Prechádzať zdrojové kódy

fix: 全局注入undo/redo图标到Quill icons映射,使snow主题能渲染图标

Developer 2 týždňov pred
rodič
commit
eee8710add
2 zmenil súbory, kde vykonal 8 pridanie a 9 odobranie
  1. BIN
      dist.zip
  2. 8 9
      src/components/editor/index.vue

BIN
dist.zip


+ 8 - 9
src/components/editor/index.vue

@@ -13,17 +13,16 @@ import 'quill/dist/quill.core.css'
 import 'quill/dist/quill.snow.css'
 import 'quill/dist/quill.bubble.css'
 import {
-    quillEditor
+    quillEditor,
+    Quill
 } from 'vue-quill-editor'
-// Quill 1.3.6 的 ui/icons.js 不含 undo/redo,需手动注入 SVG
-const undoIcon = '<svg viewBox="0 0 18 18"><polygon class="ql-fill ql-stroke" points="6 10 4 12 2 10 2 14 6 14 4 12 6 10 8 7 14 7 14 11 16 11 16 4 8 4 6 7"></polygon></svg>'
-const redoIcon = '<svg viewBox="0 0 18 18"><polygon class="ql-fill ql-stroke" points="12 10 14 12 16 10 16 14 12 14 14 12 12 10 10 7 4 7 4 11 2 11 2 4 10 4 12 7"></polygon></svg>'
+// Quill 1.3.6 的 ui/icons.js 不含 undo/redo,需手动注入到全局 icons 映射,
+// 否则 snow 主题的 buildButtons 会因 icons[name] 为 null 跳过按钮 innerHTML 的渲染。
+const icons = Quill.import('ui/icons')
+icons['undo'] = '<svg viewbox="0 0 18 18"><polygon class="ql-fill ql-stroke" points="6 10 4 12 2 10 2 14 6 14 4 12 6 10 8 7 14 7 14 11 16 11 16 4 8 4 6 7"></polygon></svg>'
+icons['redo'] = '<svg viewbox="0 0 18 18"><polygon class="ql-fill ql-stroke" points="12 10 14 12 16 10 16 14 12 14 14 12 12 10 10 7 4 7 4 11 2 11 2 4 10 4 12 7"></polygon></svg>'
 const toolbarOptions = [
-    [{
-        'undo': undoIcon
-    }, {
-        'redo': redoIcon
-    }], // 撤销,重做
+    ['undo', 'redo'], // 撤销,重做
     ['bold', 'italic', 'underline', 'strike'], // 加粗,斜体,下划线,删除线
     ['blockquote', 'code-block'], //引用,代码块
     [{