2017-05-27 52 views
1

我試圖在QuillJS中創建一個自定義類屬性。 我走了這麼遠:在QuillJS中創建自定義類屬性

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

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

但是當試圖:

this.quillEditor.format('mark', 'MarkThisHere'); 

我得到:

錯誤類型錯誤:BlotClass.create不是一個函數

我是什麼做錯了?

回答

3

適合我這個example

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'); 
相關問題