Skip to content

Commit

Permalink
Paragraph docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mariosimao committed Nov 1, 2021
1 parent 79ba69d commit 32011c6
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions docs/blocks/Paragraph.md
@@ -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`.

0 comments on commit 32011c6

Please sign in to comment.