@univerjs/docs-ui 0.1.17 → 0.2.1
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 +4 -3
- package/lib/es/index.js +2208 -1545
- package/lib/index.css +1 -1
- package/lib/locale/en-US.json +13 -1
- package/lib/locale/ru-RU.json +13 -1
- package/lib/locale/zh-CN.json +13 -1
- package/lib/types/commands/commands/doc-header-footer.command.d.ts +24 -0
- package/lib/types/commands/operations/doc-header-footer-panel.operation.d.ts +6 -0
- package/lib/types/controllers/doc-header-footer.controller.d.ts +35 -0
- package/lib/types/controllers/menu/menu.d.ts +1 -0
- package/lib/types/controllers/render-controllers/back-scroll.render-controller.d.ts +9 -5
- package/lib/types/controllers/render-controllers/doc.render-controller.d.ts +4 -2
- package/lib/types/controllers/render-controllers/text-selection.render-controller.d.ts +1 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/locale/zh-CN.d.ts +12 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +2 -1
- package/lib/types/services/doc-mark-selection.service.d.ts +27 -0
- package/lib/types/services/doc-popup-manager.service.d.ts +3 -1
- package/lib/types/views/header-footer/panel/DocHeaderFooterOptions.d.ts +6 -0
- package/lib/types/views/header-footer/panel/DocHeaderFooterPanel.d.ts +3 -0
- package/lib/types/views/header-footer/panel/component-name.d.ts +16 -0
- package/lib/types/views/header-footer/text-bubble.d.ts +20 -0
- package/lib/umd/index.js +4 -3
- package/package.json +18 -16
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
(function(g,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("@univerjs/docs"),require("@wendellhu/redi/react-bindings"),require("react"),require("rxjs"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","@univerjs/engine-render","@univerjs/docs","@wendellhu/redi/react-bindings","react","rxjs","@univerjs/design"],a):(g=typeof globalThis<"u"?globalThis:g||self,a(g.UniverDocsUi={},g.UniverCore,g["@wendellhu/redi"],g.UniverUi,g.UniverEngineRender,g.UniverDocs,g["@wendellhu/redi/react-bindings"],g.React,g.rxjs,g.UniverDesign))})(this,function(g,a,C,l,I,d,we,$e,T,Ve){"use strict";var Pn=Object.defineProperty;var Un=(g,a,C)=>a in g?Pn(g,a,{enumerable:!0,configurable:!0,writable:!0,value:C}):g[a]=C;var b=(g,a,C)=>Un(g,typeof a!="symbol"?a+"":a,C);var ee;const me={undo:!0,redo:!0,font:!0,fontSize:!0,bold:!0,italic:!0,strikethrough:!0,underline:!0,textColor:!0,fillColor:!0,horizontalAlignMode:!0,verticalAlignMode:!0,textWrapMode:!0,textRotateMode:!0},Se={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},fe={layout:{docContainerConfig:Se,toolbarConfig:me}},ve="DocUI";function R(i){return i.getContextValue(a.FOCUSING_DOC)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(a.FOCUSING_COMMON_DRAWINGS)}function je(i){return i.getContextValue(a.FOCUSING_DOC)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(a.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE)&&!i.getContextValue(a.FOCUSING_COMMON_DRAWINGS)}const We={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_UP,preconditions:R,staticParameters:{direction:a.Direction.UP}},He={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_DOWN,preconditions:R,staticParameters:{direction:a.Direction.DOWN}},ze={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_LEFT,preconditions:R,staticParameters:{direction:a.Direction.LEFT}},ke={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_RIGHT,preconditions:R,staticParameters:{direction:a.Direction.RIGHT}},Ge={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_UP|l.MetaKeys.SHIFT,preconditions:R,staticParameters:{direction:a.Direction.UP}},Ye={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_DOWN|l.MetaKeys.SHIFT,preconditions:R,staticParameters:{direction:a.Direction.DOWN}},Ke={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_LEFT|l.MetaKeys.SHIFT,preconditions:R,staticParameters:{direction:a.Direction.LEFT}},Xe={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_RIGHT|l.MetaKeys.SHIFT,preconditions:R,staticParameters:{direction:a.Direction.RIGHT}},qe={id:d.SelectAllOperation.id,binding:l.KeyCode.A|l.MetaKeys.CTRL_COMMAND,preconditions:i=>i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&(i.getContextValue(a.FOCUSING_DOC)||i.getContextValue(a.EDITOR_ACTIVATED))};var Ze=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(i,e,t,n)=>{for(var r=n>1?void 0:n?Je(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ze(e,t,r),r},Ce=(i,e)=>(t,n)=>e(t,n,i);let ne=class{constructor(i,e,t){b(this,"_docContainer");b(this,"getComponent",i=>{if(this._docContainer=i,!i.getContentRef().current)throw new Error("container is not ready")});b(this,"changeLocale",i=>{this._localeService.setLocale(i)});this._config=i,this._localeService=e,this._injector=t}getUIConfig(){return{injector:this._injector,config:this._config,changeLocale:this.changeLocale,getComponent:this.getComponent}}getContentRef(){return this._docContainer.getContentRef()}UIDidMount(i){if(this._docContainer)return i(this._docContainer)}getDocContainer(){return this._docContainer}};ne=Qe([Ce(1,C.Inject(a.LocaleService)),Ce(2,C.Inject(C.Injector))],ne);var et=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(i,e,t,n)=>{for(var r=n>1?void 0:n?tt(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&et(e,t,r),r},z=(i,e)=>(t,n)=>e(t,n,i);let L=class extends a.RxDisposable{constructor(e,t,n,r,s){super();b(this,"_docContainerController");b(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._localeService=t,this._injector=n,this._textSelectionRenderManager=r,this._layoutService=s,this._docContainerController=this._injector.createInstance(ne,e),this._registerContainer()}_registerContainer(){this._layoutService&&this.disposeWithMe(this._layoutService.registerContainerElement(this._textSelectionRenderManager.__getEditorContainer()))}getDocContainerController(){return this._docContainerController}};L=nt([z(1,C.Inject(a.LocaleService)),z(2,C.Inject(C.Injector)),z(3,I.ITextSelectionRenderManager),z(4,C.Optional(l.ILayoutService))],L);const k="UI_PLUGIN_DOCS",ie=`${k}_COLOR_PICKER_COMPONENT`,Ie=`${k}_FONT_FAMILY_COMPONENT`,Oe=`${k}_FONT_FAMILY_ITEM_COMPONENT`,Te=`${k}_FONT_SIZE_COMPONENT`;var be={exports:{}},G={};/**
|
|
1
|
+
(function(O,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/ui"),require("@wendellhu/redi"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("rxjs"),require("@wendellhu/redi/react-bindings"),require("react"),require("@univerjs/design"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","@wendellhu/redi","@univerjs/docs","@univerjs/engine-render","rxjs","@wendellhu/redi/react-bindings","react","@univerjs/design","clsx"],a):(O=typeof globalThis<"u"?globalThis:O||self,a(O.UniverDocsUi={},O.UniverCore,O.UniverUi,O["@wendellhu/redi"],O.UniverDocs,O.UniverEngineRender,O.rxjs,O["@wendellhu/redi/react-bindings"],O.React,O.UniverDesign,O.clsx))})(this,function(O,a,d,E,u,I,b,w,Y,j,ct){"use strict";var ni=Object.defineProperty;var ii=(O,a,d)=>a in O?ni(O,a,{enumerable:!0,configurable:!0,writable:!0,value:d}):O[a]=d;var M=(O,a,d)=>ii(O,typeof a!="symbol"?a+"":a,d);var pe;function F(i){return i.getContextValue(a.FOCUSING_DOC)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(a.FOCUSING_COMMON_DRAWINGS)}function lt(i){return i.getContextValue(a.FOCUSING_DOC)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(a.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE)&&!i.getContextValue(a.FOCUSING_COMMON_DRAWINGS)}const dt=10,ut=6;function ht(){return a.Tools.generateRandomId(ut)}function pt(i){const e=i.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class gt{constructor(){M(this,"_cache",new a.LRUMap(dt))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}clear(){this._cache.clear()}}const De=new gt;function ge(i){const e=i.style,t={},n=i.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{t.bl=a.BooleanNumber.TRUE;break}case"s":{t.st={s:a.BooleanNumber.TRUE};break}case"u":{t.ul={s:a.BooleanNumber.TRUE};break}case"i":{t.it=a.BooleanNumber.TRUE;break}case"sub":case"sup":{t.va=n==="sup"?a.BaselineOffset.SUPERSCRIPT:a.BaselineOffset.SUBSCRIPT;break}}for(let o=0;o<e.length;o++){const r=e[o],s=e.getPropertyValue(r);switch(r){case"font-family":{t.ff=s;break}case"font-size":{const c=Number.parseInt(s);Number.isNaN(c)||(s.endsWith("pt")?t.fs=c:s.endsWith("px")&&(t.fs=I.pixelToPt(c)));break}case"font-style":{s==="italic"&&(t.it=a.BooleanNumber.TRUE);break}case"font-weight":{(Number(s)>400||String(s)==="bold")&&(t.bl=a.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(s)?t.ul={s:a.BooleanNumber.TRUE}:/overline/.test(s)?t.ol={s:a.BooleanNumber.TRUE}:/line-through/.test(s)&&(t.st={s:a.BooleanNumber.TRUE});break}case"color":{const c=new a.ColorKit(s);c.isValid&&(t.cl={rgb:c.toRgbString()});break}case"background-color":{const c=new a.ColorKit(s);c.isValid&&(t.bg={rgb:c.toRgbString()});break}}}return t}function mt(i){const e=new DOMParser,t=`<x-univer id="univer-root">${i}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function ye(i,e){const t=i.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(i)}const he=class he{constructor(){M(this,"_styleCache",new Map);M(this,"_styleRules",[]);M(this,"_afterProcessRules",[])}static use(e){if(this._pluginList.includes(e))throw new Error(`Univer paste plugin ${e.name} already added`);this._pluginList.push(e)}convert(e){const t=he._pluginList.find(r=>r.checkPasteType(e)),n=mt(e),o={dataStream:"",textRuns:[]};return t&&(this._styleRules=[...t.stylesRules],this._afterProcessRules=[...t.afterProcessRules]),this._styleCache.clear(),this._process(null,n==null?void 0:n.childNodes,o),this._styleCache.clear(),this._styleRules=[],this._afterProcessRules=[],o}_process(e,t,n){var o,r;for(const s of t)if(s.nodeType===Node.TEXT_NODE){if(((o=s.nodeValue)==null?void 0:o.trim())==="")continue;const c=(r=s.nodeValue)==null?void 0:r.replace(/[\r\n]/g,"");let l;e&&this._styleCache.has(e)&&(l=this._styleCache.get(e)),n.dataStream+=c,l&&Object.getOwnPropertyNames(l).length&&n.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:l})}else{if(a.skipParseTagNames.includes(s.nodeName.toLowerCase()))continue;if(s.nodeType===Node.ELEMENT_NODE){const c=e?this._styleCache.get(e):{},l=this._styleRules.find(({filter:m})=>ye(s,m)),p=l?l.getStyle(s):ge(s);this._styleCache.set(s,{...c,...p});const{childNodes:_}=s;this._process(s,_,n);const f=this._afterProcessRules.find(({filter:m})=>ye(s,m));f&&f.handler(n,s)}}}};M(he,"_pluginList",[]);let W=he;const Pe={name:"univer-doc-paste-plugin-lark",checkPasteType(i){return/lark-record-clipboard/i.test(i)},stylesRules:[{filter:["s"],getStyle(i){const e=ge(i);return{st:{s:a.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(i){return i.tagName==="DIV"&&/ace-line/i.test(i.className)},handler(i){i.paragraphs==null&&(i.paragraphs=[]),i.paragraphs.push({startIndex:i.dataStream.length}),i.dataStream+="\r"}}]};function Ae(i){const e=i.style,t={};for(let n=0;n<e.length;n++){const o=e[n],r=e.getPropertyValue(o);switch(o){case"margin-top":{const s=Number.parseInt(r);t.spaceAbove=/pt/.test(r)?I.ptToPixel(s):s;break}case"margin-bottom":{const s=Number.parseInt(r);t.spaceBelow=/pt/.test(r)?I.ptToPixel(s):s;break}case"line-height":{const s=Number.parseFloat(r);t.lineSpacing=s;break}}}return Object.getOwnPropertyNames(t).length?t:null}const Ne={name:"univer-doc-paste-plugin-word",checkPasteType(i){return/word|mso/i.test(i)},stylesRules:[{filter:["b"],getStyle(i){const e=ge(i);return{bl:a.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(i){return i.tagName==="P"},handler(i,e){i.paragraphs==null&&(i.paragraphs=[]);const t={startIndex:i.dataStream.length},n=Ae(e);n&&(t.paragraphStyle=n),i.paragraphs.push(t),i.dataStream+="\r"}}]},xe={name:"univer-doc-paste-plugin-univer",checkPasteType(i){return/UniverNormal/i.test(i)},stylesRules:[],afterProcessRules:[{filter(i){return i.tagName==="P"&&/UniverNormal/i.test(i.className)},handler(i,e){i.paragraphs==null&&(i.paragraphs=[]);const t={startIndex:i.dataStream.length},n=Ae(e);n&&(t.paragraphStyle=n),i.paragraphs.push(t),i.dataStream+="\r"}}]};function Ue(i,e){const{st:t,ed:n,ts:o={}}=e,{ff:r,fs:s,it:c,bl:l,ul:p,st:_,ol:f,bg:m,cl:h,va:v}=o;let g=i.slice(t,n);const S=[];return c===a.BooleanNumber.TRUE&&(g=`<i>${g}</i>`),v===a.BaselineOffset.SUPERSCRIPT?g=`<sup>${g}</sup>`:v===a.BaselineOffset.SUBSCRIPT&&(g=`<sub>${g}</sub>`),(p==null?void 0:p.s)===a.BooleanNumber.TRUE&&(g=`<u>${g}</u>`),(_==null?void 0:_.s)===a.BooleanNumber.TRUE&&(g=`<s>${g}</s>`),l===a.BooleanNumber.TRUE&&(g=`<strong>${g}</strong>`),r&&S.push(`font-family: ${r}`),h&&S.push(`color: ${h.rgb}`),s&&S.push(`font-size: ${s}pt`),f&&S.push("text-decoration: overline"),m&&S.push(`background: ${m.rgb}`),S.length?`<span style="${S.join("; ")};">${g}</span>`:g}function me(i,e,t){const{dataStream:n,textRuns:o=[]}=i;let r=e;const s=[];for(const c of o){const{st:l,ed:p}=c;a.Tools.hasIntersectionBetweenTwoRanges(e,t,l,p)&&(l>r?(s.push(n.slice(r,l)),s.push(Ue(n,{...c,ed:Math.min(p,t)}))):s.push(Ue(n,{...c,st:r,ed:Math.min(p,t)}))),r=Math.max(e,Math.min(p,t))}return r!==t&&s.push(n.slice(r,t)),s.join("")}function Fe(i,e=!0){var t;if(e&&((t=i.paragraphs)!=null&&t.length)){const{dataStream:n,paragraphs:o=[]}=i;let r="",s=-1;for(const c of o){const{startIndex:l,paragraphStyle:p={}}=c,{spaceAbove:_,spaceBelow:f,lineSpacing:m}=p,h=[];_!=null&&(typeof _=="number"?h.push(`margin-top: ${_}px`):h.push(`margin-top: ${_.v}px`)),f!=null&&(typeof f=="number"?h.push(`margin-bottom: ${f}px`):h.push(`margin-bottom: ${f.v}px`)),m!=null&&h.push(`line-height: ${m}`),l>s+1?r+=`<p class="UniverNormal" ${h.length?`style="${h.join("; ")};"`:""}>${me(i,s+1,l)}</p>`:r+=`<p class="UniverNormal" ${h.length?`style="${h.join("; ")};"`:""}></p>`,s=l}return s!==n.length&&(r+=me(i,s,n.length)),r}else return me(i,0,i.dataStream.length)}class _t{convert(e){if(e.length===0)throw new Error("The bodyList length at least to be 1");if(e.length===1)return Fe(e[0]);let t="";for(const n of e)t+='<p className="UniverNormal">',t+=Fe(n,!1),t+="</p>";return t}}var ft=Object.defineProperty,St=Object.getOwnPropertyDescriptor,vt=(i,e,t,n)=>{for(var o=n>1?void 0:n?St(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&ft(e,t,o),o},z=(i,e)=>(t,n)=>e(t,n,i);W.use(Ne),W.use(Pe),W.use(xe);function It(i){const e=i.replace(/\n/g,"\r"),t=[];for(let n=0;n<e.length;n++)e[n]==="\r"&&t.push({startIndex:n});return{dataStream:e,paragraphs:t}}const k=E.createIdentifier("doc.clipboard-service");let _e=class extends a.Disposable{constructor(e,t,n,o,r){super();M(this,"_clipboardHooks",[]);M(this,"_htmlToUDM",new W);M(this,"_umdToHtml",new _t);this._univerInstanceService=e,this._logService=t,this._commandService=n,this._clipboardInterfaceService=o,this._textSelectionManagerService=r}async copy(){const e=this._getDocumentBodyInRanges();if(e.length===0)return!1;try{const t=this._textSelectionManagerService.getActiveRange(),n=!!(t!=null&&t.segmentId);this._setClipboardData(e,!n)}catch(t){return this._logService.error("[DocClipboardService] copy failed",t),!1}return!0}async cut(){return this._cut()}async paste(e){const t=await this._generateBodyFromClipboardItems(e);return this._paste(t)}async legacyPaste(e,t){const n=this._generateBodyFromHtmlAndText(e,t);return this._paste(n)}async _cut(){var r;const{segmentId:e,endOffset:t,style:n}=(r=this._textSelectionManagerService.getActiveRange())!=null?r:{},o=this._textSelectionManagerService.getSelections();if(e==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),t==null||o==null)return!1;this.copy();try{let s=t;for(const l of o){const{startOffset:p,endOffset:_}=l;p==null||_==null||_<=t&&(s-=_-p)}const c=[{startOffset:s,endOffset:s,style:n}];return this._commandService.executeCommand(u.CutContentCommand.id,{segmentId:e,textRanges:c})}catch{return this._logService.error("[DocClipboardController] cut content failed"),!1}}async _paste(e){let t=a.normalizeBody(e);this._clipboardHooks.forEach(l=>{l.onBeforePaste&&(t=l.onBeforePaste(t))});const n=this._textSelectionManagerService.getActiveRange(),{segmentId:o,endOffset:r,style:s}=n||{},c=this._textSelectionManagerService.getSelections();if(o==null&&this._logService.error("[DocClipboardController] segmentId does not exist!"),r==null||c==null)return!1;try{let l=r;for(const _ of c){const{startOffset:f,endOffset:m}=_;f==null||m==null||m<=r&&(l+=t.dataStream.length-(m-f))}const p=[{startOffset:l,endOffset:l,style:s}];return this._commandService.executeCommand(u.InnerPasteCommand.id,{body:t,segmentId:o,textRanges:p})}catch{return this._logService.error("[DocClipboardController]","clipboard is empty."),!1}}async _setClipboardData(e,t=!0){const n=ht(),o=e.length>1?e.map(s=>s.dataStream).join(`
|
|
2
|
+
`):e[0].dataStream;let r=this._umdToHtml.convert(e);return e.length===1&&t&&(r=r.replace(/(<[a-z]+)/,(s,c)=>`${c} data-copy-id="${n}"`),De.set(n,e[0])),this._clipboardInterfaceService.write(o,r)}addClipboardHook(e){return this._clipboardHooks.push(e),a.toDisposable(()=>{const t=this._clipboardHooks.indexOf(e);t>-1&&this._clipboardHooks.splice(t,1)})}_getDocumentBodyInRanges(){const e=this._textSelectionManagerService.getSelections(),t=this._textSelectionManagerService.getActiveRange(),n=this._univerInstanceService.getCurrentUniverDocInstance(),o=[],r=n==null?void 0:n.getBody();if(e==null||n==null||r==null||t==null)return o;const{segmentId:s}=t;for(const c of e){const{startOffset:l,endOffset:p,collapsed:_}=c;if(_||l==null||p==null)continue;const f=u.getDeleteSelection({startOffset:l,endOffset:p,collapsed:_},r),m=n.getSelfOrHeaderFooterModel(s).sliceBody(f.startOffset,f.endOffset);if(m!=null){if(m.customRanges){const h=[];m.customRanges.forEach(S=>{S.startIndex===S.endIndex&&h.push(S)}),m.customRanges=m.customRanges.filter(S=>h.indexOf(S)===-1);let v="",g=0;h.forEach(S=>{v+=m.dataStream.slice(g,S.endIndex),g=S.endIndex+1}),v+=m.dataStream.slice(g,m.dataStream.length),m.dataStream=v}o.push(m)}}return o}async _generateBodyFromClipboardItems(e){try{let t="",n="";for(const o of e)for(const r of o.types)r===d.PLAIN_TEXT_CLIPBOARD_MIME_TYPE?n=await o.getType(r).then(s=>s&&s.text()):r===d.HTML_CLIPBOARD_MIME_TYPE&&(t=await o.getType(r).then(s=>s&&s.text()));return this._generateBodyFromHtmlAndText(t,n)}catch(t){return Promise.reject(t)}}_generateBodyFromHtmlAndText(e,t){if(!e){if(t)return It(t);throw new Error("[DocClipboardService] html and text cannot be both empty!")}const n=pt(e);if(n){const o=De.get(n);if(o)return o}return this._htmlToUDM.convert(e)}};_e=vt([z(0,a.IUniverInstanceService),z(1,a.ILogService),z(2,a.ICommandService),z(3,d.IClipboardInterfaceService),z(4,E.Inject(u.TextSelectionManagerService))],_e);var Ot=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,Tt=(i,e,t,n)=>{for(var o=n>1?void 0:n?Ct(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Ot(e,t,o),o},te=(i,e)=>(t,n)=>e(t,n,i);const Le=1.5;O.DocBackScrollRenderController=class extends a.RxDisposable{constructor(e,t,n,o,r){super(),this._context=e,this._textSelectionManagerService=t,this._editorService=n,this._univerInstanceService=o,this._renderManagerService=r,this._init()}_init(){this._textSelectionManagerService.textSelection$.pipe(b.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{isEditing:t,unitId:n}=e;t&&this._scrollToSelection(n)})}scrollToRange(e,t){var c;const n=(c=this._renderManagerService.getRenderById(e))==null?void 0:c.with(u.DocSkeletonManagerService),o=n==null?void 0:n.getSkeleton();if(!o)return;const{startOffset:r}=t,s=o.findNodePositionByCharIndex(r);this.scrollToNode(e,s)}scrollToNode(e,t){var ee;const n=this._getDocObject(),o=(ee=this._renderManagerService.getRenderById(e))==null?void 0:ee.with(u.DocSkeletonManagerService),r=o==null?void 0:o.getSkeleton();if(n==null||r==null)return;const s=n.document.getOffsetConfig(),{docsLeft:c,docsTop:l}=s,p=new I.NodePositionConvertToCursor(s,r),{contentBoxPointGroup:_}=p.getRangePointData(t,t),{left:f,top:m,height:h}=I.getAnchorBounding(_),v=f+c,g=m+l,S=n.scene.getViewport(u.VIEWPORT_KEY.VIEW_MAIN),C=!!this._editorService.getEditor(e);if(S==null)return;const{left:T,top:P,right:A,bottom:D}=S.getBounding().viewBound;let R=0,U=0;const L=C?0:100;g<P?R=g-P-L:g>D-h&&(R=g-D+h+L),v<T?U=v-T:v>A-Le&&(U=v-A+Le);const B=S.transViewportScroll2ScrollValue(U,R);S.scrollBy(B)}_scrollToSelection(e){const t=this._textSelectionManagerService.getActiveRange();if(t==null)return;const{collapsed:n,startNodePosition:o}=t;n&&this.scrollToNode(e,o)}_getDocObject(){return u.getDocObject(this._univerInstanceService,this._renderManagerService)}},O.DocBackScrollRenderController=Tt([te(1,E.Inject(u.TextSelectionManagerService)),te(2,d.IEditorService),te(3,E.Inject(a.IUniverInstanceService)),te(4,I.IRenderManagerService)],O.DocBackScrollRenderController);const Be={undo:!0,redo:!0,font:!0,fontSize:!0,bold:!0,italic:!0,strikethrough:!0,underline:!0,textColor:!0,fillColor:!0,horizontalAlignMode:!0,verticalAlignMode:!0,textWrapMode:!0,textRotateMode:!0},we={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},$e={layout:{docContainerConfig:we,toolbarConfig:Be}},He="DocUI",Et={id:u.MoveCursorOperation.id,binding:d.KeyCode.ARROW_UP,preconditions:F,staticParameters:{direction:a.Direction.UP}},bt={id:u.MoveCursorOperation.id,binding:d.KeyCode.ARROW_DOWN,preconditions:F,staticParameters:{direction:a.Direction.DOWN}},Rt={id:u.MoveCursorOperation.id,binding:d.KeyCode.ARROW_LEFT,preconditions:F,staticParameters:{direction:a.Direction.LEFT}},Mt={id:u.MoveCursorOperation.id,binding:d.KeyCode.ARROW_RIGHT,preconditions:F,staticParameters:{direction:a.Direction.RIGHT}},Dt={id:u.MoveSelectionOperation.id,binding:d.KeyCode.ARROW_UP|d.MetaKeys.SHIFT,preconditions:F,staticParameters:{direction:a.Direction.UP}},yt={id:u.MoveSelectionOperation.id,binding:d.KeyCode.ARROW_DOWN|d.MetaKeys.SHIFT,preconditions:F,staticParameters:{direction:a.Direction.DOWN}},Pt={id:u.MoveSelectionOperation.id,binding:d.KeyCode.ARROW_LEFT|d.MetaKeys.SHIFT,preconditions:F,staticParameters:{direction:a.Direction.LEFT}},At={id:u.MoveSelectionOperation.id,binding:d.KeyCode.ARROW_RIGHT|d.MetaKeys.SHIFT,preconditions:F,staticParameters:{direction:a.Direction.RIGHT}},Nt={id:u.SelectAllOperation.id,binding:d.KeyCode.A|d.MetaKeys.CTRL_COMMAND,preconditions:i=>i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&(i.getContextValue(a.FOCUSING_DOC)||i.getContextValue(a.EDITOR_ACTIVATED))};var xt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,Ft=(i,e,t,n)=>{for(var o=n>1?void 0:n?Ut(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&xt(e,t,o),o},Ve=(i,e)=>(t,n)=>e(t,n,i);let fe=class{constructor(i,e,t){M(this,"_docContainer");M(this,"getComponent",i=>{if(this._docContainer=i,!i.getContentRef().current)throw new Error("container is not ready")});M(this,"changeLocale",i=>{this._localeService.setLocale(i)});this._config=i,this._localeService=e,this._injector=t}getUIConfig(){return{injector:this._injector,config:this._config,changeLocale:this.changeLocale,getComponent:this.getComponent}}getContentRef(){return this._docContainer.getContentRef()}UIDidMount(i){if(this._docContainer)return i(this._docContainer)}getDocContainer(){return this._docContainer}};fe=Ft([Ve(1,E.Inject(a.LocaleService)),Ve(2,E.Inject(E.Injector))],fe);var Lt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,wt=(i,e,t,n)=>{for(var o=n>1?void 0:n?Bt(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Lt(e,t,o),o},ne=(i,e)=>(t,n)=>e(t,n,i);let K=class extends a.RxDisposable{constructor(e,t,n,o,r){super();M(this,"_docContainerController");M(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._localeService=t,this._injector=n,this._textSelectionRenderManager=o,this._layoutService=r,this._docContainerController=this._injector.createInstance(fe,e),this._registerContainer()}_registerContainer(){this._layoutService&&this.disposeWithMe(this._layoutService.registerContainerElement(this._textSelectionRenderManager.__getEditorContainer()))}getDocContainerController(){return this._docContainerController}};K=wt([ne(1,E.Inject(a.LocaleService)),ne(2,E.Inject(E.Injector)),ne(3,I.ITextSelectionRenderManager),ne(4,E.Optional(d.ILayoutService))],K);const ie="UI_PLUGIN_DOCS",Se=`${ie}_COLOR_PICKER_COMPONENT`,je=`${ie}_FONT_FAMILY_COMPONENT`,We=`${ie}_FONT_FAMILY_ITEM_COMPONENT`,ke=`${ie}_FONT_SIZE_COMPONENT`;var Ge={exports:{}},oe={};/**
|
|
2
3
|
* @license React
|
|
3
4
|
* react-jsx-runtime.production.min.js
|
|
4
5
|
*
|
|
@@ -6,5 +7,5 @@
|
|
|
6
7
|
*
|
|
7
8
|
* This source code is licensed under the MIT license found in the
|
|
8
9
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var it=$e,rt=Symbol.for("react.element"),ot=Symbol.for("react.fragment"),st=Object.prototype.hasOwnProperty,at=it.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ct={key:!0,ref:!0,__self:!0,__source:!0};function Re(i,e,t){var n,r={},s=null,o=null;t!==void 0&&(s=""+t),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(n in e)st.call(e,n)&&!ct.hasOwnProperty(n)&&(r[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)r[n]===void 0&&(r[n]=e[n]);return{$$typeof:rt,type:i,key:s,ref:o,props:r,_owner:at.current}}G.Fragment=ot,G.jsx=Re,G.jsxs=Re,be.exports=G;var lt=be.exports;const dt={docsUiCanvasBackground:"univer-docs-ui-canvas-background"},ut=()=>lt.jsx("div",{className:dt.docsUiCanvasBackground});function ht(i){const e=i.get(a.ICommandService);return{id:d.SetInlineFormatBoldCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var o;const s=r.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=y(i);if(c==null)return;const u=(o=c.ts)==null?void 0:o.bl;t.next(u===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function pt(i){const e=i.get(a.ICommandService);return{id:d.SetInlineFormatItalicCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var o;const s=r.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=y(i);if(c==null)return;const u=(o=c.ts)==null?void 0:o.it;t.next(u===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function _t(i){const e=i.get(a.ICommandService);return{id:d.SetInlineFormatUnderlineCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var o;const s=r.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=y(i);if(c==null)return;const u=(o=c.ts)==null?void 0:o.ul;t.next((u==null?void 0:u.s)===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function gt(i){const e=i.get(a.ICommandService);return{id:d.SetInlineFormatStrikethroughCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var o;const s=r.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=y(i);if(c==null)return;const u=(o=c.ts)==null?void 0:o.st;t.next((u==null?void 0:u.s)===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function mt(i){const e=i.get(a.ICommandService);return{id:d.SetInlineFormatSubscriptCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"SubscriptSingle",tooltip:"toolbar.subscript",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var o;const s=r.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=y(i);if(c==null)return;const u=(o=c.ts)==null?void 0:o.va;t.next(u===a.BaselineOffset.SUBSCRIPT)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function St(i){const e=i.get(a.ICommandService);return{id:d.SetInlineFormatSuperscriptCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"SuperscriptSingle",tooltip:"toolbar.superscript",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var o;const s=r.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=y(i);if(c==null)return;const u=(o=c.ts)==null?void 0:o.va;t.next(u===a.BaselineOffset.SUPERSCRIPT)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function ft(i){const e=i.get(a.ICommandService);return{id:d.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,label:Ie,positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_FAMILY_LIST.map(t=>({label:{name:Oe,hoverable:!0},value:t.value})),value$:new T.Observable(t=>{const n=l.FONT_FAMILY_LIST[0].value,r=e.onCommandExecuted(s=>{var c;const o=s.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatFontFamilyCommand.id){const u=y(i);if(u==null)return;const h=(c=u.ts)==null?void 0:c.ff;t.next(h!=null?h:n)}});return t.next(n),r.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function vt(i){const e=i.get(a.ICommandService);return{id:d.SetInlineFormatFontSizeCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Te,props:{min:1,max:400}},positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_SIZE_LIST,value$:new T.Observable(t=>{const r=e.onCommandExecuted(s=>{var c;const o=s.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatFontSizeCommand.id){const u=y(i);if(u==null)return;const h=(c=u.ts)==null?void 0:c.fs;t.next(h!=null?h:14)}});return t.next(14),r.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function Ct(i){const e=i.get(a.ICommandService),t=i.get(a.ThemeService);return{id:d.SetInlineFormatTextColorCommand.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON_SELECTOR,positions:[l.MenuPosition.TOOLBAR_START],selections:[{label:{name:ie,hoverable:!1}}],value$:new T.Observable(n=>{const r=t.getCurrentTheme().textColor,s=e.onCommandExecuted(o=>{if(o.id===d.SetInlineFormatTextColorCommand.id){const c=o.params.value;n.next(c!=null?c:r)}});return n.next(r),s.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function It(i){const e=i.get(a.ICommandService);return{id:d.AlignLeftCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"LeftJustifyingSingle",tooltip:"toolbar.alignLeft",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var o;const s=r.id;if(s===d.SetTextSelectionsOperation.id||s===d.AlignOperationCommand.id){const c=Y(i);if(c==null)return;const u=(o=c.paragraphStyle)==null?void 0:o.horizontalAlign;t.next(u===a.HorizontalAlign.LEFT)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function Ot(i){const e=i.get(a.ICommandService);return{id:d.AlignCenterCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"HorizontallySingle",tooltip:"toolbar.alignCenter",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var o;const s=r.id;if(s===d.SetTextSelectionsOperation.id||s===d.AlignOperationCommand.id){const c=Y(i);if(c==null)return;const u=(o=c.paragraphStyle)==null?void 0:o.horizontalAlign;t.next(u===a.HorizontalAlign.CENTER)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function Tt(i){const e=i.get(a.ICommandService);return{id:d.AlignRightCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"RightJustifyingSingle",tooltip:"toolbar.alignRight",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var o;const s=r.id;if(s===d.SetTextSelectionsOperation.id||s===d.AlignOperationCommand.id){const c=Y(i);if(c==null)return;const u=(o=c.paragraphStyle)==null?void 0:o.horizontalAlign;t.next(u===a.HorizontalAlign.RIGHT)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function bt(i){const e=i.get(a.ICommandService);return{id:d.AlignJustifyCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"AlignTextBothSingle",tooltip:"toolbar.alignJustify",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var o;const s=r.id;if(s===d.SetTextSelectionsOperation.id||s===d.AlignOperationCommand.id){const c=Y(i);if(c==null)return;const u=(o=c.paragraphStyle)==null?void 0:o.horizontalAlign;t.next(u===a.HorizontalAlign.JUSTIFIED)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function Rt(i){return{id:d.OrderListCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"OrderSingle",tooltip:"toolbar.order",positions:[l.MenuPosition.TOOLBAR_START],hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function Mt(i){return{id:d.BulletListCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"UnorderSingle",tooltip:"toolbar.unorder",positions:[l.MenuPosition.TOOLBAR_START],hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function yt(i){return{id:d.ResetInlineFormatTextBackgroundColorCommand.id,type:l.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:d.SetInlineFormatTextBackgroundColorCommand.id}}function Et(i){const e=i.get(a.ICommandService),t=i.get(a.ThemeService);return{id:d.SetInlineFormatTextBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON_SELECTOR,positions:[l.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:ie,hoverable:!1}}],value$:new T.Observable(n=>{const r=t.getCurrentTheme().primaryColor,s=e.onCommandExecuted(o=>{if(o.id===d.SetInlineFormatTextBackgroundColorCommand.id){const c=o.params.value;n.next(c!=null?c:r)}});return n.next(r),s.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function y(i){var u;const e=i.get(a.IUniverInstanceService),t=i.get(d.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),r=t.getActiveRange();if(n==null||r==null)return;const s=(u=n.getBody())==null?void 0:u.textRuns;if(s==null)return;const{startOffset:o}=r;let c;for(let h=0;h<s.length;h++){const _=s[h],m=s[h+1];if(m&&m.st===m.ed&&o===m.st){c=m;break}if(_.st<=o&&o<=_.ed){c=_;break}}return c}function Y(i){var u;const e=i.get(a.IUniverInstanceService),t=i.get(d.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),r=t.getActiveRange();if(n==null||r==null)return;const s=(u=n.getBody())==null?void 0:u.paragraphs;if(s==null)return;const{startOffset:o}=r;let c=-1;for(const h of s){const{startIndex:_}=h;if(o>c&&o<=_)return h;c=_}return null}var Dt=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Ut=(i,e,t,n)=>{for(var r=n>1?void 0:n?Pt(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Dt(e,t,r),r},D=(i,e)=>(t,n)=>e(t,n,i);let B=class extends a.Disposable{constructor(i,e,t,n,r,s,o,c){super(),this._config=i,this._injector=e,this._componentManager=t,this._layoutService=n,this._editorService=r,this._menuService=s,this._uiPartsService=o,this._univerInstanceService=c,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(ie,Ve.ColorPicker)),this.disposeWithMe(i.register(Ie,l.FontFamily)),this.disposeWithMe(i.register(Oe,l.FontFamilyItem)),this.disposeWithMe(i.register(Te,l.FontSize))}_initMenus(){const{menu:i={}}=this._config;[ht,pt,_t,gt,mt,St,vt,ft,Ct,It,Ot,Tt,bt,Rt,Mt,yt,Et].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e),i))})}_init(){this._initCustomComponents(),this._initMenus(),this._initDocBackground(),this._initFocusHandler()}_initDocBackground(){const i=this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_DOC)[0].getUnitId();if(i==null)return;this._editorService.isEditor(i)||this.disposeWithMe(this._uiPartsService.registerComponent(l.BuiltInUIPart.CONTENT,()=>we.connectInjector(ut,this._injector)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(a.UniverInstanceType.UNIVER_DOC,()=>{this._injector.get(I.ITextSelectionRenderManager).focus()}))}};B=Ut([a.OnLifecycle(a.LifecycleStages.Rendered,B),D(1,C.Inject(C.Injector)),D(2,C.Inject(l.ComponentManager)),D(3,l.ILayoutService),D(4,l.IEditorService),D(5,l.IMenuService),D(6,l.IUIPartsService),D(7,a.IUniverInstanceService)],B);const Nt={id:d.BreakLineCommand.id,preconditions:je,binding:l.KeyCode.ENTER},xt={id:d.DeleteLeftCommand.id,preconditions:R,binding:l.KeyCode.BACKSPACE},At={id:d.DeleteRightCommand.id,preconditions:R,binding:l.KeyCode.DELETE},Lt=10,Bt=6;function Ft(){return a.Tools.generateRandomId(Bt)}function wt(i){const e=i.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class $t{constructor(){b(this,"_cache",new a.LRUMap(Lt))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}clear(){this._cache.clear()}}const Me=new $t;function re(i){const e=i.style,t={},n=i.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{t.bl=a.BooleanNumber.TRUE;break}case"s":{t.st={s:a.BooleanNumber.TRUE};break}case"u":{t.ul={s:a.BooleanNumber.TRUE};break}case"i":{t.it=a.BooleanNumber.TRUE;break}case"sub":case"sup":{t.va=n==="sup"?a.BaselineOffset.SUPERSCRIPT:a.BaselineOffset.SUBSCRIPT;break}}for(let r=0;r<e.length;r++){const s=e[r],o=e.getPropertyValue(s);switch(s){case"font-family":{t.ff=o;break}case"font-size":{const c=Number.parseInt(o);Number.isNaN(c)||(o.endsWith("pt")?t.fs=c:o.endsWith("px")&&(t.fs=I.pixelToPt(c)));break}case"font-style":{o==="italic"&&(t.it=a.BooleanNumber.TRUE);break}case"font-weight":{(Number(o)>400||String(o)==="bold")&&(t.bl=a.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(o)?t.ul={s:a.BooleanNumber.TRUE}:/overline/.test(o)?t.ol={s:a.BooleanNumber.TRUE}:/line-through/.test(o)&&(t.st={s:a.BooleanNumber.TRUE});break}case"color":{const c=new a.ColorKit(o);c.isValid&&(t.cl={rgb:c.toRgbString()});break}case"background-color":{const c=new a.ColorKit(o);c.isValid&&(t.bg={rgb:c.toRgbString()});break}}}return t}function Vt(i){const e=new DOMParser,t=`<x-univer id="univer-root">${i}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function ye(i,e){const t=i.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(i)}const Q=class Q{constructor(){b(this,"_styleCache",new Map);b(this,"_styleRules",[]);b(this,"_afterProcessRules",[])}static use(e){if(this._pluginList.includes(e))throw new Error(`Univer paste plugin ${e.name} already added`);this._pluginList.push(e)}convert(e){const t=Q._pluginList.find(s=>s.checkPasteType(e)),n=Vt(e),r={dataStream:"",textRuns:[]};return t&&(this._styleRules=[...t.stylesRules],this._afterProcessRules=[...t.afterProcessRules]),this._styleCache.clear(),this._process(null,n==null?void 0:n.childNodes,r),this._styleCache.clear(),this._styleRules=[],this._afterProcessRules=[],r}_process(e,t,n){var r,s;for(const o of t)if(o.nodeType===Node.TEXT_NODE){if(((r=o.nodeValue)==null?void 0:r.trim())==="")continue;const c=(s=o.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let u;e&&this._styleCache.has(e)&&(u=this._styleCache.get(e)),n.dataStream+=c,u&&Object.getOwnPropertyNames(u).length&&n.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:u})}else{if(a.skipParseTagNames.includes(o.nodeName.toLowerCase()))continue;if(o.nodeType===Node.ELEMENT_NODE){const c=e?this._styleCache.get(e):{},u=this._styleRules.find(({filter:S})=>ye(o,S)),h=u?u.getStyle(o):re(o);this._styleCache.set(o,{...c,...h});const{childNodes:_}=o;this._process(o,_,n);const m=this._afterProcessRules.find(({filter:S})=>ye(o,S));m&&m.handler(n,o)}}}};b(Q,"_pluginList",[]);let N=Q;const Ee={name:"univer-doc-paste-plugin-lark",checkPasteType(i){return/lark-record-clipboard/i.test(i)},stylesRules:[{filter:["s"],getStyle(i){const e=re(i);return{st:{s:a.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(i){return i.tagName==="DIV"&&/ace-line/i.test(i.className)},handler(i){i.paragraphs==null&&(i.paragraphs=[]),i.paragraphs.push({startIndex:i.dataStream.length}),i.dataStream+="\r"}}]};function De(i){const e=i.style,t={};for(let n=0;n<e.length;n++){const r=e[n],s=e.getPropertyValue(r);switch(r){case"margin-top":{const o=Number.parseInt(s);t.spaceAbove=/pt/.test(s)?I.ptToPixel(o):o;break}case"margin-bottom":{const o=Number.parseInt(s);t.spaceBelow=/pt/.test(s)?I.ptToPixel(o):o;break}case"line-height":{const o=Number.parseFloat(s);t.lineSpacing=o;break}}}return Object.getOwnPropertyNames(t).length?t:null}const Pe={name:"univer-doc-paste-plugin-word",checkPasteType(i){return/word|mso/i.test(i)},stylesRules:[{filter:["b"],getStyle(i){const e=re(i);return{bl:a.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(i){return i.tagName==="P"},handler(i,e){i.paragraphs==null&&(i.paragraphs=[]);const t={startIndex:i.dataStream.length},n=De(e);n&&(t.paragraphStyle=n),i.paragraphs.push(t),i.dataStream+="\r"}}]},Ue={name:"univer-doc-paste-plugin-univer",checkPasteType(i){return/UniverNormal/i.test(i)},stylesRules:[],afterProcessRules:[{filter(i){return i.tagName==="P"&&/UniverNormal/i.test(i.className)},handler(i,e){i.paragraphs==null&&(i.paragraphs=[]);const t={startIndex:i.dataStream.length},n=De(e);n&&(t.paragraphStyle=n),i.paragraphs.push(t),i.dataStream+="\r"}}]};function Ne(i,e){const{st:t,ed:n,ts:r={}}=e,{ff:s,fs:o,it:c,bl:u,ul:h,st:_,ol:m,bg:S,cl:f,va:O}=r;let p=i.slice(t,n);const v=[];return c===a.BooleanNumber.TRUE&&(p=`<i>${p}</i>`),O===a.BaselineOffset.SUPERSCRIPT?p=`<sup>${p}</sup>`:O===a.BaselineOffset.SUBSCRIPT&&(p=`<sub>${p}</sub>`),(h==null?void 0:h.s)===a.BooleanNumber.TRUE&&(p=`<u>${p}</u>`),(_==null?void 0:_.s)===a.BooleanNumber.TRUE&&(p=`<s>${p}</s>`),u===a.BooleanNumber.TRUE&&(p=`<strong>${p}</strong>`),s&&v.push(`font-family: ${s}`),f&&v.push(`color: ${f.rgb}`),o&&v.push(`font-size: ${o}pt`),m&&v.push("text-decoration: overline"),S&&v.push(`background: ${S.rgb}`),v.length?`<span style="${v.join("; ")};">${p}</span>`:p}function oe(i,e,t){const{dataStream:n,textRuns:r=[]}=i;let s=e;const o=[];for(const c of r){const{st:u,ed:h}=c;a.Tools.hasIntersectionBetweenTwoRanges(e,t,u,h)&&(u>s?(o.push(n.slice(s,u)),o.push(Ne(n,{...c,ed:Math.min(h,t)}))):o.push(Ne(n,{...c,st:s,ed:Math.min(h,t)}))),s=Math.max(e,Math.min(h,t))}return s!==t&&o.push(n.slice(s,t)),o.join("")}function xe(i,e=!0){var t;if(e&&((t=i.paragraphs)!=null&&t.length)){const{dataStream:n,paragraphs:r=[]}=i;let s="",o=-1;for(const c of r){const{startIndex:u,paragraphStyle:h={}}=c,{spaceAbove:_,spaceBelow:m,lineSpacing:S}=h,f=[];_!=null&&(typeof _=="number"?f.push(`margin-top: ${_}px`):f.push(`margin-top: ${_.v}px`)),m!=null&&(typeof m=="number"?f.push(`margin-bottom: ${m}px`):f.push(`margin-bottom: ${m.v}px`)),S!=null&&f.push(`line-height: ${S}`),u>o+1?s+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}>${oe(i,o+1,u)}</p>`:s+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}></p>`,o=u}return o!==n.length&&(s+=oe(i,o,n.length)),s}else return oe(i,0,i.dataStream.length)}class jt{convert(e){if(e.length===0)throw new Error("The bodyList length at least to be 1");if(e.length===1)return xe(e[0]);let t="";for(const n of e)t+='<p className="UniverNormal">',t+=xe(n,!1),t+="</p>";return t}}var Wt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,zt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ht(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Wt(e,t,r),r},F=(i,e)=>(t,n)=>e(t,n,i);N.use(Pe),N.use(Ee),N.use(Ue);function kt(i){const e=i.replace(/\n/g,"\r"),t=[];for(let n=0;n<e.length;n++)e[n]==="\r"&&t.push({startIndex:n});return{dataStream:e,paragraphs:t}}const w=C.createIdentifier("doc.clipboard-service");let se=class extends a.Disposable{constructor(e,t,n,r,s){super();b(this,"_clipboardHooks",[]);b(this,"_htmlToUDM",new N);b(this,"_umdToHtml",new jt);this._univerInstanceService=e,this._logService=t,this._commandService=n,this._clipboardInterfaceService=r,this._textSelectionManagerService=s}async copy(){const e=this._getDocumentBodyInRanges();if(e.length===0)return!1;try{this._setClipboardData(e)}catch(t){return this._logService.error("[DocClipboardService] copy failed",t),!1}return!0}async cut(){return this._cut()}async paste(e){const t=await this._generateBodyFromClipboardItems(e);return this._paste(t)}async legacyPaste(e,t){const n=this._generateBodyFromHtmlAndText(e,t);return this._paste(n)}async _cut(){var s;const{segmentId:e,endOffset:t,style:n}=(s=this._textSelectionManagerService.getActiveRange())!=null?s:{},r=this._textSelectionManagerService.getSelections();if(e==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),t==null||r==null)return!1;this.copy();try{let o=t;for(const u of r){const{startOffset:h,endOffset:_}=u;h==null||_==null||_<=t&&(o-=_-h)}const c=[{startOffset:o,endOffset:o,style:n}];return this._commandService.executeCommand(d.CutContentCommand.id,{segmentId:e,textRanges:c})}catch{return this._logService.error("[DocClipboardController] cut content failed"),!1}}async _paste(e){var o;const{segmentId:t,endOffset:n,style:r}=(o=this._textSelectionManagerService.getActiveRange())!=null?o:{},s=this._textSelectionManagerService.getSelections();if(t==null&&this._logService.error("[DocClipboardController] segmentId does not exist!"),n==null||s==null)return!1;try{let c=n;for(const h of s){const{startOffset:_,endOffset:m}=h;_==null||m==null||m<=n&&(c+=e.dataStream.length-(m-_))}const u=[{startOffset:c,endOffset:c,style:r}];return this._commandService.executeCommand(d.InnerPasteCommand.id,{body:e,segmentId:t,textRanges:u})}catch{return this._logService.error("[DocClipboardController]","clipboard is empty."),!1}}async _setClipboardData(e){const t=Ft(),n=e.length>1?e.map(s=>s.dataStream).join(`
|
|
10
|
-
`):e[0].dataStream;let r=this._umdToHtml.convert(e);return e.length===1&&(r=r.replace(/(<[a-z]+)/,(s,o)=>`${o} data-copy-id="${t}"`),Me.set(t,e[0])),this._clipboardInterfaceService.write(n,r)}addClipboardHook(e){return this._clipboardHooks.push(e),a.toDisposable(()=>{const t=this._clipboardHooks.indexOf(e);t>-1&&this._clipboardHooks.splice(t,1)})}_getDocumentBodyInRanges(){const e=this._textSelectionManagerService.getSelections(),t=this._univerInstanceService.getCurrentUniverDocInstance(),n=[];if(e==null||!t)return n;for(const r of e){const{startOffset:s,endOffset:o,collapsed:c}=r;if(c||s==null||o==null)continue;const u=t.sliceBody(s,o);u!=null&&n.push(u)}return n}async _generateBodyFromClipboardItems(e){try{let t="",n="";for(const r of e)for(const s of r.types)s===l.PLAIN_TEXT_CLIPBOARD_MIME_TYPE?n=await r.getType(s).then(o=>o&&o.text()):s===l.HTML_CLIPBOARD_MIME_TYPE&&(t=await r.getType(s).then(o=>o&&o.text()));return this._generateBodyFromHtmlAndText(t,n)}catch(t){return Promise.reject(t)}}_generateBodyFromHtmlAndText(e,t){if(!e){if(t)return kt(t);throw new Error("[DocClipboardService] html and text cannot be both empty!")}const n=wt(e);if(n){const r=Me.get(n);if(r)return r}return this._htmlToUDM.convert(e)}};se=zt([F(0,a.IUniverInstanceService),F(1,a.ILogService),F(2,a.ICommandService),F(3,l.IClipboardInterfaceService),F(4,C.Inject(d.TextSelectionManagerService))],se);function K(i){return i.getContextValue(a.FOCUSING_DOC)||i.getContextValue(a.EDITOR_ACTIVATED)}const ae=999,Gt={id:l.CopyCommand.id,name:"doc.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:ae,preconditions:K,handler:async i=>i.get(w).copy()},Yt={id:l.CutCommand.id,name:"doc.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:ae,preconditions:K,handler:async i=>i.get(w).cut()},Kt={id:l.PasteCommand.id,name:"doc.command.paste",type:a.CommandType.COMMAND,multi:!0,priority:ae,preconditions:K,handler:async i=>{const e=i.get(w),n=await i.get(l.IClipboardInterfaceService).read();return n.length===0?!1:e.paste(n)}};var Xt=Object.defineProperty,qt=Object.getOwnPropertyDescriptor,Zt=(i,e,t,n)=>{for(var r=n>1?void 0:n?qt(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Xt(e,t,r),r},$=(i,e)=>(t,n)=>e(t,n,i);let X=class extends a.RxDisposable{constructor(i,e,t,n,r){super(),this._commandService=i,this._clipboardInterfaceService=e,this._docClipboardService=t,this._textSelectionRenderManager=n,this._contextService=r,this._init()}_init(){[Gt,Yt,Kt].forEach(i=>this.disposeWithMe(this._commandService.registerMultipleCommand(i))),[d.InnerPasteCommand,d.CutContentCommand].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i))),this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var i;(i=this._textSelectionRenderManager)==null||i.onPaste$.pipe(T.takeUntil(this.dispose$)).subscribe(e=>{var s,o;if(!K(this._contextService))return;e.event.preventDefault();const t=e.event,n=(s=t.clipboardData)==null?void 0:s.getData("text/html"),r=(o=t.clipboardData)==null?void 0:o.getData("text/plain");this._docClipboardService.legacyPaste(n,r)})}};X=Zt([a.OnLifecycle(a.LifecycleStages.Rendered,X),$(0,a.ICommandService),$(1,l.IClipboardInterfaceService),$(2,w),$(3,I.ITextSelectionRenderManager),$(4,a.IContextService)],X);var Jt=Object.defineProperty,Qt=Object.getOwnPropertyDescriptor,en=(i,e,t,n)=>{for(var r=n>1?void 0:n?Qt(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Jt(e,t,r),r},V=(i,e)=>(t,n)=>e(t,n,i);let q=class extends a.Disposable{constructor(e,t,n,r,s){super();b(this,"_initialEditors",new Set);this._univerInstanceService=e,this._editorService=t,this._commandService=n,this._textSelectionRenderManager=r,this._renderManagerService=s,this._initialize()}_initialize(){this.disposeWithMe(this._editorService.resize$.subscribe(e=>{this._resize(e)})),this._editorService.getAllEditor().forEach(e=>{const t=e.editorUnitId;this._initialEditors.has(t)||(this._initialEditors.add(t),this._resize(t))}),this._commandExecutedListener(),this._initialSetValue(),this._initialBlur(),this._initialFocus(),this._initialValueChange()}_resize(e){var A,P,U;if(e==null)return;const t=this._editorService.getEditor(e);if((t==null?void 0:t.cancelDefaultResizeListener)===!0)return;const n=this._univerInstanceService.getUniverDocInstance(e);if(!n)return;const r=(A=this._renderManagerService.getRenderById(n.getUnitId()))==null?void 0:A.with(d.DocSkeletonManagerService).getSkeleton();if(t==null||t.render==null||r==null||n==null)return;r.calculate();const{marginTop:s=0,marginBottom:o=0,marginLeft:c=0,marginRight:u=0}=n.getSnapshot().documentStyle,{scene:h,mainComponent:_}=t.render;let{actualHeight:m,actualWidth:S}=r.getActualSize();m+=s+o,S+=c+u;const{width:f,height:O}=t.getBoundingClientRect(),p=h.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);let v=p==null?void 0:p.getScrollBar();const M=Math.max(S,f),E=Math.max(m,O);h.transformByState({width:M,height:E}),_==null||_.resize(M,E),t.isSingle()?S>f?v==null?p&&new I.ScrollBar(p,{barSize:8,enableVertical:!1}):p==null||p.resetCanvasSizeAndUpdateScrollBar():(v=null,p==null||p.scrollTo({x:0,y:0}),(U=p==null?void 0:p.getScrollBar())==null||U.dispose()):m>O?v==null?p&&new I.ScrollBar(p,{enableHorizontal:!1,barSize:8}):p==null||p.resetCanvasSizeAndUpdateScrollBar():(v=null,p==null||p.scrollTo({x:0,y:0}),(P=p==null?void 0:p.getScrollBar())==null||P.dispose())}_initialSetValue(){this.disposeWithMe(this._editorService.setValue$.subscribe(e=>{this._commandService.executeCommand(d.CoverContentCommand.id,{unitId:e.editorUnitId,body:e.body,segmentId:null})}))}_initialBlur(){this.disposeWithMe(this._editorService.blur$.subscribe(()=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.blur()})),this.disposeWithMe(this._textSelectionRenderManager.onBlur$.subscribe(()=>{var r;const e=(r=this._univerInstanceService.getCurrentUniverDocInstance())==null?void 0:r.getUnitId();if(e==null)return;const t=this._editorService.getEditor(e),n=this._editorService.getFocusEditor();t==null||t.isSheetEditor()||n&&n.editorUnitId===e||this._editorService.blur()}))}_initialFocus(){this.disposeWithMe(this._editorService.focus$.subscribe(n=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.addTextRanges([n])}));const e=["univer-formula-search","univer-formula-help","formula-help-decorator","univer-formula-help-param"];this.disposeWithMe(T.fromEvent(window,"mousedown").subscribe(n=>{const s=n.target.classList[0]||"";if(a.checkForSubstrings(s,e)){this._editorService.changeSpreadsheetFocusState(!0),n.stopPropagation();return}this._editorService.changeSpreadsheetFocusState(!1)})),this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET).forEach(n=>{const r=n.getUnitId(),s=this._renderManagerService.getRenderById(r),o=s==null?void 0:s.engine.getCanvas().getCanvasEle();o!=null&&T.fromEvent(o,"mousedown").subscribe(c=>{this._editorService.changeSpreadsheetFocusState(!0),c.stopPropagation()})})}_initialValueChange(){this.disposeWithMe(this._textSelectionRenderManager.onCompositionupdate$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onInput$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onKeydown$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onPaste$.subscribe(this._valueChange.bind(this)))}_valueChange(){var n;const e=(n=this._univerInstanceService.getCurrentUniverDocInstance())==null?void 0:n.getUnitId();if(e==null)return;const t=this._editorService.getEditor(e);t==null||t.isSheetEditor()||this._editorService.refreshValueChange(e)}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id,l.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{unitId:r}=n;if(this._editorService.isSheetEditor(r))return;this._resize(r),this._valueChange()}}))}};q=en([a.OnLifecycle(a.LifecycleStages.Rendered,q),V(0,a.IUniverInstanceService),V(1,l.IEditorService),V(2,a.ICommandService),V(3,I.ITextSelectionRenderManager),V(4,I.IRenderManagerService)],q);var tn=Object.defineProperty,nn=Object.getOwnPropertyDescriptor,rn=(i,e,t,n)=>{for(var r=n>1?void 0:n?nn(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&tn(e,t,r),r},Z=(i,e)=>(t,n)=>e(t,n,i);g.DocRenderController=class extends a.RxDisposable{constructor(e,t,n,r,s){super(),this._context=e,this._commandService=t,this._docSkeletonManagerService=n,this._configService=r,this._editorService=s,this._addNewRender(),this._initRenderRefresh(),this._initCommandListener()}_addNewRender(){const{scene:e,engine:t,unit:n}=this._context,r=new I.Viewport(d.VIEWPORT_KEY.VIEW_MAIN,e,{left:0,top:0,bottom:0,right:0,isRelativeX:!0,isRelativeY:!0,isWheelPreventDefaultX:!0});e.attachControl(),e.onMouseWheel$.subscribeEvent((c,u)=>{const h=c;if(h.ctrlKey){const _=Math.abs(h.deltaX);let m=_<40?.2:_<80?.4:.2;m*=h.deltaY>0?-1:1,e.scaleX<1&&(m/=2),e.scaleX+m>4?e.scale(4,4):e.scaleX+m<.1?e.scale(.1,.1):h.preventDefault()}else r.onMouseWheel(h,u)}),this._configService.getConfig("hasScroll")!==!1&&new I.ScrollBar(r),e.addLayer(new I.Layer(e,[],d.DOCS_COMPONENT_MAIN_LAYER_INDEX),new I.Layer(e,[],d.DOCS_COMPONENT_HEADER_LAYER_INDEX)),this._addComponent(),n.getShouldRenderLoopImmediately()&&t.runRenderLoop(()=>{e.render()})}_addComponent(){const{scene:e,unit:t,components:n}=this._context,r={pageMarginLeft:t.documentStyle.marginLeft||0,pageMarginTop:t.documentStyle.marginTop||0},s=new I.Documents(d.DOCS_VIEW_KEY.MAIN,void 0,r);s.zIndex=d.DOCS_COMPONENT_DEFAULT_Z_INDEX;const o=new I.DocBackground(d.DOCS_VIEW_KEY.BACKGROUND,void 0,r);o.zIndex=d.DOCS_COMPONENT_DEFAULT_Z_INDEX,this._context.mainComponent=s,n.set(d.DOCS_VIEW_KEY.MAIN,s),n.set(d.DOCS_VIEW_KEY.BACKGROUND,o),e.addObjects([s],d.DOCS_COMPONENT_MAIN_LAYER_INDEX),e.addObjects([o],d.DOCS_COMPONENT_BACKGROUND_LAYER_INDEX),this._editorService.getEditor(t.getUnitId())==null&&e.enableLayerCache(d.DOCS_COMPONENT_MAIN_LAYER_INDEX)}_initRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.pipe(T.takeUntil(this.dispose$)).subscribe(e=>{this._create(e)})}_create(e){if(!e)return;const{mainComponent:t,components:n}=this._context,r=t,s=n.get(d.DOCS_VIEW_KEY.BACKGROUND);r.changeSkeleton(e),s.changeSkeleton(e),this._recalculateSizeBySkeleton(e)}_initCommandListener(){const e=[d.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const r=t.params,{unitId:s}=r,o=this._docSkeletonManagerService.getSkeleton();if(!o||!!o.getViewModel().getDataModel().getSnapshot().disabled)return;if(o.calculate(),this._editorService.isEditor(s)){(n=this._context.mainComponent)==null||n.makeDirty();return}this._recalculateSizeBySkeleton(o)}}))}_recalculateSizeBySkeleton(e){var m;const{mainComponent:t,scene:n,unitId:r,components:s}=this._context,o=t,c=s.get(d.DOCS_VIEW_KEY.BACKGROUND),u=(m=e.getSkeletonData())==null?void 0:m.pages;if(u==null)return;let h=0,_=0;for(let S=0,f=u.length;S<f;S++){const O=u[S],{pageWidth:p,pageHeight:v}=O;o.pageLayoutType===I.PageLayoutType.VERTICAL?(_+=v,_+=o.pageMarginTop,S===f-1&&(_+=o.pageMarginTop),h=Math.max(h,p)):o.pageLayoutType===I.PageLayoutType.HORIZONTAL&&(h+=p,S!==f-1&&(h+=o.pageMarginLeft),_=Math.max(_,v))}o.resize(h,_),c.resize(h,_),this._editorService.isEditor(r)||n.resize(h,_)}},g.DocRenderController=rn([Z(1,a.ICommandService),Z(2,C.Inject(d.DocSkeletonManagerService)),Z(3,a.IConfigService),Z(4,l.IEditorService)],g.DocRenderController);var on=Object.defineProperty,sn=Object.getOwnPropertyDescriptor,an=(i,e,t,n)=>{for(var r=n>1?void 0:n?sn(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&on(e,t,r),r},ce=(i,e)=>(t,n)=>e(t,n,i);let le=class extends a.Disposable{constructor(e,t,n,r){super();b(this,"_liquid",new I.Liquid);b(this,"_pageMarginCache",new Map);this._context=e,this._docSkeletonManagerService=t,this._commandService=n,this._editorService=r,this._initialize(),this._commandExecutedListener()}_initialize(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{e!=null&&this._refreshDrawing(e)})}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id,d.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const r=t.params,{unitId:s}=r,o=this._docSkeletonManagerService.getSkeleton();if(!o)return;if(this._editorService.isEditor(s)){(n=this._context.mainComponent)==null||n.makeDirty();return}this._refreshDrawing(o)}}))}_refreshDrawing(e){const t=e==null?void 0:e.getSkeletonData(),{mainComponent:n,scene:r,unitId:s}=this._context,o=n;if(!t)return;const{left:c,top:u,pageLayoutType:h,pageMarginLeft:_,pageMarginTop:m}=o,{pages:S}=t,f=[];r.getAncestorScale(),this._liquid.reset(),this._pageMarginCache.clear();for(let O=0,p=S.length;O<p;O++){const v=S[O],{skeDrawings:M,marginLeft:E,marginTop:A}=v;this._liquid.translatePagePadding(v),M.forEach(P=>{const{aLeft:U,aTop:W,height:H,width:ge,drawingId:te,drawingOrigin:Fe}=P,Dn=Fe.layoutType===a.PositionedObjectLayoutType.WRAP_NONE&&Fe.behindDoc===a.BooleanNumber.TRUE;f.push({unitId:s,subUnitId:a.DEFAULT_DOCUMENT_SUB_COMPONENT_ID,floatingObjectId:te,behindText:Dn,floatingObject:{left:U+c+this._liquid.x,top:W+u+this._liquid.y,width:ge,height:H}}),this._pageMarginCache.set(te,{marginLeft:this._liquid.x,marginTop:this._liquid.y})}),this._liquid.restorePagePadding(v),this._liquid.translatePage(v,h,_,m)}}};le=an([ce(1,C.Inject(d.DocSkeletonManagerService)),ce(2,a.ICommandService),ce(3,l.IEditorService)],le);var cn=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,dn=(i,e,t,n)=>{for(var r=n>1?void 0:n?ln(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&cn(e,t,r),r},j=(i,e)=>(t,n)=>e(t,n,i);let de=class extends a.Disposable{constructor(i,e,t,n,r,s){super(),this._context=i,this._docSkeletonManagerService=e,this._univerInstanceService=t,this._commandService=n,this._textSelectionManagerService=r,this._editorService=s,this._init()}_init(){this._initSkeletonListener(),this._initCommandExecutedListener(),this._initRenderRefresher(),setTimeout(()=>this._updateViewZoom(1,!0),20)}_initRenderRefresher(){this._docSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,scene:t}=this._context;this._editorService.isEditor(e)||this.disposeWithMe(t.onMouseWheel$.subscribeEvent(n=>{if(!n.ctrlKey)return;const r=this._univerInstanceService.getCurrentUniverDocInstance();if(!r)return;const s=Math.abs(n.deltaX);let o=s<40?.2:s<80?.4:.2;o*=n.deltaY>0?-1:1,t.scaleX<1&&(o/=2);const c=r.zoomRatio;let u=+Number.parseFloat(`${c+o}`).toFixed(1);u=u>=4?4:u<=.1?.1:u,this._commandService.executeCommand(d.SetDocZoomRatioCommand.id,{zoomRatio:u,unitId:r.getUnitId()}),n.preventDefault()}))})}_initSkeletonListener(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const e=this._univerInstanceService.getCurrentUniverDocInstance();if(!e)return;const t=e.zoomRatio||1;this._updateViewZoom(t,!1)}))}_initCommandExecutedListener(){const i=[d.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._univerInstanceService.getCurrentUniverDocInstance();if(!t)return;const n=e.params,{unitId:r}=n;if(r!==t.getUnitId())return;const s=t.zoomRatio||1;this._updateViewZoom(s)}}))}_updateViewZoom(i,e=!0){var n;const t=d.neoGetDocObject(this._context);t.scene.scale(i,i),this._calculatePagePosition(t,i),e&&this._textSelectionManagerService.refreshSelection(),(n=t.scene.getTransformer())==null||n.clearSelectedObjects()}_calculatePagePosition(i,e){const{document:t,scene:n,docBackground:r}=i,s=n==null?void 0:n.getParent(),{width:o,height:c,pageMarginLeft:u,pageMarginTop:h}=t;if(s==null||o===Number.POSITIVE_INFINITY||c===Number.POSITIVE_INFINITY)return;const{width:_,height:m}=s;let S=0,f=0,O=0,p=0,v=Number.POSITIVE_INFINITY;_>(o+u*2)*e?(S=_/2-o*e/2,S/=e,O=(_-u*2)/e,v=0):(S=u,O=o+u*2,v=(O-_/e)/2),m>c?(f=m/2-c/2,p=(m-h*2)/e):(f=h,p=c+h*2),n.resize(O,p+200),t.translate(S,f),r.translate(S,f);const M=n.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);if(v!==Number.POSITIVE_INFINITY&&M!=null){const E=M.transViewportScroll2ScrollValue(v,0).x;M.scrollTo({x:E})}return this}};de=dn([j(1,C.Inject(d.DocSkeletonManagerService)),j(2,a.IUniverInstanceService),j(3,a.ICommandService),j(4,C.Inject(d.TextSelectionManagerService)),j(5,l.IEditorService)],de);var un=Object.defineProperty,hn=Object.getOwnPropertyDescriptor,pn=(i,e,t,n)=>{for(var r=n>1?void 0:n?hn(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&un(e,t,r),r},x=(i,e)=>(t,n)=>e(t,n,i);let ue=class extends a.Disposable{constructor(e,t,n,r,s,o,c){super();b(this,"_loadedMap",new WeakSet);this._context=e,this._commandService=t,this._editorService=n,this._instanceSrv=r,this._textSelectionRenderManager=s,this._docSkeletonManagerService=o,this._textSelectionManagerService=c,this._initialize()}_initialize(){this._init(),this._skeletonListener(),this._commandExecutedListener()}_init(){const{unitId:e}=this._context,t=d.neoGetDocObject(this._context);t==null||t.document==null||this._loadedMap.has(t.document)||(this._initialMain(e),this._loadedMap.add(t.document))}_initialMain(e){const t=d.neoGetDocObject(this._context),{document:n,scene:r}=t;this.disposeWithMe(n.onPointerEnter$.subscribeEvent(()=>{this._isEditorReadOnly(e)||(n.cursor=I.CURSOR_TYPE.TEXT)})),this.disposeWithMe(n.onPointerLeave$.subscribeEvent(()=>{n.cursor=I.CURSOR_TYPE.DEFAULT,r.resetCursor()})),this.disposeWithMe(n.onPointerDown$.subscribeEvent((s,o)=>{if(this._isEditorReadOnly(e))return;const c=this._instanceSrv.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC);if((c==null?void 0:c.getUnitId())!==e&&this._instanceSrv.setCurrentUnitForType(e),this._textSelectionRenderManager.eventTrigger(s),this._editorService.getEditor(e)){this._setEditorFocus(e);const{offsetX:u,offsetY:h}=s;setTimeout(()=>{this._setEditorFocus(e),this._textSelectionRenderManager.setCursorManually(u,h)},0)}s.button!==2&&o.stopPropagation()})),this.disposeWithMe(n.onDblclick$.subscribeEvent(s=>{this._isEditorReadOnly(e)||this._textSelectionRenderManager.handleDblClick(s)})),this.disposeWithMe(n.onTripleClick$.subscribeEvent(s=>{this._isEditorReadOnly(e)||this._textSelectionRenderManager.handleTripleClick(s)}))}_isEditorReadOnly(e){const t=this._editorService.getEditor(e);return t?t.isReadOnly():!1}_setEditorFocus(e){this._editorService.focusStyle(e)}_commandExecutedListener(){const e=[d.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const r=t.params,{unitId:s}=r,o=(n=this._textSelectionManagerService.getCurrentSelection())==null?void 0:n.unitId;if(s!==o)return;this._textSelectionManagerService.refreshSelection()}}))}_skeletonListener(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{scene:t,mainComponent:n,unitId:r}=this._context;this._textSelectionRenderManager.changeRuntime(e,t,n),this._textSelectionManagerService.setCurrentSelectionNotRefresh({unitId:r,subUnitId:""}),this._editorService.isEditor(r)||this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}],!1)}))}};ue=pn([x(1,a.ICommandService),x(2,l.IEditorService),x(3,a.IUniverInstanceService),x(4,I.ITextSelectionRenderManager),x(5,C.Inject(d.DocSkeletonManagerService)),x(6,C.Inject(d.TextSelectionManagerService))],ue);var _n=Object.defineProperty,gn=Object.getOwnPropertyDescriptor,mn=(i,e,t,n)=>{for(var r=n>1?void 0:n?gn(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&_n(e,t,r),r},he=(i,e)=>(t,n)=>e(t,n,i);const Ae=1.5;let pe=class extends a.RxDisposable{constructor(i,e,t,n){super(),this._context=i,this._docSkeletonManagerService=e,this._textSelectionManagerService=t,this._editorService=n,this._init()}_init(){this._textSelectionManagerService.textSelection$.pipe(T.takeUntil(this.dispose$)).subscribe(i=>{if(i==null)return;const{isEditing:e,unitId:t}=i;e&&this._scrollToSelection(t)})}_scrollToSelection(i){const e=this._textSelectionManagerService.getActiveRange(),t=d.neoGetDocObject(this._context),n=this._docSkeletonManagerService.getSkeleton();if(e==null||t==null)return;const{collapsed:r,startNodePosition:s}=e;if(!r)return;const o=t.document.getOffsetConfig(),{docsLeft:c,docsTop:u}=o,h=new I.NodePositionConvertToCursor(o,n),{contentBoxPointGroup:_}=h.getRangePointData(s,s),{left:m,top:S,height:f}=I.getAnchorBounding(_),O=m+c,p=S+u,v=t.scene.getViewport(d.VIEWPORT_KEY.VIEW_MAIN),M=!!this._editorService.getEditor(i);if(v==null)return;const{left:E,top:A,right:P,bottom:U}=v.getBounding().viewBound;let W=0,H=0;const ge=M?0:100;p<A?W=p-A:p>U-f&&(W=p-U+f+ge),O<E?H=O-E:O>P-Ae&&(H=O-P+Ae);const te=v.transViewportScroll2ScrollValue(H,W);v.scrollBy(te)}};pe=mn([he(1,C.Inject(d.DocSkeletonManagerService)),he(2,C.Inject(d.TextSelectionManagerService)),he(3,l.IEditorService)],pe);var Sn=Object.defineProperty,fn=Object.getOwnPropertyDescriptor,vn=(i,e,t,n)=>{for(var r=n>1?void 0:n?fn(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Sn(e,t,r),r},J=(i,e)=>(t,n)=>e(t,n,i);function Cn(i,e){const t=Le(i.left,i.top,e),n=Le(i.right,i.bottom,e);return{left:t.x,top:t.y,right:n.x,bottom:n.y}}function Le(i,e,t){const{scaleX:n,scaleY:r}=t.getAncestorScale(),s=t.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);if(!s)return{x:i,y:e};const{viewportScrollX:o,viewportScrollY:c}=s,u=(i-o)*n,h=(e-c)*r;return{x:u,y:h}}g.DocCanvasPopManagerService=class extends a.Disposable{constructor(e,t,n,r){super(),this._globalPopupManagerService=e,this._renderManagerService=t,this._univerInstanceService=n,this._commandService=r}_createObjectPositionObserver(e,t){const n=()=>{const{scene:u}=t,{left:h,top:_,width:m,height:S}=e,f={left:h,right:h+m,top:_,bottom:_+S},O=Cn(f,u);return{left:O.left,right:O.right,top:O.top,bottom:O.bottom}},r=n(),s=new T.BehaviorSubject(r),o=new a.DisposableCollection;o.add(this._commandService.onCommandExecuted(u=>{u.id===d.SetDocZoomRatioOperation.id&&s.next(n())}));const c=t.scene.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);return c&&o.add(c.onScrollAfter$.subscribeEvent(()=>{s.next(n())})),{position:r,position$:s,disposable:o}}attachPopupToObject(e,t){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC).getUnitId(),s=this._renderManagerService.getRenderById(r);if(!s)return{dispose:()=>{}};const{position:o,position$:c,disposable:u}=this._createObjectPositionObserver(e,s),h=this._globalPopupManagerService.addPopup({...t,unitId:r,subUnitId:"default",anchorRect:o,anchorRect$:c});return{dispose:()=>{this._globalPopupManagerService.removePopup(h),c.complete(),u.dispose()}}}},g.DocCanvasPopManagerService=vn([J(0,C.Inject(l.ICanvasPopupService)),J(1,I.IRenderManagerService),J(2,a.IUniverInstanceService),J(3,a.ICommandService)],g.DocCanvasPopManagerService);var In=Object.defineProperty,On=Object.getOwnPropertyDescriptor,Tn=(i,e,t,n)=>{for(var r=n>1?void 0:n?On(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&In(e,t,r),r},Be=(i,e)=>(t,n)=>e(t,n,i);g.DocsRenderService=class extends a.RxDisposable{constructor(e,t){super(),this._instanceSrv=e,this._renderManagerService=t,this._init()}_init(){this._renderManagerService.createRender$.pipe(T.takeUntil(this.dispose$)).subscribe(e=>this._createRenderWithId(e)),this._instanceSrv.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_DOC).pipe(T.takeUntil(this.dispose$)).subscribe(e=>this._createRenderer(e)),this._instanceSrv.getAllUnitsForType(a.UniverInstanceType.UNIVER_DOC).forEach(e=>this._createRenderer(e)),this._instanceSrv.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_DOC).pipe(T.takeUntil(this.dispose$)).subscribe(e=>this._disposeRenderer(e))}_createRenderer(e){const t=e.getUnitId();this._renderManagerService.has(t)||(this._createRenderWithId(t),this._renderManagerService.setCurrent(t))}_createRenderWithId(e){this._renderManagerService.createRender(e)}_disposeRenderer(e){const t=e.getUnitId();this._renderManagerService.removeRender(t)}},g.DocsRenderService=Tn([a.OnLifecycle(a.LifecycleStages.Ready,g.DocsRenderService),Be(0,a.IUniverInstanceService),Be(1,I.IRenderManagerService)],g.DocsRenderService);var bn=Object.defineProperty,Rn=Object.getOwnPropertyDescriptor,Mn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Rn(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&bn(e,t,r),r},_e=(i,e)=>(t,n)=>e(t,n,i);g.UniverDocsUIPlugin=(ee=class extends a.Plugin{constructor(e,t,n,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._logService=r,this._config=a.Tools.deepMerge({},fe,this._config),this._initDependencies(t),this._initializeCommands()}onReady(){this._initRenderBasics()}onRendered(){this._initUI(),this._initRenderModules(),this._markDocAsFocused()}_initializeCommands(){[We,He,ke,ze,Ge,Ye,Ke,Xe,qe,xt,At,Nt].forEach(e=>{this._injector.get(l.IShortcutService).registerShortcut(e)})}_initDependencies(e){[[B,{useFactory:()=>this._injector.createInstance(B,this._config)}],[X],[q],[g.DocsRenderService],[L,{useFactory:()=>this._injector.createInstance(L,this._config)}],[w,{useClass:se}],[g.DocCanvasPopManagerService]].forEach(n=>e.add(n))}_markDocAsFocused(){const e=this._injector.get(a.IUniverInstanceService),t=this._injector.get(l.IEditorService);try{const n=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC);if(!n)return;const r=n.getUnitId();t.isEditor(r)||e.focusUnit(n.getUnitId())}catch(n){this._logService.warn(n)}}_initUI(){this._injector.get(L)}_initRenderBasics(){[d.DocSkeletonManagerService,g.DocRenderController,de].forEach(e=>{this._renderManagerSrv.registerRenderModule(a.UniverInstanceType.UNIVER_DOC,e)})}_initRenderModules(){[pe,le,ue].forEach(e=>{this._renderManagerSrv.registerRenderModule(a.UniverInstanceType.UNIVER_DOC,e)})}},b(ee,"pluginName",ve),b(ee,"type",a.UniverInstanceType.UNIVER_DOC),ee),g.UniverDocsUIPlugin=Mn([_e(1,C.Inject(C.Injector)),_e(2,I.IRenderManagerService),_e(3,a.ILogService)],g.UniverDocsUIPlugin);function yn(i){return{left:i.positionH.posOffset,top:i.positionV.posOffset,width:i.size.width,height:i.size.height}}function En(i,e=0,t=0){return{size:{width:i.width,height:i.height},positionH:{relativeFrom:a.ObjectRelativeFromH.MARGIN,posOffset:(i.left||0)-e},positionV:{relativeFrom:a.ObjectRelativeFromV.PAGE,posOffset:(i.top||0)-t},angle:i.angle||0}}g.DOC_UI_PLUGIN_NAME=ve,g.DefaultDocContainerConfig=Se,g.DefaultDocUiConfig=fe,g.DefaultToolbarConfig=me,g.PastePluginLark=Ee,g.PastePluginUniver=Ue,g.PastePluginWord=Pe,g.docDrawingPositionToTransform=yn,g.transformToDocDrawingPosition=En,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
10
|
+
*/var $t=Y,Ht=Symbol.for("react.element"),Vt=Symbol.for("react.fragment"),jt=Object.prototype.hasOwnProperty,Wt=$t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,kt={key:!0,ref:!0,__self:!0,__source:!0};function Ye(i,e,t){var n,o={},r=null,s=null;t!==void 0&&(r=""+t),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)jt.call(e,n)&&!kt.hasOwnProperty(n)&&(o[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)o[n]===void 0&&(o[n]=e[n]);return{$$typeof:Ht,type:i,key:r,ref:s,props:o,_owner:Wt.current}}oe.Fragment=Vt,oe.jsx=Ye,oe.jsxs=Ye,Ge.exports=oe;var y=Ge.exports;const Gt={docsUiCanvasBackground:"univer-docs-ui-canvas-background"},Yt=()=>y.jsx("div",{className:Gt.docsUiCanvasBackground}),ze=18,Ke=200,ve=6,zt=4;function Kt(i,e){let{radius:t,width:n,height:o}=e;t=t!=null?t:0,n=n!=null?n:30,o=o!=null?o:30;let r=0;r=Math.min(t,n/2,o/2),i.beginPath(),i.moveTo(0,0),i.lineTo(n,0),i.lineTo(n,o-r),i.arc(n-r,o-r,r,0,Math.PI/2,!1),i.lineTo(0,o),i.lineTo(0,0),i.closePath(),e.fill&&(i.save(),i.fillStyle=e.fill,e.fillRule==="evenodd"?i.fill("evenodd"):i.fill(),i.restore())}class re extends I.Shape{constructor(t,n){super(t,n);M(this,"color");M(this,"text");this.color=n==null?void 0:n.color,this.text=n==null?void 0:n.text}static drawWith(t,n){const{text:o,color:r}=n;t.save(),t.font="13px Source Han Sans CN";const s=t.measureText(o).width,c=Math.min(s+2*ve,Ke);Kt(t,{height:ze,width:c,radius:4,fill:r,evented:!1}),t.fillStyle="rgba(58, 96, 247, 1)";const l=ve,p=ze-zt,_=Ke-2*ve;if(s>_){let f="",m=0;for(const h of o){const v=t.measureText(h).width;if(m+v<=_-t.measureText("...").width)f+=h,m+=v;else{f+="...";break}}t.fillText(f,l,p)}else t.fillText(o,l,p);t.restore()}_draw(t){re.drawWith(t,this)}}const Xe="COMPONENT_DOC_HEADER_FOOTER_PANEL",x={panel:"univer-panel",optionsSection:"univer-options-section",optionsFormItem:"univer-options-form-item",optionsInput:"univer-options-input",optionsMarginSetting:"univer-options-margin-setting"},Xt=i=>{const e=w.useDependency(a.LocaleService),t=w.useDependency(a.IUniverInstanceService),n=w.useDependency(I.IRenderManagerService),o=w.useDependency(a.ICommandService),r=w.useDependency(I.ITextSelectionRenderManager),s=w.useDependency(u.TextSelectionManagerService),{unitId:c}=i,[l,p]=Y.useState({}),_=(h,v)=>{var U;p(L=>({...L,[v]:h?a.BooleanNumber.TRUE:a.BooleanNumber.FALSE}));const g=t.getUniverDocInstance(c),S=g==null?void 0:g.getSnapshot().documentStyle,C=(U=n.getRenderById(c))==null?void 0:U.with(u.DocSkeletonManagerService),T=C==null?void 0:C.getViewModel();if(S==null||T==null)return;const P=T.getEditArea();let A=!1;const D=r.getSegmentPage();let R=!1;if(v==="useFirstPageHeaderFooter"&&h===!0&&((P===I.DocumentEditArea.HEADER&&!S.firstPageHeaderId||P===I.DocumentEditArea.FOOTER&&!S.firstPageFooterId)&&(A=!0),A&&D===0&&(R=!0)),v==="evenAndOddHeaders"&&h===!0&&((P===I.DocumentEditArea.HEADER&&!S.evenPageHeaderId||P===I.DocumentEditArea.FOOTER&&!S.evenPageFooterId)&&(A=!0),A&&D%2===1&&(R=!0)),A){const B=a.Tools.generateRandomId(6);R&&r.setSegment(B),o.executeCommand(se,{unitId:c,segmentId:B,headerFooterProps:{[v]:h?a.BooleanNumber.TRUE:a.BooleanNumber.FALSE}})}else o.executeCommand(se,{unitId:c,headerFooterProps:{[v]:h?a.BooleanNumber.TRUE:a.BooleanNumber.FALSE}})},f=async(h,v)=>{p(g=>({...g,[v]:h})),await o.executeCommand(se,{unitId:c,headerFooterProps:{[v]:h}}),r.removeAllTextRanges(),r.blur()},m=()=>{var C,T;const h=(C=n.getRenderById(c))==null?void 0:C.with(u.DocSkeletonManagerService),v=h==null?void 0:h.getSkeleton(),g=h==null?void 0:h.getViewModel(),S=n.getRenderById(c);S==null||g==null||v==null||(s.replaceTextRanges([]),r.setSegment(""),r.setSegmentPage(-1),g.setEditArea(I.DocumentEditArea.BODY),v.calculate(),(T=S.mainComponent)==null||T.makeDirty(!0))};return Y.useEffect(()=>{const h=t.getUniverDocInstance(c),v=h==null?void 0:h.getSnapshot().documentStyle;if(v){const{marginHeader:g,marginFooter:S,useFirstPageHeaderFooter:C,evenAndOddHeaders:T}=v;p({marginHeader:g,marginFooter:S,useFirstPageHeaderFooter:C,evenAndOddHeaders:T})}},[c]),y.jsxs("div",{className:x.options,children:[y.jsxs("div",{className:x.optionsSection,children:[y.jsx("div",{className:x.optionsFormItem,children:y.jsx(j.Checkbox,{checked:l.useFirstPageHeaderFooter===a.BooleanNumber.TRUE,onChange:h=>{_(h,"useFirstPageHeaderFooter")},children:e.t("headerFooter.firstPageCheckBox")})}),y.jsx("div",{className:x.optionsFormItem,children:y.jsx(j.Checkbox,{checked:l.evenAndOddHeaders===a.BooleanNumber.TRUE,onChange:h=>{_(h,"evenAndOddHeaders")},children:e.t("headerFooter.oddEvenCheckBox")})})]}),y.jsxs("div",{className:ct(x.optionsSection,x.optionsMarginSetting),children:[y.jsxs("div",{className:x.optionsMarginItem,children:[y.jsx("span",{children:e.t("headerFooter.headerTopMargin")}),y.jsx(j.InputNumber,{min:0,max:200,precision:1,value:l.marginHeader,onChange:h=>{f(h,"marginHeader")},className:x.optionsInput})]}),y.jsxs("div",{className:x.optionsMarginItem,children:[y.jsx("span",{children:e.t("headerFooter.footerBottomMargin")}),y.jsx(j.InputNumber,{min:0,max:200,precision:1,value:l.marginFooter,onChange:h=>{f(h,"marginFooter")},className:x.optionsInput})]})]}),y.jsx("div",{className:x.optionsSection,children:y.jsx(j.Button,{onClick:m,children:e.t("headerFooter.closeHeaderFooter")})})]})},Zt=()=>{var p;const i=w.useDependency(a.LocaleService),e=w.useDependency(I.IRenderManagerService),o=w.useDependency(a.IUniverInstanceService).getCurrentUniverDocInstance().getUnitId(),s=((p=e.getRenderById(o))==null?void 0:p.with(u.DocSkeletonManagerService)).getViewModel(),[c,l]=Y.useState(!0);return Y.useEffect(()=>{const _=s.getEditArea();l(_!==I.DocumentEditArea.BODY);const f=s.editAreaChange$.subscribe(m=>{m!=null&&l(m!==I.DocumentEditArea.BODY)});return()=>{f.unsubscribe()}},[]),y.jsx("div",{className:x.panel,children:c?y.jsx(Xt,{unitId:o}):y.jsx("div",{className:x.panelDisableText,children:i.t("headerFooter.disableText")})})},Ze={id:"sidebar.operation.doc-header-footer-panel",type:a.CommandType.COMMAND,handler:async(i,e)=>{const t=i.get(d.ISidebarService),n=i.get(a.LocaleService);switch(e.value){case"open":t.open({header:{title:n.t("headerFooter.panel")},children:{label:Xe},onClose:()=>{},width:400});break;case"close":default:t.close();break}return!0}};var qt=Object.defineProperty,Jt=Object.getOwnPropertyDescriptor,Qt=(i,e,t,n)=>{for(var o=n>1?void 0:n?Jt(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&qt(e,t,o),o},$=(i,e)=>(t,n)=>e(t,n,i);const qe="rgba(58, 96, 247, 1)",Je="rgba(58, 96, 247, 0.08)";var N=(i=>(i[i.FIRST_PAGE_HEADER=0]="FIRST_PAGE_HEADER",i[i.FIRST_PAGE_FOOTER=1]="FIRST_PAGE_FOOTER",i[i.DEFAULT_HEADER=2]="DEFAULT_HEADER",i[i.DEFAULT_FOOTER=3]="DEFAULT_FOOTER",i[i.EVEN_PAGE_HEADER=4]="EVEN_PAGE_HEADER",i[i.EVEN_PAGE_FOOTER=5]="EVEN_PAGE_FOOTER",i))(N||{});function en(i,e,t){const{documentStyle:n}=i.getDataModel().getSnapshot(),{defaultHeaderId:o,defaultFooterId:r,evenPageHeaderId:s,evenPageFooterId:c,firstPageHeaderId:l,firstPageFooterId:p,evenAndOddHeaders:_,useFirstPageHeaderFooter:f}=n;switch(e){case I.DocumentEditArea.BODY:return{createType:null,headerFooterId:null};case I.DocumentEditArea.HEADER:return f===a.BooleanNumber.TRUE&&!l?{createType:0,headerFooterId:null}:_===a.BooleanNumber.TRUE&&t%2===0&&!s?{createType:4,headerFooterId:null}:o?{createType:null,headerFooterId:o}:{createType:2,headerFooterId:null};case I.DocumentEditArea.FOOTER:return f===a.BooleanNumber.TRUE&&!p?{createType:1,headerFooterId:null}:_===a.BooleanNumber.TRUE&&t%2===0&&!c?{createType:5,headerFooterId:null}:r?{createType:null,headerFooterId:r}:{createType:3,headerFooterId:null};default:throw new Error(`Invalid editArea: ${e}`)}}let Ie=class extends a.Disposable{constructor(e,t,n,o,r,s,c,l,p){super();M(this,"_loadedMap",new WeakSet);this._context=e,this._commandService=t,this._editorService=n,this._instanceSrv=o,this._renderManagerService=r,this._docSkeletonManagerService=s,this._textSelectionRenderManager=c,this._localeService=l,this._componentManager=p,this._initialize()}_initialize(){this._context.unit.getSnapshot().documentStyle.documentFlavor===a.DocumentFlavor.TRADITIONAL&&(this._init(),this._drawHeaderFooterLabel(),this._registerCommands(),this._initCustomComponents())}_registerCommands(){[et,tt,Ze].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initCustomComponents(){const e=this._componentManager;this.disposeWithMe(e.register(Xe,Zt))}_init(){const{unitId:e}=this._context,t=u.neoGetDocObject(this._context);t==null||t.document==null||this._loadedMap.has(t.document)||(this._initialMain(e),this._loadedMap.add(t.document))}_initialMain(e){const t=u.neoGetDocObject(this._context),{document:n}=t;this.disposeWithMe(n.onDblclick$.subscribeEvent(async o=>{if(this._isEditorReadOnly(e))return;const{offsetX:r,offsetY:s}=o,{pageLayoutType:c=I.PageLayoutType.VERTICAL,pageMarginLeft:l,pageMarginTop:p}=n.getOffsetConfig(),_=this._getTransformCoordForDocumentOffset(r,s);if(_==null)return;const f=this._docSkeletonManagerService.getViewModel(),m=this._docSkeletonManagerService.getSkeleton(),h=f.getEditArea(),{editArea:v,pageNumber:g}=m.findEditAreaByCoord(_,c,l,p);if(h===v)return;f.setEditArea(v);const{createType:S,headerFooterId:C}=en(f,v,g);if(v===I.DocumentEditArea.BODY)this._textSelectionRenderManager.setSegment(""),this._textSelectionRenderManager.setSegmentPage(-1),this._textSelectionRenderManager.setCursorManually(r,s);else if(S!=null){const P=a.Tools.generateRandomId(6);this._textSelectionRenderManager.setSegment(P),this._textSelectionRenderManager.setSegmentPage(g),await this._commandService.executeCommand(et.id,{unitId:e,createType:S,segmentId:P})}else C!=null&&(this._textSelectionRenderManager.setSegment(C),this._textSelectionRenderManager.setSegmentPage(g),this._textSelectionRenderManager.setCursorManually(r,s))}))}_getTransformCoordForDocumentOffset(e,t){const n=u.neoGetDocObject(this._context),{document:o,scene:r}=n,{documentTransform:s}=o.getOffsetConfig(),c=r.getViewports()[0];if(c==null)return;const l=c.transformVector2SceneCoord(I.Vector2.FromArray([e,t]));return s.clone().invert().applyPoint(l)}_drawHeaderFooterLabel(){const e=this._localeService;this._renderManagerService.currentRender$.subscribe(t=>{if(t==null)return;const n=this._renderManagerService.getRenderById(t);if(this._editorService.isEditor(t)||this._instanceSrv.getUniverDocInstance(t)==null||n==null)return;const{mainComponent:o}=n,r=o;this.disposeWithMe(a.toDisposable(r.pageRender$.subscribe(s=>{if(this._editorService.isEditor(t))return;const p=this._docSkeletonManagerService.getViewModel().getEditArea()===I.DocumentEditArea.BODY,{page:_,pageLeft:f,pageTop:m,ctx:h}=s,{pageWidth:v,pageHeight:g,marginTop:S,marginBottom:C}=_;if(h.save(),h.translate(f-.5,m-.5),p?(I.Rect.drawWith(h,{left:0,top:0,width:v,height:S,fill:"rgba(255, 255, 255, 0.5)"}),h.save(),h.translate(0,g-C),I.Rect.drawWith(h,{left:0,top:0,width:v,height:C,fill:"rgba(255, 255, 255, 0.5)"}),h.restore()):(h.save(),h.translate(0,S),I.Rect.drawWith(h,{left:0,top:S,width:v,height:g-S-C,fill:"rgba(255, 255, 255, 0.5)"}),h.restore()),!p){const T={dataArray:[{command:"M",points:[0,S]},{command:"L",points:[v,S]}],strokeWidth:1,stroke:qe},P={dataArray:[{command:"M",points:[0,g-C]},{command:"L",points:[v,g-C]}],strokeWidth:1,stroke:qe};I.Path.drawWith(h,T),I.Path.drawWith(h,P),h.translate(0,S+1),re.drawWith(h,{text:e.t("headerFooter.header"),color:Je}),h.translate(0,g-S-C),re.drawWith(h,{text:e.t("headerFooter.footer"),color:Je})}h.restore()})))})}_isEditorReadOnly(e){const t=this._editorService.getEditor(e);return t?t.isReadOnly():!1}_getDocDataModel(){return this._context.unit}};Ie=Qt([$(1,a.ICommandService),$(2,d.IEditorService),$(3,a.IUniverInstanceService),$(4,I.IRenderManagerService),$(5,E.Inject(u.DocSkeletonManagerService)),$(6,I.ITextSelectionRenderManager),$(7,E.Inject(a.LocaleService)),$(8,E.Inject(d.ComponentManager))],Ie);function Qe(){return{dataStream:`\r
|
|
11
|
+
`,textRuns:[{st:0,ed:0,ts:{fs:9}}],paragraphs:[{startIndex:0,spaceAbove:0,lineSpacing:1.5,spaceBelow:0}],sectionBreaks:[{startIndex:1}]}}function Oe(i,e,t,n){const o=a.JSONX.getInstance(),r=6,s=i!=null?i:a.Tools.generateRandomId(r),c=e===N.DEFAULT_HEADER||e===N.FIRST_PAGE_HEADER||e===N.EVEN_PAGE_HEADER,l=o.insertOp([c?"headers":"footers",s],{[c?"headerId":"footerId"]:s,body:Qe()});n.push(l);const p=a.Tools.generateRandomId(r),_=o.insertOp([c?"footers":"headers",p],{[c?"footers":"headers"]:p,body:Qe()});n.push(_);let f="defaultHeaderId",m="defaultFooterId";switch(e){case N.DEFAULT_HEADER:f="defaultHeaderId",m="defaultFooterId";break;case N.DEFAULT_FOOTER:f="defaultFooterId",m="defaultHeaderId";break;case N.FIRST_PAGE_HEADER:f="firstPageHeaderId",m="firstPageFooterId";break;case N.FIRST_PAGE_FOOTER:f="firstPageFooterId",m="firstPageHeaderId";break;case N.EVEN_PAGE_HEADER:f="evenPageHeaderId",m="evenPageFooterId";break;case N.EVEN_PAGE_FOOTER:f="evenPageFooterId",m="evenPageHeaderId";break;default:throw new Error(`Unknown header footer type: ${e}`)}for(const[h,v]of[[f,s],[m,p]])if(t[h]!=null){const g=o.replaceOp(["documentStyle",h],t[h],v);n.push(g)}else{const g=o.insertOp(["documentStyle",h],v);n.push(g)}return n}const se="doc.command.core-header-footer",et={id:se,type:a.CommandType.COMMAND,handler:async(i,e)=>{var A;const t=i.get(a.ICommandService),n=i.get(a.IUniverInstanceService),o=i.get(I.IRenderManagerService),{unitId:r,segmentId:s,createType:c,headerFooterProps:l}=e,p=(A=o.getRenderById(r))==null?void 0:A.with(u.DocSkeletonManagerService),_=n.getUniverDocInstance(r),f=p==null?void 0:p.getViewModel();if(_==null||f==null)return!1;const m=f.getEditArea(),{documentStyle:h}=_.getSnapshot(),v=(l==null?void 0:l.marginFooter)!=null||(l==null?void 0:l.marginHeader)!=null,g=[{startOffset:0,endOffset:0,collapsed:!0}],S={id:u.RichTextEditingMutation.id,params:{unitId:r,actions:[],textRanges:g,debounce:!0}};v&&(S.params.noNeedSetTextRange=!0);const C=a.JSONX.getInstance(),T=[];return c!=null&&Oe(s,c,h,T),l!=null&&Object.keys(l).forEach(D=>{const R=l[D],U=h[D];if(R===U)return;let L;if(U===void 0?L=C.insertOp(["documentStyle",D],R):L=C.replaceOp(["documentStyle",D],U,R),T.push(L),D==="useFirstPageHeaderFooter"&&R===a.BooleanNumber.TRUE&&!h.firstPageHeaderId){const B=m===I.DocumentEditArea.HEADER?N.FIRST_PAGE_HEADER:N.FIRST_PAGE_FOOTER;Oe(s,B,h,T)}else if(D==="evenAndOddHeaders"&&R===a.BooleanNumber.TRUE&&!h.evenPageHeaderId){const B=m===I.DocumentEditArea.HEADER?N.EVEN_PAGE_HEADER:N.EVEN_PAGE_FOOTER;Oe(s,B,h,T)}}),T.length===0?!1:(S.params.actions=T.reduce((D,R)=>a.JSONX.compose(D,R),null),!!t.syncExecuteCommand(S.id,S.params))}},tt={id:"doc.command.open-header-footer-panel",type:a.CommandType.COMMAND,handler:async(i,e)=>i.get(a.ICommandService).executeCommand(Ze.id,{value:"open"})};function tn(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatBoldCommand.id,group:d.MenuGroup.TOOLBAR_FORMAT,type:d.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[d.MenuPosition.TOOLBAR_START],activated$:new b.Observable(t=>{const n=e.onCommandExecuted(o=>{var s;const r=o.id;if(r===u.SetTextSelectionsOperation.id||r===u.SetInlineFormatCommand.id){const c=H(i);if(c==null)return;const l=(s=c.ts)==null?void 0:s.bl;t.next(l===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function nn(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatItalicCommand.id,group:d.MenuGroup.TOOLBAR_FORMAT,type:d.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[d.MenuPosition.TOOLBAR_START],activated$:new b.Observable(t=>{const n=e.onCommandExecuted(o=>{var s;const r=o.id;if(r===u.SetTextSelectionsOperation.id||r===u.SetInlineFormatCommand.id){const c=H(i);if(c==null)return;const l=(s=c.ts)==null?void 0:s.it;t.next(l===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function on(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatUnderlineCommand.id,group:d.MenuGroup.TOOLBAR_FORMAT,type:d.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[d.MenuPosition.TOOLBAR_START],activated$:new b.Observable(t=>{const n=e.onCommandExecuted(o=>{var s;const r=o.id;if(r===u.SetTextSelectionsOperation.id||r===u.SetInlineFormatCommand.id){const c=H(i);if(c==null)return;const l=(s=c.ts)==null?void 0:s.ul;t.next((l==null?void 0:l.s)===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function rn(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatStrikethroughCommand.id,group:d.MenuGroup.TOOLBAR_FORMAT,type:d.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[d.MenuPosition.TOOLBAR_START],activated$:new b.Observable(t=>{const n=e.onCommandExecuted(o=>{var s;const r=o.id;if(r===u.SetTextSelectionsOperation.id||r===u.SetInlineFormatCommand.id){const c=H(i);if(c==null)return;const l=(s=c.ts)==null?void 0:s.st;t.next((l==null?void 0:l.s)===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function sn(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatSubscriptCommand.id,group:d.MenuGroup.TOOLBAR_FORMAT,type:d.MenuItemType.BUTTON,icon:"SubscriptSingle",tooltip:"toolbar.subscript",positions:[d.MenuPosition.TOOLBAR_START],activated$:new b.Observable(t=>{const n=e.onCommandExecuted(o=>{var s;const r=o.id;if(r===u.SetTextSelectionsOperation.id||r===u.SetInlineFormatCommand.id){const c=H(i);if(c==null)return;const l=(s=c.ts)==null?void 0:s.va;t.next(l===a.BaselineOffset.SUBSCRIPT)}});return t.next(!1),n.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function an(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatSuperscriptCommand.id,group:d.MenuGroup.TOOLBAR_FORMAT,type:d.MenuItemType.BUTTON,icon:"SuperscriptSingle",tooltip:"toolbar.superscript",positions:[d.MenuPosition.TOOLBAR_START],activated$:new b.Observable(t=>{const n=e.onCommandExecuted(o=>{var s;const r=o.id;if(r===u.SetTextSelectionsOperation.id||r===u.SetInlineFormatCommand.id){const c=H(i);if(c==null)return;const l=(s=c.ts)==null?void 0:s.va;t.next(l===a.BaselineOffset.SUPERSCRIPT)}});return t.next(!1),n.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function cn(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:d.MenuGroup.TOOLBAR_FORMAT,type:d.MenuItemType.SELECTOR,label:je,positions:[d.MenuPosition.TOOLBAR_START],selections:d.FONT_FAMILY_LIST.map(t=>({label:{name:We,hoverable:!0},value:t.value})),value$:new b.Observable(t=>{const n=d.FONT_FAMILY_LIST[0].value,o=e.onCommandExecuted(r=>{var c;const s=r.id;if(s===u.SetTextSelectionsOperation.id||s===u.SetInlineFormatFontFamilyCommand.id){const l=H(i);if(l==null)return;const p=(c=l.ts)==null?void 0:c.ff;t.next(p!=null?p:n)}});return t.next(n),o.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function ln(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatFontSizeCommand.id,group:d.MenuGroup.TOOLBAR_FORMAT,type:d.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:ke,props:{min:1,max:400}},positions:[d.MenuPosition.TOOLBAR_START],selections:d.FONT_SIZE_LIST,value$:new b.Observable(t=>{const o=e.onCommandExecuted(r=>{var c;const s=r.id;if(s===u.SetTextSelectionsOperation.id||s===u.SetInlineFormatFontSizeCommand.id){const l=H(i);if(l==null)return;const p=(c=l.ts)==null?void 0:c.fs;t.next(p!=null?p:14)}});return t.next(14),o.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function dn(i){const e=i.get(a.ICommandService),t=i.get(a.ThemeService);return{id:u.SetInlineFormatTextColorCommand.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:d.MenuGroup.TOOLBAR_FORMAT,type:d.MenuItemType.BUTTON_SELECTOR,positions:[d.MenuPosition.TOOLBAR_START],selections:[{label:{name:Se,hoverable:!1}}],value$:new b.Observable(n=>{const o=t.getCurrentTheme().textColor,r=e.onCommandExecuted(s=>{if(s.id===u.SetInlineFormatTextColorCommand.id){const c=s.params.value;n.next(c!=null?c:o)}});return n.next(o),r.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function un(i){return{id:tt.id,group:d.MenuGroup.TOOLBAR_OTHERS,type:d.MenuItemType.BUTTON,icon:"FreezeRowSingle",tooltip:"toolbar.headerFooter",positions:[d.MenuPosition.TOOLBAR_START],hidden$:b.combineLatest(d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC),d.getHeaderFooterMenuHiddenObservable(i),(e,t)=>e||t)}}function hn(i){const e=i.get(a.ICommandService);return{id:u.AlignLeftCommand.id,group:d.MenuGroup.TOOLBAR_LAYOUT,type:d.MenuItemType.BUTTON,icon:"LeftJustifyingSingle",tooltip:"toolbar.alignLeft",positions:[d.MenuPosition.TOOLBAR_START],activated$:new b.Observable(t=>{const n=e.onCommandExecuted(o=>{var s;const r=o.id;if(r===u.SetTextSelectionsOperation.id||r===u.AlignOperationCommand.id){const c=ae(i);if(c==null)return;const l=(s=c.paragraphStyle)==null?void 0:s.horizontalAlign;t.next(l===a.HorizontalAlign.LEFT)}});return t.next(!1),n.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function pn(i){const e=i.get(a.ICommandService);return{id:u.AlignCenterCommand.id,group:d.MenuGroup.TOOLBAR_LAYOUT,type:d.MenuItemType.BUTTON,icon:"HorizontallySingle",tooltip:"toolbar.alignCenter",positions:[d.MenuPosition.TOOLBAR_START],activated$:new b.Observable(t=>{const n=e.onCommandExecuted(o=>{var s;const r=o.id;if(r===u.SetTextSelectionsOperation.id||r===u.AlignOperationCommand.id){const c=ae(i);if(c==null)return;const l=(s=c.paragraphStyle)==null?void 0:s.horizontalAlign;t.next(l===a.HorizontalAlign.CENTER)}});return t.next(!1),n.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function gn(i){const e=i.get(a.ICommandService);return{id:u.AlignRightCommand.id,group:d.MenuGroup.TOOLBAR_LAYOUT,type:d.MenuItemType.BUTTON,icon:"RightJustifyingSingle",tooltip:"toolbar.alignRight",positions:[d.MenuPosition.TOOLBAR_START],activated$:new b.Observable(t=>{const n=e.onCommandExecuted(o=>{var s;const r=o.id;if(r===u.SetTextSelectionsOperation.id||r===u.AlignOperationCommand.id){const c=ae(i);if(c==null)return;const l=(s=c.paragraphStyle)==null?void 0:s.horizontalAlign;t.next(l===a.HorizontalAlign.RIGHT)}});return t.next(!1),n.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function mn(i){const e=i.get(a.ICommandService);return{id:u.AlignJustifyCommand.id,group:d.MenuGroup.TOOLBAR_LAYOUT,type:d.MenuItemType.BUTTON,icon:"AlignTextBothSingle",tooltip:"toolbar.alignJustify",positions:[d.MenuPosition.TOOLBAR_START],activated$:new b.Observable(t=>{const n=e.onCommandExecuted(o=>{var s;const r=o.id;if(r===u.SetTextSelectionsOperation.id||r===u.AlignOperationCommand.id){const c=ae(i);if(c==null)return;const l=(s=c.paragraphStyle)==null?void 0:s.horizontalAlign;t.next(l===a.HorizontalAlign.JUSTIFIED)}});return t.next(!1),n.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function _n(i){return{id:u.OrderListCommand.id,group:d.MenuGroup.TOOLBAR_LAYOUT,type:d.MenuItemType.BUTTON,icon:"OrderSingle",tooltip:"toolbar.order",positions:[d.MenuPosition.TOOLBAR_START],hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function fn(i){return{id:u.BulletListCommand.id,group:d.MenuGroup.TOOLBAR_LAYOUT,type:d.MenuItemType.BUTTON,icon:"UnorderSingle",tooltip:"toolbar.unorder",positions:[d.MenuPosition.TOOLBAR_START],hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function Sn(i){return{id:u.ResetInlineFormatTextBackgroundColorCommand.id,type:d.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:u.SetInlineFormatTextBackgroundColorCommand.id}}function vn(i){const e=i.get(a.ICommandService),t=i.get(a.ThemeService);return{id:u.SetInlineFormatTextBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:d.MenuGroup.TOOLBAR_FORMAT,type:d.MenuItemType.BUTTON_SELECTOR,positions:[d.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:Se,hoverable:!1}}],value$:new b.Observable(n=>{const o=t.getCurrentTheme().primaryColor,r=e.onCommandExecuted(s=>{if(s.id===u.SetInlineFormatTextBackgroundColorCommand.id){const c=s.params.value;n.next(c!=null?c:o)}});return n.next(o),r.dispose}),hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_DOC)}}function H(i){var p;const e=i.get(a.IUniverInstanceService),t=i.get(u.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),o=t.getActiveRange();if(n==null||o==null)return;const{startOffset:r,segmentId:s}=o,c=(p=n.getSelfOrHeaderFooterModel(s).getBody())==null?void 0:p.textRuns;if(c==null)return;let l;for(let _=0;_<c.length;_++){const f=c[_],m=c[_+1];if(m&&m.st===m.ed&&r===m.st){l=m;break}if(f.st<=r&&r<=f.ed){l=f;break}}return l}function ae(i){var p;const e=i.get(a.IUniverInstanceService),t=i.get(u.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),o=t.getActiveRange();if(n==null||o==null)return;const{startOffset:r,segmentId:s}=o,c=(p=n.getSelfOrHeaderFooterModel(s).getBody())==null?void 0:p.paragraphs;if(c==null)return;let l=-1;for(const _ of c){const{startIndex:f}=_;if(r>l&&r<=f)return _;l=f}return null}var In=Object.defineProperty,On=Object.getOwnPropertyDescriptor,Cn=(i,e,t,n)=>{for(var o=n>1?void 0:n?On(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&In(e,t,o),o},V=(i,e)=>(t,n)=>e(t,n,i);let X=class extends a.Disposable{constructor(i,e,t,n,o,r,s,c){super(),this._config=i,this._injector=e,this._componentManager=t,this._layoutService=n,this._editorService=o,this._menuService=r,this._uiPartsService=s,this._univerInstanceService=c,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Se,j.ColorPicker)),this.disposeWithMe(i.register(je,d.FontFamily)),this.disposeWithMe(i.register(We,d.FontFamilyItem)),this.disposeWithMe(i.register(ke,d.FontSize))}_initMenus(){const{menu:i={}}=this._config;[tn,nn,on,rn,sn,an,ln,cn,dn,un,hn,pn,gn,mn,_n,fn,Sn,vn].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e),i))})}_init(){this._initCustomComponents(),this._initMenus(),this._initDocBackground(),this._initFocusHandler()}_initDocBackground(){const i=this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_DOC)[0].getUnitId();if(i==null)return;this._editorService.isEditor(i)||this.disposeWithMe(this._uiPartsService.registerComponent(d.BuiltInUIPart.CONTENT,()=>w.connectInjector(Yt,this._injector)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(a.UniverInstanceType.UNIVER_DOC,()=>{this._injector.get(I.ITextSelectionRenderManager).focus()}))}};X=Cn([a.OnLifecycle(a.LifecycleStages.Rendered,X),V(1,E.Inject(E.Injector)),V(2,E.Inject(d.ComponentManager)),V(3,d.ILayoutService),V(4,d.IEditorService),V(5,d.IMenuService),V(6,d.IUIPartsService),V(7,a.IUniverInstanceService)],X);const Tn={id:u.BreakLineCommand.id,preconditions:lt,binding:d.KeyCode.ENTER},En={id:u.DeleteLeftCommand.id,preconditions:F,binding:d.KeyCode.BACKSPACE},bn={id:u.DeleteRightCommand.id,preconditions:F,binding:d.KeyCode.DELETE};function ce(i){return i.getContextValue(a.FOCUSING_DOC)||i.getContextValue(a.EDITOR_ACTIVATED)}const Ce=999,nt={id:d.CopyCommand.id,name:"doc.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:Ce,preconditions:ce,handler:async i=>i.get(k).copy()},it={id:d.CutCommand.id,name:"doc.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:Ce,preconditions:ce,handler:async i=>i.get(k).cut()},ot={id:d.PasteCommand.id,name:"doc.command.paste",type:a.CommandType.COMMAND,multi:!0,priority:Ce,preconditions:ce,handler:async i=>{const e=i.get(k),n=await i.get(d.IClipboardInterfaceService).read();return n.length===0?!1:e.paste(n)}};var Rn=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,Dn=(i,e,t,n)=>{for(var o=n>1?void 0:n?Mn(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Rn(e,t,o),o},Z=(i,e)=>(t,n)=>e(t,n,i);let le=class extends a.RxDisposable{constructor(i,e,t,n,o){super(),this._commandService=i,this._clipboardInterfaceService=e,this._docClipboardService=t,this._textSelectionRenderManager=n,this._contextService=o,this._init()}_init(){[nt,it,ot].forEach(i=>this.disposeWithMe(this._commandService.registerMultipleCommand(i))),[u.InnerPasteCommand,u.CutContentCommand].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i))),this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var i;(i=this._textSelectionRenderManager)==null||i.onPaste$.pipe(b.takeUntil(this.dispose$)).subscribe(e=>{var r,s;if(!ce(this._contextService))return;e.event.preventDefault();const t=e.event,n=(r=t.clipboardData)==null?void 0:r.getData("text/html"),o=(s=t.clipboardData)==null?void 0:s.getData("text/plain");this._docClipboardService.legacyPaste(n,o)})}};le=Dn([a.OnLifecycle(a.LifecycleStages.Rendered,le),Z(0,a.ICommandService),Z(1,d.IClipboardInterfaceService),Z(2,k),Z(3,I.ITextSelectionRenderManager),Z(4,a.IContextService)],le);var yn=Object.defineProperty,Pn=Object.getOwnPropertyDescriptor,An=(i,e,t,n)=>{for(var o=n>1?void 0:n?Pn(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&yn(e,t,o),o},q=(i,e)=>(t,n)=>e(t,n,i);let de=class extends a.Disposable{constructor(e,t,n,o,r){super();M(this,"_initialEditors",new Set);this._univerInstanceService=e,this._editorService=t,this._commandService=n,this._textSelectionRenderManager=o,this._renderManagerService=r,this._initialize()}_initialize(){this.disposeWithMe(this._editorService.resize$.subscribe(e=>{this._resize(e)})),this._editorService.getAllEditor().forEach(e=>{const t=e.editorUnitId;this._initialEditors.has(t)||(this._initialEditors.add(t),this._resize(t))}),this._commandExecutedListener(),this._initialSetValue(),this._initialBlur(),this._initialFocus(),this._initialValueChange()}_resize(e){var P,A,D;if(e==null)return;const t=this._editorService.getEditor(e);if((t==null?void 0:t.cancelDefaultResizeListener)===!0)return;const n=this._univerInstanceService.getUniverDocInstance(e);if(!n)return;const o=(P=this._renderManagerService.getRenderById(n.getUnitId()))==null?void 0:P.with(u.DocSkeletonManagerService).getSkeleton();if(t==null||t.render==null||o==null||n==null)return;o.calculate();const{marginTop:r=0,marginBottom:s=0,marginLeft:c=0,marginRight:l=0}=n.getSnapshot().documentStyle,{scene:p,mainComponent:_}=t.render;let{actualHeight:f,actualWidth:m}=o.getActualSize();f+=r+s,m+=c+l;const{width:h,height:v}=t.getBoundingClientRect(),g=p.getViewport(u.VIEWPORT_KEY.VIEW_MAIN);let S=g==null?void 0:g.getScrollBar();const C=Math.max(m,h),T=Math.max(f,v);p.transformByState({width:C,height:T}),_==null||_.resize(C,T),t.isSingle()?m>h?S==null?g&&new I.ScrollBar(g,{barSize:8,enableVertical:!1}):g==null||g.resetCanvasSizeAndUpdateScrollBar():(S=null,g==null||g.scrollTo({x:0,y:0}),(D=g==null?void 0:g.getScrollBar())==null||D.dispose()):f>v?S==null?g&&new I.ScrollBar(g,{enableHorizontal:!1,barSize:8}):g==null||g.resetCanvasSizeAndUpdateScrollBar():(S=null,g==null||g.scrollTo({x:0,y:0}),(A=g==null?void 0:g.getScrollBar())==null||A.dispose())}_initialSetValue(){this.disposeWithMe(this._editorService.setValue$.subscribe(e=>{this._commandService.executeCommand(u.CoverContentCommand.id,{unitId:e.editorUnitId,body:e.body,segmentId:null})}))}_initialBlur(){this.disposeWithMe(this._editorService.blur$.subscribe(()=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.blur()})),this.disposeWithMe(this._textSelectionRenderManager.onBlur$.subscribe(()=>{var o;const e=(o=this._univerInstanceService.getCurrentUniverDocInstance())==null?void 0:o.getUnitId();if(e==null)return;const t=this._editorService.getEditor(e),n=this._editorService.getFocusEditor();t==null||t.isSheetEditor()||n&&n.editorUnitId===e||this._editorService.blur()}))}_initialFocus(){this.disposeWithMe(this._editorService.focus$.subscribe(n=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.addTextRanges([n])}));const e=["univer-formula-search","univer-formula-help","formula-help-decorator","univer-formula-help-param"];this.disposeWithMe(b.fromEvent(window,"mousedown").subscribe(n=>{const r=n.target.classList[0]||"";if(a.checkForSubstrings(r,e)){this._editorService.changeSpreadsheetFocusState(!0),n.stopPropagation();return}this._editorService.changeSpreadsheetFocusState(!1)})),this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET).forEach(n=>{const o=n.getUnitId(),r=this._renderManagerService.getRenderById(o),s=r==null?void 0:r.engine.getCanvas().getCanvasEle();s!=null&&b.fromEvent(s,"mousedown").subscribe(c=>{this._editorService.changeSpreadsheetFocusState(!0),c.stopPropagation()})})}_initialValueChange(){this.disposeWithMe(this._textSelectionRenderManager.onCompositionupdate$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onInput$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onKeydown$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onPaste$.subscribe(this._valueChange.bind(this)))}_valueChange(){var n;const e=(n=this._univerInstanceService.getCurrentUniverDocInstance())==null?void 0:n.getUnitId();if(e==null)return;const t=this._editorService.getEditor(e);t==null||t.isSheetEditor()||this._editorService.refreshValueChange(e)}_commandExecutedListener(){const e=[u.RichTextEditingMutation.id,d.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{unitId:o}=n;if(this._editorService.isSheetEditor(o))return;this._resize(o),this._valueChange()}}))}};de=An([a.OnLifecycle(a.LifecycleStages.Rendered,de),q(0,a.IUniverInstanceService),q(1,d.IEditorService),q(2,a.ICommandService),q(3,I.ITextSelectionRenderManager),q(4,I.IRenderManagerService)],de);var Nn=Object.defineProperty,xn=Object.getOwnPropertyDescriptor,Un=(i,e,t,n)=>{for(var o=n>1?void 0:n?xn(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Nn(e,t,o),o},J=(i,e)=>(t,n)=>e(t,n,i);O.DocRenderController=class extends a.RxDisposable{constructor(e,t,n,o,r,s){super(),this._context=e,this._commandService=t,this._docSkeletonManagerService=n,this._configService=o,this._editorService=r,this._renderManagerService=s,this._addNewRender(),this._initRenderRefresh(),this._initCommandListener()}reRender(e){var r,s;const t=(r=this._renderManagerService.getRenderById(e))==null?void 0:r.with(u.DocSkeletonManagerService),n=t==null?void 0:t.getSkeleton();if(!(!n||n.getViewModel().getDataModel().getSnapshot().disabled)){if(n.calculate(),this._editorService.isEditor(e)){(s=this._context.mainComponent)==null||s.makeDirty();return}this._recalculateSizeBySkeleton(n)}}_addNewRender(){const{scene:e,engine:t,unit:n}=this._context,o=new I.Viewport(u.VIEWPORT_KEY.VIEW_MAIN,e,{left:0,top:0,bottom:0,right:0,isRelativeX:!0,isRelativeY:!0,isWheelPreventDefaultX:!0});e.attachControl(),e.onMouseWheel$.subscribeEvent((c,l)=>{const p=c;if(p.ctrlKey){const _=Math.abs(p.deltaX);let f=_<40?.2:_<80?.4:.2;f*=p.deltaY>0?-1:1,e.scaleX<1&&(f/=2),e.scaleX+f>4?e.scale(4,4):e.scaleX+f<.1?e.scale(.1,.1):p.preventDefault()}else o.onMouseWheel(p,l)}),this._configService.getConfig("hasScroll")!==!1&&new I.ScrollBar(o),e.addLayer(new I.Layer(e,[],u.DOCS_COMPONENT_MAIN_LAYER_INDEX),new I.Layer(e,[],u.DOCS_COMPONENT_HEADER_LAYER_INDEX)),this._addComponent(),n.getShouldRenderLoopImmediately()&&t.runRenderLoop(()=>{e.render()})}_addComponent(){const{scene:e,unit:t,components:n}=this._context,o={pageMarginLeft:t.documentStyle.marginLeft||0,pageMarginTop:t.documentStyle.marginTop||0},r=new I.Documents(u.DOCS_VIEW_KEY.MAIN,void 0,o);r.zIndex=u.DOCS_COMPONENT_DEFAULT_Z_INDEX;const s=new I.DocBackground(u.DOCS_VIEW_KEY.BACKGROUND,void 0,o);s.zIndex=u.DOCS_COMPONENT_DEFAULT_Z_INDEX,this._context.mainComponent=r,n.set(u.DOCS_VIEW_KEY.MAIN,r),n.set(u.DOCS_VIEW_KEY.BACKGROUND,s),e.addObjects([r],u.DOCS_COMPONENT_MAIN_LAYER_INDEX),e.addObjects([s],u.DOCS_COMPONENT_BACKGROUND_LAYER_INDEX),this._editorService.getEditor(t.getUnitId())==null&&e.enableLayerCache(u.DOCS_COMPONENT_MAIN_LAYER_INDEX)}_initRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.pipe(b.takeUntil(this.dispose$)).subscribe(e=>{this._create(e)})}_create(e){if(!e)return;const{mainComponent:t,components:n}=this._context,o=t,r=n.get(u.DOCS_VIEW_KEY.BACKGROUND);o.changeSkeleton(e),r.changeSkeleton(e),this._recalculateSizeBySkeleton(e)}_initCommandListener(){const e=[u.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{unitId:o}=n;this.reRender(o)}}))}_recalculateSizeBySkeleton(e){var f;const{mainComponent:t,scene:n,unitId:o,components:r}=this._context,s=t,c=r.get(u.DOCS_VIEW_KEY.BACKGROUND),l=(f=e.getSkeletonData())==null?void 0:f.pages;if(l==null)return;let p=0,_=0;for(let m=0,h=l.length;m<h;m++){const v=l[m],{pageWidth:g,pageHeight:S}=v;s.pageLayoutType===I.PageLayoutType.VERTICAL?(_+=S,_+=s.pageMarginTop,m===h-1&&(_+=s.pageMarginTop),p=Math.max(p,g)):s.pageLayoutType===I.PageLayoutType.HORIZONTAL&&(p+=g,m!==h-1&&(p+=s.pageMarginLeft),_=Math.max(_,S))}s.resize(p,_),c.resize(p,_),this._editorService.isEditor(o)||n.resize(p,_)}},O.DocRenderController=Un([J(1,a.ICommandService),J(2,E.Inject(u.DocSkeletonManagerService)),J(3,a.IConfigService),J(4,d.IEditorService),J(5,I.IRenderManagerService)],O.DocRenderController);var Fn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Bn=(i,e,t,n)=>{for(var o=n>1?void 0:n?Ln(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Fn(e,t,o),o},Te=(i,e)=>(t,n)=>e(t,n,i);let Ee=class extends a.Disposable{constructor(e,t,n,o){super();M(this,"_liquid",new I.Liquid);M(this,"_pageMarginCache",new Map);this._context=e,this._docSkeletonManagerService=t,this._commandService=n,this._editorService=o,this._initialize(),this._commandExecutedListener()}_initialize(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{e!=null&&this._refreshDrawing(e)})}_commandExecutedListener(){const e=[u.RichTextEditingMutation.id,u.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const o=t.params,{unitId:r}=o,s=this._docSkeletonManagerService.getSkeleton();if(!s)return;if(this._editorService.isEditor(r)){(n=this._context.mainComponent)==null||n.makeDirty();return}this._refreshDrawing(s)}}))}_refreshDrawing(e){const t=e==null?void 0:e.getSkeletonData(),{mainComponent:n,scene:o,unitId:r}=this._context,s=n;if(!t)return;const{left:c,top:l,pageLayoutType:p,pageMarginLeft:_,pageMarginTop:f}=s,{pages:m}=t,h=[];o.getAncestorScale(),this._liquid.reset(),this._pageMarginCache.clear();for(let v=0,g=m.length;v<g;v++){const S=m[v],{skeDrawings:C,marginLeft:T,marginTop:P}=S;this._liquid.translatePagePadding(S),C.forEach(A=>{const{aLeft:D,aTop:R,height:U,width:L,drawingId:B,drawingOrigin:ee}=A,ti=ee.layoutType===a.PositionedObjectLayoutType.WRAP_NONE&&ee.behindDoc===a.BooleanNumber.TRUE;h.push({unitId:r,subUnitId:a.DEFAULT_DOCUMENT_SUB_COMPONENT_ID,floatingObjectId:B,behindText:ti,floatingObject:{left:D+c+this._liquid.x,top:R+l+this._liquid.y,width:L,height:U}}),this._pageMarginCache.set(B,{marginLeft:this._liquid.x,marginTop:this._liquid.y})}),this._liquid.restorePagePadding(S),this._liquid.translatePage(S,p,_,f)}}};Ee=Bn([Te(1,E.Inject(u.DocSkeletonManagerService)),Te(2,a.ICommandService),Te(3,d.IEditorService)],Ee);var wn=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Hn=(i,e,t,n)=>{for(var o=n>1?void 0:n?$n(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&wn(e,t,o),o},Q=(i,e)=>(t,n)=>e(t,n,i);let be=class extends a.Disposable{constructor(i,e,t,n,o,r){super(),this._context=i,this._docSkeletonManagerService=e,this._univerInstanceService=t,this._commandService=n,this._textSelectionManagerService=o,this._editorService=r,this._init()}_init(){this._initSkeletonListener(),this._initCommandExecutedListener(),this._initRenderRefresher(),setTimeout(()=>this._updateViewZoom(1,!0),20)}_initRenderRefresher(){this._docSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,scene:t}=this._context;this._editorService.isEditor(e)||this.disposeWithMe(t.onMouseWheel$.subscribeEvent(n=>{if(!n.ctrlKey)return;const o=this._univerInstanceService.getCurrentUniverDocInstance();if(!o)return;const r=Math.abs(n.deltaX);let s=r<40?.2:r<80?.4:.2;s*=n.deltaY>0?-1:1,t.scaleX<1&&(s/=2);const c=o.zoomRatio;let l=+Number.parseFloat(`${c+s}`).toFixed(1);l=l>=4?4:l<=.1?.1:l,this._commandService.executeCommand(u.SetDocZoomRatioCommand.id,{zoomRatio:l,unitId:o.getUnitId()}),n.preventDefault()}))})}_initSkeletonListener(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const e=this._univerInstanceService.getCurrentUniverDocInstance();if(!e)return;const t=e.zoomRatio||1;this._updateViewZoom(t,!1)}))}_initCommandExecutedListener(){const i=[u.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._univerInstanceService.getCurrentUniverDocInstance();if(!t)return;const n=e.params,{unitId:o}=n;if(o!==t.getUnitId())return;const r=t.zoomRatio||1;this._updateViewZoom(r)}}))}_updateViewZoom(i,e=!0){var n;const t=u.neoGetDocObject(this._context);t.scene.scale(i,i),this._calculatePagePosition(t,i),e&&this._textSelectionManagerService.refreshSelection(),(n=t.scene.getTransformer())==null||n.clearSelectedObjects()}_calculatePagePosition(i,e){const{document:t,scene:n,docBackground:o}=i,r=n==null?void 0:n.getParent(),{width:s,height:c,pageMarginLeft:l,pageMarginTop:p}=t;if(r==null||s===Number.POSITIVE_INFINITY||c===Number.POSITIVE_INFINITY)return;const{width:_,height:f}=r;let m=0,h=0,v=0,g=0,S=Number.POSITIVE_INFINITY;_>(s+l*2)*e?(m=_/2-s*e/2,m/=e,v=(_-l*2)/e,S=0):(m=l,v=s+l*2,S=(v-_/e)/2),f>c?(h=f/2-c/2,g=(f-p*2)/e):(h=p,g=c+p*2),n.resize(v,g+200),t.translate(m,h),o.translate(m,h);const C=n.getViewport(u.VIEWPORT_KEY.VIEW_MAIN);if(S!==Number.POSITIVE_INFINITY&&C!=null){const T=C.transViewportScroll2ScrollValue(S,0).x;C.scrollTo({x:T})}return this}};be=Hn([Q(1,E.Inject(u.DocSkeletonManagerService)),Q(2,a.IUniverInstanceService),Q(3,a.ICommandService),Q(4,E.Inject(u.TextSelectionManagerService)),Q(5,d.IEditorService)],be);var Vn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Wn=(i,e,t,n)=>{for(var o=n>1?void 0:n?jn(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Vn(e,t,o),o},G=(i,e)=>(t,n)=>e(t,n,i);let Re=class extends a.Disposable{constructor(e,t,n,o,r,s,c){super();M(this,"_loadedMap",new WeakSet);this._context=e,this._commandService=t,this._editorService=n,this._instanceSrv=o,this._textSelectionRenderManager=r,this._docSkeletonManagerService=s,this._textSelectionManagerService=c,this._initialize()}_initialize(){this._init(),this._skeletonListener(),this._commandExecutedListener()}_init(){const{unitId:e}=this._context,t=u.neoGetDocObject(this._context);t==null||t.document==null||this._loadedMap.has(t.document)||(this._initialMain(e),this._loadedMap.add(t.document))}_initialMain(e){const t=u.neoGetDocObject(this._context),{document:n,scene:o}=t;this.disposeWithMe(n.onPointerEnter$.subscribeEvent(()=>{this._isEditorReadOnly(e)||(n.cursor=I.CURSOR_TYPE.TEXT)})),this.disposeWithMe(n.onPointerLeave$.subscribeEvent(()=>{n.cursor=I.CURSOR_TYPE.DEFAULT,o.resetCursor()})),this.disposeWithMe(n.onPointerDown$.subscribeEvent((r,s)=>{if(this._isEditorReadOnly(e))return;const c=this._instanceSrv.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC);(c==null?void 0:c.getUnitId())!==e&&this._instanceSrv.setCurrentUnitForType(e);const l=this._docSkeletonManagerService.getSkeleton(),{offsetX:p,offsetY:_}=r,f=this._getTransformCoordForDocumentOffset(p,_);if(f!=null){const{pageLayoutType:m=I.PageLayoutType.VERTICAL,pageMarginLeft:h,pageMarginTop:v}=n.getOffsetConfig(),{editArea:g}=l.findEditAreaByCoord(f,m,h,v),S=this._docSkeletonManagerService.getViewModel(),C=S.getEditArea();C!==I.DocumentEditArea.BODY&&g!==I.DocumentEditArea.BODY&&g!==C&&S.setEditArea(g)}if(this._textSelectionRenderManager.eventTrigger(r),this._editorService.getEditor(e)){this._setEditorFocus(e);const{offsetX:m,offsetY:h}=r;setTimeout(()=>{this._setEditorFocus(e),this._textSelectionRenderManager.setCursorManually(m,h)},0)}r.button!==2&&s.stopPropagation()})),this.disposeWithMe(n.onDblclick$.subscribeEvent(r=>{this._isEditorReadOnly(e)||this._textSelectionRenderManager.handleDblClick(r)})),this.disposeWithMe(n.onTripleClick$.subscribeEvent(r=>{this._isEditorReadOnly(e)||this._textSelectionRenderManager.handleTripleClick(r)}))}_getTransformCoordForDocumentOffset(e,t){const n=u.neoGetDocObject(this._context),{document:o,scene:r}=n,{documentTransform:s}=o.getOffsetConfig(),c=r.getViewports()[0];if(c==null)return;const l=c.transformVector2SceneCoord(I.Vector2.FromArray([e,t]));return s.clone().invert().applyPoint(l)}_isEditorReadOnly(e){const t=this._editorService.getEditor(e);return t?t.isReadOnly():!1}_setEditorFocus(e){this._editorService.focusStyle(e)}_commandExecutedListener(){const e=[u.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const o=t.params,{unitId:r}=o,s=(n=this._textSelectionManagerService.getCurrentSelection())==null?void 0:n.unitId;if(r!==s)return;this._textSelectionManagerService.refreshSelection()}}))}_skeletonListener(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{scene:t,mainComponent:n,unitId:o}=this._context;this._textSelectionRenderManager.changeRuntime(e,t,n),this._textSelectionManagerService.setCurrentSelectionNotRefresh({unitId:o,subUnitId:""}),this._editorService.isEditor(o)||this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}],!1)}))}};Re=Wn([G(1,a.ICommandService),G(2,d.IEditorService),G(3,a.IUniverInstanceService),G(4,I.ITextSelectionRenderManager),G(5,E.Inject(u.DocSkeletonManagerService)),G(6,E.Inject(u.TextSelectionManagerService))],Re);var kn=Object.defineProperty,Gn=Object.getOwnPropertyDescriptor,Yn=(i,e,t,n)=>{for(var o=n>1?void 0:n?Gn(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&kn(e,t,o),o},ue=(i,e)=>(t,n)=>e(t,n,i);function rt(i,e){const t=st(i.left,i.top,e),n=st(i.right,i.bottom,e);return{left:t.x,top:t.y,right:n.x,bottom:n.y}}function st(i,e,t){const{scaleX:n,scaleY:o}=t.getAncestorScale(),r=t.getViewport(u.VIEWPORT_KEY.VIEW_MAIN);if(!r)return{x:i,y:e};const{viewportScrollX:s,viewportScrollY:c}=r,l=(i-s)*n,p=(e-c)*o;return{x:l,y:p}}O.DocCanvasPopManagerService=class extends a.Disposable{constructor(e,t,n,o){super(),this._globalPopupManagerService=e,this._renderManagerService=t,this._univerInstanceService=n,this._commandService=o}_createObjectPositionObserver(e,t){const n=()=>{const{scene:l}=t,{left:p,top:_,width:f,height:m}=e,h={left:p,right:p+f,top:_,bottom:_+m},v=rt(h,l);return{left:v.left,right:v.right,top:v.top,bottom:v.bottom}},o=n(),r=new b.BehaviorSubject(o),s=new a.DisposableCollection;s.add(this._commandService.onCommandExecuted(l=>{l.id===u.SetDocZoomRatioOperation.id&&r.next(n())}));const c=t.scene.getViewport(u.VIEWPORT_KEY.VIEW_MAIN);return c&&s.add(c.onScrollAfter$.subscribeEvent(()=>{r.next(n())})),{position:o,position$:r,disposable:s}}_createRangePositionObserver(e,t){var l;const n=()=>{const{scene:p,mainComponent:_}=t,f=t.with(u.DocSkeletonManagerService).getSkeleton(),m=f.findNodePositionByCharIndex(e.startOffset),h=f.findNodePositionByCharIndex(e.endOffset),v=_;if(!h||!m)return;const g=v.getOffsetConfig(),{docsLeft:S,docsTop:C}=g,T=new I.NodePositionConvertToCursor(g,f),{borderBoxPointGroup:P}=T.getRangePointData(m,h);return I.getLineBounding(P).map(R=>rt(R,p)).map(R=>({left:R.left+S,right:R.right+S,top:R.top+C,bottom:R.bottom+C}))},o=(l=n())!=null?l:[],r=new b.BehaviorSubject(o),s=new a.DisposableCollection;s.add(this._commandService.onCommandExecuted(p=>{if(p.id===u.SetDocZoomRatioOperation.id){const _=n();_&&r.next(_)}}));const c=t.scene.getViewport(u.VIEWPORT_KEY.VIEW_MAIN);return c&&s.add(c.onScrollAfter$.subscribeEvent(()=>{const p=n();p&&r.next(p)})),{positions:o,positions$:r,disposable:s}}attachPopupToObject(e,t){const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC).getUnitId(),r=this._renderManagerService.getRenderById(o);if(!r)return{dispose:()=>{}};const{position:s,position$:c,disposable:l}=this._createObjectPositionObserver(e,r),p=this._globalPopupManagerService.addPopup({...t,unitId:o,subUnitId:"default",anchorRect:s,anchorRect$:c});return{dispose:()=>{this._globalPopupManagerService.removePopup(p),c.complete(),l.dispose()}}}attachPopupToRange(e,t){const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC).getUnitId(),{direction:r="top"}=t,s=this._renderManagerService.getRenderById(o);if(!s)return{dispose:()=>{}};const{positions:c,positions$:l,disposable:p}=this._createRangePositionObserver(e,s),_=l.pipe(b.map(m=>r==="top"?m[0]:m[m.length-1])),f=this._globalPopupManagerService.addPopup({...t,unitId:o,subUnitId:"default",anchorRect:r==="top"?c[0]:c[c.length-1],anchorRect$:_,excludeRects:c,excludeRects$:l,direction:r==="top"?"top":"bottom"});return{dispose:()=>{this._globalPopupManagerService.removePopup(f),l.complete(),p.dispose()}}}},O.DocCanvasPopManagerService=Yn([ue(0,E.Inject(d.ICanvasPopupService)),ue(1,I.IRenderManagerService),ue(2,a.IUniverInstanceService),ue(3,a.ICommandService)],O.DocCanvasPopManagerService);var zn=Object.defineProperty,Kn=Object.getOwnPropertyDescriptor,Xn=(i,e,t,n)=>{for(var o=n>1?void 0:n?Kn(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&zn(e,t,o),o},at=(i,e)=>(t,n)=>e(t,n,i);O.DocsRenderService=class extends a.RxDisposable{constructor(e,t){super(),this._instanceSrv=e,this._renderManagerService=t,this._init()}_init(){this._renderManagerService.createRender$.pipe(b.takeUntil(this.dispose$)).subscribe(e=>this._createRenderWithId(e)),this._instanceSrv.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_DOC).pipe(b.takeUntil(this.dispose$)).subscribe(e=>this._createRenderer(e)),this._instanceSrv.getAllUnitsForType(a.UniverInstanceType.UNIVER_DOC).forEach(e=>this._createRenderer(e)),this._instanceSrv.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_DOC).pipe(b.takeUntil(this.dispose$)).subscribe(e=>this._disposeRenderer(e))}_createRenderer(e){const t=e.getUnitId();this._renderManagerService.has(t)||(this._createRenderWithId(t),this._renderManagerService.setCurrent(t))}_createRenderWithId(e){this._renderManagerService.createRender(e)}_disposeRenderer(e){const t=e.getUnitId();this._renderManagerService.removeRender(t)}},O.DocsRenderService=Xn([a.OnLifecycle(a.LifecycleStages.Ready,O.DocsRenderService),at(0,a.IUniverInstanceService),at(1,I.IRenderManagerService)],O.DocsRenderService);var Zn=Object.defineProperty,qn=Object.getOwnPropertyDescriptor,Jn=(i,e,t,n)=>{for(var o=n>1?void 0:n?qn(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Zn(e,t,o),o},Me=(i,e)=>(t,n)=>e(t,n,i);O.UniverDocsUIPlugin=(pe=class extends a.Plugin{constructor(e,t,n,o){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._logService=o,this._config=a.Tools.deepMerge({},$e,this._config),this._initDependencies(t),this._initializeCommands()}onReady(){this._initRenderBasics()}onRendered(){this._initUI(),this._initRenderModules(),this._markDocAsFocused()}_initializeCommands(){[Et,bt,Mt,Rt,Dt,yt,Pt,At,Nt,En,bn,Tn].forEach(e=>{this._injector.get(d.IShortcutService).registerShortcut(e)})}_initDependencies(e){[[X,{useFactory:()=>this._injector.createInstance(X,this._config)}],[le],[de],[O.DocsRenderService],[K,{useFactory:()=>this._injector.createInstance(K,this._config)}],[k,{useClass:_e}],[O.DocCanvasPopManagerService]].forEach(n=>e.add(n))}_markDocAsFocused(){const e=this._injector.get(a.IUniverInstanceService),t=this._injector.get(d.IEditorService);try{const n=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC);if(!n)return;const o=n.getUnitId();t.isEditor(o)||e.focusUnit(n.getUnitId())}catch(n){this._logService.warn(n)}}_initUI(){this._injector.get(K)}_initRenderBasics(){[u.DocSkeletonManagerService,u.DocInterceptorService,O.DocRenderController,be].forEach(e=>{this._renderManagerSrv.registerRenderModule(a.UniverInstanceType.UNIVER_DOC,e)})}_initRenderModules(){[O.DocBackScrollRenderController,Ee,Re,Ie].forEach(e=>{this._renderManagerSrv.registerRenderModule(a.UniverInstanceType.UNIVER_DOC,e)})}},M(pe,"pluginName",He),M(pe,"type",a.UniverInstanceType.UNIVER_DOC),pe),O.UniverDocsUIPlugin=Jn([Me(1,E.Inject(E.Injector)),Me(2,I.IRenderManagerService),Me(3,a.ILogService)],O.UniverDocsUIPlugin);function Qn(i){return{left:i.positionH.posOffset,top:i.positionV.posOffset,width:i.size.width,height:i.size.height}}function ei(i,e=0,t=0){return{size:{width:i.width,height:i.height},positionH:{relativeFrom:a.ObjectRelativeFromH.MARGIN,posOffset:(i.left||0)-e},positionV:{relativeFrom:a.ObjectRelativeFromV.PAGE,posOffset:(i.top||0)-t},angle:i.angle||0}}O.DOC_UI_PLUGIN_NAME=He,O.DefaultDocContainerConfig=we,O.DefaultDocUiConfig=$e,O.DefaultToolbarConfig=Be,O.DocCopyCommand=nt,O.DocCutCommand=it,O.DocPasteCommand=ot,O.IDocClipboardService=k,O.PastePluginLark=Pe,O.PastePluginUniver=xe,O.PastePluginWord=Ne,O.docDrawingPositionToTransform=Qn,O.transformToDocDrawingPosition=ei,O.whenDocAndEditorFocused=F,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-ui",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer normal ui-plugin-docs",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -50,30 +50,32 @@
|
|
|
50
50
|
"lib"
|
|
51
51
|
],
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@wendellhu/redi": "0.15.
|
|
53
|
+
"@wendellhu/redi": "0.15.5",
|
|
54
|
+
"clsx": ">=2.0.0",
|
|
54
55
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
55
56
|
"rxjs": ">=7.0.0",
|
|
56
|
-
"@univerjs/core": "0.1
|
|
57
|
-
"@univerjs/design": "0.1
|
|
58
|
-
"@univerjs/docs": "0.1
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
57
|
+
"@univerjs/core": "0.2.1",
|
|
58
|
+
"@univerjs/design": "0.2.1",
|
|
59
|
+
"@univerjs/docs": "0.2.1",
|
|
60
|
+
"@univerjs/engine-render": "0.2.1",
|
|
61
|
+
"@univerjs/ui": "0.2.1"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@types/react": "^18.3.3",
|
|
64
|
-
"@wendellhu/redi": "0.15.
|
|
65
|
+
"@wendellhu/redi": "0.15.5",
|
|
66
|
+
"clsx": "^2.1.1",
|
|
65
67
|
"less": "^4.2.0",
|
|
66
68
|
"react": "18.3.1",
|
|
67
69
|
"rxjs": "^7.8.1",
|
|
68
|
-
"typescript": "^5.
|
|
69
|
-
"vite": "^5.3.
|
|
70
|
+
"typescript": "^5.5.3",
|
|
71
|
+
"vite": "^5.3.3",
|
|
70
72
|
"vitest": "^1.6.0",
|
|
71
|
-
"@univerjs/
|
|
72
|
-
"@univerjs/
|
|
73
|
-
"@univerjs/docs": "0.1
|
|
74
|
-
"@univerjs/engine-render": "0.1
|
|
75
|
-
"@univerjs/shared": "0.1
|
|
76
|
-
"@univerjs/ui": "0.1
|
|
73
|
+
"@univerjs/core": "0.2.1",
|
|
74
|
+
"@univerjs/design": "0.2.1",
|
|
75
|
+
"@univerjs/docs": "0.2.1",
|
|
76
|
+
"@univerjs/engine-render": "0.2.1",
|
|
77
|
+
"@univerjs/shared": "0.2.1",
|
|
78
|
+
"@univerjs/ui": "0.2.1"
|
|
77
79
|
},
|
|
78
80
|
"univerSpace": {
|
|
79
81
|
".": {
|