參考:
- https://www.gushiciku.cn/pl/pTP3/zh-tw
- https://stackoverflow.com/questions/56056893/how-to-disable-copy-paste-in-tinymce
- summernote也是類似的作法:
- https://www.796t.com/post/MWJycGc=.html
- 註冊事件:
- editor.on('paste',function(){...});
語法:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); |
沒有留言:
張貼留言