@univerjs/sheets-zen-editor 0.10.12-nightly.202510221114 → 0.10.12-nightly.202510251119
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/lib/cjs/index.js +3 -3
- package/lib/es/index.js +233 -199
- package/lib/index.js +233 -199
- package/lib/umd/index.js +3 -3
- package/package.json +10 -10
package/lib/umd/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(d,
|
|
1
|
+
(function(d,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("rxjs"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-ui","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","react/jsx-runtime","@univerjs/design","react","rxjs","@univerjs/sheets"],r):(d=typeof globalThis<"u"?globalThis:d||self,r(d.UniverSheetsZenEditor={},d.UniverCore,d.UniverDocsUi,d.UniverEngineRender,d.UniverSheetsUi,d.UniverUi,d.React,d.UniverDesign,d.React,d.rxjs,d.UniverSheets))})(this,(function(d,r,v,$,h,l,I,k,_,O,N){"use strict";var fe=Object.defineProperty;var he=(d,r,v)=>r in d?fe(d,r,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[r]=v;var T=(d,r,v)=>he(d,typeof r!="symbol"?r+"":r,v);var U;const D={id:"zen-editor.command.open-zen-editor",type:r.CommandType.COMMAND,handler:async e=>{var P;const n=e.get(l.IZenZoneService),t=e.get(v.IEditorService),i=e.get(h.IEditorBridgeService),s=e.get(r.IUniverInstanceService),o=e.get(l.ISidebarService);o.visible&&(o.close(),await r.delayAnimationFrame()),n.open();const c=t.getEditor(r.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(c==null)return!1;const a=i.getLatestEditCellState();if(a==null)return!1;const u=(P=a.documentLayoutObject.documentModel)==null?void 0:P.getSnapshot();if(u==null)return!1;s.focusUnit(r.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body:g,drawings:E,drawingsOrder:f,tableSource:S,settings:C}=r.Tools.deepClone(u),p={...c.getDocumentData(),body:g,drawings:E,drawingsOrder:f,tableSource:S,settings:C},m=[{startOffset:0,endOffset:0,collapsed:!0}];return c.focus(),c.setDocumentData(p,m),c.clearUndoRedoHistory(),!0}},y={id:"zen-editor.command.cancel-zen-edit",type:r.CommandType.COMMAND,handler:async e=>{const n=e.get(l.IZenZoneService),t=e.get(h.IEditorBridgeService),i=e.get(r.IUniverInstanceService),s=e.get(l.ISidebarService);s.visible&&(s.close(),await r.delayAnimationFrame()),n.close();const o=i.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);return o?(i.focusUnit(o.getUnitId()),t.refreshEditCellState(),!0):!1}},M={id:"zen-editor.command.confirm-zen-edit",type:r.CommandType.COMMAND,handler:async e=>{var g;const n=e.get(l.IZenZoneService),t=e.get(h.IEditorBridgeService),i=e.get(r.IUniverInstanceService),s=e.get(v.IEditorService),o=e.get(l.ISidebarService);o.visible&&(o.close(),await r.delayAnimationFrame()),n.close();const c=s.getEditor(r.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(c==null)return!1;const a=e.get($.IRenderManagerService),u=i.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(u){const E=u.getUnitId(),f=(g=a.getRenderById(E))==null?void 0:g.with(h.EditingRenderController);if(f){const S=r.Tools.deepClone(c.getDocumentData());S.documentStyle.documentFlavor=r.DocumentFlavor.UNSPECIFIED,f.submitCellData(new r.DocumentDataModel(S))}return i.focusUnit(u.getUnitId()),t.refreshEditCellState(),!0}return!1}},W="sheets-zen-editor.config",B={};function j({ref:e,...n}){const{icon:t,id:i,className:s,extend:o,...c}=n,a=`univerjs-icon univerjs-icon-${i} ${s||""}`.trim(),u=_.useRef(`_${G()}`);return A(t,`${i}`,{defIds:t.defIds,idSuffix:u.current},{ref:e,className:a,...c},o)}function A(e,n,t,i,s){return _.createElement(e.tag,{key:n,...q(e,t,s),...i},(H(e,t).children||[]).map((o,c)=>A(o,`${n}-${e.tag}-${c}`,t,void 0,s)))}function q(e,n,t){const i={...e.attrs};t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1),e.tag==="mask"&&i.id&&(i.id=i.id+n.idSuffix),Object.entries(i).forEach(([o,c])=>{o==="mask"&&typeof c=="string"&&(i[o]=c.replace(/url\(#(.*)\)/,`url(#$1${n.idSuffix})`))});const{defIds:s}=n;return!s||s.length===0||(e.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+n.idSuffix),Object.entries(i).forEach(([o,c])=>{typeof c=="string"&&(i[o]=c.replace(/url\(#(.*)\)/,`url(#$1${n.idSuffix})`))})),i}function H(e,n){var i;const{defIds:t}=n;return!t||t.length===0?e:e.tag==="defs"&&((i=e.children)!=null&&i.length)?{...e,children:e.children.map(s=>typeof s.attrs.id=="string"&&t&&t.includes(s.attrs.id)?{...s,attrs:{...s.attrs,id:s.attrs.id+n.idSuffix}}:s)}:e}function G(){return Math.random().toString(36).substring(2,8)}j.displayName="UniverIcon";const X={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},L=_.forwardRef(function(n,t){return _.createElement(j,Object.assign({},n,{id:"check-mark-icon",ref:t,icon:X}))});L.displayName="CheckMarkIcon";const J={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},F=_.forwardRef(function(n,t){return _.createElement(j,Object.assign({},n,{id:"close-icon",ref:t,icon:J}))});F.displayName="CloseIcon";class Q{constructor(){T(this,"_position",null);T(this,"_position$",new O.BehaviorSubject(null));T(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(n){this._position=n,this._refresh(n)}getPosition(){return this._position}_refresh(n){this._position$.next(n)}}const z=r.createIdentifier("univer.sheet-zen-editor-manager.service"),ee="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT",te={id:r.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:r.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function ne(){const e=_.useRef(null),n=l.useDependency(z),t=l.useDependency(v.IEditorService),i=l.useDependency(r.ICommandService);_.useEffect(()=>{const a=e.current;if(!a)return;const u=t.register({editorUnitId:r.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:te,scrollBar:!0,backScrollOffset:100},a),g=new ResizeObserver(()=>{n.setPosition(a.getBoundingClientRect())});return g.observe(a),()=>{u.dispose(),g.unobserve(a)}},[]);function s(){const a=t.getEditor(r.DOCS_ZEN_EDITOR_UNIT_ID_KEY);a==null||a.blur(),i.executeCommand(y.id)}function o(){const a=t.getEditor(r.DOCS_ZEN_EDITOR_UNIT_ID_KEY);a==null||a.blur(),i.executeCommand(M.id)}const c="univer-flex univer-w-7 univer-cursor-pointer univer-items-center univer-justify-center univer-transition-colors";return I.jsxs("div",{className:"univer-absolute univer-inset-0 univer-size-full univer-bg-white dark:!univer-bg-gray-800",children:[I.jsxs("div",{className:"univer-absolute univer-right-6 univer-top-2 univer-z-10 univer-flex univer-items-center univer-justify-center",children:[I.jsx("span",{className:k.clsx(c,`
|
|
2
2
|
univer-text-red-500
|
|
3
3
|
hover:univer-text-red-600
|
|
4
|
-
`),onClick:
|
|
4
|
+
`),onClick:s,children:I.jsx(F,{className:"univer-size-5"})}),I.jsx("span",{className:k.clsx(c,`
|
|
5
5
|
univer-text-green-500
|
|
6
6
|
hover:univer-text-green-600
|
|
7
|
-
`),onClick:
|
|
7
|
+
`),onClick:o,children:I.jsx(L,{className:"univer-size-5"})})]}),I.jsx("div",{ref:e,className:"univer-absolute univer-inset-0 univer-size-full"})]})}function ie(e){const n=e.get(h.IEditorBridgeService);return{id:D.id,type:l.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifyIcon",hidden$:h.getCurrentExclusiveRangeInterest$(e),disabled$:n.currentEditCell$.pipe(O.switchMap(t=>h.getCurrentRangeDisable$(e,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission,N.WorksheetSetCellValuePermission,N.WorksheetSetCellStylePermission],rangeTypes:[N.RangeProtectionPermissionEditPoint]}).pipe(O.map(i=>{var s,o,c,a;return i||((a=(c=(o=(s=t==null?void 0:t.documentLayoutObject.documentModel)==null?void 0:s.getBody())==null?void 0:o.customBlocks)==null?void 0:c.length)!=null?a:0)>0}))))}}const re={[l.ContextMenuPosition.MAIN_AREA]:{[l.ContextMenuGroup.OTHERS]:{[D.id]:{order:2,menuItemFactory:ie}}}},se={id:M.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>V(e),binding:l.KeyCode.ENTER|l.MetaKeys.ALT},oe={id:y.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>V(e),binding:l.KeyCode.ESC};function V(e){return e.getContextValue(r.FOCUSING_DOC)&&e.getContextValue(r.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(r.EDITOR_ACTIVATED)&&!e.getContextValue(r.FOCUSING_EDITOR_STANDALONE)}var ce=Object.getOwnPropertyDescriptor,ae=(e,n,t,i)=>{for(var s=i>1?void 0:i?ce(n,t):n,o=e.length-1,c;o>=0;o--)(c=e[o])&&(s=c(s)||s);return s},R=(e,n)=>(t,i)=>n(t,i,e);let b=class extends r.Disposable{constructor(e,n,t,i){super(),this._zenZoneService=e,this._commandService=n,this._menuManagerService=t,this._shortcutService=i,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(ee,ne))}_initCommands(){[D,y,M].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(re)}_initShortcuts(){[se,oe].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};b=ae([R(0,l.IZenZoneService),R(1,r.ICommandService),R(2,l.IMenuManagerService),R(3,l.IShortcutService)],b);var de=Object.getOwnPropertyDescriptor,le=(e,n,t,i)=>{for(var s=i>1?void 0:i?de(n,t):n,o=e.length-1,c;o>=0;o--)(c=e[o])&&(s=c(s)||s);return s},Y=(e,n)=>(t,i)=>n(t,i,e);let Z=class extends r.RxDisposable{constructor(e,n){super(),this._zenEditorManagerService=e,this._renderManagerService=n,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(O.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:n,height:t}=e,i=h.getEditorObject(r.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);i!=null&&requestIdleCallback(()=>{i.engine.resizeBySize(n,t),this._calculatePagePosition(i),this._scrollToTop()})})}_calculatePagePosition(e){const{document:n,scene:t,docBackground:i}=e,s=t==null?void 0:t.getParent(),{width:o,height:c,pageMarginLeft:a,pageMarginTop:u}=n;if(s==null||o===Number.POSITIVE_INFINITY||c===Number.POSITIVE_INFINITY)return;const{width:g,height:E}=s;let f=0;const S=u;let C=0,w=0,p=Number.POSITIVE_INFINITY;const{scaleX:m,scaleY:P}=t.getAncestorScale();g>(o+a*2)*m?(f=g/2-o*m/2,f/=m,C=(g-a*2)/m,p=0):(f=a,C=o+a*2,p=(C-g/m)/2),E>c?w=(E-u*2)/P:w=c+u*2,t.resize(C,w),n.translate(f,S),i.translate(f,S);const x=t.getViewport(v.VIEWPORT_KEY.VIEW_MAIN);if(p!==Number.POSITIVE_INFINITY&&x!=null){const ve=x.transScroll2ViewportScrollValue(p,0).x;x.scrollToBarPos({x:ve})}return this}_scrollToTop(){var t;const e=(t=this._renderManagerService.getRenderById(r.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:t.with(v.DocBackScrollRenderController),n={startOffset:0,endOffset:0};e&&e.scrollToRange(n)}};Z=le([Y(0,z),Y(1,$.IRenderManagerService)],Z);var ue=Object.getOwnPropertyDescriptor,ge=(e,n,t,i)=>{for(var s=i>1?void 0:i?ue(n,t):n,o=e.length-1,c;o>=0;o--)(c=e[o])&&(s=c(s)||s);return s},K=(e,n)=>(t,i)=>n(t,i,e);d.UniverSheetsZenEditorPlugin=(U=class extends r.Plugin{constructor(n=B,t,i){super(),this._config=n,this._injector=t,this._configService=i;const{menu:s,...o}=r.merge({},B,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(W,o),this._initializeDependencies(this._injector)}_initializeDependencies(n){[[b],[Z],[z,{useClass:Q}]].forEach(i=>n.add(i))}onReady(){this._injector.get(b)}onSteady(){this._injector.get(Z)}},T(U,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),T(U,"type",r.UniverInstanceType.UNIVER_SHEET),U),d.UniverSheetsZenEditorPlugin=ge([K(1,r.Inject(r.Injector)),K(2,r.IConfigService)],d.UniverSheetsZenEditorPlugin),d.CancelZenEditCommand=y,d.ConfirmZenEditCommand=M,d.OpenZenEditorCommand=D,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-zen-editor",
|
|
3
|
-
"version": "0.10.12-nightly.
|
|
3
|
+
"version": "0.10.12-nightly.202510251119",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Zen Editor plugin for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -64,15 +64,15 @@
|
|
|
64
64
|
"rxjs": ">=7.0.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@univerjs/icons": "^0.
|
|
68
|
-
"@univerjs/core": "0.10.12-nightly.
|
|
69
|
-
"@univerjs/design": "0.10.12-nightly.
|
|
70
|
-
"@univerjs/docs": "0.10.12-nightly.
|
|
71
|
-
"@univerjs/
|
|
72
|
-
"@univerjs/docs-ui": "0.10.12-nightly.
|
|
73
|
-
"@univerjs/
|
|
74
|
-
"@univerjs/ui": "0.10.12-nightly.
|
|
75
|
-
"@univerjs/sheets
|
|
67
|
+
"@univerjs/icons": "^1.0.2",
|
|
68
|
+
"@univerjs/core": "0.10.12-nightly.202510251119",
|
|
69
|
+
"@univerjs/design": "0.10.12-nightly.202510251119",
|
|
70
|
+
"@univerjs/docs": "0.10.12-nightly.202510251119",
|
|
71
|
+
"@univerjs/engine-render": "0.10.12-nightly.202510251119",
|
|
72
|
+
"@univerjs/docs-ui": "0.10.12-nightly.202510251119",
|
|
73
|
+
"@univerjs/sheets-ui": "0.10.12-nightly.202510251119",
|
|
74
|
+
"@univerjs/ui": "0.10.12-nightly.202510251119",
|
|
75
|
+
"@univerjs/sheets": "0.10.12-nightly.202510251119"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"postcss": "^8.5.6",
|