From c2ca5103d428cc341c00f6626eb89976f77205ee Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Thu, 9 Dec 2021 19:18:36 +0100 Subject: [PATCH] docs: add some more information to the parseHTML docs, fix #1860 --- docs/guide/custom-extensions.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/guide/custom-extensions.md b/docs/guide/custom-extensions.md index f86a669ba..8101d917c 100644 --- a/docs/guide/custom-extensions.md +++ b/docs/guide/custom-extensions.md @@ -333,10 +333,14 @@ parseHTML() { }, ``` -This looks for `` and `` tags, and any HTML tag with an inline style setting the `font-weight` to bold. +This checks for `` and `` tags, and any HTML tag with an inline style setting the `font-weight` to bold. As you can see, you can optionally pass a `getAttrs` callback, to add more complex checks, for example for specific HTML attributes. The callback gets passed the HTML DOM node, except when checking for the `style` attribute, then it’s the value. +You are wondering what’s that `&& null` doing? [ProseMirror expects `null` or `undefined` if the check is successful.](https://prosemirror.net/docs/ref/version/0.18.0.html#model.ParseRule.getAttrs) + +[Pass `priority` to a rule](https://prosemirror.net/docs/ref/version/0.18.0.html#model.ParseRule.priority) to resolve conflicts with other extensions, for example if you build a custom extension which looks for paragraphs with a class attribute, but you already use the default paragraph extension. + #### Using getAttrs The `getAttrs` function you’ve probably noticed in the example has two purposes: