2021年7月6日 星期二

[筆記]TinyMCE/SummerNote純文字貼上

參考:

  1. https://www.gushiciku.cn/pl/pTP3/zh-tw
  2. https://stackoverflow.com/questions/56056893/how-to-disable-copy-paste-in-tinymce
  3. summernote也是類似的作法:
    1. https://www.796t.com/post/MWJycGc=.html
  4. 註冊事件:
    1. editor.on('paste',function(){...});


語法:
tinymce.init({
selector: 'textarea#editor',
setup: function (editor) {
editor.on('paste',function(e){
//貼上後的事件
var text = null;
//取得剪貼簿上面的值
if(e.clipboardData && e.setData) {
text = e.clipboardData.getData('text');// IE
} else {
text = (e.originalEvent || e).clipboardData.getData('text/plain') || prompt('在這裡輸入文字');
}
//插入文字
editor.execCommand("insertText", false, text);
//取消原先的貼上動作
e.preventDefault();
});
},
menubar: false
});

沒有留言:

張貼留言