docs: update content

This commit is contained in:
Philipp Kühn
2021-04-20 18:31:56 +02:00
parent 52fe19fce3
commit d14942ecbf

View File

@@ -239,19 +239,19 @@ renderHTML({ HTMLAttributes }) {
The `parseHTML()` function tries to load the editor document from HTML. The function gets the HTML DOM element passed as a parameter, and is expected to return an object with attributes and their values. Here is a simplified example from the [`Bold`](/api/marks/bold) mark:
```js
parseHTML() {
parseHTML() {
return [
{
tag: 'strong',
},
]
},
},
```
This defines a rule to convert all `<strong>` tags to `Bold` marks. But you can get more advanced with this, here is the full example from the extension:
```js
parseHTML() {
parseHTML() {
return [
// <strong>
{
@@ -268,7 +268,7 @@ This defines a rule to convert all `<strong>` tags to `Bold` marks. But you can
getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value as string) && null,
},
]
},
},
```
This looks for `<strong>` and `<b>` tags, and any HTML tag with an inline style setting the `font-weight` to bold.