@opentiny/fluent-editor 4.0.0-beta.1 → 4.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/es/config/i18n/en-us.es.js +0 -2
  2. package/es/config/i18n/en-us.es.js.map +1 -1
  3. package/es/config/i18n/zh-cn.es.js +0 -2
  4. package/es/config/i18n/zh-cn.es.js.map +1 -1
  5. package/es/fluent-editor.es.js +0 -6
  6. package/es/fluent-editor.es.js.map +1 -1
  7. package/es/index.es.js +0 -4
  8. package/es/index.es.js.map +1 -1
  9. package/es/modules/index.es.js +0 -4
  10. package/es/modules/index.es.js.map +1 -1
  11. package/es/modules/shortcut-key/index.es.js +0 -16
  12. package/es/modules/shortcut-key/index.es.js.map +1 -1
  13. package/es/ui/icons.config.es.js +0 -4
  14. package/es/ui/icons.config.es.js.map +1 -1
  15. package/es/ui/icons.es.js +2 -4
  16. package/es/ui/icons.es.js.map +1 -1
  17. package/lib/config/i18n/en-us.cjs.js +0 -2
  18. package/lib/config/i18n/en-us.cjs.js.map +1 -1
  19. package/lib/config/i18n/zh-cn.cjs.js +0 -2
  20. package/lib/config/i18n/zh-cn.cjs.js.map +1 -1
  21. package/lib/fluent-editor.cjs.js +2 -8
  22. package/lib/fluent-editor.cjs.js.map +1 -1
  23. package/lib/index.cjs.js +5 -9
  24. package/lib/index.cjs.js.map +1 -1
  25. package/lib/modules/index.cjs.js +5 -9
  26. package/lib/modules/index.cjs.js.map +1 -1
  27. package/lib/modules/shortcut-key/index.cjs.js +0 -16
  28. package/lib/modules/shortcut-key/index.cjs.js.map +1 -1
  29. package/lib/ui/icons.cjs.js +1 -3
  30. package/lib/ui/icons.cjs.js.map +1 -1
  31. package/lib/ui/icons.config.cjs.js +0 -4
  32. package/lib/ui/icons.config.cjs.js.map +1 -1
  33. package/package.json +1 -3
  34. package/types/config/i18n/en-us.d.ts +0 -2
  35. package/types/config/i18n/zh-cn.d.ts +0 -2
  36. package/types/config/types/editor-modules.interface.d.ts +0 -4
  37. package/types/modules/index.d.ts +0 -2
  38. package/types/ui/icons.config.d.ts +0 -2
  39. package/es/modules/ai/constants.es.js +0 -50
  40. package/es/modules/ai/constants.es.js.map +0 -1
  41. package/es/modules/ai/icons.es.js +0 -319
  42. package/es/modules/ai/icons.es.js.map +0 -1
  43. package/es/modules/ai/index.es.js +0 -670
  44. package/es/modules/ai/index.es.js.map +0 -1
  45. package/es/modules/flow-chart/config-utils.es.js +0 -102
  46. package/es/modules/flow-chart/config-utils.es.js.map +0 -1
  47. package/es/modules/flow-chart/formats/flow-chart-blot.es.js +0 -369
  48. package/es/modules/flow-chart/formats/flow-chart-blot.es.js.map +0 -1
  49. package/es/modules/flow-chart/i18n/en-us.es.js +0 -30
  50. package/es/modules/flow-chart/i18n/en-us.es.js.map +0 -1
  51. package/es/modules/flow-chart/i18n/index.es.js +0 -12
  52. package/es/modules/flow-chart/i18n/index.es.js.map +0 -1
  53. package/es/modules/flow-chart/i18n/zh-cn.es.js +0 -30
  54. package/es/modules/flow-chart/i18n/zh-cn.es.js.map +0 -1
  55. package/es/modules/flow-chart/icons.es.js +0 -27
  56. package/es/modules/flow-chart/icons.es.js.map +0 -1
  57. package/es/modules/flow-chart/index.es.js +0 -45
  58. package/es/modules/flow-chart/index.es.js.map +0 -1
  59. package/es/modules/flow-chart/modules/context-menu.es.js +0 -184
  60. package/es/modules/flow-chart/modules/context-menu.es.js.map +0 -1
  61. package/es/modules/flow-chart/modules/control-panel.es.js +0 -286
  62. package/es/modules/flow-chart/modules/control-panel.es.js.map +0 -1
  63. package/es/modules/flow-chart/modules/custom-resize-action.es.js +0 -150
  64. package/es/modules/flow-chart/modules/custom-resize-action.es.js.map +0 -1
  65. package/es/modules/mind-map/config-utils.es.js +0 -108
  66. package/es/modules/mind-map/config-utils.es.js.map +0 -1
  67. package/es/modules/mind-map/formats/mind-map-blot.es.js +0 -356
  68. package/es/modules/mind-map/formats/mind-map-blot.es.js.map +0 -1
  69. package/es/modules/mind-map/i18n/en-us.es.js +0 -29
  70. package/es/modules/mind-map/i18n/en-us.es.js.map +0 -1
  71. package/es/modules/mind-map/i18n/index.es.js +0 -12
  72. package/es/modules/mind-map/i18n/index.es.js.map +0 -1
  73. package/es/modules/mind-map/i18n/zh-cn.es.js +0 -29
  74. package/es/modules/mind-map/i18n/zh-cn.es.js.map +0 -1
  75. package/es/modules/mind-map/icons.es.js +0 -45
  76. package/es/modules/mind-map/icons.es.js.map +0 -1
  77. package/es/modules/mind-map/index.es.js +0 -56
  78. package/es/modules/mind-map/index.es.js.map +0 -1
  79. package/es/modules/mind-map/modules/context-menu.es.js +0 -128
  80. package/es/modules/mind-map/modules/context-menu.es.js.map +0 -1
  81. package/es/modules/mind-map/modules/control-panel.es.js +0 -425
  82. package/es/modules/mind-map/modules/control-panel.es.js.map +0 -1
  83. package/es/modules/mind-map/modules/custom-resize-action.es.js +0 -161
  84. package/es/modules/mind-map/modules/custom-resize-action.es.js.map +0 -1
  85. package/flow-chart.css +0 -185
  86. package/lib/modules/ai/constants.cjs.js +0 -50
  87. package/lib/modules/ai/constants.cjs.js.map +0 -1
  88. package/lib/modules/ai/icons.cjs.js +0 -319
  89. package/lib/modules/ai/icons.cjs.js.map +0 -1
  90. package/lib/modules/ai/index.cjs.js +0 -670
  91. package/lib/modules/ai/index.cjs.js.map +0 -1
  92. package/lib/modules/flow-chart/config-utils.cjs.js +0 -102
  93. package/lib/modules/flow-chart/config-utils.cjs.js.map +0 -1
  94. package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js +0 -369
  95. package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js.map +0 -1
  96. package/lib/modules/flow-chart/i18n/en-us.cjs.js +0 -30
  97. package/lib/modules/flow-chart/i18n/en-us.cjs.js.map +0 -1
  98. package/lib/modules/flow-chart/i18n/index.cjs.js +0 -12
  99. package/lib/modules/flow-chart/i18n/index.cjs.js.map +0 -1
  100. package/lib/modules/flow-chart/i18n/zh-cn.cjs.js +0 -30
  101. package/lib/modules/flow-chart/i18n/zh-cn.cjs.js.map +0 -1
  102. package/lib/modules/flow-chart/icons.cjs.js +0 -27
  103. package/lib/modules/flow-chart/icons.cjs.js.map +0 -1
  104. package/lib/modules/flow-chart/index.cjs.js +0 -45
  105. package/lib/modules/flow-chart/index.cjs.js.map +0 -1
  106. package/lib/modules/flow-chart/modules/context-menu.cjs.js +0 -184
  107. package/lib/modules/flow-chart/modules/context-menu.cjs.js.map +0 -1
  108. package/lib/modules/flow-chart/modules/control-panel.cjs.js +0 -286
  109. package/lib/modules/flow-chart/modules/control-panel.cjs.js.map +0 -1
  110. package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js +0 -150
  111. package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js.map +0 -1
  112. package/lib/modules/mind-map/config-utils.cjs.js +0 -108
  113. package/lib/modules/mind-map/config-utils.cjs.js.map +0 -1
  114. package/lib/modules/mind-map/formats/mind-map-blot.cjs.js +0 -356
  115. package/lib/modules/mind-map/formats/mind-map-blot.cjs.js.map +0 -1
  116. package/lib/modules/mind-map/i18n/en-us.cjs.js +0 -29
  117. package/lib/modules/mind-map/i18n/en-us.cjs.js.map +0 -1
  118. package/lib/modules/mind-map/i18n/index.cjs.js +0 -12
  119. package/lib/modules/mind-map/i18n/index.cjs.js.map +0 -1
  120. package/lib/modules/mind-map/i18n/zh-cn.cjs.js +0 -29
  121. package/lib/modules/mind-map/i18n/zh-cn.cjs.js.map +0 -1
  122. package/lib/modules/mind-map/icons.cjs.js +0 -45
  123. package/lib/modules/mind-map/icons.cjs.js.map +0 -1
  124. package/lib/modules/mind-map/index.cjs.js +0 -56
  125. package/lib/modules/mind-map/index.cjs.js.map +0 -1
  126. package/lib/modules/mind-map/modules/context-menu.cjs.js +0 -128
  127. package/lib/modules/mind-map/modules/context-menu.cjs.js.map +0 -1
  128. package/lib/modules/mind-map/modules/control-panel.cjs.js +0 -425
  129. package/lib/modules/mind-map/modules/control-panel.cjs.js.map +0 -1
  130. package/lib/modules/mind-map/modules/custom-resize-action.cjs.js +0 -161
  131. package/lib/modules/mind-map/modules/custom-resize-action.cjs.js.map +0 -1
  132. package/mind-map.css +0 -224
  133. package/types/modules/ai/constants.d.ts +0 -30
  134. package/types/modules/ai/icons.d.ts +0 -21
  135. package/types/modules/ai/index.d.ts +0 -96
  136. package/types/modules/ai/types.d.ts +0 -16
  137. package/types/modules/flow-chart/config-utils.d.ts +0 -10
  138. package/types/modules/flow-chart/formats/flow-chart-blot.d.ts +0 -43
  139. package/types/modules/flow-chart/i18n/en-us.d.ts +0 -26
  140. package/types/modules/flow-chart/i18n/index.d.ts +0 -1
  141. package/types/modules/flow-chart/i18n/zh-cn.d.ts +0 -26
  142. package/types/modules/flow-chart/icons.d.ts +0 -12
  143. package/types/modules/flow-chart/index.d.ts +0 -10
  144. package/types/modules/flow-chart/modules/context-menu.d.ts +0 -3
  145. package/types/modules/flow-chart/modules/control-panel.d.ts +0 -3
  146. package/types/modules/flow-chart/modules/custom-resize-action.d.ts +0 -22
  147. package/types/modules/flow-chart/options.d.ts +0 -29
  148. package/types/modules/mind-map/config-utils.d.ts +0 -12
  149. package/types/modules/mind-map/formats/mind-map-blot.d.ts +0 -44
  150. package/types/modules/mind-map/i18n/en-us.d.ts +0 -25
  151. package/types/modules/mind-map/i18n/index.d.ts +0 -1
  152. package/types/modules/mind-map/i18n/zh-cn.d.ts +0 -25
  153. package/types/modules/mind-map/icons.d.ts +0 -21
  154. package/types/modules/mind-map/index.d.ts +0 -10
  155. package/types/modules/mind-map/modules/context-menu.d.ts +0 -3
  156. package/types/modules/mind-map/modules/control-panel.d.ts +0 -3
  157. package/types/modules/mind-map/modules/custom-resize-action.d.ts +0 -23
  158. package/types/modules/mind-map/options.d.ts +0 -27
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- const Quill = require("quill");
7
- const mindMapBlot = require("./formats/mind-map-blot.cjs.js");
8
- class MindMapModule {
9
- constructor(quill, options) {
10
- __publicField(this, "quill");
11
- __publicField(this, "toolbar");
12
- __publicField(this, "options");
13
- quill.container.__quillInstance = quill;
14
- this.quill = quill;
15
- this.options = options;
16
- this.toolbar = quill.getModule("toolbar");
17
- if (this.toolbar) {
18
- this.toolbar.addHandler("mind-map", () => {
19
- this.insertMindMapEditor();
20
- });
21
- }
22
- }
23
- static register() {
24
- Quill.register("formats/mind-map", mindMapBlot.default, true);
25
- }
26
- insertMindMapEditor() {
27
- const range = this.quill.getSelection();
28
- if (range) {
29
- const defaultData = {
30
- data: {
31
- text: "根节点",
32
- expand: true,
33
- uid: "36bae545-da0b-4c08-be14-ff05f7f05d0a",
34
- isActive: false
35
- },
36
- children: [
37
- {
38
- data: {
39
- text: "二级节点",
40
- uid: "ef0895d2-b5cc-4214-b0ee-e29f8f02420d",
41
- expand: true,
42
- richText: false,
43
- isActive: false
44
- },
45
- children: []
46
- }
47
- ]
48
- };
49
- this.quill.insertText(range.index, "\n", "user");
50
- this.quill.insertEmbed(range.index + 1, "mind-map", defaultData, "user");
51
- this.quill.insertText(range.index + 2, "\n", "user");
52
- }
53
- }
54
- }
55
- exports.MindMapModule = MindMapModule;
56
- //# sourceMappingURL=index.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../../../src/modules/mind-map/index.ts"],"sourcesContent":["import type Quill from 'quill'\nimport type { MindMapOptions } from './options'\nimport Quills from 'quill'\nimport MindMapPlaceholderBlot from './formats/mind-map-blot'\n\nexport class MindMapModule {\n quill: Quill\n toolbar: any\n options: MindMapOptions\n\n static register() {\n Quills.register('formats/mind-map', MindMapPlaceholderBlot, true)\n }\n\n constructor(quill: Quill, options: MindMapOptions) {\n (quill.container as any).__quillInstance = quill\n this.quill = quill\n this.options = options\n this.toolbar = quill.getModule('toolbar')\n if (this.toolbar) {\n this.toolbar.addHandler('mind-map', () => {\n this.insertMindMapEditor()\n })\n }\n }\n\n public insertMindMapEditor(): void {\n const range = this.quill.getSelection()\n if (range) {\n const defaultData = {\n data: {\n text: '根节点',\n expand: true,\n uid: '36bae545-da0b-4c08-be14-ff05f7f05d0a',\n isActive: false,\n },\n children: [\n {\n data: {\n text: '二级节点',\n uid: 'ef0895d2-b5cc-4214-b0ee-e29f8f02420d',\n expand: true,\n richText: false,\n isActive: false,\n },\n children: [],\n },\n ],\n }\n this.quill.insertText(range.index, '\\n', 'user')\n this.quill.insertEmbed(range.index + 1, 'mind-map', defaultData, 'user')\n this.quill.insertText(range.index + 2, '\\n', 'user')\n }\n }\n}\n"],"names":["Quills","MindMapPlaceholderBlot"],"mappings":";;;;;;;AAKO,MAAM,cAAc;AAAA,EASzB,YAAY,OAAc,SAAyB;AARnD;AACA;AACA;AAOG,UAAM,UAAkB,kBAAkB;AAC3C,SAAK,QAAQ;AACb,SAAK,UAAU;AACf,SAAK,UAAU,MAAM,UAAU,SAAS;AACxC,QAAI,KAAK,SAAS;AAChB,WAAK,QAAQ,WAAW,YAAY,MAAM;AACxC,aAAK,oBAAA;AAAA,MACP,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAdA,OAAO,WAAW;AAChBA,UAAO,SAAS,oBAAoBC,YAAAA,SAAwB,IAAI;AAAA,EAClE;AAAA,EAcO,sBAA4B;AACjC,UAAM,QAAQ,KAAK,MAAM,aAAA;AACzB,QAAI,OAAO;AACT,YAAM,cAAc;AAAA,QAClB,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,KAAK;AAAA,UACL,UAAU;AAAA,QAAA;AAAA,QAEZ,UAAU;AAAA,UACR;AAAA,YACE,MAAM;AAAA,cACJ,MAAM;AAAA,cACN,KAAK;AAAA,cACL,QAAQ;AAAA,cACR,UAAU;AAAA,cACV,UAAU;AAAA,YAAA;AAAA,YAEZ,UAAU,CAAA;AAAA,UAAC;AAAA,QACb;AAAA,MACF;AAEF,WAAK,MAAM,WAAW,MAAM,OAAO,MAAM,MAAM;AAC/C,WAAK,MAAM,YAAY,MAAM,QAAQ,GAAG,YAAY,aAAa,MAAM;AACvE,WAAK,MAAM,WAAW,MAAM,QAAQ,GAAG,MAAM,MAAM;AAAA,IACrD;AAAA,EACF;AACF;;"}
@@ -1,128 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- require("../../../config/index.cjs.js");
7
- const i18n = require("../../i18n.cjs.js");
8
- const index = require("../i18n/index.cjs.js");
9
- const editor_config = require("../../../config/editor.config.cjs.js");
10
- class MindMapContextMenuHandler {
11
- constructor(quill, blot) {
12
- __publicField(this, "texts");
13
- __publicField(this, "lang");
14
- this.quill = quill;
15
- this.blot = blot;
16
- const i18nModule = this.quill.getModule("i18n");
17
- index.registerMindMapI18N(i18n.I18N);
18
- this.lang = i18nModule.options.lang;
19
- this.texts = this.resolveTexts();
20
- this.quill.emitter.on(editor_config.CHANGE_LANGUAGE_EVENT, (lang) => {
21
- this.lang = lang;
22
- this.texts = this.resolveTexts();
23
- this.updateContextMenuItems();
24
- });
25
- }
26
- getText(key) {
27
- return this.texts[key];
28
- }
29
- resolveTexts() {
30
- return {
31
- copy: i18n.I18N.parserText("mindMap.contextMenu.copy", this.lang),
32
- cut: i18n.I18N.parserText("mindMap.contextMenu.cut", this.lang),
33
- paste: i18n.I18N.parserText("mindMap.contextMenu.paste", this.lang),
34
- delete: i18n.I18N.parserText("mindMap.contextMenu.deleteContent", this.lang)
35
- };
36
- }
37
- updateContextMenuItems() {
38
- if (!this.blot.contextMenu) return;
39
- const menuItems = this.blot.contextMenu.querySelectorAll(".ql-mind-map-context-menu-item");
40
- if (menuItems.length >= 4) {
41
- menuItems[0].textContent = this.texts.copy;
42
- menuItems[1].textContent = this.texts.cut;
43
- menuItems[2].textContent = this.texts.paste;
44
- menuItems[3].textContent = this.texts.delete;
45
- }
46
- }
47
- }
48
- const contextMenuHandlers = /* @__PURE__ */ new WeakMap();
49
- function initContextMenu(blot, quill) {
50
- blot.contextMenu = document.createElement("div");
51
- blot.contextMenu.className = "ql-mind-map-context-menu";
52
- blot.domNode.appendChild(blot.contextMenu);
53
- const handler = new MindMapContextMenuHandler(quill, blot);
54
- contextMenuHandlers.set(blot, handler);
55
- addContextMenuItem(blot, handler.getText("copy"), () => handleCopy(blot));
56
- addContextMenuItem(blot, handler.getText("cut"), () => handleCut(blot));
57
- addContextMenuItem(blot, handler.getText("paste"), () => handlePaste(blot));
58
- addContextMenuItem(blot, handler.getText("delete"), () => handleDeleteContent(blot));
59
- if (blot.mindMap) {
60
- blot.mindMap.on("node_contextmenu", (e, node) => {
61
- e.preventDefault();
62
- e.stopPropagation();
63
- blot.currentNode = node;
64
- if (blot.contextMenu) {
65
- blot.contextMenu.style.display = "block";
66
- blot.contextMenu.style.left = `${e.clientX}px`;
67
- blot.contextMenu.style.top = `${e.clientY}px`;
68
- }
69
- });
70
- }
71
- const hideMenu = () => {
72
- if (blot.contextMenu) {
73
- blot.contextMenu.style.display = "none";
74
- blot.currentNode = null;
75
- }
76
- };
77
- blot.mindMap.on("node_click", hideMenu);
78
- blot.mindMap.on("draw_click", hideMenu);
79
- blot.mindMap.on("expand_btn_click", hideMenu);
80
- document.addEventListener("click", (e) => {
81
- if (blot.contextMenu && !blot.contextMenu.contains(e.target)) {
82
- hideMenu();
83
- }
84
- });
85
- }
86
- function addContextMenuItem(blot, text, onClick) {
87
- const item = document.createElement("div");
88
- item.className = "ql-mind-map-context-menu-item";
89
- item.textContent = text;
90
- item.style.padding = "5px 15px";
91
- item.style.cursor = "pointer";
92
- item.style.whiteSpace = "nowrap";
93
- item.addEventListener("click", onClick);
94
- item.addEventListener("mouseenter", () => {
95
- item.style.background = "#f5f5f5";
96
- });
97
- item.addEventListener("mouseleave", () => {
98
- item.style.background = "white";
99
- });
100
- blot.contextMenu.appendChild(item);
101
- }
102
- function handleCopy(blot) {
103
- blot.mindMap.renderer.copy();
104
- hideContextMenu(blot);
105
- }
106
- function handleCut(blot) {
107
- blot.mindMap.renderer.cut();
108
- hideContextMenu(blot);
109
- }
110
- function handlePaste(blot) {
111
- blot.mindMap.renderer.paste();
112
- hideContextMenu(blot);
113
- }
114
- function handleDeleteContent(blot) {
115
- if (blot.currentNode) {
116
- blot.currentNode.setText("");
117
- blot.data = blot.mindMap.getData({});
118
- blot.domNode.setAttribute("data-mind-map", JSON.stringify(blot.data));
119
- }
120
- hideContextMenu(blot);
121
- }
122
- function hideContextMenu(blot) {
123
- if (blot.contextMenu) {
124
- blot.contextMenu.style.display = "none";
125
- }
126
- }
127
- exports.initContextMenu = initContextMenu;
128
- //# sourceMappingURL=context-menu.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-menu.cjs.js","sources":["../../../../../src/modules/mind-map/modules/context-menu.ts"],"sourcesContent":["import type FluentEditor from '../../../core/fluent-editor'\nimport type MindMapPlaceholderBlot from '../formats/mind-map-blot'\nimport { CHANGE_LANGUAGE_EVENT } from '../../../config'\nimport { I18N } from '../../../modules/i18n'\nimport { registerMindMapI18N } from '../i18n'\n\nclass MindMapContextMenuHandler {\n private texts: Record<string, string>\n private lang: string\n getText(key: keyof Record<string, string>): string {\n return this.texts[key]\n }\n\n constructor(private quill: FluentEditor, private blot: MindMapPlaceholderBlot) {\n const i18nModule = this.quill.getModule('i18n') as I18N\n registerMindMapI18N(I18N)\n this.lang = i18nModule.options.lang\n this.texts = this.resolveTexts()\n this.quill.emitter.on(CHANGE_LANGUAGE_EVENT, (lang: string) => {\n this.lang = lang\n this.texts = this.resolveTexts()\n this.updateContextMenuItems()\n })\n }\n\n resolveTexts() {\n return {\n copy: I18N.parserText('mindMap.contextMenu.copy', this.lang),\n cut: I18N.parserText('mindMap.contextMenu.cut', this.lang),\n paste: I18N.parserText('mindMap.contextMenu.paste', this.lang),\n delete: I18N.parserText('mindMap.contextMenu.deleteContent', this.lang),\n }\n }\n\n updateContextMenuItems() {\n if (!this.blot.contextMenu) return\n\n const menuItems = this.blot.contextMenu.querySelectorAll('.ql-mind-map-context-menu-item')\n if (menuItems.length >= 4) {\n menuItems[0].textContent = this.texts.copy\n menuItems[1].textContent = this.texts.cut\n menuItems[2].textContent = this.texts.paste\n menuItems[3].textContent = this.texts.delete\n }\n }\n}\n\nconst contextMenuHandlers = new WeakMap<MindMapPlaceholderBlot, MindMapContextMenuHandler>()\n\nexport function initContextMenu(blot: MindMapPlaceholderBlot, quill: FluentEditor): void {\n blot.contextMenu = document.createElement('div')\n blot.contextMenu.className = 'ql-mind-map-context-menu'\n blot.domNode.appendChild(blot.contextMenu)\n\n const handler = new MindMapContextMenuHandler(quill, blot)\n contextMenuHandlers.set(blot, handler)\n\n addContextMenuItem(blot, handler.getText('copy'), () => handleCopy(blot))\n addContextMenuItem(blot, handler.getText('cut'), () => handleCut(blot))\n addContextMenuItem(blot, handler.getText('paste'), () => handlePaste(blot))\n addContextMenuItem(blot, handler.getText('delete'), () => handleDeleteContent(blot))\n\n // 监听节点右键点击事件\n if (blot.mindMap) {\n blot.mindMap.on('node_contextmenu', (e: any, node: any) => {\n e.preventDefault()\n e.stopPropagation()\n blot.currentNode = node\n if (blot.contextMenu) {\n blot.contextMenu.style.display = 'block'\n blot.contextMenu.style.left = `${e.clientX}px`\n blot.contextMenu.style.top = `${e.clientY}px`\n }\n })\n }\n\n // 隐藏菜单的逻辑\n const hideMenu = () => {\n if (blot.contextMenu) {\n blot.contextMenu.style.display = 'none'\n blot.currentNode = null\n }\n }\n\n blot.mindMap.on('node_click', hideMenu)\n blot.mindMap.on('draw_click', hideMenu)\n blot.mindMap.on('expand_btn_click', hideMenu)\n document.addEventListener('click', (e) => {\n if (blot.contextMenu && !blot.contextMenu.contains(e.target as Node)) {\n hideMenu()\n }\n })\n}\n\nfunction addContextMenuItem(blot: MindMapPlaceholderBlot, text: string, onClick: () => void): void {\n const item = document.createElement('div')\n item.className = 'ql-mind-map-context-menu-item'\n item.textContent = text\n item.style.padding = '5px 15px'\n item.style.cursor = 'pointer'\n item.style.whiteSpace = 'nowrap'\n item.addEventListener('click', onClick)\n item.addEventListener('mouseenter', () => {\n item.style.background = '#f5f5f5'\n })\n item.addEventListener('mouseleave', () => {\n item.style.background = 'white'\n })\n blot.contextMenu!.appendChild(item)\n}\n\nfunction handleCopy(blot: MindMapPlaceholderBlot): void {\n blot.mindMap.renderer.copy()\n hideContextMenu(blot)\n}\n\nfunction handleCut(blot: MindMapPlaceholderBlot): void {\n blot.mindMap.renderer.cut()\n hideContextMenu(blot)\n}\n\nfunction handlePaste(blot: MindMapPlaceholderBlot): void {\n blot.mindMap.renderer.paste()\n hideContextMenu(blot)\n}\n\nfunction handleDeleteContent(blot: MindMapPlaceholderBlot): void {\n if (blot.currentNode) {\n blot.currentNode.setText('')\n blot.data = blot.mindMap.getData({})\n blot.domNode.setAttribute('data-mind-map', JSON.stringify(blot.data))\n }\n hideContextMenu(blot)\n}\n\nfunction hideContextMenu(blot: MindMapPlaceholderBlot): void {\n if (blot.contextMenu) {\n blot.contextMenu.style.display = 'none'\n }\n}\n"],"names":["registerMindMapI18N","I18N","CHANGE_LANGUAGE_EVENT"],"mappings":"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"}
@@ -1,425 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- require("../../../config/index.cjs.js");
7
- const i18n = require("../../i18n.cjs.js");
8
- const configUtils = require("../config-utils.cjs.js");
9
- const index = require("../i18n/index.cjs.js");
10
- const icons = require("../icons.cjs.js");
11
- const editor_config = require("../../../config/editor.config.cjs.js");
12
- class MindMapControlPanelHandler {
13
- constructor(quill, blot) {
14
- __publicField(this, "texts");
15
- __publicField(this, "lang");
16
- this.quill = quill;
17
- this.blot = blot;
18
- const i18nModule = this.quill.getModule("i18n");
19
- index.registerMindMapI18N(i18n.I18N);
20
- this.lang = i18nModule.options.lang;
21
- this.texts = this.resolveTexts();
22
- this.quill.emitter.on(editor_config.CHANGE_LANGUAGE_EVENT, (lang) => {
23
- this.lang = lang;
24
- this.texts = this.resolveTexts();
25
- this.updateControlPanelTexts();
26
- });
27
- }
28
- getText(key) {
29
- return this.texts[key];
30
- }
31
- resolveTexts() {
32
- const textKeys = [
33
- "zoomOutTitle",
34
- "zoomInTitle",
35
- "fitTitle",
36
- "backTitle",
37
- "forwardTitle",
38
- "inserChildNodeTitle",
39
- "inserNodeTitle",
40
- "insertIconTitle",
41
- "inserParentNodeTitle",
42
- "removeNodeTitle",
43
- "setLayoutTitle",
44
- "logicalStructureLayout",
45
- "catalogOrganizationLayout",
46
- "mindMapLayout",
47
- "organizationStructureLayout",
48
- "timelineLayout",
49
- "fishboneLayout",
50
- "panelStatusTitle",
51
- "screenTypeTitle"
52
- ];
53
- return textKeys.reduce((acc, key) => {
54
- if (!key.includes("Title")) {
55
- acc[key] = i18n.I18N.parserText(`mindMap.layout.${key.replace("Layout", "")}`, this.lang);
56
- } else {
57
- acc[key] = i18n.I18N.parserText(`mindMap.controlPanel.${key}`, this.lang);
58
- }
59
- return acc;
60
- }, {});
61
- }
62
- updateControlPanelTexts() {
63
- const controlItems = this.blot.domNode.querySelectorAll(".ql-mind-map-control-item");
64
- const controlItemMap = {
65
- "zoom-out": "zoomOutTitle",
66
- "zoom-in": "zoomInTitle",
67
- "fit": "fitTitle",
68
- "back": "backTitle",
69
- "forward": "forwardTitle",
70
- "insert-child-node": "inserChildNodeTitle",
71
- "insert-node": "inserNodeTitle",
72
- "insert-icon": "insertIconTitle",
73
- "insert-parent-node": "inserParentNodeTitle",
74
- "remove-node": "removeNodeTitle",
75
- "set-layout-icon": "setLayoutTitle",
76
- "panel-status": "panelStatusTitle",
77
- "screen-type": "screenTypeTitle"
78
- };
79
- controlItems.forEach((item) => {
80
- const controlType = item.dataset.controlType;
81
- if (controlType && controlItemMap[controlType] && this.texts[controlItemMap[controlType]]) {
82
- item.title = this.texts[controlItemMap[controlType]];
83
- }
84
- });
85
- }
86
- }
87
- const controlPanelHandlers = /* @__PURE__ */ new WeakMap();
88
- const DISABLED_OPACITY = "0.5";
89
- const ENABLED_OPACITY = "1";
90
- function createControlPanel(blot, quill) {
91
- let isStart = true;
92
- let isEnd = true;
93
- let selectedNodes = [];
94
- blot.mindMap.on("node_active", (...args) => {
95
- selectedNodes = Array.isArray(args[1]) ? args[1] : [];
96
- });
97
- const controlPanel = document.createElement("div");
98
- controlPanel.className = "ql-mind-map-control";
99
- const controlRightUpPanel = document.createElement("div");
100
- controlRightUpPanel.className = "ql-mind-map-right-up-control";
101
- const controlLeftUpPanel = document.createElement("div");
102
- controlLeftUpPanel.className = "ql-mind-map-left-up-control";
103
- const handler = new MindMapControlPanelHandler(quill, blot);
104
- controlPanelHandlers.set(blot, handler);
105
- const zoomOutBtn = createControlItem("zoom-out", handler.getText("zoomOutTitle"), () => handleZoomOut(blot));
106
- const zoomInBtn = createControlItem("zoom-in", handler.getText("zoomInTitle"), () => handleZoomIn(blot));
107
- const resetBtn = createControlItem("fit", handler.getText("fitTitle"), () => handleResetZoom(blot));
108
- const backBtn = createControlItem("back", handler.getText("backTitle"), () => {
109
- if (!isStart) {
110
- blot.mindMap.execCommand("BACK");
111
- }
112
- });
113
- const forwardBtn = createControlItem("forward", handler.getText("forwardTitle"), () => {
114
- if (!isEnd) {
115
- blot.mindMap.execCommand("FORWARD");
116
- }
117
- });
118
- const insertChildNode = createControlItem("insert-child-node", handler.getText("inserChildNodeTitle"), () => handleInsertChildNode(blot));
119
- const insertNode = createControlItem("insert-node", handler.getText("inserNodeTitle"), () => handleInsertNode(blot));
120
- const insertParentNode = createControlItem("insert-parent-node", handler.getText("inserParentNodeTitle"), () => handleInsertParentNode(blot));
121
- const removeNode = createControlItem("remove-node", handler.getText("removeNodeTitle"), () => handleRemoveNode(blot));
122
- const insertIconBtn = createControlItem("insert-icon", handler.getText("insertIconTitle"), () => handleInsertIcon(blot, selectedNodes));
123
- const setLayoutBtn = createControlItem("set-layout-icon", handler.getText("setLayoutTitle"), () => handleSetLayoutBtn(blot));
124
- const panelStatusBtn = createControlItem("panel-status", handler.getText("panelStatusTitle"));
125
- const screenTypeBtn = createControlItem("screen-type", handler.getText("screenTypeTitle"), () => handleScreenTypeBtn(blot));
126
- const updateButtonState = (index2, len) => {
127
- isStart = index2 <= 0;
128
- isEnd = index2 >= len - 1;
129
- backBtn.style.cursor = isStart ? "not-allowed" : "pointer";
130
- backBtn.style.opacity = isStart ? DISABLED_OPACITY : ENABLED_OPACITY;
131
- forwardBtn.style.cursor = isEnd ? "not-allowed" : "pointer";
132
- forwardBtn.style.opacity = isEnd ? DISABLED_OPACITY : ENABLED_OPACITY;
133
- };
134
- blot.mindMap.on("back_forward", (index2, len) => {
135
- updateButtonState(index2, len);
136
- });
137
- controlPanel.append(zoomOutBtn, zoomInBtn, resetBtn, screenTypeBtn, backBtn, forwardBtn);
138
- blot.domNode.appendChild(controlPanel);
139
- controlRightUpPanel.append(panelStatusBtn);
140
- blot.domNode.appendChild(controlRightUpPanel);
141
- controlLeftUpPanel.append(insertChildNode, insertNode, insertParentNode, removeNode, insertIconBtn, setLayoutBtn);
142
- blot.domNode.appendChild(controlLeftUpPanel);
143
- }
144
- function createControlItem(iconClass, title, onClick, disabled = false) {
145
- const controlItem = document.createElement("div");
146
- controlItem.className = "ql-mind-map-control-item";
147
- controlItem.title = title;
148
- controlItem.dataset.controlType = iconClass;
149
- controlItem.style.cursor = disabled ? "not-allowed" : "pointer";
150
- controlItem.style.opacity = disabled ? DISABLED_OPACITY : ENABLED_OPACITY;
151
- const iconMap = {
152
- "back": icons.backIcon,
153
- "forward": icons.forwardIcon,
154
- "zoom-out": icons.zoomOutIcon,
155
- "zoom-in": icons.zoomInIcon,
156
- "fit": icons.fitIcon,
157
- "insert-child-node": icons.insertChildNodeIcon,
158
- "insert-node": icons.insertNodeIcon,
159
- "insert-parent-node": icons.insertParentNodeIcon,
160
- "remove-node": icons.removeNodeIcon,
161
- "insert-icon": icons.insertIconIcon,
162
- "set-layout-icon": icons.setLayoutIcon,
163
- "screen-type": icons.screenTypeIcon,
164
- "panel-status": icons.contractIcon
165
- };
166
- const icon = document.createElement("i");
167
- icon.innerHTML = iconMap[iconClass] || "";
168
- controlItem.appendChild(icon);
169
- if (!disabled) {
170
- controlItem.addEventListener("click", onClick);
171
- }
172
- return controlItem;
173
- }
174
- function handleInsertChildNode(blot) {
175
- blot.mindMap.execCommand("INSERT_CHILD_NODE");
176
- }
177
- function handleInsertNode(blot) {
178
- blot.mindMap.execCommand("INSERT_NODE");
179
- }
180
- function handleInsertParentNode(blot) {
181
- blot.mindMap.execCommand("INSERT_PARENT_NODE");
182
- }
183
- function handleRemoveNode(blot) {
184
- blot.mindMap.execCommand("REMOVE_CURRENT_NODE");
185
- }
186
- function handleZoomIn(blot) {
187
- if (blot.mindMap && blot.mindMap.view) {
188
- const containerRect = blot.mindMap.el.getBoundingClientRect();
189
- const cx = containerRect.width / 2;
190
- const cy = containerRect.height / 2;
191
- blot.mindMap.view.enlarge(cx, cy, false);
192
- blot.zoomCount++;
193
- }
194
- }
195
- function handleZoomOut(blot) {
196
- if (blot.mindMap && blot.mindMap.view) {
197
- const containerRect = blot.mindMap.el.getBoundingClientRect();
198
- const cx = containerRect.width / 2;
199
- const cy = containerRect.height / 2;
200
- blot.mindMap.view.narrow(cx, cy, false);
201
- blot.zoomCount--;
202
- }
203
- }
204
- function handleResetZoom(blot) {
205
- blot.mindMap.renderer.setRootNodeCenter();
206
- if (!blot.mindMap || !blot.mindMap.view || blot.zoomCount === 0) return;
207
- const containerRect = blot.mindMap.el.getBoundingClientRect();
208
- const centerX = containerRect.width / 2;
209
- const centerY = containerRect.height / 2;
210
- const operationCount = Math.abs(blot.zoomCount);
211
- const isEnlarge = blot.zoomCount < 0;
212
- for (let i = 0; i < operationCount; i++) {
213
- if (isEnlarge) {
214
- blot.mindMap.view.enlarge(centerX, centerY, false);
215
- } else {
216
- blot.mindMap.view.narrow(centerX, centerY, false);
217
- }
218
- }
219
- blot.zoomCount = 0;
220
- }
221
- function handleInsertIcon(blot, selectedNodes) {
222
- blot.selectedNodes = selectedNodes;
223
- const heightStr = blot.domNode.getAttribute("height") || "500px";
224
- const height = Number.parseInt(heightStr.replace(/[^\d.]/g, ""), 10) || 500;
225
- let iconList = [];
226
- const { deps } = configUtils.getAllConfigs(blot.quill);
227
- iconList = deps.nodeIconList.nodeIconList ? deps.nodeIconList.nodeIconList : deps.nodeIconList;
228
- const leftUpControl = blot.domNode.querySelector(".ql-mind-map-left-up-control");
229
- let iconPanel = leftUpControl.querySelector(".ql-mind-map-icon-panel");
230
- if (!iconPanel) {
231
- iconPanel = document.createElement("div");
232
- iconPanel.className = "ql-mind-map-icon-panel";
233
- iconList == null ? void 0 : iconList.forEach((group) => {
234
- const groupContainer = document.createElement("div");
235
- groupContainer.className = "ql-mind-map-icon-group-container";
236
- group.list.forEach((icon) => {
237
- const iconItem = document.createElement("div");
238
- iconItem.className = "ql-mind-map-icon-item";
239
- iconItem.innerHTML = icon.icon;
240
- iconItem.addEventListener("click", () => {
241
- const currentSelectedNodes = blot.selectedNodes || [];
242
- if (currentSelectedNodes.length > 0) {
243
- const node = currentSelectedNodes[0];
244
- if (node.getData("icon") && node.getData("icon")[0] === `${group.type}_${icon.name}`) {
245
- node.setIcon([]);
246
- } else {
247
- node.setIcon([`${group.type}_${icon.name}`]);
248
- }
249
- blot.data = blot.mindMap.getData({});
250
- blot.domNode.setAttribute("data-mind-map", JSON.stringify(blot.data));
251
- }
252
- iconPanel.style.display = "none";
253
- });
254
- groupContainer.appendChild(iconItem);
255
- });
256
- iconPanel.appendChild(groupContainer);
257
- });
258
- if (height < 395) {
259
- iconPanel.style.height = `${height - 130}px`;
260
- } else {
261
- iconPanel.style.height = "270px";
262
- }
263
- leftUpControl.appendChild(iconPanel);
264
- } else {
265
- if (height < 395) {
266
- iconPanel.style.height = `${height - 130}px`;
267
- } else {
268
- iconPanel.style.height = "270px";
269
- }
270
- iconPanel.style.display = "block";
271
- }
272
- const handleOutsideClick = (e) => {
273
- let insertIconBtn = null;
274
- const controlItems = leftUpControl.querySelectorAll(".ql-mind-map-control-item");
275
- controlItems.forEach((item) => {
276
- if (item.dataset.controlType === "insert-icon") {
277
- insertIconBtn = item;
278
- }
279
- });
280
- if (!iconPanel.contains(e.target) && (!insertIconBtn || !insertIconBtn.contains(e.target))) {
281
- iconPanel.style.display = "none";
282
- document.removeEventListener("click", handleOutsideClick);
283
- }
284
- };
285
- document.removeEventListener("click", handleOutsideClick);
286
- document.addEventListener("click", handleOutsideClick);
287
- }
288
- function handleSetLayoutBtn(blot) {
289
- const handler = controlPanelHandlers.get(blot);
290
- const leftUpControl = blot.domNode.querySelector(".ql-mind-map-left-up-control");
291
- let layoutPanel = leftUpControl.querySelector(".ql-mind-map-layout-panel");
292
- const heightStr = blot.domNode.getAttribute("height") || "500";
293
- const height = Number.parseInt(heightStr.replace(/[^\d.]/g, ""), 10) || 500;
294
- if (!layoutPanel) {
295
- layoutPanel = document.createElement("div");
296
- layoutPanel.className = "ql-mind-map-layout-panel";
297
- const layouts = [
298
- {
299
- name: "logicalStructure",
300
- displayName: handler == null ? void 0 : handler.getText("logicalStructureLayout"),
301
- icon: icons.logicalStructureIcon
302
- },
303
- {
304
- name: "catalogOrganization",
305
- displayName: handler == null ? void 0 : handler.getText("catalogOrganizationLayout"),
306
- icon: icons.catalogOrganizationIcon
307
- },
308
- {
309
- name: "mindMap",
310
- displayName: handler == null ? void 0 : handler.getText("mindMapLayout"),
311
- icon: icons.mindMapIcon
312
- },
313
- {
314
- name: "organizationStructure",
315
- displayName: handler == null ? void 0 : handler.getText("organizationStructureLayout"),
316
- icon: icons.organizationStructureIcon
317
- },
318
- {
319
- name: "timeline",
320
- displayName: handler == null ? void 0 : handler.getText("timelineLayout"),
321
- icon: icons.timelineIcon
322
- },
323
- {
324
- name: "fishbone",
325
- displayName: handler == null ? void 0 : handler.getText("fishboneLayout"),
326
- icon: icons.fishboneIcon
327
- }
328
- ];
329
- layouts.forEach((layout) => {
330
- const layoutItem = document.createElement("div");
331
- layoutItem.className = "ql-mind-map-layout-item";
332
- const iconContainer = document.createElement("div");
333
- iconContainer.className = "ql-mind-map-layout-icon-container";
334
- const img = document.createElement("div");
335
- img.className = "ql-mind-map-layout-icon";
336
- img.innerHTML = layout.icon;
337
- img.style.display = "flex";
338
- img.style.alignItems = "center";
339
- img.style.justifyContent = "center";
340
- const svgElement = img.querySelector("svg");
341
- svgElement.style.maxWidth = "100%";
342
- svgElement.style.maxHeight = "100%";
343
- svgElement.style.width = "auto";
344
- svgElement.style.height = "auto";
345
- svgElement.removeAttribute("width");
346
- svgElement.removeAttribute("height");
347
- iconContainer.appendChild(img);
348
- const nameText = document.createElement("div");
349
- nameText.className = "ql-mind-map-layout-name";
350
- nameText.textContent = layout.displayName;
351
- layoutItem.appendChild(iconContainer);
352
- layoutItem.appendChild(nameText);
353
- layoutItem.addEventListener("click", () => {
354
- blot.mindMap.setLayout(layout.name);
355
- blot.data = blot.mindMap.getData({});
356
- blot.domNode.setAttribute("data-mind-map", JSON.stringify(blot.data));
357
- layoutPanel.style.display = "none";
358
- });
359
- layoutPanel.appendChild(layoutItem);
360
- });
361
- leftUpControl.appendChild(layoutPanel);
362
- if (height < 395) {
363
- layoutPanel.style.height = `${height - 130}px`;
364
- } else {
365
- layoutPanel.style.height = "270px";
366
- }
367
- } else {
368
- if (height < 395) {
369
- layoutPanel.style.height = `${height - 130}px`;
370
- } else {
371
- layoutPanel.style.height = "270px";
372
- }
373
- layoutPanel.style.display = "flex";
374
- }
375
- const handleOutsideClick = (e) => {
376
- let setLayoutBtn = null;
377
- const controlItems = leftUpControl.querySelectorAll(".ql-mind-map-control-item");
378
- setLayoutBtn = Array.from(controlItems).find((item) => item.getAttribute("data-control-type") === "set-layout-icon");
379
- if (!layoutPanel.contains(e.target) && (!setLayoutBtn || !setLayoutBtn.contains(e.target))) {
380
- layoutPanel.style.display = "none";
381
- document.removeEventListener("click", handleOutsideClick);
382
- }
383
- };
384
- document.removeEventListener("click", handleOutsideClick);
385
- document.addEventListener("click", handleOutsideClick);
386
- }
387
- function handleScreenTypeBtn(blot) {
388
- const screenTypeBtn = blot.domNode.querySelector('[data-control-type="screen-type"]');
389
- if (!screenTypeBtn || !blot.domNode) return;
390
- const mindMapContainer = blot.domNode;
391
- const isFullscreen = mindMapContainer.style.position === "fixed";
392
- if (isFullscreen) {
393
- const originalPosition = mindMapContainer.getAttribute("data-original-position");
394
- const originalWidth = mindMapContainer.getAttribute("data-original-width");
395
- const originalHeight = mindMapContainer.getAttribute("data-original-height");
396
- if (originalWidth && originalHeight) {
397
- mindMapContainer.style.position = originalPosition;
398
- mindMapContainer.style.width = originalWidth;
399
- mindMapContainer.style.height = originalHeight;
400
- mindMapContainer.style.zIndex = "0";
401
- }
402
- const iconElement = screenTypeBtn.querySelector("i");
403
- if (iconElement) {
404
- iconElement.innerHTML = icons.screenTypeIcon;
405
- }
406
- } else {
407
- mindMapContainer.setAttribute("data-original-position", mindMapContainer.style.position || "");
408
- mindMapContainer.setAttribute("data-original-width", mindMapContainer.style.width || "");
409
- mindMapContainer.setAttribute("data-original-height", mindMapContainer.style.height || "");
410
- mindMapContainer.style.position = "fixed";
411
- mindMapContainer.style.top = "0";
412
- mindMapContainer.style.left = "0";
413
- mindMapContainer.style.width = "100vw";
414
- mindMapContainer.style.height = "100vh";
415
- mindMapContainer.style.zIndex = "100";
416
- const iconElement = screenTypeBtn.querySelector("i");
417
- if (iconElement) {
418
- iconElement.innerHTML = icons.screenReduceIcon;
419
- }
420
- }
421
- blot.mindMap.renderer.setRootNodeCenter();
422
- blot.mindMap.resize();
423
- }
424
- exports.createControlPanel = createControlPanel;
425
- //# sourceMappingURL=control-panel.cjs.js.map