Tinymce insert/edit image fields on pop up are not editable(focused) inside vuetify's dialog

删除回忆录丶 提交于 2020-12-10 08:45:28

问题


I am aware with the tweaks required for enabling focus inside the tinymce pop up when in bootstrap modal. But currently I am working with a vuetify dialog. Which does'nt seem to focus the pop up fields of tinymce.

I have gone through this question but it does not work in context to vuetify TinyMCE 4 links plugin modal in not editable

Below is my code I have removed some methods just for clean up and have kept basic things that I have tried in mounted event & editor init.

  <no-ssr placeholder="Loading Editor..">
    <tinymce
      id="content"
      :toolbar2="toolbar2"
      :toolbar1="type=='BASIC'?'':toolbar1"
      :plugins="plugins"
      :other_options="other_options"
      v-model="content"
      @input="handleInput"
      v-on:editorInit="initCallBack"
    />
  </no-ssr>
</template>

<script>
//https://dyonir.github.io/vue-tinymce-editor/?en_US
export default {
  props: {
    value: { type: String },
    type: { type: String }
  },
  data() {
    return {
      content: this.value,
      plugins: this.getPlugins(),
      toolbar2: "",
      toolbar1: this.getToolbar1(),
      other_options: {
        menubar: this.getMenubar(),
        height: "320",
        file_browser_callback: this.browseFile,
        auto_focus: '#content'
      }
    };
  },
  mounted(event) {
    // window.tinyMCE.activeEditor.focus();
    // window.tinymce.editors["content"]
    console.log(this.$el, event);
    let list=document.getElementsByClassName("mce-textbox");
    for (let index = 0; index < list.length; ++index) {
    list[index].setAttribute("tabindex", "-1");
}
    //     if ((event.target).closest(".mce-window").length) {
    //     e.stopImmediatePropagation();
    // }
    // this.$refs.refToElement ..$el.focus())
    // this.el.addEventListener('focusin', e => e.stopPropagation());
  },
  methods: {
    handleInput(e) {
      this.$emit("input", this.content);
    },
    initCallBack(e) {
      window.tinymce.editors["content"].setContent(this.value);
      window.tinymce.editors["content"].getBody().focus();
// console.log(this.$refs);
//       const focusable = this.$refs.content.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')
//         focusable.length && focusable[0].focus()

      document.getElementById("content").addEventListener("onfocusin", console.log("fucssed"));
      // tinymce.activeEditor.fire("focus");

this.$el.querySelector(".mce-tinymce").addEventListener('focusin', e =>{ e.stopImmediatePropagation();console.log('event',e)});

      const element = this.$el.querySelector(".mce-tinymce");
      let _this=this;
      if (element)
        this.$nextTick(() => {
          element.focus();
          console.log("FOCUSED",element,_this);
          // element.stopImmediatePropagation();
        });
      // window.tinyMCE.activeEditor.focus();

      //   console.log(this.$el,e);
      //     if ((e).closest(".mce-window").length) {
      //     e.stopImmediatePropagation();
      // }
    }
};
</script>```


I am using the component : https://github.com/dyonir/vue-tinymce-editor
But fields of the pop are not getting focussed/edited.

回答1:


From vuetify 2.0 onwards there is a new prop 'retain-focus' which you can set to false in order to fix the above issue.

<v-dialog :retain-focus="false">

Tab focus will return to the first child of the dialog by default. Disable this when using external tools that require focus such as TinyMCE or vue-clipboard.

Edit: Here is the link to retain-focus prop implementation GitHub: https://github.com/vuetifyjs/vuetify/issues/6892




回答2:


Modify the z-index of v-dialog:

Current:

z-index: 202

Modified:

<style>
.v-dialog__content {z-index: 203 !important;}
</style>

Do not forget the !important to give priority to style.



来源:https://stackoverflow.com/questions/55780976/tinymce-insert-edit-image-fields-on-pop-up-are-not-editablefocused-inside-vuet

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