@opentiny/fluent-editor 4.0.0 → 4.1.0-alpha.0

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 (180) hide show
  1. package/es/config/i18n/en-us.es.js +2 -0
  2. package/es/config/i18n/en-us.es.js.map +1 -1
  3. package/es/config/i18n/zh-cn.es.js +2 -0
  4. package/es/config/i18n/zh-cn.es.js.map +1 -1
  5. package/es/config/index.es.js +1 -1
  6. package/es/config/index.es.js.map +1 -1
  7. package/es/fluent-editor.es.js +6 -0
  8. package/es/fluent-editor.es.js.map +1 -1
  9. package/es/index.es.js +4 -0
  10. package/es/index.es.js.map +1 -1
  11. package/es/modules/ai/constants.es.js +50 -0
  12. package/es/modules/ai/constants.es.js.map +1 -0
  13. package/es/modules/ai/icons.es.js +319 -0
  14. package/es/modules/ai/icons.es.js.map +1 -0
  15. package/es/modules/ai/index.es.js +670 -0
  16. package/es/modules/ai/index.es.js.map +1 -0
  17. package/es/modules/custom-uploader.es.js +42 -6
  18. package/es/modules/custom-uploader.es.js.map +1 -1
  19. package/es/modules/file/modules/file-module.es.js +4 -2
  20. package/es/modules/file/modules/file-module.es.js.map +1 -1
  21. package/es/modules/flow-chart/config-utils.es.js +102 -0
  22. package/es/modules/flow-chart/config-utils.es.js.map +1 -0
  23. package/es/modules/flow-chart/formats/flow-chart-blot.es.js +369 -0
  24. package/es/modules/flow-chart/formats/flow-chart-blot.es.js.map +1 -0
  25. package/es/modules/flow-chart/i18n/en-us.es.js +30 -0
  26. package/es/modules/flow-chart/i18n/en-us.es.js.map +1 -0
  27. package/es/modules/flow-chart/i18n/index.es.js +12 -0
  28. package/es/modules/flow-chart/i18n/index.es.js.map +1 -0
  29. package/es/modules/flow-chart/i18n/zh-cn.es.js +30 -0
  30. package/es/modules/flow-chart/i18n/zh-cn.es.js.map +1 -0
  31. package/es/modules/flow-chart/icons.es.js +27 -0
  32. package/es/modules/flow-chart/icons.es.js.map +1 -0
  33. package/es/modules/flow-chart/index.es.js +45 -0
  34. package/es/modules/flow-chart/index.es.js.map +1 -0
  35. package/es/modules/flow-chart/modules/context-menu.es.js +184 -0
  36. package/es/modules/flow-chart/modules/context-menu.es.js.map +1 -0
  37. package/es/modules/flow-chart/modules/control-panel.es.js +286 -0
  38. package/es/modules/flow-chart/modules/control-panel.es.js.map +1 -0
  39. package/es/modules/flow-chart/modules/custom-resize-action.es.js +150 -0
  40. package/es/modules/flow-chart/modules/custom-resize-action.es.js.map +1 -0
  41. package/es/modules/index.es.js +4 -0
  42. package/es/modules/index.es.js.map +1 -1
  43. package/es/modules/mind-map/config-utils.es.js +108 -0
  44. package/es/modules/mind-map/config-utils.es.js.map +1 -0
  45. package/es/modules/mind-map/formats/mind-map-blot.es.js +356 -0
  46. package/es/modules/mind-map/formats/mind-map-blot.es.js.map +1 -0
  47. package/es/modules/mind-map/i18n/en-us.es.js +29 -0
  48. package/es/modules/mind-map/i18n/en-us.es.js.map +1 -0
  49. package/es/modules/mind-map/i18n/index.es.js +12 -0
  50. package/es/modules/mind-map/i18n/index.es.js.map +1 -0
  51. package/es/modules/mind-map/i18n/zh-cn.es.js +29 -0
  52. package/es/modules/mind-map/i18n/zh-cn.es.js.map +1 -0
  53. package/es/modules/mind-map/icons.es.js +45 -0
  54. package/es/modules/mind-map/icons.es.js.map +1 -0
  55. package/es/modules/mind-map/index.es.js +56 -0
  56. package/es/modules/mind-map/index.es.js.map +1 -0
  57. package/es/modules/mind-map/modules/context-menu.es.js +128 -0
  58. package/es/modules/mind-map/modules/context-menu.es.js.map +1 -0
  59. package/es/modules/mind-map/modules/control-panel.es.js +425 -0
  60. package/es/modules/mind-map/modules/control-panel.es.js.map +1 -0
  61. package/es/modules/mind-map/modules/custom-resize-action.es.js +161 -0
  62. package/es/modules/mind-map/modules/custom-resize-action.es.js.map +1 -0
  63. package/es/modules/shortcut-key/index.es.js +18 -1
  64. package/es/modules/shortcut-key/index.es.js.map +1 -1
  65. package/es/modules/syntax.es.js +19 -0
  66. package/es/modules/syntax.es.js.map +1 -1
  67. package/es/themes/snow.es.js +3 -9
  68. package/es/themes/snow.es.js.map +1 -1
  69. package/es/ui/icons.config.es.js +4 -0
  70. package/es/ui/icons.config.es.js.map +1 -1
  71. package/es/ui/icons.es.js +4 -2
  72. package/es/ui/icons.es.js.map +1 -1
  73. package/flow-chart.css +185 -0
  74. package/lib/config/i18n/en-us.cjs.js +2 -0
  75. package/lib/config/i18n/en-us.cjs.js.map +1 -1
  76. package/lib/config/i18n/zh-cn.cjs.js +2 -0
  77. package/lib/config/i18n/zh-cn.cjs.js.map +1 -1
  78. package/lib/config/index.cjs.js +1 -1
  79. package/lib/config/index.cjs.js.map +1 -1
  80. package/lib/fluent-editor.cjs.js +8 -2
  81. package/lib/fluent-editor.cjs.js.map +1 -1
  82. package/lib/index.cjs.js +9 -5
  83. package/lib/index.cjs.js.map +1 -1
  84. package/lib/modules/ai/constants.cjs.js +50 -0
  85. package/lib/modules/ai/constants.cjs.js.map +1 -0
  86. package/lib/modules/ai/icons.cjs.js +319 -0
  87. package/lib/modules/ai/icons.cjs.js.map +1 -0
  88. package/lib/modules/ai/index.cjs.js +670 -0
  89. package/lib/modules/ai/index.cjs.js.map +1 -0
  90. package/lib/modules/custom-uploader.cjs.js +42 -6
  91. package/lib/modules/custom-uploader.cjs.js.map +1 -1
  92. package/lib/modules/file/modules/file-module.cjs.js +4 -2
  93. package/lib/modules/file/modules/file-module.cjs.js.map +1 -1
  94. package/lib/modules/flow-chart/config-utils.cjs.js +102 -0
  95. package/lib/modules/flow-chart/config-utils.cjs.js.map +1 -0
  96. package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js +369 -0
  97. package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js.map +1 -0
  98. package/lib/modules/flow-chart/i18n/en-us.cjs.js +30 -0
  99. package/lib/modules/flow-chart/i18n/en-us.cjs.js.map +1 -0
  100. package/lib/modules/flow-chart/i18n/index.cjs.js +12 -0
  101. package/lib/modules/flow-chart/i18n/index.cjs.js.map +1 -0
  102. package/lib/modules/flow-chart/i18n/zh-cn.cjs.js +30 -0
  103. package/lib/modules/flow-chart/i18n/zh-cn.cjs.js.map +1 -0
  104. package/lib/modules/flow-chart/icons.cjs.js +27 -0
  105. package/lib/modules/flow-chart/icons.cjs.js.map +1 -0
  106. package/lib/modules/flow-chart/index.cjs.js +45 -0
  107. package/lib/modules/flow-chart/index.cjs.js.map +1 -0
  108. package/lib/modules/flow-chart/modules/context-menu.cjs.js +184 -0
  109. package/lib/modules/flow-chart/modules/context-menu.cjs.js.map +1 -0
  110. package/lib/modules/flow-chart/modules/control-panel.cjs.js +286 -0
  111. package/lib/modules/flow-chart/modules/control-panel.cjs.js.map +1 -0
  112. package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js +150 -0
  113. package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js.map +1 -0
  114. package/lib/modules/index.cjs.js +9 -5
  115. package/lib/modules/index.cjs.js.map +1 -1
  116. package/lib/modules/mind-map/config-utils.cjs.js +108 -0
  117. package/lib/modules/mind-map/config-utils.cjs.js.map +1 -0
  118. package/lib/modules/mind-map/formats/mind-map-blot.cjs.js +356 -0
  119. package/lib/modules/mind-map/formats/mind-map-blot.cjs.js.map +1 -0
  120. package/lib/modules/mind-map/i18n/en-us.cjs.js +29 -0
  121. package/lib/modules/mind-map/i18n/en-us.cjs.js.map +1 -0
  122. package/lib/modules/mind-map/i18n/index.cjs.js +12 -0
  123. package/lib/modules/mind-map/i18n/index.cjs.js.map +1 -0
  124. package/lib/modules/mind-map/i18n/zh-cn.cjs.js +29 -0
  125. package/lib/modules/mind-map/i18n/zh-cn.cjs.js.map +1 -0
  126. package/lib/modules/mind-map/icons.cjs.js +45 -0
  127. package/lib/modules/mind-map/icons.cjs.js.map +1 -0
  128. package/lib/modules/mind-map/index.cjs.js +56 -0
  129. package/lib/modules/mind-map/index.cjs.js.map +1 -0
  130. package/lib/modules/mind-map/modules/context-menu.cjs.js +128 -0
  131. package/lib/modules/mind-map/modules/context-menu.cjs.js.map +1 -0
  132. package/lib/modules/mind-map/modules/control-panel.cjs.js +425 -0
  133. package/lib/modules/mind-map/modules/control-panel.cjs.js.map +1 -0
  134. package/lib/modules/mind-map/modules/custom-resize-action.cjs.js +161 -0
  135. package/lib/modules/mind-map/modules/custom-resize-action.cjs.js.map +1 -0
  136. package/lib/modules/shortcut-key/index.cjs.js +18 -1
  137. package/lib/modules/shortcut-key/index.cjs.js.map +1 -1
  138. package/lib/modules/syntax.cjs.js +19 -0
  139. package/lib/modules/syntax.cjs.js.map +1 -1
  140. package/lib/themes/snow.cjs.js +3 -9
  141. package/lib/themes/snow.cjs.js.map +1 -1
  142. package/lib/ui/icons.cjs.js +3 -1
  143. package/lib/ui/icons.cjs.js.map +1 -1
  144. package/lib/ui/icons.config.cjs.js +4 -0
  145. package/lib/ui/icons.config.cjs.js.map +1 -1
  146. package/mind-map.css +224 -0
  147. package/package.json +3 -1
  148. package/types/config/i18n/en-us.d.ts +2 -0
  149. package/types/config/i18n/zh-cn.d.ts +2 -0
  150. package/types/config/types/editor-modules.interface.d.ts +4 -0
  151. package/types/modules/ai/constants.d.ts +30 -0
  152. package/types/modules/ai/icons.d.ts +21 -0
  153. package/types/modules/ai/index.d.ts +96 -0
  154. package/types/modules/ai/types.d.ts +16 -0
  155. package/types/modules/custom-uploader.d.ts +14 -4
  156. package/types/modules/flow-chart/config-utils.d.ts +10 -0
  157. package/types/modules/flow-chart/formats/flow-chart-blot.d.ts +43 -0
  158. package/types/modules/flow-chart/i18n/en-us.d.ts +26 -0
  159. package/types/modules/flow-chart/i18n/index.d.ts +1 -0
  160. package/types/modules/flow-chart/i18n/zh-cn.d.ts +26 -0
  161. package/types/modules/flow-chart/icons.d.ts +12 -0
  162. package/types/modules/flow-chart/index.d.ts +10 -0
  163. package/types/modules/flow-chart/modules/context-menu.d.ts +3 -0
  164. package/types/modules/flow-chart/modules/control-panel.d.ts +3 -0
  165. package/types/modules/flow-chart/modules/custom-resize-action.d.ts +22 -0
  166. package/types/modules/flow-chart/options.d.ts +29 -0
  167. package/types/modules/index.d.ts +2 -0
  168. package/types/modules/mind-map/config-utils.d.ts +12 -0
  169. package/types/modules/mind-map/formats/mind-map-blot.d.ts +44 -0
  170. package/types/modules/mind-map/i18n/en-us.d.ts +25 -0
  171. package/types/modules/mind-map/i18n/index.d.ts +1 -0
  172. package/types/modules/mind-map/i18n/zh-cn.d.ts +25 -0
  173. package/types/modules/mind-map/icons.d.ts +21 -0
  174. package/types/modules/mind-map/index.d.ts +10 -0
  175. package/types/modules/mind-map/modules/context-menu.d.ts +3 -0
  176. package/types/modules/mind-map/modules/control-panel.d.ts +3 -0
  177. package/types/modules/mind-map/modules/custom-resize-action.d.ts +23 -0
  178. package/types/modules/mind-map/options.d.ts +27 -0
  179. package/types/ui/icons.config.d.ts +2 -0
  180. package/types/modules/syntax.d.ts +0 -13
