弹出窗口中的 Tinymce 插入/编辑图像字段在 vuetify 的对话框中不可编辑(聚焦)

Bal*_*tra 4 javascript tinymce-4 vue.js vuetify.js

我知道在引导模式下启用 tinymce 弹出窗口中的焦点所需的调整。但目前我正在使用 vuetify 对话框。这似乎并没有关注tinymce的弹出字段。 焦点在 tinymce 对话框后面的弹出窗口中

我已经解决了这个问题,但它在上下文中不起作用,无法在不可编辑中vuetify TinyMCE 4 links plugin modal

下面是我的代码,我删除了一些方法只是为了清理,并保留了我在挂载事件和编辑器初始化中尝试过的基本内容。

  <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.
Run Code Online (Sandbox Code Playgroud)

Bal*_*tra 9

从 vuetify 2.0 开始,有一个新的道具“retain-focus”,您可以将其设置为 false 以解决上述问题。

<v-dialog :retain-focus="false">
Run Code Online (Sandbox Code Playgroud)

默认情况下,选项卡焦点将返回到对话框的第一个子级。当使用需要焦点的外部工具时禁用此功能,例如 TinyMCE 或 vue-clipboard。

编辑: 这是保留焦点道具实现 GitHub 的链接:https : //github.com/vuetifyjs/vuetify/issues/6892


小智 5

修改v-dialog的z-index:

当前的:

z-index: 202
Run Code Online (Sandbox Code Playgroud)

修改的:

<style>
.v-dialog__content {z-index: 203 !important;}
</style>
Run Code Online (Sandbox Code Playgroud)

不要忘记!重要的是要优先考虑风格。