wendang-react 0.6.5 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/integrity.json CHANGED
@@ -3,11 +3,11 @@
3
3
  "algorithm": "sha256",
4
4
  "package": {
5
5
  "name": "wendang-react",
6
- "version": "0.6.5"
6
+ "version": "0.6.6"
7
7
  },
8
8
  "workspaceVersions": {
9
- "wendang": "0.6.3",
10
- "wendang-export": "0.6.4"
9
+ "wendang": "0.6.4",
10
+ "wendang-export": "0.6.5"
11
11
  },
12
12
  "files": [
13
13
  {
@@ -18,7 +18,7 @@
18
18
  {
19
19
  "path": "NOTICE.md",
20
20
  "bytes": 20129,
21
- "sha256": "2c39e3bf9bc74779f6e67306a0e7f5a21207fea29b7db4ddfcb46a3a1038bdbd"
21
+ "sha256": "bcf247cc4c0963cd847bed591b38f34f2a38ca00b6e51ada8707dd7ee109fce9"
22
22
  },
23
23
  {
24
24
  "path": "README.md",
@@ -28,7 +28,7 @@
28
28
  {
29
29
  "path": "dist/bindings/yjs.js",
30
30
  "bytes": 93,
31
- "sha256": "dec3ca3ec8ddb13c61540bd6c8b815f23c1ad179423b948bf0e582133f6977d6"
31
+ "sha256": "753876e860f92f63f7b6bafd51023d08fe9ce596ea44df3f881683743b5328ad"
32
32
  },
33
33
  {
34
34
  "path": "dist/chunks/AnchoredPanel-C7jMoPze.js",
@@ -46,14 +46,14 @@
46
46
  "sha256": "d55aad0f0d7da17bf61fd2789fdf6b185b6291047fb5438a35c3f89862500b83"
47
47
  },
48
48
  {
49
- "path": "dist/chunks/MindMapCanvas-C46Q5JBU.js",
49
+ "path": "dist/chunks/MindMapCanvas-BA3FYy8p.js",
50
50
  "bytes": 67143,
51
- "sha256": "2ab9f614894d599df2afe6df0ed0f2634f5c175539e710bc3a4c89e51f1ca25a"
51
+ "sha256": "b8ada0812bc54821047dbd4d57f6899de10a349b4037abd76c446ac2f8f8faa1"
52
52
  },
53
53
  {
54
- "path": "dist/chunks/MindMapViewer-C9zxZIW8.js",
54
+ "path": "dist/chunks/MindMapViewer-B1_uaMHB.js",
55
55
  "bytes": 6020,
56
- "sha256": "f597f171cf79f5a408bc8928dcc3abc711ac6ecbd1db5142e1cd00044872a599"
56
+ "sha256": "b3c4a47a672d5814c10d2728d8f9c5dd09e0f93d1ae78c2a13f63e7776b047cd"
57
57
  },
58
58
  {
59
59
  "path": "dist/chunks/SpreadsheetViewer-CoQ4VIgj.js",
@@ -81,9 +81,9 @@
81
81
  "sha256": "1b1465ba0d4b0663fb18b3e9d2045b8c742b3071fb3fc2e84a99db1bee1ae3c0"
82
82
  },
83
83
  {
84
- "path": "dist/chunks/extensions-BefQ1tDm.js",
85
- "bytes": 87992,
86
- "sha256": "91d47a33bb599248d6d02c0b0e1ecc363315f91b2f8fe62b8b648dbd4b4cdb53"
84
+ "path": "dist/chunks/extensions-D4JlN-IP.js",
85
+ "bytes": 88382,
86
+ "sha256": "10c1dfa5b04f43aa623e1af2b683563c1eaad586094d0aa0b34c5d010b9d015b"
87
87
  },
88
88
  {
89
89
  "path": "dist/chunks/fuzzy-match-DYQR-4w2.js",
@@ -116,9 +116,9 @@
116
116
  "sha256": "d72727d654f02c2035418876af4763f7c06365584a48f9e49189d72ef0d1a1b6"
117
117
  },
118
118
  {
119
- "path": "dist/chunks/mind-map-controller-Ce76mETT.js",
120
- "bytes": 13903,
121
- "sha256": "0b89e0f7ff9b61d894634274725bc19b94a675161980090f197b6a5b41c9daa8"
119
+ "path": "dist/chunks/mind-map-defaults-B9SSENmK.js",
120
+ "bytes": 14086,
121
+ "sha256": "8fc8f7d3a9a97436d9373b311809272a07e9e9e2db69ff5266cee990cb081dc4"
122
122
  },
123
123
  {
124
124
  "path": "dist/chunks/mind-map-delete-CVsxdXfs.js",
@@ -131,9 +131,9 @@
131
131
  "sha256": "69dcc9e190d07c33f3b3b67127fac6fe5dd657572b29b97e1db3adc692e61adb"
132
132
  },
133
133
  {
134
- "path": "dist/chunks/mind-topic-text-BHXkxexr.js",
135
- "bytes": 14373,
136
- "sha256": "49742aaa14b9e4ad68405f67f9c2faf0de00e771e557f45244017ec9e0c4b509"
134
+ "path": "dist/chunks/mind-topic-text-C7pIS6L9.js",
135
+ "bytes": 14420,
136
+ "sha256": "1754ec2df23708e867c09d9dca0dc939fd4db37fa4941be97e25b77b2289d8c5"
137
137
  },
138
138
  {
139
139
  "path": "dist/chunks/popover-placement-D3xVYdkt.js",
@@ -141,9 +141,9 @@
141
141
  "sha256": "0a730d718d611ae848daa5fa95f22e9c75b3690ca3531cdbb4dd87aa935c1aa6"
142
142
  },
143
143
  {
144
- "path": "dist/chunks/worksheet-engine-c84sdD4N.js",
145
- "bytes": 3936,
146
- "sha256": "a1b4c69450b41be4dae7b83ed8ac21b482602d24b16282ac1183e10edf22e082"
144
+ "path": "dist/chunks/worksheet-engine-Dz6P8Kiq.js",
145
+ "bytes": 3977,
146
+ "sha256": "ca46c00c8aca6e2f71e9b2a271f3137ff91103f3698d029df776e427f2ff7fa8"
147
147
  },
148
148
  {
149
149
  "path": "dist/chunks/worksheet-preview-DsDVWxIM.js",
@@ -152,13 +152,13 @@
152
152
  },
153
153
  {
154
154
  "path": "dist/document.js",
155
- "bytes": 120464,
156
- "sha256": "6681e5e41c3e0e383ad6a218fe66e792d9d749d62430525522e47642c78a57fc"
155
+ "bytes": 119328,
156
+ "sha256": "56ebef43f3b4dee1cac005c9a601d34340ec60008081d36276bc21169fe9ba8e"
157
157
  },
158
158
  {
159
159
  "path": "dist/document/viewer.js",
160
- "bytes": 10594,
161
- "sha256": "67c2b94e4bf2e719020092b2c20f3f87b1f16e2ce633e88ad9ccba5f7f45e2e0"
160
+ "bytes": 10599,
161
+ "sha256": "0c4421bf8ee99d90d4d613a4696b9fc36a806f77bf30a53dd9e57bc7ece896a7"
162
162
  },
163
163
  {
164
164
  "path": "dist/export.js",
@@ -232,13 +232,13 @@
232
232
  },
233
233
  {
234
234
  "path": "dist/mindmap.js",
235
- "bytes": 3468,
236
- "sha256": "e656b4e1fed6c9572327ae16aed0254132c653c026446652cc793f2d982623fd"
235
+ "bytes": 3455,
236
+ "sha256": "39c3e559a8a6985896471cc06ecc28292ad676fe0002c201c56fe3f49b90d4ec"
237
237
  },
238
238
  {
239
239
  "path": "dist/mindmap/viewer.js",
240
240
  "bytes": 122,
241
- "sha256": "fbbcad3ddfe7eefe09fcbadd93f8c1898eade512831a16692b6d8555124b4df9"
241
+ "sha256": "defbd1e80f5e8a6fdc61e92fa019ab741b3686fb2ecf3ba5c4cbc26f6da7dedd"
242
242
  },
243
243
  {
244
244
  "path": "dist/shared.js",
@@ -248,7 +248,7 @@
248
248
  {
249
249
  "path": "dist/spreadsheet.js",
250
250
  "bytes": 2873,
251
- "sha256": "80326ad4dc4c940fc2edc32db637475969e1383cca4a03839d45ccb3241860a3"
251
+ "sha256": "d7c50eacaf1b9b6b22aff0b7e776aa1117bd974ca3cf1ca27d51440ab0642d33"
252
252
  },
253
253
  {
254
254
  "path": "dist/spreadsheet/viewer.js",
@@ -262,8 +262,8 @@
262
262
  },
263
263
  {
264
264
  "path": "dist/styles.css",
265
- "bytes": 120397,
266
- "sha256": "3a7e076d7843019785a8ed272919d982c70332c2badfeadc698e86bc823f3c1a"
265
+ "bytes": 121932,
266
+ "sha256": "ed09fec23d83f2e499dc38db243985f0be141c8dbb96b7f3904ddf47d0ff3e50"
267
267
  },
268
268
  {
269
269
  "path": "dist/styles/callout.css",
@@ -770,6 +770,11 @@
770
770
  "bytes": 291,
771
771
  "sha256": "357dd9a8a2d59171ca8db708bd6c4056bd4f311737a37a843f03b198b4c20537"
772
772
  },
773
+ {
774
+ "path": "dist/types/engine/shared/color-preview.d.ts",
775
+ "bytes": 119,
776
+ "sha256": "c95b52d15fb4d33b8a27c138372188269171d8c390b17c4f2fbdf7699521f63d"
777
+ },
773
778
  {
774
779
  "path": "dist/types/engine/shared/comment-hint-position.d.ts",
775
780
  "bytes": 466,
@@ -800,6 +805,11 @@
800
805
  "bytes": 50,
801
806
  "sha256": "2fbe74026e1dd4012ae1c9310358057c1cc6afb91be24b47d824474b2b10b88a"
802
807
  },
808
+ {
809
+ "path": "dist/types/engine/shared/mind-map-defaults.d.ts",
810
+ "bytes": 223,
811
+ "sha256": "cda011131c8103b18fdd1ae6739451427fac53e9556d7d46b918bb9037e88074"
812
+ },
803
813
  {
804
814
  "path": "dist/types/engine/shared/mind-map-phase2.d.ts",
805
815
  "bytes": 50,
@@ -1108,7 +1118,7 @@
1108
1118
  {
1109
1119
  "path": "package.json",
1110
1120
  "bytes": 3977,
1111
- "sha256": "bb9fa9d232782ec1abe0d75792085ff312214e3ae3286bc52138226f61d4ce62"
1121
+ "sha256": "fe576ff8da220037f3aa5ecc59e92de70fc8ac3fbbb9067a518c1c9a277a3821"
1112
1122
  },
1113
1123
  {
1114
1124
  "path": "third-party-notices/@fast-csv__format@4.3.5-LICENSE.txt",
@@ -3046,12 +3056,12 @@
3046
3056
  "sha256": "869c30f368eb08735e779027b9f4bc9fea2f39624351856aebe42741f0bc0884"
3047
3057
  },
3048
3058
  {
3049
- "path": "third-party-notices/wendang-export@0.6.4-LICENSE.txt",
3059
+ "path": "third-party-notices/wendang-export@0.6.5-LICENSE.txt",
3050
3060
  "bytes": 1061,
3051
3061
  "sha256": "cbceba6740b3cbaa1d8c81c4bdf82fb7985c8c10cf5a31714b8ea2d62bef63e8"
3052
3062
  },
3053
3063
  {
3054
- "path": "third-party-notices/wendang-export@0.6.4-NOTICE.md.txt",
3064
+ "path": "third-party-notices/wendang-export@0.6.5-NOTICE.md.txt",
3055
3065
  "bytes": 3208,
3056
3066
  "sha256": "3f0fc9af9ed7a7709211332e9087e8d410aa12d739cabd44360395bdf395256e"
3057
3067
  },
@@ -3136,5 +3146,5 @@
3136
3146
  "sha256": "989ac42055978f5f90614f5fdfdd76a9010338df8388fc5724fae5d4f9fa1c1d"
3137
3147
  }
3138
3148
  ],
3139
- "digest": "3af0c0f9ee26daeaaf99291458a6b363cb2ca4b88e4dd5c303a68e4d181a168d"
3149
+ "digest": "49701a909ddda04e09dbaa2f80eb4a6bb66a90d6d373637db5e3d499feebbd90"
3140
3150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wendang-react",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "description": "Wendang 原生 React 文档、工作表和思维导图编辑与展示组件。",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -130,8 +130,8 @@
130
130
  "lowlight": "3.3.0",
131
131
  "numfmt": "4.0.1",
132
132
  "tiny-pinyin": "1.3.2",
133
- "wendang": "0.6.3",
134
- "wendang-export": "0.6.4"
133
+ "wendang": "0.6.4",
134
+ "wendang-export": "0.6.5"
135
135
  },
136
136
  "devDependencies": {
137
137
  "react": "19.3.1",
@@ -1 +0,0 @@
1
- "use client";import{closeHistory as t}from"@tiptap/pm/history";import{yUndoPluginKey as e}from"@tiptap/y-tiptap";import{p as n}from"./mind-map-delete-CVsxdXfs.js";import{readI18n as o}from"wendang/i18n";import{textDifference as r,MIND_MAP_MAX_TOPICS as i,mindMapId as a,mindMapTree as d,mindMapDescendants as s,mindMapOutline as l,projectMindSideMove as c,canMoveMindTopic as u,mindMapBranchSides as p,MIND_MAP_MAX_TEXT as f,readMindMap as m,MIND_MAP_VERSION as h}from"wendang/internal/mind-map";import{searchMindMap as g,topicTitle as v,topicField as M}from"wendang/internal/mind-map-phase2";function createMindMapController(y,I,x={}){var S;const b=/* @__PURE__ */new Set,A=/* @__PURE__ */new Map;let T=!1;const C=I(),N="number"==typeof C?null==(S=y.state.doc.nodeAt(C))?void 0:S.attrs.id:void 0;let k=!1;function composition(t){var e;if(t===k)return;k=t;const n=null==(e=y.storage)?void 0:e.mindMap;n&&(n.composing=Math.max(0,n.composing+(t?1:-1)))}function current(){if(T||y.isDestroyed)return null;const t=I();if("number"!=typeof t)return null;const e=y.state.doc.nodeAt(t);if("mindMap"!==(null==e?void 0:e.type.name)||e.attrs.id!==N)return null;const n=m(e.toJSON());return n?{node:e,pos:t,model:n}:null}function topicAt(t){const e=current();if(!e)return null;let n=null;return e.node.forEach((o,r)=>{o.attrs.id===t&&(n={node:o,pos:e.pos+r+1})}),n}function topicInsertPos(t){let e=t.pos+1;return t.node.forEach(t=>{"mindMapTopic"===t.type.name&&(e+=t.nodeSize)}),e}function fieldAt(t,e){const n=topicAt(t);if(!n)return null;if("title"===e)return{...n,text:v(n.node.toJSON())};let o=null;return n.node.forEach((t,r)=>{t.type.name===("description"===e?"mindMapDescription":"mindMapNote")&&(o={node:t,pos:n.pos+1+r,text:t.textContent})}),o}const editable=()=>!!current()&&y.isEditable;function structuralChange(n){var o;const r=current();if(r&&r.node.attrs.formatVersion<h){const t=n.doc.nodeAt(n.mapping.map(r.pos));"mindMap"===(null==t?void 0:t.type.name)&&n.setNodeMarkup(n.mapping.map(r.pos),void 0,{...t.attrs,formatVersion:h})}const i=null==(o=e.getState(y.state))?void 0:o.undoManager;null==i||i.stopCapturing(),y.view.dispatch(t(n)),null==i||i.stopCapturing()}function notify(){for(const t of b)t()}function onTransaction({transaction:t}){for(const[e,n]of A){const locate=t=>{let n=null;return t.descendants((t,o)=>"mindMapTopic"===t.type.name&&t.attrs.id===e.split("::")[0]?(n={node:t,pos:o},!1):!n),n},o=e.split("::")[1]||"title",i=locate(t.before),a=locate(t.doc);if(!i||!a){A.delete(e);continue}const getText=t=>"title"===o?v(t.toJSON()):M(t.toJSON(),o),d=r(getText(i.node),getText(a.node)),s=d.text.length-(d.to-d.from);n.boundaries=n.boundaries.map(t=>{const e=Math.max(0,Math.min(getText(i.node).length,t)),n=e<d.from?e:e>=d.to?e+s:d.from+d.text.length;return Math.max(0,Math.min(getText(a.node).length,n))})}notify()}function beginText(t,e="title"){var n,o,r;const i=fieldAt(t,e);if(!i)return;const a=i.text;A.set(`${t}::${e}`,{text:a,boundaries:Array.from({length:a.length+1},(t,e)=>e)});const d=null==(o=null==(n=x.awareness)?void 0:n.getLocalState())?void 0:o.mindMap;(null==d?void 0:d.blockId)===N&&(null==(r=x.awareness)||r.setLocalStateField("mindMap",{...d,topicId:t,editing:!0}))}function orderAt(t,e,n){var o,r,i;const a=(null==(o=e[n-1])?void 0:o.order)??((null==(r=e[n])?void 0:r.order)??0)-2048,d=(null==(i=e[n])?void 0:i.order)??a+2048,s=(a+d)/2;return s>a&&s<d&&Math.abs(s)<1e12&&d-a>Number.EPSILON*Math.max(1,Math.abs(a),Math.abs(d))*8?s:(e.forEach((e,n)=>{const o=topicAt(e.id);o&&t.setNodeMarkup(o.pos,void 0,{...o.node.attrs,order:1024*n})}),1024*n-512)}function freezeBranchSides(t,e){const n=p(e.model);for(const[e,o]of n){const n=topicAt(e);t.setNodeMarkup(n.pos,void 0,{...t.doc.nodeAt(n.pos).attrs,side:o})}return n}function insertTopic(t,e,n=o(y).t("mind.newTopic"),r="after",s){const l=current();if(!editable()||!l||l.model.topics.length>=i||!topicAt(t))return null;if(void 0!==s&&(t!==l.model.rootId||"down"===l.model.layout||-1!==s&&1!==s))return null;const c=d(l.model).filter(e=>e.parentId===t),u=c.findIndex(t=>t.id===e);if(e&&u<0)return null;const m=y.state.tr,h=orderAt(m,c,u>=0?u+("after"===r?1:0):c.length),g=a(),v=void 0!==s&&"both"!==l.model.layout&&s!==("left"===l.model.layout?-1:1),M="both"===l.model.layout||v?freezeBranchSides(m,l):p(l.model),I=s??(t===l.model.rootId?e?M.get(e):"left"===l.model.layout?-1:1:null),x=y.schema.nodes.mindMapTopic.create({id:g,parentId:t,order:h,side:I},n?y.schema.text(n.slice(0,f)):void 0);return v&&m.setNodeMarkup(l.pos,void 0,{...l.node.attrs,layout:"both"}),structuralChange(m.insert(topicInsertPos(l),x)),g}function move(t,e,n="child"){const o=current();if(!o||!editable())return!1;const r=d(o.model),i=r.find(t=>t.id===e);if(!i)return!1;const a="child"===n?e:i.parentId;if(!u(o.model,t,a)||t===e)return!1;const s=r.filter(e=>e.parentId===a&&e.id!==t),l=y.state.tr;let c;if("child"===n)c=s.length;else{const t=s.findIndex(t=>t.id===e);if(t<0)return!1;c="before"===n?t:t+1}const f=orderAt(l,s,c),m=topicAt(t),h=p(o.model);if(a===o.model.rootId)for(const e of r.filter(e=>e.parentId===a&&e.id!==t)){const t=topicAt(e.id);l.setNodeMarkup(t.pos,void 0,{...l.doc.nodeAt(t.pos).attrs,side:h.get(e.id)})}const g=a===o.model.rootId?h.get("child"===n?t:e)??("left"===o.model.layout?-1:1):null;return l.setNodeMarkup(m.pos,void 0,{...l.doc.nodeAt(m.pos).attrs,parentId:a,order:f,side:g}),structuralChange(l),!0}function removeMany(t){const e=current();if(!editable()||!e)return!1;const o=n(e.model,t);if(!o)return!1;const{ids:r}=o,i=[];e.node.forEach((t,n)=>{(r.has(t.attrs.id)||"mindMapRelation"===t.type.name&&(r.has(t.attrs.source)||r.has(t.attrs.target)))&&i.push({from:e.pos+1+n,to:e.pos+1+n+t.nodeSize})});const a=y.state.tr;"both"===e.model.layout&&freezeBranchSides(a,e);for(const t of i.reverse())a.delete(t.from,t.to);return structuralChange(a),!0}return y.on("transaction",onTransaction),y.on("update",notify),{context:x,snapshot:()=>{var t;return(null==(t=current())?void 0:t.model)??null},editable:editable,beginText:beginText,text:function text(t,e,n="title"){if(!editable()||e.length>("title"===n?f:4e3))return!1;let o=fieldAt(t,n);if(!o&&"title"!==n){const e=topicAt(t);if(!e)return!1;let r=e.pos+e.node.nodeSize-1;"description"===n&&e.node.forEach((t,n)=>{"mindMapNote"===t.type.name&&(r=e.pos+1+n)}),structuralChange(y.state.tr.insert(r,y.schema.nodes["description"===n?"mindMapDescription":"mindMapNote"].create())),o=fieldAt(t,n)}if(!o)return!1;const i=`${t}::${n}`;A.has(i)||beginText(t,n);const a=A.get(i),d=r(a.text,e);if(d.from===d.to&&!d.text)return!0;const s=o.pos+1+a.boundaries[d.from],l=o.pos+1+a.boundaries[d.to];if(s<o.pos+1||l>o.pos+1+o.text.length||s>l)return!1;const c=y.state.tr.insertText(d.text,s,l);y.view.dispatch(c);const u=A.get(i);return!!u&&(u.boundaries=[...u.boundaries.slice(0,d.from),...Array.from({length:d.text.length+1},(t,e)=>s-o.pos-1+e),...u.boundaries.slice(d.to+1)],u.text=e,!0)},composition:composition,patch:function patch(t,e){const n=topicAt(t);return!(!editable()||!n||(structuralChange(y.state.tr.setNodeMarkup(n.pos,void 0,{...n.node.attrs,...e})),0))},addParent:function addParent(t){const e=current(),n=topicAt(t);if(!e||!n||!editable()||t===e.model.rootId||e.model.topics.length>=500)return null;const o=d(e.model).find(e=>e.id===t),r=a(),i=y.state.tr;return"both"===e.model.layout&&freezeBranchSides(i,e),i.setNodeMarkup(n.pos,void 0,{...n.node.attrs,parentId:r,order:0}),i.insert(topicInsertPos(e),y.schema.nodes.mindMapTopic.create({id:r,parentId:o.parentId,order:o.order,side:p(e.model).get(t)??null},y.schema.text("父主题"))),structuralChange(i),r},indent:function indent(t,e=!1){const n=current();if(!n)return!1;const o=d(n.model),r=o.find(e=>e.id===t);if(!r||!r.parentId)return!1;if(e){const e=o.find(t=>t.id===r.parentId);return!!(null==e?void 0:e.parentId)&&move(t,e.id,"after")}const i=o.filter(t=>t.parentId===r.parentId),a=i.findIndex(e=>e.id===t);return a>0&&move(t,i[a-1].id)},format:function format(t,e,n,o,r){const i=fieldAt(t,"title"),a=y.schema.marks[o];if(!editable()||!i||!a||e<0||n>i.text.length||n<=e)return!1;const d=i.pos+1+e,s=i.pos+1+n,l=y.state.tr;return!r&&y.state.doc.rangeHasMark(d,s,a)?l.removeMark(d,s,a):l.addMark(d,s,a.create(r)),structuralChange(l),!0},clearFormat:function clearFormat(t,e,n,o){const r=fieldAt(t,"title");if(!editable()||!r||e<0||n>r.text.length||n<=e)return!1;const i=y.state.tr;if(o)for(const t of o){const o=y.schema.marks[t];o&&i.removeMark(r.pos+1+e,r.pos+1+n,o)}else i.removeMark(r.pos+1+e,r.pos+1+n);return structuralChange(i),!0},replace:function replace(t,e,n){const o=current();if(!o||!editable()||!t)return 0;const r=n?[n]:g(o.model,t),i=y.state.tr;if(r.length>5e3)return-1;const a=/* @__PURE__ */new Map;for(const t of r)a.set(`${t.id}::${t.field}`,(a.get(`${t.id}::${t.field}`)??0)+1);for(const[n,o]of a){const[r,i]=n.split("::"),a=fieldAt(r,i);if(a&&a.text.length+o*(e.length-t.length)>("title"===i?2e3:4e3))return-2}const d=r.flatMap(n=>{const o=fieldAt(n.id,n.field);return o&&o.text.slice(n.from,n.to).toLocaleLowerCase()===t.toLocaleLowerCase()?o.text.length+e.length-t.length>("title"===n.field?2e3:4e3)?[]:[{from:o.pos+1+n.from,to:o.pos+1+n.to}]:[]}).sort((t,e)=>e.from-t.from);for(const t of d)i.insertText(e,t.from,t.to);return d.length&&structuralChange(i),d.length},relation:function relation(t){const e=current();if(!(e&&editable()&&t.source!==t.target&&topicAt(t.source)&&topicAt(t.target)))return!1;let n=null;e.node.forEach((o,r)=>{"mindMapRelation"===o.type.name&&o.attrs.id===t.id&&(n={node:o,pos:e.pos+1+r})});const o=n,r={...t,id:t.id??a(),label:t.label.slice(0,200)};return structuralChange(o?y.state.tr.setNodeMarkup(o.pos,void 0,r):y.state.tr.insert(e.pos+e.node.nodeSize-1,y.schema.nodes.mindMapRelation.create(r))),!0},deleteRelation:function deleteRelation(t){const e=current();if(!e||!editable())return!1;const n=y.state.tr;let o=!1;return e.node.forEach((r,i)=>{"mindMapRelation"===r.type.name&&r.attrs.id===t&&(n.delete(e.pos+1+i,e.pos+1+i+r.nodeSize),o=!0)}),o&&structuralChange(n),o},hasActiveText:()=>A.size>0,endText:(t,e="title")=>{var n,o,r;A.delete(`${t}::${e}`);const i=null==(o=null==(n=x.awareness)?void 0:n.getLocalState())?void 0:o.mindMap;(null==i?void 0:i.blockId)===N&&(null==(r=x.awareness)||r.setLocalStateField("mindMap",{...i,editing:A.size>0}))},add:function add(t,e,n=o(y).t("mind.newTopic")){return insertTopic(t,e,n)},addRootChild:function addRootChild(t,e=o(y).t("mind.newTopic")){const n=current();return n?insertTopic(n.model.rootId,void 0,e,"after",t):null},addSibling:function addSibling(t,e,n=o(y).t("mind.newTopic")){const r=current();if(!r||t===r.model.rootId)return null;const i=d(r.model).find(e=>e.id===t);return(null==i?void 0:i.parentId)?insertTopic(i.parentId,t,n,e):null},move:move,moveToSide:function moveToSide(t,e,n){const o=current();if(!o||!editable())return!1;const r=c(o.model,t,e,n);if(!r)return!1;const i=y.state.tr;for(const t of r.topics){const e=o.model.topics.find(e=>e.id===t.id);if(e.parentId===t.parentId&&e.order===t.order&&e.side===t.side)continue;const n=topicAt(t.id);i.setNodeMarkup(n.pos,void 0,{...n.node.attrs,parentId:t.parentId,order:t.order,side:t.side??null})}return o.model.layout!==r.layout&&i.setNodeMarkup(o.pos,void 0,{...o.node.attrs,layout:r.layout}),i.docChanged&&structuralChange(i),!0},remove:function remove(t){return removeMany([t])},removeMany:removeMany,settings:function settings(t){const e=current();if(!editable()||!e)return!1;const n=y.state.tr;if(t.layout&&t.layout!==e.model.layout)for(const t of e.model.topics.filter(t=>t.parentId===e.model.rootId)){const e=topicAt(t.id);null!==e.node.attrs.side&&n.setNodeMarkup(e.pos,void 0,{...e.node.attrs,side:null})}return structuralChange(n.setNodeMarkup(e.pos,void 0,{...e.node.attrs,...t})),!0},copyBranch:function copyBranch(t){const e=current();if(!e)return[];const n=s(e.model,t),o=new Map((e.node.toJSON().content??[]).map(t=>{var e;return[String(null==(e=t.attrs)?void 0:e.id),t]}));return[...l(e.model).filter(t=>n.has(t.id)).map(t=>o.get(t.id)),...(e.node.toJSON().content??[]).filter(t=>{var e,o;return"mindMapRelation"===t.type&&n.has(String(null==(e=t.attrs)?void 0:e.source))&&n.has(String(null==(o=t.attrs)?void 0:o.target))})]},pasteBranch:function pasteBranch(t,e){var n,o,r,s;const l=current();if(!editable()||!l||!topicAt(t)||!e.length||e.filter(t=>"mindMapTopic"===t.type).length+l.model.topics.length>i)return null;const c=e.filter(t=>"mindMapTopic"===t.type);if(!c.length)return null;const u=new Map(c.map(t=>{var e;return[String(null==(e=t.attrs)?void 0:e.id),a()]})),p=d(l.model).filter(e=>e.parentId===t),f=c.map((e,n)=>{var o,r,i,a,d;return y.schema.nodeFromJSON({...e,attrs:{...e.attrs,id:u.get(String(null==(o=e.attrs)?void 0:o.id)),parentId:u.get(String(null==(r=e.attrs)?void 0:r.parentId))??t,order:u.has(String(null==(i=e.attrs)?void 0:i.parentId))?Number(null==(a=e.attrs)?void 0:a.order)||0:((null==(d=p.at(-1))?void 0:d.order)??-1)+1+n}})}),m=y.state.tr.insert(topicInsertPos(l),f);for(const t of e.filter(t=>"mindMapRelation"===t.type))u.has(String(null==(n=t.attrs)?void 0:n.source))&&u.has(String(null==(o=t.attrs)?void 0:o.target))&&m.insert(m.mapping.map(l.pos+l.node.nodeSize-1),y.schema.nodes.mindMapRelation.create({...t.attrs,id:a(),source:u.get(String(null==(r=t.attrs)?void 0:r.source)),target:u.get(String(null==(s=t.attrs)?void 0:s.target))}));return structuralChange(m),f[0].attrs.id},undo:()=>editable()&&y.commands.undo(),redo:()=>editable()&&y.commands.redo(),canUndo:()=>editable()&&y.can().undo(),canRedo:()=>editable()&&y.can().redo(),canExport:()=>{var t;return(null==(t=x.canExport)?void 0:t.call(x))??!1},status:()=>{var t;return(null==(t=x.status)?void 0:t.call(x))??""},subscribe:t=>(b.add(t),()=>b.delete(t)),dispose(){composition(!1),T=!0,y.off("transaction",onTransaction),y.off("update",notify),notify(),b.clear(),A.clear()}}}export{createMindMapController as c};
@@ -1 +0,0 @@
1
- "use client";import{createUniver as e,LocaleType as s,mergeLocales as t,CommandType as r}from"@univerjs/presets";import{UniverSheetsCorePreset as o}from"@univerjs/preset-sheets-core";import i from"@univerjs/preset-sheets-core/locales/zh-CN";import{UniverSheetsFilterPreset as l}from"@univerjs/preset-sheets-filter";import n from"@univerjs/preset-sheets-filter/locales/zh-CN";import{UniverSheetsSortPreset as a}from"@univerjs/preset-sheets-sort";import c from"@univerjs/preset-sheets-sort/locales/zh-CN";import"@univerjs/preset-sheets-core/lib/index.css";import"@univerjs/preset-sheets-filter/lib/index.css";import"@univerjs/preset-sheets-sort/lib/index.css";import{sanitizeNonFiniteNumbers as p}from"wendang/internal/workbook";function snapshotWorkbook(e){const{value:s,dropped:t}=p(e);if(t.length){const e=t.filter(e=>e.includes(".cellData."));console.warn(`[wendang] 工作表快照含 ${t.length} 处非有限数值,已清洗(内容字段 ${e.length} 处)`,t.slice(0,10))}return s}function editKey(e){return JSON.stringify(e,(e,s)=>"cellData"===e?Object.fromEntries(Object.entries(s??{}).map(([e,s])=>[e,Object.fromEntries(Object.entries(s).map(([e,s])=>{const t=s;if(!(null==t?void 0:t.f))return[e,t];const{v:r,t:o,...i}=t;return[e,i]}))])):s)}const u={"zh-TW":()=>Promise.all([import("@univerjs/preset-sheets-core/locales/zh-TW"),import("@univerjs/preset-sheets-filter/locales/zh-TW"),import("@univerjs/preset-sheets-sort/locales/zh-TW")]),"en-US":()=>Promise.all([import("@univerjs/preset-sheets-core/locales/en-US"),import("@univerjs/preset-sheets-filter/locales/en-US"),import("@univerjs/preset-sheets-sort/locales/en-US")]),"ja-JP":()=>Promise.all([import("@univerjs/preset-sheets-core/locales/ja-JP"),import("@univerjs/preset-sheets-filter/locales/ja-JP"),import("@univerjs/preset-sheets-sort/locales/ja-JP")]),"ko-KR":()=>Promise.all([import("@univerjs/preset-sheets-core/locales/ko-KR"),import("@univerjs/preset-sheets-filter/locales/ko-KR"),import("@univerjs/preset-sheets-sort/locales/ko-KR")]),"es-ES":()=>Promise.all([import("@univerjs/preset-sheets-core/locales/es-ES"),import("@univerjs/preset-sheets-filter/locales/es-ES"),import("@univerjs/preset-sheets-sort/locales/es-ES")])},d={"zh-CN":s.ZH_CN,"zh-TW":s.ZH_TW,"en-US":s.EN_US,"ja-JP":s.JA_JP,"ko-KR":s.KO_KR,"es-ES":s.ES_ES};function createWorksheetEngine(p,h,m,v={}){const{univer:k,univerAPI:f}=e({locale:s.ZH_CN,region:Object.values(s).includes(h.workbook.locale)?h.workbook.locale:s.ZH_CN,darkMode:"dark"===v.theme,locales:{[s.ZH_CN]:t(i,n,c)},presets:[o({container:p,header:!0,ribbonType:"collapsed",footer:{statisticBar:!1,zoomSlider:!1}}),l(),a()]});let j;try{j=f.createWorkbook(h.workbook)}catch(e){throw k.dispose(),e}let E=null,b=0,w=!1;const snapshot=()=>E??(E={type:"workbook",formatVersion:1,workbook:snapshotWorkbook(j.save())});let S=editKey(snapshot()),g=!1,y=!1;const W=f.addEvent(f.Event.SheetEditStarted,()=>{y=!0}),C=f.addEvent(f.Event.SheetEditEnded,()=>{y=!1}),K=f.addEvent(f.Event.CommandExecuted,e=>{if(e.type!==r.MUTATION)return;if(E=null,g||e.id.startsWith("formula."))return;const s=editKey(snapshot());s!==S&&(S=s,m())});return{snapshot:snapshot,setEditable:e=>j.setEditable(e),setTheme:e=>f.toggleDarkMode("dark"===e),async setLocale(e){const r=++b,o=d[e]??s.ZH_CN;if(Object.hasOwn(u,e)){const s=await u[e]();if(w||r!==b)return;f.loadLocales(o,t(...s.map(e=>e.default)))}w||r!==b||f.setLocale(o)},isEditing:()=>y,async finishEditing(){await j.endEditingAsync(!0),await f.getFormula().onCalculationResultApplied(15e3),E=null},async settleCalculation(){await f.getFormula().onCalculationResultApplied(15e3),E=null},replace(e){g=!0;const s=snapshot();try{f.disposeUnit(j.getId()),j=f.createWorkbook(e.workbook),E=null,S=editKey(snapshot())}catch(e){throw j=f.createWorkbook(s.workbook),E=null,S=editKey(snapshot()),e}finally{g=!1}},dispose(){w=!0,b++,K.dispose(),W.dispose(),C.dispose(),k.dispose()}}}export{createWorksheetEngine};