slab / parchment

Generalized state model for rich-text editors to interface with browser DOM
BSD 3-Clause "New" or "Revised" License
637 stars 146 forks source link

Adding a custom Blot #122

Open IvanFarkas opened 1 year ago

IvanFarkas commented 1 year ago

Adding a custom Blot

The Example instructs

import Parchment from 'parchment';

class LinkBlot extends Parchment.Inline {

but Parchment.Inline does not exist, InlineBlot does from here as class InlineBlot extends ParentBlot implements Formattable

import { InlineBlot } from 'parchment';

class CustomInlineBlot extends InlineBlot {

Also, this does not work as in the example.

Parchment.register(LinkBlot);

Getting error

Property 'register' does not exist on type 'typeof import(".../node_modules/parchment/dist/typings/parchment")'
64jcl commented 1 year ago

Was not able to get the example to work either where it extends Parchment.Inline. Only way I got custom blots to work was to extend Parchment.Embed. But perhaps my problem is something else. Also need to register this using Quill.register - Parchment.register does nothing.