Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79ba69d
commit 32011c6
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Paragraph block | ||
|
||
## Working with strings | ||
|
||
Creating a paragraph from a simple string: | ||
```php | ||
<?php | ||
|
||
$paragraph = Paragraph::fromString("Simple paragraph."); | ||
$paragraph->toString(); // "Simple paragraph." | ||
``` | ||
|
||
Or creating an empty paragraph: | ||
```php | ||
<?php | ||
|
||
$paragraph = Paragraph::create(); | ||
$paragraph->toString(); // empty string | ||
``` | ||
|
||
## Working with `RichText` objects | ||
|
||
```php | ||
<?php | ||
|
||
// "Simple text" will be bold and italic | ||
$text = RichText::createText("Simple text")->bold()->italic(); | ||
|
||
$paragraph = Paragraph::create()->appendText($text); | ||
``` | ||
|
||
While working with multiple texts: | ||
|
||
```php | ||
$text = [ | ||
RichText::createText("Paragraphs can be "), | ||
RichText::createText("bold")->bold(), | ||
RichText::createText(", "), | ||
RichText::createText("underlined")->underline(), | ||
RichText::createText(" and much more!"), | ||
]; | ||
|
||
$paragraph = Paragraph::create()->withText(...$text); | ||
``` | ||
|
||
Note that `withText()` will replace the text on a new instance of `Paragraph`. |