<script setup lang="ts">
import { ref } from "vue";

const id = ref("tab1");

let editor: any = null;

// 加载编辑器
const onLoad = (e: any) => {
  editor = e.target.contentWindow.editor;
};

// 异步加载文档
const loadDoc = () => {
  if (editor) {
    console.log("editor", editor);
    editor.loadUrl("/mock/临时医嘱单.html");
  } else {
    console.error("Editor not loaded");
  }
};
setTimeout(loadDoc, 0);

// 处理文档命令
const execCommand = (cmd: string) => {
  if (editor) {
    editor.execCommand(cmd);
  }
};
</script>

<template>
  <el-tabs v-model="id" type="card">
    <el-tab-pane label="长期医嘱" name="tab1">
      <Editor @load="onLoad" style="margin: 10px 0" />
    </el-tab-pane>
    <el-tab-pane label="临时医嘱" name="tab2">
      <Editor @load="onLoad" style="margin: 10px 0" />
    </el-tab-pane>
  </el-tabs>
</template>

<style scoped></style>
