Skip to content

Commit

Permalink
Move create docs inline
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Feb 26, 2019
1 parent 2c82b83 commit 34e13eb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
15 changes: 0 additions & 15 deletions packages/rich-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,6 @@ create( {

Create a RichText value from an `Element` tree (DOM), an HTML string or a plain text string, with optionally a `Range` object to set the selection. If called without any arguments, an empty value will be created. If `multilineTag` is provided, any content of direct children whose type matches `multilineTag` will be separated by a line separator.

A value will have the following shape, which you are strongly encouraced not to modify without the use of helper functions:

```js
{
text: string,
formats: Array,
objects: Array,
lines: Array,
?start: number,
?end: number,
}
```

As you can see, text and formatting are separated. `text` holds the text, including any replacement characters for objects and lines. `formats`, `objects` and `lines` are all sparse arrays of the same length as `text`. It holds information about the formatting at the relevant text indices. Finally `start` and `end` state which text indices are selected. They are only provided if a `Range` was given.

### toHTMLString

```js
Expand Down
21 changes: 21 additions & 0 deletions packages/rich-text/src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,27 @@ function toFormat( { type, attributes } ) {
* `multilineTag` will be separated by two newlines. The optional functions can
* be used to filter out content.
*
* A value will have the following shape, which you are strongly encouraced not
* to modify without the use of helper functions:
*
* ```js
* {
* text: string,
* formats: Array,
* objects: Array,
* lines: Array,
* ?start: number,
* ?end: number,
* }
* ```
*
* As you can see, text and formatting are separated. `text` holds the text,
* including any replacement characters for objects and lines. `formats`,
* `objects` and `lines` are all sparse arrays of the same length as `text`. It
* holds information about the formatting at the relevant text indices. Finally
* `start` and `end` state which text indices are selected. They are only
* provided if a `Range` was given.
*
* @param {?Object} $1 Optional named argements.
* @param {?Element} $1.element Element to create value from.
* @param {?string} $1.text Text to create value from.
Expand Down

0 comments on commit 34e13eb

Please sign in to comment.