CKEditor插入文本的键盘快捷键是什么?
发布于 2018-05-28 09:59:37
CKEDITOR.plugins.add('soft-hyphen-shortcut-key', {
init: function (editor) {
var shortcutKeys = CKEDITOR.CTRL + CKEDITOR.SHIFT + 189;
editor.addCommand('insertSoftHyphen', {
exec: function (editor, data) {
editor.insertHtml('­');
}
});
editor.keystrokeHandler.keystrokes[shortcutKeys] = 'insertSoftHyphen';
}
});
此实现使用insertHtml()
方法来添加­
当用户按下组合键时,HTML实体将在光标位置指向文档。方法初始化一个新编辑器实例。<textarea name="editor">
加载我们的插件:
CKEDITOR.replace('editor', {
extraPlugins: 'soft-hyphen-shortcut-key'
});
ClassicEditor
.create(document.querySelector('#editor1'))
.then(function (editor) {
var shortcutKeys = [ 'Ctrl', 'Shift', 189 ];
var softHyphen = '\u00AD';
editor.keystrokes.set(shortcutKeys, function () {
editor.execute('input', { text: softHyphen });
});
});
tinymce.init({
selector: "#editor",
init_instance_callback: function (editor) {
editor.shortcuts.add("ctrl+shift+189", 'Insert Soft Hyphen', function () {
editor.execCommand('mceInsertContent', false, '\u00AD');
})
}
});
发布于 2018-05-28 10:53:17
tinymce.init({
selector: "#editor",
init_instance_callback: function (editor) {
editor.shortcuts.add("alt+189", 'Insert Soft Hyphen', function () {
editor.execCommand('mceInsertContent', false, '­');
})
}
});
https://stackoverflow.com/questions/-100008594
复制相似问题