微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

TinyMCE v4自定义插件对话框更新提交按钮

如何解决TinyMCE v4自定义插件对话框更新提交按钮

出于无法控制的原因,我们使用TinyMCE v4而不是v5,并且我试图添加一个自定义插件,该插件会插入看起来像链接内容,但这是自定义<resource>标签

打开对话框如下:

  var openDialog = function () {

    var content = editor.selection.getContent();

    var selectList = [
      {
        value: undefined,text: '--Choose One--',disabled: true
      }
    ];
    // add some more to the select list

    return editor.windowManager.open({
      title: 'Link resource',size: 'large',body: createBody(selectList,content),buttons: createButtons(),onSubmit: function (api) {
        editor.insertContent('XXX');
        editor.windowManager.close();
      }
    });
  };

  var createBody = function(selectList,content) {
    return ([
      {
        type: 'listBox',name: 'resources',label: 'Select resource',size: 1,value: undefined,values: selectList,onselect: function(evt) {
          console.log(evt);
        }
      },{
        type: 'textBox',name: 'title',label: 'Link Text',placeholder: 'Link Text',value: content
      }
    ]);
  };

  var createButtons = function() {
    return ([
      {
        text: 'Insert Content',subtype: 'primary',onclick: 'submit',disabled: true
      },{
        text: 'Cancel',onclick: 'close'
      }
    ]);
  };

如何在列表框的onselect处理程序中更改提交按钮的禁用状态?我发现editor.windowManager.getwindows()[0].features.buttons[1]获得了按钮,但是我似乎无法更改其禁用状态。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。