顯示具有 TinyMCE 標籤的文章。 顯示所有文章
顯示具有 TinyMCE 標籤的文章。 顯示所有文章

2021年7月6日 星期二

[筆記]TinyMCE自訂快速鍵

                  editor.addShortcut(

                    'meta+v', '純文字貼上', function (e) {

                        editor.insertContent('<b>請勿使用Ctrl+V貼上</b>');//寫提醒文字

                        editor.execCommand('mcePasteText',false); //不處理貼上的文字

                    });             

                    

[筆記]TinyMCE相關貼上禁止事件

                plugins: [

                    "advlist autolink lists link image charmap print preview anchor",

                    "searchreplace visualblocks code fullscreen",

                    "insertdatetime media table contextmenu paste"

                ],

                paste_preprocess: function (plugin, args) {

                    console.log("Attempted to paste: ", args.content);

                    // replace copied text with empty string

                    args.content = '禁止貼上';                   

                }


  • plugins:禁止右鍵選單。(無法貼上)
  • 按鍵貼上:
    • Ctrl+V or Ctrl+Shift+V 。
    • 貼上後觸發事件(paste_preprocess)。
    • 這邊可以實作貼上後觸發警告或其它。



[筆記]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(){...});


語法: