有没有办法在对话框tinymce中更改自定义输入的值动态

时间:2019-05-02 10:19:05

标签: javascript laravel vue.js tinymce

我正在使用tinymce4,我想以编程方式在对话框内设置textarea的值,我该怎么办!

这是我以前实现的一种方式,我有两个对话框,一个调用addMark,另一个调用addText,当我按下按钮addMark时,它必须调用api,并且此api设置了对通用变量的响应,并在设置后将值设置为通用变量,然后打开对话框addText,其中已设置了我已设置的通用变量值。

const config = {
  selector: "#editor",
  directionality: "rtl",
  branding: false,
  height: 500,
  theme: "modern",
  init_instance_callback:function(){

     const dialogConfig = {
        title: 'إضافة نص',
        type:'panel',
        body: [{
          type: 'container',
          label  : 'الرسالة',
          layout: 'flow',
          items: [
            {
              icon: 'unlock',
              type: 'textbox',
              name: 'my_textbox',
              label: 'textbox',
              value: textResponse,
              placeholder:'أكتب تعليقك هنا',
              multiline: true,
              autofocus: true,
            },
          ]
        }],
        initialdata: {
          my_textbox: textResponse
        },
        onsubmit: function(e) {

          // Do stuff
        }
    };

     const dialogAddMarker = {
        title: 'إضافة علامة',
        body: [{
          type: 'panel',
          layout: 'flow',
          items: [

            ],

          },
          {
            type: 'button',
            text: '+/-',
            name: 'alpha-button',
            icon: 'toolbarplugin',
            onclick : function(e) {


           }
          },
          {
            type: 'button',
            text: 'addText',
            name: 'alpha-button2',
            icon: 'toolbarplugin',
            // disabled:true,
            onclick : function(e) {
              alert(textResponse);
              console.log(e);
              editor.windowManager.open(dialogConfig);

             api.getHighlighComment(textId);



           }
          },
        ],
        buttons:[],
        // onsubmit: function(e) {

        //   alert(e.data.my_textbox)
        // },

    };


     editor.on('click', function (e) {

        // here is the thing
        dialogConfig.my_textbox = "my new text";
        editor.windowManager.open(dialogMarker);
    } 

    });
  },

}

0 个答案:

没有答案