@idraw/core 0.4.0-beta.40 → 0.4.0-beta.41

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 (32) hide show
  1. package/dist/esm/board/index.d.ts +2 -4
  2. package/dist/esm/board/index.js +20 -33
  3. package/dist/esm/index.d.ts +22 -7
  4. package/dist/esm/index.js +233 -2
  5. package/dist/esm/middleware/dragger/index.d.ts +2 -2
  6. package/dist/esm/middleware/info/draw-info.js +3 -3
  7. package/dist/esm/middleware/info/index.d.ts +2 -2
  8. package/dist/esm/middleware/layout-selector/index.d.ts +2 -2
  9. package/dist/esm/middleware/layout-selector/index.js +24 -2
  10. package/dist/esm/middleware/layout-selector/util.js +19 -4
  11. package/dist/esm/middleware/pointer/index.d.ts +2 -2
  12. package/dist/esm/middleware/pointer/index.js +11 -12
  13. package/dist/esm/middleware/ruler/config.js +1 -1
  14. package/dist/esm/middleware/ruler/index.d.ts +2 -2
  15. package/dist/esm/middleware/ruler/index.js +1 -1
  16. package/dist/esm/middleware/ruler/util.js +5 -4
  17. package/dist/esm/middleware/scaler/index.d.ts +2 -2
  18. package/dist/esm/middleware/scroller/index.d.ts +2 -2
  19. package/dist/esm/middleware/scroller/util.js +1 -1
  20. package/dist/esm/middleware/selector/draw-base.js +2 -2
  21. package/dist/esm/middleware/selector/draw-debug.js +1 -1
  22. package/dist/esm/middleware/selector/draw-wrapper.js +15 -5
  23. package/dist/esm/middleware/selector/index.d.ts +2 -2
  24. package/dist/esm/middleware/selector/index.js +35 -5
  25. package/dist/esm/middleware/selector/types.d.ts +2 -2
  26. package/dist/esm/middleware/text-editor/index.d.ts +2 -2
  27. package/dist/esm/middleware/text-editor/index.js +85 -22
  28. package/dist/esm/record.d.ts +5 -0
  29. package/dist/esm/record.js +38 -0
  30. package/dist/index.global.js +1050 -139
  31. package/dist/index.global.min.js +1 -1
  32. package/package.json +4 -4
@@ -8,7 +8,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
8
8
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
9
9
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
10
10
 
11
- var _opts, _store, _hasDestroyed, _BoardWatcher_instances, init_fn, _onWheel, _onContextMenu, _onClick, _onPointLeave, _onPointEnd, _onPointMove, _onPointStart, _onHover, isInTarget_fn, getPoint_fn, isVaildPoint_fn, _activeStore, _sharedStore, _opts2, _drawFrameSnapshotQueue, _drawFrameStatus, _Viewer_instances, init_fn2, drawAnimationFrame_fn, _opts3, _middlewareMap, _middlewares, _activeMiddlewareObjs, _watcher, _renderer, _sharer, _viewer, _calculator, _eventHub, _hasDestroyed2, _Board_instances, init_fn3, handlePointStart_fn, handlePointEnd_fn, handlePointMove_fn, handlePointLeave_fn, handleHover_fn, handleDoubleClick_fn, handleContextMenu_fn, handleWheel_fn, handleWheelScale_fn, handleScrollX_fn, handleScrollY_fn, handleResize_fn, handleClear_fn, handleBeforeDrawFrame_fn, handleAfterDrawFrame_fn, resetActiveMiddlewareObjs_fn, _eventHub2, _container, _cursorType, _resizeCursorBaseImage, _cursorImageMap, _Cursor_instances, init_fn4, loadResizeCursorBaseImage_fn, resetCursor_fn, setCursorResize_fn, appendRotateResizeImage_fn, _board, _canvas, _container2, _Core_instances, initContainer_fn;
11
+ var _opts, _store, _hasDestroyed, _BoardWatcher_instances, init_fn, _onWheel, _onContextMenu, _onClick, _onPointLeave, _onPointEnd, _onPointMove, _onPointStart, _onHover, isInTarget_fn, getPoint_fn, isVaildPoint_fn, _activeStore, _sharedStore, _opts2, _drawFrameSnapshotQueue, _drawFrameStatus, _Viewer_instances, init_fn2, drawAnimationFrame_fn, _opts3, _middlewareMap, _activeMiddlewareObjs, _watcher, _renderer, _sharer, _viewer, _calculator, _eventHub, _hasDestroyed2, _Board_instances, init_fn3, handlePointStart_fn, handlePointEnd_fn, handlePointMove_fn, handlePointLeave_fn, handleHover_fn, handleDoubleClick_fn, handleContextMenu_fn, handleWheel_fn, handleWheelScale_fn, handleScrollX_fn, handleScrollY_fn, handleResize_fn, handleClear_fn, handleBeforeDrawFrame_fn, handleAfterDrawFrame_fn, resetActiveMiddlewareObjs_fn, _eventHub2, _container, _cursorType, _resizeCursorBaseImage, _cursorImageMap, _Cursor_instances, init_fn4, loadResizeCursorBaseImage_fn, resetCursor_fn, setCursorResize_fn, appendRotateResizeImage_fn, _board, _canvas, _container2, _Core_instances, initContainer_fn;
12
12
  function isColorStr(color2) {
13
13
  return typeof color2 === "string" && (/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2) || /^[a-z]{1,}$/i.test(color2));
14
14
  }
@@ -33,36 +33,50 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
33
33
  }
34
34
  return result;
35
35
  }
36
+ function generate32Base36Hash(str) {
37
+ const hash256 = generate256BitHash(str);
38
+ return bigIntToBase36(hash256).padStart(32, "0").slice(0, 32);
39
+ }
40
+ function generate256BitHash(str) {
41
+ let h1 = 0xcbf29ce484222325n, h2 = 0x84222325cbf29ce4n;
42
+ let h3 = 0x1b3n * h1, h4 = 0x1000000n * h2;
43
+ const prime = 0x100000001b3n;
44
+ const chunkSize = 4096;
45
+ for (let i = 0; i < str.length; i += chunkSize) {
46
+ const chunk = str.slice(i, i + chunkSize);
47
+ for (let j = 0; j < chunk.length; j++) {
48
+ const code = BigInt(chunk.charCodeAt(j) + i + j);
49
+ h1 = (h1 ^ code) * prime;
50
+ h2 = (h2 ^ h1) * prime ^ h3;
51
+ h3 = (h3 ^ h2) * prime + h4;
52
+ h4 = (h4 ^ h3) * prime | 0x1234567890abcdefn;
53
+ }
54
+ }
55
+ return h1 << 192n | h2 << 128n | h3 << 64n | h4;
56
+ }
57
+ function bigIntToBase36(num) {
58
+ const chars = "0123456789abcdefghijklmnopqrstuvwxyz";
59
+ if (num === 0n)
60
+ return "0";
61
+ let result = "";
62
+ while (num > 0n) {
63
+ const rem = num % 36n;
64
+ result = chars[Number(rem)] + result;
65
+ num = num / 36n;
66
+ }
67
+ return result;
68
+ }
36
69
  function createUUID() {
37
70
  function _createStr() {
38
71
  return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
39
72
  }
40
73
  return `${_createStr()}${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}${_createStr()}${_createStr()}`;
41
74
  }
42
- function limitHexStr(str) {
43
- let count = 0;
44
- for (let i = 0; i < str.length; i++) {
45
- count += str.charCodeAt(i) * str.charCodeAt(i) * i * i;
46
- }
47
- return count.toString(16).substring(0, 4);
48
- }
49
75
  function createAssetId(assetStr) {
50
- const len = assetStr.length;
51
- const mid = Math.floor(len / 2);
52
- const start4 = assetStr.substring(0, 4).padEnd(4, "0");
53
- const end4 = assetStr.substring(0, 4).padEnd(4, "0");
54
- const str1 = limitHexStr(len.toString(16).padEnd(4, start4));
55
- const str2 = limitHexStr(assetStr.substring(mid - 4, mid).padEnd(4, start4)).padEnd(4, "f");
56
- const str3 = limitHexStr(assetStr.substring(mid - 8, mid - 4).padEnd(4, start4)).padEnd(4, "f");
57
- const str4 = limitHexStr(assetStr.substring(mid - 12, mid - 8).padEnd(4, start4)).padEnd(4, "f");
58
- const str5 = limitHexStr(assetStr.substring(mid - 16, mid - 12).padEnd(4, end4)).padEnd(4, "f");
59
- const str6 = limitHexStr(assetStr.substring(mid, mid + 4).padEnd(4, end4)).padEnd(4, "f");
60
- const str7 = limitHexStr(assetStr.substring(mid + 4, mid + 8).padEnd(4, end4)).padEnd(4, "f");
61
- const str8 = limitHexStr(end4.padEnd(4, start4).padEnd(4, end4));
62
- return `@assets/${str1}${str2}-${str3}-${str4}-${str5}-${str6}${str7}${str8}`;
76
+ return `@assets/${generate32Base36Hash(assetStr)}`;
63
77
  }
