docs: update content
This commit is contained in:
@@ -239,36 +239,36 @@ 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:
|
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
|
```js
|
||||||
parseHTML() {
|
parseHTML() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
tag: 'strong',
|
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:
|
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
|
```js
|
||||||
parseHTML() {
|
parseHTML() {
|
||||||
return [
|
return [
|
||||||
// <strong>
|
// <strong>
|
||||||
{
|
{
|
||||||
tag: 'strong',
|
tag: 'strong',
|
||||||
},
|
},
|
||||||
// <b>
|
// <b>
|
||||||
{
|
{
|
||||||
tag: 'b',
|
tag: 'b',
|
||||||
getAttrs: node => node.style.fontWeight !== 'normal' && null,
|
getAttrs: node => node.style.fontWeight !== 'normal' && null,
|
||||||
},
|
},
|
||||||
// <span style="font-weight: bold">
|
// <span style="font-weight: bold">
|
||||||
{
|
{
|
||||||
style: 'font-weight',
|
style: 'font-weight',
|
||||||
getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value as string) && null,
|
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.
|
This looks for `<strong>` and `<b>` tags, and any HTML tag with an inline style setting the `font-weight` to bold.
|
||||||
|
|||||||
Reference in New Issue
Block a user