我在我的summernote
工具欄中啓用了codeview
。啓用codeview時無法調用editor.insertText
以及針對自定義菜單代碼(插入自定義參數編輯器):
let event = ui.buttonGroup([
ui.button({
contents: '<span>Custom parameters</span> <span class="note-icon-caret"></span>',
tooltip: 'Custom parameters',
className: 'btn-codeview', // <== this is just to not disable the menu when codeview is enabled
data: {
toggle: 'dropdown'
}
}),
ui.dropdown({
items: ['one', 'two'],
callback: (items) => {
$(items).find('li a').on('click', (e) => {
context.invoke('editor.insertText', ` ${e.target.innerText} `);
e.preventDefault();
})
}
})
]);
它正常工作時,代碼查看被禁用(粘貼我的自定義one
並在編輯器two
PARAMS),但是當我啓用codeview
並點擊我的菜單項,它不會插入任何內容。
下面的代碼片段被調用,但沒有任何反應:
context.invoke('editor.insertText', ` ${e.target.innerText} `);
啓用代碼查看時,我怎樣才能插入我的自訂參數?
UPD:的想法是有一個簡單的切換文本模式沒有HTML一個工具欄中的按鈕,並有可用的菜單(插入編輯器中自定義的話)。
[這可能會幫助你引用這個鏈接的答案](http:// stackoverflow。 com/questions/26822724/summernote-angle-custom-button-in-toolbar/40830317#40830317) – Varsha