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): input crash (#343)

Univerdb227563b4df
diff --git a/docs/object architecture design .tldr b/docs/object architecture design .tldr
new file mode 100644
index 0000000000..8d272e2ed6
--- /dev/null
+++ b/docs/object architecture design .tldr
@@ -0,0 +1,1096 @@
+{
+ "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": 21
+ },
+ "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": 1,
+ "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": -410.59663851457776,
+ "y": 372.5379325418338,
+ "lastActivityTimestamp": 1698468348822,
+ "meta": {}
+ },
+ {
+ "meta": {},
+ "id": "page:page",
+ "name": "Page 1",
+ "index": "a1",
+ "typeName": "page"
+ },
+ {
+ "x": 650.0906443061476,
+ "y": 525.0931191337122,
+ "z": 0.707046270098422,
+ "meta": {},
+ "id": "camera:page:page",
+ "typeName": "camera"
+ },
+ {
+ "editingShapeId": null,
+ "croppingShapeId": null,
+ "selectedShapeIds": [],
+ "hoveredShapeId": null,
+ "erasingShapeIds": [],
+ "hintingShapeIds": [],
+ "focusedGroupId": null,
+ "meta": {},
+ "id": "instance_page_state:page:page",
+ "pageId": "page:page",
+ "typeName": "instance_page_state"
+ },
+ {
+ "followingUserId": null,
+ "opacityForNextShape": 1,
+ "stylesForNextShape": {
+ "tldraw:arrowheadStart": "arrow",
+ "tldraw:arrowheadEnd": "none"
+ },
+ "brush": null,
+ "scribble": null,
+ "cursor": {
+ "type": "default",
+ "rotation": 0
+ },
+ "isFocusMode": false,
+ "exportBackground": true,
+ "isDebugMode": false,
+ "isToolLocked": false,
+ "screenBounds": {
+ "x": 0,
+ "y": 0,
+ "w": 1566,
+ "h": 1278
+ },
+ "zoomBrush": null,
+ "isGridMode": false,
+ "isPenMode": false,
+ "chatMessage": "",
+ "isChatting": false,
+ "highlightedUserIds": [],
+ "canMoveCamera": true,
+ "isFocused": false,
+ "devicePixelRatio": 1.5,
+ "isCoarsePointer": false,
+ "isHoveringCanvas": true,
+ "openMenus": [],
+ "isChangingStyle": false,
+ "isReadonly": false,
+ "meta": {},
+ "id": "instance:instance",
+ "currentPageId": "page:page",
+ "typeName": "instance"
+ },
+ {
+ "x": -31.789487122467563,
+ "y": -194.64489847046013,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 666,
+ "h": 324.52244221867863,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "core bussinese plugin\nbase-doc base-sheet base-slide",
+ "align": "middle",
+ "verticalAlign": "start",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a1",
+ "id": "shape:WxAbqMewUaC0iJqDW10wb",
+ "typeName": "shape"
+ },
+ {
+ "x": 712.8403565995236,
+ "y": 159.48468988427305,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 562,
+ "h": 817.0938720703127,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "common-plugin-image",
+ "align": "middle",
+ "verticalAlign": "start",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a2",
+ "id": "shape:J768s645VaJxx4saUFaa1",
+ "typeName": "shape"
+ },
+ {
+ "x": 31.441960314613425,
+ "y": -103.19309319221247,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 548.9240558569692,
+ "h": 91.39583587646484,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "Sheet/doc/slide\n-Object-mutation",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a3",
+ "id": "shape:20Cd2pI4zhREQfQvSh8B7",
+ "typeName": "shape"
+ },
+ {
+ "x": -469.05581615808006,
+ "y": 44.752682387448544,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 258.0000305175781,
+ "h": 131.23928340081693,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "Univer",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a4",
+ "id": "shape:4jsLQFkWIctYo4BhaIvER",
+ "typeName": "shape"
+ },
+ {
+ "x": 854.7934362022124,
+ "y": 408.4836293145796,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 261.3333740234375,
+ "h": 91.39583587646484,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "image-canvas-view\n(initialize)",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a5",
+ "id": "shape:Ox0Z2p3IoS-qkQ2iAMlhG",
+ "typeName": "shape"
+ },
+ {
+ "x": 1020.9328150357676,
+ "y": 534.1025831941336,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 220,
+ "h": 91.39583587646484,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "image.Model\n(other attibute)",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a6",
+ "id": "shape:ru-Q7ve2cKuXU1-kkuxzU",
+ "typeName": "shape"
+ },
+ {
+ "x": 798.1739137284299,
+ "y": 238.15104120263243,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 361.3333740234375,
+ "h": 83.69791793823242,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "image-transform.controller",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "a7",
+ "id": "shape:DBIUd-XyMO5Imw4RuD-ly",
+ "typeName": "shape"
+ },
+ {
+ "x": 963.5071656815549,
+ "y": 536.1511327553669,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "a8",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:DBIUd-XyMO5Imw4RuD-ly",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:Ox0Z2p3IoS-qkQ2iAMlhG",
+ "normalizedAnchor": {
+ "x": 0.49234623930853405,
+ "y": 0.6856633889661741
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "update",
+ "font": "draw"
+ },
+ "id": "shape:JtlFlne6CpOg-KeD9huRo",
+ "typeName": "shape"
+ },
+ {
+ "x": 813.5071046463986,
+ "y": 483.4844762612262,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "a9",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:DBIUd-XyMO5Imw4RuD-ly",
+ "normalizedAnchor": {
+ "x": 0.12546135309520842,
+ "y": 0.17280700145982122
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:WxAbqMewUaC0iJqDW10wb",
+ "normalizedAnchor": {
+ "x": 0.5675674301009994,
+ "y": 0.8517715869703985
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "call",
+ "font": "draw"
+ },
+ "id": "shape:b9bhznch5mAxKZGlF94O7",
+ "typeName": "shape"
+ },
+ {
+ "x": 726.8405397049924,
+ "y": 695.4842931557575,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 223.3333740234375,
+ "h": 253.15621948242188,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "controllers\n\nimage-cut\nimage-style\nimage-editor\nimage-animation",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aA",
+ "id": "shape:ma9uM4Swwai29NlvzremC",
+ "typeName": "shape"
+ },
+ {
+ "x": 757.5071656815549,
+ "y": 702.8178197670857,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "aB",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": -63.98329339262261,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:ma9uM4Swwai29NlvzremC",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:Ox0Z2p3IoS-qkQ2iAMlhG",
+ "normalizedAnchor": {
+ "x": 0.1326524177625356,
+ "y": 0.6346032179313966
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "update",
+ "font": "draw"
+ },
+ "id": "shape:lCKPn7D5ogBpV81VvGWmo",
+ "typeName": "shape"
+ },
+ {
+ "x": 929.5071656815549,
+ "y": 603.4844457436482,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "aC",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": -72.75121872185699,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:ma9uM4Swwai29NlvzremC",
+ "normalizedAnchor": {
+ "x": 0.817453085633953,
+ "y": 0.2536916814761041
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:ru-Q7ve2cKuXU1-kkuxzU",
+ "normalizedAnchor": {
+ "x": 0.1330830741796469,
+ "y": 0.3530872499564307
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "listener",
+ "font": "draw"
+ },
+ "id": "shape:uKNPS-iQ4T-FTqON6Tr2W",
+ "typeName": "shape"
+ },
+ {
+ "x": -464.45628094570975,
+ "y": -156.64502054077263,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 258.0000305175781,
+ "h": 162,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "UI",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aD",
+ "id": "shape:4QxyZV9zgA-z1pUzGM3QA",
+ "typeName": "shape"
+ },
+ {
+ "x": -247.1228916634832,
+ "y": -89.97845559936638,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "aE",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:4QxyZV9zgA-z1pUzGM3QA",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:WxAbqMewUaC0iJqDW10wb",
+ "normalizedAnchor": {
+ "x": 0.022021915103580144,
+ "y": 0.5239415739948216
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "call",
+ "font": "draw"
+ },
+ "id": "shape:RoAEIqDWAJ_Ve950fw-7-",
+ "typeName": "shape"
+ },
+ {
+ "x": 1041.5073487870236,
+ "y": 696.1511022377888,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 223.3333740234375,
+ "h": 248.55216979980466,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "commands\nmutations\n\nimage-cut\nimage-style\nimage-editor\nimage-animation",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aF",
+ "id": "shape:IEUl70iWiJTsQ3WY3ke6n",
+ "typeName": "shape"
+ },
+ {
+ "x": 923.5071656815549,
+ "y": 828.1511327553669,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "aG",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:ma9uM4Swwai29NlvzremC",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:IEUl70iWiJTsQ3WY3ke6n",
+ "normalizedAnchor": {
+ "x": 0.18208851699355086,
+ "y": 0.5069361963495255
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "call",
+ "font": "draw"
+ },
+ "id": "shape:jTG_qcFKJHdTBYfQRSUNf",
+ "typeName": "shape"
+ },
+ {
+ "x": 1166.8405397049924,
+ "y": 710.1511327553669,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "aH",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:IEUl70iWiJTsQ3WY3ke6n",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:ru-Q7ve2cKuXU1-kkuxzU",
+ "normalizedAnchor": {
+ "x": 0.5666656494140625,
+ "y": 0.7950775641756059
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "update",
+ "font": "draw"
+ },
+ "id": "shape:D0KKe0zKwz3Aiij3pgwcQ",
+ "typeName": "shape"
+ },
+ {
+ "x": -244.6117585671821,
+ "y": 286.3290541574055,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 487.2859795869851,
+ "h": 456.21253777103925,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "Render",
+ "align": "middle",
+ "verticalAlign": "start",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aI",
+ "id": "shape:ZlgbbpRFMAiNz-n4CzVOj",
+ "typeName": "shape"
+ },
+ {
+ "x": -185.00506487181798,
+ "y": 561.4947001838739,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 355.2618930613943,
+ "h": 97.29415061941036,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "imageObject",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aJ",
+ "id": "shape:bzni4TnDurRet4YB0lZh6",
+ "typeName": "shape"
+ },
+ {
+ "x": -648.6957826703153,
+ "y": 1193.1249404247367,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "aK",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 45.283375288481864,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:bzni4TnDurRet4YB0lZh6",
+ "normalizedAnchor": {
+ "x": 0.8855655132960593,
+ "y": 0.7037818542735483
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:Ox0Z2p3IoS-qkQ2iAMlhG",
+ "normalizedAnchor": {
+ "x": 0.037159696717694646,
+ "y": 0.3092472431150634
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "arrow",
+ "arrowheadEnd": "none",
+ "text": "add scene",
+ "font": "draw"
+ },
+ "id": "shape:PPsYZ3OGM20QEHowAqnb7",
+ "typeName": "shape"
+ },
+ {
+ "x": 335.3041562945284,
+ "y": 975.7917495067675,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "aL",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": -23.51018579829972,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:bzni4TnDurRet4YB0lZh6",
+ "normalizedAnchor": {
+ "x": 0.7996492813499693,
+ "y": 0.14417749848965208
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:DBIUd-XyMO5Imw4RuD-ly",
+ "normalizedAnchor": {
+ "x": 0.1972804581014258,
+ "y": 0.8110224474495177
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "arrow",
+ "arrowheadEnd": "none",
+ "text": "user interface \ntransform observer",
+ "font": "draw"
+ },
+ "id": "shape:9A_QRFjw0We_Ta4_Vncju",
+ "typeName": "shape"
+ },
+ {
+ "x": 666.722503169799,
+ "y": -219.2451879311481,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 717,
+ "h": 285.26318869851707,
+ "geo": "rectangle",
+ "color": "yellow",
+ "labelColor": "black",
+ "fill": "solid",
+ "dash": "dotted",
+ "size": "m",
+ "font": "sans",
+ "text": " Floating elements in spreadsheets need to stay synchronized with the grid layout, and inserting rows and columns will change their position; \n Floating elements in documents need to stay synchronized with the text layout and can affect the text layout;\n Floating elements in slides are more flexible but support settings such as animations.",
+ "align": "start",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aM",
+ "id": "shape:OJtCzCz_Hj_Pg5fpCdrWB",
+ "typeName": "shape"
+ },
+ {
+ "x": -212.96919241332915,
+ "y": 334.668761279083,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 428.2377180569433,
+ "h": 150.7916717529297,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "object-manager.service\n(manage all position rotation size)",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aN",
+ "id": "shape:bmzEx-2X8uPg82dBiF9tr",
+ "typeName": "shape"
+ },
+ {
+ "x": 538.2560160939761,
+ "y": -156.42187969153463,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "aO",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 52.747039992516115,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:DBIUd-XyMO5Imw4RuD-ly",
+ "normalizedAnchor": {
+ "x": 0.06448345886770626,
+ "y": 0.24134969181870905
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:bmzEx-2X8uPg82dBiF9tr",
+ "normalizedAnchor": {
+ "x": 0.8787197660788061,
+ "y": 0.23284391634849327
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "listener",
+ "font": "draw"
+ },
+ "id": "shape:gh7_n3Nz0THtu0JqswG0B",
+ "typeName": "shape"
+ },
+ {
+ "x": -369.0406672276244,
+ "y": -181.88475051697094,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "aP",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:4jsLQFkWIctYo4BhaIvER",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:bmzEx-2X8uPg82dBiF9tr",
+ "normalizedAnchor": {
+ "x": 0.29304051661229397,
+ "y": 0.4081776916092556
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "initalize snapshot",
+ "font": "draw"
+ },
+ "id": "shape:3kiHnzlNLN5uNnVexyrZ9",
+ "typeName": "shape"
+ },
+ {
+ "x": -246.60687993057854,
+ "y": -485.62579972604715,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:page",
+ "index": "aQ",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 48.52021104858354,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:WxAbqMewUaC0iJqDW10wb",
+ "normalizedAnchor": {
+ "x": 0.4326245507495111,
+ "y": 0.9236222732260428
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:bmzEx-2X8uPg82dBiF9tr",
+ "normalizedAnchor": {
+ "x": 0.7649860483904719,
+ "y": 0.4692152173896646
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "convert to actual postion or size",
+ "font": "draw"
+ },
+ "id": "shape:omX80WogVaqzRwKM0F8mO",
+ "typeName": "shape"
+ },
+ {
+ "x": 27.736403675957717,
+ "y": 11.679219148423272,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 548.9240558569692,
+ "h": 91.39583587646484,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "Sheet/doc/slide\n-Object-controller",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:page",
+ "index": "aR",
+ "id": "shape:Xeb45uyVU9_dUz_CHB6M8",
+ "typeName": "shape"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/docs/selection architecture design.tldr b/docs/selection architecture design.tldr
new file mode 100644
index 0000000000..fe260171ed
--- /dev/null
+++ b/docs/selection architecture design.tldr
@@ -0,0 +1,1340 @@
+{
+ "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": 21
+ },
+ "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": 1,
+ "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"
+ },
+ {
+ "meta": {},
+ "id": "page:m5j4HHFgvoTjk70taDp3z",
+ "name": "Page 1",
+ "index": "a1",
+ "typeName": "page"
+ },
+ {
+ "id": "pointer:pointer",
+ "typeName": "pointer",
+ "x": 842.4583548598578,
+ "y": -280.40478871472527,
+ "lastActivityTimestamp": 1698485989925,
+ "meta": {}
+ },
+ {
+ "followingUserId": null,
+ "opacityForNextShape": 1,
+ "stylesForNextShape": {
+ "tldraw:size": "m"
+ },
+ "brush": null,
+ "scribble": null,
+ "cursor": {
+ "type": "default",
+ "rotation": 0
+ },
+ "isFocusMode": false,
+ "exportBackground": true,
+ "isDebugMode": false,
+ "isToolLocked": false,
+ "screenBounds": {
+ "x": 0,
+ "y": 0,
+ "w": 1380,
+ "h": 1278
+ },
+ "zoomBrush": null,
+ "isGridMode": false,
+ "isPenMode": false,
+ "chatMessage": "",
+ "isChatting": false,
+ "highlightedUserIds": [],
+ "canMoveCamera": true,
+ "isFocused": true,
+ "devicePixelRatio": 1.5,
+ "isCoarsePointer": false,
+ "isHoveringCanvas": true,
+ "openMenus": [],
+ "isChangingStyle": false,
+ "isReadonly": false,
+ "meta": {},
+ "id": "instance:instance",
+ "currentPageId": "page:m5j4HHFgvoTjk70taDp3z",
+ "typeName": "instance"
+ },
+ {
+ "editingShapeId": null,
+ "croppingShapeId": null,
+ "selectedShapeIds": [],
+ "hoveredShapeId": null,
+ "erasingShapeIds": [],
+ "hintingShapeIds": [],
+ "focusedGroupId": null,
+ "meta": {},
+ "id": "instance_page_state:page:m5j4HHFgvoTjk70taDp3z",
+ "pageId": "page:m5j4HHFgvoTjk70taDp3z",
+ "typeName": "instance_page_state"
+ },
+ {
+ "x": 301.52647227164124,
+ "y": 673.3562070188598,
+ "z": 0.4970928578114363,
+ "meta": {},
+ "id": "camera:page:m5j4HHFgvoTjk70taDp3z",
+ "typeName": "camera"
+ },
+ {
+ "x": -44.02931054707142,
+ "y": -91.13014975058138,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 1090.6704114237873,
+ "h": 1407.5062930688746,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "semi",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "Zy",
+ "id": "shape:1yPiyJH20q6kjnPta3tGW",
+ "typeName": "shape"
+ },
+ {
+ "x": 41.927067659030854,
+ "y": 259.340727647408,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 398.58418817251396,
+ "h": 106.66668701171874,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "solid",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "spreadsheet",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aA",
+ "id": "shape:6W3IkxKUKdbm_P_q6RR1I",
+ "typeName": "shape"
+ },
+ {
+ "x": 1550.4723816911571,
+ "y": -80.41208720465238,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "xl",
+ "w": 269.2708435058594,
+ "text": "Base-sheets",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "a9",
+ "id": "shape:AX-L8X3q1b8dlQ49A049o",
+ "typeName": "shape"
+ },
+ {
+ "x": 12.238709367267461,
+ "y": 133.51863774421957,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 462.2020987977213,
+ "h": 683.4690766802684,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "solid",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "Zz",
+ "id": "shape:A__ynWGGk2Nesmx4nTqcj",
+ "typeName": "shape"
+ },
+ {
+ "x": 198.9634463714325,
+ "y": 724.8510969659656,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aY",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "semi",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:SRnxGERDNUtjvhIpW9R9v",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:Z-DZmYlF3BKS4wfi8GCdi",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:DdvhCwXKe0epJUW_tvEzZ",
+ "typeName": "shape"
+ },
+ {
+ "x": 145.24802537853896,
+ "y": 169.34042743585593,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "m",
+ "w": 203.640625,
+ "text": "sheetComponent",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aE",
+ "id": "shape:IIZY_l5g8wgDNuPyp0ae6",
+ "typeName": "shape"
+ },
+ {
+ "x": 204.6183717603398,
+ "y": 433.6224394372372,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aXV",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "semi",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:Z-DZmYlF3BKS4wfi8GCdi",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:fmfOCLCRaA83mhkB8aQxL",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:OPr-mJ_jBHI3vyOvqFZ2C",
+ "typeName": "shape"
+ },
+ {
+ "x": 197.71003138382923,
+ "y": 419.7646815998704,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aXG",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "semi",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:Z-DZmYlF3BKS4wfi8GCdi",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:uKVm2kDEsfUW3ycYVlxYw",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:RgiSpmlFc21Yi5dbDoqV_",
+ "typeName": "shape"
+ },
+ {
+ "x": -1.9472538827207018,
+ "y": 898.4981897343866,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 388.7761204873801,
+ "h": 74.92776140302234,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "semi",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "engine and canvas",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aS",
+ "id": "shape:Rptnh0tNygvGbrqdhAVas",
+ "typeName": "shape"
+ },
+ {
+ "x": 1158.5502247908628,
+ "y": 608.9066199058,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 437.38613012339334,
+ "h": 106.66668701171874,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "solid",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "selection-render.service",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aW",
+ "id": "shape:SRnxGERDNUtjvhIpW9R9v",
+ "typeName": "shape"
+ },
+ {
+ "x": 347.7985766909039,
+ "y": -79.5445385152297,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "xl",
+ "w": 328.8020935058594,
+ "text": "Render Engine",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "a4",
+ "id": "shape:SSJl5HHnY7UG5KZSu43U2",
+ "typeName": "shape"
+ },
+ {
+ "x": 553.9703308849921,
+ "y": 209.1187108630716,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aPV",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "semi",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:A__ynWGGk2Nesmx4nTqcj",
+ "normalizedAnchor": {
+ "x": 0.929095284132791,
+ "y": 0.8532365653183067
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:uKVm2kDEsfUW3ycYVlxYw",
+ "normalizedAnchor": {
+ "x": 0.666164212849653,
+ "y": 0.5142921981597529
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:Sow1CkEYEm4aGNY9WK5Dp",
+ "typeName": "shape"
+ },
+ {
+ "x": 1717.009182299657,
+ "y": 200.5181066601359,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 446,
+ "h": 106.66668701171874,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "selection.operation\n(Command that does not require collaboration)",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 14.427062988281264,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aK",
+ "id": "shape:Tz-yklI84G42rV0f1UIpZ",
+ "typeName": "shape"
+ },
+ {
+ "x": -4.77471657717399,
+ "y": 1028.5614736792556,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 395.84477722351437,
+ "h": 91.89253756974438,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "semi",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "scene",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aR",
+ "id": "shape:X5xpjOaj3j_XUs7vkRagY",
+ "typeName": "shape"
+ },
+ {
+ "x": 37.68587361735047,
+ "y": 540.6732657455484,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 398.58418817251396,
+ "h": 106.66668701171874,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "solid",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "columnTitle",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aC",
+ "id": "shape:XNmg0I_qN87Zr1EOmmNdb",
+ "typeName": "shape"
+ },
+ {
+ "x": 1179.852259951592,
+ "y": 1015.7981142229353,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 398.58418817251396,
+ "h": 106.66668701171874,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "solid",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "selection-shape",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aX",
+ "id": "shape:Z-DZmYlF3BKS4wfi8GCdi",
+ "typeName": "shape"
+ },
+ {
+ "x": 360.12881995529193,
+ "y": 744.6433358271413,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aWV",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "semi",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:SRnxGERDNUtjvhIpW9R9v",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:hhTFKdv-e84RT9eJIi7OX",
+ "normalizedAnchor": {
+ "x": 0.8466186408151378,
+ "y": 0.4725979457378775
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:aZtG24KLR4Qnjn-s6VeHp",
+ "typeName": "shape"
+ },
+ {
+ "x": -117.5520590477555,
+ "y": -11.423379304315063,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aRV",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "semi",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 27.82457991188302,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:X5xpjOaj3j_XUs7vkRagY",
+ "normalizedAnchor": {
+ "x": 0.8464285714285714,
+ "y": 0.3615384615384618
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:uKVm2kDEsfUW3ycYVlxYw",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:b9KcRnra4KJHt8V144o-q",
+ "typeName": "shape"
+ },
+ {
+ "x": 39.099604964577225,
+ "y": 396.47266832841115,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 398.58418817251396,
+ "h": 106.66668701171874,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "solid",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "rowTitle",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aB",
+ "id": "shape:dr5gqreK1gOzrCr0s9wHs",
+ "typeName": "shape"
+ },
+ {
+ "x": 2124.4397287017873,
+ "y": 638.6134847851284,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aL",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "semi",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:kr811EWPL7oNIa1Xd9tNE",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:Tz-yklI84G42rV0f1UIpZ",
+ "normalizedAnchor": {
+ "x": 0.5637134332041507,
+ "y": 0.43649343283130326
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:fLilm68-7615050GR1tn9",
+ "typeName": "shape"
+ },
+ {
+ "x": 1765.3777064841809,
+ "y": 1016.9515693637318,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 398.58418817251396,
+ "h": 106.66668701171874,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "solid",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "selection-render-model",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "a2",
+ "id": "shape:fmfOCLCRaA83mhkB8aQxL",
+ "typeName": "shape"
+ },
+ {
+ "x": 613.00686662937,
+ "y": 539.0871929963505,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 338,
+ "h": 249.530955317578,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "semi",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "sheetSkeleton",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aN",
+ "id": "shape:hhTFKdv-e84RT9eJIi7OX",
+ "typeName": "shape"
+ },
+ {
+ "x": 766.0165716183835,
+ "y": 187.912740654669,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aO",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "semi",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:A__ynWGGk2Nesmx4nTqcj",
+ "normalizedAnchor": {
+ "x": 0.8981490675612426,
+ "y": 0.7762164830743573
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:hhTFKdv-e84RT9eJIi7OX",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:kcW7xXBl2US4dgdD0R-oQ",
+ "typeName": "shape"
+ },
+ {
+ "x": 1915.207489312215,
+ "y": 411.0027378816077,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aM",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "semi",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:Tz-yklI84G42rV0f1UIpZ",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:m1vXOoevi8r9rRMvn1Ao5",
+ "normalizedAnchor": {
+ "x": 0.8004321371159255,
+ "y": 0.4735295965801327
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:kgCuD4cHw0LL-zmCP9kp9",
+ "typeName": "shape"
+ },
+ {
+ "x": 1743.2810413985878,
+ "y": 603.9890919257937,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 445.33349609374994,
+ "h": 106.66668701171874,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "selection.controller",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aJ",
+ "id": "shape:kr811EWPL7oNIa1Xd9tNE",
+ "typeName": "shape"
+ },
+ {
+ "x": 86.025254952909,
+ "y": -305.4794995274972,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aT",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "semi",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:Rptnh0tNygvGbrqdhAVas",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:X5xpjOaj3j_XUs7vkRagY",
+ "normalizedAnchor": {
+ "x": 0.49797543221110097,
+ "y": 0.2079185520361982
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:luAt1wAIJTHfqXRaqUbQq",
+ "typeName": "shape"
+ },
+ {
+ "x": 1139.7166484179857,
+ "y": 197.0839049259764,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 445.33349609374994,
+ "h": 106.66668701171874,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "solid",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "selection.manager.service\n(Manage the selection data)",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "a6",
+ "id": "shape:m1vXOoevi8r9rRMvn1Ao5",
+ "typeName": "shape"
+ },
+ {
+ "x": 41.92706765903097,
+ "y": 679.2189377737784,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 398.58418817251396,
+ "h": 106.66668701171874,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "solid",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "leftTop",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aD",
+ "id": "shape:pLSExtO7CTIch5SDgRfkD",
+ "typeName": "shape"
+ },
+ {
+ "x": 539.3381172705998,
+ "y": 988.8979131377703,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 442.0624566038375,
+ "h": 149.85552280604475,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "semi",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "BaseObejct\n(Provide a drawing method, draw)",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aP",
+ "id": "shape:uKVm2kDEsfUW3ycYVlxYw",
+ "typeName": "shape"
+ },
+ {
+ "x": 1951.9645043401129,
+ "y": 676.7842311602531,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aJV",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "semi",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:kr811EWPL7oNIa1Xd9tNE",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:m1vXOoevi8r9rRMvn1Ao5",
+ "normalizedAnchor": {
+ "x": 0.8917828791344565,
+ "y": 0.7495968758025121
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:ub5jHrOlnIxwnHACcejiD",
+ "typeName": "shape"
+ },
+ {
+ "x": 1095.0280291777353,
+ "y": -92.14033326226115,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 1122.0896116690722,
+ "h": 1399.199773165109,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "semi",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "Zx",
+ "id": "shape:uh9EfpNJLs7tEeDlwsZmy",
+ "typeName": "shape"
+ },
+ {
+ "x": 2049.9190434417415,
+ "y": 772.4208493460044,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aWG",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:kr811EWPL7oNIa1Xd9tNE",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:SRnxGERDNUtjvhIpW9R9v",
+ "normalizedAnchor": {
+ "x": 0.5779078031014979,
+ "y": 0.4321664030694113
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:y6mvvQU05kDgH5YxT0HQi",
+ "typeName": "shape"
+ },
+ {
+ "x": 1445.8345876309388,
+ "y": -9.620779572888523,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "xl",
+ "w": 504.625,
+ "text": "(core bussiness plugin)",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aZ",
+ "id": "shape:jMLDBXv0CgIaMXJS8d4Gp",
+ "typeName": "shape"
+ },
+ {
+ "x": 1142.8042943788116,
+ "y": 411.0982570989007,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "geo",
+ "props": {
+ "w": 446,
+ "h": 106.66668701171874,
+ "geo": "rectangle",
+ "color": "black",
+ "labelColor": "black",
+ "fill": "none",
+ "dash": "draw",
+ "size": "m",
+ "font": "draw",
+ "text": "Other feature plugins or controller that rely on selection",
+ "align": "middle",
+ "verticalAlign": "middle",
+ "growY": 0,
+ "url": ""
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "aa",
+ "id": "shape:qQY8O2gF0Gra_RM4TXqL_",
+ "typeName": "shape"
+ },
+ {
+ "x": 1363.2902108596315,
+ "y": 434.33306839170336,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "arrow",
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "ab",
+ "props": {
+ "dash": "draw",
+ "size": "m",
+ "fill": "none",
+ "color": "black",
+ "labelColor": "black",
+ "bend": 0,
+ "start": {
+ "type": "binding",
+ "boundShapeId": "shape:qQY8O2gF0Gra_RM4TXqL_",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "end": {
+ "type": "binding",
+ "boundShapeId": "shape:m1vXOoevi8r9rRMvn1Ao5",
+ "normalizedAnchor": {
+ "x": 0.5,
+ "y": 0.5
+ },
+ "isExact": false
+ },
+ "arrowheadStart": "none",
+ "arrowheadEnd": "arrow",
+ "text": "",
+ "font": "draw"
+ },
+ "id": "shape:_YkG5yLPD-oZHtlWQ1usd",
+ "typeName": "shape"
+ },
+ {
+ "x": 98.59411301674407,
+ "y": -5.326484465262752,
+ "rotation": 0,
+ "isLocked": false,
+ "opacity": 1,
+ "meta": {},
+ "type": "text",
+ "props": {
+ "color": "black",
+ "size": "m",
+ "w": 849.3541870117188,
+ "text": "https://www.processon.com/diagraming/63adf093950a3501fbed27cb",
+ "font": "draw",
+ "align": "middle",
+ "autoSize": true,
+ "scale": 1
+ },
+ "parentId": "page:m5j4HHFgvoTjk70taDp3z",
+ "index": "ac",
+ "id": "shape:3-BPR_WDcVAPcWXf5Et-D",
+ "typeName": "shape"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/base-docs/src/commands/mutations/core-editing.mutation.ts b/packages/base-docs/src/commands/mutations/core-editing.mutation.ts
index aad0e48978..5692f74f72 100644
--- a/packages/base-docs/src/commands/mutations/core-editing.mutation.ts
+++ b/packages/base-docs/src/commands/mutations/core-editing.mutation.ts
@@ -1,8 +1,8 @@
import { CommandType, IDocumentBody, IMutation, IUniverInstanceService, UpdateDocsAttributeType } from '@univerjs/core';
import { DeleteApply } from './functions/delete-apply';
-import { InsertApply } from './functions/insert';
-import { UpdateAttributeApply } from './functions/update';
+import { InsertApply } from './functions/insert-apply';
+import { UpdateAttributeApply } from './functions/update-apply';
/**
* Retain mutation is used to move the cursor or to update properties of the text in the given range.
diff --git a/packages/base-docs/src/commands/mutations/functions/common.ts b/packages/base-docs/src/commands/mutations/functions/common.ts
index 00d80d5977..252e5edc2f 100644
--- a/packages/base-docs/src/commands/mutations/functions/common.ts
+++ b/packages/base-docs/src/commands/mutations/functions/common.ts
@@ -43,7 +43,7 @@ export function insertTextRuns(
if (insertIndex === Infinity) {
insertIndex = -Infinity;
}
- } else if (ed >= currentIndex - 1) {
+ } else if (ed >= currentIndex) {
/**
* Inserting text at the end of a rich text content,
* with the newly inserted text inheriting the style of that content.
@@ -72,7 +72,7 @@ export function insertTextRuns(
const startSplitTextRun = {
...splitTextRun,
st,
- ed: insertTextRuns[0].st - 1,
+ ed: insertTextRuns[0].st,
};
if (isSameStyleTextRun(startSplitTextRun, insertTextRuns[0])) {
@@ -81,9 +81,15 @@ export function insertTextRuns(
}
const lastInsertTextRuns = insertTextRuns[insertTextRuns.length - 1];
+
+ if (lastInsertTextRuns.ed === ed) {
+ textRuns.splice(insertIndex, 1, startSplitTextRun, ...insertTextRuns);
+ return;
+ }
+
const endSplitTextRun = {
...splitTextRun,
- st: lastInsertTextRuns.ed + 1,
+ st: lastInsertTextRuns.ed,
ed,
};
@@ -318,34 +324,54 @@ export function deleteTextRuns(body: IDocumentBody, textLength: number, currentI
const textRun = textRuns[i];
const { st, ed } = textRun;
- if (startIndex <= st && endIndex >= ed) {
+ if (startIndex <= st - 1 && endIndex >= ed - 1) {
+ /**
+ * If the selection range is larger than the current textRuns, it needs to be deleted.
+ */
removeTextRuns.push({
...textRun,
- st: st - currentIndex,
- ed: ed - currentIndex,
+ st: st - startIndex,
+ ed: ed - startIndex,
});
continue;
- } else if (st <= startIndex && ed >= endIndex) {
+ } else if (st - 1 < startIndex && ed - 1 >= endIndex) {
+ /**
+ * If the selection range is smaller than the current textRun,
+ * it needs to be trimmed. After trimming, the two segments of textRun should be merged.
+ */
const segments = horizontalLineSegmentsSubtraction(st, ed, startIndex, endIndex);
textRun.st = segments[0];
textRun.ed = segments[1];
- } else if (startIndex >= st && startIndex <= ed) {
+ } else if (startIndex > st - 1 && startIndex <= ed - 1) {
+ /**
+ * If the cursor start position is within the textRun,
+ * the content on the right side of the textRun needs to be removed,
+ * leaving the content on the left
+ */
removeTextRuns.push({
...textRun,
- st: startIndex - currentIndex,
- ed: ed - currentIndex,
+ st: startIndex - startIndex,
+ ed: ed - startIndex,
});
- textRun.ed = startIndex - 1;
- } else if (endIndex >= st && endIndex <= ed) {
+ textRun.ed = startIndex;
+ } else if (endIndex > st - 1 && endIndex <= ed - 1) {
+ /**
+ * If the cursor end position is within the textRun,
+ * the content on the left side of the textRun needs to be removed,
+ * leaving the content on the right.
+ */
removeTextRuns.push({
...textRun,
- st: st - currentIndex,
- ed: endIndex - currentIndex,
+ st: st - startIndex,
+ ed: endIndex - startIndex,
});
textRun.st = endIndex - textLength + 1;
textRun.ed -= textLength;
} else if (st > endIndex) {
+ /**
+ * TextRuns to the right of the selection content need to be moved as a whole
+ */
textRun.st -= textLength;
textRun.ed -= textLength;
}
diff --git a/packages/base-docs/src/commands/mutations/functions/delete-apply.ts b/packages/base-docs/src/commands/mutations/functions/delete-apply.ts
index 77683c4c8f..55046c5811 100644
--- a/packages/base-docs/src/commands/mutations/functions/delete-apply.ts
+++ b/packages/base-docs/src/commands/mutations/functions/delete-apply.ts
@@ -1,4 +1,13 @@
-import { deleteContent, DocumentModel, getDocsUpdateBody, IDocumentBody } from '@univerjs/core';
+import {
+ DEFAULT_EMPTY_DOCUMENT_VALUE,
+ deleteContent,
+ DocumentBodyModel,
+ DocumentModel,
+ getDocsUpdateBody,
+ IDocumentBody,
+ IParagraph,
+ Tools,
+} from '@univerjs/core';
import {
deleteCustomBlocks,
@@ -33,6 +42,8 @@ export function DeleteApply(
const deleBody = updateAttributeByDelete(body, textLength, currentIndex);
+ recoveryBody(bodyModel, body, deleBody); // If the last paragraph in the document is deleted, restore an initial blank document.
+
console.log('删除的model打印', bodyModel, body, deleBody);
return deleBody;
@@ -74,3 +85,23 @@ function updateAttributeByDelete(body: IDocumentBody, textLength: number, curren
customRanges: removeCustomRanges,
};
}
+
+function recoveryBody(bodyModel: DocumentBodyModel, body: IDocumentBody, deleBody: IDocumentBody) {
+ if (bodyModel.children[0].children.length === 0) {
+ bodyModel.reset({
+ dataStream: DEFAULT_EMPTY_DOCUMENT_VALUE,
+ });
+ }
+
+ if (body.dataStream === '\n') {
+ body.dataStream = DEFAULT_EMPTY_DOCUMENT_VALUE;
+
+ const firstParagraph = deleBody.paragraphs?.[0];
+
+ if (firstParagraph != null) {
+ const newParagraph = Tools.deepClone(firstParagraph) as IParagraph;
+ newParagraph.startIndex = 0;
+ body.paragraphs = [newParagraph];
+ }
+ }
+}
diff --git a/packages/base-docs/src/commands/mutations/functions/insert.ts b/packages/base-docs/src/commands/mutations/functions/insert-apply.ts
similarity index 100%
rename from packages/base-docs/src/commands/mutations/functions/insert.ts
rename to packages/base-docs/src/commands/mutations/functions/insert-apply.ts
diff --git a/packages/base-docs/src/commands/mutations/functions/update.ts b/packages/base-docs/src/commands/mutations/functions/update-apply.ts
similarity index 100%
rename from packages/base-docs/src/commands/mutations/functions/update.ts
rename to packages/base-docs/src/commands/mutations/functions/update-apply.ts
diff --git a/packages/base-render/src/Basics/FontCache.ts b/packages/base-render/src/Basics/FontCache.ts
index 3281cf96ed..5a63ec4849 100644
--- a/packages/base-render/src/Basics/FontCache.ts
+++ b/packages/base-render/src/Basics/FontCache.ts
@@ -1,321 +1,324 @@
-import { Nullable } from '@univerjs/core';
-
-import { DEFAULT_MEASURE_TEXT } from './Const';
-import { IDocumentSkeletonBoundingBox, IDocumentSkeletonFontStyle } from './IDocumentSkeletonCached';
-import { IMeasureTextCache } from './Interfaces';
-
-const getDefaultBaselineOffset = (fontSize: number) => ({
- sbr: 0.5,
- sbo: fontSize,
- spr: 0.5,
- spo: fontSize,
-});
-
-interface IFontData {
- notDefWidth: number;
- ascender: number;
- descender: number;
- typoAscender: number;
- typoDescender: number;
- strikeoutPosition: number;
- subscriptSizeRatio: number;
- subscriptOffset: number;
- superscriptSizeRatio: number;
- superscriptOffset: number;
- hdmxData?: number[]; // hdmxData https://docs.microsoft.com/en-us/typography/opentype/spec/recom#hdmx
- glyphHorizonMap: Map<number, IGlyphHorizonData>;
-}
-
-interface IGlyphHorizonData {
- width: number;
- lsb: number;
- pixelsPerEm?: number[];
-}
-
-export class FontCache {
- private static _getTextHeightCache: { [key: string]: { width: number; height: number } } = {};
-
- private static _context: CanvasRenderingContext2D;
-
- private static _fontDataMap: Map<string, IFontData> = new Map();
-
- // 文字缓存全局变量
- private static _globalFontMeasureCache: Map<string, Map<string, IMeasureTextCache>> = new Map();
-
- static get globalFontMeasureCache() {
- return this._globalFontMeasureCache;
- }
-
- static setFontMeasureCache(fontStyle: string, content: string, tm: IMeasureTextCache) {
- if (!this._globalFontMeasureCache.has(fontStyle)) {
- this._globalFontMeasureCache.set(fontStyle, new Map());
- }
-
- const fontMeasureCache = this._globalFontMeasureCache.get(fontStyle);
- if (fontMeasureCache) {
- fontMeasureCache.set(content, tm);
- }
- }
-
- static clearFontMeasureCache(path: string) {
- const pathArr = path.split('/');
- if (pathArr.length === 1) {
- const fontStyle = pathArr[0];
- this._globalFontMeasureCache.delete(fontStyle);
- } else if (pathArr.length === 2) {
- const fontStyle = pathArr[0];
- const content = pathArr[1];
- this._globalFontMeasureCache.get(fontStyle)?.delete(content);
- } else {
- return false;
- }
- return true;
- }
-
- static getFontMeasureCache(fontStyle: string, content: string): Nullable<IMeasureTextCache> {
- return this._globalFontMeasureCache.get(fontStyle)?.get(content);
- }
-
- // 自动清除文字缓存,阈值可调整,清除规则是触发上限后删除一半的缓存
- static autoCleanFontMeasureCache(cacheLimit: number = 1000000) {
- let allSize = 0;
- let isDelete = false;
- let i = 0;
-
- for (const item of this._globalFontMeasureCache) {
- const [, values] = item;
- allSize += values.size;
- if (allSize > cacheLimit) {
- isDelete = true;
- break;
- }
- i++;
- }
-
- if (isDelete) {
- let deleteAllSize = 0;
- for (const item of this._globalFontMeasureCache) {
- const [key, values] = item;
- deleteAllSize += values.size;
- if (deleteAllSize > cacheLimit / 2) {
- const limit = deleteAllSize - cacheLimit / 2;
- this._clearMeasureCache(limit, values); // 如果字体样式下面的文字数量部门超过阈值,则深入内部清除
- break;
- }
-
- // 清除整个样式下的字体缓存
- this._globalFontMeasureCache.delete(key);
- }
-
- return true;
- }
-
- return false;
- }
-
- static getBaselineOffsetInfo(fontFamily: string, fontSize: number) {
- if (this._fontDataMap.size === 0) {
- return getDefaultBaselineOffset(fontSize);
- }
- const fontFamilyList = fontFamily.split(',');
- for (let ff of fontFamilyList) {
- ff = ff.replace(/'/g, '');
- const fontData = this._fontDataMap.get(ff);
- if (!fontData) {
- continue;
- }
- const { subscriptSizeRatio, subscriptOffset, superscriptSizeRatio, superscriptOffset } = fontData;
- return {
- sbr: subscriptSizeRatio,
- sbo: subscriptOffset * fontSize,
- spr: superscriptSizeRatio,
- spo: superscriptOffset * fontSize,
- };
- }
- return getDefaultBaselineOffset(fontSize);
- }
-
- static getTextSizeByDom(text: string, fontStyle: string) {
- if (fontStyle in this._getTextHeightCache) {
- return this._getTextHeightCache[fontStyle];
- }
-
- let dom = document.getElementById('universheetTextSizeTest');
- const defaultStyle = 'float:left;white-space:nowrap;visibility:hidden;margin:0;padding:0;';
- if (!dom) {
- dom = document.createElement('span');
- // dom.style.cssText = 'visibility:hidden;';
- dom.id = 'universheetTextSizeTest';
- document.getElementsByTagName('body')[0].appendChild(dom);
- }
- dom.style.cssText += `${defaultStyle};${fontStyle}`;
- dom.innerText = text;
- const rect = dom.getBoundingClientRect();
- const result = { width: rect.width, height: rect.height };
- this._getTextHeightCache[fontStyle] = result;
-
- return result;
- }
-
- static getTextSize(content: string, fontStyle: IDocumentSkeletonFontStyle): IDocumentSkeletonBoundingBox {
- const { fontString, fontSize, fontFamily } = fontStyle;
-
- let bBox = this._getBoundingBoxByFont(fontFamily, fontSize);
- if (!bBox) {
- const measureText = this.getMeasureText(content, fontString);
- bBox = this._calculateBoundingBoxByMeasureText(measureText, fontSize);
- }
- return bBox;
- }
-
- // 获取有值单元格文本大小
- // let measureTextCache = {}, measureTextCacheTimeOut = null;
- static getMeasureText(content: string, fontString: string): IMeasureTextCache {
- if (!this._context) {
- const canvas = document.createElement('canvas');
- this._context = canvas.getContext('2d')!;
- }
-
- // const { fontString, fontSize, fontFamily } = fontStyle;
-
- const ctx = this._context;
-
- const mtc = this.getFontMeasureCache(fontString, content);
- if (mtc != null) {
- return mtc;
- }
-
- ctx.font = fontString;
-
- const textMetrics = ctx.measureText(content);
-
- const {
- width,
- fontBoundingBoxAscent,
- fontBoundingBoxDescent,
- actualBoundingBoxAscent,
- actualBoundingBoxDescent,
- } = textMetrics;
-
- const cache: IMeasureTextCache = {
- width,
- fontBoundingBoxAscent,
- fontBoundingBoxDescent,
- actualBoundingBoxAscent,
- actualBoundingBoxDescent,
- };
-
- // 兼容不支持textMetrics的情况
- if (
- fontBoundingBoxAscent == null ||
- fontBoundingBoxDescent == null ||
- Number.isNaN(fontBoundingBoxAscent) ||
- Number.isNaN(fontBoundingBoxDescent)
- ) {
- const oneLineTextHeight = this.getTextSizeByDom(DEFAULT_MEASURE_TEXT, fontString).height;
-
- if (ctx.textBaseline === 'top') {
- cache.fontBoundingBoxAscent = cache.actualBoundingBoxAscent = oneLineTextHeight;
- cache.fontBoundingBoxDescent = cache.actualBoundingBoxDescent = 0;
- } else if (ctx.textBaseline === 'middle') {
- cache.fontBoundingBoxDescent = cache.actualBoundingBoxDescent = oneLineTextHeight / 2;
- cache.fontBoundingBoxAscent = cache.actualBoundingBoxAscent = oneLineTextHeight / 2;
- } else {
- cache.fontBoundingBoxDescent = cache.actualBoundingBoxDescent = 0;
- cache.fontBoundingBoxAscent = cache.actualBoundingBoxAscent = oneLineTextHeight;
- }
- }
-
- this.setFontMeasureCache(fontString, content, cache);
- return cache;
- }
-
- private static _clearMeasureCache(limit: number, values: Map<string, IMeasureTextCache>) {
- let valueIndex = 0;
- for (const txtItem of values) {
- const [txtKey] = txtItem;
- if (valueIndex > limit) {
- break;
- }
- values.delete(txtKey);
- valueIndex++;
- }
- return true;
- }
-
- /**
- * Vertical Metrics https://glyphsapp.com/learn/vertical-metrics
- * @param fontFamily
- * @param fontSize
- * @param content
- * @returns
- */
- private static _getBoundingBoxByFont(fontFamily: string, fontSize = 28, content: string = '') {
- const fontData = this._fontDataMap.get(fontFamily);
- if (!fontData) {
- return;
- }
- const {
- notDefWidth,
- ascender,
- descender,
- typoAscender,
- typoDescender,
- strikeoutPosition,
- subscriptSizeRatio,
- subscriptOffset,
- superscriptSizeRatio,
- superscriptOffset,
- hdmxData,
- glyphHorizonMap,
- } = fontData;
-
- const pixelsPerEmIndex = hdmxData?.indexOf(Math.floor(fontSize));
-
- const glyph = glyphHorizonMap.get(content.charCodeAt(0));
- let widthResult = notDefWidth;
- if (glyph) {
- const { width, pixelsPerEm = [] } = glyph;
-
- if (pixelsPerEmIndex) {
- widthResult = pixelsPerEm[pixelsPerEmIndex];
- } else {
- widthResult = width;
- }
- }
- return {
- width: widthResult * fontSize,
- ba: ascender * fontSize,
- bd: descender * fontSize,
- aba: typoAscender * fontSize,
- abd: typoDescender * fontSize,
- sp: strikeoutPosition * fontSize,
- sbr: subscriptSizeRatio,
- sbo: subscriptOffset * fontSize,
- spr: superscriptSizeRatio,
- spo: superscriptOffset * fontSize,
- };
- }
-
- private static _calculateBoundingBoxByMeasureText(textCache: IMeasureTextCache, fontSize: number) {
- const {
- width,
- fontBoundingBoxAscent,
- fontBoundingBoxDescent,
- actualBoundingBoxAscent,
- actualBoundingBoxDescent,
- } = textCache;
- return {
- width,
- ba: fontBoundingBoxAscent,
- bd: fontBoundingBoxDescent,
- aba: actualBoundingBoxAscent,
- abd: actualBoundingBoxDescent,
- sp: (fontBoundingBoxAscent + fontBoundingBoxDescent) / 2,
- sbr: 0.5,
- sbo: fontSize,
- spr: 0.5,
- spo: fontSize,
- };
- }
-}
+import { Nullable } from '@univerjs/core';
+
+import { DEFAULT_MEASURE_TEXT } from './Const';
+import { IDocumentSkeletonBoundingBox, IDocumentSkeletonFontStyle } from './IDocumentSkeletonCached';
+import { IMeasureTextCache } from './Interfaces';
+
+const getDefaultBaselineOffset = (fontSize: number) => ({
+ sbr: 0.5,
+ sbo: fontSize,
+ spr: 0.5,
+ spo: fontSize,
+});
+
+interface IFontData {
+ notDefWidth: number;
+ ascender: number;
+ descender: number;
+ typoAscender: number;
+ typoDescender: number;
+ strikeoutPosition: number;
+ subscriptSizeRatio: number;
+ subscriptOffset: number;
+ superscriptSizeRatio: number;
+ superscriptOffset: number;
+ hdmxData?: number[]; // hdmxData https://docs.microsoft.com/en-us/typography/opentype/spec/recom#hdmx
+ glyphHorizonMap: Map<number, IGlyphHorizonData>;
+}
+
+interface IGlyphHorizonData {
+ width: number;
+ lsb: number;
+ pixelsPerEm?: number[];
+}
+
+export class FontCache {
+ private static _getTextHeightCache: { [key: string]: { width: number; height: number } } = {};
+
+ private static _context: CanvasRenderingContext2D;
+
+ private static _fontDataMap: Map<string, IFontData> = new Map();
+
+ // 文字缓存全局变量
+ private static _globalFontMeasureCache: Map<string, Map<string, IMeasureTextCache>> = new Map();
+
+ static get globalFontMeasureCache() {
+ return this._globalFontMeasureCache;
+ }
+
+ static setFontMeasureCache(fontStyle: string, content: string, tm: IMeasureTextCache) {
+ if (!this._globalFontMeasureCache.has(fontStyle)) {
+ this._globalFontMeasureCache.set(fontStyle, new Map());
+ }
+
+ const fontMeasureCache = this._globalFontMeasureCache.get(fontStyle);
+ if (fontMeasureCache) {
+ fontMeasureCache.set(content, tm);
+ }
+ }
+
+ static clearFontMeasureCache(path: string) {
+ const pathArr = path.split('/');
+ if (pathArr.length === 1) {
+ const fontStyle = pathArr[0];
+ this._globalFontMeasureCache.delete(fontStyle);
+ } else if (pathArr.length === 2) {
+ const fontStyle = pathArr[0];
+ const content = pathArr[1];
+ this._globalFontMeasureCache.get(fontStyle)?.delete(content);
+ } else {
+ return false;
+ }
+ return true;
+ }
+
+ static getFontMeasureCache(fontStyle: string, content: string): Nullable<IMeasureTextCache> {
+ return this._globalFontMeasureCache.get(fontStyle)?.get(content);
+ }
+
+ // 自动清除文字缓存,阈值可调整,清除规则是触发上限后删除一半的缓存
+ static autoCleanFontMeasureCache(cacheLimit: number = 1000000) {
+ let allSize = 0;
+ let isDelete = false;
+ let i = 0;
+
+ for (const item of this._globalFontMeasureCache) {
+ const [, values] = item;
+ allSize += values.size;
+ if (allSize > cacheLimit) {
+ isDelete = true;
+ break;
+ }
+ i++;
+ }
+
+ if (isDelete) {
+ let deleteAllSize = 0;
+ for (const item of this._globalFontMeasureCache) {
+ const [key, values] = item;
+ deleteAllSize += values.size;
+ if (deleteAllSize > cacheLimit / 2) {
+ const limit = deleteAllSize - cacheLimit / 2;
+ this._clearMeasureCache(limit, values); // 如果字体样式下面的文字数量部门超过阈值,则深入内部清除
+ break;
+ }
+
+ // 清除整个样式下的字体缓存
+ this._globalFontMeasureCache.delete(key);
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ static getBaselineOffsetInfo(fontFamily: string, fontSize: number) {
+ if (this._fontDataMap.size === 0) {
+ return getDefaultBaselineOffset(fontSize);
+ }
+ const fontFamilyList = fontFamily.split(',');
+ for (let ff of fontFamilyList) {
+ ff = ff.replace(/'/g, '');
+ const fontData = this._fontDataMap.get(ff);
+ if (!fontData) {
+ continue;
+ }
+ const { subscriptSizeRatio, subscriptOffset, superscriptSizeRatio, superscriptOffset } = fontData;
+ return {
+ sbr: subscriptSizeRatio,
+ sbo: subscriptOffset * fontSize,
+ spr: superscriptSizeRatio,
+ spo: superscriptOffset * fontSize,
+ };
+ }
+ return getDefaultBaselineOffset(fontSize);
+ }
+
+ static getTextSizeByDom(text: string, fontStyle: string) {
+ if (fontStyle in this._getTextHeightCache) {
+ return this._getTextHeightCache[fontStyle];
+ }
+
+ let dom = document.getElementById('universheetTextSizeTest');
+ const defaultStyle = 'float:left;white-space:nowrap;visibility:hidden;margin:0;padding:0;';
+ if (!dom) {
+ dom = document.createElement('span');
+ // dom.style.cssText = 'visibility:hidden;';
+ dom.id = 'universheetTextSizeTest';
+ document.getElementsByTagName('body')[0].appendChild(dom);
+ }
+ dom.style.cssText += `${defaultStyle};${fontStyle}`;
+ dom.innerText = text;
+ const rect = dom.getBoundingClientRect();
+ const result = { width: rect.width, height: rect.height };
+ this._getTextHeightCache[fontStyle] = result;
+
+ return result;
+ }
+
+ static getTextSize(content: string, fontStyle: IDocumentSkeletonFontStyle): IDocumentSkeletonBoundingBox {
+ const { fontString, fontSize, fontFamily } = fontStyle;
+
+ let bBox = this._getBoundingBoxByFont(fontFamily, fontSize);
+ if (!bBox) {
+ // if (content === DataStreamTreeTokenType.PARAGRAPH) {
+ // content = '0';
+ // }
+ const measureText = this.getMeasureText(content, fontString);
+ bBox = this._calculateBoundingBoxByMeasureText(measureText, fontSize);
+ }
+ return bBox;
+ }
+
+ // 获取有值单元格文本大小
+ // let measureTextCache = {}, measureTextCacheTimeOut = null;
+ static getMeasureText(content: string, fontString: string): IMeasureTextCache {
+ if (!this._context) {
+ const canvas = document.createElement('canvas');
+ this._context = canvas.getContext('2d')!;
+ }
+
+ // const { fontString, fontSize, fontFamily } = fontStyle;
+
+ const ctx = this._context;
+
+ const mtc = this.getFontMeasureCache(fontString, content);
+ if (mtc != null) {
+ return mtc;
+ }
+
+ ctx.font = fontString;
+
+ const textMetrics = ctx.measureText(content);
+
+ const {
+ width,
+ fontBoundingBoxAscent,
+ fontBoundingBoxDescent,
+ actualBoundingBoxAscent,
+ actualBoundingBoxDescent,
+ } = textMetrics;
+
+ const cache: IMeasureTextCache = {
+ width,
+ fontBoundingBoxAscent,
+ fontBoundingBoxDescent,
+ actualBoundingBoxAscent,
+ actualBoundingBoxDescent,
+ };
+
+ // 兼容不支持textMetrics的情况
+ if (
+ fontBoundingBoxAscent == null ||
+ fontBoundingBoxDescent == null ||
+ Number.isNaN(fontBoundingBoxAscent) ||
+ Number.isNaN(fontBoundingBoxDescent)
+ ) {
+ const oneLineTextHeight = this.getTextSizeByDom(DEFAULT_MEASURE_TEXT, fontString).height;
+
+ if (ctx.textBaseline === 'top') {
+ cache.fontBoundingBoxAscent = cache.actualBoundingBoxAscent = oneLineTextHeight;
+ cache.fontBoundingBoxDescent = cache.actualBoundingBoxDescent = 0;
+ } else if (ctx.textBaseline === 'middle') {
+ cache.fontBoundingBoxDescent = cache.actualBoundingBoxDescent = oneLineTextHeight / 2;
+ cache.fontBoundingBoxAscent = cache.actualBoundingBoxAscent = oneLineTextHeight / 2;
+ } else {
+ cache.fontBoundingBoxDescent = cache.actualBoundingBoxDescent = 0;
+ cache.fontBoundingBoxAscent = cache.actualBoundingBoxAscent = oneLineTextHeight;
+ }
+ }
+
+ this.setFontMeasureCache(fontString, content, cache);
+ return cache;
+ }
+
+ private static _clearMeasureCache(limit: number, values: Map<string, IMeasureTextCache>) {
+ let valueIndex = 0;
+ for (const txtItem of values) {
+ const [txtKey] = txtItem;
+ if (valueIndex > limit) {
+ break;
+ }
+ values.delete(txtKey);
+ valueIndex++;
+ }
+ return true;
+ }
+
+ /**
+ * Vertical Metrics https://glyphsapp.com/learn/vertical-metrics
+ * @param fontFamily
+ * @param fontSize
+ * @param content
+ * @returns
+ */
+ private static _getBoundingBoxByFont(fontFamily: string, fontSize = 28, content: string = '') {
+ const fontData = this._fontDataMap.get(fontFamily);
+ if (!fontData) {
+ return;
+ }
+ const {
+ notDefWidth,
+ ascender,
+ descender,
+ typoAscender,
+ typoDescender,
+ strikeoutPosition,
+ subscriptSizeRatio,
+ subscriptOffset,
+ superscriptSizeRatio,
+ superscriptOffset,
+ hdmxData,
+ glyphHorizonMap,
+ } = fontData;
+
+ const pixelsPerEmIndex = hdmxData?.indexOf(Math.floor(fontSize));
+
+ const glyph = glyphHorizonMap.get(content.charCodeAt(0));
+ let widthResult = notDefWidth;
+ if (glyph) {
+ const { width, pixelsPerEm = [] } = glyph;
+
+ if (pixelsPerEmIndex) {
+ widthResult = pixelsPerEm[pixelsPerEmIndex];
+ } else {
+ widthResult = width;
+ }
+ }
+ return {
+ width: widthResult * fontSize,
+ ba: ascender * fontSize,
+ bd: descender * fontSize,
+ aba: typoAscender * fontSize,
+ abd: typoDescender * fontSize,
+ sp: strikeoutPosition * fontSize,
+ sbr: subscriptSizeRatio,
+ sbo: subscriptOffset * fontSize,
+ spr: superscriptSizeRatio,
+ spo: superscriptOffset * fontSize,
+ };
+ }
+
+ private static _calculateBoundingBoxByMeasureText(textCache: IMeasureTextCache, fontSize: number) {
+ const {
+ width,
+ fontBoundingBoxAscent,
+ fontBoundingBoxDescent,
+ actualBoundingBoxAscent,
+ actualBoundingBoxDescent,
+ } = textCache;
+ return {
+ width,
+ ba: fontBoundingBoxAscent,
+ bd: fontBoundingBoxDescent,
+ aba: actualBoundingBoxAscent,
+ abd: actualBoundingBoxDescent,
+ sp: (fontBoundingBoxAscent + fontBoundingBoxDescent) / 2,
+ sbr: 0.5,
+ sbo: fontSize,
+ spr: 0.5,
+ spo: fontSize,
+ };
+ }
+}
diff --git a/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.ts b/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.ts
index 139eb1e206..32b9598631 100644
--- a/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.ts
+++ b/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.ts
@@ -143,7 +143,7 @@ export function dealWidthParagraph(
const charIndex = i + startIndex;
const char = content[i];
- const fontCreateConfig = getFontCreateConfig(i, bodyModel, paragraphNode, sectionBreakConfig, paragraphStyle);
+ const fontCreateConfig = getFontCreateConfig(i, bodyModel, paragraphNode, sectionBreakConfig, paragraphStyle); // Get the style of the text.
if (char === DataStreamTreeTokenType.TAB) {
const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
diff --git a/packages/base-render/src/Component/Docs/DocSkeleton.ts b/packages/base-render/src/Component/Docs/DocSkeleton.ts
index ae6d895498..bb299f8014 100644
--- a/packages/base-render/src/Component/Docs/DocSkeleton.ts
+++ b/packages/base-render/src/Component/Docs/DocSkeleton.ts
@@ -461,7 +461,6 @@ export class DocumentSkeleton extends Skeleton {
* Split the document according to SectionBreak and perform layout calculations.
* @returns view model: skeleton
*/
- // eslint-disable-next-line max-lines-per-function
private _createSkeleton(bounds?: IBoundRect) {
// 每一个布局
const DEFAULT_PAGE_SIZE = { width: Infinity, height: Infinity };
diff --git a/packages/base-render/src/Component/Sheets/SheetSkeleton.ts b/packages/base-render/src/Component/Sheets/SheetSkeleton.ts
index 6cc0a8c95b..90bb563571 100644
--- a/packages/base-render/src/Component/Sheets/SheetSkeleton.ts
+++ b/packages/base-render/src/Component/Sheets/SheetSkeleton.ts
@@ -1,5 +1,6 @@
import {
BooleanNumber,
+ DEFAULT_EMPTY_DOCUMENT_VALUE,
DocumentModel,
DocumentModelOrSimple,
DocumentModelSimple,
@@ -1566,12 +1567,12 @@ export class SpreadsheetSkeleton extends Skeleton {
const documentData: IDocumentData = {
id: 'd',
body: {
- dataStream: `${content}\r\n`,
+ dataStream: `${content}${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
textRuns: [
{
ts: textStyle,
st: 0,
- ed: contentLength - 1,
+ ed: contentLength,
},
],
paragraphs: [
diff --git a/packages/base-render/src/Shape/RichText.ts b/packages/base-render/src/Shape/RichText.ts
index fd67179824..a7750dff09 100644
--- a/packages/base-render/src/Shape/RichText.ts
+++ b/packages/base-render/src/Shape/RichText.ts
@@ -2,6 +2,7 @@
import {
BooleanNumber,
+ DEFAULT_EMPTY_DOCUMENT_VALUE,
DocumentModelSimple,
IBorderData,
IColorStyle,
@@ -232,7 +233,7 @@ export class RichText extends BaseObject {
const documentData: IDocumentData = {
id: 'd',
body: {
- dataStream: `${text}\r\n`,
+ dataStream: `${text}${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
textRuns: [
{
ts: {
diff --git a/packages/base-sheets/src/Controller/freeze.controller.ts b/packages/base-sheets/src/Controller/freeze.controller.ts
index 3cb30fc5cd..cfc5efe119 100644
--- a/packages/base-sheets/src/Controller/freeze.controller.ts
+++ b/packages/base-sheets/src/Controller/freeze.controller.ts
@@ -22,6 +22,7 @@ import {
} from '@univerjs/core';
import { Inject } from '@wendellhu/redi';
+import { SetWorksheetActivateMutation } from '..';
import { getCoordByOffset, getSheetObject } from '../Basics/component-tools';
import { SHEET_COMPONENT_HEADER_LAYER_INDEX, VIEWPORT_KEY } from '../Basics/Const/DEFAULT_SPREADSHEET_VIEW';
import { SetFrozenCommand } from '../commands/commands/set-frozen.command';
@@ -895,21 +896,20 @@ export class FreezeController extends Disposable {
}
}
+ /**
+ * When switching sheet tabs, it is necessary to update the frozen state of the current view.
+ */
private _skeletonListener() {
- // this.disposeWithMe(
- // toDisposable(
- // this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
- // if (
- // [SetWorksheetRowIsAutoHeightMutation.id, SetWorksheetRowAutoHeightMutation.id].includes(
- // param?.commandId || ''
- // )
- // ) {
- // return;
- // }
- // this._refreshCurrent();
- // })
- // )
- // );
+ this.disposeWithMe(
+ toDisposable(
+ this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
+ if (![SetWorksheetActivateMutation.id].includes(param?.commandId || '')) {
+ return;
+ }
+ this._refreshCurrent();
+ })
+ )
+ );
}
private _refreshCurrent() {
diff --git a/packages/base-sheets/src/commands/commands/set-selections.command.ts b/packages/base-sheets/src/commands/commands/set-selections.command.ts
index 0272f02d0f..dc8e3be6e4 100644
--- a/packages/base-sheets/src/commands/commands/set-selections.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-selections.command.ts
@@ -149,7 +149,14 @@ export const MoveSelectionEnterAndTabCommand: ICommand<IMoveSelectionEnterAndTab
let resultRange;
const { startRow, endRow, startColumn, endColumn } = range;
- if (startRow < endRow || startColumn < endColumn) {
+ if (
+ !(
+ startRow === primary.startRow &&
+ endRow === primary.startRow &&
+ startColumn === primary.startColumn &&
+ endColumn === primary.endColumn
+ )
+ ) {
// Handle the situation of moving the active cell within the selection area.
shortcutExperienceService.remove({
unitId,
diff --git a/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.ts b/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.ts
index a45d71b7fb..81f24f6b46 100644
--- a/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.ts
+++ b/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.ts
@@ -70,11 +70,11 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
lists: DEFAULT_LIST_TEST,
body: {
dataStream:
- 'What’s New in the 2022 Gartner Hype Cycle for Emerging Technologies\rEmerging technologies for 2022 fit into three main themes: evolving/expanding immersive experiences, accelerated artificial intelligence automation, and optimized technologist delivery.\rThe 2022 Gartner Hype Cycle identifies 25 must-know emerging technologies designed to help enterprise architecture and technology innovation leaders: \rExpand immersive experiences\rAccelerate artificial intelligence (AI) automation\rOptimize technologist delivery \rThese technologies are expected to greatly impact business and society over the next two to 10 years, but will especially enable CIOs and IT leaders to deliver on digital business transformation. \rThree Hype Cycle themes to think about in 2022 and beyond\rThe 2022 Gartner Hype Cycle features emerging technologies and distills insights from more than 2,000 technologies into a succinct high-potential set. Most technologies have multiple use cases but enterprise architecture and technology innovation leaders should prioritize those with the greatest potential benefit for their organization. (They will also need to launch a proof-of-concept project to demonstrate the feasibility of a technology for their target use case.)\b\r\nThe benefit of these technologies is that they provide individuals with more control over their identities and data, and expand their range of experiences into virtual venues and ecosystems that can be integrated with digital currencies. These technologies also provide new ways to reach customers to strengthen or open up new revenue streams.\rDigital twin of the customer (DToC) is a dynamic virtual representation of a customer that simulates and learns to emulate and anticipate behavior. It can be used to modify and enhance the customer experience (CX) and support new digitalization efforts, products, services and opportunities. DToC will take five to 10 years until mainstream adoption but will be transformational to organizations.\rOther critical technologies in immersive experiences include the following:\rDecentralized identity (DCI) allows an entity (typically a human user) to control their own digital identity by leveraging technologies such as blockchain or other distributed ledger technologies (DLTs), along with digital wallets.\rDigital humans are interactive, AI-driven representations that have some of the characteristics, personality, knowledge and mindset of a human.\rInternal talent marketplaces match internal employees and, in some cases, a pool of contingent workers, to time-boxed projects and various work opportunities, with no recruiter involvement.\r\n\0',
+ 'What’s New in the 2022 Gartner Hype Cycle for Emerging Technologies\rEmerging technologies for 2022 fit into three main themes: evolving/expanding immersive experiences, accelerated artificial intelligence automation, and optimized technologist delivery.\rThe 2022 Gartner Hype Cycle identifies 25 must-know emerging technologies designed to help enterprise architecture and technology innovation leaders: \rExpand immersive experiences\rAccelerate artificial intelligence (AI) automation\rOptimize technologist delivery \rThese technologies are expected to greatly impact business and society over the next two to 10 years, but will especially enable CIOs and IT leaders to deliver on digital business transformation. \rThree Hype Cycle themes to think about in 2022 and beyond\rThe 2022 Gartner Hype Cycle features emerging technologies and distills insights from more than 2,000 technologies into a succinct high-potential set. Most technologies have multiple use cases but enterprise architecture and technology innovation leaders should prioritize those with the greatest potential benefit for their organization. (They will also need to launch a proof-of-concept project to demonstrate the feasibility of a technology for their target use case.)\b\r\nThe benefit of these technologies is that they provide individuals with more control over their identities and data, and expand their range of experiences into virtual venues and ecosystems that can be integrated with digital currencies. These technologies also provide new ways to reach customers to strengthen or open up new revenue streams.\rDigital twin of the customer (DToC) is a dynamic virtual representation of a customer that simulates and learns to emulate and anticipate behavior. It can be used to modify and enhance the customer experience (CX) and support new digitalization efforts, products, services and opportunities. DToC will take five to 10 years until mainstream adoption but will be transformational to organizations.\rOther critical technologies in immersive experiences include the following:\rDecentralized identity (DCI) allows an entity (typically a human user) to control their own digital identity by leveraging technologies such as blockchain or other distributed ledger technologies (DLTs), along with digital wallets.\rDigital humans are interactive, AI-driven representations that have some of the characteristics, personality, knowledge and mindset of a human.\rInternal talent marketplaces match internal employees and, in some cases, a pool of contingent workers, to time-boxed projects and various work opportunities, with no recruiter involvement.\r\n',
textRuns: [
{
st: 0,
- ed: 66,
+ ed: 67,
ts: {
bl: BooleanNumber.TRUE,
fs: 24,
@@ -85,7 +85,7 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
{
st: 68,
- ed: 252,
+ ed: 253,
ts: {
fs: 18,
cl: {
@@ -95,42 +95,42 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
{
st: 254,
- ed: 403,
+ ed: 404,
ts: {
fs: 16,
},
},
{
st: 405,
- ed: 432,
+ ed: 433,
ts: {
fs: 16,
},
},
{
st: 434,
- ed: 483,
+ ed: 484,
ts: {
fs: 16,
},
},
{
st: 485,
- ed: 515,
+ ed: 516,
ts: {
fs: 16,
},
},
{
st: 517,
- ed: 678,
+ ed: 679,
ts: {
fs: 16,
},
},
{
st: 680,
- ed: 712,
+ ed: 713,
ts: {
fs: 16,
cl: {
@@ -141,7 +141,7 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
{
st: 714,
- ed: 770,
+ ed: 771,
ts: {
fs: 24,
cl: {
@@ -154,35 +154,35 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
{
st: 772,
- ed: 1243,
+ ed: 1244,
ts: {
fs: 16,
},
},
{
st: 1246,
- ed: 1588,
+ ed: 1589,
ts: {
fs: 16,
},
},
{
st: 1590,
- ed: 1985,
+ ed: 1986,
ts: {
fs: 16,
},
},
{
st: 1987,
- ed: 2061,
+ ed: 2062,
ts: {
fs: 16,
},
},
{
st: 2063,
- ed: 2085,
+ ed: 2086,
ts: {
fs: 16,
cl: {
@@ -193,14 +193,14 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
{
st: 2086,
- ed: 2293,
+ ed: 2294,
ts: {
fs: 16,
},
},
{
st: 2295,
- ed: 2309,
+ ed: 2310,
ts: {
fs: 16,
cl: {
@@ -211,14 +211,14 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
{
st: 2310,
- ed: 2437,
+ ed: 2438,
ts: {
fs: 16,
},
},
{
st: 2439,
- ed: 2467,
+ ed: 2468,
ts: {
fs: 16,
cl: {
@@ -229,7 +229,7 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
{
st: 2468,
- ed: 2627,
+ ed: 2628,
ts: {
fs: 16,
},
diff --git a/packages/core/src/Docs/Domain/DocumentBodyModel.ts b/packages/core/src/Docs/Domain/DocumentBodyModel.ts
index 0d897004e6..a2e8af8dfb 100644
--- a/packages/core/src/Docs/Domain/DocumentBodyModel.ts
+++ b/packages/core/src/Docs/Domain/DocumentBodyModel.ts
@@ -447,6 +447,9 @@ export class DocumentBodyModel extends DocumentBodyModelSimple {
return trRange;
}
+ /**
+ * textRun matches according to the selection. If the text length is 10, then the range of textRun is from 0 to 11.
+ */
override getTextRun(index: number) {
const textRuns = this.body.textRuns;
if (textRuns == null) {
@@ -466,7 +469,7 @@ export class DocumentBodyModel extends DocumentBodyModelSimple {
for (let i = this.textRunCurrentIndex, textRunsLen = textRuns.length; i < textRunsLen; i++) {
const textRun = textRuns[i];
- if (index >= textRun.st && index <= textRun.ed) {
+ if (index >= textRun.st && index < textRun.ed) {
this.textRunCurrentIndex = i;
return textRun;
}
diff --git a/packages/core/src/Docs/Domain/DocumentModel.ts b/packages/core/src/Docs/Domain/DocumentModel.ts
index cc198f5e78..413fcc93ba 100644
--- a/packages/core/src/Docs/Domain/DocumentModel.ts
+++ b/packages/core/src/Docs/Domain/DocumentModel.ts
@@ -231,10 +231,12 @@ export class DocumentModel extends DocumentModelSimple {
}
}
+export const DEFAULT_EMPTY_DOCUMENT_VALUE = '\r\n';
+
export function createEmptyDocSnapshot(): Partial<IDocumentData> {
return {
body: {
- dataStream: '\r\n\0',
+ dataStream: DEFAULT_EMPTY_DOCUMENT_VALUE,
},
};
}
diff --git a/packages/core/src/Types/Interfaces/IDocumentData.ts b/packages/core/src/Types/Interfaces/IDocumentData.ts
index c5143bce61..6b7f9a5a4d 100644
--- a/packages/core/src/Types/Interfaces/IDocumentData.ts
+++ b/packages/core/src/Types/Interfaces/IDocumentData.ts
@@ -74,6 +74,28 @@ export interface ISizeData {
/**
* Properties of document body
* 三种更新类型,范围叠加、范围互斥、占位符
+ * \v COLUMN_BREAK
+ * \f PAGE_BREAK
+ * \0 DOCS_END
+ * \t TAB
+ *
+ * Needs to be changed:
+ * \r PARAGRAPH
+ * \n SECTION_BREAK
+ *
+ * \b customBlock: Scenarios where customBlock, images, mentions, etc. do not participate in the document flow.
+ *
+ * Table
+ * \x1A table start
+ * \x1B table row start
+ * \x1C table cell start
+ * \x1D table cell end
+ * \x1E table row end
+ * \x1F table end
+ *
+ * Special ranges within the document flow::hyperlinks,field,structured document tags, bookmark,comment
+ * \x1F customRange start
+ * \x1E customRange end
*/
export interface IDocumentBody {
dataStream: string;
@@ -83,7 +105,7 @@ export interface IDocumentBody {
paragraphs?: IParagraph[]; // paragraph
sectionBreaks?: ISectionBreak[]; // SectionBreak https://support.microsoft.com/en-us/office/insert-a-section-break-eef20fd8-e38c-4ba6-a027-e503bdf8375c
customBlocks?: ICustomBlock[]; // customBlock 用户通过插件自定义的block
- tables?: ITable[]; // table
+ tables?: ITable[]; // Table
// tableOfContents?: { [index: number]: ITableOfContent }; // tableOfContents 目录
// links?: { [index: number]: IHyperlink }; // links 超链接
customRanges?: ICustomRange[]; // plugin注册,实现针对stream的特殊逻辑,超链接,field,structured document tags, bookmark,comment
diff --git a/packages/ui-plugin-sheets/src/View/EditorContainer/EditorContainer.tsx b/packages/ui-plugin-sheets/src/View/EditorContainer/EditorContainer.tsx
index 2566e4463e..2702474e3e 100644
--- a/packages/ui-plugin-sheets/src/View/EditorContainer/EditorContainer.tsx
+++ b/packages/ui-plugin-sheets/src/View/EditorContainer/EditorContainer.tsx
@@ -66,8 +66,8 @@ export const EditorContainer: React.FC<ICellIEditorProps> = () => {
setState({
width: endX - startX,
height: endY - startY,
- left: startX - 1,
- top: startY - 1,
+ left: startX - 1.5,
+ top: startY - 1.5,
});
}
});
diff --git a/packages/ui-plugin-sheets/src/View/EditorContainer/index.module.less b/packages/ui-plugin-sheets/src/View/EditorContainer/index.module.less
index ea29888dcf..981508fda0 100644
--- a/packages/ui-plugin-sheets/src/View/EditorContainer/index.module.less
+++ b/packages/ui-plugin-sheets/src/View/EditorContainer/index.module.less
@@ -1,9 +1,9 @@
.editor-container {
display: flex;
position: absolute;
- border: 1px solid #409f11;
+ border: 1.5px solid rgb(var(--primary-color));
box-shadow: none;
- outline: 1px solid #49b811;
+ outline: 1.5px solid rgba(var(--primary-color-hover), 0.5);
z-index: 10;
left: 100px;
diff --git a/packages/ui-plugin-sheets/src/controller/editor/end-edit.controller.ts b/packages/ui-plugin-sheets/src/controller/editor/end-edit.controller.ts
index 24a53a613b..438f71ceeb 100644
--- a/packages/ui-plugin-sheets/src/controller/editor/end-edit.controller.ts
+++ b/packages/ui-plugin-sheets/src/controller/editor/end-edit.controller.ts
@@ -14,6 +14,7 @@ import {
} from '@univerjs/base-sheets';
import { KeyCode } from '@univerjs/base-ui';
import {
+ DEFAULT_EMPTY_DOCUMENT_VALUE,
Direction,
Disposable,
DocumentModel,
@@ -156,7 +157,8 @@ export class EndEditController extends Disposable {
} else {
const data = body.dataStream;
const lastString = data.substring(data.length - 2, data.length);
- const newDataStream = lastString === '\r\n' ? data.substring(0, data.length - 2) : data;
+ const newDataStream =
+ lastString === DEFAULT_EMPTY_DOCUMENT_VALUE ? data.substring(0, data.length - 2) : data;
if (newDataStream === cellData.v) {
return;
diff --git a/packages/ui-plugin-sheets/src/controller/editor/start-edit.controller.ts b/packages/ui-plugin-sheets/src/controller/editor/start-edit.controller.ts
index bebbc29aac..43ee2e36ac 100644
--- a/packages/ui-plugin-sheets/src/controller/editor/start-edit.controller.ts
+++ b/packages/ui-plugin-sheets/src/controller/editor/start-edit.controller.ts
@@ -22,6 +22,7 @@ import {
} from '@univerjs/base-render';
import { KeyCode } from '@univerjs/base-ui';
import {
+ DEFAULT_EMPTY_DOCUMENT_VALUE,
Disposable,
DocumentModel,
FOCUSING_EDITOR,
@@ -464,7 +465,7 @@ export class StartEditController extends Disposable {
}
private _resetBodyStyle(body: IDocumentBody) {
- body.dataStream = `\r\n`;
+ body.dataStream = DEFAULT_EMPTY_DOCUMENT_VALUE;
if (body.textRuns != null) {
if (body.textRuns.length === 1) {