【发布时间】:2017-09-19 11:48:25
【问题描述】:
在 wordpress 管理端 tinymce 编辑器中默认显示禁用超链接按钮。当我们从编辑器中选择任何文本时,链接/取消链接按钮将变为活动状态。我想要确切的事件。如何在内容文本选择上启用我的自定义按钮?并且还需要在取消选择文本时禁用。
谁能帮我解决这个问题?
谢谢
【问题讨论】:
标签: wordpress tinymce customization
在 wordpress 管理端 tinymce 编辑器中默认显示禁用超链接按钮。当我们从编辑器中选择任何文本时,链接/取消链接按钮将变为活动状态。我想要确切的事件。如何在内容文本选择上启用我的自定义按钮?并且还需要在取消选择文本时禁用。
谁能帮我解决这个问题?
谢谢
【问题讨论】:
标签: wordpress tinymce customization
试试这个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 );
});
【讨论】: