在QuillJS中创建自定义类属性

ami*_*mit 3 quill

我正在尝试在QuillJS中创建一个自定义类属性.我到目前为止:

let config = {
  scope: Parchment.Scope.BLOCK,
};

let MClass = new Parchment.Attributor.Class('mark', 'dom-mark', config);
Quill.register(MClass,true)
Run Code Online (Sandbox Code Playgroud)

但在尝试时:

this.quillEditor.format('mark', 'MarkThisHere');
Run Code Online (Sandbox Code Playgroud)

我明白了:

错误TypeError:BlotClass.create不是函数

我究竟做错了什么?

小智 6

在这个例子中对我有用.

Parchment = Quill.import('parchment');

let config = {
  scope: Parchment.Scope.BLOCK,
};

let MClass = new Parchment.Attributor.Class('mark', 'dom-mark', config);
Quill.register(MClass,true)

var quill = new Quill('#editor-container', {
  modules: {
    toolbar: [
      [{ header: [1, 2, false] }],
      ['bold', 'italic', 'underline'],
      ['image', 'code-block']
    ]
  },
  placeholder: 'Compose an epic...',
  theme: 'snow'  // or 'bubble'
});

quill.format('mark', 'MarkThisHere');
Run Code Online (Sandbox Code Playgroud)