Procházet zdrojové kódy

规则详情编辑进入默认展示python代码高亮

zhangliang2 před 2 roky
rodič
revize
1c8bec60e5
1 změnil soubory, kde provedl 11 přidání a 0 odebrání
  1. 11 0
      src/views/sceneLibrary/components/editor.vue

+ 11 - 0
src/views/sceneLibrary/components/editor.vue

@@ -18,6 +18,7 @@
 
 <script>
 import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
+import { SlateTransforms } from "@wangeditor/editor";
 import "@wangeditor/editor/dist/css/style.css"; // 引入 css
 
 export default {
@@ -55,6 +56,16 @@ export default {
         content(newVal, oldVal) {
             if (newVal && newVal != oldVal) {
                 this.html = `<pre><code>${newVal}</code></pre>`;
+
+                this.$nextTick(() => {
+                    SlateTransforms.setNodes(
+                        this.editor,
+                        { language: "python" },
+                        {
+                            type: "code",
+                        }
+                    );
+                });
             }
         },
     },