@antv/infographic 0.2.11 → 0.2.12

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 (300) hide show
  1. package/dist/infographic.min.js +1 -1
  2. package/dist/infographic.min.js.map +1 -1
  3. package/esm/designs/components/Btn.js +15 -4
  4. package/esm/designs/components/BtnsGroup.js +1 -1
  5. package/esm/designs/components/Illus.js +15 -3
  6. package/esm/designs/components/ItemDesc.js +17 -11
  7. package/esm/designs/components/ItemIcon.js +17 -18
  8. package/esm/designs/components/ItemLabel.js +17 -11
  9. package/esm/designs/components/ItemValue.js +17 -12
  10. package/esm/designs/components/ItemsGroup.js +1 -1
  11. package/esm/designs/components/ShapesGroup.js +1 -1
  12. package/esm/designs/components/Title.js +2 -2
  13. package/esm/designs/decorations/simple-arrow.js +14 -2
  14. package/esm/designs/decorations/triangle.js +14 -2
  15. package/esm/designs/defs/DropShadow.js +13 -2
  16. package/esm/designs/defs/LinearGradient.js +1 -1
  17. package/esm/designs/items/BadgeCard.js +2 -2
  18. package/esm/designs/items/CandyCardLite.js +1 -1
  19. package/esm/designs/items/CapsuleItem.js +3 -3
  20. package/esm/designs/items/CircleNode.js +1 -1
  21. package/esm/designs/items/CircularProgress.js +3 -2
  22. package/esm/designs/items/CompactCard.js +1 -1
  23. package/esm/designs/items/DoneList.js +1 -1
  24. package/esm/designs/items/HorizontalIconArrow.js +2 -2
  25. package/esm/designs/items/HorizontalIconLine.js +2 -2
  26. package/esm/designs/items/IconBadge.js +4 -3
  27. package/esm/designs/items/IndexedCard.js +1 -1
  28. package/esm/designs/items/LCornerCard.js +1 -1
  29. package/esm/designs/items/LetterCard.js +4 -3
  30. package/esm/designs/items/LinedText.js +6 -5
  31. package/esm/designs/items/PillBadge.js +2 -2
  32. package/esm/designs/items/PlainText.js +4 -4
  33. package/esm/designs/items/ProgressCard.js +4 -4
  34. package/esm/designs/items/QuarterCircular.js +1 -1
  35. package/esm/designs/items/QuarterSimpleCard.js +1 -1
  36. package/esm/designs/items/RibbonCard.js +2 -2
  37. package/esm/designs/items/RoundedRectNode.js +2 -2
  38. package/esm/designs/items/SimpleCircleNode.js +1 -1
  39. package/esm/designs/items/SimpleHorizontalArrow.js +2 -2
  40. package/esm/designs/items/SimpleIllusItem.js +1 -1
  41. package/esm/designs/items/SimpleItem.js +3 -3
  42. package/esm/designs/items/SimpleVerticalArrow.js +2 -2
  43. package/esm/designs/items/UnderlineText.js +1 -1
  44. package/esm/designs/items/VerticalIconArrow.js +2 -2
  45. package/esm/designs/layouts/Align.js +22 -15
  46. package/esm/designs/layouts/Flex.js +23 -16
  47. package/esm/designs/structures/chart-bar.js +7 -5
  48. package/esm/designs/structures/chart-column.js +3 -2
  49. package/esm/designs/structures/chart-line.js +7 -5
  50. package/esm/designs/structures/chart-pie.js +4 -3
  51. package/esm/designs/structures/chart-wordcloud.js +5 -14
  52. package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
  53. package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
  54. package/esm/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
  55. package/esm/designs/structures/compare-hierarchy-left-right.js +6 -5
  56. package/esm/designs/structures/compare-hierarchy-row.js +3 -2
  57. package/esm/designs/structures/compare-quadrant.js +2 -3
  58. package/esm/designs/structures/hierarchy-mindmap.js +19 -19
  59. package/esm/designs/structures/hierarchy-structure.js +1 -1
  60. package/esm/designs/structures/hierarchy-tree.js +15 -24
  61. package/esm/designs/structures/list-sector.js +5 -6
  62. package/esm/designs/structures/list-zigzag.js +2 -1
  63. package/esm/designs/structures/relation-dagre-flow.js +30 -35
  64. package/esm/designs/structures/relation-network.js +2 -2
  65. package/esm/designs/structures/sequence-funnel.js +1 -1
  66. package/esm/designs/structures/sequence-mountain.js +4 -4
  67. package/esm/designs/structures/sequence-pyramid.js +1 -1
  68. package/esm/designs/structures/sequence-zigzag-steps.js +2 -1
  69. package/esm/designs/utils/color.js +8 -4
  70. package/esm/designs/utils/item.js +3 -2
  71. package/esm/editor/commands/Batch.js +21 -8
  72. package/esm/editor/commands/UpdateElement.js +25 -22
  73. package/esm/editor/commands/UpdateOptions.js +23 -10
  74. package/esm/editor/commands/UpdateText.js +24 -11
  75. package/esm/editor/interactions/brush-select.js +27 -13
  76. package/esm/editor/interactions/click-select.js +13 -3
  77. package/esm/editor/interactions/dblclick-edit-text.js +36 -20
  78. package/esm/editor/interactions/drag-element.js +23 -9
  79. package/esm/editor/interactions/hotkey-history.js +17 -7
  80. package/esm/editor/interactions/select-highlight.js +5 -9
  81. package/esm/editor/interactions/zoom-wheel.js +2 -1
  82. package/esm/editor/managers/command.js +45 -27
  83. package/esm/editor/managers/interaction.js +46 -33
  84. package/esm/editor/managers/state.js +1 -1
  85. package/esm/editor/plugins/edit-bar/components/color-picker.js +9 -6
  86. package/esm/editor/plugins/edit-bar/components/popover.js +15 -12
  87. package/esm/editor/plugins/edit-bar/components/select.js +10 -8
  88. package/esm/editor/plugins/edit-bar/edit-bar.js +7 -25
  89. package/esm/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
  90. package/esm/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
  91. package/esm/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
  92. package/esm/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
  93. package/esm/editor/plugins/resize-element.js +6 -4
  94. package/esm/editor/utils/click-handler.js +6 -3
  95. package/esm/editor/utils/coordinate.js +2 -1
  96. package/esm/editor/utils/element.js +2 -1
  97. package/esm/editor/utils/event.js +2 -1
  98. package/esm/editor/utils/extension.js +1 -1
  99. package/esm/editor/utils/hotkey.js +2 -1
  100. package/esm/exporter/font.js +106 -90
  101. package/esm/exporter/png.js +49 -37
  102. package/esm/exporter/svg.js +55 -38
  103. package/esm/jsx/components/Ellipse.js +5 -4
  104. package/esm/jsx/components/Path.js +2 -4
  105. package/esm/jsx/components/Polygon.js +15 -6
  106. package/esm/jsx/components/Text.js +21 -41
  107. package/esm/jsx/renderer.js +15 -7
  108. package/esm/jsx/utils/bounds.js +18 -16
  109. package/esm/jsx/utils/children.js +2 -1
  110. package/esm/jsx/utils/clone.js +13 -2
  111. package/esm/jsx/utils/element.js +2 -1
  112. package/esm/options/parser.js +45 -46
  113. package/esm/renderer/composites/background.js +3 -2
  114. package/esm/renderer/composites/icon.js +14 -19
  115. package/esm/renderer/composites/illus.js +17 -22
  116. package/esm/renderer/composites/shape.js +4 -2
  117. package/esm/renderer/composites/svg.js +2 -1
  118. package/esm/renderer/composites/text.js +5 -3
  119. package/esm/renderer/fonts/loader.js +4 -3
  120. package/esm/renderer/fonts/registry.js +1 -1
  121. package/esm/renderer/palettes/utils.js +3 -2
  122. package/esm/renderer/renderer.js +7 -5
  123. package/esm/renderer/stylize/gradient.js +3 -2
  124. package/esm/renderer/stylize/pattern.js +15 -8
  125. package/esm/renderer/stylize/rough.js +1 -1
  126. package/esm/resource/load-tracker.js +22 -10
  127. package/esm/resource/loader.js +80 -67
  128. package/esm/resource/loaders/image.js +71 -59
  129. package/esm/resource/loaders/remote.js +26 -15
  130. package/esm/resource/loaders/search.js +38 -25
  131. package/esm/resource/utils/parser.js +2 -1
  132. package/esm/runtime/Infographic.js +26 -13
  133. package/esm/runtime/utils.js +5 -8
  134. package/esm/ssr/renderer.js +42 -35
  135. package/esm/syntax/index.js +19 -6
  136. package/esm/syntax/mapper.js +2 -2
  137. package/esm/templates/built-in.js +96 -200
  138. package/esm/templates/hierarchy-mindmap.js +1 -5
  139. package/esm/templates/hierarchy-tree.js +1 -5
  140. package/esm/templates/relation-dagre-flow.js +4 -28
  141. package/esm/themes/generator.js +8 -14
  142. package/esm/utils/fetch.js +48 -35
  143. package/esm/utils/icon.js +1 -4
  144. package/esm/utils/is-browser.js +2 -2
  145. package/esm/utils/measure-text.js +2 -1
  146. package/esm/utils/padding.js +1 -1
  147. package/esm/utils/recognizer.js +2 -1
  148. package/esm/utils/text.js +14 -3
  149. package/esm/version.d.ts +1 -1
  150. package/esm/version.js +1 -1
  151. package/lib/designs/components/Btn.js +15 -4
  152. package/lib/designs/components/BtnsGroup.js +1 -1
  153. package/lib/designs/components/Illus.js +15 -3
  154. package/lib/designs/components/ItemDesc.js +17 -11
  155. package/lib/designs/components/ItemIcon.js +17 -18
  156. package/lib/designs/components/ItemLabel.js +17 -11
  157. package/lib/designs/components/ItemValue.js +17 -12
  158. package/lib/designs/components/ItemsGroup.js +1 -1
  159. package/lib/designs/components/ShapesGroup.js +1 -1
  160. package/lib/designs/components/Title.js +2 -2
  161. package/lib/designs/decorations/simple-arrow.js +14 -2
  162. package/lib/designs/decorations/triangle.js +14 -2
  163. package/lib/designs/defs/DropShadow.js +13 -2
  164. package/lib/designs/defs/LinearGradient.js +1 -1
  165. package/lib/designs/items/BadgeCard.js +2 -2
  166. package/lib/designs/items/CandyCardLite.js +1 -1
  167. package/lib/designs/items/CapsuleItem.js +3 -3
  168. package/lib/designs/items/CircleNode.js +1 -1
  169. package/lib/designs/items/CircularProgress.js +3 -2
  170. package/lib/designs/items/CompactCard.js +1 -1
  171. package/lib/designs/items/DoneList.js +1 -1
  172. package/lib/designs/items/HorizontalIconArrow.js +2 -2
  173. package/lib/designs/items/HorizontalIconLine.js +2 -2
  174. package/lib/designs/items/IconBadge.js +4 -3
  175. package/lib/designs/items/IndexedCard.js +1 -1
  176. package/lib/designs/items/LCornerCard.js +1 -1
  177. package/lib/designs/items/LetterCard.js +4 -3
  178. package/lib/designs/items/LinedText.js +6 -5
  179. package/lib/designs/items/PillBadge.js +2 -2
  180. package/lib/designs/items/PlainText.js +4 -4
  181. package/lib/designs/items/ProgressCard.js +4 -4
  182. package/lib/designs/items/QuarterCircular.js +1 -1
  183. package/lib/designs/items/QuarterSimpleCard.js +1 -1
  184. package/lib/designs/items/RibbonCard.js +2 -2
  185. package/lib/designs/items/RoundedRectNode.js +2 -2
  186. package/lib/designs/items/SimpleCircleNode.js +1 -1
  187. package/lib/designs/items/SimpleHorizontalArrow.js +2 -2
  188. package/lib/designs/items/SimpleIllusItem.js +1 -1
  189. package/lib/designs/items/SimpleItem.js +3 -3
  190. package/lib/designs/items/SimpleVerticalArrow.js +2 -2
  191. package/lib/designs/items/UnderlineText.js +1 -1
  192. package/lib/designs/items/VerticalIconArrow.js +2 -2
  193. package/lib/designs/layouts/Align.js +22 -15
  194. package/lib/designs/layouts/Flex.js +23 -16
  195. package/lib/designs/structures/chart-bar.js +7 -5
  196. package/lib/designs/structures/chart-column.js +3 -2
  197. package/lib/designs/structures/chart-line.js +7 -5
  198. package/lib/designs/structures/chart-pie.js +4 -3
  199. package/lib/designs/structures/chart-wordcloud.js +5 -14
  200. package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
  201. package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
  202. package/lib/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
  203. package/lib/designs/structures/compare-hierarchy-left-right.js +6 -5
  204. package/lib/designs/structures/compare-hierarchy-row.js +3 -2
  205. package/lib/designs/structures/compare-quadrant.js +2 -3
  206. package/lib/designs/structures/hierarchy-mindmap.js +19 -19
  207. package/lib/designs/structures/hierarchy-structure.js +1 -1
  208. package/lib/designs/structures/hierarchy-tree.js +15 -24
  209. package/lib/designs/structures/list-sector.js +5 -6
  210. package/lib/designs/structures/list-zigzag.js +2 -1
  211. package/lib/designs/structures/relation-dagre-flow.js +30 -35
  212. package/lib/designs/structures/relation-network.js +2 -2
  213. package/lib/designs/structures/sequence-funnel.js +1 -1
  214. package/lib/designs/structures/sequence-mountain.js +4 -4
  215. package/lib/designs/structures/sequence-pyramid.js +1 -1
  216. package/lib/designs/structures/sequence-zigzag-steps.js +2 -1
  217. package/lib/designs/utils/color.js +8 -4
  218. package/lib/designs/utils/item.js +3 -2
  219. package/lib/editor/commands/Batch.js +21 -8
  220. package/lib/editor/commands/UpdateElement.js +25 -22
  221. package/lib/editor/commands/UpdateOptions.js +23 -10
  222. package/lib/editor/commands/UpdateText.js +24 -11
  223. package/lib/editor/interactions/brush-select.js +27 -13
  224. package/lib/editor/interactions/click-select.js +13 -3
  225. package/lib/editor/interactions/dblclick-edit-text.js +36 -20
  226. package/lib/editor/interactions/drag-element.js +23 -9
  227. package/lib/editor/interactions/hotkey-history.js +17 -7
  228. package/lib/editor/interactions/select-highlight.js +5 -9
  229. package/lib/editor/interactions/zoom-wheel.js +2 -1
  230. package/lib/editor/managers/command.js +43 -25
  231. package/lib/editor/managers/interaction.js +46 -33
  232. package/lib/editor/managers/state.js +1 -1
  233. package/lib/editor/plugins/edit-bar/components/color-picker.js +9 -6
  234. package/lib/editor/plugins/edit-bar/components/popover.js +15 -12
  235. package/lib/editor/plugins/edit-bar/components/select.js +10 -8
  236. package/lib/editor/plugins/edit-bar/edit-bar.js +7 -25
  237. package/lib/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
  238. package/lib/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
  239. package/lib/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
  240. package/lib/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
  241. package/lib/editor/plugins/resize-element.js +6 -4
  242. package/lib/editor/utils/click-handler.js +6 -3
  243. package/lib/editor/utils/coordinate.js +2 -1
  244. package/lib/editor/utils/element.js +2 -1
  245. package/lib/editor/utils/event.js +2 -1
  246. package/lib/editor/utils/extension.js +1 -1
  247. package/lib/editor/utils/hotkey.js +2 -1
  248. package/lib/exporter/font.js +106 -90
  249. package/lib/exporter/png.js +49 -37
  250. package/lib/exporter/svg.js +55 -38
  251. package/lib/jsx/components/Ellipse.js +5 -4
  252. package/lib/jsx/components/Path.js +2 -4
  253. package/lib/jsx/components/Polygon.js +15 -6
  254. package/lib/jsx/components/Text.js +21 -41
  255. package/lib/jsx/renderer.js +15 -7
  256. package/lib/jsx/utils/bounds.js +18 -16
  257. package/lib/jsx/utils/children.js +2 -1
  258. package/lib/jsx/utils/clone.js +13 -2
  259. package/lib/jsx/utils/element.js +2 -1
  260. package/lib/options/parser.js +45 -46
  261. package/lib/renderer/composites/background.js +3 -2
  262. package/lib/renderer/composites/icon.js +14 -19
  263. package/lib/renderer/composites/illus.js +17 -22
  264. package/lib/renderer/composites/shape.js +4 -2
  265. package/lib/renderer/composites/svg.js +2 -1
  266. package/lib/renderer/composites/text.js +5 -3
  267. package/lib/renderer/fonts/loader.js +4 -3
  268. package/lib/renderer/fonts/registry.js +1 -1
  269. package/lib/renderer/palettes/utils.js +3 -2
  270. package/lib/renderer/renderer.js +7 -5
  271. package/lib/renderer/stylize/gradient.js +3 -2
  272. package/lib/renderer/stylize/pattern.js +15 -8
  273. package/lib/renderer/stylize/rough.js +1 -1
  274. package/lib/resource/load-tracker.js +22 -10
  275. package/lib/resource/loader.js +80 -67
  276. package/lib/resource/loaders/image.js +71 -59
  277. package/lib/resource/loaders/remote.js +26 -15
  278. package/lib/resource/loaders/search.js +38 -25
  279. package/lib/resource/utils/parser.js +2 -1
  280. package/lib/runtime/Infographic.js +26 -13
  281. package/lib/runtime/utils.js +5 -8
  282. package/lib/ssr/renderer.js +42 -35
  283. package/lib/syntax/index.js +19 -6
  284. package/lib/syntax/mapper.js +2 -2
  285. package/lib/templates/built-in.js +96 -200
  286. package/lib/templates/hierarchy-mindmap.js +1 -5
  287. package/lib/templates/hierarchy-tree.js +1 -5
  288. package/lib/templates/relation-dagre-flow.js +4 -28
  289. package/lib/themes/generator.js +8 -14
  290. package/lib/utils/fetch.js +48 -35
  291. package/lib/utils/icon.js +1 -4
  292. package/lib/utils/is-browser.js +2 -2
  293. package/lib/utils/measure-text.js +2 -1
  294. package/lib/utils/padding.js +1 -1
  295. package/lib/utils/recognizer.js +2 -1
  296. package/lib/utils/text.js +14 -3
  297. package/lib/version.d.ts +1 -1
  298. package/lib/version.js +1 -1
  299. package/package.json +1 -1
  300. package/src/version.ts +1 -1
