Silverstripe 4 CMS 的 TinyMCE 插件

问题描述 投票:0回答:0

我正在为 Tinymce 开发一个插件,以便在 Silverstripe 4 中使用。

这是一个脚注-创建具有连续数字的

<sup>
标签的插件。

脚注 - 文本存储在有序列表中编辑器内容末尾的 div (.footnoteContainer) 中。

脚注的创建和编辑是在单词本身上处理的(edit Link | delete Link)。有一个窗口(editor.windowManager.open)。

我正在为这个功能苦苦挣扎:

我试图阻止用户在按下退格键时删除 .footnoteContainer 或其内容。如果选择了容器本身,那是有效的。但如果

<li>
脚注 - 容器中的文本
</li>
被选中,它就不起作用。

这就是我的功能(有很多尝试和错误)......

请看:

        editor.on('keydown', function (e) {
            if (e.keyCode == 8) { // backspace / delete
                

                var selection = editor.selection.getSel();
                    console.log('selection = ' + selection);
                var target = editor.selection.getNode(); //e.target;
                    console.log('target = ' + target.className);
                var footnoteContainer = editor.dom.select('.footnoteContainer')[0];
                var fNC = editor.dom.select('.footnoteContent')[0];
                var fND = editor.dom.select('.fndiv')[0];
                
                var isFootnoteContainer = target === footnoteContainer || footnoteContainer.contains(target) || footnoteContainer.contains(fNC) || footnoteContainer.contains(fND);
                var isContent = target === fNC;
                var isDiv = target === fND;

                if (isFootnoteContainer || isContent || isDiv) {
                    console.log('it is fnContainer!');
                    e.preventDefault();
                    return false;
                }
            }
        });

和脚注 html :

    <div class="footnoteContainer"><br />
 
  <ol id="fNol">
    <li>
      <div class="fndiv"><a id="1681202707036" class="footnoteContent"></a><a href="#1681202707036_back">Footnotetext 1</a></div>
    </li>
    <li>
      <div class="fndiv"><a id="1681215616710" class="footnoteContent"></a><a href="#1681215616710_back">Footnotetext 2</a></div>
    </li>
  </ol>
    
</div>

按退格键我如何解决

<li>
-标签或
<div>
-标签或
<a>
标签?

javascript tinymce silverstripe-4
© www.soinside.com 2019 - 2024. All rights reserved.