关于内容文本选择事件的Wordpress Tinymce编辑

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

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

谁可以帮我这个事?

谢谢

wordpress tinymce customization
1个回答
0
投票

试试这个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 );
    });
© www.soinside.com 2019 - 2024. All rights reserved.