@@ -42,8 +42,8 @@ export const RelationNetwork = (props) => {
42
42
  }
43
43
  const { nodes, links } = runForceLayout();
44
44
  /** --- 偏移 --- */
45
- const minX = Math.min(...nodes.map((d) => d.x ?? 0));
46
- const minY = Math.min(...nodes.map((d) => d.y ?? 0));
45
+ const minX = Math.min(...nodes.map((d) => { var _a; return (_a = d.x) !== null && _a !== void 0 ? _a : 0; }));
46
+ const minY = Math.min(...nodes.map((d) => { var _a; return (_a = d.y) !== null && _a !== void 0 ? _a : 0; }));
47
47
  const offsetX = Math.max(0, -minX + itemBounds.width / 2);
48
48
  const offsetY = Math.max(0, -minY + itemBounds.height / 2);
49
49
  const positionBy = (x, y) => ({
@@ -28,7 +28,7 @@ export const SequenceFunnel = (props) => {
28
28
  }
29
29
  const themeColors = getThemeColors(options.themeConfig);
30
30
  // 计算各区域尺寸
31
- const actualFunnelWidth = funnelWidth ?? width * 0.55; // 稍微调窄一点漏斗,给右侧留更多空间
31
+ const actualFunnelWidth = funnelWidth !== null && funnelWidth !== void 0 ? funnelWidth : width * 0.55; // 稍微调窄一点漏斗,给右侧留更多空间
32
32
  const itemAreaWidth = width - actualFunnelWidth;
33
33
  // 漏斗层高度
34
34
  const funnelLayerHeight = itemHeight * FUNNEL_LAYER_HEIGHT_RATIO;
@@ -96,7 +96,7 @@ function Mountain(props) {
96
96
  centerBottom,
97
97
  ];
98
98
  const toPointsString = (points) => points.map((p) => `${p.x},${p.y}`).join(' ');
99
- return (_jsxs(ShapesGroup, { ...props, children: [_jsx("polygon", { points: toPointsString(leftTopShape), fill: leftTopColor }), _jsx("polygon", { points: toPointsString(rightTopShape), fill: rightTopColor }), _jsx("polygon", { points: toPointsString(leftBottomShape), fill: leftBottomColor }), _jsx("polygon", { points: toPointsString(rightBottomShape), fill: rightBottomColor })] }));
99
+ return (_jsxs(ShapesGroup, Object.assign({}, props, { children: [_jsx("polygon", { points: toPointsString(leftTopShape), fill: leftTopColor }), _jsx("polygon", { points: toPointsString(rightTopShape), fill: rightTopColor }), _jsx("polygon", { points: toPointsString(leftBottomShape), fill: leftBottomColor }), _jsx("polygon", { points: toPointsString(rightBottomShape), fill: rightBottomColor })] })));
100
100
  }
101
101
  function Tree(size) {
102
102
  const heightMap = {
@@ -135,13 +135,13 @@ function Sun(props) {
135
135
  const angle = (360 / rayCount) * i;
136
136
  return (_jsx("rect", { x: rayX, y: rayY, width: rayWidth, height: rayHeight, rx: cornerRadius, ry: cornerRadius, fill: "#FFCB0E", transform: `rotate(${angle}, ${centerX}, ${centerY})` }));
137
137
  });
138
- return (_jsxs(ShapesGroup, { ...props, children: [_jsx("circle", { cx: centerX, cy: centerY, r: radius, fill: "#FFCB0E" }), ...rays] }));
138
+ return (_jsxs(ShapesGroup, Object.assign({}, props, { children: [_jsx("circle", { cx: centerX, cy: centerY, r: radius, fill: "#FFCB0E" }), ...rays] })));
139
139
  }
140
140
  function Cloud(props) {
141
141
  if (props.type === 'single') {
142
- return (_jsx(ShapesGroup, { ...props, width: 54, height: 36, children: _jsx("path", { d: "M10.2635 13.3806C11.0019 9.99045 12.7381 6.91002 15.2405 4.55004C17.743 2.19007 20.8929 0.662716 24.2701 0.171643C27.6473 -0.31943 31.0914 0.24912 34.143 1.80148C37.1946 3.35385 39.7087 5.81625 41.3501 8.86031C44.8835 9.0468 48.1994 10.6544 50.5684 13.3294C52.9373 16.0044 54.1653 19.5277 53.9821 23.1242C53.7989 26.7207 52.2195 30.0959 49.5914 32.5071C46.9634 34.9184 43.5019 36.1683 39.9684 35.9818H11.1517C4.93436 35.9818 0 30.9593 0 24.6309C0.0598447 21.8016 1.13799 19.093 3.02989 17.0192C4.9218 14.9454 7.49584 13.6506 10.2635 13.3806Z", fill: "#70CAF8" }) }));
142
+ return (_jsx(ShapesGroup, Object.assign({}, props, { width: 54, height: 36, children: _jsx("path", { d: "M10.2635 13.3806C11.0019 9.99045 12.7381 6.91002 15.2405 4.55004C17.743 2.19007 20.8929 0.662716 24.2701 0.171643C27.6473 -0.31943 31.0914 0.24912 34.143 1.80148C37.1946 3.35385 39.7087 5.81625 41.3501 8.86031C44.8835 9.0468 48.1994 10.6544 50.5684 13.3294C52.9373 16.0044 54.1653 19.5277 53.9821 23.1242C53.7989 26.7207 52.2195 30.0959 49.5914 32.5071C46.9634 34.9184 43.5019 36.1683 39.9684 35.9818H11.1517C4.93436 35.9818 0 30.9593 0 24.6309C0.0598447 21.8016 1.13799 19.093 3.02989 17.0192C4.9218 14.9454 7.49584 13.6506 10.2635 13.3806Z", fill: "#70CAF8" }) })));
143
143
  }
144
- return (_jsxs(ShapesGroup, { ...props, width: 73, height: 40, children: [_jsx("path", { d: "M61.6461 14.9716C60.8681 11.1875 58.9581 7.73823 56.1763 5.09315C53.3944 2.44806 49.8758 0.735682 46.0992 0.189041C42.3226 -0.357601 38.4714 0.288046 35.0699 2.03812C31.6683 3.7882 28.8815 6.5577 27.0889 9.96971C23.161 10.1687 19.4719 11.9405 16.8333 14.8953C14.1947 17.8502 12.8227 21.746 13.0191 25.7258C13.2155 29.7055 14.9642 33.4433 17.8806 36.1167C20.7969 38.7901 24.642 40.1802 28.5699 39.9812H60.6588C67.5702 39.9812 73.0006 34.4791 73.0006 27.4764C73.0006 20.9739 67.8664 15.4718 61.6461 14.9716Z", fill: "#70CAF8" }), _jsx("path", { d: "M21.9691 6.47136e-09C25.9369 6.47136e-09 29.5264 1.62125 32.0003 4.21094C30.0604 5.7917 28.4423 7.75571 27.2581 10C23.3149 10.1989 19.6111 11.9702 16.9622 14.9238C14.3136 17.8774 12.936 21.772 13.1331 25.75C13.2057 27.2131 13.4902 28.6432 13.9652 30H10.7689C7.96116 29.8907 5.29664 28.7203 3.30402 26.7217C1.31144 24.7231 0.135825 22.0419 0.0110544 19.21C-0.113702 16.378 0.821178 13.6017 2.63019 11.4326C4.43921 9.26356 6.99065 7.8602 9.77766 7.5C11.9582 3.00012 16.6168 8.76701e-05 21.9691 6.47136e-09Z", fill: "#5BA2C6" })] }));
144
+ return (_jsxs(ShapesGroup, Object.assign({}, props, { width: 73, height: 40, children: [_jsx("path", { d: "M61.6461 14.9716C60.8681 11.1875 58.9581 7.73823 56.1763 5.09315C53.3944 2.44806 49.8758 0.735682 46.0992 0.189041C42.3226 -0.357601 38.4714 0.288046 35.0699 2.03812C31.6683 3.7882 28.8815 6.5577 27.0889 9.96971C23.161 10.1687 19.4719 11.9405 16.8333 14.8953C14.1947 17.8502 12.8227 21.746 13.0191 25.7258C13.2155 29.7055 14.9642 33.4433 17.8806 36.1167C20.7969 38.7901 24.642 40.1802 28.5699 39.9812H60.6588C67.5702 39.9812 73.0006 34.4791 73.0006 27.4764C73.0006 20.9739 67.8664 15.4718 61.6461 14.9716Z", fill: "#70CAF8" }), _jsx("path", { d: "M21.9691 6.47136e-09C25.9369 6.47136e-09 29.5264 1.62125 32.0003 4.21094C30.0604 5.7917 28.4423 7.75571 27.2581 10C23.3149 10.1989 19.6111 11.9702 16.9622 14.9238C14.3136 17.8774 12.936 21.772 13.1331 25.75C13.2057 27.2131 13.4902 28.6432 13.9652 30H10.7689C7.96116 29.8907 5.29664 28.7203 3.30402 26.7217C1.31144 24.7231 0.135825 22.0419 0.0110544 19.21C-0.113702 16.378 0.821178 13.6017 2.63019 11.4326C4.43921 9.26356 6.99065 7.8602 9.77766 7.5C11.9582 3.00012 16.6168 8.76701e-05 21.9691 6.47136e-09Z", fill: "#5BA2C6" })] })));
145
145
  }
146
146
  export const SequenceMountain = (props) => {
147
147
  const { Title, Item, data, gap = 20, minHeight = 100, maxHeight = 200, minWidth = 260, maxWidth = 300, options, } = props;
@@ -21,7 +21,7 @@ export const SequencePyramid = (props) => {
21
21
  const backgroundElements = [];
22
22
  const iconElements = [];
23
23
  // Calculate dimensions
24
- const actualPyramidWidth = pyramidWidth ?? width * 0.6;
24
+ const actualPyramidWidth = pyramidWidth !== null && pyramidWidth !== void 0 ? pyramidWidth : width * 0.6;
25
25
  const itemAreaWidth = width - actualPyramidWidth;
26
26
  // Pyramid layer height should be greater than itemHeight
27
27
  const pyramidLayerHeight = itemHeight * 1.2; // Magic number: 20% larger than itemHeight
@@ -23,6 +23,7 @@ const DECO_OFFSET_Y = 40 + W_PATH_W / 2;
23
23
  // 滤镜定义
24
24
  const GlowFilter = (_jsx("filter", { id: "sequence-zigzag-glow-filter", x: "-50%", y: "-50%", width: "200%", height: "200%", children: _jsx("feGaussianBlur", { in: "SourceGraphic", stdDeviation: "15", result: "blur" }) }));
25
25
  export const SequenceZigzagSteps = (props) => {
26
+ var _a;
26
27
  const { Title, Item, data, options, dx = DX, dy = DY, iconSize = 30 } = props;
27
28
  const { title, desc, items = [] } = data;
28
29
  const titleContent = Title ? _jsx(Title, { title: title, desc: desc }) : null;
@@ -115,7 +116,7 @@ export const SequenceZigzagSteps = (props) => {
115
116
  }
116
117
  });
117
118
  if (pathD) {
118
- const finalX = (pathPoints[pathPoints.length - 1]?.x || 0) + offsetX;
119
+ const finalX = (((_a = pathPoints[pathPoints.length - 1]) === null || _a === void 0 ? void 0 : _a.x) || 0) + offsetX;
119
120
  pathElements.push(_jsx(Path, { d: pathD, stroke: "#f3f2f1", strokeWidth: W_PATH_W, fill: "none", width: finalX, height: maxItemY - Math.min(minPathY + offsetY, 0) }));
120
121
  }
121
122
  return (_jsxs(FlexLayout, { id: "infographic-container", flexDirection: "column", justifyContent: "center", alignItems: "center", gap: 30, children: [_jsx(Defs, { children: GlowFilter }), titleContent, _jsxs(Group, { x: 0, y: 0, children: [_jsx(Group, { children: [...pathElements, ...decoElements, ...iconElements] }), _jsx(ItemsGroup, { children: itemElements }), _jsx(BtnsGroup, { children: btnElements })] })] }));
@@ -3,21 +3,25 @@ import { generateThemeColors } from '../../themes/index.js';
3
3
  import { isDarkColor } from '../../utils/index.js';
4
4
  const DEFAULT_COLOR = '#FF356A';
5
5
  export function getColorPrimary(options) {
6
- return options?.themeConfig?.colorPrimary || DEFAULT_COLOR;
6
+ var _a;
7
+ return ((_a = options === null || options === void 0 ? void 0 : options.themeConfig) === null || _a === void 0 ? void 0 : _a.colorPrimary) || DEFAULT_COLOR;
7
8
  }
8
9
  export function getPaletteColors(options) {
10
+ var _a;
9
11
  const { themeConfig = {}, data } = options;
10
12
  const { colorPrimary, palette } = themeConfig;
11
13
  if (!palette || palette.length === 0) {
12
- return Array(data?.items?.length || 1).fill(colorPrimary || DEFAULT_COLOR);
14
+ return Array(((_a = data === null || data === void 0 ? void 0 : data.items) === null || _a === void 0 ? void 0 : _a.length) || 1).fill(colorPrimary || DEFAULT_COLOR);
13
15
  }
14
16
  return data.items.map((_, i) => _getPaletteColor(palette, [i], data.items.length) || DEFAULT_COLOR);
15
17
  }
16
18
  export function getPaletteColor(options, indexes) {
17
- return _getPaletteColor(options?.themeConfig?.palette, indexes, options.data?.items?.length);
19
+ var _a, _b, _c;
20
+ return _getPaletteColor((_a = options === null || options === void 0 ? void 0 : options.themeConfig) === null || _a === void 0 ? void 0 : _a.palette, indexes, (_c = (_b = options.data) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c.length);
18
21
  }
19
22
  export function getThemeColors(colors, options) {
20
- const { colorBg = options?.themeConfig?.colorBg || 'white', colorPrimary = options ? getColorPrimary(options) : 'black', } = colors;
23
+ var _a;
24
+ const { colorBg = ((_a = options === null || options === void 0 ? void 0 : options.themeConfig) === null || _a === void 0 ? void 0 : _a.colorBg) || 'white', colorPrimary = options ? getColorPrimary(options) : 'black', } = colors;
21
25
  return generateThemeColors({
22
26
  colorPrimary: colorPrimary,
23
27
  isDarkMode: isDarkColor(colorBg),
@@ -5,7 +5,7 @@
5
5
  * @returns
6
6
  */
7
7
  export function getItemProps(props, extKeys = []) {
8
- const restProps = { ...props };
8
+ const restProps = Object.assign({}, props);
9
9
  const extProps = {};
10
10
  const keys = [
11
11
  'indexes',
@@ -35,9 +35,10 @@ export function getItemProps(props, extKeys = []) {
35
35
  * 针对层级结构,获取当前层级对应的组件
36
36
  */
37
37
  export function getItemComponent(Items, level) {
38
+ var _a;
38
39
  if (Items.length === 0)
39
40
  return () => null;
40
41
  if (level === undefined)
41
42
  return Items[0];
42
- return Items[level] ?? Items[0];
43
+ return (_a = Items[level]) !== null && _a !== void 0 ? _a : Items[0];
43
44
  }
@@ -1,16 +1,29 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  export class BatchCommand {
2
11
  constructor(commands) {
3
12
  this.commands = commands;
4
13
  }
5
- async apply(state) {
6
- for (const command of this.commands) {
7
- await command.apply(state);
8
- }
14
+ apply(state) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ for (const command of this.commands) {
17
+ yield command.apply(state);
18
+ }
19
+ });
9
20
  }
10
- async undo(state) {
11
- for (let i = this.commands.length - 1; i >= 0; i--) {
12
- await this.commands[i].undo(state);
13
- }
21
+ undo(state) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ for (let i = this.commands.length - 1; i >= 0; i--) {
24
+ yield this.commands[i].undo(state);
25
+ }
26
+ });
14
27
  }
15
28
  serialize() {
16
29
  return {
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { getAttributes, getIconAttrs, getIconEntity, getTextElementProps, isEditableText, isIconElement, setAttributes, updateIconElement, updateTextElement, } from '../../utils/index.js';
2
11
  export class UpdateElementCommand {
3
12
  constructor(element, modified, original) {
@@ -6,15 +15,19 @@ export class UpdateElementCommand {
6
15
  const computedOriginal = getOriginalProps(element, modified);
7
16
  this.original = mergeOriginalProps(computedOriginal, original);
8
17
  }
9
- async apply(state) {
10
- updateElement(this.element, this.modified);
11
- state.updateElement(this.element, this.modified);
18
+ apply(state) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ updateElement(this.element, this.modified);
21
+ state.updateElement(this.element, this.modified);
22
+ });
12
23
  }
13
- async undo(state) {
14
- if (this.original) {
15
- updateElement(this.element, this.original);
16
- state.updateElement(this.element, this.original);
17
- }
24
+ undo(state) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ if (this.original) {
27
+ updateElement(this.element, this.original);
28
+ state.updateElement(this.element, this.original);
29
+ }
30
+ });
18
31
  }
19
32
  serialize() {
20
33
  return {
@@ -47,10 +60,7 @@ function getOriginalProps(element, modified) {
47
60
  originalAttributes[key] = attrs[key];
48
61
  });
49
62
  };
50
- const original = {
51
- ...modified,
52
- attributes: originalAttributes,
53
- };
63
+ const original = Object.assign(Object.assign({}, modified), { attributes: originalAttributes });
54
64
  if (isEditableText(element)) {
55
65
  const { attributes } = getTextElementProps(element);
56
66
  assignModifiedAttributes(attributes);
@@ -69,15 +79,8 @@ function mergeOriginalProps(computed, provided) {
69
79
  return provided;
70
80
  if (!provided)
71
81
  return computed;
72
- const mergedAttributes = {
73
- ...(computed.attributes || {}),
74
- ...(provided.attributes || {}),
75
- };
76
- return {
77
- ...computed,
78
- ...provided,
79
- attributes: Object.keys(mergedAttributes).length
82
+ const mergedAttributes = Object.assign(Object.assign({}, (computed.attributes || {})), (provided.attributes || {}));
83
+ return Object.assign(Object.assign(Object.assign({}, computed), provided), { attributes: Object.keys(mergedAttributes).length
80
84
  ? mergedAttributes
81
- : undefined,
82
- };
85
+ : undefined });
83
86
  }
@@ -1,19 +1,32 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  export class UpdateOptionsCommand {
2
11
  constructor(options, original) {
3
12
  this.options = options;
4
13
  this.original = original;
5
14
  }
6
- async apply(state) {
7
- const prev = state.getOptions();
8
- if (!this.original) {
9
- this.original = prev;
10
- }
11
- state.updateOptions({ ...prev, ...this.options });
15
+ apply(state) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const prev = state.getOptions();
18
+ if (!this.original) {
19
+ this.original = prev;
20
+ }
21
+ state.updateOptions(Object.assign(Object.assign({}, prev), this.options));
22
+ });
12
23
  }
13
- async undo(state) {
14
- if (this.original) {
15
- state.updateOptions(this.original);
16
- }
24
+ undo(state) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ if (this.original) {
27
+ state.updateOptions(this.original);
28
+ }
29
+ });
17
30
  }
18
31
  serialize() {
19
32
  return {
@@ -1,22 +1,35 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { getElementRole, getTextContent, setTextContent } from '../../utils/index.js';
2
11
  import { getIndexesFromElement } from '../utils/index.js';
3
12
  export class UpdateTextCommand {
4
13
  constructor(element, newText, originalText) {
5
14
  this.element = element;
6
- this.originalText = originalText ?? getTextContent(element);
15
+ this.originalText = originalText !== null && originalText !== void 0 ? originalText : getTextContent(element);
7
16
  this.modifiedText = newText;
8
17
  }
9
- async apply(state) {
10
- if (this.originalText === this.modifiedText)
11
- return;
12
- setTextContent(this.element, this.modifiedText);
13
- updateItemText(state, this.element, this.modifiedText);
18
+ apply(state) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ if (this.originalText === this.modifiedText)
21
+ return;
22
+ setTextContent(this.element, this.modifiedText);
23
+ updateItemText(state, this.element, this.modifiedText);
24
+ });
14
25
  }
15
- async undo(state) {
16
- if (this.originalText === this.modifiedText)
17
- return;
18
- setTextContent(this.element, this.originalText);
19
- updateItemText(state, this.element, this.originalText);
26
+ undo(state) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ if (this.originalText === this.modifiedText)
29
+ return;
30
+ setTextContent(this.element, this.originalText);
31
+ updateItemText(state, this.element, this.originalText);
32
+ });
20
33
  }
21
34
  serialize() {
22
35
  return {
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { createElement, setAttributes } from '../../utils/index.js';
2
11
  import { clientToViewport, getElementViewportBounds, getEventTarget, getSelectableTarget, } from '../utils/index.js';
3
12
  import { Interaction } from './base.js';
@@ -17,15 +26,17 @@ export class BrushSelect extends Interaction {
17
26
  return;
18
27
  if (this.hasElementAtStart(event.target))
19
28
  return;
20
- this.interaction.executeExclusiveInteraction(this, async () => new Promise((resolve) => {
21
- this.completeInteraction = resolve;
22
- const svg = this.editor.getDocument();
23
- this.startPoint = clientToViewport(svg, event.clientX, event.clientY);
24
- this.pointerId = event.pointerId;
25
- this.shiftKey = event.shiftKey;
26
- this.dragging = false;
27
- window.addEventListener('pointermove', this.handleMove);
28
- window.addEventListener('pointerup', this.handleEnd);
29
+ this.interaction.executeExclusiveInteraction(this, () => __awaiter(this, void 0, void 0, function* () {
30
+ return new Promise((resolve) => {
31
+ this.completeInteraction = resolve;
32
+ const svg = this.editor.getDocument();
33
+ this.startPoint = clientToViewport(svg, event.clientX, event.clientY);
34
+ this.pointerId = event.pointerId;
35
+ this.shiftKey = event.shiftKey;
36
+ this.dragging = false;
37
+ window.addEventListener('pointermove', this.handleMove);
38
+ window.addEventListener('pointerup', this.handleEnd);
39
+ });
29
40
  }));
30
41
  };
31
42
  this.handleMove = (event) => {
@@ -47,6 +58,7 @@ export class BrushSelect extends Interaction {
47
58
  this.updateBrush(this.startPoint, current);
48
59
  };
49
60
  this.handleEnd = (event) => {
61
+ var _a, _b;
50
62
  if (event.pointerId !== this.pointerId || !this.startPoint)
51
63
  return;
52
64
  window.removeEventListener('pointermove', this.handleMove);
@@ -66,12 +78,12 @@ export class BrushSelect extends Interaction {
66
78
  const withShift = this.shiftKey;
67
79
  this.shiftKey = false;
68
80
  if (!rect) {
69
- this.completeInteraction?.();
81
+ (_a = this.completeInteraction) === null || _a === void 0 ? void 0 : _a.call(this);
70
82
  this.completeInteraction = undefined;
71
83
  return;
72
84
  }
73
85
  const selection = this.collectSelection(rect);
74
- this.completeInteraction?.();
86
+ (_b = this.completeInteraction) === null || _b === void 0 ? void 0 : _b.call(this);
75
87
  this.completeInteraction = undefined;
76
88
  if (selection.length === 0) {
77
89
  if (!withShift)
@@ -117,7 +129,8 @@ export class BrushSelect extends Interaction {
117
129
  return { x, y, width, height };
118
130
  }
119
131
  clearBrush() {
120
- this.brush?.remove();
132
+ var _a;
133
+ (_a = this.brush) === null || _a === void 0 ? void 0 : _a.remove();
121
134
  this.brush = undefined;
122
135
  }
123
136
  collectSelection(rect) {
@@ -150,11 +163,12 @@ export class BrushSelect extends Interaction {
150
163
  }, []);
151
164
  }
152
165
  hasElementAtStart(target) {
166
+ var _a;
153
167
  if (!(target instanceof Element))
154
168
  return false;
155
169
  if (getEventTarget(target))
156
170
  return true;
157
- return Boolean(target.closest?.('[data-element-type]'));
171
+ return Boolean((_a = target.closest) === null || _a === void 0 ? void 0 : _a.call(target, '[data-element-type]'));
158
172
  }
159
173
  isTextSelectionTarget(target) {
160
174
  if (!(target instanceof HTMLElement))
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { isEditingText } from '../../utils/index.js';
2
11
  import { ClickHandler, getEventTarget } from '../utils/index.js';
3
12
  import { Interaction } from './base.js';
@@ -29,7 +38,7 @@ export class ClickSelect extends Interaction {
29
38
  const handleSelect = (event) => {
30
39
  if (!interaction.isActive())
31
40
  return;
32
- interaction.executeExclusiveInteraction(this, async () => {
41
+ interaction.executeExclusiveInteraction(this, () => __awaiter(this, void 0, void 0, function* () {
33
42
  const target = getEventTarget(event.target);
34
43
  if (isEditingText(target))
35
44
  return;
@@ -51,7 +60,7 @@ export class ClickSelect extends Interaction {
51
60
  else
52
61
  interaction.clearSelection();
53
62
  }
54
- });
63
+ }));
55
64
  };
56
65
  this.clickHandler.onClick(handleSelect);
57
66
  document.addEventListener('keydown', this.onShiftKeyDown);
@@ -59,7 +68,8 @@ export class ClickSelect extends Interaction {
59
68
  document.addEventListener('keydown', this.onEscKeyDown);
60
69
  }
61
70
  destroy() {
62
- this.clickHandler?.destroy();
71
+ var _a;
72
+ (_a = this.clickHandler) === null || _a === void 0 ? void 0 : _a.destroy();
63
73
  document.removeEventListener('keydown', this.onShiftKeyDown);
64
74
  document.removeEventListener('keyup', this.onShiftKeyUp);
65
75
  document.removeEventListener('keydown', this.onEscKeyDown);
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { getTextContent, getTextEntity, injectStyleOnce, isEditableText, } from '../../utils/index.js';
2
11
  import { UpdateTextCommand } from '../commands/index.js';
3
12
  import { ClickHandler, getEventTarget } from '../utils/index.js';
@@ -13,14 +22,14 @@ export class DblClickEditText extends Interaction {
13
22
  this.clickHandler = new ClickHandler(editor.getDocument()).onDoubleClick((event) => {
14
23
  if (!interaction.isActive())
15
24
  return;
16
- interaction.executeExclusiveInteraction(this, async () => {
25
+ interaction.executeExclusiveInteraction(this, () => __awaiter(this, void 0, void 0, function* () {
17
26
  const target = getEventTarget(event.target);
18
27
  if (!target)
19
28
  return;
20
29
  if (isEditableText(target)) {
21
30
  interaction.select([target], 'replace');
22
31
  const originalText = getTextContent(target);
23
- const text = await new Promise((resolve) => {
32
+ const text = yield new Promise((resolve) => {
24
33
  const stopListen = this.listenSelectionChange(target);
25
34
  editText(target, {
26
35
  cursorPosition: {
@@ -34,17 +43,19 @@ export class DblClickEditText extends Interaction {
34
43
  });
35
44
  commander.execute(new UpdateTextCommand(target, text, originalText));
36
45
  }
37
- });
46
+ }));
38
47
  });
39
48
  }
40
49
  destroy() {
41
- this.clickHandler?.destroy();
42
- this.detachSelectionListener?.();
50
+ var _a, _b;
51
+ (_a = this.clickHandler) === null || _a === void 0 ? void 0 : _a.destroy();
52
+ (_b = this.detachSelectionListener) === null || _b === void 0 ? void 0 : _b.call(this);
43
53
  }
44
54
  listenSelectionChange(target) {
45
55
  const handler = ({ next }) => {
56
+ var _a;
46
57
  if (!next.includes(target)) {
47
- this.detachSelectionListener?.();
58
+ (_a = this.detachSelectionListener) === null || _a === void 0 ? void 0 : _a.call(this);
48
59
  this.detachSelectionListener = undefined;
49
60
  const entity = getTextEntity(target);
50
61
  if (entity)
@@ -81,14 +92,16 @@ class InlineTextEditor {
81
92
  }
82
93
  };
83
94
  this.handleInput = () => {
95
+ var _a, _b;
84
96
  this.normalizeSpanContent();
85
- this.options?.onInput?.(this.getText());
97
+ (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.onInput) === null || _b === void 0 ? void 0 : _b.call(_a, this.getText());
86
98
  };
87
99
  this.handleBlur = () => {
100
+ var _a, _b;
88
101
  this.entity.removeAttribute('contenteditable');
89
102
  this.entity.classList.remove(EDITOR_BASE_CLASS);
90
103
  this.normalizeSpanContent();
91
- this.options?.onBlur?.(this.getText());
104
+ (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, this.getText());
92
105
  this.detachListeners();
93
106
  };
94
107
  }
@@ -111,6 +124,7 @@ class InlineTextEditor {
111
124
  this.entity.removeEventListener('input', this.handleInput);
112
125
  }
113
126
  insertPlainText(text) {
127
+ var _a, _b;
114
128
  const selection = window.getSelection();
115
129
  if (!selection)
116
130
  return;
@@ -129,11 +143,12 @@ class InlineTextEditor {
129
143
  selection.addRange(range);
130
144
  // Mirror native input behavior so consumers stay in sync.
131
145
  this.normalizeSpanContent();
132
- this.options?.onInput?.(this.getText());
146
+ (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.onInput) === null || _b === void 0 ? void 0 : _b.call(_a, this.getText());
133
147
  }
134
148
  normalizeSpanContent() {
149
+ var _a;
135
150
  if (this.entity.childNodes.length === 1 &&
136
- this.entity.firstChild?.nodeType === Node.TEXT_NODE) {
151
+ ((_a = this.entity.firstChild) === null || _a === void 0 ? void 0 : _a.nodeType) === Node.TEXT_NODE) {
137
152
  return;
138
153
  }
139
154
  const plainText = this.getText();
@@ -152,21 +167,22 @@ class InlineTextEditor {
152
167
  this.placeCaretAtEnd();
153
168
  }
154
169
  getRangeFromPoint() {
170
+ var _a, _b;
155
171
  const { cursorPosition } = this.options || {};
156
172
  if (!cursorPosition)
157
173
  return null;
158
174
  const { clientX, clientY } = cursorPosition;
159
175
  const doc = document;
160
- const rangeFromPoint = doc.caretRangeFromPoint?.(clientX, clientY) ??
161
- (() => {
162
- const caretPosition = doc.caretPositionFromPoint?.(clientX, clientY);
163
- if (!caretPosition)
164
- return null;
165
- const caretRange = document.createRange();
166
- caretRange.setStart(caretPosition.offsetNode, caretPosition.offset);
167
- caretRange.collapse(true);
168
- return caretRange;
169
- })();
176
+ const rangeFromPoint = (_b = (_a = doc.caretRangeFromPoint) === null || _a === void 0 ? void 0 : _a.call(doc, clientX, clientY)) !== null && _b !== void 0 ? _b : (() => {
177
+ var _a;
178
+ const caretPosition = (_a = doc.caretPositionFromPoint) === null || _a === void 0 ? void 0 : _a.call(doc, clientX, clientY);
179
+ if (!caretPosition)
180
+ return null;
181
+ const caretRange = document.createRange();
182
+ caretRange.setStart(caretPosition.offsetNode, caretPosition.offset);
183
+ caretRange.collapse(true);
184
+ return caretRange;
185
+ })();
170
186
  if (!rangeFromPoint)
171
187
  return null;
172
188
  if (!this.entity.contains(rangeFromPoint.startContainer))