@@ -0,0 +1,150 @@
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 MIN_WIDTH = 350;
7
+ const MIN_HEIGHT = 290;
8
+ class FlowChartResizeAction {
9
+ constructor(blot) {
10
+ __publicField(this, "topLeftHandle");
11
+ __publicField(this, "topRightHandle");
12
+ __publicField(this, "bottomRightHandle");
13
+ __publicField(this, "bottomLeftHandle");
14
+ __publicField(this, "dragHandle", null);
15
+ __publicField(this, "dragStartX", 0);
16
+ __publicField(this, "dragStartY", 0);
17
+ __publicField(this, "preDragWidth", 0);
18
+ __publicField(this, "preDragHeight", 0);
19
+ __publicField(this, "targetRatio", 0);
20
+ __publicField(this, "blot");
21
+ this.blot = blot;
22
+ this.topLeftHandle = this.createHandle("top-left", "nwse-resize");
23
+ this.topRightHandle = this.createHandle("top-right", "nesw-resize");
24
+ this.bottomRightHandle = this.createHandle("bottom-right", "nwse-resize");
25
+ this.bottomLeftHandle = this.createHandle("bottom-left", "nesw-resize");
26
+ this.init();
27
+ }
28
+ isFullscreen() {
29
+ const container = this.blot.domNode;
30
+ return container.style.position === "fixed" && container.style.width === "100vw" && container.style.height === "100vh";
31
+ }
32
+ init() {
33
+ const container = this.blot.domNode;
34
+ container.style.position = "relative";
35
+ container.appendChild(this.topLeftHandle);
36
+ container.appendChild(this.topRightHandle);
37
+ container.appendChild(this.bottomRightHandle);
38
+ container.appendChild(this.bottomLeftHandle);
39
+ this.repositionHandles();
40
+ }
41
+ createHandle(position, cursor) {
42
+ const box = document.createElement("div");
43
+ box.classList.add("ql-flow-chart-resize-handle");
44
+ box.setAttribute("data-position", position);
45
+ Object.assign(box.style, {
46
+ cursor,
47
+ position: "absolute",
48
+ width: "10px",
49
+ height: "10px",
50
+ background: "#4285f4",
51
+ border: "1px solid white",
52
+ borderRadius: "50%",
53
+ zIndex: "99",
54
+ userSelect: "none"
55
+ });
56
+ box.addEventListener("mousedown", this.onMouseDown.bind(this));
57
+ return box;
58
+ }
59
+ repositionHandles() {
60
+ const container = this.blot.domNode;
61
+ const rect = container.getBoundingClientRect();
62
+ Object.assign(this.topLeftHandle.style, {
63
+ left: "-5px",
64
+ top: "-5px"
65
+ });
66
+ Object.assign(this.topRightHandle.style, {
67
+ right: "-5px",
68
+ top: "-5px"
69
+ });
70
+ Object.assign(this.bottomRightHandle.style, {
71
+ right: "-5px",
72
+ bottom: "-5px"
73
+ });
74
+ Object.assign(this.bottomLeftHandle.style, {
75
+ left: "-5px",
76
+ bottom: "-5px"
77
+ });
78
+ }
79
+ onMouseDown(event) {
80
+ if (this.isFullscreen()) {
81
+ return;
82
+ }
83
+ if (!(event.target instanceof HTMLElement)) {
84
+ return;
85
+ }
86
+ this.dragHandle = event.target;
87
+ document.body.style.cursor = this.dragHandle.style.cursor;
88
+ const container = this.blot.domNode;
89
+ const rect = container.getBoundingClientRect();
90
+ this.dragStartX = event.clientX;
91
+ this.dragStartY = event.clientY;
92
+ this.preDragWidth = rect.width;
93
+ this.preDragHeight = rect.height;
94
+ this.targetRatio = rect.height / rect.width;
95
+ event.preventDefault();
96
+ document.addEventListener("mousemove", this.onDrag.bind(this));
97
+ document.addEventListener("mouseup", this.onMouseUp.bind(this));
98
+ }
99
+ onDrag(event) {
100
+ if (!this.dragHandle) return;
101
+ const container = this.blot.domNode;
102
+ let newWidth = this.preDragWidth;
103
+ let newHeight = this.preDragHeight;
104
+ const deltaX = event.clientX - this.dragStartX;
105
+ const deltaY = event.clientY - this.dragStartY;
106
+ switch (this.dragHandle.dataset.position) {
107
+ case "top-left":
108
+ newWidth = Math.max(MIN_WIDTH, this.preDragWidth - deltaX);
109
+ newHeight = Math.max(MIN_HEIGHT, this.preDragHeight - deltaY);
110
+ break;
111
+ case "top-right":
112
+ newWidth = Math.max(MIN_WIDTH, this.preDragWidth + deltaX);
113
+ newHeight = Math.max(MIN_HEIGHT, this.preDragHeight - deltaY);
114
+ break;
115
+ case "bottom-right":
116
+ newWidth = Math.max(MIN_WIDTH, this.preDragWidth + deltaX);
117
+ newHeight = Math.max(MIN_HEIGHT, this.preDragHeight + deltaY);
118
+ break;
119
+ case "bottom-left":
120
+ newWidth = Math.max(MIN_WIDTH, this.preDragWidth - deltaX);
121
+ newHeight = Math.max(MIN_HEIGHT, this.preDragHeight + deltaY);
122
+ break;
123
+ }
124
+ container.style.width = `${newWidth}px`;
125
+ container.style.height = `${newHeight}px`;
126
+ container.setAttribute("width", String(newWidth));
127
+ container.setAttribute("height", String(newHeight));
128
+ if (this.blot.flowChart) {
129
+ this.blot.flowChart.resize(newWidth, newHeight);
130
+ }
131
+ this.blot.data.width = newWidth;
132
+ this.blot.data.height = newHeight;
133
+ container.setAttribute("data-flow-chart", JSON.stringify(this.blot.data));
134
+ }
135
+ onMouseUp() {
136
+ document.body.style.cursor = "";
137
+ document.removeEventListener("mousemove", this.onDrag.bind(this));
138
+ document.removeEventListener("mouseup", this.onMouseUp.bind(this));
139
+ this.dragHandle = null;
140
+ }
141
+ destroy() {
142
+ const container = this.blot.domNode;
143
+ container.removeChild(this.topLeftHandle);
144
+ container.removeChild(this.topRightHandle);
145
+ container.removeChild(this.bottomRightHandle);
146
+ container.removeChild(this.bottomLeftHandle);
147
+ }
148
+ }
149
+ exports.FlowChartResizeAction = FlowChartResizeAction;
150
+ //# sourceMappingURL=custom-resize-action.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-resize-action.cjs.js","sources":["../../../../../src/modules/flow-chart/modules/custom-resize-action.ts"],"sourcesContent":["const MIN_WIDTH = 350\nconst MIN_HEIGHT = 290\n\nexport class FlowChartResizeAction {\n topLeftHandle: HTMLElement\n topRightHandle: HTMLElement\n bottomRightHandle: HTMLElement\n bottomLeftHandle: HTMLElement\n dragHandle: HTMLElement | null = null\n dragStartX: number = 0\n dragStartY: number = 0\n preDragWidth: number = 0\n preDragHeight: number = 0\n targetRatio: number = 0\n blot: any\n\n constructor(blot: any) {\n this.blot = blot\n this.topLeftHandle = this.createHandle('top-left', 'nwse-resize')\n this.topRightHandle = this.createHandle('top-right', 'nesw-resize')\n this.bottomRightHandle = this.createHandle('bottom-right', 'nwse-resize')\n this.bottomLeftHandle = this.createHandle('bottom-left', 'nesw-resize')\n this.init()\n }\n\n isFullscreen(): boolean {\n const container = this.blot.domNode\n return container.style.position === 'fixed' && container.style.width === '100vw' && container.style.height === '100vh'\n }\n\n init() {\n const container = this.blot.domNode\n container.style.position = 'relative'\n container.appendChild(this.topLeftHandle)\n container.appendChild(this.topRightHandle)\n container.appendChild(this.bottomRightHandle)\n container.appendChild(this.bottomLeftHandle)\n this.repositionHandles()\n }\n\n createHandle(position: string, cursor: string): HTMLElement {\n const box = document.createElement('div')\n box.classList.add('ql-flow-chart-resize-handle')\n box.setAttribute('data-position', position)\n Object.assign(box.style, {\n cursor,\n position: 'absolute',\n width: '10px',\n height: '10px',\n background: '#4285f4',\n border: '1px solid white',\n borderRadius: '50%',\n zIndex: '99',\n userSelect: 'none',\n })\n box.addEventListener('mousedown', this.onMouseDown.bind(this))\n return box\n }\n\n repositionHandles() {\n const container = this.blot.domNode\n const rect = container.getBoundingClientRect()\n\n Object.assign(this.topLeftHandle.style, {\n left: '-5px',\n top: '-5px',\n })\n Object.assign(this.topRightHandle.style, {\n right: '-5px',\n top: '-5px',\n })\n Object.assign(this.bottomRightHandle.style, {\n right: '-5px',\n bottom: '-5px',\n })\n Object.assign(this.bottomLeftHandle.style, {\n left: '-5px',\n bottom: '-5px',\n })\n }\n\n onMouseDown(event: MouseEvent) {\n if (this.isFullscreen()) {\n return\n }\n if (!(event.target instanceof HTMLElement)) {\n return\n }\n\n this.dragHandle = event.target\n document.body.style.cursor = this.dragHandle.style.cursor\n\n const container = this.blot.domNode\n const rect = container.getBoundingClientRect()\n\n this.dragStartX = event.clientX\n this.dragStartY = event.clientY\n this.preDragWidth = rect.width\n this.preDragHeight = rect.height\n this.targetRatio = rect.height / rect.width\n\n event.preventDefault()\n document.addEventListener('mousemove', this.onDrag.bind(this))\n document.addEventListener('mouseup', this.onMouseUp.bind(this))\n }\n\n onDrag(event: MouseEvent) {\n if (!this.dragHandle) return\n\n const container = this.blot.domNode\n let newWidth = this.preDragWidth\n let newHeight = this.preDragHeight\n\n const deltaX = event.clientX - this.dragStartX\n const deltaY = event.clientY - this.dragStartY\n\n switch (this.dragHandle.dataset.position) {\n case 'top-left':\n newWidth = Math.max(MIN_WIDTH, this.preDragWidth - deltaX)\n newHeight = Math.max(MIN_HEIGHT, this.preDragHeight - deltaY)\n break\n case 'top-right':\n newWidth = Math.max(MIN_WIDTH, this.preDragWidth + deltaX)\n newHeight = Math.max(MIN_HEIGHT, this.preDragHeight - deltaY)\n break\n case 'bottom-right':\n newWidth = Math.max(MIN_WIDTH, this.preDragWidth + deltaX)\n newHeight = Math.max(MIN_HEIGHT, this.preDragHeight + deltaY)\n break\n case 'bottom-left':\n newWidth = Math.max(MIN_WIDTH, this.preDragWidth - deltaX)\n newHeight = Math.max(MIN_HEIGHT, this.preDragHeight + deltaY)\n break\n }\n\n container.style.width = `${newWidth}px`\n container.style.height = `${newHeight}px`\n container.setAttribute('width', String(newWidth))\n container.setAttribute('height', String(newHeight))\n\n if (this.blot.flowChart) {\n this.blot.flowChart.resize(newWidth, newHeight)\n }\n\n this.blot.data.width = newWidth\n this.blot.data.height = newHeight\n container.setAttribute('data-flow-chart', JSON.stringify(this.blot.data))\n }\n\n onMouseUp() {\n document.body.style.cursor = ''\n document.removeEventListener('mousemove', this.onDrag.bind(this))\n document.removeEventListener('mouseup', this.onMouseUp.bind(this))\n this.dragHandle = null\n }\n\n destroy() {\n const container = this.blot.domNode\n container.removeChild(this.topLeftHandle)\n container.removeChild(this.topRightHandle)\n container.removeChild(this.bottomRightHandle)\n container.removeChild(this.bottomLeftHandle)\n }\n}\n"],"names":[],"mappings":";;;;;AAAA,MAAM,YAAY;AAClB,MAAM,aAAa;AAEZ,MAAM,sBAAsB;AAAA,EAajC,YAAY,MAAW;AAZvB;AACA;AACA;AACA;AACA,sCAAiC;AACjC,sCAAqB;AACrB,sCAAqB;AACrB,wCAAuB;AACvB,yCAAwB;AACxB,uCAAsB;AACtB;AAGE,SAAK,OAAO;AACZ,SAAK,gBAAgB,KAAK,aAAa,YAAY,aAAa;AAChE,SAAK,iBAAiB,KAAK,aAAa,aAAa,aAAa;AAClE,SAAK,oBAAoB,KAAK,aAAa,gBAAgB,aAAa;AACxE,SAAK,mBAAmB,KAAK,aAAa,eAAe,aAAa;AACtE,SAAK,KAAA;AAAA,EACP;AAAA,EAEA,eAAwB;AACtB,UAAM,YAAY,KAAK,KAAK;AAC5B,WAAO,UAAU,MAAM,aAAa,WAAW,UAAU,MAAM,UAAU,WAAW,UAAU,MAAM,WAAW;AAAA,EACjH;AAAA,EAEA,OAAO;AACL,UAAM,YAAY,KAAK,KAAK;AAC5B,c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AChD,cAAU,aAAa,UAAU,OAAO,SAAS,CAAC;AAElD,QAAI,KAAK,KAAK,WAAW;AACvB,WAAK,KAAK,UAAU,OAAO,UAAU,SAAS;AAAA,IAChD;AAEA,SAAK,KAAK,KAAK,QAAQ;AACvB,SAAK,KAAK,KAAK,SAAS;AACxB,cAAU,aAAa,mBAAmB,KAAK,UAAU,KAAK,KAAK,IAAI,CAAC;AAAA,EAC1E;AAAA,EAEA,YAAY;AACV,aAAS,KAAK,MAAM,SAAS;AAC7B,aAAS,oBAAoB,aAAa,KAAK,OAAO,KAAK,IAAI,CAAC;AAChE,aAAS,oBAAoB,WAAW,KAAK,UAAU,KAAK,IAAI,CAAC;AACjE,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,UAAU;AACR,UAAM,YAAY,KAAK,KAAK;AAC5B,cAAU,YAAY,KAAK,aAAa;AACxC,cAAU,YAAY,KAAK,cAAc;AACzC,cAAU,YAAY,KAAK,iBAAiB;AAC5C,cAAU,YAAY,KAAK,gBAAgB;AAAA,EAC7C;AACF;;"}
@@ -8,20 +8,24 @@ const customUploader = require("./custom-uploader.cjs.js");
8
8
  const divider = require("./divider.cjs.js");
