diff --git a/README.md b/README.md index 5917da7..e3e63e0 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ class Blot { Implementation for a Blot representing a link, which is a parent, inline scoped, and formattable. ```typescript -import { InlineBlot, register } from 'parchment'; +import { InlineBlot } from 'parchment'; class LinkBlot extends InlineBlot { static blotName = 'link'; @@ -144,8 +144,6 @@ class LinkBlot extends InlineBlot { return formats; } } - -register(LinkBlot); ``` Quill also provides many great example implementations in its [source code](https://github.com/quilljs/quill/tree/develop/packages/quill/src/formats). @@ -196,10 +194,9 @@ The implementation for Attributors is surprisingly simple, and its [source code] Uses a plain attribute to represent formats. ```js -import { Attributor, register } from 'parchment'; +import { Attributor } from 'parchment'; let Width = new Attributor('width', 'width'); -register(Width); let imageNode = document.createElement('img'); @@ -215,10 +212,9 @@ console.log(imageNode.outerHTML); // Will print Uses a class name pattern to represent formats. ```js -import { ClassAttributor, register } from 'parchment'; +import { ClassAttributor } from 'parchment'; let Align = new ClassAttributor('align', 'blot-align'); -register(Align); let node = document.createElement('div'); Align.add(node, 'right'); @@ -230,12 +226,11 @@ console.log(node.outerHTML); // Will print
Uses inline styles to represent formats. ```js -import { StyleAttributor, register } from 'parchment'; +import { StyleAttributor } from 'parchment'; let Align = new StyleAttributor('align', 'text-align', { whitelist: ['right', 'center', 'justify'], // Having no value implies left align }); -register(Align); let node = document.createElement('div'); Align.add(node, 'right'); @@ -244,28 +239,69 @@ console.log(node.outerHTML); // Will print
{ + const blot = myRegistry.find(event.target, true) + if (blot === myRegistry.query('link')) { + // Opens the link. + } +}) ```