我有这个旧代码
// myenter.js, enter key is binded to insertParagraph command.
$.summernote.addPlugin({
name : 'myenter',
events : {
// redefine insertParagraph
'insertParagraph' : function(event, editor, layoutInfo) {
//you can use summernote enter
//layoutInfo.holder().summernote('insertParagraph');
// also you can use your enter key
layoutInfo.holder().summernote('insertNode', document.createTextNode("\r\n"));
// to stop enter key
//e.preventDefault();
}
}
});
$('.summernote').summernote({ height : 300 });
但现在添加插件的方法已经改变,我希望通过此代码使用新版本的此功能
$.extend($.summernote.plugins, {
'myenter': function (context) {
console.log('myenter');
}
});
但它根本没有被调用
我曾尝试通过以下方式获得相同的功能
summernote.onEnter
和
summernote.keyPress
但它给出了错误..
最佳答案
$.extend($.summernote.plugins, {
'brenter': function (context) {
this.events = {
'summernote.enter': function (we, e) {
// insert 2 br tags (if only one br tag is inserted the cursor won't go to the next line)
document.execCommand('insertHTML', false, '<br><br>');
e.preventDefault();
}
};
}
}
关于summernote - 如何在summernote中更改输入行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37567346/