64
78
  function isAssetId(id) {
65
- return /^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${id}`);
79
+ return /^@assets\/[0-9a-z-]{0,}$/.test(`${id}`);
66
80
  }
67
81
  (function(s, e) {
68
82
  var t = {};
@@ -1092,7 +1106,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1092
1106
  return ctxSize;
1093
1107
  }
1094
1108
  function calcElementsViewInfo(elements, prevViewSize, options) {
1095
- const contextSize = calcElementsContextSize(elements, { viewWidth: prevViewSize.width, viewHeight: prevViewSize.height, extend: options === null || options === void 0 ? void 0 : options.extend });
1109
+ const contextSize = calcElementsContextSize(elements, {
1110
+ viewWidth: prevViewSize.width,
1111
+ viewHeight: prevViewSize.height,
1112
+ extend: options === null || options === void 0 ? void 0 : options.extend
1113
+ });
1096
1114
  if ((options === null || options === void 0 ? void 0 : options.extend) === true) {
1097
1115
  contextSize.contextWidth = Math.max(contextSize.contextWidth, prevViewSize.contextWidth);
1098
1116
  contextSize.contextHeight = Math.max(contextSize.contextHeight, prevViewSize.contextHeight);
@@ -1181,7 +1199,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1181
1199
  for (let i = 0; i < position.length; i++) {
1182
1200
  const pos = position[i];
1183
1201
  const item = tempList[pos];
1184
- if (i < position.length - 1 && item.type === "group") {
1202
+ if (i < position.length - 1 && (item === null || item === void 0 ? void 0 : item.type) === "group") {
1185
1203
  tempList = item.detail.children;
1186
1204
  } else if (i === position.length - 1) {
1187
1205
  result = item;
@@ -1624,15 +1642,38 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1624
1642
  const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: totalAngle });
1625
1643
  const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: totalAngle });
1626
1644
  const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: totalAngle });
1627
- const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, { size: ctrlSize, angle: totalAngle });
1645
+ const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, {
1646
+ size: ctrlSize,
1647
+ angle: totalAngle
1648
+ });
1628
1649
  const topLeftVertexes = calcElementVertexes(topLeftSize);
1629
1650
  const topRightVertexes = calcElementVertexes(topRightSize);
1630
1651
  const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
1631
1652
  const bottomRightVertexes = calcElementVertexes(bottomRightSize);
1632
- const topVertexes = [topLeftVertexes[1], topRightVertexes[0], topRightVertexes[3], topLeftVertexes[2]];
1633
- const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
1634
- const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
1635
- const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
1653
+ const topVertexes = [
1654
+ topLeftVertexes[1],
1655
+ topRightVertexes[0],
1656
+ topRightVertexes[3],
1657
+ topLeftVertexes[2]
1658
+ ];
1659
+ const rightVertexes = [
1660
+ topRightVertexes[3],
1661
+ topRightVertexes[2],
1662
+ bottomRightVertexes[1],
1663
+ bottomRightVertexes[0]
1664
+ ];
1665
+ const bottomVertexes = [
1666
+ bottomLeftVertexes[1],
1667
+ bottomRightVertexes[0],
1668
+ bottomRightVertexes[3],
1669
+ bottomLeftVertexes[2]
1670
+ ];
1671
+ const leftVertexes = [
1672
+ topLeftVertexes[3],
1673
+ topLeftVertexes[2],
1674
+ bottomLeftVertexes[1],
1675
+ bottomLeftVertexes[0]
1676
+ ];
1636
1677
  const topMiddleVertexes = calcElementVertexes(topMiddleSize);
1637
1678
  const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
1638
1679
  const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
@@ -1754,10 +1795,30 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1754
1795
  const topRightVertexes = calcElementVertexes(topRightSize);
1755
1796
  const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
1756
1797
  const bottomRightVertexes = calcElementVertexes(bottomRightSize);
1757
- const topVertexes = [topLeftVertexes[1], topRightVertexes[0], topRightVertexes[3], topLeftVertexes[2]];
1758
- const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
1759
- const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
1760
- const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
1798
+ const topVertexes = [
1799
+ topLeftVertexes[1],
1800
+ topRightVertexes[0],
1801
+ topRightVertexes[3],
1802
+ topLeftVertexes[2]
1803
+ ];
1804
+ const rightVertexes = [
1805
+ topRightVertexes[3],
1806
+ topRightVertexes[2],
1807
+ bottomRightVertexes[1],
1808
+ bottomRightVertexes[0]
1809
+ ];
1810
+ const bottomVertexes = [
1811
+ bottomLeftVertexes[1],
1812
+ bottomRightVertexes[0],
1813
+ bottomRightVertexes[3],
1814
+ bottomLeftVertexes[2]
1815
+ ];
1816
+ const leftVertexes = [
1817
+ topLeftVertexes[3],
1818
+ topLeftVertexes[2],
1819
+ bottomLeftVertexes[1],
1820
+ bottomLeftVertexes[0]
1821
+ ];
1761
1822
  const topMiddleVertexes = calcElementVertexes(topMiddleSize);
1762
1823
  const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
1763
1824
  const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
@@ -1852,6 +1913,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1852
1913
  }
1853
1914
  return parseFloat(num.toFixed(decimalPlaces));
1854
1915
  }
1916
+ const defaultText = "Text Element";
1855
1917
  function getDefaultElementDetailConfig() {
1856
1918
  const config = {
1857
1919
  boxSizing: "border-box",
@@ -1876,6 +1938,53 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1876
1938
  };
1877
1939
  return config;
1878
1940
  }
1941
+ function getDefaultElementRectDetail() {
1942
+ const detail = {
1943
+ background: "#D9D9D9"
1944
+ };
1945
+ return detail;
1946
+ }
1947
+ function getDefaultElementCircleDetail() {
1948
+ const detail = {
1949
+ background: "#D9D9D9",
1950
+ radius: 0
1951
+ };
1952
+ return detail;
1953
+ }
1954
+ function getDefaultElementTextDetail(elementSize) {
1955
+ const detailConfig2 = getDefaultElementDetailConfig();
1956
+ const detail = {
1957
+ text: defaultText,
1958
+ color: detailConfig2.color,
1959
+ fontFamily: detailConfig2.fontFamily,
1960
+ fontWeight: detailConfig2.fontWeight,
1961
+ lineHeight: elementSize.w / defaultText.length,
1962
+ fontSize: elementSize.w / defaultText.length,
1963
+ textAlign: "center",
1964
+ verticalAlign: "middle"
1965
+ };
1966
+ return detail;
1967
+ }
1968
+ function getDefaultElementSVGDetail() {
1969
+ const detail = {
1970
+ svg: '<svg t="1701004189871" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9 0.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-0.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z" fill="#2c2c2c"></path></svg>'
1971
+ };
1972
+ return detail;
1973
+ }
1974
+ function getDefaultElementImageDetail() {
1975
+ const detail = {
1976
+ src: "data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="
1977
+ };
1978
+ return detail;
1979
+ }
1980
+ function getDefaultElementGroupDetail() {
1981
+ const detail = {
1982
+ children: [],
1983
+ background: "#D9D9D9",
1984
+ overflow: "hidden"
1985
+ };
1986
+ return detail;
1987
+ }
1879
1988
  const defaultElemConfig$1 = getDefaultElementDetailConfig();
1880
1989
  function calcViewBoxSize(viewElem, opts) {
1881
1990
  const { viewScaleInfo } = opts;
@@ -1928,6 +2037,107 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1928
2037
  radiusList
1929
2038
  };
1930
2039
  }
2040
+ function flattenObject(obj, parentKey = "", result = {}, opts) {
2041
+ Object.keys(obj).forEach((key2) => {
2042
+ var _a;
2043
+ const currentKey = parentKey ? `${parentKey}${isArrayIndex(key2) ? `[${key2}]` : `.${key2}`}` : key2;
2044
+ if (!((_a = opts === null || opts === void 0 ? void 0 : opts.ignorePaths) === null || _a === void 0 ? void 0 : _a.includes(currentKey))) {
2045
+ const value = obj[key2];
2046
+ if (isFlattenable(value)) {
2047
+ flattenObject(value, Array.isArray(value) ? currentKey : currentKey, result, opts);
2048
+ } else {
2049
+ result[currentKey] = value;
2050
+ }
2051
+ }
2052
+ });
2053
+ return result;
2054
+ }
2055
+ function isFlattenable(value) {
2056
+ return typeof value === "object" && value !== null && !(value instanceof Date) || Array.isArray(value);
2057
+ }
2058
+ function isArrayIndex(key2) {
2059
+ return /^\d+$/.test(key2) && !isNaN(Number(key2));
2060
+ }
2061
+ function flatObject(obj, opts) {
2062
+ if (typeof obj !== "object" || obj === null) {
2063
+ return { "": obj };
2064
+ }
2065
+ return flattenObject(obj, "", {}, opts);
2066
+ }
2067
+ function toFlattenElement(elem) {
2068
+ return flatObject(elem, { ignorePaths: ["detail.children"] });
2069
+ }
2070
+ function toFlattenLayout(layout) {
2071
+ return flatObject(layout);
2072
+ }
2073
+ function toFlattenGlobal(global) {
2074
+ return flatObject(global);
2075
+ }
2076
+ function toPath(path) {
2077
+ if (Array.isArray(path))
2078
+ return [...path];
2079
+ return path.split(/\.|\[|\]/).filter((key2) => key2 !== "");
2080
+ }
2081
+ function get(obj, path, defaultValue) {
2082
+ if (!path) {
2083
+ return void 0;
2084
+ }
2085
+ const pathArray = toPath(path);
2086
+ let current = obj;
2087
+ for (const key2 of pathArray) {
2088
+ if (current === null || current === void 0) {
2089
+ return defaultValue;
2090
+ }
2091
+ current = current[key2];
2092
+ }
2093
+ return current !== void 0 ? current : defaultValue;
2094
+ }
2095
+ function set(obj, path, value) {
2096
+ const pathArray = toPath(path);
2097
+ if (pathArray.length === 0) {
2098
+ return obj;
2099
+ }
2100
+ let current = obj;
2101
+ if (current) {
2102
+ for (let i = 0; i < pathArray.length; i++) {
2103
+ const key2 = pathArray[i];
2104
+ if (i === pathArray.length - 1) {
2105
+ current[key2] = value;
2106
+ break;
2107
+ }
2108
+ if (current && ((current === null || current === void 0 ? void 0 : current[key2]) === void 0 || typeof (current === null || current === void 0 ? void 0 : current[key2]) !== "object" || (current === null || current === void 0 ? void 0 : current[key2]) === null)) {
2109
+ const nextKey = pathArray[i + 1];
2110
+ const isNextNumeric = /^\d+$/.test(nextKey);
2111
+ current[key2] = isNextNumeric ? [] : {};
2112
+ }
2113
+ current = current === null || current === void 0 ? void 0 : current[key2];
2114
+ }
2115
+ }
2116
+ return obj;
2117
+ }
2118
+ function del(obj, path) {
2119
+ const pathArray = toPath(path);
2120
+ if (pathArray.length === 0) {
2121
+ return obj;
2122
+ }
2123
+ let current = obj;
2124
+ if (current) {
2125
+ for (let i = 0; i < pathArray.length; i++) {
2126
+ const key2 = pathArray[i];
2127
+ if (i === pathArray.length - 1) {
2128
+ delete current[key2];
2129
+ break;
2130
+ }
2131
+ if (current && ((current === null || current === void 0 ? void 0 : current[key2]) === void 0 || typeof (current === null || current === void 0 ? void 0 : current[key2]) !== "object" || (current === null || current === void 0 ? void 0 : current[key2]) === null)) {
2132
+ const nextKey = pathArray[i + 1];
2133
+ const isNextNumeric = /^\d+$/.test(nextKey);
2134
+ current[key2] = isNextNumeric ? [] : {};
2135
+ }
2136
+ current = current === null || current === void 0 ? void 0 : current[key2];
2137
+ }
2138
+ }
2139
+ return obj;
2140
+ }
1931
2141
  const doNum = (n) => {
1932
2142
  return formatNumber(n, { decimalPlaces: 4 });
1933
2143
  };
@@ -2020,6 +2230,266 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2020
2230
  resizeElementBaseDetail(elem, opts);
2021
2231
  return elem;
2022
2232
  }
2233
+ const defaultViewWidth = 200;
2234
+ const defaultViewHeight = 200;
2235
+ function createElementSize(type, opts) {
2236
+ let x2 = 0;
2237
+ let y2 = 0;
2238
+ let w2 = defaultViewWidth;
2239
+ let h2 = defaultViewHeight;
2240
+ if (opts) {
2241
+ const { viewScaleInfo, viewSizeInfo } = opts;
2242
+ const { scale, offsetLeft, offsetTop } = viewScaleInfo;
2243
+ const { width, height } = viewSizeInfo;
2244
+ const limitViewWidth = width / 4;
2245
+ const limitViewHeight = height / 4;
2246
+ if (defaultViewWidth >= limitViewWidth) {
2247
+ w2 = limitViewWidth / scale;
2248
+ } else {
2249
+ w2 = defaultViewWidth / scale;
2250
+ }
2251
+ if (defaultViewHeight >= limitViewHeight) {
2252
+ h2 = limitViewHeight / scale;
2253
+ } else {
2254
+ h2 = defaultViewHeight / scale;
2255
+ }
2256
+ if (["circle", "svg", "image"].includes(type)) {
2257
+ w2 = h2 = Math.max(w2, h2);
2258
+ } else if (type === "text") {
2259
+ const fontSize2 = w2 / defaultText.length;
2260
+ h2 = fontSize2 * 2;
2261
+ }
2262
+ x2 = (0 - offsetLeft + width / 2 - w2 * scale / 2) / scale;
2263
+ y2 = (0 - offsetTop + height / 2 - h2 * scale / 2) / scale;
2264
+ }
2265
+ const elemSize = {
2266
+ x: x2,
2267
+ y: y2,
2268
+ w: w2,
2269
+ h: h2
2270
+ };
2271
+ return elemSize;
2272
+ }
2273
+ function createElement(type, baseElem, opts) {
2274
+ const elementSize = createElementSize(type, opts);
2275
+ let detail = {};
2276
+ if (type === "rect") {
2277
+ detail = getDefaultElementRectDetail();
2278
+ } else if (type === "circle") {
2279
+ detail = getDefaultElementCircleDetail();
2280
+ } else if (type === "text") {
2281
+ detail = getDefaultElementTextDetail(elementSize);
2282
+ } else if (type === "svg") {
2283
+ detail = getDefaultElementSVGDetail();
2284
+ } else if (type === "image") {
2285
+ detail = getDefaultElementImageDetail();
2286
+ } else if (type === "group") {
2287
+ detail = getDefaultElementGroupDetail();
2288
+ }
2289
+ const elem = Object.assign(Object.assign(Object.assign({ uuid: createUUID() }, elementSize), baseElem), { type, detail: Object.assign(Object.assign({}, detail), baseElem.detail || {}) });
2290
+ return elem;
2291
+ }
2292
+ function insertElementToListByPosition(element, position, list) {
2293
+ let result = false;
2294
+ if (position.length === 1) {
2295
+ const pos = position[0];
2296
+ list.splice(pos, 0, element);
2297
+ result = true;
2298
+ } else if (position.length > 1) {
2299
+ let tempList = list;
2300
+ for (let i = 0; i < position.length; i++) {
2301
+ const pos = position[i];
2302
+ const item = tempList[pos];
2303
+ if (i === position.length - 1) {
2304
+ const pos2 = position[i];
2305
+ tempList.splice(pos2, 0, element);
2306
+ result = true;
2307
+ } else if (i < position.length - 1 && item.type === "group") {
2308
+ tempList = item.detail.children;
2309
+ } else {
2310
+ break;
2311
+ }
2312
+ }
2313
+ }
2314
+ return result;
2315
+ }
2316
+ function deleteElementInListByPosition(position, list) {
2317
+ let result = false;
2318
+ if (position.length === 1) {
2319
+ const pos = position[0];
2320
+ list.splice(pos, 1);
2321
+ result = true;
2322
+ } else if (position.length > 1) {
2323
+ let tempList = list;
2324
+ for (let i = 0; i < position.length; i++) {
2325
+ const pos = position[i];
2326
+ const item = tempList[pos];
2327
+ if (i === position.length - 1) {
2328
+ const pos2 = position[i];
2329
+ tempList.splice(pos2, 1);
2330
+ result = true;
2331
+ } else if (i < position.length - 1 && item.type === "group") {
2332
+ tempList = item.detail.children;
2333
+ } else {
2334
+ break;
2335
+ }
2336
+ }
2337
+ }
2338
+ return result;
2339
+ }
2340
+ function deleteElementInList(uuid, list) {
2341
+ const position = getElementPositionFromList(uuid, list);
2342
+ return deleteElementInListByPosition(position, list);
2343
+ }
2344
+ function moveElementPosition(elements, opts) {
2345
+ const from = [...opts.from];
2346
+ const to = [...opts.to];
2347
+ if (from.length === 0 || to.length === 0) {
2348
+ return { elements, from, to };
2349
+ }
2350
+ if (from.length <= to.length) {
2351
+ for (let i = 0; i < from.length; i++) {
2352
+ if (to[i] === from[i]) {
2353
+ if (i === from.length - 1) {
2354
+ return { elements, from, to };
2355
+ }
2356
+ continue;
2357
+ }
2358
+ }
2359
+ }
2360
+ const target = findElementFromListByPosition(from, elements);
2361
+ if (target) {
2362
+ const insterResult = insertElementToListByPosition(target, to, elements);
2363
+ if (!insterResult) {
2364
+ return { elements, from, to };
2365
+ }
2366
+ let trimDeletePosIndex = -1;
2367
+ let isEffectToIndex = false;
2368
+ if (from.length >= 1 && to.length >= 1) {
2369
+ if (from.length <= to.length) {
2370
+ if (from.length === 1) {
2371
+ if (from[0] < to[0]) {
2372
+ isEffectToIndex = true;
2373
+ }
2374
+ } else {
2375
+ for (let i = 0; i < from.length; i++) {
2376
+ if (from[i] === to[i]) {
2377
+ if (from.length === from.length - 1) {
2378
+ isEffectToIndex = true;
2379
+ break;
2380
+ }
2381
+ } else {
2382
+ break;
2383
+ }
2384
+ }
2385
+ }
2386
+ }
2387
+ if (from.length >= to.length) {
2388
+ if (to.length === 1) {
2389
+ if (to[0] < from[0]) {
2390
+ isEffectToIndex = true;
2391
+ }
2392
+ } else {
2393
+ for (let i = 0; i < to.length; i++) {
2394
+ if (i === to.length - 1 && to[i] < from[i]) {
2395
+ isEffectToIndex = true;
2396
+ }
2397
+ if (from[i] === to[i]) {
2398
+ continue;
2399
+ } else {
2400
+ break;
2401
+ }
2402
+ }
2403
+ }
2404
+ }
2405
+ }
2406
+ if (isEffectToIndex === true) {
2407
+ for (let i = 0; i < from.length; i++) {
2408
+ if (!(to[i] >= 0)) {
2409
+ break;
2410
+ }
2411
+ if (to[i] === from[i]) {
2412
+ continue;
2413
+ }
2414
+ if (to[i] < from[i] && i == to.length - 1) {
2415
+ trimDeletePosIndex = i;
2416
+ }
2417
+ }
2418
+ }
2419
+ if (trimDeletePosIndex >= 0) {
2420
+ {
2421
+ from[trimDeletePosIndex] = from[trimDeletePosIndex] + 1;
2422
+ }
2423
+ }
2424
+ deleteElementInListByPosition(from, elements);
2425
+ }
2426
+ return { elements, from, to };
2427
+ }
2428
+ function mergeElement(originElem, updateContent, opts) {
2429
+ const updatedFlatten = toFlattenElement(updateContent);
2430
+ const ignoreKeys = ["uuid", "type"];
2431
+ const updatedKeys = Object.keys(updatedFlatten);
2432
+ updatedKeys.forEach((key2) => {
2433
+ if (!ignoreKeys.includes(key2)) {
2434
+ const value = updatedFlatten[key2];
2435
+ del(originElem, key2);
2436
+ if (value !== void 0) {
2437
+ set(originElem, key2, value);
2438
+ }
2439
+ }
2440
+ });
2441
+ if ((opts === null || opts === void 0 ? void 0 : opts.strict) === true) {
2442
+ const originFlatten = toFlattenElement(originElem);
2443
+ const originKeys = Object.keys(originFlatten);
2444
+ originKeys.forEach((key2) => {
2445
+ if (!ignoreKeys.includes(key2)) {
2446
+ if (!updatedKeys.includes(key2)) {
2447
+ del(originElem, key2);
2448
+ }
2449
+ }
2450
+ });
2451
+ }
2452
+ return originElem;
2453
+ }
2454
+ function updateElementInList(uuid, updateContent, elements) {
2455
+ var _a, _b;
2456
+ let targetElement = null;
2457
+ for (let i = 0; i < elements.length; i++) {
2458
+ const elem = elements[i];
2459
+ if (elem.uuid === uuid) {
2460
+ if (elem.type === "group" && ((_a = elem.operations) === null || _a === void 0 ? void 0 : _a.deepResize) === true) {
2461
+ if (updateContent.w && updateContent.w > 0 || updateContent.h && updateContent.h > 0) {
2462
+ deepResizeGroupElement(elem, {
2463
+ w: updateContent.w,
2464
+ h: updateContent.h
2465
+ });
2466
+ }
2467
+ }
2468
+ mergeElement(elem, updateContent);
2469
+ targetElement = elem;
2470
+ break;
2471
+ } else if (elem.type === "group") {
2472
+ targetElement = updateElementInList(uuid, updateContent, ((_b = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _b === void 0 ? void 0 : _b.children) || []);
2473
+ }
2474
+ }
2475
+ return targetElement;
2476
+ }
2477
+ function updateElementInListByPosition(position, updateContent, elements, opts) {
2478
+ var _a;
2479
+ const elem = findElementFromListByPosition(position, elements);
2480
+ if (elem) {
2481
+ if (elem.type === "group" && ((_a = elem.operations) === null || _a === void 0 ? void 0 : _a.deepResize) === true) {
2482
+ if (updateContent.w && updateContent.w > 0 || updateContent.h && updateContent.h > 0) {
2483
+ deepResizeGroupElement(elem, {
2484
+ w: updateContent.w,
2485
+ h: updateContent.h
2486
+ });
2487
+ }
2488
+ }
2489
+ mergeElement(elem, updateContent, opts);
2490
+ }
2491
+ return elem;
2492
+ }
2023
2493
  const baseFontFamilyList = ["-apple-system", '"system-ui"', ' "Segoe UI"', " Roboto", '"Helvetica Neue"', "Arial", '"Noto Sans"', " sans-serif"];
2024
2494
  function enhanceFontFamliy(fontFamily2) {
2025
2495
  return [fontFamily2, ...baseFontFamilyList].join(", ");
@@ -2060,6 +2530,36 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2060
2530
  moveY
2061
2531
  };
2062
2532
  }
2533
+ function mergeLayout(originLayout, updateContent, opts) {
2534
+ const updatedFlatten = toFlattenLayout(updateContent);
2535
+ const ignoreKeys = [];
2536
+ const updatedKeys = Object.keys(updatedFlatten);
2537
+ updatedKeys.forEach((key2) => {
2538
+ if (!ignoreKeys.includes(key2)) {
2539
+ const value = updatedFlatten[key2];
2540
+ del(originLayout, key2);
2541
+ if (value !== void 0) {
2542
+ set(originLayout, key2, value);
2543
+ }
2544
+ }
2545
+ });
2546
+ return originLayout;
2547
+ }
2548
+ function mergeGlobal(originGlobal, updateContent, opts) {
2549
+ const updatedFlatten = toFlattenGlobal(updateContent);
2550
+ const ignoreKeys = [];
2551
+ const updatedKeys = Object.keys(updatedFlatten);
2552
+ updatedKeys.forEach((key2) => {
2553
+ if (!ignoreKeys.includes(key2)) {
2554
+ const value = updatedFlatten[key2];
2555
+ del(originGlobal, key2);
2556
+ if (value !== void 0) {
2557
+ set(originGlobal, key2, value);
2558
+ }
2559
+ }
2560
+ });
2561
+ return originGlobal;
2562
+ }
2063
2563
  function createColorStyle(ctx, color2, opts) {
2064
2564
  if (typeof color2 === "string") {
2065
2565
  return color2;
@@ -2163,7 +2663,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2163
2663
  ctx.scale(totalScale * scaleW, totalScale * scaleH);
2164
2664
  const pathStr = generateSVGPath(clipPath.commands || []);
2165
2665
  const path2d = new Path2D(pathStr);
2166
- ctx.clip(path2d);
2666
+ ctx.clip(path2d, "nonzero");
2167
2667
  ctx.translate(0 - internalX, 0 - internalY);
2168
2668
  ctx.setTransform(1, 0, 0, 1, 0, 0);
2169
2669
  rotateElement$1(ctx, Object.assign({}, viewElem), () => {
@@ -2254,7 +2754,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2254
2754
  }
2255
2755
  }
2256
2756
  }
2257
- ctx.fill();
2757
+ ctx.fill("nonzero");
2258
2758
  if (transform && transform.length > 0) {
2259
2759
  ctx.setTransform(1, 0, 0, 1, 0, 0);
2260
2760
  }
@@ -2460,7 +2960,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2460
2960
  ctx.fillStyle = fillStyle;
2461
2961
  ctx.circle(centerX, centerY, radiusA, radiusB, 0, 0, 2 * Math.PI);
2462
2962
  ctx.closePath();
2463
- ctx.fill();
2963
+ ctx.fill("nonzero");
2464
2964
  ctx.globalAlpha = parentOpacity;
2465
2965
  if (typeof bw === "number" && bw > 0) {
2466
2966
  const ba = bw / 2 + a;
@@ -2540,8 +3040,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2540
3040
  ctx.arcTo(x3, y3 + h3, x3, y3, radiusList[3]);
2541
3041
  ctx.arcTo(x3, y3, x3 + w3, y3, radiusList[0]);
2542
3042
  ctx.closePath();
2543
- ctx.fill();
2544
- ctx.clip();
3043
+ ctx.fill("nonzero");
3044
+ ctx.clip("nonzero");
2545
3045
  if (scaleMode && originH && originW) {
2546
3046
  let sx = 0;
2547
3047
  let sy = 0;
@@ -2741,7 +3241,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2741
3241
  }
2742
3242
  }
2743
3243
  if (detail.fill) {
2744
- ctx.fill(path2d, fillRule);
3244
+ ctx.fill(path2d, fillRule || "nonzero");
2745
3245
  }
2746
3246
  if (detail.stroke && detail.strokeWidth !== 0) {
2747
3247
  ctx.strokeStyle = detail.stroke;
@@ -2844,8 +3344,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2844
3344
  ctx.arcTo(x3, y3 + h3, x3, y3, radiusList[3]);
2845
3345
  ctx.arcTo(x3, y3, x3 + w3, y3, radiusList[0]);
2846
3346
  ctx.closePath();
2847
- ctx.fill();
2848
- ctx.clip();
3347
+ ctx.fill("nonzero");
3348
+ ctx.clip("nonzero");
2849
3349
  }
2850
3350
  if (Array.isArray(elem.detail.children)) {
2851
3351
  const { parentElementSize: parentSize } = opts;
@@ -2939,8 +3439,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2939
3439
  ctx.arcTo(x3, y3 + h3, x3, y3, radiusList[3]);
2940
3440
  ctx.arcTo(x3, y3, x3 + w3, y3, radiusList[0]);
2941
3441
  ctx.closePath();
2942
- ctx.fill();
2943
- ctx.clip();
3442
+ ctx.fill("nonzero");
3443
+ ctx.clip("nonzero");
2944
3444
  }
2945
3445
  renderContent(ctx);
2946
3446
  if (layout.detail.overflow === "hidden") {
@@ -3288,9 +3788,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3288
3788
  eachLineStartY = (fontHeight - fontSize2) / 2;
3289
3789
  }
3290
3790
  if (lines.length * fontHeight < h2) {
3291
- if (elem.detail.verticalAlign === "top") {
3791
+ if (detail.verticalAlign === "top") {
3292
3792
  startY = 0;
3293
- } else if (elem.detail.verticalAlign === "bottom") {
3793
+ } else if (detail.verticalAlign === "bottom") {
3294
3794
  startY += h2 - lines.length * fontHeight;
3295
3795
  } else {
3296
3796
  startY += (h2 - lines.length * fontHeight) / 2;
@@ -3525,9 +4025,20 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3525
4025
  };
3526
4026
  return viewRectInfo;
3527
4027
  }
4028
+ modifyText(element) {
4029
+ const virtualFlatItemMap = __classPrivateFieldGet$1(this, _Calculator_store, "f").get("virtualFlatItemMap");
4030
+ const flatItem = virtualFlatItemMap[element.uuid];
4031
+ if (element && element.type === "text") {
4032
+ const newVirtualFlatItem = Object.assign(Object.assign({}, flatItem), calcVirtualTextDetail(element, {
4033
+ tempContext: __classPrivateFieldGet$1(this, _Calculator_opts, "f").tempContext
4034
+ }));
4035
+ virtualFlatItemMap[element.uuid] = newVirtualFlatItem;
4036
+ __classPrivateFieldGet$1(this, _Calculator_store, "f").set("virtualFlatItemMap", virtualFlatItemMap);
4037
+ }
4038
+ }
3528
4039
  modifyVirtualFlatItemMap(data, opts) {
3529
- const { modifyOptions, viewScaleInfo, viewSizeInfo } = opts;
3530
- const { type, content } = modifyOptions;
4040
+ const { modifyInfo, viewScaleInfo, viewSizeInfo } = opts;
4041
+ const { type, content } = modifyInfo;
3531
4042
  const list = data.elements;
3532
4043
  const virtualFlatItemMap = __classPrivateFieldGet$1(this, _Calculator_store, "f").get("virtualFlatItemMap");
3533
4044
  if (type === "deleteElement") {
@@ -3628,6 +4139,12 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3628
4139
  w: opts.viewSizeInfo.width,
3629
4140
  h: opts.viewSizeInfo.height
3630
4141
  };
4142
+ if (opts.forceDrawAll === true) {
4143
+ __classPrivateFieldGet(this, _Renderer_calculator, "f").resetVirtualFlatItemMap(data, {
4144
+ viewScaleInfo: opts.viewScaleInfo,
4145
+ viewSizeInfo: opts.viewSizeInfo
4146
+ });
4147
+ }
3631
4148
  const drawOpts = Object.assign({
3632
4149
  loader,
3633
4150
  calculator,
@@ -4153,8 +4670,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4153
4670
  constructor(opts) {
4154
4671
  __privateAdd(this, _Board_instances);
4155
4672
  __privateAdd(this, _opts3);
4156
- __privateAdd(this, _middlewareMap, /* @__PURE__ */ new WeakMap());
4157
- __privateAdd(this, _middlewares, []);
4673
+ __privateAdd(this, _middlewareMap, /* @__PURE__ */ new Map());
4674
+ // #middlewares: BoardMiddleware[] = [];
4158
4675
  __privateAdd(this, _activeMiddlewareObjs, []);
4159
4676
  __privateAdd(this, _watcher);
4160
4677
  __privateAdd(this, _renderer);
@@ -4214,8 +4731,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4214
4731
  getRenderer() {
4215
4732
  return __privateGet(this, _renderer);
4216
4733
  }
4217
- setData(data, opts) {
4218
- const { modifiedOptions } = opts || {};
4734
+ setData(data) {
4219
4735
  const sharer = __privateGet(this, _sharer);
4220
4736
  __privateGet(this, _sharer).setActiveStorage("data", data);
4221
4737
  const viewSizeInfo = sharer.getActiveViewSizeInfo();
@@ -4225,17 +4741,10 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4225
4741
  viewHeight: viewSizeInfo.height,
4226
4742
  extend: true
4227
4743
  });
4228
- if (modifiedOptions) {
4229
- __privateGet(this, _viewer).resetVirtualFlatItemMap(data, {
4230
- viewSizeInfo,
4231
- viewScaleInfo
4232
- });
4233
- } else {
4234
- __privateGet(this, _viewer).resetVirtualFlatItemMap(data, {
4235
- viewSizeInfo,
4236
- viewScaleInfo
4237
- });
4238
- }
4744
+ __privateGet(this, _viewer).resetVirtualFlatItemMap(data, {
4745
+ viewSizeInfo,
4746
+ viewScaleInfo
4747
+ });
4239
4748
  __privateGet(this, _viewer).drawFrame();
4240
4749
  const newViewSizeInfo = {
4241
4750
  ...viewSizeInfo,
@@ -4252,13 +4761,12 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4252
4761
  var _a, _b, _c;
4253
4762
  if (__privateGet(this, _middlewareMap).has(middleware)) {
4254
4763
  const item = __privateGet(this, _middlewareMap).get(middleware);
4255
- if (item) {
4256
- (_b = (_a = item.middlewareObject).use) == null ? void 0 : _b.call(_a);
4764
+ if (item && item.status !== "enable") {
4257
4765
  item.status = "enable";
4258
- __privateGet(this, _middlewareMap).set(middleware, item);
4766
+ (_b = (_a = item.middlewareObject).use) == null ? void 0 : _b.call(_a);
4259
4767
  __privateMethod(this, _Board_instances, resetActiveMiddlewareObjs_fn).call(this);
4260
- return;
4261
4768
  }
4769
+ return;
4262
4770
  }
4263
4771
  const { boardContent, container } = __privateGet(this, _opts3);
4264
4772
  const sharer = __privateGet(this, _sharer);
@@ -4270,8 +4778,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4270
4778
  config
4271
4779
  );
4272
4780
  (_c = obj.use) == null ? void 0 : _c.call(obj);
4273
- __privateGet(this, _middlewares).push(middleware);
4274
- __privateGet(this, _activeMiddlewareObjs).push(obj);
4275
4781
  __privateGet(this, _middlewareMap).set(middleware, {
4276
4782
  status: "enable",
4277
4783
  middlewareObject: obj,
@@ -4281,11 +4787,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4281
4787
  }
4282
4788
  disuse(middleware) {
4283
4789
  var _a, _b;
4284
- const item = __privateGet(this, _middlewareMap).get(middleware);
4285
- if (item) {
4286
- (_b = (_a = item.middlewareObject).disuse) == null ? void 0 : _b.call(_a);
4287
- item.status = "disable";
4288
- __privateGet(this, _middlewareMap).set(middleware, item);
4790
+ if (__privateGet(this, _middlewareMap).has(middleware)) {
4791
+ const item = __privateGet(this, _middlewareMap).get(middleware);
4792
+ if (item) {
4793
+ (_b = (_a = item.middlewareObject).disuse) == null ? void 0 : _b.call(_a);
4794
+ item.status = "disable";
4795
+ }
4796
+ __privateGet(this, _middlewareMap).delete(middleware);
4289
4797
  __privateMethod(this, _Board_instances, resetActiveMiddlewareObjs_fn).call(this);
4290
4798
  }
4291
4799
  }
@@ -4350,7 +4858,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4350
4858
  }
4351
4859
  _opts3 = new WeakMap();
4352
4860
  _middlewareMap = new WeakMap();
4353
- _middlewares = new WeakMap();
4354
4861
  _activeMiddlewareObjs = new WeakMap();
4355
4862
  _watcher = new WeakMap();
4356
4863
  _renderer = new WeakMap();
@@ -4530,13 +5037,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4530
5037
  };
4531
5038
  resetActiveMiddlewareObjs_fn = function() {
4532
5039
  const activeMiddlewareObjs = [];
4533
- const middlewareMap = __privateGet(this, _middlewareMap);
4534
- __privateGet(this, _middlewares).forEach((middleware) => {
4535
- const item = middlewareMap.get(middleware);
5040
+ for (const [_, item] of __privateGet(this, _middlewareMap)) {
4536
5041
  if ((item == null ? void 0 : item.status) === "enable" && (item == null ? void 0 : item.middlewareObject)) {
4537
5042
  activeMiddlewareObjs.push(item.middlewareObject);
4538
5043
  }
4539
- });
5044
+ }
4540
5045
  __privateSet(this, _activeMiddlewareObjs, activeMiddlewareObjs);
4541
5046
  };
4542
5047
  const CURSOR = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZURhdGU9IjIwMjMtMDktMTdUMTY6MDc6MjYrMDg6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDIzLTA5LTE3VDE2OjEyOjUwKzA4OjAwIiB4bXA6TWV0YWRhdGFEYXRlPSIyMDIzLTA5LTE3VDE2OjEyOjUwKzA4OjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgcGhvdG9zaG9wOkNvbG9yTW9kZT0iMyIgcGhvdG9zaG9wOklDQ1Byb2ZpbGU9InNSR0IgSUVDNjE5NjYtMi4xIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjliMGM0MzI2LWU4ZTQtNDlkNy04MmUzLTgxODkwYTE2ZmU1YSIgeG1wTU06RG9jdW1lbnRJRD0iYWRvYmU6ZG9jaWQ6cGhvdG9zaG9wOjMzOGFhZDBmLWZkZjMtODE0MS1iMTZmLWNiZWIzNTQyYTJhMCIgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOjUwODAxNzc1LWZlNGEtNDQyMy05NDQ3LThkYWRhNzZhYTllOSI+IDx4bXBNTTpIaXN0b3J5PiA8cmRmOlNlcT4gPHJkZjpsaSBzdEV2dDphY3Rpb249ImNyZWF0ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6NTA4MDE3NzUtZmU0YS00NDIzLTk0NDctOGRhZGE3NmFhOWU5IiBzdEV2dDp3aGVuPSIyMDIzLTA5LTE3VDE2OjA3OjI2KzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6OWIwYzQzMjYtZThlNC00OWQ3LTgyZTMtODE4OTBhMTZmZTVhIiBzdEV2dDp3aGVuPSIyMDIzLTA5LTE3VDE2OjEyOjUwKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgc3RFdnQ6Y2hhbmdlZD0iLyIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7W6XrzAAAGLklEQVRYhb2Xf2iUdRzHX/txtfXLplZ6Wblm6fzRmG6r7Uou1AxKRjQKYUqgaLBACFogppcK1h8aLRkMSYaJIA5hYMomZpskEfPOufCaDpZ6t7rbre263U3vzn3643meu+eu3XNzvz7w4bbdc/e89nl/Pu/v50HUCAQCx1tbW0uAx4CHgSwggxkKERkziUQif2mQ0WjU53a7vwSeBB4BTEDmTICmBBwYGDivVlDjlFAo9KvT6dwIPAHkANkq6MwDXr169bCISENDg9TX14s+BgcHf2hubi5mBmRPCXj06NFPREQ6OjoEkPLycrl06VIMMhKJeFwu1xdMs+wpAYuLi9eIiIyOjkpeXp4AAsj27dvF7/fHQIPB4C9dXV0fME2ypwQEXvX7/bdFRNauXRsDBMRkMsnhw4cTZB8YGGhsamp6hSmW3Qhw1Y0bN86LiNTW1iYAallWViZtbW162ftcLtdO/i/7tAAWtba2ficicvLkyTEBtdy6dasMDg7GQIeHh9s7OzvfBx5nkrIbAS7du3fvxyIiPT09hoBa1tXVJcv+fWNj4zLgUeAhJiC7EeDLwOsiMioisnDhwnFBrlixQi5evKiX/c6tW7c+R5E9lweU3QjwReDV/v7+bhGRqqqqcQFquWnTJvH5fHrZLzocjkoSZU9bTSPA54GV165daxYROXDgwAMBannw4MFk2RsaGhqWME7ZjQDNwIrTp09/JSLS0tIyIUBACgoK5MKFCzHIcDj85+3btz8FZpFGdiPAZ4DCmpqaTSIiPp9vwoBaVlVVidfr1ct+/sqVK+9iILsR4FzgJcASDoeHRUSKioomDQnI/v37E2T3+Xz1hw4dWjSW7EaAeUA+UNbX12cXEdmyZcuUAAJiNpvlzJkzetl73G53rVrN2EmUCjATuA9EgYjL5eoGKCkpGatNHijmz5/Pxo0b2blzJ2azOfZ3k8lUYDabv45Go/Y7d+6sIY0VZQOjGqDT6bxeWlrKqlWrJgRlsVhYv349FRUVWCwWcnJyEt4PBoOuoaEhu9frvdzR0fHTtm3buolvRpLqe3OBp4EllZWV74mIRKNRyc3NTSvf7Nmzpbq6Wk6cOCFut1uSY2RkJOB0Ou3Nzc3Ha2trPwPWAGXAEuBZFFPPAbKMevBhYA6wCKgIBoP9IiKrV682hLPZbP8DEpH7vb29N1paWn602WwHFyxYsAX4EKgE3gIsQBFQgOIeT6j3z0wFqEkc60OPx9Odn58/t6SkhPb29jFLbrVa2bNnDwBer7fv5s2bPQ6Ho7upqcnZ1tbmASJq3gPC6utdYESXYfWeo6mkBaUHRQ/odrv/yM/Pt5SWlqb8kAbncDh+W7lyZYN683u6DOvAwipsOOnniA4wZf9lqhdoVYzY7fbrQMpBsdlsWK1WRkZGAtXV1d8D/wA+wKNLr5o+YEC9ZggIAEHiFbyfDhCUCcoFngIWFxYWrtMaat68eQl9V15eHmu2+vr6OuAd4A2gGFgMLERp/mdQ+noWyuadi9Jr2aQ4k42GBPXDs1Ga97WhoaFbIiIbNmxIANTWq87Ozp9VuApgGfACihPkoRjwI+p3mlSgtA9ZRkYNYwwKJBr2rl27sFqthEKhwZqamqOAX5f/AsPE5btLvM/GJWO6yFb/82eBonPnztWJiJw9e1YAWb58eUzaI0eOfAO8CbwCPIfiZZN+eEoncSaKLPOApbt3794uIuL1ehOktdvtF4C3gRKURXcOSn9lTRRsvIAZKI4+l/gjQFREZMeOHSIiEggE+tetW/cRitkuRhmERxnnxjxZQFDWnzzURwCv1+vUHxHHjh37lri0C1Am9KGpgDMC1G8SQnxxCHs8Hqf2RldX10+bN28+i+JjwyT62KSaP13oAfWTHO7t7f0dIBQK/b1v375GlEnVjPYuyoQaHlNTDahVMALca29vdwBcvnz5+KlTp26OATft1UuODBS7yEOxj0K/329HOSWWopjxlE1tchhtM7FriPfgXSDDbrfXo0gbJr4QzIi0WiRPYBbKZJrUV23b0dYn7XSYcsBkS9EiO/k6lApq1cwiPjzaAM1Y9cYC1G6uAWrPCtrvMwoHqU02Q5caIEzj1KaS+D+vIjxtLug31gAAAABJRU5ErkJggg==";
@@ -4709,6 +5214,32 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4709
5214
  }
4710
5215
  return key2;
4711
5216
  };
5217
+ function getModifyElementRecord(opts) {
5218
+ const { modifiedElement, beforeElement } = opts;
5219
+ const { uuid, ...restElement } = modifiedElement;
5220
+ const after = toFlattenElement(restElement);
5221
+ let before = {};
5222
+ Object.keys(after).forEach((key2) => {
5223
+ let val = get(beforeElement, key2);
5224
+ if (val === void 0 && /(borderRadius|borderWidth)\[[0-9]{1,}\]$/.test(key2)) {
5225
+ key2 = key2.replace(/\[[0-9]{1,}\]$/, "");
5226
+ val = get(beforeElement, key2);
5227
+ }
5228
+ before[key2] = val;
5229
+ });
5230
+ before = toFlattenElement(before);
5231
+ const record = {
5232
+ type: "modifyElement",
5233
+ time: Date.now(),
5234
+ content: {
5235
+ method: "modifyElement",
5236
+ uuid,
5237
+ before,
5238
+ after
5239
+ }
5240
+ };
5241
+ return record;
5242
+ }
4712
5243
  const key$3 = "SELECT";
4713
5244
  const keyActionType = Symbol(`${key$3}_actionType`);
4714
5245
  const keyResizeType = Symbol(`${key$3}_resizeType`);
@@ -4756,7 +5287,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4756
5287
  ctx.lineTo(vertexes[0].x, vertexes[0].y);
4757
5288
  ctx.closePath();
4758
5289
  ctx.stroke();
4759
- ctx.fill();
5290
+ ctx.fill("nonzero");
4760
5291
  }
4761
5292
  function drawLine(ctx, start, end, opts) {
4762
5293
  const { borderColor: borderColor2, borderWidth: borderWidth2, lineDash } = opts;
@@ -4781,7 +5312,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4781
5312
  ctx.fillStyle = background2;
4782
5313
  ctx.circle(center.x, center.y, a, b, 0, 0, 2 * Math.PI);
4783
5314
  ctx.closePath();
4784
- ctx.fill();
5315
+ ctx.fill("nonzero");
4785
5316
  }
4786
5317
  }
4787
5318
  function drawCrossVertexes(ctx, vertexes, opts) {
@@ -4878,7 +5409,12 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4878
5409
  const { devicePixelRatio = 1 } = viewSizeInfo;
4879
5410
  const { activeColor: activeColor2 } = style;
4880
5411
  const { elementWrapper, topLeft, topRight, bottomLeft, bottomRight, rotate } = controller;
4881
- const wrapperOpts = { borderColor: activeColor2, borderWidth: selectWrapperBorderWidth, background: "transparent", lineDash: [] };
5412
+ const wrapperOpts = {
5413
+ borderColor: activeColor2,
5414
+ borderWidth: selectWrapperBorderWidth,
5415
+ background: "transparent",
5416
+ lineDash: []
5417
+ };
4882
5418
  const ctrlOpts = { ...wrapperOpts, borderWidth: resizeControllerBorderWidth, background: "#FFFFFF" };
4883
5419
  drawVertexes(ctx, calcViewVertexes(elementWrapper, opts), wrapperOpts);
4884
5420
  if (!hideControllers) {
@@ -4887,7 +5423,10 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4887
5423
  drawVertexes(ctx, calcViewVertexes(bottomLeft.vertexes, opts), ctrlOpts);
4888
5424
  drawVertexes(ctx, calcViewVertexes(bottomRight.vertexes, opts), ctrlOpts);
4889
5425
  if (((_a = element == null ? void 0 : element.operations) == null ? void 0 : _a.rotatable) !== false) {
4890
- drawCircleController(ctx, calcViewPointSize(rotate.center, opts), { ...ctrlOpts, size: rotate.size });
5426
+ drawCircleController(ctx, calcViewPointSize(rotate.center, opts), {
5427
+ ...ctrlOpts,
5428
+ size: rotate.size
5429
+ });
4891
5430
  const rotateCenter = calcViewPointSize(rotate.center, opts);
4892
5431
  ctx.drawImage(
4893
5432
  rotateControllerPattern.canvas,
@@ -4917,7 +5456,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4917
5456
  ctx.lineTo(start.x, end.y);
4918
5457
  ctx.closePath();
4919
5458
  ctx.stroke();
4920
- ctx.fill();
5459
+ ctx.fill("nonzero");
4921
5460
  }
4922
5461
  function drawListArea(ctx, opts) {
4923
5462
  const { areaSize, style } = opts;
@@ -4934,14 +5473,19 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4934
5473
  ctx.lineTo(x2, y2 + h2);
4935
5474
  ctx.closePath();
4936
5475
  ctx.stroke();
4937
- ctx.fill();
5476
+ ctx.fill("nonzero");
4938
5477
  }
4939
5478
  function drawGroupQueueVertexesWrappers(ctx, vertexesList, opts) {
4940
5479
  const { style } = opts;
4941
5480
  const { activeColor: activeColor2 } = style;
4942
5481
  for (let i = 0; i < vertexesList.length; i++) {
4943
5482
  const vertexes = vertexesList[i];
4944
- const wrapperOpts = { borderColor: activeColor2, borderWidth: selectWrapperBorderWidth, background: "transparent", lineDash: [4, 4] };
5483
+ const wrapperOpts = {
5484
+ borderColor: activeColor2,
5485
+ borderWidth: selectWrapperBorderWidth,
5486
+ background: "transparent",
5487
+ lineDash: [4, 4]
5488
+ };
4945
5489
  drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
4946
5490
  }
4947
5491
  }
@@ -6044,7 +6588,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
6044
6588
  ctx.lineTo(boxVertexes[2].x, boxVertexes[2].y);
6045
6589
  ctx.lineTo(boxVertexes[3].x, boxVertexes[3].y);
6046
6590
  ctx.closePath();
6047
- ctx.fill();
6591
+ ctx.fill("nonzero");
6048
6592
  ctx.strokeStyle = activeColor2;
6049
6593
  ctx.lineWidth = 2;
6050
6594
  ctx.beginPath();
@@ -6073,9 +6617,24 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
6073
6617
  const { controller, style } = opts;
6074
6618
  const { topLeft, topRight, bottomLeft, bottomRight, topMiddle, rightMiddle, bottomMiddle, leftMiddle } = controller;
6075
6619
  drawControllerLine(ctx, { start: topLeft.center, end: topRight.center, centerVertexes: topMiddle.vertexes, style });
6076
- drawControllerLine(ctx, { start: topRight.center, end: bottomRight.center, centerVertexes: rightMiddle.vertexes, style });
6077
- drawControllerLine(ctx, { start: bottomRight.center, end: bottomLeft.center, centerVertexes: bottomMiddle.vertexes, style });
6078
- drawControllerLine(ctx, { start: bottomLeft.center, end: topLeft.center, centerVertexes: leftMiddle.vertexes, style });
6620
+ drawControllerLine(ctx, {
6621
+ start: topRight.center,
6622
+ end: bottomRight.center,
6623
+ centerVertexes: rightMiddle.vertexes,
6624
+ style
6625
+ });
6626
+ drawControllerLine(ctx, {
6627
+ start: bottomRight.center,
6628
+ end: bottomLeft.center,
6629
+ centerVertexes: bottomMiddle.vertexes,
6630
+ style
6631
+ });
6632
+ drawControllerLine(ctx, {
6633
+ start: bottomLeft.center,
6634
+ end: topLeft.center,
6635
+ centerVertexes: leftMiddle.vertexes,
6636
+ style
6637
+ });
6079
6638
  drawControllerBox(ctx, topLeft.vertexes, style);
6080
6639
  drawControllerBox(ctx, topRight.vertexes, style);
6081
6640
  drawControllerBox(ctx, bottomRight.vertexes, style);
@@ -6107,6 +6666,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
6107
6666
  let prevPoint = null;
6108
6667
  let prevIsHoverContent = null;
6109
6668
  let prevIsSelected = null;
6669
+ let pointStartLayoutSize = null;
6110
6670
  const clear = () => {
6111
6671
  prevPoint = null;
6112
6672
  sharer.setSharedStorage(keyLayoutActionType, null);
@@ -6272,6 +6832,12 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
6272
6832
  }
6273
6833
  sharer.setSharedStorage(keyLayoutIsSelected, false);
6274
6834
  }
6835
+ const data = sharer.getActiveStorage("data");
6836
+ if (data == null ? void 0 : data.layout) {
6837
+ pointStartLayoutSize = getElementSize(data.layout);
6838
+ } else {
6839
+ pointStartLayoutSize = null;
6840
+ }
6275
6841
  resetController();
6276
6842
  const layoutControlType = resetControlType(e);
6277
6843
  prevPoint = e.point;
@@ -6381,11 +6947,25 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
6381
6947
  const layoutControlType = sharer.getSharedStorage(keyLayoutControlType);
6382
6948
  const data = sharer.getActiveStorage("data");
6383
6949
  if (data && layoutActionType === "resize" && layoutControlType) {
6950
+ let modifyRecord = void 0;
6951
+ if (pointStartLayoutSize) {
6952
+ modifyRecord = {
6953
+ type: "modifyLayout",
6954
+ time: Date.now(),
6955
+ content: {
6956
+ method: "modifyLayout",
6957
+ before: toFlattenLayout(pointStartLayoutSize),
6958
+ after: toFlattenLayout(getElementSize(data.layout))
6959
+ }
6960
+ };
6961
+ }
6384
6962
  eventHub.trigger(coreEventKeys.CHANGE, {
6385
6963
  type: "dragLayout",
6386
- data
6964
+ data,
6965
+ modifyRecord
6387
6966
  });
6388
6967
  }
6968
+ pointStartLayoutSize = null;
6389
6969
  sharer.setSharedStorage(keyLayoutActionType, null);
6390
6970
  sharer.setSharedStorage(keyLayoutControlType, null);
6391
6971
  if (sharer.getSharedStorage(keyLayoutIsHoverController) === true) {
@@ -6655,7 +7235,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
6655
7235
  ctx.lineTo(bgEnd.x, bgEnd.y);
6656
7236
  ctx.lineTo(bgStart.x, bgEnd.y);
6657
7237
  ctx.closePath();
6658
- ctx.fill();
7238
+ ctx.fill("nonzero");
6659
7239
  ctx.fillStyle = textColor2;
6660
7240
  ctx.textBaseline = "top";
6661
7241
  ctx.fillText(text2, textStart.x, textStart.y + padding);
@@ -6692,7 +7272,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
6692
7272
  ctx.lineTo(bgEnd.x, bgEnd.y);
6693
7273
  ctx.lineTo(bgStart.x, bgEnd.y);
6694
7274
  ctx.closePath();
6695
- ctx.fill();
7275
+ ctx.fill("nonzero");
6696
7276
  ctx.fillStyle = textColor2;
6697
7277
  ctx.textBaseline = "top";
6698
7278
  ctx.fillText(text2, textStart.x, textStart.y + padding);
@@ -6729,7 +7309,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
6729
7309
  ctx.lineTo(bgEnd.x, bgEnd.y);
6730
7310
  ctx.lineTo(bgStart.x, bgEnd.y);
6731
7311
  ctx.closePath();
6732
- ctx.fill();
7312
+ ctx.fill("nonzero");
6733
7313
  ctx.fillStyle = textColor2;
6734
7314
  ctx.textBaseline = "top";
6735
7315
  ctx.fillText(text2, textStart.x, textStart.y + padding);
@@ -6879,6 +7459,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
6879
7459
  const { viewer, sharer, boardContent, calculator, eventHub } = opts;
6880
7460
  const { overlayContext } = boardContent;
6881
7461
  let prevPoint = null;
7462
+ let pointStartElementSizeList = [];
6882
7463
  let moveOriginalStartPoint = null;
6883
7464
  let moveOriginalStartElementSize = null;
6884
7465
  let inBusyMode = null;
@@ -7035,6 +7616,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
7035
7616
  eventHub.off(coreEventKeys.CLEAR_SELECT, selectClearCallback);
7036
7617
  eventHub.off(coreEventKeys.SELECT_IN_GROUP, selectInGroupCallback);
7037
7618
  eventHub.off(coreEventKeys.SNAP_TO_GRID, setSnapToSnapCallback);
7619
+ clear();
7620
+ innerConfig = null;
7038
7621
  },
7039
7622
  resetConfig(config2) {
7040
7623
  innerConfig = { ...innerConfig, ...config2 };
@@ -7156,6 +7739,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
7156
7739
  } else if (target2.type === "over-element" && ((_e = target2 == null ? void 0 : target2.elements) == null ? void 0 : _e.length) === 1) {
7157
7740
  updateSelectedElementList([target2.elements[0]], { triggerEvent: true });
7158
7741
  sharer.setSharedStorage(keyActionType, "drag");
7742
+ pointStartElementSizeList = [{ ...getElementSize(target2 == null ? void 0 : target2.elements[0]), uuid: target2 == null ? void 0 : target2.elements[0].uuid }];
7159
7743
  } else if ((_f = target2.type) == null ? void 0 : _f.startsWith("resize-")) {
7160
7744
  sharer.setSharedStorage(keyResizeType, target2.type);
7161
7745
  sharer.setSharedStorage(keyActionType, "resize");
@@ -7192,6 +7776,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
7192
7776
  } else if (target.type === "over-element" && ((_k = target == null ? void 0 : target.elements) == null ? void 0 : _k.length) === 1) {
7193
7777
  updateSelectedElementList([target.elements[0]], { triggerEvent: true });
7194
7778
  sharer.setSharedStorage(keyActionType, "drag");
7779
+ pointStartElementSizeList = [{ ...getElementSize(target == null ? void 0 : target.elements[0]), uuid: target == null ? void 0 : target.elements[0].uuid }];
7195
7780
  } else if ((_l = target.type) == null ? void 0 : _l.startsWith("resize-")) {
7196
7781
  sharer.setSharedStorage(keyResizeType, target.type);
7197
7782
  sharer.setSharedStorage(keyActionType, "resize");
@@ -7251,7 +7836,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
7251
7836
  elems[0].y = calculator.toGridNum(moveOriginalStartElementSize.y + totalMoveY);
7252
7837
  updateSelectedElementList([elems[0]]);
7253
7838
  calculator.modifyVirtualFlatItemMap(data, {
7254
- modifyOptions: {
7839
+ modifyInfo: {
7255
7840
  type: "updateElement",
7256
7841
  content: {
7257
7842
  element: elems[0],
@@ -7275,7 +7860,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
7275
7860
  elem.x = calculator.toGridNum(elem.x + moveX);
7276
7861
  elem.y = calculator.toGridNum(elem.y + moveY);
7277
7862
  calculator.modifyVirtualFlatItemMap(data, {
7278
- modifyOptions: {
7863
+ modifyInfo: {
7279
7864
  type: "updateElement",
7280
7865
  content: {
7281
7866
  element: elem,
@@ -7349,7 +7934,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
7349
7934
  }
7350
7935
  updateSelectedElementList([elems[0]]);
7351
7936
  calculator.modifyVirtualFlatItemMap(data, {
7352
- modifyOptions: {
7937
+ modifyInfo: {
7353
7938
  type: "updateElement",
7354
7939
  content: {
7355
7940
  element: elems[0],
@@ -7438,7 +8023,37 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
7438
8023
  if (data && ["drag", "drag-list", "drag-list-end", "resize"].includes(actionType)) {
7439
8024
  let type = "dragElement";
7440
8025
  if (hasChangedData) {
7441
- eventHub.trigger(coreEventKeys.CHANGE, { data, type, selectedElements, hoverElement });
8026
+ const startSize = pointStartElementSizeList[0];
8027
+ let modifyRecord = void 0;
8028
+ if (selectedElements.length === 1) {
8029
+ modifyRecord = {
8030
+ type: "dragElement",
8031
+ time: 0,
8032
+ content: {
8033
+ method: "modifyElement",
8034
+ uuid: startSize.uuid,
8035
+ before: toFlattenElement(startSize),
8036
+ after: toFlattenElement(getElementSize(selectedElements[0]))
8037
+ }
8038
+ };
8039
+ } else if (selectedElements.length > 1) {
8040
+ modifyRecord = {
8041
+ type: "dragElements",
8042
+ time: 0,
8043
+ content: {
8044
+ method: "modifyElements",
8045
+ before: pointStartElementSizeList.map((item) => ({
8046
+ ...toFlattenElement(item),
8047
+ uuid: item.uuid
8048
+ })),
8049
+ after: selectedElements.map((item) => ({
8050
+ ...toFlattenElement(getElementSize(item)),
8051
+ uuid: item.uuid
8052
+ }))
8053
+ }
8054
+ };
8055
+ }
8056
+ eventHub.trigger(coreEventKeys.CHANGE, { data, type, selectedElements, hoverElement, modifyRecord });
7442
8057
  hasChangedData = false;
7443
8058
  }
7444
8059
  }
@@ -7830,7 +8445,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
7830
8445
  ctx.arcTo(x2, y2, x2 + w2, y2, r);
7831
8446
  ctx.closePath();
7832
8447
  ctx.fillStyle = background2;
7833
- ctx.fill();
8448
+ ctx.fill("nonzero");
7834
8449
  ctx.beginPath();
7835
8450
  ctx.lineWidth = 1;
7836
8451
  ctx.strokeStyle = borderColor2;
@@ -8004,7 +8619,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8004
8619
  }
8005
8620
  },
8006
8621
  beforeDrawFrame({ snapshot }) {
8007
- const { thumbBackground, thumbBorderColor, hoverThumbBackground, hoverThumbBorderColor, activeThumbBackground, activeThumbBorderColor } = innerConfig;
8622
+ const {
8623
+ thumbBackground,
8624
+ thumbBorderColor,
8625
+ hoverThumbBackground,
8626
+ hoverThumbBorderColor,
8627
+ activeThumbBackground,
8628
+ activeThumbBorderColor
8629
+ } = innerConfig;
8008
8630
  const style = {
8009
8631
  thumbBackground,
8010
8632
  thumbBorderColor,
@@ -8056,7 +8678,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8056
8678
  const textColor = "#00000080";
8057
8679
  const gridColor = "#AAAAAA20";
8058
8680
  const gridPrimaryColor = "#AAAAAA40";
8059
- const selectedAreaColor = "#196097";
8681
+ const selectedAreaColor = "#19609780";
8060
8682
  const defaultStyle = {
8061
8683
  background,
8062
8684
  borderColor,
@@ -8225,7 +8847,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8225
8847
  ctx.lineTo(basePosition, basePosition);
8226
8848
  ctx.closePath();
8227
8849
  ctx.fillStyle = background2;
8228
- ctx.fill();
8850
+ ctx.fill("nonzero");
8229
8851
  ctx.lineWidth = lineSize;
8230
8852
  ctx.setLineDash([]);
8231
8853
  ctx.strokeStyle = borderColor2;
@@ -8307,7 +8929,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8307
8929
  ctx.lineTo(xAreaStart, rulerSize);
8308
8930
  ctx.fillStyle = selectedAreaColor2;
8309
8931
  ctx.closePath();
8310
- ctx.fill();
8932
+ ctx.fill("nonzero");
8311
8933
  ctx.beginPath();
8312
8934
  ctx.moveTo(0, yAreaStart);
8313
8935
  ctx.lineTo(rulerSize, yAreaStart);
@@ -8315,7 +8937,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8315
8937
  ctx.lineTo(0, yAreaEnd);
8316
8938
  ctx.fillStyle = selectedAreaColor2;
8317
8939
  ctx.closePath();
8318
- ctx.fill();
8940
+ ctx.fill("nonzero");
8319
8941
  }
8320
8942
  }
8321
8943
  const MiddlewareRuler = (opts, config) => {
@@ -8363,8 +8985,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8363
8985
  if (show === true) {
8364
8986
  const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
8365
8987
  const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
8366
- drawScrollerSelectedArea(overlayContext, { snapshot, calculator, style });
8367
8988
  drawRulerBackground(overlayContext, { viewSizeInfo, style });
8989
+ drawScrollerSelectedArea(overlayContext, { snapshot, calculator, style });
8368
8990
  const { list: xList, rulerUnit } = calcXRulerScaleList({ viewScaleInfo, viewSizeInfo });
8369
8991
  drawXRuler(overlayContext, { scaleList: xList, style });
8370
8992
  const { list: yList } = calcYRulerScaleList({ viewScaleInfo, viewSizeInfo });
@@ -8384,15 +9006,16 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8384
9006
  };
8385
9007
  const defaultElementDetail = getDefaultElementDetailConfig();
8386
9008
  const MiddlewareTextEditor = (opts) => {
8387
- const { eventHub, boardContent, viewer, sharer } = opts;
9009
+ const { eventHub, boardContent, viewer, sharer, calculator } = opts;
8388
9010
  const canvas = boardContent.boardContext.canvas;
8389
- const textarea = document.createElement("div");
8390
- textarea.setAttribute("contenteditable", "true");
8391
- const canvasWrapper = document.createElement("div");
8392
9011
  const container = opts.container || document.body;
8393
- const mask = document.createElement("div");
9012
+ let textarea = document.createElement("div");
9013
+ textarea.setAttribute("contenteditable", "true");
9014
+ let canvasWrapper = document.createElement("div");
9015
+ let mask = document.createElement("div");
8394
9016
  let activeElem = null;
8395
9017
  let activePosition = [];
9018
+ let originText = "";
8396
9019
  const id = `idraw-middleware-text-editor-${Math.random().toString(26).substring(2)}`;
8397
9020
  mask.setAttribute("id", id);
8398
9021
  canvasWrapper.appendChild(textarea);
@@ -8409,12 +9032,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8409
9032
  resetCanvasWrapper();
8410
9033
  resetTextArea(e);
8411
9034
  mask.style.display = "block";
9035
+ originText = "";
8412
9036
  if (activeElem == null ? void 0 : activeElem.uuid) {
8413
9037
  sharer.setActiveOverrideElemenentMap({
8414
9038
  [activeElem.uuid]: {
8415
9039
  operations: { invisible: true }
8416
9040
  }
8417
9041
  });
9042
+ originText = activeElem.detail.text || "";
8418
9043
  viewer.drawFrame();
8419
9044
  }
8420
9045
  };
@@ -8538,13 +9163,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8538
9163
  canvasWrapper.style.width = `${width}px`;
8539
9164
  canvasWrapper.style.height = `${height}px`;
8540
9165
  };
8541
- mask.addEventListener("click", () => {
9166
+ const maskClickEvent = () => {
8542
9167
  hideTextArea();
8543
- });
8544
- textarea.addEventListener("click", (e) => {
9168
+ };
9169
+ const textareaClickEvent = (e) => {
8545
9170
  e.stopPropagation();
8546
- });
8547
- textarea.addEventListener("input", () => {
9171
+ };
9172
+ const textareaInputEvent = () => {
8548
9173
  if (activeElem && activePosition) {
8549
9174
  activeElem.detail.text = textarea.innerText || "";
8550
9175
  eventHub.trigger(coreEventKeys.TEXT_CHANGE, {
@@ -8556,11 +9181,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8556
9181
  },
8557
9182
  position: [...activePosition || []]
8558
9183
  });
9184
+ calculator.modifyText(activeElem);
8559
9185
  viewer.drawFrame();
8560
9186
  }
8561
- });
8562
- textarea.addEventListener("blur", () => {
9187
+ };
9188
+ const textareaBlurEvent = () => {
8563
9189
  if (activeElem && activePosition) {
9190
+ activeElem.detail.text = textarea.innerText || "";
8564
9191
  eventHub.trigger(coreEventKeys.TEXT_CHANGE, {
8565
9192
  element: {
8566
9193
  uuid: activeElem.uuid,
@@ -8570,22 +9197,66 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8570
9197
  },
8571
9198
  position: [...activePosition]
8572
9199
  });
9200
+ const data = sharer.getActiveStorage("data") || { elements: [] };
9201
+ const updateContent = {
9202
+ detail: {
9203
+ text: activeElem.detail.text
9204
+ }
9205
+ };
9206
+ updateElementInList(activeElem.uuid, updateContent, data.elements);
9207
+ eventHub.trigger(coreEventKeys.CHANGE, {
9208
+ selectedElements: [
9209
+ {
9210
+ ...activeElem,
9211
+ detail: {
9212
+ ...activeElem.detail,
9213
+ ...updateContent.detail
9214
+ }
9215
+ }
9216
+ ],
9217
+ data,
9218
+ type: "modifyElement",
9219
+ modifyRecord: {
9220
+ type: "modifyElement",
9221
+ time: Date.now(),
9222
+ content: {
9223
+ method: "modifyElement",
9224
+ uuid: activeElem.uuid,
9225
+ before: {
9226
+ "detail.text": originText
9227
+ },
9228
+ after: {
9229
+ "detail.text": activeElem.detail.text
9230
+ }
9231
+ }
9232
+ }
9233
+ });
9234
+ calculator.modifyText(activeElem);
9235
+ viewer.drawFrame();
8573
9236
  }
8574
9237
  hideTextArea();
8575
- });
8576
- textarea.addEventListener("keydown", (e) => {
9238
+ };
9239
+ const textareaKeyDownEvent = (e) => {
8577
9240
  e.stopPropagation();
8578
- });
8579
- textarea.addEventListener("keypress", (e) => {
9241
+ };
9242
+ const textareaKeyPressEvent = (e) => {
8580
9243
  e.stopPropagation();
8581
- });
8582
- textarea.addEventListener("keyup", (e) => {
9244
+ };
9245
+ const textareaKeyUpEvent = (e) => {
8583
9246
  e.stopPropagation();
8584
- });
8585
- textarea.addEventListener("wheel", (e) => {
9247
+ };
9248
+ const textareaWheelEvent = (e) => {
8586
9249
  e.stopPropagation();
8587
9250
  e.preventDefault();
8588
- });
9251
+ };
9252
+ mask.addEventListener("click", maskClickEvent);
9253
+ textarea.addEventListener("click", textareaClickEvent);
9254
+ textarea.addEventListener("input", textareaInputEvent);
9255
+ textarea.addEventListener("blur", textareaBlurEvent);
9256
+ textarea.addEventListener("keydown", textareaKeyDownEvent);
9257
+ textarea.addEventListener("keypress", textareaKeyPressEvent);
9258
+ textarea.addEventListener("keyup", textareaKeyUpEvent);
9259
+ textarea.addEventListener("wheel", textareaWheelEvent);
8589
9260
  const textEditCallback = (e) => {
8590
9261
  var _a;
8591
9262
  if ((e == null ? void 0 : e.position) && (e == null ? void 0 : e.element) && ((_a = e == null ? void 0 : e.element) == null ? void 0 : _a.type) === "text") {
@@ -8601,6 +9272,26 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8601
9272
  },
8602
9273
  disuse() {
8603
9274
  eventHub.off(coreEventKeys.TEXT_EDIT, textEditCallback);
9275
+ mask.removeEventListener("click", maskClickEvent);
9276
+ textarea.removeEventListener("click", textareaClickEvent);
9277
+ textarea.removeEventListener("input", textareaInputEvent);
9278
+ textarea.removeEventListener("blur", textareaBlurEvent);
9279
+ textarea.removeEventListener("keydown", textareaKeyDownEvent);
9280
+ textarea.removeEventListener("keypress", textareaKeyPressEvent);
9281
+ textarea.removeEventListener("keyup", textareaKeyUpEvent);
9282
+ textarea.removeEventListener("wheel", textareaWheelEvent);
9283
+ canvasWrapper.removeChild(textarea);
9284
+ mask.removeChild(canvasWrapper);
9285
+ container.removeChild(mask);
9286
+ textarea.remove();
9287
+ canvasWrapper.remove();
9288
+ mask = null;
9289
+ textarea = null;
9290
+ canvasWrapper = null;
9291
+ mask = null;
9292
+ activeElem = null;
9293
+ activePosition = null;
9294
+ originText = null;
8604
9295
  }
8605
9296
  };
8606
9297
  };
@@ -8657,23 +9348,22 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8657
9348
  const { left, top, width, height } = clientRect;
8658
9349
  return { left, top, width, height };
8659
9350
  };
8660
- const contextMenuPointer = document.createElement("div");
8661
- contextMenuPointer.setAttribute("id", id);
8662
- contextMenuPointer.style.position = "fixed";
8663
- contextMenuPointer.style.top = "0";
8664
- contextMenuPointer.style.bottom = "unset";
8665
- contextMenuPointer.style.left = "0";
8666
- contextMenuPointer.style.right = "unset";
8667
- container.appendChild(contextMenuPointer);
9351
+ let contextMenuPointer = document.createElement("div");
8668
9352
  return {
8669
9353
  name: "@middleware/pointer",
8670
9354
  use() {
9355
+ contextMenuPointer.setAttribute("id", id);
9356
+ contextMenuPointer.style.position = "fixed";
9357
+ contextMenuPointer.style.top = "0";
9358
+ contextMenuPointer.style.bottom = "unset";
9359
+ contextMenuPointer.style.left = "0";
9360
+ contextMenuPointer.style.right = "unset";
9361
+ container.appendChild(contextMenuPointer);
8671
9362
  },
8672
9363
  disuse() {
8673
- },
8674
- pointStart(e) {
8675
- },
8676
- pointEnd() {
9364
+ container.removeChild(contextMenuPointer);
9365
+ contextMenuPointer.remove();
9366
+ contextMenuPointer = null;
8677
9367
  },
8678
9368
  contextMenu(e) {
8679
9369
  const { point } = e;
@@ -8735,9 +9425,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8735
9425
  resetMiddlewareConfig(middleware, config) {
8736
9426
  __privateGet(this, _board).resetMiddlewareConfig(middleware, config);
8737
9427
  }
8738
- setData(data, opts) {
9428
+ setData(data) {
8739
9429
  validateElements((data == null ? void 0 : data.elements) || []);
8740
- __privateGet(this, _board).setData(data, opts);
9430
+ __privateGet(this, _board).setData(data);
8741
9431
  }
8742
9432
  getData() {
8743
9433
  return __privateGet(this, _board).getData();
@@ -8796,6 +9486,227 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
8796
9486
  offBoardWatcherEvents() {
8797
9487
  __privateGet(this, _board).offWatcherEvents();
8798
9488
  }
9489
+ createElement(type, element, opts) {
9490
+ const { viewScaleInfo, viewSizeInfo } = this.getViewInfo();
9491
+ return createElement(
9492
+ type,
9493
+ element || {},
9494
+ (opts == null ? void 0 : opts.viewCenter) === true ? {
9495
+ viewScaleInfo,
9496
+ viewSizeInfo
9497
+ } : void 0
9498
+ );
9499
+ }
9500
+ updateElement(element) {
9501
+ const data = this.getData() || { elements: [] };
9502
+ const uuid = element.uuid;
9503
+ const position = getElementPositionFromList(uuid, data.elements);
9504
+ const beforeElem = findElementFromListByPosition(position, data.elements);
9505
+ if (!beforeElem) {
9506
+ return null;
9507
+ }
9508
+ const before = toFlattenElement(beforeElem);
9509
+ const updatedElement = updateElementInListByPosition(position, element, data.elements, { strict: true });
9510
+ const after = toFlattenElement(updatedElement);
9511
+ this.setData(data);
9512
+ this.refresh();
9513
+ const modifyRecord = {
9514
+ type: "updateElement",
9515
+ time: Date.now(),
9516
+ content: { method: "updateElement", uuid, before, after }
9517
+ };
9518
+ return modifyRecord;
9519
+ }
9520
+ modifyElement(element) {
9521
+ const { uuid, ...restElement } = element;
9522
+ const data = this.getData() || { elements: [] };
9523
+ const position = getElementPositionFromList(uuid, data.elements);
9524
+ const beforeElem = findElementFromListByPosition(position, data.elements);
9525
+ if (!beforeElem) {
9526
+ return null;
9527
+ }
9528
+ const modifyRecord = getModifyElementRecord({
9529
+ modifiedElement: element,
9530
+ beforeElement: beforeElem
9531
+ });
9532
+ updateElementInListByPosition(position, restElement, data.elements);
9533
+ this.setData(data);
9534
+ this.refresh();
9535
+ return modifyRecord;
9536
+ }
9537
+ modifyElements(elements) {
9538
+ const data = this.getData() || { elements: [] };
9539
+ let modifyRecord = null;
9540
+ const before = [];
9541
+ const after = [];
9542
+ elements.forEach((element) => {
9543
+ const { uuid, ...restElement } = element;
9544
+ const position = getElementPositionFromList(uuid, data.elements);
9545
+ const beforeElem = findElementFromListByPosition(position, data.elements);
9546
+ if (!beforeElem) {
9547
+ return null;
9548
+ }
9549
+ const tempRecord = getModifyElementRecord({
9550
+ modifiedElement: element,
9551
+ beforeElement: beforeElem
9552
+ });
9553
+ if (tempRecord.content) {
9554
+ before.push({
9555
+ ...tempRecord.content.before,
9556
+ uuid
9557
+ });
9558
+ after.push({
9559
+ ...tempRecord.content.after,
9560
+ uuid
9561
+ });
9562
+ }
9563
+ updateElementInListByPosition(position, restElement, data.elements);
9564
+ });
9565
+ modifyRecord = {
9566
+ type: "modifyElements",
9567
+ time: Date.now(),
9568
+ content: {
9569
+ method: "modifyElements",
9570
+ before,
9571
+ after
9572
+ }
9573
+ };
9574
+ this.setData(data);
9575
+ this.refresh();
9576
+ return modifyRecord;
9577
+ }
9578
+ addElement(element, opts) {
9579
+ var _a;
9580
+ const data = this.getData() || { elements: [] };
9581
+ if (!opts || !((_a = opts == null ? void 0 : opts.position) == null ? void 0 : _a.length)) {
9582
+ data.elements.push(element);
9583
+ } else if (opts == null ? void 0 : opts.position) {
9584
+ const position2 = [...(opts == null ? void 0 : opts.position) || []];
9585
+ insertElementToListByPosition(element, position2, data.elements);
9586
+ }
9587
+ const position = getElementPositionFromList(element.uuid, data.elements);
9588
+ const modifyRecord = {
9589
+ type: "addElement",
9590
+ time: Date.now(),
9591
+ content: { method: "addElement", uuid: element.uuid, position, element: deepClone(element) }
9592
+ };
9593
+ this.setData(data);
9594
+ this.refresh();
9595
+ return modifyRecord;
9596
+ }
9597
+ deleteElement(uuid) {
9598
+ const data = this.getData() || { elements: [] };
9599
+ const position = getElementPositionFromList(uuid, data.elements);
9600
+ const element = findElementFromListByPosition(position, data.elements);
9601
+ const modifyRecord = {
9602
+ type: "deleteElement",
9603
+ time: Date.now(),
9604
+ content: { method: "deleteElement", uuid, position, element: element ? deepClone(element) : null }
9605
+ };
9606
+ deleteElementInList(uuid, data.elements);
9607
+ this.setData(data);
9608
+ this.refresh();
9609
+ return modifyRecord;
9610
+ }
9611
+ moveElement(uuid, to) {
9612
+ const data = this.getData() || { elements: [] };
9613
+ const from = getElementPositionFromList(uuid, data.elements);
9614
+ const modifyRecord = {
9615
+ type: "moveElement",
9616
+ time: Date.now(),
9617
+ content: { method: "moveElement", uuid, from: [...from], to: [...to] }
9618
+ };
9619
+ const { elements: list } = moveElementPosition(data.elements, { from, to });
9620
+ data.elements = list;
9621
+ this.setData(data);
9622
+ this.refresh();
9623
+ return modifyRecord;
9624
+ }
9625
+ modifyLayout(layout) {
9626
+ const data = this.getData() || { elements: [] };
9627
+ const modifyRecord = {
9628
+ type: "modifyLayout",
9629
+ time: Date.now(),
9630
+ content: {
9631
+ method: "modifyLayout",
9632
+ before: null,
9633
+ after: null
9634
+ }
9635
+ };
9636
+ if (layout === null) {
9637
+ if (data.layout) {
9638
+ modifyRecord.content.before = toFlattenLayout(data.layout);
9639
+ delete data["layout"];
9640
+ this.setData(data);
9641
+ this.refresh();
9642
+ return modifyRecord;
9643
+ } else {
9644
+ return modifyRecord;
9645
+ }
9646
+ }
9647
+ const beforeLayout = data.layout;
9648
+ let before = {};
9649
+ const after = toFlattenLayout(layout);
9650
+ if (data.layout) {
9651
+ Object.keys(after).forEach((key2) => {
9652
+ let val = get(beforeLayout, key2);
9653
+ if (val === void 0 && /(borderRadius|borderWidth)\[[0-9]{1,}\]$/.test(key2)) {
9654
+ key2 = key2.replace(/\[[0-9]{1,}\]$/, "");
9655
+ val = get(beforeLayout, key2);
9656
+ }
9657
+ before[key2] = val;
9658
+ });
9659
+ before = toFlattenLayout(before);
9660
+ modifyRecord.content.before = before;
9661
+ } else {
9662
+ data.layout = {};
9663
+ }
9664
+ modifyRecord.content.after = after;
9665
+ mergeLayout(data.layout, layout);
9666
+ this.setData(data);
9667
+ this.refresh();
9668
+ return modifyRecord;
9669
+ }
9670
+ modifyGlobal(global) {
9671
+ const data = this.getData() || { elements: [] };
9672
+ const modifyRecord = {
9673
+ type: "modifyGlobal",
9674
+ time: Date.now(),
9675
+ content: {
9676
+ method: "modifyGlobal",
9677
+ before: null,
9678
+ after: null
9679
+ }
9680
+ };
9681
+ if (global === null) {
9682
+ if (data.global) {
9683
+ modifyRecord.content.before = toFlattenGlobal(data.global);
9684
+ delete data["global"];
9685
+ this.setData(data);
9686
+ this.refresh();
9687
+ return modifyRecord;
9688
+ } else {
9689
+ return modifyRecord;
9690
+ }
9691
+ }
9692
+ const beforeGlobal = data.global;
9693
+ let before = {};
9694
+ const after = toFlattenGlobal(global);
9695
+ if (data.global) {
9696
+ Object.keys(after).forEach((key2) => {
9697
+ before[key2] = get(beforeGlobal, key2);
9698
+ });
9699
+ before = toFlattenGlobal(before);
9700
+ modifyRecord.content.before = before;
9701
+ } else {
9702
+ data.global = {};
9703
+ }
9704
+ modifyRecord.content.after = after;
9705
+ mergeGlobal(data.global, global);
9706
+ this.setData(data);
9707
+ this.refresh();
9708
+ return modifyRecord;
9709
+ }
8799
9710
  }
8800
9711
  _board = new WeakMap();
8801
9712
  _canvas = new WeakMap();