Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheet): #1016 drag rows and columns to merge cells in the wrong position (#1074)

Gpound.liub1a21d8c7549
diff --git a/docs/tldr/handMoveRowsCols.tldr b/docs/tldr/handMoveRowsCols.tldr
new file mode 100644
index 0000000000..33865d6418
--- /dev/null
+++ b/docs/tldr/handMoveRowsCols.tldr
@@ -0,0 +1,2161 @@
+{
+ "tldrawFileFormatVersion": 1,
+ "schema": {
+ "schemaVersion": 1,
+ "storeVersion": 4,
+ "recordVersions": {
+ "asset": {
+ "version": 1,
+ "subTypeKey": "type",
+ "subTypeVersions": {
+ "image": 2,
+ "video": 2,
+ "bookmark": 0
+ }
+ },
+ "camera": {
+ "version": 1
+ },
+ "document": {
+ "version": 2
+ },
+ "instance": {
+ "version": 22
+ },
+ "instance_page_state": {
+ "version": 5
+ },
+ "page": {
+ "version": 1
+ },
+ "shape": {
+ "version": 3,
+ "subTypeKey": "type",
+ "subTypeVersions": {
+ "group": 0,
+ "text": 1,
+ "bookmark": 1,
+ "draw": 1,
+ "geo": 7,
+ "note": 4,
+ "line": 1,
+ "frame": 0,
+ "arrow": 2,
+ "highlight": 0,
+ "embed": 4,
+ "image": 2,
+ "video": 1
+ }
+ },
+ "instance_presence": {
+ "version": 5
+ },
+ "pointer": {
+ "version": 1
+ }
+ }
+ },
+ "records": [
+ {
+ "gridSize": 10,
+ "name": "",
+ "meta": {},
+ "id": "document:document",
+ "typeName": "document"
+ },
+ {
+ "id": "pointer:pointer",
+ "typeName": "pointer",
+ "x": 1612.998880263944,
+ "y": 347.3408281592515,
+ "lastActivityTimestamp": 1704866955718,
+ "meta": {}
+ },
+ {
+ "meta": {},
+ "id": "page:page",
+ "name": "Page 1",
+ "index": "a1",
+ "typeName": "page"
+ },
+ {
+ "x": -292.4424917164073,
+ "y": 160.35701328752248,
+ "z": 0.43819124652182156,
+ "meta": {},
+ "id": "camera:page:page",
+ "typeName": "camera"
+ },
+ {
+ "editingShapeId": null,
+ "croppingShapeId": null,
+ "selectedShapeIds": [],
+ "hoveredShapeId": "shape:dFeveS-GehMaRYzINPKui",
+ "erasingShapeIds": [],
+ "hintingShapeIds": [],
+ "focusedGroupId": null,
+ "meta": {},
+ "id": "instance_page_state:page:page",
+ "pageId": "page:page",
+ "typeName": "instance_page_state"
+ },
+ {
+ "followingUserId": null,
+ "opacityForNextShape": 1,
+ "stylesForNextShape": {
+ "tldraw:geo": "rectangle",
+ "tldraw:color": "violet"
+ },
+ "brush": null,
+ "scribbles": [],
+ "cursor": {
+ "type": "default",
+ "rotation": 0
+ },
+ "isFocusMode": false,
+ "exportBackground": true,
+ "isDebugMode": false,
+ "isToolLocked": false,
+ "screenBounds": {
+ "x": 0,
+ "y": 0,
+ "w": 1399,
+ "h": 966
+ },
+ "zoomBrush": null,
+ "isGridMode": false,
+ "isPenMode": false,
+ "chatMessage": "",
+ "isChatting": false,
+ "highlightedUserIds": [],
+ "canMoveCamera": true,
+ "isFocused": true,
+ "devicePixelRatio": 2,
+ "isCoarsePointer": false,
+ "isHoveringCanvas": true,
+ "openMenus": [],
+ "isChangingStyle": false,
+ "isReadonly": false,
+ "meta": {},
+ "id": "instance:instance",
+ "currentPageId": "page:page",
+ "typeName": "instance"
+ },
+ {
+ "x": 472.0625,
+ "y": 57.3203125,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 84.44837816408484,
+ "h": 701.5329274578631,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a1",
+ "id": "shape:P62MdUY0Dy81VSeTUIONl",
+ "typeName": "shape"
+ },
+ {
+ "x": 864.109375,
+ "y": 56.1796875,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 86.28864137419669,
+ "h": 702.5900322883235,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a2",
+ "id": "shape:vbhz70wsL10JtI9Xtq6KC",
+ "typeName": "shape"
+ },
+ {
+ "x": 320.3671875,
+ "y": 88.24255859375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 103.96875,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "1",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a3",
+ "id": "shape:CNSeMR_BSUg9frAXK1VUW",
+ "typeName": "shape"
+ },
+ {
+ "x": 639.6796875,
+ "y": 84.82849609375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 157.28515625,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "2",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a4",
+ "id": "shape:2D7Oin0ZthSKRprVWSjVh",
+ "typeName": "shape"
+ },
+ {
+ "x": 966.7734375,
+ "y": 84.06287109375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 190.19921875,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "3",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a5",
+ "id": "shape:53jPM-Q_ZIMhF73t2JUAf",
+ "typeName": "shape"
+ },
+ {
+ "x": 399.375,
+ "y": 194.39880859375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 87.9921875,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "4",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a6",
+ "id": "shape:OTEkfsumv6I3__FfNszb2",
+ "typeName": "shape"
+ },
+ {
+ "x": 518.28125,
+ "y": 191.81287109375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 134.328125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "5",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a7",
+ "id": "shape:dppGVZY6bvPOfkCbWEVD2",
+ "typeName": "shape"
+ },
+ {
+ "x": 736.765625,
+ "y": 184.00818359375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 143.05859375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "6",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a8",
+ "id": "shape:Lns1atnS5NiJaz2IZHgpq",
+ "typeName": "shape"
+ },
+ {
+ "x": 898.875,
+ "y": 183.56287109375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 257.0078125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "7",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a9",
+ "id": "shape:o1rgYhARe-nUdq9dbtGsh",
+ "typeName": "shape"
+ },
+ {
+ "x": 524.6484375,
+ "y": 275.00818359375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 359.55859375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "8",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aA",
+ "id": "shape:cqr-o-7eDFKCQE_xUV5AK",
+ "typeName": "shape"
+ },
+ {
+ "x": 425.1171875,
+ "y": 346.78162109375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 162.98828125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "9",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aB",
+ "id": "shape:GnlPTdf2n5aP-oPABBbwn",
+ "typeName": "shape"
+ },
+ {
+ "x": 816.5078125,
+ "y": 343.54724609375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 206.76953125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "10",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aC",
+ "id": "shape:I14tOD8CBmS4i_lCfqeec",
+ "typeName": "shape"
+ },
+ {
+ "x": 425.8359375,
+ "y": 429.18787109375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 645.6875,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "11",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aD",
+ "id": "shape:LMKxPzywvA9bwQCoBHNd8",
+ "typeName": "shape"
+ },
+ {
+ "x": 477.8671875,
+ "y": 499.591875,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 61.6953125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "12",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aE",
+ "id": "shape:N2o98gLAI0Tu_RY-eG82P",
+ "typeName": "shape"
+ },
+ {
+ "x": 878.48828125,
+ "y": 483.75984375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 56.3984375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "13",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aF",
+ "id": "shape:OrzEyM2qRUb3rCIMm4W2M",
+ "typeName": "shape"
+ },
+ {
+ "x": 444.5685039964794,
+ "y": 768.473474749199,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "m",
+ "w": 139.078125,
+ "text": "fromRange",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "aG",
+ "id": "shape:WplwFUreuMXbzmz9nImMi",
+ "typeName": "shape"
+ },
+ {
+ "x": 858.4978139432524,
+ "y": 778.3026825648035,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "m",
+ "w": 105.640625,
+ "text": "toRange",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "aH",
+ "id": "shape:_-jyV9-75YjoYv27BrN_5",
+ "typeName": "shape"
+ },
+ {
+ "x": 515.6821636368934,
+ "y": 809.8912193648168,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "violet",
+ "size": "m",
+ "w": 413.828125,
+ "text": "1,3,13 unchnged\n2 move forward fromRamge step\n4,5,6,7,8,9,10,14,15 unhandle \n12 move to mirror position",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "aI",
+ "id": "shape:yqgyKvkqk2c8BIR2xSo3D",
+ "typeName": "shape"
+ },
+ {
+ "x": 1375.4013671875,
+ "y": 56.40625,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 75.6285915297724,
+ "h": 718.8506485950418,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aJ",
+ "id": "shape:yDkvUKbSh4fbDNHNjTJu3",
+ "typeName": "shape"
+ },
+ {
+ "x": 1767.4482421875,
+ "y": 55.265625,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 85.63974594789352,
+ "h": 726.4901486299218,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aK",
+ "id": "shape:NRWw5GJfSaVB5oqekU-VR",
+ "typeName": "shape"
+ },
+ {
+ "x": 1223.7060546875,
+ "y": 87.32849609375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 103.96875,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "1",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aL",
+ "id": "shape:ZA4OG8Xf5kERNkScCteNM",
+ "typeName": "shape"
+ },
+ {
+ "x": 1543.0185546875,
+ "y": 83.91443359375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 157.28515625,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "2",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aM",
+ "id": "shape:8W2uiQV7-ZI-Oi0bJ6kPZ",
+ "typeName": "shape"
+ },
+ {
+ "x": 1870.1123046875,
+ "y": 83.14880859375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 190.19921875,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "3",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aN",
+ "id": "shape:nhiHR5tm-TbwLmhGXSFiA",
+ "typeName": "shape"
+ },
+ {
+ "x": 1302.7138671875,
+ "y": 193.48474609375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 87.9921875,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "4",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aO",
+ "id": "shape:tskMS3Y2tlTNzsQ_-7Htr",
+ "typeName": "shape"
+ },
+ {
+ "x": 1421.6201171875,
+ "y": 190.89880859375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 134.328125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "5",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aP",
+ "id": "shape:I44AWzgcfCWBlp7mP14oc",
+ "typeName": "shape"
+ },
+ {
+ "x": 1640.1044921875,
+ "y": 183.09412109375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 143.05859375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "6",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aQ",
+ "id": "shape:9gwPFFe06d3O9CJFbT8mI",
+ "typeName": "shape"
+ },
+ {
+ "x": 1802.2138671875,
+ "y": 182.64880859375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 257.0078125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "7",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aR",
+ "id": "shape:nRlZeaz1AJNOzYS4P6FOv",
+ "typeName": "shape"
+ },
+ {
+ "x": 1427.9873046875,
+ "y": 274.09412109375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 359.55859375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "8",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aS",
+ "id": "shape:dFeveS-GehMaRYzINPKui",
+ "typeName": "shape"
+ },
+ {
+ "x": 1328.4560546875,
+ "y": 345.86755859375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 162.98828125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "9",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aT",
+ "id": "shape:CGFibHbFXYd3EGJD1wCj_",
+ "typeName": "shape"
+ },
+ {
+ "x": 1719.8466796875,
+ "y": 342.63318359375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 206.76953125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "10",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aU",
+ "id": "shape:zBCzM8t3iAco9S6K64qPY",
+ "typeName": "shape"
+ },
+ {
+ "x": 1329.1748046875,
+ "y": 428.27380859375,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 645.6875,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "11",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aV",
+ "id": "shape:lc5YAIGjb5W4e3_nmEQvq",
+ "typeName": "shape"
+ },
+ {
+ "x": 1381.2060546875,
+ "y": 498.6778125,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 61.6953125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "12",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aW",
+ "id": "shape:_5tQs7Nrv6rkhqjTlhk99",
+ "typeName": "shape"
+ },
+ {
+ "x": 1781.8271484375,
+ "y": 482.84578125,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 56.3984375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "13",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aX",
+ "id": "shape:8IcZnSV-nKKph8Ub7CIfA",
+ "typeName": "shape"
+ },
+ {
+ "x": 1361.3712617256426,
+ "y": 778.6840754377405,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "m",
+ "w": 105.640625,
+ "text": "toRange",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "aY",
+ "id": "shape:cjcW0RQgdyn5A2ejCmZcE",
+ "typeName": "shape"
+ },
+ {
+ "x": 1768.9557535114254,
+ "y": 785.0923065658747,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "m",
+ "w": 139.078125,
+ "text": "fromRange",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "aZ",
+ "id": "shape:4cbs5XzURQifPCxvKBL7k",
+ "typeName": "shape"
+ },
+ {
+ "x": 1466.9183002479476,
+ "y": 823.113365068284,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "violet",
+ "size": "m",
+ "w": 363.140625,
+ "text": "1,3 unchanged\n2 move back fromRange step\n4,5,6,7,8,9,10,11,14,15 unhandle\n13 move to mirror position\n12 move right",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "aa",
+ "id": "shape:G0zg7fkZTEce7PNcOTl_v",
+ "typeName": "shape"
+ },
+ {
+ "x": 2230.7672502938017,
+ "y": 72.59615047955401,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 298.453125,
+ "h": 650.8844989933119,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "ad",
+ "id": "shape:USoQ-Gz6lgAtx9o6_Nvz1",
+ "typeName": "shape"
+ },
+ {
+ "x": 2431.6695940438017,
+ "y": 42.813859204113896,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 317.4137666022398,
+ "h": 729.1924324265369,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "ae",
+ "id": "shape:5iRoVaumyCh18yyPrqIW9",
+ "typeName": "shape"
+ },
+ {
+ "x": 2126.7438127938017,
+ "y": 99.17196787658833,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 77.66796875,
+ "h": 70.6796875,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "1",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "af",
+ "id": "shape:06hUQvNWG9Azznfv69KfK",
+ "typeName": "shape"
+ },
+ {
+ "x": 2779.350247715548,
+ "y": 94.60580533242506,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 152.3046875,
+ "h": 69.30078125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "2",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "ag",
+ "id": "shape:k39Bg4CT2Qj4J-5FXUTdS",
+ "typeName": "shape"
+ },
+ {
+ "x": 2179.2516252938017,
+ "y": 222.57040537658833,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 100.0234375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "3",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "ah",
+ "id": "shape:wtWUB9L6S3Wi85fCTLoaw",
+ "typeName": "shape"
+ },
+ {
+ "x": 2679.455948511778,
+ "y": 218.3948443270014,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 144.76953125,
+ "h": 62.0625,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "4",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "ai",
+ "id": "shape:qNw6a4kSCL8NxgcwwAafk",
+ "typeName": "shape"
+ },
+ {
+ "x": 2355.3028112169095,
+ "y": 298.6087647508237,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 274.9375,
+ "h": 62.77734375,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "5",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aj",
+ "id": "shape:gifZmd76T4qNd-XZ6bCq8",
+ "typeName": "shape"
+ },
+ {
+ "x": 2371.2438127938017,
+ "y": 388.2344678765883,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 97.76656061206359,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "6",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "ak",
+ "id": "shape:-I6rWzltrZxkhEOkMtJPz",
+ "typeName": "shape"
+ },
+ {
+ "x": 2499.4235002938017,
+ "y": 387.8360303765883,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 83.0234375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "7",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "al",
+ "id": "shape:W-MKxZH0RNPTkyvMqCyIu",
+ "typeName": "shape"
+ },
+ {
+ "x": 2453.503049756205,
+ "y": 471.276221493116,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 61.6953125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "8",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "am",
+ "id": "shape:-il-WBxPjKs9gOfbOv5ka",
+ "typeName": "shape"
+ },
+ {
+ "x": 2180.0044017017103,
+ "y": 609.2202258074503,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 650.80859375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "11",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "an",
+ "id": "shape:9LKJHT6UeDwlvTiY6cDB8",
+ "typeName": "shape"
+ },
+ {
+ "x": 2288.568090018054,
+ "y": 542.7594195869685,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 85.77842662415833,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "9",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "ao",
+ "id": "shape:cX0-RvXN_8tutum0qQavY",
+ "typeName": "shape"
+ },
+ {
+ "x": 2571.402629065568,
+ "y": 537.4819353558903,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 119.31619531702245,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "10",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "ap",
+ "id": "shape:2abj8uSErOBSgdH7zQDjb",
+ "typeName": "shape"
+ },
+ {
+ "x": 2322.4499606706718,
+ "y": 842.8417831541492,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "violet",
+ "size": "m",
+ "w": 334.2421875,
+ "text": "1,2,11,10 unchnged\n3,4,5,6,7 deestroy\n8,9 move to mirror position",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "ar",
+ "id": "shape:kHLcCXu7Z_DEvFwcu5fKj",
+ "typeName": "shape"
+ },
+ {
+ "x": 2544.490208833556,
+ "y": 778.892978148866,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "m",
+ "w": 105.640625,
+ "text": "toRange",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "as",
+ "id": "shape:SD0M6P51K2i9BtIu5lBw7",
+ "typeName": "shape"
+ },
+ {
+ "x": 2270.981507056962,
+ "y": 726.9030949443218,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "m",
+ "w": 139.078125,
+ "text": "fromRange",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "at",
+ "id": "shape:oh9mpeiYHfgjPYG4bWKS6",
+ "typeName": "shape"
+ },
+ {
+ "x": 3150.05147464424,
+ "y": 69.71067771276694,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 298.453125,
+ "h": 650.8844989933119,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "au",
+ "id": "shape:pcN9670sdxI7rxL_3elxq",
+ "typeName": "shape"
+ },
+ {
+ "x": 3350.95381839424,
+ "y": 39.92838643732682,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 317.4137666022398,
+ "h": 729.1924324265369,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "av",
+ "id": "shape:1uCMJS6cqH2YYXg2Zhyec",
+ "typeName": "shape"
+ },
+ {
+ "x": 3046.02803714424,
+ "y": 96.28649510980125,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 77.66796875,
+ "h": 70.6796875,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "1",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aw",
+ "id": "shape:-z4w1mDbtiEJ3Fp-qtPWU",
+ "typeName": "shape"
+ },
+ {
+ "x": 3698.6344720659863,
+ "y": 91.72033256563799,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 152.3046875,
+ "h": 69.30078125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "2",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "ax",
+ "id": "shape:6A3shFz50wuzMN3DwcvWz",
+ "typeName": "shape"
+ },
+ {
+ "x": 3098.53584964424,
+ "y": 219.68493260980125,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 100.0234375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "3",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "ay",
+ "id": "shape:8UUQWaChGsQRQk-icYNY5",
+ "typeName": "shape"
+ },
+ {
+ "x": 3598.7401728622162,
+ "y": 215.50937156021433,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 144.76953125,
+ "h": 62.0625,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "4",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "az",
+ "id": "shape:nQZ22tV8Ar4AJLEe_1ch0",
+ "typeName": "shape"
+ },
+ {
+ "x": 3274.587035567348,
+ "y": 295.7232919840366,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 274.9375,
+ "h": 62.77734375,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "5",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "b00",
+ "id": "shape:f-INTEQ9H8xLd4Qq06Lpr",
+ "typeName": "shape"
+ },
+ {
+ "x": 3290.52803714424,
+ "y": 385.34899510980125,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 97.76656061206359,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "6",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "b01",
+ "id": "shape:OCTXq7gpWl4evpdEFLhgJ",
+ "typeName": "shape"
+ },
+ {
+ "x": 3418.70772464424,
+ "y": 384.95055760980125,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 83.0234375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "7",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "b02",
+ "id": "shape:PwZsY2RNJ2yBJixaYY5Mw",
+ "typeName": "shape"
+ },
+ {
+ "x": 3372.7872741066435,
+ "y": 468.3907487263289,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 61.6953125,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "8",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "b03",
+ "id": "shape:ArXaxW0gJt4ZQquiPTXk3",
+ "typeName": "shape"
+ },
+ {
+ "x": 3099.2886260521486,
+ "y": 606.3347530406633,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 650.80859375,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "11",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "b04",
+ "id": "shape:LKIX_v9CFTfWNenI7thrn",
+ "typeName": "shape"
+ },
+ {
+ "x": 3207.8523143684924,
+ "y": 539.8739468201816,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 85.77842662415833,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "9",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "b05",
+ "id": "shape:eHQ0-nx7uSVvg-lPsc4wf",
+ "typeName": "shape"
+ },
+ {
+ "x": 3490.686853416006,
+ "y": 534.5964625891033,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 119.31619531702245,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "10",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "b06",
+ "id": "shape:_TrxMAgk1Ht0XiP9d3jYZ",
+ "typeName": "shape"
+ },
+ {
+ "x": 3264.085190882668,
+ "y": 854.8051637107698,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "violet",
+ "size": "m",
+ "w": 367.171875,
+ "text": "1,2,11 unchnged\n3,4,5,6,7, deestroy\n10,8 move to mirror position\n9 move right fromRange step",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "b07",
+ "id": "shape:IBxxUJ_KBA1FL58U-YuYC",
+ "typeName": "shape"
+ },
+ {
+ "x": 3198.0026982253244,
+ "y": 731.4582032883303,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "m",
+ "w": 105.640625,
+ "text": "toRange",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "b08",
+ "id": "shape:NQ57JvxaZgtDxCqrvsVB-",
+ "typeName": "shape"
+ },
+ {
+ "x": 3448.554074086629,
+ "y": 774.4834277782564,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "m",
+ "w": 139.078125,
+ "text": "fromRange",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:page",
+ "index": "b09",
+ "id": "shape:gZmLskcNZ51K8RSqmNq6N",
+ "typeName": "shape"
+ },
+ {
+ "x": 442.4586613526074,
+ "y": 584.1852181749076,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 464.9205950376922,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "14",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "b0A",
+ "id": "shape:l53ETguoSEd5vAAEhqVFC",
+ "typeName": "shape"
+ },
+ {
+ "x": 515.0415081571743,
+ "y": 658.2527377148562,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 523.6482266998339,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "15",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "b0B",
+ "id": "shape:DW-wjdlDyxBwAzCLgeISU",
+ "typeName": "shape"
+ },
+ {
+ "x": 1333.2519202547724,
+ "y": 584.2475121358327,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 464.9205950376922,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "14",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "b0C",
+ "id": "shape:uqtIqThhennukeWGwDFQ3",
+ "typeName": "shape"
+ },
+ {
+ "x": 1405.8347670593394,
+ "y": 658.3150316757813,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 523.6482266998339,
+ "h": 61.6953125,
+ "geo": "rectangle",
+ "color": "violet",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "15",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "b0D",
+ "id": "shape:bT5sc_XKqn6PuZFDg-x2M",
+ "typeName": "shape"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/sheets-formula/src/controllers/__tests__/update-formula.controller.spec.ts b/packages/sheets-formula/src/controllers/__tests__/update-formula.controller.spec.ts
index 26b07d3730..de7d79ea98 100644
--- a/packages/sheets-formula/src/controllers/__tests__/update-formula.controller.spec.ts
+++ b/packages/sheets-formula/src/controllers/__tests__/update-formula.controller.spec.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { ICellData, Nullable, Univer } from '@univerjs/core';
+import type { ICellData, IRange, Nullable, Univer } from '@univerjs/core';
import { ICommandService, IUniverInstanceService, RANGE_TYPE } from '@univerjs/core';
import { MoveRowsCommand, NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '@univerjs/sheets';
import type { Injector } from '@wendellhu/redi';
@@ -22,6 +22,8 @@ import { afterEach, beforeEach, describe, it } from 'vitest';
import { createCommandTestBed } from './create-command-test-bed';
+const cellToRange = (row: number, col: number) =>
+ ({ startRow: row, endRow: row, startColumn: col, endColumn: col }) as IRange;
// TODO@Dushusir: add move range,insert range,delete range test case
describe('Test insert function operation', () => {
let univer: Univer;
@@ -79,8 +81,8 @@ describe('Test insert function operation', () => {
]);
const params = {
- fromRow: 0,
- toRow: 1,
+ fromRange: cellToRange(0, 1),
+ toRange: cellToRange(1, 1),
};
await commandService.executeCommand(MoveRowsCommand.id, params);
diff --git a/packages/sheets-formula/src/controllers/__tests__/utils.spec.ts b/packages/sheets-formula/src/controllers/__tests__/utils.spec.ts
index 54cb3561c5..609f887e78 100644
--- a/packages/sheets-formula/src/controllers/__tests__/utils.spec.ts
+++ b/packages/sheets-formula/src/controllers/__tests__/utils.spec.ts
@@ -14,6 +14,15 @@
* limitations under the License.
*/
+import type { IRange } from '@univerjs/core';
+import type {
+ IDeleteRangeMoveLeftCommandParams,
+ IDeleteRangeMoveUpCommandParams,
+ IMoveRowsCommandParams,
+ InsertRangeMoveDownCommandParams,
+ InsertRangeMoveRightCommandParams,
+ IRemoveRowColCommandParams,
+} from '@univerjs/sheets';
import {
DeleteRangeMoveLeftCommand,
DeleteRangeMoveUpCommand,
@@ -31,6 +40,8 @@ import { describe, expect, it } from 'vitest';
import { offsetArrayFormula, offsetFormula, removeFormulaData } from '../utils';
+const cellToRange = (row: number, col: number) =>
+ ({ startRow: row, endRow: row, startColumn: col, endColumn: col }) as IRange;
describe('utils test', () => {
describe('function offsetFormula', () => {
it('move range', () => {
@@ -100,9 +111,9 @@ describe('utils test', () => {
const command = {
id: MoveRowsCommand.id,
params: {
- fromRow: 0,
- toRow: 4,
- },
+ fromRange: cellToRange(0, 1),
+ toRange: cellToRange(4, 1),
+ } as IMoveRowsCommandParams,
};
const selections = [
@@ -179,9 +190,9 @@ describe('utils test', () => {
const command = {
id: MoveColsCommand.id,
params: {
- fromCol: 0,
- toCol: 4,
- },
+ fromRange: cellToRange(1, 0),
+ toRange: cellToRange(1, 4),
+ } as IMoveRowsCommandParams,
};
const selections = [
@@ -364,16 +375,14 @@ describe('utils test', () => {
const command = {
id: InsertRangeMoveRightCommand.id,
params: {
- ranges: [
- {
- startRow: 0,
- startColumn: 0,
- endRow: 0,
- endColumn: 0,
- rangeType: 0,
- },
- ],
- },
+ range: {
+ startRow: 0,
+ startColumn: 0,
+ endRow: 0,
+ endColumn: 0,
+ rangeType: 0,
+ },
+ } as InsertRangeMoveRightCommandParams,
};
const newFormulaData = offsetFormula(formulaData, command, unitId, sheetId);
@@ -415,16 +424,14 @@ describe('utils test', () => {
const command = {
id: InsertRangeMoveDownCommand.id,
params: {
- ranges: [
- {
- startRow: 0,
- startColumn: 3,
- endRow: 0,
- endColumn: 3,
- rangeType: 0,
- },
- ],
- },
+ range: {
+ startRow: 0,
+ startColumn: 3,
+ endRow: 0,
+ endColumn: 3,
+ rangeType: 0,
+ },
+ } as InsertRangeMoveDownCommandParams,
};
const newFormulaData = offsetFormula(formulaData, command, unitId, sheetId);
@@ -469,16 +476,14 @@ describe('utils test', () => {
const command = {
id: RemoveRowCommand.id,
params: {
- ranges: [
- {
- startRow: 0,
- startColumn: 0,
- endRow: 0,
- endColumn: 19,
- rangeType: 1,
- },
- ],
- },
+ range: {
+ startRow: 0,
+ startColumn: 0,
+ endRow: 0,
+ endColumn: 19,
+ rangeType: 1,
+ },
+ } as IRemoveRowColCommandParams,
};
const newFormulaData = offsetFormula(formulaData, command, unitId, sheetId);
expect(newFormulaData).toStrictEqual({
@@ -520,16 +525,14 @@ describe('utils test', () => {
const command = {
id: RemoveColCommand.id,
params: {
- ranges: [
- {
- startRow: 0,
- startColumn: 0,
- endRow: 999,
- endColumn: 0,
- rangeType: 2,
- },
- ],
- },
+ range: {
+ startRow: 0,
+ startColumn: 0,
+ endRow: 999,
+ endColumn: 0,
+ rangeType: 2,
+ },
+ } as IRemoveRowColCommandParams,
};
const newFormulaData = offsetFormula(formulaData, command, unitId, sheetId);
expect(newFormulaData).toStrictEqual({
@@ -570,16 +573,14 @@ describe('utils test', () => {
const command = {
id: DeleteRangeMoveUpCommand.id,
params: {
- ranges: [
- {
- startRow: 0,
- startColumn: 3,
- endRow: 0,
- endColumn: 3,
- rangeType: 0,
- },
- ],
- },
+ range: {
+ startRow: 0,
+ startColumn: 3,
+ endRow: 0,
+ endColumn: 3,
+ rangeType: 0,
+ },
+ } as IDeleteRangeMoveUpCommandParams,
};
const newFormulaData = offsetFormula(formulaData, command, unitId, sheetId);
@@ -622,16 +623,14 @@ describe('utils test', () => {
const command = {
id: DeleteRangeMoveLeftCommand.id,
params: {
- ranges: [
- {
- startRow: 0,
- startColumn: 0,
- endRow: 0,
- endColumn: 0,
- rangeType: 0,
- },
- ],
- },
+ range: {
+ startRow: 0,
+ startColumn: 0,
+ endRow: 0,
+ endColumn: 0,
+ rangeType: 0,
+ },
+ } as IDeleteRangeMoveLeftCommandParams,
};
const newFormulaData = offsetFormula(formulaData, command, unitId, sheetId);
diff --git a/packages/sheets-formula/src/controllers/update-formula.controller.ts b/packages/sheets-formula/src/controllers/update-formula.controller.ts
index 7a9e8f1678..8e826ed531 100644
--- a/packages/sheets-formula/src/controllers/update-formula.controller.ts
+++ b/packages/sheets-formula/src/controllers/update-formula.controller.ts
@@ -355,7 +355,10 @@ export class UpdateFormulaController extends Disposable {
const { params } = command;
if (!params) return null;
- const { fromRow, toRow } = params;
+ const {
+ fromRange: { startRow: fromRow },
+ toRange: { startRow: toRow },
+ } = params;
const workbook = this._currentUniverService.getCurrentUniverSheetInstance();
const unitId = workbook.getUnitId();
@@ -390,7 +393,10 @@ export class UpdateFormulaController extends Disposable {
const { params } = command;
if (!params) return null;
- const { fromCol, toCol } = params;
+ const {
+ fromRange: { startColumn: fromCol },
+ toRange: { startColumn: toCol },
+ } = params;
const workbook = this._currentUniverService.getCurrentUniverSheetInstance();
const unitId = workbook.getUnitId();
diff --git a/packages/sheets-formula/src/controllers/utils.ts b/packages/sheets-formula/src/controllers/utils.ts
index c9766377f2..aa89d3030f 100644
--- a/packages/sheets-formula/src/controllers/utils.ts
+++ b/packages/sheets-formula/src/controllers/utils.ts
@@ -142,7 +142,10 @@ function handleMoveRows<T>(
const { params } = command;
if (!params) return;
- const { fromRow, toRow } = params;
+ const {
+ fromRange: { startRow: fromRow },
+ toRange: { startRow: toRow },
+ } = params;
const filteredSelections = selections?.filter(
(selection) =>
@@ -168,7 +171,10 @@ function handleMoveCols<T>(
const { params } = command;
if (!params) return;
- const { fromCol, toCol } = params;
+ const {
+ fromRange: { startColumn: fromCol },
+ toRange: { startColumn: toCol },
+ } = params;
const filteredSelections = selections?.filter(
(selection) =>
diff --git a/packages/sheets-numfmt/src/controllers/numfmt.ref-range.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.ref-range.controller.ts
index 350fae36d1..0752f3d9b7 100644
--- a/packages/sheets-numfmt/src/controllers/numfmt.ref-range.controller.ts
+++ b/packages/sheets-numfmt/src/controllers/numfmt.ref-range.controller.ts
@@ -27,6 +27,7 @@ import {
} from '@univerjs/core';
import type {
EffectRefRangeParams,
+ IOperator,
IRemoveNumfmtMutationParams,
ISetCellsNumfmt,
ISetNumfmtMutationParams,
@@ -43,7 +44,9 @@ import {
handleInsertRow,
handleIRemoveCol,
handleIRemoveRow,
+ handleMoveCols,
handleMoveRange,
+ handleMoveRows,
INumfmtService,
RefRangeService,
RemoveNumfmtMutation,
@@ -126,7 +129,7 @@ export class NumfmtRefRangeController extends Disposable {
endRow: row,
endColumn: col,
};
- let operators = [];
+ let operators: IOperator[] = [];
switch (commandInfo.id) {
case EffectRefRangId.DeleteRangeMoveLeftCommandId: {
operators = handleDeleteRangeMoveLeft(commandInfo, targetRange);
@@ -164,6 +167,13 @@ export class NumfmtRefRangeController extends Disposable {
operators = handleIRemoveRow(commandInfo, targetRange);
break;
}
+ case EffectRefRangId.MoveColsCommandId: {
+ operators = handleMoveCols(commandInfo, targetRange);
+ break;
+ }
+ case EffectRefRangId.MoveRowsCommandId: {
+ operators = handleMoveRows(commandInfo, targetRange);
+ }
}
const resultRange = runRefRangeMutations(operators, targetRange);
diff --git a/packages/sheets-ui/src/controllers/freeze.controller.ts b/packages/sheets-ui/src/controllers/freeze.controller.ts
index 0e2baecafd..86f0737a39 100644
--- a/packages/sheets-ui/src/controllers/freeze.controller.ts
+++ b/packages/sheets-ui/src/controllers/freeze.controller.ts
@@ -1154,7 +1154,10 @@ export class FreezeController extends Disposable {
if (command.id === MoveColsCommand.id) {
const selections = this._selectionManagerService.getSelections();
- const { fromCol, toCol } = command.params as IMoveColsCommandParams;
+ const {
+ fromRange: { startColumn: fromCol },
+ toRange: { startColumn: toCol },
+ } = command.params as IMoveColsCommandParams;
const filteredSelections = selections?.filter(
(selection) =>
selection.range.rangeType === RANGE_TYPE.COLUMN &&
@@ -1215,7 +1218,10 @@ export class FreezeController extends Disposable {
if (command.id === MoveRowsCommand.id) {
const selections = this._selectionManagerService.getSelections();
- const { fromRow, toRow } = command.params as IMoveRowsCommandParams;
+ const {
+ fromRange: { startRow: fromRow },
+ toRange: { startRow: toRow },
+ } = command.params as IMoveRowsCommandParams;
const filteredSelections = selections?.filter(
(selection) =>
selection.range.rangeType === RANGE_TYPE.ROW &&
diff --git a/packages/sheets-ui/src/controllers/header-move.controller.ts b/packages/sheets-ui/src/controllers/header-move.controller.ts
index 6c1b46e145..3ffa5850bd 100644
--- a/packages/sheets-ui/src/controllers/header-move.controller.ts
+++ b/packages/sheets-ui/src/controllers/header-move.controller.ts
@@ -292,23 +292,52 @@ export class HeaderMoveController extends Disposable {
// when multi ranges are selected, we should only move the range that contains
// `changeFromRow`
+ const selections = this._selectionManagerService.getSelections();
if (initialType === HEADER_MOVE_TYPE.ROW) {
if (this._changeFromRow !== this._changeToRow && this._changeToRow !== -1) {
- this._commandService.executeCommand<IMoveRowsCommandParams>(MoveRowsCommand.id, {
- fromRow: this._changeFromRow,
- toRow: this._changeToRow,
- });
+ const filteredSelections =
+ selections?.filter(
+ (selection) =>
+ selection.range.rangeType === RANGE_TYPE.ROW &&
+ selection.range.startRow <= this._changeFromRow &&
+ this._changeFromRow <= selection.range.endRow
+ ) || [];
+ const range = filteredSelections[0]?.range;
+ if (range) {
+ this._commandService.executeCommand<IMoveRowsCommandParams>(MoveRowsCommand.id, {
+ fromRange: range,
+ toRange: {
+ ...range,
+ startRow: this._changeToRow,
+ endRow: this._changeToRow + range.endRow - range.startRow,
+ },
+ });
+ }
}
// reset dragging status
this._changeToRow = this._changeFromRow = -1;
} else {
if (this._changeFromColumn !== this._changeToColumn && this._changeToColumn !== -1) {
- this._commandService.executeCommand<IMoveColsCommandParams>(MoveColsCommand.id, {
- fromCol: this._changeFromColumn,
- toCol: this._changeToColumn,
- });
+ const filteredSelections =
+ selections?.filter(
+ (selection) =>
+ selection.range.rangeType === RANGE_TYPE.COLUMN &&
+ selection.range.startColumn <= this._changeFromColumn &&
+ this._changeFromColumn <= selection.range.endColumn
+ ) || [];
+ const range = filteredSelections[0]?.range;
+ if (range) {
+ this._commandService.executeCommand<IMoveColsCommandParams>(MoveColsCommand.id, {
+ fromRange: range,
+ toRange: {
+ ...range,
+ startColumn: this._changeToColumn,
+ endColumn: this._changeToColumn + range.endColumn - range.startColumn,
+ },
+ });
+ }
}
this._changeToColumn = this._changeFromColumn = -1;
diff --git a/packages/sheets/src/commands/commands/__tests__/move-rows-cols.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/move-rows-cols.command.spec.ts
index b55dc23f1b..7ef6015042 100644
--- a/packages/sheets/src/commands/commands/__tests__/move-rows-cols.command.spec.ts
+++ b/packages/sheets/src/commands/commands/__tests__/move-rows-cols.command.spec.ts
@@ -27,6 +27,8 @@ import {
import type { Injector } from '@wendellhu/redi';
import { beforeEach, describe, expect, it } from 'vitest';
+import { MergeCellController } from '../../../controllers/merge-cell.controller';
+import { RefRangeService } from '../../../services/ref-range/ref-range.service';
import { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '../../../services/selection-manager.service';
import { AddWorksheetMergeMutation } from '../../mutations/add-worksheet-merge.mutation';
import { MoveColsMutation, MoveRowsMutation } from '../../mutations/move-rows-cols.mutation';
@@ -36,6 +38,9 @@ import type { IMoveColsCommandParams, IMoveRowsCommandParams } from '../move-row
import { MoveColsCommand, MoveRowsCommand } from '../move-rows-cols.command';
import { createCommandTestBed } from './create-command-test-bed';
+const cellToRange = (row: number, col: number) =>
+ ({ startRow: row, endRow: row, startColumn: col, endColumn: col }) as IRange;
+
describe('Test move rows cols', () => {
let univer: Univer;
let get: Injector['get'];
@@ -57,7 +62,7 @@ describe('Test move rows cols', () => {
AddWorksheetMergeMutation,
SetSelectionsOperation,
].forEach((c) => commandService.registerCommand(c));
-
+ get(MergeCellController);
const selectionManagerService = get(SelectionManagerService);
selectionManagerService.setCurrentSelection({
pluginName: NORMAL_SELECTION_PLUGIN_NAME,
@@ -170,8 +175,8 @@ describe('Test move rows cols', () => {
selectRow(18, 19);
const result = await commandService.executeCommand<IMoveRowsCommandParams>(MoveRowsCommand.id, {
- fromRow: 18,
- toRow: 1,
+ fromRange: { ...cellToRange(18, 1), endRow: 19 },
+ toRange: { ...cellToRange(1, 1), endRow: 2 },
});
expect(result).toEqual(true);
expect(getCellInfo(0, 0)?.v).toEqual('A1');
@@ -224,8 +229,8 @@ describe('Test move rows cols', () => {
selectRow(2, 2);
const result = await commandService.executeCommand<IMoveRowsCommandParams>(MoveRowsCommand.id, {
- fromRow: 2,
- toRow: 1,
+ fromRange: cellToRange(2, 1),
+ toRange: cellToRange(1, 1),
});
expect(result).toBeFalsy();
});
@@ -234,14 +239,14 @@ describe('Test move rows cols', () => {
selectRow(18, 19);
const result = await commandService.executeCommand<IMoveRowsCommandParams>(MoveRowsCommand.id, {
- fromRow: 18,
- toRow: 3,
+ fromRange: cellToRange(18, 1),
+ toRange: cellToRange(3, 1),
});
expect(result).toBeFalsy();
const result2 = await commandService.executeCommand<IMoveRowsCommandParams>(MoveRowsCommand.id, {
- fromRow: 18,
- toRow: 4,
+ fromRange: cellToRange(18, 1),
+ toRange: cellToRange(4, 1),
});
expect(result2).toBeTruthy();
});
@@ -252,8 +257,8 @@ describe('Test move rows cols', () => {
selectColumn(18, 19);
const result = await commandService.executeCommand<IMoveColsCommandParams>(MoveColsCommand.id, {
- fromCol: 18,
- toCol: 1,
+ fromRange: { ...cellToRange(1, 18), endColumn: 19 },
+ toRange: { ...cellToRange(1, 1), endColumn: 2 },
});
expect(result).toEqual(true);
expect(getCellInfo(0, 0)?.v).toEqual('A1');
@@ -306,8 +311,8 @@ describe('Test move rows cols', () => {
selectColumn(2, 2);
const result = await commandService.executeCommand<IMoveColsCommandParams>(MoveColsCommand.id, {
- fromCol: 2,
- toCol: 1,
+ fromRange: cellToRange(1, 2),
+ toRange: cellToRange(1, 1),
});
expect(result).toBeFalsy();
});
@@ -316,14 +321,14 @@ describe('Test move rows cols', () => {
selectColumn(18, 19);
const result = await commandService.executeCommand<IMoveColsCommandParams>(MoveColsCommand.id, {
- fromCol: 18,
- toCol: 2,
+ fromRange: cellToRange(1, 18),
+ toRange: cellToRange(1, 2),
});
expect(result).toBeFalsy();
const result2 = await commandService.executeCommand<IMoveColsCommandParams>(MoveColsCommand.id, {
- fromCol: 18,
- toCol: 3,
+ fromRange: cellToRange(1, 18),
+ toRange: cellToRange(1, 3),
});
expect(result2).toBeTruthy();
});
@@ -392,5 +397,5 @@ const TEST_ROWS_COLS_MOVE_DEMO: IWorkbookData = {
};
function createMoveRowsColsTestBed() {
- return createCommandTestBed(Tools.deepClone(TEST_ROWS_COLS_MOVE_DEMO));
+ return createCommandTestBed(Tools.deepClone(TEST_ROWS_COLS_MOVE_DEMO), [[MergeCellController], [RefRangeService]]);
}
diff --git a/packages/sheets/src/commands/commands/move-rows-cols.command.ts b/packages/sheets/src/commands/commands/move-rows-cols.command.ts
index 69630336ac..9103d23674 100644
--- a/packages/sheets/src/commands/commands/move-rows-cols.command.ts
+++ b/packages/sheets/src/commands/commands/move-rows-cols.command.ts
@@ -24,17 +24,11 @@ import {
RANGE_TYPE,
Rectangle,
sequenceExecute,
- Tools,
} from '@univerjs/core';
import type { IAccessor } from '@wendellhu/redi';
-import type {
- IAddWorksheetMergeMutationParams,
- IRemoveWorksheetMergeMutationParams,
-} from '../../basics/interfaces/mutation-interface';
import { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '../../services/selection-manager.service';
import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';
-import { AddMergeUndoMutationFactory, AddWorksheetMergeMutation } from '../mutations/add-worksheet-merge.mutation';
import type { IMoveColumnsMutationParams, IMoveRowsMutationParams } from '../mutations/move-rows-cols.mutation';
import {
MoveColsMutation,
@@ -42,30 +36,30 @@ import {
MoveRowsMutation,
MoveRowsMutationUndoFactory,
} from '../mutations/move-rows-cols.mutation';
-import {
- RemoveMergeUndoMutationFactory,
- RemoveWorksheetMergeMutation,
-} from '../mutations/remove-worksheet-merge.mutation';
import type { ISetSelectionsOperationParams } from '../operations/selection.operation';
import { SetSelectionsOperation } from '../operations/selection.operation';
import { columnAcrossMergedCell, rowAcrossMergedCell } from './utils/merged-cell-util';
import { alignToMergedCellsBorders, getPrimaryForRange } from './utils/selection-utils';
export interface IMoveRowsCommandParams {
- fromRow: number;
- toRow: number;
+ fromRange: IRange;
+ toRange: IRange;
}
+export const MoveRowsCommandId = 'sheet.command.move-rows' as const;
/**
* Command to move the selected rows (must currently selected) to the specified row.
*/
export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {
- id: 'sheet.command.move-rows',
+ id: MoveRowsCommandId,
type: CommandType.COMMAND,
handler: async (accessor: IAccessor, params: IMoveRowsCommandParams) => {
const selectionManagerService = accessor.get(SelectionManagerService);
const selections = selectionManagerService.getSelections();
- const { fromRow, toRow } = params;
+ const {
+ fromRange: { startRow: fromRow },
+ toRange: { startRow: toRow },
+ } = params;
const filteredSelections = selections?.filter(
(selection) =>
selection.range.rangeType === RANGE_TYPE.ROW &&
@@ -123,43 +117,6 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {
const movedLength = toRow - fromRow;
const moveBackward = movedLength < 0;
const count = rangeToMove.endRow - rangeToMove.startRow + 1;
- const mergedCells: IRange[] = Tools.deepClone(worksheet.getMergeData());
- for (let i = 0; i < mergedCells.length; i++) {
- const mergedCell = mergedCells[i];
- const { startRow: mergeStartRow, endRow: mergedEndRow } = mergedCell;
- if (moveBackward) {
- // merged cells between `rangeToMove` to `destination` should be moved forward
- // merged cells in the `rangeToMove` should be moved backward
- if (Rectangle.contains(rangeToMove, mergedCell)) {
- mergedCell.startRow += movedLength;
- mergedCell.endRow += movedLength;
- } else if (mergedEndRow < rangeToMove.startRow && mergeStartRow >= destinationRange.startRow) {
- mergedCell.startRow += count;
- mergedCell.endRow += count;
- }
- } else {
- // move forward
- if (Rectangle.contains(rangeToMove, mergedCell)) {
- mergedCell.startRow += movedLength;
- mergedCell.endRow += movedLength;
- } else if (rangeToMove.endRow < mergeStartRow && mergedEndRow < destinationRange.startRow) {
- mergedCell.startRow -= count;
- mergedCell.endRow -= count;
- }
- }
- }
- const removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {
- unitId,
- subUnitId,
- ranges: Tools.deepClone(worksheet.getMergeData()),
- };
- const undoRemoveMergeMutationParams = RemoveMergeUndoMutationFactory(accessor, removeMergeMutationParams);
- const addMergeParams: IAddWorksheetMergeMutationParams = {
- unitId,
- subUnitId,
- ranges: mergedCells,
- };
- const undoAddMergeParams = AddMergeUndoMutationFactory(accessor, addMergeParams);
// deal with selections
const destSelection: IRange = moveBackward
@@ -188,16 +145,12 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {
const redos = [
{ id: MoveRowsMutation.id, params: moveRowsParams },
- { id: RemoveWorksheetMergeMutation.id, params: removeMergeMutationParams },
- { id: AddWorksheetMergeMutation.id, params: addMergeParams },
{ id: SetSelectionsOperation.id, params: setSelectionsParam },
...interceptorCommands.redos,
];
const undos = [
{ id: MoveRowsMutation.id, params: undoMoveRowsParams },
- { id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams },
- { id: AddWorksheetMergeMutation.id, params: undoRemoveMergeMutationParams },
{ id: SetSelectionsOperation.id, params: undoSetSelectionsParam },
...interceptorCommands.undos,
];
@@ -219,17 +172,21 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {
};
export interface IMoveColsCommandParams {
- fromCol: number;
- toCol: number;
+ fromRange: IRange;
+ toRange: IRange;
}
+export const MoveColsCommandId = 'sheet.command.move-cols' as const;
export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {
- id: 'sheet.command.move-cols',
+ id: MoveColsCommandId,
type: CommandType.COMMAND,
handler: async (accessor: IAccessor, params: IMoveColsCommandParams) => {
const selectionManagerService = accessor.get(SelectionManagerService);
const selections = selectionManagerService.getSelections();
- const { fromCol, toCol } = params;
+ const {
+ fromRange: { startColumn: fromCol },
+ toRange: { startColumn: toCol },
+ } = params;
const filteredSelections = selections?.filter(
(selection) =>
selection.range.rangeType === RANGE_TYPE.COLUMN &&
@@ -288,45 +245,6 @@ export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {
const movedLength = toCol - fromCol;
const moveBackward = movedLength < 0;
- const mergedCells: IRange[] = Tools.deepClone(worksheet.getMergeData());
- for (let i = 0; i < mergedCells.length; i++) {
- const mergedCell = mergedCells[i];
- const { startColumn: mergeStartCol, endColumn: mergedEndCol } = mergedCell;
- if (moveBackward) {
- // merged cells between `rangeToMove` to `destination` should be moved forward
- // merged cells in the `rangeToMove` should be moved backward
- if (Rectangle.contains(rangeToMove, mergedCell)) {
- mergedCell.startColumn += movedLength;
- mergedCell.endColumn += movedLength;
- } else if (mergedEndCol < rangeToMove.startColumn && mergeStartCol >= destinationRange.startColumn) {
- mergedCell.startColumn += count;
- mergedCell.endColumn += count;
- }
- } else {
- // move forward
- if (Rectangle.contains(rangeToMove, mergedCell)) {
- mergedCell.startColumn += movedLength;
- mergedCell.endColumn += movedLength;
- } else if (rangeToMove.endColumn < mergeStartCol && mergedEndCol < destinationRange.startColumn) {
- mergedCell.startColumn -= count;
- mergedCell.endColumn -= count;
- }
- }
- }
-
- const removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {
- unitId,
- subUnitId,
- ranges: Tools.deepClone(worksheet.getMergeData()),
- };
- const undoRemoveMergeMutationParams = RemoveMergeUndoMutationFactory(accessor, removeMergeMutationParams);
- const addMergeParams: IAddWorksheetMergeMutationParams = {
- unitId,
- subUnitId,
- ranges: mergedCells,
- };
- const undoAddMergeParams = AddMergeUndoMutationFactory(accessor, addMergeParams);
-
// deal with selections
const destSelection: IRange = moveBackward
? destinationRange
@@ -354,16 +272,12 @@ export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {
const redos = [
{ id: MoveColsMutation.id, params: moveColsParams },
- { id: RemoveWorksheetMergeMutation.id, params: removeMergeMutationParams },
- { id: AddWorksheetMergeMutation.id, params: addMergeParams },
{ id: SetSelectionsOperation.id, params: setSelectionsParam },
...interceptorCommands.redos,
];
const undos = [
{ id: MoveColsMutation.id, params: undoMoveColsParams },
- { id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams },
- { id: AddWorksheetMergeMutation.id, params: undoRemoveMergeMutationParams },
{ id: SetSelectionsOperation.id, params: undoSetSelectionsParam },
...interceptorCommands.undos,
];
diff --git a/packages/sheets/src/controllers/merge-cell.controller.ts b/packages/sheets/src/controllers/merge-cell.controller.ts
index 5d80bf3978..1376dc3b7c 100644
--- a/packages/sheets/src/controllers/merge-cell.controller.ts
+++ b/packages/sheets/src/controllers/merge-cell.controller.ts
@@ -28,6 +28,7 @@ import {
} from '@univerjs/core';
import { Inject, Injector } from '@wendellhu/redi';
+import type { IMoveColsCommandParams, IMoveRowsCommandParams } from '..';
import type {
IAddWorksheetMergeMutationParams,
IRemoveColMutationParams,
@@ -61,6 +62,8 @@ import {
} from '../commands/mutations/remove-worksheet-merge.mutation';
import { RefRangeService } from '../services/ref-range/ref-range.service';
import type { EffectRefRangeParams } from '../services/ref-range/type';
+import { EffectRefRangId } from '../services/ref-range/type';
+import { handleMoveCols, handleMoveRows, runRefRangeMutations } from '../services/ref-range/util';
import { SelectionManagerService } from '../services/selection-manager.service';
import { SheetInterceptorService } from '../services/sheet-interceptor/sheet-interceptor.service';
@@ -217,6 +220,14 @@ export class MergeCellController extends Disposable {
const params = config.params as unknown as IDeleteRangeMoveLeftCommandParams;
return this._handleDeleteRangeMoveLeftCommand(params, unitId, subUnitId);
}
+ case EffectRefRangId.MoveColsCommandId: {
+ const params = config.params as unknown as IMoveColsCommandParams;
+ return this._handleMoveColsCommand(params, unitId, subUnitId);
+ }
+ case EffectRefRangId.MoveRowsCommandId: {
+ const params = config.params as unknown as IMoveRowsCommandParams;
+ return this._handleMoveRowsCommand(params, unitId, subUnitId);
+ }
}
return { redos: [], undos: [] };
};
@@ -252,6 +263,82 @@ export class MergeCellController extends Disposable {
registerRefRange(workbook.getUnitId(), sheet.getSheetId());
}
+ private _handleMoveRowsCommand(params: IMoveRowsCommandParams, unitId: string, subUnitId: string) {
+ const workbook = getWorkbook(this._univerInstanceService, unitId);
+ if (!workbook) {
+ return this._handleNull();
+ }
+ const worksheet = getWorksheet(workbook, subUnitId);
+ if (!worksheet) {
+ return this._handleNull();
+ }
+ const mergeData = [...worksheet.getMergeData()];
+
+ const removeParams: IRemoveWorksheetMergeMutationParams = { unitId, subUnitId, ranges: mergeData };
+ const addParams: IAddWorksheetMergeMutationParams = { unitId, subUnitId, ranges: [] };
+ mergeData.forEach((range) => {
+ const operation = handleMoveRows({ id: EffectRefRangId.MoveRowsCommandId, params }, range);
+ const result = runRefRangeMutations(operation, range);
+ result && addParams.ranges.push(result);
+ });
+ const removeUndo = RemoveMergeUndoMutationFactory(this._injector, removeParams);
+ const addUndo = AddMergeUndoMutationFactory(this._injector, addParams);
+ return {
+ redos: [
+ { id: RemoveWorksheetMergeMutation.id, params: removeParams },
+ {
+ id: AddWorksheetMergeMutation.id,
+ params: addParams,
+ },
+ ],
+ undos: [
+ { id: RemoveWorksheetMergeMutation.id, params: addUndo },
+ {
+ id: AddWorksheetMergeMutation.id,
+ params: removeUndo,
+ },
+ ],
+ };
+ }
+
+ private _handleMoveColsCommand(params: IMoveColsCommandParams, unitId: string, subUnitId: string) {
+ const workbook = getWorkbook(this._univerInstanceService, unitId);
+ if (!workbook) {
+ return this._handleNull();
+ }
+ const worksheet = getWorksheet(workbook, subUnitId);
+ if (!worksheet) {
+ return this._handleNull();
+ }
+ const mergeData = [...worksheet.getMergeData()];
+
+ const removeParams: IRemoveWorksheetMergeMutationParams = { unitId, subUnitId, ranges: mergeData };
+ const addParams: IAddWorksheetMergeMutationParams = { unitId, subUnitId, ranges: [] };
+ mergeData.forEach((range) => {
+ const operation = handleMoveCols({ id: EffectRefRangId.MoveColsCommandId, params }, range);
+ const result = runRefRangeMutations(operation, range);
+ result && addParams.ranges.push(result);
+ });
+ const removeUndo = RemoveMergeUndoMutationFactory(this._injector, removeParams);
+ const addUndo = AddMergeUndoMutationFactory(this._injector, addParams);
+ return {
+ redos: [
+ { id: RemoveWorksheetMergeMutation.id, params: removeParams },
+ {
+ id: AddWorksheetMergeMutation.id,
+ params: addParams,
+ },
+ ],
+ undos: [
+ { id: RemoveWorksheetMergeMutation.id, params: addUndo },
+ {
+ id: AddWorksheetMergeMutation.id,
+ params: removeUndo,
+ },
+ ],
+ };
+ }
+
private _handleMoveRangeCommand(params: IMoveRangeCommandParams, unitId: string, subUnitId: string) {
const workbook = getWorkbook(this._univerInstanceService, unitId);
if (!workbook) {
diff --git a/packages/sheets/src/index.ts b/packages/sheets/src/index.ts
index c912bf1d13..775231b7a0 100644
--- a/packages/sheets/src/index.ts
+++ b/packages/sheets/src/index.ts
@@ -254,7 +254,7 @@ export { enUS, zhCN } from './locale';
export type { FormatType, INumfmtItem, INumfmtItemWithCache } from './services/numfmt/type';
export { INumfmtService } from './services/numfmt/type';
export { RefRangeService } from './services/ref-range/ref-range.service';
-export type { EffectRefRangeParams } from './services/ref-range/type';
+export type { EffectRefRangeParams, IOperator } from './services/ref-range/type';
export { EffectRefRangId, OperatorType } from './services/ref-range/type';
export {
handleDeleteRangeMoveLeft,
@@ -265,7 +265,9 @@ export {
handleInsertRow,
handleIRemoveCol,
handleIRemoveRow,
+ handleMoveCols,
handleMoveRange,
+ handleMoveRows,
runRefRangeMutations,
} from './services/ref-range/util';
export { INTERCEPTOR_POINT } from './services/sheet-interceptor/interceptor-const';
diff --git a/packages/sheets/src/services/ref-range/__tests__/util.spec.ts b/packages/sheets/src/services/ref-range/__tests__/util.spec.ts
index a19f428a4e..870ff165b2 100644
--- a/packages/sheets/src/services/ref-range/__tests__/util.spec.ts
+++ b/packages/sheets/src/services/ref-range/__tests__/util.spec.ts
@@ -28,10 +28,155 @@ import {
handleIRemoveCol,
handleIRemoveRow,
handleMoveRange,
+ handleMoveRows,
runRefRangeMutations,
} from '../util';
describe('test ref-range move', () => {
+ describe('handleMoveRows', () => {
+ // see docs/tldr/handMoveRowsCols.tldr
+ const startCol = 0;
+ const endCol = 999;
+ let fromRange: IRange;
+ let toRange: IRange;
+ describe('fromRange is top of toRange', () => {
+ beforeEach(() => {
+ fromRange = { startRow: 5, endRow: 10, startColumn: startCol, endColumn: endCol };
+ toRange = { startRow: 15, endRow: 20, startColumn: startCol, endColumn: endCol };
+ });
+ it('1-1 1-3 1-11 1-13', () => {
+ const targetRange1_1 = { startRow: 2, endRow: 3, startColumn: startCol, endColumn: endCol };
+ const targetRange1_3 = { startRow: 25, endRow: 26, startColumn: startCol, endColumn: endCol };
+ const targetRange1_11 = { startRow: 3, endRow: 22, startColumn: startCol, endColumn: endCol };
+ const targetRange1_13 = { startRow: 16, endRow: 17, startColumn: startCol, endColumn: endCol };
+
+ const operators1_1 = handleMoveRows(
+ { id: EffectRefRangId.MoveRowsCommandId, params: { toRange, fromRange } },
+ targetRange1_3
+ );
+ const operators1_3 = handleMoveRows(
+ { id: EffectRefRangId.MoveRowsCommandId, params: { toRange, fromRange } },
+ targetRange1_1
+ );
+ const operators1_11 = handleMoveRows(
+ { id: EffectRefRangId.MoveRowsCommandId, params: { toRange, fromRange } },
+ targetRange1_11
+ );
+ const operators1_13 = handleMoveRows(
+ { id: EffectRefRangId.MoveRowsCommandId, params: { toRange, fromRange } },
+ targetRange1_13
+ );
+ expect(runRefRangeMutations(operators1_1!, targetRange1_1)).toEqual({
+ startRow: 2,
+ endRow: 3,
+ startColumn: startCol,
+ endColumn: endCol,
+ });
+ expect(runRefRangeMutations(operators1_3!, targetRange1_3)).toEqual({
+ startRow: 25,
+ endRow: 26,
+ startColumn: startCol,
+ endColumn: endCol,
+ });
+ // wait support expansion
+ // expect(runRefRangeMutations(operators1_11!, targetRange1_11)).toEqual({
+ // startRow: 3,
+ // endRow: 22,
+ // startColumn: startCol,
+ // endColumn: endCol,
+ // });
+ expect(runRefRangeMutations(operators1_13!, targetRange1_13)).toEqual({
+ startRow: 16,
+ endRow: 17,
+ startColumn: startCol,
+ endColumn: endCol,
+ });
+ });
+ it('1-2', () => {
+ const targetRange = { startRow: 12, endRow: 13, startColumn: startCol, endColumn: endCol };
+ const operators = handleMoveRows(
+ { id: EffectRefRangId.MoveRowsCommandId, params: { toRange, fromRange } },
+ targetRange
+ );
+ expect(runRefRangeMutations(operators!, targetRange)).toEqual({
+ startRow: 6,
+ endRow: 7,
+ startColumn: startCol,
+ endColumn: endCol,
+ });
+ });
+ it('1-12', () => {
+ const targetRange = { startRow: 6, endRow: 7, startColumn: startCol, endColumn: endCol };
+ const operators = handleMoveRows(
+ { id: EffectRefRangId.MoveRowsCommandId, params: { toRange, fromRange } },
+ targetRange
+ );
+ expect(runRefRangeMutations(operators!, targetRange)).toEqual({
+ startRow: 10,
+ endRow: 11,
+ startColumn: startCol,
+ endColumn: endCol,
+ });
+ });
+ });
+ describe('fromRange is bottom of toRange', () => {
+ beforeEach(() => {
+ fromRange = { startRow: 15, endRow: 20, startColumn: startCol, endColumn: endCol };
+ toRange = { startRow: 5, endRow: 10, startColumn: startCol, endColumn: endCol };
+ });
+ it('1-1 1-3 1-11 1-13', () => {
+ const targetRange1_1 = { startRow: 2, endRow: 3, startColumn: startCol, endColumn: endCol };
+ const targetRange1_3 = { startRow: 25, endRow: 26, startColumn: startCol, endColumn: endCol };
+
+ const operators1_1 = handleMoveRows(
+ { id: EffectRefRangId.MoveRowsCommandId, params: { toRange, fromRange } },
+ targetRange1_3
+ );
+ const operators1_3 = handleMoveRows(
+ { id: EffectRefRangId.MoveRowsCommandId, params: { toRange, fromRange } },
+ targetRange1_1
+ );
+ expect(runRefRangeMutations(operators1_1!, targetRange1_1)).toEqual({
+ startRow: 2,
+ endRow: 3,
+ startColumn: startCol,
+ endColumn: endCol,
+ });
+ expect(runRefRangeMutations(operators1_3!, targetRange1_3)).toEqual({
+ startRow: 25,
+ endRow: 26,
+ startColumn: startCol,
+ endColumn: endCol,
+ });
+ });
+ it('1-2', () => {
+ const targetRange = { startRow: 12, endRow: 13, startColumn: startCol, endColumn: endCol };
+ const operators = handleMoveRows(
+ { id: EffectRefRangId.MoveRowsCommandId, params: { toRange, fromRange } },
+ targetRange
+ );
+ expect(runRefRangeMutations(operators!, targetRange)).toEqual({
+ startRow: 18,
+ endRow: 19,
+ startColumn: startCol,
+ endColumn: endCol,
+ });
+ });
+ it('1-13', () => {
+ const targetRange = { startRow: 16, endRow: 17, startColumn: startCol, endColumn: endCol };
+ const operators = handleMoveRows(
+ { id: EffectRefRangId.MoveRowsCommandId, params: { toRange, fromRange } },
+ targetRange
+ );
+ expect(runRefRangeMutations(operators!, targetRange)).toEqual({
+ startRow: 6,
+ endRow: 7,
+ startColumn: startCol,
+ endColumn: endCol,
+ });
+ });
+ });
+ });
describe('handleInsertRangeMoveDown', () => {
let range: IRange;
beforeEach(() => {
diff --git a/packages/sheets/src/services/ref-range/ref-range.service.ts b/packages/sheets/src/services/ref-range/ref-range.service.ts
index 0f6d9af83c..b6d28b2fe0 100644
--- a/packages/sheets/src/services/ref-range/ref-range.service.ts
+++ b/packages/sheets/src/services/ref-range/ref-range.service.ts
@@ -76,6 +76,25 @@ export class RefRangeService extends Disposable {
const subUnitId = getsubUnitId(this._univerInstanceService);
const getEffectsCbList = () => {
switch (command.id) {
+ case EffectRefRangId.MoveColsCommandId: {
+ const params = command.params!;
+ const startColumn = Math.min(params.fromRange.startColumn, params.toRange.startColumn);
+ return this._checkRange(
+ [{ ...params.fromRange, startColumn, endColumn: workSheet.getColumnCount() - 1 }],
+ unitId,
+ subUnitId
+ );
+ }
+ case EffectRefRangId.MoveRowsCommandId: {
+ const params = command.params!;
+ const startRow = Math.min(params.fromRange.startRow, params.toRange.startRow);
+
+ return this._checkRange(
+ [{ ...params.fromRange, startRow, endRow: workSheet.getRowCount() - 1 }],
+ unitId,
+ subUnitId
+ );
+ }
case EffectRefRangId.MoveRangeCommandId: {
const params = command;
return this._checkRange(
diff --git a/packages/sheets/src/services/ref-range/type.ts b/packages/sheets/src/services/ref-range/type.ts
index 8cba26592d..e4a9d46d64 100644
--- a/packages/sheets/src/services/ref-range/type.ts
+++ b/packages/sheets/src/services/ref-range/type.ts
@@ -28,9 +28,14 @@ import type { IInsertColCommandParams, IInsertRowCommandParams } from '../../com
import { InsertColCommandId, InsertRowCommandId } from '../../commands/commands/insert-row-col.command';
import type { IMoveRangeCommandParams } from '../../commands/commands/move-range.command';
import { MoveRangeCommandId } from '../../commands/commands/move-range.command';
+import type { IMoveColsCommandParams, IMoveRowsCommandParams } from '../../commands/commands/move-rows-cols.command';
+import { MoveColsCommandId, MoveRowsCommandId } from '../../commands/commands/move-rows-cols.command';
import type { IRemoveRowColCommandParams } from '../../commands/commands/remove-row-col.command';
import { RemoveColCommandId, RemoveRowCommandId } from '../../commands/commands/remove-row-col.command';
+export type IMoveRowsCommand = ICommandInfo<IMoveRowsCommandParams> & { id: typeof MoveRowsCommandId };
+export type IMoveColsCommand = ICommandInfo<IMoveColsCommandParams> & { id: typeof MoveColsCommandId };
+
export type IMoveRangeCommand = ICommandInfo<IMoveRangeCommandParams> & { id: typeof MoveRangeCommandId };
export type IInsertRowCommand = ICommandInfo<IInsertRowCommandParams> & { id: typeof InsertRowCommandId };
export type IInsertColCommand = ICommandInfo<IInsertColCommandParams> & { id: typeof InsertColCommandId };
@@ -58,7 +63,9 @@ export type EffectRefRangeParams =
| IDeleteRangeMoveLeftCommand
| IDeleteRangeMoveUpCommand
| IInsertRangeMoveDownCommand
- | IInsertRangeMoveRightCommand;
+ | IInsertRangeMoveRightCommand
+ | IMoveColsCommand
+ | IMoveRowsCommand;
export const EffectRefRangId = {
MoveRangeCommandId,
@@ -70,6 +77,8 @@ export const EffectRefRangId = {
DeleteRangeMoveUpCommandId,
InsertRangeMoveDownCommandId,
InsertRangeMoveRightCommandId,
+ MoveColsCommandId,
+ MoveRowsCommandId,
} as const;
export enum OperatorType {
diff --git a/packages/sheets/src/services/ref-range/util.ts b/packages/sheets/src/services/ref-range/util.ts
index 440b40c26a..bf5281021a 100644
--- a/packages/sheets/src/services/ref-range/util.ts
+++ b/packages/sheets/src/services/ref-range/util.ts
@@ -26,7 +26,9 @@ import type {
IInsertRangeMoveDownCommand,
IInsertRangeMoveRightCommand,
IInsertRowCommand,
+ IMoveColsCommand,
IMoveRangeCommand,
+ IMoveRowsCommand,
IOperator,
IRemoveRowColCommand,
IVerticalMoveOperator,
@@ -34,6 +36,135 @@ import type {
import { OperatorType } from './type';
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
+interface ILine {
+ start: number;
+ end: number;
+}
+/**
+ * see docs/tldr/handMoveRowsCols.tldr
+ */
+const handleBaseMove = (fromRange: ILine, toRange: ILine, effectRange: ILine): Nullable<number> => {
+ const _effectRange = { ...effectRange };
+ const _toRange = { ...toRange };
+ const getIntersects = (line1: ILine, line2: ILine): Nullable<ILine> => {
+ const start = Math.max(line1.start, line2.start);
+ const end = Math.min(line1.end, line2.end);
+ if (end < start) {
+ return null;
+ }
+ return { start, end };
+ };
+ const getLength = (line: ILine) => line.end - line.start + 1;
+ const getRelative = (line: ILine, origin: ILine) => ({
+ start: line.start - origin.start,
+ end: line.start - origin.start + line.end - line.start,
+ });
+ const getAbsolute = (line: ILine, origin: ILine): ILine => ({
+ start: origin.start + line.start,
+ end: origin.start + line.start + line.end - line.start,
+ });
+
+ if (toRange.start > fromRange.start) {
+ const step = Math.min(fromRange.end, toRange.start) - fromRange.start + 1;
+ _toRange.start -= step;
+ _toRange.end -= step;
+ }
+ const fromRangeStep = getLength(fromRange);
+ const toRangeStep = fromRangeStep;
+ const fromRangeIntersectsEffectRange = getIntersects(fromRange, _effectRange);
+ const isFromRangeContainEffectRange =
+ fromRangeIntersectsEffectRange && getLength(fromRangeIntersectsEffectRange) <= getLength(_effectRange);
+ if (fromRange.end < _effectRange.start) {
+ _effectRange.start -= fromRangeStep;
+ _effectRange.end -= fromRangeStep;
+ } else if (fromRangeIntersectsEffectRange) {
+ const fromRangeIntersectsEffectRangeStep = getLength(fromRangeIntersectsEffectRange);
+ if (isFromRangeContainEffectRange) {
+ const relative = getRelative(_effectRange, fromRange);
+ const newLine = getAbsolute(relative, _toRange);
+ _effectRange.start = newLine.start;
+ _effectRange.end = newLine.end;
+ } else if (fromRangeIntersectsEffectRange.start > fromRange.start) {
+ _effectRange.end -= fromRangeIntersectsEffectRangeStep;
+ } else {
+ _effectRange.start -= fromRangeStep;
+ _effectRange.start -= fromRangeStep + fromRangeIntersectsEffectRangeStep;
+ }
+ }
+
+ const toRangeIntersectsEffectRange = getIntersects(_toRange, _effectRange);
+ if (_toRange.start <= _effectRange.start && !isFromRangeContainEffectRange) {
+ _effectRange.start += toRangeStep;
+ _effectRange.end += toRangeStep;
+ } else if (toRangeIntersectsEffectRange) {
+ const insertStart = _toRange.start;
+ if (getLength(toRangeIntersectsEffectRange) <= getLength(_effectRange)) {
+ return _effectRange.start - effectRange.start;
+ }
+ if (insertStart < _effectRange.start) {
+ _effectRange.start += toRangeStep;
+ _effectRange.end += toRangeStep;
+ } else if (insertStart >= _effectRange.start && insertStart <= _effectRange.end) {
+ // 1. move
+ _effectRange.end += toRangeStep;
+ _effectRange.start += toRangeStep;
+ // 2. split
+ // 3. expansion
+ }
+ }
+ return _effectRange.start - effectRange.start;
+};
+
+export const handleMoveRows = (params: IMoveRowsCommand, targetRange: IRange): IOperator[] => {
+ const { fromRange, toRange } = params.params || {};
+ if (!toRange || !fromRange) {
+ return [];
+ }
+ const step = handleBaseMove(
+ { start: fromRange.startRow, end: fromRange.endRow },
+ { start: toRange.startRow, end: toRange.endRow },
+ { start: targetRange.startRow, end: targetRange.endRow }
+ );
+ if (step === null) {
+ return [
+ {
+ type: OperatorType.Delete,
+ },
+ ];
+ }
+ return [
+ {
+ type: OperatorType.VerticalMove,
+ step: step || 0,
+ },
+ ];
+};
+
+export const handleMoveCols = (params: IMoveColsCommand, targetRange: IRange): IOperator[] => {
+ const { fromRange, toRange } = params.params || {};
+ if (!toRange || !fromRange) {
+ return [];
+ }
+ const step = handleBaseMove(
+ { start: fromRange.startColumn, end: fromRange.endColumn },
+ { start: toRange.startColumn, end: toRange.endColumn },
+ { start: targetRange.startColumn, end: targetRange.endColumn }
+ );
+ if (step === null) {
+ return [
+ {
+ type: OperatorType.Delete,
+ },
+ ];
+ }
+ return [
+ {
+ type: OperatorType.HorizontalMove,
+ step: step || 0,
+ },
+ ];
+};
+
export const handleMoveRange = (param: IMoveRangeCommand, targetRange: IRange) => {
const toRange = param.params?.toRange;
const fromRange = param.params?.fromRange;