@univerjs/docs-ui 0.1.16 → 0.2.0

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