【问题标题】:Wordpress Tinymce editor on content text selection event内容文本选择事件上的 Wordpress Tinymce 编辑器
【发布时间】:2017-09-19 11:48:25
【问题描述】:

在 wordpress 管理端 tinymce 编辑器中默认显示禁用超链接按钮。当我们从编辑器中选择任何文本时,链接/取消链接按钮将变为活动状态。我想要确切的事件。如何在内容文本选择上启用我的自定义按钮?并且还需要在取消选择文本时禁用。

谁能帮我解决这个问题?

谢谢

【问题讨论】:

    标签: wordpress tinymce customization


    【解决方案1】:

    试试这个Tutorial

    这是不久前分享给我的,当时我有一个类似的问题。
    正如其他用户所提到的,我应该包含代码以防链接中断,这应该是可能对您有所帮助的部分

        // Enable/disable the button on the node change event
        editor.onNodeChange.add(function( editor ) {
            // Get selected text, and assume we'll disable our button
            var selection = editor.selection.getContent();
            var disable = true;
    
            // If we have some text selected, don't disable the button
            if ( selection ) {
                disable = false;
            }
            // Define whether our button should be enabled or disabled
            editor.controlManager.setDisabled( 'custom_class', disable );
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-27
      • 2011-12-06
      • 1970-01-01
      相关资源
      最近更新 更多