TinyMCE Dirty Flag is not set or is reset automatically after Editor leaving?

混江龙づ霸主 提交于 2020-02-04 04:00:26

问题


After Configuring the TinyMce Editor and some Functions I want now to Warn the User if he did changes but did not save them.
For that Iam Checking the Dirty Flag at Blur. But its always set false .

controller.js

this.$scope.tinymceOptions = {
  selector: 'textarea',
  menubar: false,
  plugins: 'save',
  save_enablewhendirty: true,
  save_onsavecallback: (editor) => {
    doing here my save stuff
  },
  setup: function(editor) {
    editor.on('dirty', () => {
      console.log('dirty woop')//if i do edits its triggered
    })
    editor.on('blur', function(e) {
      console.log(tinyMCE.activeEditor.isDirty());//its triggered but after edits it says dirty=false  
    //wanna do here some warning output as info
    });
    editor.on('change', function(e) {
      editor.setDirty(true);//seting dirty true if changes appear
      console.log(tinyMCE.activeEditor.isDirty());//dirty output  = true
    });
  },
  height: 100,
  width: 250,
  toolbar1: ' undo redo | bold underline italic',
  toolbar2: 'save'
};

Why is it always set to false if I leave the Editor after changes?
Using TinyMce 4.4.x
Angular 1.5.x
Angular-ui-TinyMce 0.0.17

Edit
It seems it is somehow reseting the Flag somewhere in a Cycle Loop? If I write something and wait more than ~1sec it is set always to false. If I write something and immediately move out the dirtyFlag is set true. How can I set the Flag Dirty by writing something and say wait till its saved be always Dirty ?

来源:https://stackoverflow.com/questions/40790328/tinymce-dirty-flag-is-not-set-or-is-reset-automatically-after-editor-leaving

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!