9
9
  const emoji = require("./emoji.cjs.js");
10
10
  require("./file/index.cjs.js");
11
+ const index = require("./flow-chart/index.cjs.js");
11
12
  const i18n = require("./i18n.cjs.js");
12
13
  require("./link/index.cjs.js");
13
14
  require("./mathlive/index.cjs.js");
14
15
  require("./mention/index.cjs.js");
15
- const index = require("./shortcut-key/index.cjs.js");
16
+ const index$1 = require("./mind-map/index.cjs.js");
17
+ const index$2 = require("./shortcut-key/index.cjs.js");
16
18
  require("./syntax.cjs.js");
17
- const index$1 = require("./table-up/index.cjs.js");
19
+ const index$3 = require("./table-up/index.cjs.js");
18
20
  require("./toolbar/index.cjs.js");
19
21
  exports.CustomClipboard = customClipboard.CustomClipboard;
20
22
  exports.FileUploader = customUploader.FileUploader;
21
23
  exports.DividerBlot = divider.DividerBlot;
22
24
  exports.EmojiModule = emoji.EmojiModule;
25
+ exports.FlowChartModule = index.FlowChartModule;
23
26
  exports.I18N = i18n.I18N;
24
- exports.ShortCutKey = index.ShortCutKey;
25
- exports.shortKey = index.shortKey;
26
- exports.generateTableUp = index$1.generateTableUp;
27
+ exports.MindMapModule = index$1.MindMapModule;
28
+ exports.ShortCutKey = index$2.ShortCutKey;
29
+ exports.shortKey = index$2.shortKey;
30
+ exports.generateTableUp = index$3.generateTableUp;
27
31
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function getBackgroundConfig(quill) {
4
+ var _a;
5
+ const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
6
+ if (!MindMapModule || typeof MindMapModule !== "object") {
7
+ return false;
8
+ }
9
+ if ("background" in MindMapModule) {
10
+ const background = MindMapModule.background;
11
+ if (background === false || background === void 0) {
12
+ return false;
13
+ }
14
+ if (typeof background === "object" && background !== null) {
15
+ const typedBackground = background;
16
+ const backgroundConfig = {};
17
+ if (typedBackground.color) {
18
+ backgroundConfig.backgroundColor = typedBackground.color;
19
+ }
20
+ if (typedBackground.image) {
21
+ backgroundConfig.backgroundImage = typedBackground.image;
22
+ }
23
+ if (typedBackground.repeat) {
24
+ backgroundConfig.backgroundRepeat = typedBackground.repeat;
25
+ }
26
+ if (typedBackground.position) {
27
+ backgroundConfig.backgroundPosition = typedBackground.position;
28
+ }
29
+ if (typedBackground.size) {
30
+ backgroundConfig.backgroundSize = typedBackground.size;
31
+ }
32
+ return backgroundConfig;
33
+ }
34
+ }
35
+ return false;
36
+ }
37
+ function getLineConfig(quill) {
38
+ var _a;
39
+ const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
40
+ if (!MindMapModule || typeof MindMapModule !== "object") {
41
+ return false;
42
+ }
43
+ if ("line" in MindMapModule) {
44
+ const line = MindMapModule.line;
45
+ if (line === false || line === void 0) {
46
+ return false;
47
+ }
48
+ if (typeof line === "object" && line !== null) {
49
+ const typedLine = line;
50
+ const lineConfig = {};
51
+ if (typedLine.color) {
52
+ lineConfig.lineColor = typedLine.color;
53
+ }
54
+ if (typedLine.width) {
55
+ lineConfig.lineWidth = typedLine.width;
56
+ }
57
+ if (typedLine.dasharray) {
58
+ lineConfig.lineDasharray = typedLine.dasharray;
59
+ }
60
+ if (typedLine.style) {
61
+ lineConfig.lineStyle = typedLine.style;
62
+ }
63
+ return lineConfig;
64
+ }
65
+ }
66
+ return false;
67
+ }
68
+ function getResizeConfig(quill) {
69
+ var _a;
70
+ const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
71
+ if (!MindMapModule || typeof MindMapModule !== "object") {
72
+ return false;
73
+ }
74
+ if ("resize" in MindMapModule) {
75
+ const resize = MindMapModule.resize;
76
+ return resize === true;
77
+ }
78
+ return false;
79
+ }
80
+ function getThemeConfig(quill) {
81
+ var _a;
82
+ const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
83
+ if (!MindMapModule || typeof MindMapModule !== "object") {
84
+ return "default";
85
+ }
86
+ if ("theme" in MindMapModule) {
87
+ const theme = MindMapModule.theme;
88
+ return theme || "default";
89
+ }
90
+ return "default";
91
+ }
92
+ function getAllConfigs(quill) {
93
+ var _a, _b;
94
+ const deps = (_b = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"]) == null ? void 0 : _b.deps;
95
+ return {
96
+ backgroundConfig: getBackgroundConfig(quill),
97
+ resizeConfig: getResizeConfig(quill),
98
+ lineConfig: getLineConfig(quill),
99
+ themeConfig: getThemeConfig(quill),
100
+ deps
101
+ };
102
+ }
103
+ exports.getAllConfigs = getAllConfigs;
104
+ exports.getBackgroundConfig = getBackgroundConfig;
105
+ exports.getLineConfig = getLineConfig;
106
+ exports.getResizeConfig = getResizeConfig;
107
+ exports.getThemeConfig = getThemeConfig;
108
+ //# sourceMappingURL=config-utils.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-utils.cjs.js","sources":["../../../../src/modules/mind-map/config-utils.ts"],"sourcesContent":["import type Quill from 'quill'\nimport type { BackgroundConfig, LineConfig } from './options'\n\nexport function getBackgroundConfig(quill: Quill | null): false | object {\n const MindMapModule = quill?.options.modules?.['mind-map']\n if (!MindMapModule || typeof MindMapModule !== 'object') {\n return false\n }\n if ('background' in MindMapModule) {\n const background = MindMapModule.background as BackgroundConfig | boolean | undefined\n\n if (background === false || background === undefined) {\n return false\n }\n if (typeof background === 'object' && background !== null) {\n const typedBackground = background as BackgroundConfig\n const backgroundConfig: any = {}\n\n if (typedBackground.color) {\n backgroundConfig.backgroundColor = typedBackground.color\n }\n if (typedBackground.image) {\n backgroundConfig.backgroundImage = typedBackground.image\n }\n if (typedBackground.repeat) {\n backgroundConfig.backgroundRepeat = typedBackground.repeat\n }\n if (typedBackground.position) {\n backgroundConfig.backgroundPosition = typedBackground.position\n }\n if (typedBackground.size) {\n backgroundConfig.backgroundSize = typedBackground.size\n }\n return backgroundConfig\n }\n }\n return false\n}\n\nexport function getLineConfig(quill: Quill | null): false | object {\n const MindMapModule = quill?.options.modules?.['mind-map']\n if (!MindMapModule || typeof MindMapModule !== 'object') {\n return false\n }\n if ('line' in MindMapModule) {\n const line = MindMapModule.line as LineConfig | boolean | undefined\n\n if (line === false || line === undefined) {\n return false\n }\n if (typeof line === 'object' && line !== null) {\n const typedLine = line as LineConfig\n const lineConfig: any = {}\n\n if (typedLine.color) {\n lineConfig.lineColor = typedLine.color\n }\n if (typedLine.width) {\n lineConfig.lineWidth = typedLine.width\n }\n if (typedLine.dasharray) {\n lineConfig.lineDasharray = typedLine.dasharray\n }\n if (typedLine.style) {\n lineConfig.lineStyle = typedLine.style\n }\n return lineConfig\n }\n }\n return false\n}\n\nexport function getResizeConfig(quill: Quill | null): boolean {\n const MindMapModule = quill?.options.modules?.['mind-map']\n if (!MindMapModule || typeof MindMapModule !== 'object') {\n return false\n }\n if ('resize' in MindMapModule) {\n const resize = (MindMapModule as any).resize as boolean | undefined\n return resize === true\n }\n return false\n}\n\nexport function getThemeConfig(quill: Quill | null): string {\n const MindMapModule = quill?.options.modules?.['mind-map']\n if (!MindMapModule || typeof MindMapModule !== 'object') {\n return 'default'\n }\n if ('theme' in MindMapModule) {\n const theme = MindMapModule.theme as string | undefined\n return theme || 'default'\n }\n return 'default'\n}\n\nexport function getAllConfigs(quill: Quill | null): {\n backgroundConfig: false | object\n resizeConfig: boolean\n lineConfig: false | object\n themeConfig: string\n deps?: any\n} {\n const deps = (quill?.options.modules?.['mind-map'] as any)?.deps\n return {\n backgroundConfig: getBackgroundConfig(quill),\n resizeConfig: getResizeConfig(quill),\n lineConfig: getLineConfig(quill),\n themeConfig: getThemeConfig(quill),\n deps,\n }\n}\n"],"names":[],"mappings":";;AAGO,SAAS,oBAAoB,OAAqC;;AACvE,QAAM,iBAAgB,oCAAO,QAAQ,YAAf,mBAAyB;AAC/C,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAAU;AACvD,WAAO;AAAA,EACT;AACA,MAAI,gBAAgB,eAAe;AACjC,UAAM,aAAa,cAAc;AAEjC,QAAI,eAAe,SAAS,eAAe,QAAW;AACpD,aAAO;AAAA,IACT;AACA,QAAI,OAAO,eAAe,YAAY,eAAe,MAAM;AACzD,YAAM,kBAAkB;AACxB,YAAM,mBAAwB,CAAA;AAE9B,UAAI,gBAAgB,OAAO;AACzB,yBAAiB,kBAAkB,gBAAgB;AAAA,MACrD;AACA,UAAI,gBAAgB,OAAO;AACzB,yBAAiB,kBAAkB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B;AAC/C,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAAU;AACvD,WAAO;AAAA,EACT;AACA,MAAI,WAAW,eAAe;AAC5B,UAAM,QAAQ,cAAc;AAC5B,WAAO,SAAS;AAAA,EAClB;AACA,SAAO;AACT;AAEO,SAAS,cAAc,OAM5B;;AACA,QAAM,QAAQ,0CAAO,QAAQ,YAAf,mBAAyB,gBAAzB,mBAA8C;AAC5D,SAAO;AAAA,IACL,kBAAkB,oBAAoB,KAAK;AAAA,IAC3C,cAAc,gBAAgB,KAAK;AAAA,IACnC,YAAY,cAAc,KAAK;AAAA,IAC/B,aAAa,eAAe,KAAK;AAAA,IACjC;AAAA,EAAA;AAEJ;;;;;;"}
@@ -0,0 +1,356 @@
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.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
6
+ const Quill = require("quill");
7
+ const configUtils = require("../config-utils.cjs.js");
8
+ const icons = require("../icons.cjs.js");
9
+ const contextMenu = require("../modules/context-menu.cjs.js");
10
+ const controlPanel = require("../modules/control-panel.cjs.js");
11
+ const customResizeAction = require("../modules/custom-resize-action.cjs.js");
12
+ ;/* empty css */
13
+ const BlockEmbed = Quill.import("blots/embed");
14
+ const _MindMapPlaceholderBlot = class _MindMapPlaceholderBlot extends BlockEmbed {
15
+ constructor(scroll, domNode) {
16
+ super(scroll, domNode);
17
+ __publicField(this, "quill", null);
18
+ __publicField(this, "mindMap", null);
19
+ __publicField(this, "data");
20
+ __publicField(this, "zoomCount", 0);
21
+ __publicField(this, "contextMenu", null);
22
+ __publicField(this, "currentNode", null);
23
+ __publicField(this, "width", 100);
24
+ __publicField(this, "height", 500);
25
+ __publicField(this, "parentObserver", null);
26
+ __publicField(this, "nextPObserver", null);
27
+ const data = _MindMapPlaceholderBlot.value(domNode);
28
+ this.width = data.width || 100;
29
+ this.height = data.height || 500;
30
+ this.domNode.style.width = `${this.width}${data.width ? "px" : "%"}`;
31
+ this.domNode.style.height = `${this.height}px`;
32
+ this.domNode.style.maxWidth = "100%";
33
+ this.domNode.style.border = "1px solid #e8e8e8";
34
+ this.domNode.setAttribute("contenteditable", "false");
35
+ this.data = _MindMapPlaceholderBlot.value(domNode);
36
+ this.initMindMap();
37
+ }
38
+ static value(domNode) {
39
+ const dataStr = JSON.parse(domNode.getAttribute("data-mind-map"));
40
+ const value = dataStr;
41
+ if (domNode.hasAttribute("width")) {
42
+ value.width = Number.parseInt(domNode.getAttribute("width"), 10);
43
+ }
44
+ if (domNode.hasAttribute("height")) {
45
+ value.height = Number.parseInt(domNode.getAttribute("height"), 10);
46
+ }
47
+ return dataStr;
48
+ }
49
+ static create(value) {
50
+ const node = super.create();
51
+ if (value) {
52
+ node.setAttribute("data-mind-map", JSON.stringify(value));
53
+ }
54
+ if (value.width) {
55
+ node.setAttribute("width", String(value.width));
56
+ node.style.width = `${value.width}%`;
57
+ }
58
+ if (value.height) {
59
+ node.setAttribute("height", String(value.height));
60
+ node.style.height = `${value.height}px`;
61
+ }
62
+ node.setAttribute("contenteditable", "false");
63
+ return node;
64
+ }
65
+ static findQuill(el) {
66
+ let cur = el;
67
+ while (cur) {
68
+ const q = cur.__quillInstance;
69
+ if (q) return q;
70
+ cur = cur.parentElement;
71
+ }
72
+ return null;
73
+ }
74
+ attach() {
75
+ super.attach();
76
+ this.quill = _MindMapPlaceholderBlot.findQuill(this.domNode);
77
+ }
78
+ initMindMap() {
79
+ if (this.domNode.isConnected) {
80
+ this.insertMindMapEditor();
81
+ } else {
82
+ const observer = new MutationObserver(() => {
83
+ if (this.domNode.isConnected) {
84
+ this.insertMindMapEditor();
85
+ observer.disconnect();
86
+ }
87
+ });
88
+ observer.observe(document.body, { childList: true, subtree: true });
89
+ }
90
+ }
91
+ insertMindMapEditor() {
92
+ this.domNode.style.width = `${this.width}${this.data.width ? "px" : "%"}`;
93
+ this.domNode.style.height = `${this.height}px`;
94
+ while (this.domNode.firstChild) {
95
+ this.domNode.removeChild(this.domNode.firstChild);
96
+ }
97
+ this.updateAlignmentStyle();
98
+ this.observeParentAlignment();
99
+ const { backgroundConfig, resizeConfig, lineConfig, themeConfig, deps } = configUtils.getAllConfigs(this.quill);
100
+ const { SimpleMindMap, Themes, Drag, Export } = deps || window;
101
+ Themes.init(SimpleMindMap);
102
+ SimpleMindMap.usePlugin(Drag).usePlugin(Export);
103
+ this.mindMap = new SimpleMindMap({
104
+ el: this.domNode,
105
+ mousewheelAction: "zoom",
106
+ disableMouseWheelZoom: true,
107
+ layout: this.data.layout,
108
+ theme: themeConfig,
109
+ data: this.data.root ? this.data.root : this.data
110
+ });
111
+ const styleConfig = { ...backgroundConfig };
112
+ if (lineConfig && typeof lineConfig === "object") {
113
+ Object.assign(styleConfig, lineConfig);
114
+ }
115
+ this.mindMap.setThemeConfig(styleConfig);
116
+ const handleScroll = () => {
117
+ if (this.mindMap && this.domNode && this.domNode.isConnected) {
118
+ this.mindMap.getElRectInfo();
119
+ }
120
+ };
121
+ window.addEventListener("scroll", handleScroll, { passive: true });
122
+ this.domNode.addEventListener("remove", () => {
123
+ window.removeEventListener("scroll", handleScroll);
124
+ });
125
+ if (resizeConfig) {
126
+ new customResizeAction.MindMapResizeAction(this);
127
+ }
128
+ controlPanel.createControlPanel(this, this.quill);
129
+ contextMenu.initContextMenu(this, this.quill);
130
+ this.observeOwnParentChange();
131
+ this.observeNextPElement();
132
+ this.addMouseHoverEvents();
133
+ this.mindMap.on("node_tree_render_end", () => {
134
+ this.data = this.mindMap.getData({});
135
+ this.domNode.setAttribute("data-mind-map", JSON.stringify(this.data));
136
+ });
137
+ this.mindMap.on("node_dblclick", this.handleNodeDblClick.bind(this));
138
+ this.domNode.addEventListener("click", (e) => {
139
+ if (this.quill) {
140
+ this.mindMap.getElRectInfo();
141
+ const mindMapBlot = Quill.find(this.domNode);
142
+ const index = this.quill.getIndex(mindMapBlot);
143
+ if (index && typeof index === "number") {
144
+ this.quill.setSelection(index + 1, 0);
145
+ }
146
+ }
147
+ });
148
+ }
149
+ addMouseHoverEvents() {
150
+ this.domNode.addEventListener("mouseenter", () => {
151
+ this.showControlPanel();
152
+ });
153
+ this.domNode.addEventListener("mouseleave", () => {
154
+ this.mindMap.execCommand("CLEAR_ACTIVE_NODE");
155
+ this.hideControlPanel();
156
+ });
157
+ }
158
+ getControlElements() {
159
+ const leftUpControl = this.domNode.querySelector(".ql-mind-map-left-up-control");
160
+ const control = this.domNode.querySelector(".ql-mind-map-control");
161
+ const panelStatusIcon = this.domNode.querySelector('[data-control-type="panel-status"]');
162
+ return { leftUpControl, control, panelStatusIcon };
163
+ }
164
+ showControlPanel() {
165
+ const { leftUpControl, control, panelStatusIcon } = this.getControlElements();
166
+ if (!leftUpControl || !control) return;
167
+ leftUpControl.style.display = "inline-flex";
168
+ control.style.display = "flex";
169
+ if (panelStatusIcon) {
170
+ const iconElement = panelStatusIcon.querySelector("i") || panelStatusIcon;
171
+ iconElement.innerHTML = icons.expandIcon;
172
+ }
173
+ }
174
+ hideControlPanel() {
175
+ const { leftUpControl, control, panelStatusIcon } = this.getControlElements();
176
+ if (!leftUpControl || !control) return;
177
+ leftUpControl.style.display = "none";
178
+ control.style.display = "none";
179
+ if (panelStatusIcon) {
180
+ const iconElement = panelStatusIcon.querySelector("i") || panelStatusIcon;
181
+ iconElement.innerHTML = icons.contractIcon;
182
+ }
183
+ }
184
+ // 监听父元素变化
185
+ observeOwnParentChange() {
186
+ let currentParent = this.domNode.parentElement;
187
+ const observer = new MutationObserver(() => {
188
+ if (this.domNode.parentElement !== currentParent) {
189
+ currentParent = this.domNode.parentElement;
190
+ this.observeParentAlignment();
191
+ }
192
+ });
193
+ observer.observe(document.body, {
194
+ attributes: false,
195
+ childList: true,
196
+ subtree: true
197
+ });
198
+ }
199
+ // 监听父元素对齐变化
200
+ observeParentAlignment() {
201
+ if (this.parentObserver) {
202
+ this.parentObserver.disconnect();
203
+ }
204
+ const observer = new MutationObserver((mutations) => {
205
+ mutations.forEach((mutation) => {
206
+ if (mutation.attributeName === "class") {
207
+ this.updateAlignmentStyle();
208
+ }
209
+ });
210
+ });
211
+ this.parentObserver = observer;
212
+ const parent = this.domNode.parentElement;
213
+ if (parent) {
214
+ observer.observe(parent, {
215
+ attributes: true,
216
+ attributeFilter: ["class"]
217
+ });
218
+ this.updateAlignmentStyle();
219
+ }
220
+ }
221
+ // 更新对齐样式
222
+ updateAlignmentStyle() {
223
+ const parent = this.domNode.parentElement;
224
+ if (!parent) return;
225
+ this.domNode.style.margin = "";
226
+ this.domNode.style.display = "block";
227
+ if (parent.classList.contains("ql-align-center")) {
228
+ this.domNode.style.margin = "0 auto";
229
+ } else if (parent.classList.contains("ql-align-right")) {
230
+ this.domNode.style.marginLeft = "auto";
231
+ this.domNode.style.marginRight = "0";
232
+ } else {
233
+ this.domNode.style.marginLeft = "0";
234
+ this.domNode.style.marginRight = "auto";
235
+ }
236
+ }
237
+ observeNextPElement() {
238
+ if (this.nextPObserver) {
239
+ this.nextPObserver.disconnect();
240
+ }
241
+ const parentElement = this.domNode.parentElement;
242
+ if (!parentElement) {
243
+ return;
244
+ }
245
+ const trackedParentElement = parentElement;
246
+ const parentElementId = parentElement.getAttribute("id") || `mind-map-parent-${Date.now()}`;
247
+ parentElement.setAttribute("id", parentElementId);
248
+ const observer = new MutationObserver(() => {
249
+ if (!document.contains(trackedParentElement)) {
250
+ const elementById = document.getElementById(parentElementId);
251
+ if (!elementById) {
252
+ this.remove();
253
+ observer.disconnect();
254
+ }
255
+ }
256
+ });
257
+ observer.observe(document.body, {
258
+ childList: true,
259
+ subtree: true
260
+ });
261
+ this.nextPObserver = observer;
262
+ }
263
+ handleNodeDblClick(node, e) {
264
+ if (node && node.uid && e) {
265
+ this.currentNode = node;
266
+ this.createEditInput(node, e);
267
+ }
268
+ }
269
+ // 创建编辑输入框
270
+ createEditInput(node, e) {
271
+ const input = document.createElement("textarea");
272
+ input.className = "ql-mind-map-edit-input";
273
+ input.value = node.nodeData.data.text || "";
274
+ const autoResize = () => {
275
+ input.style.height = "auto";
276
+ input.style.height = `${input.scrollHeight}px`;
277
+ };
278
+ Object.assign(input.style, {
279
+ position: "absolute",
280
+ boxSizing: "border-box",
281
+ width: "100px",
282
+ height: "35px",
283
+ padding: "5px",
284
+ lineHeight: "1.2",
285
+ fontFamily: "微软雅黑",
286
+ fontSize: "16px",
287
+ whiteSpace: "pre",
288
+ textAlign: "center",
289
+ background: "#fff",
290
+ border: "1px solid #edefed",
291
+ borderRadius: "3px",
292
+ outline: "none",
293
+ transform: "translate(-50%, -50%)",
294
+ resize: "none",
295
+ zIndex: "1000",
296
+ left: `${e.pageX ? e.pageX : 100}px`,
297
+ top: `${e.pageY ? e.pageY : 100}px`,
298
+ overflow: "hidden"
299
+ });
300
+ document.body.appendChild(input);
301
+ autoResize();
302
+ input.addEventListener("keydown", (event) => {
303
+ if (event.key === "Enter" && event.shiftKey) {
304
+ autoResize();
305
+ }
306
+ });
307
+ input.focus();
308
+ const currentNode = node;
309
+ const handleDrawClick = () => {
310
+ this.updateNodeText(input.value, currentNode);
311
+ input.remove();
312
+ this.mindMap.off("draw_click", handleDrawClick);
313
+ };
314
+ this.mindMap.on("draw_click", handleDrawClick);
315
+ input.addEventListener("keydown", (event) => {
316
+ if (event.key === "Enter" && !event.shiftKey) {
317
+ event.preventDefault();
318
+ this.updateNodeText(input.value, currentNode);
319
+ input.remove();
320
+ this.mindMap.off("draw_click", handleDrawClick);
321
+ }
322
+ });
323
+ }
324
+ updateNodeText(text, node) {
325
+ if (node && this.mindMap) {
326
+ node.setText(text);
327
+ const editWraps = document.querySelectorAll(".smm-node-edit-wrap");
328
+ editWraps.forEach((editWrap) => {
329
+ const input = editWrap.querySelector("input, textarea");
330
+ if (input) {
331
+ input.value = text;
332
+ } else {
333
+ editWrap.textContent = text;
334
+ }
335
+ });
336
+ this.data = this.mindMap.getData({});
337
+ this.domNode.setAttribute("data-mind-map", JSON.stringify(this.data));
338
+ }
339
+ }
340
+ format(name, value) {
341
+ }
342
+ remove() {
343
+ this.mindMap.destroy();
344
+ if (this.nextPObserver) {
345
+ this.nextPObserver.disconnect();
346
+ this.nextPObserver = null;
347
+ }
348
+ super.remove();
349
+ }
350
+ };
351
+ __publicField(_MindMapPlaceholderBlot, "blotName", "mind-map");
352
+ __publicField(_MindMapPlaceholderBlot, "tagName", "div");
353
+ __publicField(_MindMapPlaceholderBlot, "className", "ql-mind-map-item");
354
+ let MindMapPlaceholderBlot = _MindMapPlaceholderBlot;
355
+ exports.default = MindMapPlaceholderBlot;
356
+ //# sourceMappingURL=mind-map-blot.cjs.js.map