@univerjs/docs-ui 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var we=Object.defineProperty;var je=(r,e,t)=>e in r?we(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var
|
|
1
|
+
"use strict";var we=Object.defineProperty;var je=(r,e,t)=>e in r?we(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var C=(r,e,t)=>(je(r,typeof e!="symbol"?e+"":e,t),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"),Ve=require("@wendellhu/redi/react-bindings"),m=require("@univerjs/engine-render"),We=require("react"),T=require("rxjs"),ke=require("@univerjs/design"),Re={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},Me={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},ye={layout:{docContainerConfig:Me,toolbarConfig:Re}},Ee="DocUI";function E(r){return r.getContextValue(a.FOCUSING_DOC)&&r.getContextValue(a.FOCUSING_UNIVER_EDITOR)}function He(r){return r.getContextValue(a.FOCUSING_DOC)&&r.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!r.getContextValue(a.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE)}const ze={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_UP,preconditions:E,staticParameters:{direction:a.Direction.UP}},Ye={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_DOWN,preconditions:E,staticParameters:{direction:a.Direction.DOWN}},Ge={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_LEFT,preconditions:E,staticParameters:{direction:a.Direction.LEFT}},Ke={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_RIGHT,preconditions:E,staticParameters:{direction:a.Direction.RIGHT}},Xe={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_UP|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.UP}},qe={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_DOWN|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.DOWN}},Ze={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_LEFT|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.LEFT}},Je={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_RIGHT|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.RIGHT}},Qe={id:d.SelectAllOperation.id,binding:l.KeyCode.A|l.MetaKeys.CTRL_COMMAND,preconditions:r=>r.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&(r.getContextValue(a.FOCUSING_DOC)||r.getContextValue(a.EDITOR_ACTIVATED))};var et=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(r,e,t,n)=>{for(var i=n>1?void 0:n?tt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&et(e,t,i),i},ve=(r,e)=>(t,n)=>e(t,n,r);let pe=class{constructor(r,e,t){C(this,"_docContainer");C(this,"getComponent",r=>{if(this._docContainer=r,!r.getContentRef().current)throw new Error("container is not ready")});C(this,"changeLocale",r=>{this._localeService.setLocale(r)});this._config=r,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(r){if(this._docContainer)return r(this._docContainer)}getDocContainer(){return this._docContainer}};pe=nt([ve(1,O.Inject(a.LocaleService)),ve(2,O.Inject(O.Injector))],pe);var it=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,ot=(r,e,t,n)=>{for(var i=n>1?void 0:n?rt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&it(e,t,i),i},X=(r,e)=>(t,n)=>e(t,n,r);let k=class extends a.RxDisposable{constructor(e,t,n,i,o){super();C(this,"_docContainerController");C(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._localeService=t,this._injector=n,this._textSelectionRenderManager=i,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}};k=ot([X(1,O.Inject(a.LocaleService)),X(2,O.Inject(O.Injector)),X(3,m.ITextSelectionRenderManager),X(4,O.Optional(l.ILayoutService))],k);const ae="UI_PLUGIN_DOCS",Se=`${ae}_COLOR_PICKER_COMPONENT`,De=`${ae}_FONT_FAMILY_COMPONENT`,xe=`${ae}_FONT_FAMILY_ITEM_COMPONENT`,Ue=`${ae}_FONT_SIZE_COMPONENT`;var Pe={exports:{}},ce={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var st=We,at=Symbol.for("react.element"),ct=Symbol.for("react.fragment"),lt=Object.prototype.hasOwnProperty,dt=st.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ut={key:!0,ref:!0,__self:!0,__source:!0};function Ne(r,e,t){var n,i={},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)lt.call(e,n)&&!ut.hasOwnProperty(n)&&(i[n]=e[n]);if(r&&r.defaultProps)for(n in e=r.defaultProps,e)i[n]===void 0&&(i[n]=e[n]);return{$$typeof:at,type:r,key:o,ref:s,props:i,_owner:dt.current}}ce.Fragment=ct;ce.jsx=Ne;ce.jsxs=Ne;Pe.exports=ce;var ht=Pe.exports;const gt="univer-docs-ui-canvas-background",pt={docsUiCanvasBackground:gt},_t=()=>ht.jsx("div",{className:pt.docsUiCanvasBackground});function St(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function mt(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function ft(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function vt(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Ct(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function It(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Ot(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,label:De,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,i=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatFontFamilyCommand.id){const u=U(r);if(u==null)return;const g=(c=u.ts)==null?void 0:c.ff;t.next(g!=null?g:n)}});return t.next(n),i.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function Tt(r){const e=r.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 i=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatFontSizeCommand.id){const u=U(r);if(u==null)return;const g=(c=u.ts)==null?void 0:c.fs;t.next(g!=null?g:14)}});return t.next(14),i.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function bt(r){const e=r.get(a.ICommandService),t=r.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:Se,hoverable:!1}}],value$:new T.Observable(n=>{const i=t.getCurrentTheme().textColor,o=e.onCommandExecuted(s=>{if(s.id===d.SetInlineFormatTextColorCommand.id){const c=s.params.value;n.next(c!=null?c:i)}});return n.next(i),o.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function Rt(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=le(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Mt(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=le(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function yt(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=le(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Et(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=le(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Dt(r){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(r,a.UniverInstanceType.UNIVER_DOC)}}function xt(r){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(r,a.UniverInstanceType.UNIVER_DOC)}}function Ut(r){return{id:d.ResetInlineFormatTextBackgroundColorCommand.id,type:l.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:d.SetInlineFormatTextBackgroundColorCommand.id}}function Pt(r){const e=r.get(a.ICommandService),t=r.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:Se,hoverable:!1}}],value$:new T.Observable(n=>{const i=t.getCurrentTheme().primaryColor,o=e.onCommandExecuted(s=>{if(s.id===d.SetInlineFormatTextBackgroundColorCommand.id){const c=s.params.value;n.next(c!=null?c:i)}});return n.next(i),o.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function U(r){var u;const e=r.get(a.IUniverInstanceService),t=r.get(d.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),i=t.getActiveRange();if(n==null||i==null)return;const o=(u=n.getBody())==null?void 0:u.textRuns;if(o==null)return;const{startOffset:s}=i;return o.find(({st:g,ed:p})=>s>=g&&s<p)}function le(r){var u;const e=r.get(a.IUniverInstanceService),t=r.get(d.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),i=t.getActiveRange();if(n==null||i==null)return;const o=(u=n.getBody())==null?void 0:u.paragraphs;if(o==null)return;const{startOffset:s}=i;let c=-1;for(const g of o){const{startIndex:p}=g;if(s>c&&s<=p)return g;c=p}return null}var Nt=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,At=(r,e,t,n)=>{for(var i=n>1?void 0:n?Lt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Nt(e,t,i),i},P=(r,e)=>(t,n)=>e(t,n,r);let J=class extends a.Disposable{constructor(r,e,t,n,i,o,s){super(),this._injector=r,this._componentManager=e,this._layoutService=t,this._editorService=n,this._menuService=i,this._uiController=o,this._univerInstanceService=s,this._init()}_initCustomComponents(){const r=this._componentManager;this.disposeWithMe(r.register(Se,ke.ColorPicker)),this.disposeWithMe(r.register(De,l.FontFamily)),this.disposeWithMe(r.register(xe,l.FontFamilyItem)),this.disposeWithMe(r.register(Ue,l.FontSize))}_initMenus(){[St,mt,ft,vt,Ct,It,Tt,Ot,bt,Rt,Mt,yt,Et,Dt,xt,Ut,Pt].forEach(r=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(r)))})}_init(){this._initCustomComponents(),this._initMenus(),this._initDocBackground(),this._initFocusHandler()}_initDocBackground(){const r=this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_DOC)[0].getUnitId();if(r==null)return;this._editorService.isEditor(r)||this.disposeWithMe(this._uiController.registerComponent(l.DesktopUIPart.CONTENT,()=>Ve.connectInjector(_t,this._injector)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(a.UniverInstanceType.UNIVER_DOC,()=>{this._injector.get(m.ITextSelectionRenderManager).focus()}))}};J=At([a.OnLifecycle(a.LifecycleStages.Rendered,J),P(0,O.Inject(O.Injector)),P(1,O.Inject(l.ComponentManager)),P(2,l.ILayoutService),P(3,l.IEditorService),P(4,l.IMenuService),P(5,l.IUIController),P(6,a.IUniverInstanceService)],J);const Bt={toolbar:{undo:"Undo",redo:"Redo",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},fillColor:{main:"Text Background color",right:"Choose color"},resetColor:"Reset",order:"Ordered list",unorder:"Unordered list",alignLeft:"Align Left",alignCenter:"Align Center",alignRight:"Align Right",alignJustify:"Justify"}},Ft=Bt,$t={toolbar:{undo:"撤销",redo:"重做",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},fillColor:{main:"文本背景色",right:"背景色选择"},resetColor:"重置颜色",order:"有序列表",unorder:"无序列表",alignLeft:"左对齐",alignCenter:"居中对齐",alignRight:"右对齐",alignJustify:"两端对齐"}},Le=$t,wt={toolbar:{undo:"Отменить",redo:"Повторить",font:"Шрифт",fontSize:"Размер шрифта",bold:"Полужирный",italic:"Курсив",strikethrough:"Зачеркнутый",subscript:"Нижний индекс",superscript:"Верхний индекс",underline:"Подчеркнутый",textColor:{main:"Цвет текста",right:"Выбрать цвет"},fillColor:{main:"Цвет фона текста",right:"Выбрать цвет"},resetColor:"Сбросить",order:"Упорядоченный список",unorder:"Неупорядоченный список",alignLeft:"Выровнять по левому краю",alignCenter:"Выровнять по центру",alignRight:"Выровнять по правому краю",alignJustify:"Выровнять по ширине"}},jt=wt,Vt={id:d.BreakLineCommand.id,preconditions:He,binding:l.KeyCode.ENTER},Wt={id:d.DeleteLeftCommand.id,preconditions:E,binding:l.KeyCode.BACKSPACE},kt={id:d.DeleteRightCommand.id,preconditions:E,binding:l.KeyCode.DELETE},Ht=10,zt=6;function Yt(){return a.Tools.generateRandomId(zt)}function Gt(r){const e=r.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class Kt{constructor(){I(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 Ce=new Kt;function me(r){const e=r.style,t={},n=r.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 i=0;i<e.length;i++){const o=e[i],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=m.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 Xt(r){const e=new DOMParser,t=`<x-univer id="univer-root">${r}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function Ie(r,e){const t=r.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(r)}const se=class se{constructor(){I(this,"_styleCache",new Map);I(this,"_styleRules",[]);I(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=se._pluginList.find(o=>o.checkPasteType(e)),n=Xt(e),i={dataStream:"",textRuns:[]};return t&&(this._styleRules=[...t.stylesRules],this._afterProcessRules=[...t.afterProcessRules]),this._styleCache.clear(),this._process(null,n==null?void 0:n.childNodes,i),this._styleCache.clear(),this._styleRules=[],this._afterProcessRules=[],i}_process(e,t,n){var i;for(const o of t)if(o.nodeType===Node.TEXT_NODE){const s=(i=o.nodeValue)==null?void 0:i.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:_})=>Ie(o,_)),u=c?c.getStyle(o):me(o);this._styleCache.set(o,{...s,...u});const{childNodes:g}=o;this._process(o,g,n);const p=this._afterProcessRules.find(({filter:_})=>Ie(o,_));p&&p.handler(n,o)}}};I(se,"_pluginList",[]);let w=se;const qt={name:"univer-doc-paste-plugin-lark",checkPasteType(r){return/lark-record-clipboard/i.test(r)},stylesRules:[{filter:["s"],getStyle(r){const e=me(r);return{st:{s:a.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(r){return r.tagName==="DIV"&&/ace-line/i.test(r.className)},handler(r){r.paragraphs==null&&(r.paragraphs=[]),r.paragraphs.push({startIndex:r.dataStream.length}),r.dataStream+="\r"}}]},Ae=qt;function Be(r){const e=r.style,t={};for(let n=0;n<e.length;n++){const i=e[n],o=e.getPropertyValue(i);switch(i){case"margin-top":{const s=Number.parseInt(o);t.spaceAbove=/pt/.test(o)?m.ptToPixel(s):s;break}case"margin-bottom":{const s=Number.parseInt(o);t.spaceBelow=/pt/.test(o)?m.ptToPixel(s):s;break}case"line-height":{const s=Number.parseFloat(o);t.lineSpacing=s;break}}}return Object.getOwnPropertyNames(t).length?t:null}const Zt={name:"univer-doc-paste-plugin-word",checkPasteType(r){return/word|mso/i.test(r)},stylesRules:[{filter:["b"],getStyle(r){const e=me(r);return{bl:a.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(r){return r.tagName==="P"&&/mso/i.test(r.className)},handler(r,e){r.paragraphs==null&&(r.paragraphs=[]);const t={startIndex:r.dataStream.length},n=Be(e);n&&(t.paragraphStyle=n),r.paragraphs.push(t),r.dataStream+="\r"}}]},Fe=Zt,Jt={name:"univer-doc-paste-plugin-univer",checkPasteType(r){return/UniverNormal/i.test(r)},stylesRules:[],afterProcessRules:[{filter(r){return r.tagName==="P"&&/UniverNormal/i.test(r.className)},handler(r,e){r.paragraphs==null&&(r.paragraphs=[]);const t={startIndex:r.dataStream.length},n=Be(e);n&&(t.paragraphStyle=n),r.paragraphs.push(t),r.dataStream+="\r"}}]},$e=Jt;function Oe(r,e){const{st:t,ed:n,ts:i={}}=e,{ff:o,fs:s,it:c,bl:u,ul:g,st:p,ol:_,bg:f,cl:S,va:v}=i;let h=r.slice(t,n);const C=[];return c===a.BooleanNumber.TRUE&&(h=`<i>${h}</i>`),v===a.BaselineOffset.SUPERSCRIPT?h=`<sup>${h}</sup>`:v===a.BaselineOffset.SUBSCRIPT&&(h=`<sub>${h}</sub>`),(g==null?void 0:g.s)===a.BooleanNumber.TRUE&&(h=`<u>${h}</u>`),(p==null?void 0:p.s)===a.BooleanNumber.TRUE&&(h=`<s>${h}</s>`),u===a.BooleanNumber.TRUE&&(h=`<strong>${h}</strong>`),o&&C.push(`font-family: ${o}`),S&&C.push(`color: ${S.rgb}`),s&&C.push(`font-size: ${s}pt`),_&&C.push("text-decoration: overline"),f&&C.push(`background: ${f.rgb}`),C.length?`<span style="${C.join("; ")};">${h}</span>`:h}function he(r,e,t){const{dataStream:n,textRuns:i=[]}=r;let o=e;const s=[];for(const c of i){const{st:u,ed:g}=c;a.Tools.hasIntersectionBetweenTwoRanges(e,t,u,g)&&(u>o?(s.push(n.slice(o,u)),s.push(Oe(n,{...c,ed:Math.min(g,t)}))):s.push(Oe(n,{...c,st:o,ed:Math.min(g,t)}))),o=Math.max(e,Math.min(g,t))}return o!==t&&s.push(n.slice(o,t)),s.join("")}function Te(r,e=!0){var t;if(e&&((t=r.paragraphs)!=null&&t.length)){const{dataStream:n,paragraphs:i=[]}=r;let o="",s=-1;for(const c of i){const{startIndex:u,paragraphStyle:g={}}=c,{spaceAbove:p,spaceBelow:_,lineSpacing:f}=g,S=[];p!=null&&(typeof p=="number"?S.push(`margin-top: ${p}px`):S.push(`margin-top: ${p.v}px`)),_!=null&&(typeof _=="number"?S.push(`margin-bottom: ${_}px`):S.push(`margin-bottom: ${_.v}px`)),f!=null&&S.push(`line-height: ${f}`),u>s+1?o+=`<p class="UniverNormal" ${S.length?`style="${S.join("; ")};"`:""}>${he(r,s+1,u)}</p>`:o+=`<p class="UniverNormal" ${S.length?`style="${S.join("; ")};"`:""}></p>`,s=u}return s!==n.length&&(o+=he(r,s,n.length)),o}else return he(r,0,r.dataStream.length)}class Qt{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 en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=(r,e,t,n)=>{for(var i=n>1?void 0:n?tn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&en(e,t,i),i},j=(r,e)=>(t,n)=>e(t,n,r);w.use(Fe);w.use(Ae);w.use($e);function rn(r){const e=r.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 H=O.createIdentifier("doc.clipboard-service");let _e=class extends a.Disposable{constructor(e,t,n,i,o){super();I(this,"_clipboardHooks",[]);I(this,"_htmlToUDM",new w);I(this,"_umdToHtml",new Qt);this._univerInstanceService=e,this._logService=t,this._commandService=n,this._clipboardInterfaceService=i,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:{},i=this._textSelectionManagerService.getSelections();if(e==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),t==null||i==null)return!1;this.copy();try{let s=t;for(const u of i){const{startOffset:g,endOffset:p}=u;g==null||p==null||p<=t&&(s-=p-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){var s;const{segmentId:t,endOffset:n,style:i}=(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 g of o){const{startOffset:p,endOffset:_}=g;p==null||_==null||_<=n&&(c+=e.dataStream.length-(_-p))}const u=[{startOffset:c,endOffset:c,style:i}];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=Yt(),n=e.length>1?e.map(o=>o.dataStream).join(`
|
|
10
|
-
`):e[0].dataStream;let i=this._umdToHtml.convert(e);return e.length===1&&(i=i.replace(/(<[a-z]+)/,(o,s)=>`${s} data-copy-id="${t}"`),Ce.set(t,e[0])),this._clipboardInterfaceService.write(n,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._univerInstanceService.getCurrentUniverDocInstance(),n=[];if(e==null||!t)return n;for(const i of e){const{startOffset:o,endOffset:s,collapsed:c}=i;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 i of e)for(const o of i.types)o===l.PLAIN_TEXT_CLIPBOARD_MIME_TYPE?n=await i.getType(o).then(s=>s&&s.text()):o===l.HTML_CLIPBOARD_MIME_TYPE&&(t=await i.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 rn(t);throw new Error("[DocClipboardService] html and text cannot be both empty!")}const n=Gt(e);if(n){const i=Ce.get(n);if(i)return i}return this._htmlToUDM.convert(e)}};_e=nn([j(0,a.IUniverInstanceService),j(1,a.ILogService),j(2,a.ICommandService),j(3,l.IClipboardInterfaceService),j(4,O.Inject(d.TextSelectionManagerService))],_e);function de(r){return r.getContextValue(a.FOCUSING_DOC)||r.getContextValue(a.EDITOR_ACTIVATED)}const fe=999,on={id:l.CopyCommand.id,name:"doc.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:de,handler:async r=>r.get(H).copy()},sn={id:l.CutCommand.id,name:"doc.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:de,handler:async r=>r.get(H).cut()},an={id:l.PasteCommand.id,name:"doc.command.paste",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:de,handler:async r=>{const e=r.get(H),n=await r.get(l.IClipboardInterfaceService).read();return n.length===0?!1:e.paste(n)}};var cn=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,dn=(r,e,t,n)=>{for(var i=n>1?void 0:n?ln(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&cn(e,t,i),i},V=(r,e)=>(t,n)=>e(t,n,r);let Q=class extends a.RxDisposable{constructor(r,e,t,n,i){super(),this._commandService=r,this._clipboardInterfaceService=e,this._docClipboardService=t,this._textSelectionRenderManager=n,this._contextService=i,this._init()}_init(){[on,sn,an].forEach(r=>this.disposeWithMe(this._commandService.registerMultipleCommand(r))),[d.InnerPasteCommand,d.CutContentCommand].forEach(r=>this.disposeWithMe(this._commandService.registerCommand(r))),this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var r;(r=this._textSelectionRenderManager)==null||r.onPaste$.pipe(T.takeUntil(this.dispose$)).subscribe(e=>{var o,s;if(!de(this._contextService))return;e.event.preventDefault();const t=e.event,n=(o=t.clipboardData)==null?void 0:o.getData("text/html"),i=(s=t.clipboardData)==null?void 0:s.getData("text/plain");this._docClipboardService.legacyPaste(n,i)})}};Q=dn([a.OnLifecycle(a.LifecycleStages.Rendered,Q),V(0,a.ICommandService),V(1,l.IClipboardInterfaceService),V(2,H),V(3,m.ITextSelectionRenderManager),V(4,a.IContextService)],Q);var un=Object.defineProperty,hn=Object.getOwnPropertyDescriptor,gn=(r,e,t,n)=>{for(var i=n>1?void 0:n?hn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&un(e,t,i),i},B=(r,e)=>(t,n)=>e(t,n,r);let ee=class extends a.Disposable{constructor(e,t,n,i,o,s){super();I(this,"_initialEditors",new Set);this._univerInstanceService=e,this._docSkeletonManagerService=t,this._editorService=n,this._commandService=i,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,D,x;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,i=this._univerInstanceService.getUniverDocInstance(e);if(t==null||t.render==null||n==null||i==null)return;n.calculate();const{marginTop:o=0,marginBottom:s=0,marginLeft:c=0,marginRight:u=0}=i.getSnapshot().documentStyle,{scene:g,mainComponent:p}=t.render;let{actualHeight:_,actualWidth:f}=n.getActualSize();_+=o+s,f+=c+u;const{width:S,height:v}=t.getBoundingClientRect(),h=g.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);let C=h==null?void 0:h.getScrollBar();const b=Math.max(f,S),R=Math.max(_,v);g.transformByState({width:b,height:R}),p==null||p.resize(b,R),t.isSingle()?f>S?C==null?h&&new m.ScrollBar(h,{barSize:8,enableVertical:!1}):h==null||h.resetSizeAndScrollBar():(C=null,h==null||h.scrollTo({x:0,y:0}),(x=h==null?void 0:h.getScrollBar())==null||x.dispose()):_>v?C==null?h&&new m.ScrollBar(h,{enableHorizontal:!1,barSize:8}):h==null||h.resetSizeAndScrollBar():(C=null,h==null||h.scrollTo({x:0,y:0}),(D=h==null?void 0:h.getScrollBar())==null||D.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 i;const e=(i=this._univerInstanceService.getCurrentUniverDocInstance())==null?void 0:i.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 i=n.getUnitId(),o=this._renderManagerService.getRenderById(i),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:i}=n;if(this._editorService.isSheetEditor(i))return;this._resize(i),this._valueChange()}}))}};ee=gn([a.OnLifecycle(a.LifecycleStages.Rendered,ee),B(0,a.IUniverInstanceService),B(1,O.Inject(d.DocSkeletonManagerService)),B(2,l.IEditorService),B(3,a.ICommandService),B(4,m.ITextSelectionRenderManager),B(5,m.IRenderManagerService)],ee);var pn=Object.defineProperty,_n=Object.getOwnPropertyDescriptor,Sn=(r,e,t,n)=>{for(var i=n>1?void 0:n?_n(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&pn(e,t,i),i},X=(r,e)=>(t,n)=>e(t,n,r);let te=class extends a.RxDisposable{constructor(e,t,n,i){super();I(this,"_docRenderMap",new Set);this._docSkeletonManagerService=e,this._renderManagerService=t,this._commandService=n,this._editorService=i,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 i=this._renderManagerService.getRenderById(n);i==null&&(this._renderManagerService.create(n),i=this._renderManagerService.getRenderById(n));const{mainComponent:o,components:s}=i,c=o,u=s.get(d.DOCS_VIEW_KEY.BACKGROUND);c.changeSkeleton(t),u.changeSkeleton(t),this._recalculateSizeBySkeleton(i,t)}_recalculateSizeBySkeleton(e,t){var f;const{mainComponent:n,scene:i,unitId:o,components:s}=e,c=n,u=s.get(d.DOCS_VIEW_KEY.BACKGROUND),g=(f=t.getSkeletonData())==null?void 0:f.pages;if(g==null)return;let p=0,_=0;for(let S=0,v=g.length;S<v;S++){const h=g[S],{pageWidth:C,pageHeight:b}=h;c.pageLayoutType===m.PageLayoutType.VERTICAL?(_+=b,_+=c.pageMarginTop,S===v-1&&(_+=c.pageMarginTop),p=Math.max(p,C)):c.pageLayoutType===m.PageLayoutType.HORIZONTAL&&(p+=C,S!==v-1&&(p+=c.pageMarginLeft),_=Math.max(_,b))}c.resize(p,_),u.resize(p,_),this._editorService.isEditor(o)||i.resize(p,_)}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const i=t.params,{unitId:o}=i,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)}}))}};te=Sn([a.OnLifecycle(a.LifecycleStages.Rendered,te),X(0,O.Inject(d.DocSkeletonManagerService)),X(1,m.IRenderManagerService),X(2,a.ICommandService),X(3,l.IEditorService)],te);var mn=Object.defineProperty,fn=Object.getOwnPropertyDescriptor,vn=(r,e,t,n)=>{for(var i=n>1?void 0:n?fn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&mn(e,t,i),i},q=(r,e)=>(t,n)=>e(t,n,r);exports.DocCanvasView=class extends a.RxDisposable{constructor(t,n,i,o){super();I(this,"_scene");I(this,"_currentDocumentModel");I(this,"_fps$",new T.BehaviorSubject(""));I(this,"fps$",this._fps$.asObservable());this._renderManagerService=t,this._configService=n,this._univerInstanceService=i,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 i=this._renderManagerService.getRenderById(n);if(i==null)return;const{scene:o,engine:s}=i;o.openTransformer(),this._scene=o;const c=new m.Viewport(d.VIEWPORT_KEY.VIEW_MAIN,o,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});o.attachControl(),o.on(m.EVENT_TYPE.wheel,(p,_)=>{const f=p;if(f.ctrlKey){const S=Math.abs(f.deltaX);let v=S<40?.2:S<80?.4:.2;v*=f.deltaY>0?-1:1,o.scaleX<1&&(v/=2),o.scaleX+v>4?o.scale(4,4):o.scaleX+v<.1?o.scale(.1,.1):f.preventDefault()}else c.onMouseWheel(f,_)}),this._configService.getConfig("hasScroll")!==!1&&new m.ScrollBar(c),o.addLayer(new m.Layer(o,[],d.DOCS_COMPONENT_MAIN_LAYER_INDEX),new m.Layer(o,[],d.DOCS_COMPONENT_HEADER_LAYER_INDEX)),this._addComponent(i),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,i=this._currentDocumentModel,o={pageMarginLeft:i.documentStyle.marginLeft||0,pageMarginTop:i.documentStyle.marginTop||0},s=new m.Documents(d.DOCS_VIEW_KEY.MAIN,void 0,o),c=new m.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(i.getUnitId())==null&&n.enableLayerCache(d.DOCS_COMPONENT_MAIN_LAYER_INDEX)}};exports.DocCanvasView=vn([a.OnLifecycle(a.LifecycleStages.Starting,exports.DocCanvasView),q(0,m.IRenderManagerService),q(1,a.IConfigService),q(2,a.IUniverInstanceService),q(3,l.IEditorService)],exports.DocCanvasView);var Cn=Object.defineProperty,In=Object.getOwnPropertyDescriptor,On=(r,e,t,n)=>{for(var i=n>1?void 0:n?In(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Cn(e,t,i),i},F=(r,e)=>(t,n)=>e(t,n,r);let ne=class extends a.Disposable{constructor(e,t,n,i,o,s){super();I(this,"_liquid",new m.Liquid);I(this,"_pageMarginCache",new Map);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._renderManagerService=n,this._commandService=i,this._floatingObjectManagerService=o,this._editorService=s,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh(),this._updateOnPluginChange()}_updateOnPluginChange(){this._floatingObjectManagerService.pluginUpdate$.subscribe(e=>{const t=this._docSkeletonManagerService.getCurrent();if(t==null)return;const{unitId:n,skeleton:i}=t,o=this._renderManagerService.getRenderById(n);if(o==null)return;const{mainComponent:s,components:c,scene:u}=o,g=s,{left:p,top:_}=g;e.forEach(f=>{const{unitId:S,subUnitId:v,floatingObjectId:h,floatingObject:C}=f,{left:b=0,top:R=0,width:y=0,height:D=0,angle:x,flipX:L,flipY:A,skewX:z,skewY:Y}=C,M=this._pageMarginCache.get(h),G=(M==null?void 0:M.marginLeft)||0,ue=(M==null?void 0:M.marginTop)||0;i==null||i.getViewModel().getDataModel().updateDrawing(h,{left:b-p-G,top:R-_-ue,height:D,width:y})}),i==null||i.calculate(),s==null||s.makeDirty()})}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{skeleton:t,unitId:n}=e,i=this._renderManagerService.getRenderById(n);if(i==null)return;const{mainComponent:o}=i;o.changeSkeleton(t),this._refreshFloatingObject(n,t,i)})}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id,d.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const i=t.params,{unitId:o}=i,s=this._docSkeletonManagerService.getCurrent();if(s==null)return;const{unitId:c,skeleton:u}=s;if(o!==c)return;const g=this._renderManagerService.getRenderById(c);if(g==null)return;if(this._editorService.isEditor(c)){(n=g.mainComponent)==null||n.makeDirty();return}this._refreshFloatingObject(c,u,g)}}))}_refreshFloatingObject(e,t,n){const i=t==null?void 0:t.getSkeletonData(),{mainComponent:o,scene:s}=n,c=o;if(!i)return;const{left:u,top:g,pageLayoutType:p,pageMarginLeft:_,pageMarginTop:f}=c,{pages:S}=i,v=[];s.getAncestorScale(),this._liquid.reset(),this._pageMarginCache.clear();for(let h=0,C=S.length;h<C;h++){const b=S[h],{skeDrawings:R,marginLeft:y,marginTop:D}=b;this._liquid.translatePagePadding(b),R.forEach(x=>{const{aLeft:L,aTop:A,height:z,width:Y,objectId:M,drawingOrigin:G}=x,ue=G.layoutType===a.PositionedObjectLayoutType.WRAP_NONE&&G.behindDoc===a.BooleanNumber.TRUE;v.push({unitId:e,subUnitId:a.DEFAULT_DOCUMENT_SUB_COMPONENT_ID,floatingObjectId:M,behindText:ue,floatingObject:{left:L+u+this._liquid.x,top:A+g+this._liquid.y,width:Y,height:z}}),this._pageMarginCache.set(M,{marginLeft:this._liquid.x,marginTop:this._liquid.y})}),this._liquid.restorePagePadding(b),this._liquid.translatePage(b,p,_,f)}this._floatingObjectManagerService.batchAddOrUpdate(v)}};ne=On([a.OnLifecycle(a.LifecycleStages.Steady,ne),F(0,O.Inject(d.DocSkeletonManagerService)),F(1,a.IUniverInstanceService),F(2,m.IRenderManagerService),F(3,a.ICommandService),F(4,a.IFloatingObjectManagerService),F(5,l.IEditorService)],ne);var Tn=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,Rn=(r,e,t,n)=>{for(var i=n>1?void 0:n?bn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Tn(e,t,i),i},$=(r,e)=>(t,n)=>e(t,n,r);let ie=class extends a.Disposable{constructor(e,t,n,i,o,s){super();I(this,"_initializedRender",new Set);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._commandService=n,this._renderManagerService=i,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:i}=n;this.disposeWithMe(a.toDisposable(i.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,i.scaleX<1&&(u/=2);const g=s.zoomRatio;let p=+Number.parseFloat(`${g+u}`).toFixed(1);p=p>=4?4:p<=.1?.1:p,this._commandService.executeCommand(d.SetDocZoomRatioCommand.id,{zoomRatio:p,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 i=t.params,{unitId:o}=i;if(o!==n.getUnitId())return;const s=n.zoomRatio||1;this._updateViewZoom(s)}}))}_updateViewZoom(e,t=!0){var i;const n=this._getDocObject();n!=null&&(n.scene.scale(e,e),this._calculatePagePosition(n,e),t&&this._textSelectionManagerService.refreshSelection(),(i=n.scene.getTransformer())==null||i.hideControl())}_calculatePagePosition(e,t){const{document:n,scene:i,docBackground:o}=e,s=i==null?void 0:i.getParent(),{width:c,height:u,pageMarginLeft:g,pageMarginTop:p}=n;if(s==null||c===Number.POSITIVE_INFINITY||u===Number.POSITIVE_INFINITY)return;const{width:_,height:f}=s;let S=0,v=0,h=0,C=0,b=Number.POSITIVE_INFINITY;_>(c+g*2)*t?(S=_/2-c*t/2,S/=t,h=(_-g*2)/t,b=0):(S=g,h=c+g*2,b=(h-_/t)/2),f>u?(v=f/2-u/2,C=(f-p*2)/t):(v=p,C=u+p*2),i.resize(h,C+200),n.translate(S,v),o.translate(S,v);const R=i.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);if(b!==Number.POSITIVE_INFINITY&&R!=null){const y=R.getBarScroll(b,0).x;R.scrollTo({x:y})}return this}_getDocObject(){return d.getDocObject(this._univerInstanceService,this._renderManagerService)}};ie=Rn([a.OnLifecycle(a.LifecycleStages.Rendered,ie),$(0,O.Inject(d.DocSkeletonManagerService)),$(1,a.IUniverInstanceService),$(2,a.ICommandService),$(3,m.IRenderManagerService),$(4,O.Inject(d.TextSelectionManagerService)),$(5,l.IEditorService)],ie);var Mn=Object.defineProperty,yn=Object.getOwnPropertyDescriptor,En=(r,e,t,n)=>{for(var i=n>1?void 0:n?yn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Mn(e,t,i),i},N=(r,e)=>(t,n)=>e(t,n,r);let re=class extends a.Disposable{constructor(e,t,n,i,o,s,c){super();I(this,"_loadedMap",new WeakSet);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._commandService=n,this._renderManagerService=i,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:i}=t;this.disposeWithMe(a.toDisposable(n.onPointerEnterObserver.add(()=>{this._isEditorReadOnly(e)||(n.cursor=m.CURSOR_TYPE.TEXT)}))),this.disposeWithMe(a.toDisposable(n.onPointerLeaveObserver.add(()=>{n.cursor=m.CURSOR_TYPE.DEFAULT,i.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:g}=o;this._editorService.getEditor(e)&&(this._setEditorFocus(e),setTimeout(()=>{this._setEditorFocus(e),this._textSelectionRenderManager.setCursorManually(u,g)},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 i=t.params,{unitId:o}=i,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,i=this._renderManagerService.getRenderById(t);if(i==null)return;const{scene:o,mainComponent:s}=i;this._textSelectionRenderManager.changeRuntime(n,o,s),this._textSelectionManagerService.setCurrentSelectionNotRefresh({unitId:t,subUnitId:""})}))}_getDocObjectById(e){return this._univerInstanceService.getUnitType(e)!==a.UniverInstanceType.UNIVER_DOC?null:d.getDocObjectById(e,this._renderManagerService)}};re=En([a.OnLifecycle(a.LifecycleStages.Rendered,re),N(0,O.Inject(d.DocSkeletonManagerService)),N(1,a.IUniverInstanceService),N(2,a.ICommandService),N(3,m.IRenderManagerService),N(4,m.ITextSelectionRenderManager),N(5,O.Inject(d.TextSelectionManagerService)),N(6,l.IEditorService)],re);var Dn=Object.defineProperty,xn=Object.getOwnPropertyDescriptor,Un=(r,e,t,n)=>{for(var i=n>1?void 0:n?xn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Dn(e,t,i),i},W=(r,e)=>(t,n)=>e(t,n,r);const be=1.5;let oe=class extends a.RxDisposable{constructor(r,e,t,n,i){super(),this._docSkeletonManagerService=r,this._textSelectionManagerService=e,this._editorService=t,this._univerInstanceService=n,this._renderManagerService=i,this._init()}_init(){this._textSelectionManagerService.textSelection$.pipe(T.takeUntil(this.dispose$)).subscribe(r=>{if(r==null)return;const{isEditing:e,unitId:t}=r;e&&this._scrollToSelection(t)})}_scrollToSelection(r){var M;const e=this._textSelectionManagerService.getActiveRange(),t=this._getDocObject(),n=(M=this._docSkeletonManagerService.getCurrent())==null?void 0:M.skeleton;if(e==null||t==null||n==null)return;const{collapsed:i,startNodePosition:o}=e;if(!i)return;const s=t.document.getOffsetConfig(),{docsLeft:c,docsTop:u}=s,g=new m.NodePositionConvertToCursor(s,n),{contentBoxPointGroup:p}=g.getRangePointData(o,o),{left:_,top:f,height:S}=m.getAnchorBounding(p),v=_+c,h=f+u,C=t.scene.getViewport(d.VIEWPORT_KEY.VIEW_MAIN),b=!!this._editorService.getEditor(r);if(C==null)return;const{left:R,top:y,right:D,bottom:x}=C.getBounding().viewBound;let L=0,A=0;const z=b?0:100;h<y?L=h-y:h>x-S&&(L=h-x+S+z),v<R?A=v-R:v>D-be&&(A=v-D+be);const Y=C.getBarScroll(A,L);C.scrollBy(Y)}_getDocObject(){return d.getDocObject(this._univerInstanceService,this._renderManagerService)}};oe=Un([a.OnLifecycle(a.LifecycleStages.Rendered,oe),W(0,O.Inject(d.DocSkeletonManagerService)),W(1,O.Inject(d.TextSelectionManagerService)),W(2,l.IEditorService),W(3,a.IUniverInstanceService),W(4,m.IRenderManagerService)],oe);var Pn=Object.defineProperty,Nn=Object.getOwnPropertyDescriptor,Ln=(r,e,t,n)=>{for(var i=n>1?void 0:n?Nn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Pn(e,t,i),i},ge=(r,e)=>(t,n)=>e(t,n,r),Z;exports.UniverDocsUIPlugin=(Z=class extends a.Plugin{constructor(e,t,n,i){super(),this._config=e,this._injector=t,this._localeService=n,this._logService=i,this._localeService.load({zhCN:Le}),this._config=a.Tools.deepMerge({},ye,this._config),this._initDependencies(t),this._initializeCommands()}onRendered(){this._initModules(),this._markDocAsFocused()}_initializeCommands(){[ze,Ye,Ke,Ge,Xe,qe,Ze,Je,Qe,Wt,kt,Vt].forEach(e=>{this._injector.get(l.IShortcutService).registerShortcut(e)})}_initDependencies(e){[[J],[Q],[ee],[te],[ne],[ie],[re],[oe],[k,{useFactory:()=>this._injector.createInstance(k,this._config)}],[H,{useClass:_e}],[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 i=n.getUnitId();t.isEditor(i)||e.focusUnit(n.getUnitId())}catch(n){this._logService.warn(n)}}_initModules(){this._injector.get(k)}},I(Z,"pluginName",Ee),I(Z,"type",a.UniverInstanceType.UNIVER_DOC),Z);exports.UniverDocsUIPlugin=Ln([ge(1,O.Inject(O.Injector)),ge(2,O.Inject(a.LocaleService)),ge(3,a.ILogService)],exports.UniverDocsUIPlugin);exports.DOC_UI_PLUGIN_NAME=Ee;exports.DefaultDocContainerConfig=Me;exports.DefaultDocUiConfig=ye;exports.DefaultToolbarConfig=Re;exports.PastePluginLark=Ae;exports.PastePluginUniver=$e;exports.PastePluginWord=Fe;exports.enUS=Ft;exports.ruRU=jt;exports.zhCN=Le;
|
|
9
|
+
*/var st=We,at=Symbol.for("react.element"),ct=Symbol.for("react.fragment"),lt=Object.prototype.hasOwnProperty,dt=st.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ut={key:!0,ref:!0,__self:!0,__source:!0};function Ne(r,e,t){var n,i={},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)lt.call(e,n)&&!ut.hasOwnProperty(n)&&(i[n]=e[n]);if(r&&r.defaultProps)for(n in e=r.defaultProps,e)i[n]===void 0&&(i[n]=e[n]);return{$$typeof:at,type:r,key:o,ref:s,props:i,_owner:dt.current}}ce.Fragment=ct;ce.jsx=Ne;ce.jsxs=Ne;Pe.exports=ce;var ht=Pe.exports;const gt="univer-docs-ui-canvas-background",pt={docsUiCanvasBackground:gt},_t=()=>ht.jsx("div",{className:pt.docsUiCanvasBackground});function St(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function mt(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function ft(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function vt(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function It(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Ct(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Ot(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,label:De,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,i=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatFontFamilyCommand.id){const u=U(r);if(u==null)return;const g=(c=u.ts)==null?void 0:c.ff;t.next(g!=null?g:n)}});return t.next(n),i.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function Tt(r){const e=r.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 i=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatFontSizeCommand.id){const u=U(r);if(u==null)return;const g=(c=u.ts)==null?void 0:c.fs;t.next(g!=null?g:14)}});return t.next(14),i.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function bt(r){const e=r.get(a.ICommandService),t=r.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:Se,hoverable:!1}}],value$:new T.Observable(n=>{const i=t.getCurrentTheme().textColor,o=e.onCommandExecuted(s=>{if(s.id===d.SetInlineFormatTextColorCommand.id){const c=s.params.value;n.next(c!=null?c:i)}});return n.next(i),o.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function Rt(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=le(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Mt(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=le(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function yt(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=le(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Et(r){const e=r.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(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=le(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Dt(r){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(r,a.UniverInstanceType.UNIVER_DOC)}}function xt(r){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(r,a.UniverInstanceType.UNIVER_DOC)}}function Ut(r){return{id:d.ResetInlineFormatTextBackgroundColorCommand.id,type:l.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:d.SetInlineFormatTextBackgroundColorCommand.id}}function Pt(r){const e=r.get(a.ICommandService),t=r.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:Se,hoverable:!1}}],value$:new T.Observable(n=>{const i=t.getCurrentTheme().primaryColor,o=e.onCommandExecuted(s=>{if(s.id===d.SetInlineFormatTextBackgroundColorCommand.id){const c=s.params.value;n.next(c!=null?c:i)}});return n.next(i),o.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function U(r){var u;const e=r.get(a.IUniverInstanceService),t=r.get(d.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),i=t.getActiveRange();if(n==null||i==null)return;const o=(u=n.getBody())==null?void 0:u.textRuns;if(o==null)return;const{startOffset:s}=i;return o.find(({st:g,ed:p})=>s>=g&&s<p)}function le(r){var u;const e=r.get(a.IUniverInstanceService),t=r.get(d.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),i=t.getActiveRange();if(n==null||i==null)return;const o=(u=n.getBody())==null?void 0:u.paragraphs;if(o==null)return;const{startOffset:s}=i;let c=-1;for(const g of o){const{startIndex:p}=g;if(s>c&&s<=p)return g;c=p}return null}var Nt=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,At=(r,e,t,n)=>{for(var i=n>1?void 0:n?Lt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Nt(e,t,i),i},P=(r,e)=>(t,n)=>e(t,n,r);let H=class extends a.Disposable{constructor(r,e,t,n,i,o,s,c){super(),this._config=r,this._injector=e,this._componentManager=t,this._layoutService=n,this._editorService=i,this._menuService=o,this._uiPartsService=s,this._univerInstanceService=c,this._init()}_initCustomComponents(){const r=this._componentManager;this.disposeWithMe(r.register(Se,ke.ColorPicker)),this.disposeWithMe(r.register(De,l.FontFamily)),this.disposeWithMe(r.register(xe,l.FontFamilyItem)),this.disposeWithMe(r.register(Ue,l.FontSize))}_initMenus(){const{menu:r={}}=this._config;[St,mt,ft,vt,It,Ct,Tt,Ot,bt,Rt,Mt,yt,Et,Dt,xt,Ut,Pt].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e),r))})}_init(){this._initCustomComponents(),this._initMenus(),this._initDocBackground(),this._initFocusHandler()}_initDocBackground(){const r=this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_DOC)[0].getUnitId();if(r==null)return;this._editorService.isEditor(r)||this.disposeWithMe(this._uiPartsService.registerComponent(l.BuiltInUIPart.CONTENT,()=>Ve.connectInjector(_t,this._injector)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(a.UniverInstanceType.UNIVER_DOC,()=>{this._injector.get(m.ITextSelectionRenderManager).focus()}))}};H=At([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 Bt={toolbar:{undo:"Undo",redo:"Redo",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},fillColor:{main:"Text Background color",right:"Choose color"},resetColor:"Reset",order:"Ordered list",unorder:"Unordered list",alignLeft:"Align Left",alignCenter:"Align Center",alignRight:"Align Right",alignJustify:"Justify"}},Ft=Bt,$t={toolbar:{undo:"撤销",redo:"重做",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},fillColor:{main:"文本背景色",right:"背景色选择"},resetColor:"重置颜色",order:"有序列表",unorder:"无序列表",alignLeft:"左对齐",alignCenter:"居中对齐",alignRight:"右对齐",alignJustify:"两端对齐"}},Le=$t,wt={toolbar:{undo:"Отменить",redo:"Повторить",font:"Шрифт",fontSize:"Размер шрифта",bold:"Полужирный",italic:"Курсив",strikethrough:"Зачеркнутый",subscript:"Нижний индекс",superscript:"Верхний индекс",underline:"Подчеркнутый",textColor:{main:"Цвет текста",right:"Выбрать цвет"},fillColor:{main:"Цвет фона текста",right:"Выбрать цвет"},resetColor:"Сбросить",order:"Упорядоченный список",unorder:"Неупорядоченный список",alignLeft:"Выровнять по левому краю",alignCenter:"Выровнять по центру",alignRight:"Выровнять по правому краю",alignJustify:"Выровнять по ширине"}},jt=wt,Vt={id:d.BreakLineCommand.id,preconditions:He,binding:l.KeyCode.ENTER},Wt={id:d.DeleteLeftCommand.id,preconditions:E,binding:l.KeyCode.BACKSPACE},kt={id:d.DeleteRightCommand.id,preconditions:E,binding:l.KeyCode.DELETE},Ht=10,zt=6;function Yt(){return a.Tools.generateRandomId(zt)}function Gt(r){const e=r.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class Kt{constructor(){C(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 Ie=new Kt;function me(r){const e=r.style,t={},n=r.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 i=0;i<e.length;i++){const o=e[i],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=m.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 Xt(r){const e=new DOMParser,t=`<x-univer id="univer-root">${r}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function Ce(r,e){const t=r.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(r)}const se=class se{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=se._pluginList.find(o=>o.checkPasteType(e)),n=Xt(e),i={dataStream:"",textRuns:[]};return t&&(this._styleRules=[...t.stylesRules],this._afterProcessRules=[...t.afterProcessRules]),this._styleCache.clear(),this._process(null,n==null?void 0:n.childNodes,i),this._styleCache.clear(),this._styleRules=[],this._afterProcessRules=[],i}_process(e,t,n){var i;for(const o of t)if(o.nodeType===Node.TEXT_NODE){const s=(i=o.nodeValue)==null?void 0:i.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):me(o);this._styleCache.set(o,{...s,...u});const{childNodes:g}=o;this._process(o,g,n);const p=this._afterProcessRules.find(({filter:_})=>Ce(o,_));p&&p.handler(n,o)}}};C(se,"_pluginList",[]);let w=se;const qt={name:"univer-doc-paste-plugin-lark",checkPasteType(r){return/lark-record-clipboard/i.test(r)},stylesRules:[{filter:["s"],getStyle(r){const e=me(r);return{st:{s:a.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(r){return r.tagName==="DIV"&&/ace-line/i.test(r.className)},handler(r){r.paragraphs==null&&(r.paragraphs=[]),r.paragraphs.push({startIndex:r.dataStream.length}),r.dataStream+="\r"}}]},Ae=qt;function Be(r){const e=r.style,t={};for(let n=0;n<e.length;n++){const i=e[n],o=e.getPropertyValue(i);switch(i){case"margin-top":{const s=Number.parseInt(o);t.spaceAbove=/pt/.test(o)?m.ptToPixel(s):s;break}case"margin-bottom":{const s=Number.parseInt(o);t.spaceBelow=/pt/.test(o)?m.ptToPixel(s):s;break}case"line-height":{const s=Number.parseFloat(o);t.lineSpacing=s;break}}}return Object.getOwnPropertyNames(t).length?t:null}const Zt={name:"univer-doc-paste-plugin-word",checkPasteType(r){return/word|mso/i.test(r)},stylesRules:[{filter:["b"],getStyle(r){const e=me(r);return{bl:a.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(r){return r.tagName==="P"&&/mso/i.test(r.className)},handler(r,e){r.paragraphs==null&&(r.paragraphs=[]);const t={startIndex:r.dataStream.length},n=Be(e);n&&(t.paragraphStyle=n),r.paragraphs.push(t),r.dataStream+="\r"}}]},Fe=Zt,Jt={name:"univer-doc-paste-plugin-univer",checkPasteType(r){return/UniverNormal/i.test(r)},stylesRules:[],afterProcessRules:[{filter(r){return r.tagName==="P"&&/UniverNormal/i.test(r.className)},handler(r,e){r.paragraphs==null&&(r.paragraphs=[]);const t={startIndex:r.dataStream.length},n=Be(e);n&&(t.paragraphStyle=n),r.paragraphs.push(t),r.dataStream+="\r"}}]},$e=Jt;function Oe(r,e){const{st:t,ed:n,ts:i={}}=e,{ff:o,fs:s,it:c,bl:u,ul:g,st:p,ol:_,bg:f,cl:S,va:v}=i;let h=r.slice(t,n);const I=[];return c===a.BooleanNumber.TRUE&&(h=`<i>${h}</i>`),v===a.BaselineOffset.SUPERSCRIPT?h=`<sup>${h}</sup>`:v===a.BaselineOffset.SUBSCRIPT&&(h=`<sub>${h}</sub>`),(g==null?void 0:g.s)===a.BooleanNumber.TRUE&&(h=`<u>${h}</u>`),(p==null?void 0:p.s)===a.BooleanNumber.TRUE&&(h=`<s>${h}</s>`),u===a.BooleanNumber.TRUE&&(h=`<strong>${h}</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"),f&&I.push(`background: ${f.rgb}`),I.length?`<span style="${I.join("; ")};">${h}</span>`:h}function he(r,e,t){const{dataStream:n,textRuns:i=[]}=r;let o=e;const s=[];for(const c of i){const{st:u,ed:g}=c;a.Tools.hasIntersectionBetweenTwoRanges(e,t,u,g)&&(u>o?(s.push(n.slice(o,u)),s.push(Oe(n,{...c,ed:Math.min(g,t)}))):s.push(Oe(n,{...c,st:o,ed:Math.min(g,t)}))),o=Math.max(e,Math.min(g,t))}return o!==t&&s.push(n.slice(o,t)),s.join("")}function Te(r,e=!0){var t;if(e&&((t=r.paragraphs)!=null&&t.length)){const{dataStream:n,paragraphs:i=[]}=r;let o="",s=-1;for(const c of i){const{startIndex:u,paragraphStyle:g={}}=c,{spaceAbove:p,spaceBelow:_,lineSpacing:f}=g,S=[];p!=null&&(typeof p=="number"?S.push(`margin-top: ${p}px`):S.push(`margin-top: ${p.v}px`)),_!=null&&(typeof _=="number"?S.push(`margin-bottom: ${_}px`):S.push(`margin-bottom: ${_.v}px`)),f!=null&&S.push(`line-height: ${f}`),u>s+1?o+=`<p class="UniverNormal" ${S.length?`style="${S.join("; ")};"`:""}>${he(r,s+1,u)}</p>`:o+=`<p class="UniverNormal" ${S.length?`style="${S.join("; ")};"`:""}></p>`,s=u}return s!==n.length&&(o+=he(r,s,n.length)),o}else return he(r,0,r.dataStream.length)}class Qt{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 en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=(r,e,t,n)=>{for(var i=n>1?void 0:n?tn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&en(e,t,i),i},j=(r,e)=>(t,n)=>e(t,n,r);w.use(Fe);w.use(Ae);w.use($e);function rn(r){const e=r.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 z=O.createIdentifier("doc.clipboard-service");let _e=class extends a.Disposable{constructor(e,t,n,i,o){super();C(this,"_clipboardHooks",[]);C(this,"_htmlToUDM",new w);C(this,"_umdToHtml",new Qt);this._univerInstanceService=e,this._logService=t,this._commandService=n,this._clipboardInterfaceService=i,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:{},i=this._textSelectionManagerService.getSelections();if(e==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),t==null||i==null)return!1;this.copy();try{let s=t;for(const u of i){const{startOffset:g,endOffset:p}=u;g==null||p==null||p<=t&&(s-=p-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){var s;const{segmentId:t,endOffset:n,style:i}=(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 g of o){const{startOffset:p,endOffset:_}=g;p==null||_==null||_<=n&&(c+=e.dataStream.length-(_-p))}const u=[{startOffset:c,endOffset:c,style:i}];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=Yt(),n=e.length>1?e.map(o=>o.dataStream).join(`
|
|
10
|
+
`):e[0].dataStream;let i=this._umdToHtml.convert(e);return e.length===1&&(i=i.replace(/(<[a-z]+)/,(o,s)=>`${s} data-copy-id="${t}"`),Ie.set(t,e[0])),this._clipboardInterfaceService.write(n,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._univerInstanceService.getCurrentUniverDocInstance(),n=[];if(e==null||!t)return n;for(const i of e){const{startOffset:o,endOffset:s,collapsed:c}=i;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 i of e)for(const o of i.types)o===l.PLAIN_TEXT_CLIPBOARD_MIME_TYPE?n=await i.getType(o).then(s=>s&&s.text()):o===l.HTML_CLIPBOARD_MIME_TYPE&&(t=await i.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 rn(t);throw new Error("[DocClipboardService] html and text cannot be both empty!")}const n=Gt(e);if(n){const i=Ie.get(n);if(i)return i}return this._htmlToUDM.convert(e)}};_e=nn([j(0,a.IUniverInstanceService),j(1,a.ILogService),j(2,a.ICommandService),j(3,l.IClipboardInterfaceService),j(4,O.Inject(d.TextSelectionManagerService))],_e);function de(r){return r.getContextValue(a.FOCUSING_DOC)||r.getContextValue(a.EDITOR_ACTIVATED)}const fe=999,on={id:l.CopyCommand.id,name:"doc.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:de,handler:async r=>r.get(z).copy()},sn={id:l.CutCommand.id,name:"doc.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:de,handler:async r=>r.get(z).cut()},an={id:l.PasteCommand.id,name:"doc.command.paste",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:de,handler:async r=>{const e=r.get(z),n=await r.get(l.IClipboardInterfaceService).read();return n.length===0?!1:e.paste(n)}};var cn=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,dn=(r,e,t,n)=>{for(var i=n>1?void 0:n?ln(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&cn(e,t,i),i},V=(r,e)=>(t,n)=>e(t,n,r);let Q=class extends a.RxDisposable{constructor(r,e,t,n,i){super(),this._commandService=r,this._clipboardInterfaceService=e,this._docClipboardService=t,this._textSelectionRenderManager=n,this._contextService=i,this._init()}_init(){[on,sn,an].forEach(r=>this.disposeWithMe(this._commandService.registerMultipleCommand(r))),[d.InnerPasteCommand,d.CutContentCommand].forEach(r=>this.disposeWithMe(this._commandService.registerCommand(r))),this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var r;(r=this._textSelectionRenderManager)==null||r.onPaste$.pipe(T.takeUntil(this.dispose$)).subscribe(e=>{var o,s;if(!de(this._contextService))return;e.event.preventDefault();const t=e.event,n=(o=t.clipboardData)==null?void 0:o.getData("text/html"),i=(s=t.clipboardData)==null?void 0:s.getData("text/plain");this._docClipboardService.legacyPaste(n,i)})}};Q=dn([a.OnLifecycle(a.LifecycleStages.Rendered,Q),V(0,a.ICommandService),V(1,l.IClipboardInterfaceService),V(2,z),V(3,m.ITextSelectionRenderManager),V(4,a.IContextService)],Q);var un=Object.defineProperty,hn=Object.getOwnPropertyDescriptor,gn=(r,e,t,n)=>{for(var i=n>1?void 0:n?hn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&un(e,t,i),i},B=(r,e)=>(t,n)=>e(t,n,r);let ee=class extends a.Disposable{constructor(e,t,n,i,o,s){super();C(this,"_initialEditors",new Set);this._univerInstanceService=e,this._docSkeletonManagerService=t,this._editorService=n,this._commandService=i,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,D,x;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,i=this._univerInstanceService.getUniverDocInstance(e);if(t==null||t.render==null||n==null||i==null)return;n.calculate();const{marginTop:o=0,marginBottom:s=0,marginLeft:c=0,marginRight:u=0}=i.getSnapshot().documentStyle,{scene:g,mainComponent:p}=t.render;let{actualHeight:_,actualWidth:f}=n.getActualSize();_+=o+s,f+=c+u;const{width:S,height:v}=t.getBoundingClientRect(),h=g.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);let I=h==null?void 0:h.getScrollBar();const b=Math.max(f,S),R=Math.max(_,v);g.transformByState({width:b,height:R}),p==null||p.resize(b,R),t.isSingle()?f>S?I==null?h&&new m.ScrollBar(h,{barSize:8,enableVertical:!1}):h==null||h.resetSizeAndScrollBar():(I=null,h==null||h.scrollTo({x:0,y:0}),(x=h==null?void 0:h.getScrollBar())==null||x.dispose()):_>v?I==null?h&&new m.ScrollBar(h,{enableHorizontal:!1,barSize:8}):h==null||h.resetSizeAndScrollBar():(I=null,h==null||h.scrollTo({x:0,y:0}),(D=h==null?void 0:h.getScrollBar())==null||D.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 i;const e=(i=this._univerInstanceService.getCurrentUniverDocInstance())==null?void 0:i.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 i=n.getUnitId(),o=this._renderManagerService.getRenderById(i),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:i}=n;if(this._editorService.isSheetEditor(i))return;this._resize(i),this._valueChange()}}))}};ee=gn([a.OnLifecycle(a.LifecycleStages.Rendered,ee),B(0,a.IUniverInstanceService),B(1,O.Inject(d.DocSkeletonManagerService)),B(2,l.IEditorService),B(3,a.ICommandService),B(4,m.ITextSelectionRenderManager),B(5,m.IRenderManagerService)],ee);var pn=Object.defineProperty,_n=Object.getOwnPropertyDescriptor,Sn=(r,e,t,n)=>{for(var i=n>1?void 0:n?_n(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&pn(e,t,i),i},q=(r,e)=>(t,n)=>e(t,n,r);let te=class extends a.RxDisposable{constructor(e,t,n,i){super();C(this,"_docRenderMap",new Set);this._docSkeletonManagerService=e,this._renderManagerService=t,this._commandService=n,this._editorService=i,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 i=this._renderManagerService.getRenderById(n);i==null&&(this._renderManagerService.create(n),i=this._renderManagerService.getRenderById(n));const{mainComponent:o,components:s}=i,c=o,u=s.get(d.DOCS_VIEW_KEY.BACKGROUND);c.changeSkeleton(t),u.changeSkeleton(t),this._recalculateSizeBySkeleton(i,t)}_recalculateSizeBySkeleton(e,t){var f;const{mainComponent:n,scene:i,unitId:o,components:s}=e,c=n,u=s.get(d.DOCS_VIEW_KEY.BACKGROUND),g=(f=t.getSkeletonData())==null?void 0:f.pages;if(g==null)return;let p=0,_=0;for(let S=0,v=g.length;S<v;S++){const h=g[S],{pageWidth:I,pageHeight:b}=h;c.pageLayoutType===m.PageLayoutType.VERTICAL?(_+=b,_+=c.pageMarginTop,S===v-1&&(_+=c.pageMarginTop),p=Math.max(p,I)):c.pageLayoutType===m.PageLayoutType.HORIZONTAL&&(p+=I,S!==v-1&&(p+=c.pageMarginLeft),_=Math.max(_,b))}c.resize(p,_),u.resize(p,_),this._editorService.isEditor(o)||i.resize(p,_)}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const i=t.params,{unitId:o}=i,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)}}))}};te=Sn([a.OnLifecycle(a.LifecycleStages.Rendered,te),q(0,O.Inject(d.DocSkeletonManagerService)),q(1,m.IRenderManagerService),q(2,a.ICommandService),q(3,l.IEditorService)],te);var mn=Object.defineProperty,fn=Object.getOwnPropertyDescriptor,vn=(r,e,t,n)=>{for(var i=n>1?void 0:n?fn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&mn(e,t,i),i},Z=(r,e)=>(t,n)=>e(t,n,r);exports.DocCanvasView=class extends a.RxDisposable{constructor(t,n,i,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=i,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 i=this._renderManagerService.getRenderById(n);if(i==null)return;const{scene:o,engine:s}=i;o.openTransformer(),this._scene=o;const c=new m.Viewport(d.VIEWPORT_KEY.VIEW_MAIN,o,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});o.attachControl(),o.on(m.EVENT_TYPE.wheel,(p,_)=>{const f=p;if(f.ctrlKey){const S=Math.abs(f.deltaX);let v=S<40?.2:S<80?.4:.2;v*=f.deltaY>0?-1:1,o.scaleX<1&&(v/=2),o.scaleX+v>4?o.scale(4,4):o.scaleX+v<.1?o.scale(.1,.1):f.preventDefault()}else c.onMouseWheel(f,_)}),this._configService.getConfig("hasScroll")!==!1&&new m.ScrollBar(c),o.addLayer(new m.Layer(o,[],d.DOCS_COMPONENT_MAIN_LAYER_INDEX),new m.Layer(o,[],d.DOCS_COMPONENT_HEADER_LAYER_INDEX)),this._addComponent(i),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,i=this._currentDocumentModel,o={pageMarginLeft:i.documentStyle.marginLeft||0,pageMarginTop:i.documentStyle.marginTop||0},s=new m.Documents(d.DOCS_VIEW_KEY.MAIN,void 0,o),c=new m.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(i.getUnitId())==null&&n.enableLayerCache(d.DOCS_COMPONENT_MAIN_LAYER_INDEX)}};exports.DocCanvasView=vn([a.OnLifecycle(a.LifecycleStages.Starting,exports.DocCanvasView),Z(0,m.IRenderManagerService),Z(1,a.IConfigService),Z(2,a.IUniverInstanceService),Z(3,l.IEditorService)],exports.DocCanvasView);var In=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,On=(r,e,t,n)=>{for(var i=n>1?void 0:n?Cn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&In(e,t,i),i},F=(r,e)=>(t,n)=>e(t,n,r);let ne=class extends a.Disposable{constructor(e,t,n,i,o,s){super();C(this,"_liquid",new m.Liquid);C(this,"_pageMarginCache",new Map);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._renderManagerService=n,this._commandService=i,this._floatingObjectManagerService=o,this._editorService=s,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh(),this._updateOnPluginChange()}_updateOnPluginChange(){this._floatingObjectManagerService.pluginUpdate$.subscribe(e=>{const t=this._docSkeletonManagerService.getCurrent();if(t==null)return;const{unitId:n,skeleton:i}=t,o=this._renderManagerService.getRenderById(n);if(o==null)return;const{mainComponent:s,components:c,scene:u}=o,g=s,{left:p,top:_}=g;e.forEach(f=>{const{unitId:S,subUnitId:v,floatingObjectId:h,floatingObject:I}=f,{left:b=0,top:R=0,width:y=0,height:D=0,angle:x,flipX:L,flipY:A,skewX:Y,skewY:G}=I,M=this._pageMarginCache.get(h),K=(M==null?void 0:M.marginLeft)||0,ue=(M==null?void 0:M.marginTop)||0;i==null||i.getViewModel().getDataModel().updateDrawing(h,{left:b-p-K,top:R-_-ue,height:D,width:y})}),i==null||i.calculate(),s==null||s.makeDirty()})}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{skeleton:t,unitId:n}=e,i=this._renderManagerService.getRenderById(n);if(i==null)return;const{mainComponent:o}=i;o.changeSkeleton(t),this._refreshFloatingObject(n,t,i)})}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id,d.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const i=t.params,{unitId:o}=i,s=this._docSkeletonManagerService.getCurrent();if(s==null)return;const{unitId:c,skeleton:u}=s;if(o!==c)return;const g=this._renderManagerService.getRenderById(c);if(g==null)return;if(this._editorService.isEditor(c)){(n=g.mainComponent)==null||n.makeDirty();return}this._refreshFloatingObject(c,u,g)}}))}_refreshFloatingObject(e,t,n){const i=t==null?void 0:t.getSkeletonData(),{mainComponent:o,scene:s}=n,c=o;if(!i)return;const{left:u,top:g,pageLayoutType:p,pageMarginLeft:_,pageMarginTop:f}=c,{pages:S}=i,v=[];s.getAncestorScale(),this._liquid.reset(),this._pageMarginCache.clear();for(let h=0,I=S.length;h<I;h++){const b=S[h],{skeDrawings:R,marginLeft:y,marginTop:D}=b;this._liquid.translatePagePadding(b),R.forEach(x=>{const{aLeft:L,aTop:A,height:Y,width:G,objectId:M,drawingOrigin:K}=x,ue=K.layoutType===a.PositionedObjectLayoutType.WRAP_NONE&&K.behindDoc===a.BooleanNumber.TRUE;v.push({unitId:e,subUnitId:a.DEFAULT_DOCUMENT_SUB_COMPONENT_ID,floatingObjectId:M,behindText:ue,floatingObject:{left:L+u+this._liquid.x,top:A+g+this._liquid.y,width:G,height:Y}}),this._pageMarginCache.set(M,{marginLeft:this._liquid.x,marginTop:this._liquid.y})}),this._liquid.restorePagePadding(b),this._liquid.translatePage(b,p,_,f)}this._floatingObjectManagerService.batchAddOrUpdate(v)}};ne=On([a.OnLifecycle(a.LifecycleStages.Steady,ne),F(0,O.Inject(d.DocSkeletonManagerService)),F(1,a.IUniverInstanceService),F(2,m.IRenderManagerService),F(3,a.ICommandService),F(4,a.IFloatingObjectManagerService),F(5,l.IEditorService)],ne);var Tn=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,Rn=(r,e,t,n)=>{for(var i=n>1?void 0:n?bn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Tn(e,t,i),i},$=(r,e)=>(t,n)=>e(t,n,r);let ie=class extends a.Disposable{constructor(e,t,n,i,o,s){super();C(this,"_initializedRender",new Set);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._commandService=n,this._renderManagerService=i,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:i}=n;this.disposeWithMe(a.toDisposable(i.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,i.scaleX<1&&(u/=2);const g=s.zoomRatio;let p=+Number.parseFloat(`${g+u}`).toFixed(1);p=p>=4?4:p<=.1?.1:p,this._commandService.executeCommand(d.SetDocZoomRatioCommand.id,{zoomRatio:p,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 i=t.params,{unitId:o}=i;if(o!==n.getUnitId())return;const s=n.zoomRatio||1;this._updateViewZoom(s)}}))}_updateViewZoom(e,t=!0){var i;const n=this._getDocObject();n!=null&&(n.scene.scale(e,e),this._calculatePagePosition(n,e),t&&this._textSelectionManagerService.refreshSelection(),(i=n.scene.getTransformer())==null||i.hideControl())}_calculatePagePosition(e,t){const{document:n,scene:i,docBackground:o}=e,s=i==null?void 0:i.getParent(),{width:c,height:u,pageMarginLeft:g,pageMarginTop:p}=n;if(s==null||c===Number.POSITIVE_INFINITY||u===Number.POSITIVE_INFINITY)return;const{width:_,height:f}=s;let S=0,v=0,h=0,I=0,b=Number.POSITIVE_INFINITY;_>(c+g*2)*t?(S=_/2-c*t/2,S/=t,h=(_-g*2)/t,b=0):(S=g,h=c+g*2,b=(h-_/t)/2),f>u?(v=f/2-u/2,I=(f-p*2)/t):(v=p,I=u+p*2),i.resize(h,I+200),n.translate(S,v),o.translate(S,v);const R=i.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);if(b!==Number.POSITIVE_INFINITY&&R!=null){const y=R.getBarScroll(b,0).x;R.scrollTo({x:y})}return this}_getDocObject(){return d.getDocObject(this._univerInstanceService,this._renderManagerService)}};ie=Rn([a.OnLifecycle(a.LifecycleStages.Rendered,ie),$(0,O.Inject(d.DocSkeletonManagerService)),$(1,a.IUniverInstanceService),$(2,a.ICommandService),$(3,m.IRenderManagerService),$(4,O.Inject(d.TextSelectionManagerService)),$(5,l.IEditorService)],ie);var Mn=Object.defineProperty,yn=Object.getOwnPropertyDescriptor,En=(r,e,t,n)=>{for(var i=n>1?void 0:n?yn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Mn(e,t,i),i},N=(r,e)=>(t,n)=>e(t,n,r);let re=class extends a.Disposable{constructor(e,t,n,i,o,s,c){super();C(this,"_loadedMap",new WeakSet);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._commandService=n,this._renderManagerService=i,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:i}=t;this.disposeWithMe(a.toDisposable(n.onPointerEnterObserver.add(()=>{this._isEditorReadOnly(e)||(n.cursor=m.CURSOR_TYPE.TEXT)}))),this.disposeWithMe(a.toDisposable(n.onPointerLeaveObserver.add(()=>{n.cursor=m.CURSOR_TYPE.DEFAULT,i.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:g}=o;this._editorService.getEditor(e)&&(this._setEditorFocus(e),setTimeout(()=>{this._setEditorFocus(e),this._textSelectionRenderManager.setCursorManually(u,g)},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 i=t.params,{unitId:o}=i,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,i=this._renderManagerService.getRenderById(t);if(i==null)return;const{scene:o,mainComponent:s}=i;this._textSelectionRenderManager.changeRuntime(n,o,s),this._textSelectionManagerService.setCurrentSelectionNotRefresh({unitId:t,subUnitId:""})}))}_getDocObjectById(e){return this._univerInstanceService.getUnitType(e)!==a.UniverInstanceType.UNIVER_DOC?null:d.getDocObjectById(e,this._renderManagerService)}};re=En([a.OnLifecycle(a.LifecycleStages.Rendered,re),N(0,O.Inject(d.DocSkeletonManagerService)),N(1,a.IUniverInstanceService),N(2,a.ICommandService),N(3,m.IRenderManagerService),N(4,m.ITextSelectionRenderManager),N(5,O.Inject(d.TextSelectionManagerService)),N(6,l.IEditorService)],re);var Dn=Object.defineProperty,xn=Object.getOwnPropertyDescriptor,Un=(r,e,t,n)=>{for(var i=n>1?void 0:n?xn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Dn(e,t,i),i},W=(r,e)=>(t,n)=>e(t,n,r);const be=1.5;let oe=class extends a.RxDisposable{constructor(r,e,t,n,i){super(),this._docSkeletonManagerService=r,this._textSelectionManagerService=e,this._editorService=t,this._univerInstanceService=n,this._renderManagerService=i,this._init()}_init(){this._textSelectionManagerService.textSelection$.pipe(T.takeUntil(this.dispose$)).subscribe(r=>{if(r==null)return;const{isEditing:e,unitId:t}=r;e&&this._scrollToSelection(t)})}_scrollToSelection(r){var M;const e=this._textSelectionManagerService.getActiveRange(),t=this._getDocObject(),n=(M=this._docSkeletonManagerService.getCurrent())==null?void 0:M.skeleton;if(e==null||t==null||n==null)return;const{collapsed:i,startNodePosition:o}=e;if(!i)return;const s=t.document.getOffsetConfig(),{docsLeft:c,docsTop:u}=s,g=new m.NodePositionConvertToCursor(s,n),{contentBoxPointGroup:p}=g.getRangePointData(o,o),{left:_,top:f,height:S}=m.getAnchorBounding(p),v=_+c,h=f+u,I=t.scene.getViewport(d.VIEWPORT_KEY.VIEW_MAIN),b=!!this._editorService.getEditor(r);if(I==null)return;const{left:R,top:y,right:D,bottom:x}=I.getBounding().viewBound;let L=0,A=0;const Y=b?0:100;h<y?L=h-y:h>x-S&&(L=h-x+S+Y),v<R?A=v-R:v>D-be&&(A=v-D+be);const G=I.getBarScroll(A,L);I.scrollBy(G)}_getDocObject(){return d.getDocObject(this._univerInstanceService,this._renderManagerService)}};oe=Un([a.OnLifecycle(a.LifecycleStages.Rendered,oe),W(0,O.Inject(d.DocSkeletonManagerService)),W(1,O.Inject(d.TextSelectionManagerService)),W(2,l.IEditorService),W(3,a.IUniverInstanceService),W(4,m.IRenderManagerService)],oe);var Pn=Object.defineProperty,Nn=Object.getOwnPropertyDescriptor,Ln=(r,e,t,n)=>{for(var i=n>1?void 0:n?Nn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Pn(e,t,i),i},ge=(r,e)=>(t,n)=>e(t,n,r),J;exports.UniverDocsUIPlugin=(J=class extends a.Plugin{constructor(e,t,n,i){super(),this._config=e,this._injector=t,this._localeService=n,this._logService=i,this._localeService.load({zhCN:Le}),this._config=a.Tools.deepMerge({},ye,this._config),this._initDependencies(t),this._initializeCommands()}onRendered(){this._initModules(),this._markDocAsFocused()}_initializeCommands(){[ze,Ye,Ke,Ge,Xe,qe,Ze,Je,Qe,Wt,kt,Vt].forEach(e=>{this._injector.get(l.IShortcutService).registerShortcut(e)})}_initDependencies(e){[[H,{useFactory:()=>this._injector.createInstance(H,this._config)}],[Q],[ee],[te],[ne],[ie],[re],[oe],[k,{useFactory:()=>this._injector.createInstance(k,this._config)}],[z,{useClass:_e}],[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 i=n.getUnitId();t.isEditor(i)||e.focusUnit(n.getUnitId())}catch(n){this._logService.warn(n)}}_initModules(){this._injector.get(k)}},C(J,"pluginName",Ee),C(J,"type",a.UniverInstanceType.UNIVER_DOC),J);exports.UniverDocsUIPlugin=Ln([ge(1,O.Inject(O.Injector)),ge(2,O.Inject(a.LocaleService)),ge(3,a.ILogService)],exports.UniverDocsUIPlugin);exports.DOC_UI_PLUGIN_NAME=Ee;exports.DefaultDocContainerConfig=Me;exports.DefaultDocUiConfig=ye;exports.DefaultToolbarConfig=Re;exports.PastePluginLark=Ae;exports.PastePluginUniver=$e;exports.PastePluginWord=Fe;exports.enUS=Ft;exports.ruRU=jt;exports.zhCN=Le;
|
package/lib/es/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var Bt = Object.defineProperty;
|
|
2
2
|
var $t = (i, e, t) => e in i ? Bt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var p = (i, e, t) => ($t(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import { FOCUSING_DOC as De, FOCUSING_UNIVER_EDITOR as Ke, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE as Ft, Direction as V, EDITOR_ACTIVATED as Tt, LocaleService as Ze, RxDisposable as
|
|
4
|
+
import { FOCUSING_DOC as De, FOCUSING_UNIVER_EDITOR as Ke, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE as Ft, Direction as V, EDITOR_ACTIVATED as Tt, LocaleService as Ze, RxDisposable as de, ICommandService as v, BooleanNumber as C, UniverInstanceType as m, BaselineOffset as J, ThemeService as It, HorizontalAlign as Pe, IUniverInstanceService as U, Disposable as ee, OnLifecycle as L, LifecycleStages as B, Tools as qe, LRUMap as wt, ColorKit as ot, toDisposable as j, ILogService as bt, CommandType as Je, IContextService as jt, checkForSubstrings as Vt, IConfigService as Wt, PositionedObjectLayoutType as kt, DEFAULT_DOCUMENT_SUB_COMPONENT_ID as zt, IFloatingObjectManagerService as Ht, Plugin as Yt } from "@univerjs/core";
|
|
5
5
|
import { Inject as R, Injector as Ue, Optional as Gt, createIdentifier as Xt } from "@wendellhu/redi";
|
|
6
|
-
import { KeyCode as D, MetaKeys as
|
|
6
|
+
import { KeyCode as D, MetaKeys as ue, ILayoutService as yt, MenuGroup as I, MenuItemType as T, MenuPosition as b, getMenuHiddenObservable as y, FONT_FAMILY_LIST as st, FONT_SIZE_LIST as Kt, FontFamily as Zt, FontFamilyItem as qt, FontSize as Jt, BuiltInUIPart as Qt, ComponentManager as en, IEditorService as $, IMenuService as tn, IUIPartsService as nn, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as rn, HTML_CLIPBOARD_MIME_TYPE as on, IClipboardInterfaceService as Qe, CopyCommand as sn, CutCommand as an, PasteCommand as cn, SetEditorResizeOperation as ln, IShortcutService as dn } from "@univerjs/ui";
|
|
7
7
|
import { MoveCursorOperation as Ne, MoveSelectionOperation as Ae, SelectAllOperation as un, SetInlineFormatBoldCommand as hn, SetTextSelectionsOperation as P, SetInlineFormatCommand as te, SetInlineFormatItalicCommand as gn, SetInlineFormatUnderlineCommand as _n, SetInlineFormatStrikethroughCommand as pn, SetInlineFormatSubscriptCommand as fn, SetInlineFormatSuperscriptCommand as mn, SetInlineFormatFontFamilyCommand as at, SetInlineFormatFontSizeCommand as ct, SetInlineFormatTextColorCommand as lt, AlignLeftCommand as Sn, AlignOperationCommand as Le, AlignCenterCommand as vn, AlignRightCommand as Cn, AlignJustifyCommand as On, OrderListCommand as Rn, BulletListCommand as Tn, ResetInlineFormatTextBackgroundColorCommand as In, SetInlineFormatTextBackgroundColorCommand as He, TextSelectionManagerService as ne, BreakLineCommand as bn, DeleteLeftCommand as yn, DeleteRightCommand as Mn, CutContentCommand as Mt, InnerPasteCommand as Et, VIEWPORT_KEY as Be, CoverContentCommand as En, RichTextEditingMutation as et, DocSkeletonManagerService as ie, DOCS_VIEW_KEY as q, DOCS_COMPONENT_MAIN_LAYER_INDEX as We, DOCS_COMPONENT_HEADER_LAYER_INDEX as xn, DOCS_COMPONENT_DEFAULT_Z_INDEX as dt, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX as Dn, SetDocZoomRatioOperation as tt, SetDocZoomRatioCommand as Pn, getDocObject as xt, getDocObjectById as Un } from "@univerjs/docs";
|
|
8
8
|
import { connectInjector as Nn } from "@wendellhu/redi/react-bindings";
|
|
9
|
-
import { ITextSelectionRenderManager as
|
|
9
|
+
import { ITextSelectionRenderManager as he, pixelToPt as An, ptToPixel as ut, ScrollBar as Ye, IRenderManagerService as H, PageLayoutType as ht, Viewport as Ln, EVENT_TYPE as Bn, Layer as gt, Documents as $n, DocBackground as Fn, Liquid as wn, CURSOR_TYPE as _t, NodePositionConvertToCursor as jn, getAnchorBounding as Vn } from "@univerjs/engine-render";
|
|
10
10
|
import Wn from "react";
|
|
11
|
-
import { Observable as M, takeUntil as
|
|
11
|
+
import { Observable as M, takeUntil as le, fromEvent as pt, BehaviorSubject as kn } from "rxjs";
|
|
12
12
|
import { ColorPicker as zn } from "@univerjs/design";
|
|
13
13
|
const Hn = {
|
|
14
14
|
undo: !0,
|
|
@@ -93,35 +93,35 @@ const Zn = {
|
|
|
93
93
|
}
|
|
94
94
|
}, ei = {
|
|
95
95
|
id: Ae.id,
|
|
96
|
-
binding: D.ARROW_UP |
|
|
96
|
+
binding: D.ARROW_UP | ue.SHIFT,
|
|
97
97
|
preconditions: A,
|
|
98
98
|
staticParameters: {
|
|
99
99
|
direction: V.UP
|
|
100
100
|
}
|
|
101
101
|
}, ti = {
|
|
102
102
|
id: Ae.id,
|
|
103
|
-
binding: D.ARROW_DOWN |
|
|
103
|
+
binding: D.ARROW_DOWN | ue.SHIFT,
|
|
104
104
|
preconditions: A,
|
|
105
105
|
staticParameters: {
|
|
106
106
|
direction: V.DOWN
|
|
107
107
|
}
|
|
108
108
|
}, ni = {
|
|
109
109
|
id: Ae.id,
|
|
110
|
-
binding: D.ARROW_LEFT |
|
|
110
|
+
binding: D.ARROW_LEFT | ue.SHIFT,
|
|
111
111
|
preconditions: A,
|
|
112
112
|
staticParameters: {
|
|
113
113
|
direction: V.LEFT
|
|
114
114
|
}
|
|
115
115
|
}, ii = {
|
|
116
116
|
id: Ae.id,
|
|
117
|
-
binding: D.ARROW_RIGHT |
|
|
117
|
+
binding: D.ARROW_RIGHT | ue.SHIFT,
|
|
118
118
|
preconditions: A,
|
|
119
119
|
staticParameters: {
|
|
120
120
|
direction: V.RIGHT
|
|
121
121
|
}
|
|
122
122
|
}, ri = {
|
|
123
123
|
id: un.id,
|
|
124
|
-
binding: D.A |
|
|
124
|
+
binding: D.A | ue.CTRL_COMMAND,
|
|
125
125
|
preconditions: (i) => i.getContextValue(Ke) && (i.getContextValue(De) || i.getContextValue(Tt))
|
|
126
126
|
};
|
|
127
127
|
var oi = Object.defineProperty, si = Object.getOwnPropertyDescriptor, ai = (i, e, t, n) => {
|
|
@@ -176,8 +176,8 @@ var ci = Object.defineProperty, li = Object.getOwnPropertyDescriptor, di = (i, e
|
|
|
176
176
|
for (var r = n > 1 ? void 0 : n ? li(e, t) : e, o = i.length - 1, s; o >= 0; o--)
|
|
177
177
|
(s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
|
|
178
178
|
return n && r && ci(e, t, r), r;
|
|
179
|
-
},
|
|
180
|
-
let ae = class extends
|
|
179
|
+
}, me = (i, e) => (t, n) => e(t, n, i);
|
|
180
|
+
let ae = class extends de {
|
|
181
181
|
constructor(e, t, n, r, o) {
|
|
182
182
|
super();
|
|
183
183
|
p(this, "_docContainerController");
|
|
@@ -204,10 +204,10 @@ let ae = class extends le {
|
|
|
204
204
|
}
|
|
205
205
|
};
|
|
206
206
|
ae = di([
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
me(1, R(Ze)),
|
|
208
|
+
me(2, R(Ue)),
|
|
209
|
+
me(3, he),
|
|
210
|
+
me(4, Gt(yt))
|
|
211
211
|
], ae);
|
|
212
212
|
const $e = "UI_PLUGIN_DOCS", nt = `${$e}_COLOR_PICKER_COMPONENT`, Dt = `${$e}_FONT_FAMILY_COMPONENT`, Pt = `${$e}_FONT_FAMILY_ITEM_COMPONENT`, Ut = `${$e}_FONT_SIZE_COMPONENT`;
|
|
213
213
|
var Nt = { exports: {} }, Fe = {};
|
|
@@ -696,15 +696,16 @@ var Fi = Object.defineProperty, wi = Object.getOwnPropertyDescriptor, ji = (i, e
|
|
|
696
696
|
(s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
|
|
697
697
|
return n && r && Fi(e, t, r), r;
|
|
698
698
|
}, k = (i, e) => (t, n) => e(t, n, i);
|
|
699
|
-
let
|
|
700
|
-
constructor(i, e, t, n, r, o, s) {
|
|
701
|
-
super(), this.
|
|
699
|
+
let ce = class extends ee {
|
|
700
|
+
constructor(i, e, t, n, r, o, s, a) {
|
|
701
|
+
super(), this._config = i, this._injector = e, this._componentManager = t, this._layoutService = n, this._editorService = r, this._menuService = o, this._uiPartsService = s, this._univerInstanceService = a, this._init();
|
|
702
702
|
}
|
|
703
703
|
_initCustomComponents() {
|
|
704
704
|
const i = this._componentManager;
|
|
705
705
|
this.disposeWithMe(i.register(nt, zn)), this.disposeWithMe(i.register(Dt, Zt)), this.disposeWithMe(i.register(Pt, qt)), this.disposeWithMe(i.register(Ut, Jt));
|
|
706
706
|
}
|
|
707
707
|
_initMenus() {
|
|
708
|
+
const { menu: i = {} } = this._config;
|
|
708
709
|
[
|
|
709
710
|
Oi,
|
|
710
711
|
Ri,
|
|
@@ -723,8 +724,8 @@ let Ce = class extends ee {
|
|
|
723
724
|
Li,
|
|
724
725
|
Bi,
|
|
725
726
|
$i
|
|
726
|
-
].forEach((
|
|
727
|
-
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i))
|
|
727
|
+
].forEach((e) => {
|
|
728
|
+
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), i));
|
|
728
729
|
});
|
|
729
730
|
}
|
|
730
731
|
_init() {
|
|
@@ -735,27 +736,27 @@ let Ce = class extends ee {
|
|
|
735
736
|
if (i == null)
|
|
736
737
|
return;
|
|
737
738
|
this._editorService.isEditor(i) || this.disposeWithMe(
|
|
738
|
-
this.
|
|
739
|
+
this._uiPartsService.registerComponent(Qt.CONTENT, () => Nn(Ci, this._injector))
|
|
739
740
|
);
|
|
740
741
|
}
|
|
741
742
|
_initFocusHandler() {
|
|
742
743
|
this.disposeWithMe(
|
|
743
744
|
this._layoutService.registerFocusHandler(m.UNIVER_DOC, () => {
|
|
744
|
-
this._injector.get(
|
|
745
|
+
this._injector.get(he).focus();
|
|
745
746
|
})
|
|
746
747
|
);
|
|
747
748
|
}
|
|
748
749
|
};
|
|
749
|
-
|
|
750
|
-
L(B.Rendered,
|
|
751
|
-
k(
|
|
752
|
-
k(
|
|
753
|
-
k(
|
|
754
|
-
k(
|
|
755
|
-
k(
|
|
756
|
-
k(
|
|
757
|
-
k(
|
|
758
|
-
],
|
|
750
|
+
ce = ji([
|
|
751
|
+
L(B.Rendered, ce),
|
|
752
|
+
k(1, R(Ue)),
|
|
753
|
+
k(2, R(en)),
|
|
754
|
+
k(3, yt),
|
|
755
|
+
k(4, $),
|
|
756
|
+
k(5, tn),
|
|
757
|
+
k(6, nn),
|
|
758
|
+
k(7, U)
|
|
759
|
+
], ce);
|
|
759
760
|
const Vi = {
|
|
760
761
|
toolbar: {
|
|
761
762
|
undo: "Undo",
|
|
@@ -1176,7 +1177,7 @@ function dr(i) {
|
|
|
1176
1177
|
paragraphs: t
|
|
1177
1178
|
};
|
|
1178
1179
|
}
|
|
1179
|
-
const
|
|
1180
|
+
const ge = Xt("doc.clipboard-service");
|
|
1180
1181
|
let Xe = class extends ee {
|
|
1181
1182
|
constructor(e, t, n, r, o) {
|
|
1182
1183
|
super();
|
|
@@ -1326,7 +1327,7 @@ const rt = 999, ur = {
|
|
|
1326
1327
|
multi: !0,
|
|
1327
1328
|
priority: rt,
|
|
1328
1329
|
preconditions: je,
|
|
1329
|
-
handler: async (i) => i.get(
|
|
1330
|
+
handler: async (i) => i.get(ge).copy()
|
|
1330
1331
|
}, hr = {
|
|
1331
1332
|
id: an.id,
|
|
1332
1333
|
name: "doc.command.cut",
|
|
@@ -1334,7 +1335,7 @@ const rt = 999, ur = {
|
|
|
1334
1335
|
multi: !0,
|
|
1335
1336
|
priority: rt,
|
|
1336
1337
|
preconditions: je,
|
|
1337
|
-
handler: async (i) => i.get(
|
|
1338
|
+
handler: async (i) => i.get(ge).cut()
|
|
1338
1339
|
}, gr = {
|
|
1339
1340
|
id: cn.id,
|
|
1340
1341
|
name: "doc.command.paste",
|
|
@@ -1343,7 +1344,7 @@ const rt = 999, ur = {
|
|
|
1343
1344
|
priority: rt,
|
|
1344
1345
|
preconditions: je,
|
|
1345
1346
|
handler: async (i) => {
|
|
1346
|
-
const e = i.get(
|
|
1347
|
+
const e = i.get(ge), n = await i.get(Qe).read();
|
|
1347
1348
|
return n.length === 0 ? !1 : e.paste(n);
|
|
1348
1349
|
}
|
|
1349
1350
|
};
|
|
@@ -1352,7 +1353,7 @@ var _r = Object.defineProperty, pr = Object.getOwnPropertyDescriptor, fr = (i, e
|
|
|
1352
1353
|
(s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
|
|
1353
1354
|
return n && r && _r(e, t, r), r;
|
|
1354
1355
|
}, oe = (i, e) => (t, n) => e(t, n, i);
|
|
1355
|
-
let Oe = class extends
|
|
1356
|
+
let Oe = class extends de {
|
|
1356
1357
|
constructor(i, e, t, n, r) {
|
|
1357
1358
|
super(), this._commandService = i, this._clipboardInterfaceService = e, this._docClipboardService = t, this._textSelectionRenderManager = n, this._contextService = r, this._init();
|
|
1358
1359
|
}
|
|
@@ -1361,7 +1362,7 @@ let Oe = class extends le {
|
|
|
1361
1362
|
}
|
|
1362
1363
|
_initLegacyPasteCommand() {
|
|
1363
1364
|
var i;
|
|
1364
|
-
(i = this._textSelectionRenderManager) == null || i.onPaste$.pipe(
|
|
1365
|
+
(i = this._textSelectionRenderManager) == null || i.onPaste$.pipe(le(this.dispose$)).subscribe((e) => {
|
|
1365
1366
|
var o, s;
|
|
1366
1367
|
if (!je(this._contextService))
|
|
1367
1368
|
return;
|
|
@@ -1375,8 +1376,8 @@ Oe = fr([
|
|
|
1375
1376
|
L(B.Rendered, Oe),
|
|
1376
1377
|
oe(0, v),
|
|
1377
1378
|
oe(1, Qe),
|
|
1378
|
-
oe(2,
|
|
1379
|
-
oe(3,
|
|
1379
|
+
oe(2, ge),
|
|
1380
|
+
oe(3, he),
|
|
1380
1381
|
oe(4, jt)
|
|
1381
1382
|
], Oe);
|
|
1382
1383
|
var mr = Object.defineProperty, Sr = Object.getOwnPropertyDescriptor, vr = (i, e, t, n) => {
|
|
@@ -1519,22 +1520,22 @@ Re = vr([
|
|
|
1519
1520
|
X(1, R(ie)),
|
|
1520
1521
|
X(2, $),
|
|
1521
1522
|
X(3, v),
|
|
1522
|
-
X(4,
|
|
1523
|
+
X(4, he),
|
|
1523
1524
|
X(5, H)
|
|
1524
1525
|
], Re);
|
|
1525
1526
|
var Cr = Object.defineProperty, Or = Object.getOwnPropertyDescriptor, Rr = (i, e, t, n) => {
|
|
1526
1527
|
for (var r = n > 1 ? void 0 : n ? Or(e, t) : e, o = i.length - 1, s; o >= 0; o--)
|
|
1527
1528
|
(s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
|
|
1528
1529
|
return n && r && Cr(e, t, r), r;
|
|
1529
|
-
},
|
|
1530
|
-
let Te = class extends
|
|
1530
|
+
}, Se = (i, e) => (t, n) => e(t, n, i);
|
|
1531
|
+
let Te = class extends de {
|
|
1531
1532
|
constructor(e, t, n, r) {
|
|
1532
1533
|
super();
|
|
1533
1534
|
p(this, "_docRenderMap", /* @__PURE__ */ new Set());
|
|
1534
1535
|
this._docSkeletonManagerService = e, this._renderManagerService = t, this._commandService = n, this._editorService = r, this._initialRenderRefresh(), this._commandExecutedListener();
|
|
1535
1536
|
}
|
|
1536
1537
|
_initialRenderRefresh() {
|
|
1537
|
-
this._docSkeletonManagerService.currentSkeletonBefore$.pipe(
|
|
1538
|
+
this._docSkeletonManagerService.currentSkeletonBefore$.pipe(le(this.dispose$)).subscribe((e) => {
|
|
1538
1539
|
this._create(e);
|
|
1539
1540
|
});
|
|
1540
1541
|
}
|
|
@@ -1583,17 +1584,17 @@ let Te = class extends le {
|
|
|
1583
1584
|
};
|
|
1584
1585
|
Te = Rr([
|
|
1585
1586
|
L(B.Rendered, Te),
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1587
|
+
Se(0, R(ie)),
|
|
1588
|
+
Se(1, H),
|
|
1589
|
+
Se(2, v),
|
|
1590
|
+
Se(3, $)
|
|
1590
1591
|
], Te);
|
|
1591
1592
|
var Tr = Object.defineProperty, Ir = Object.getOwnPropertyDescriptor, br = (i, e, t, n) => {
|
|
1592
1593
|
for (var r = n > 1 ? void 0 : n ? Ir(e, t) : e, o = i.length - 1, s; o >= 0; o--)
|
|
1593
1594
|
(s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
|
|
1594
1595
|
return n && r && Tr(e, t, r), r;
|
|
1595
|
-
},
|
|
1596
|
-
let Ie = class extends
|
|
1596
|
+
}, ve = (i, e) => (t, n) => e(t, n, i);
|
|
1597
|
+
let Ie = class extends de {
|
|
1597
1598
|
constructor(e, t, n, r) {
|
|
1598
1599
|
super();
|
|
1599
1600
|
p(this, "_scene");
|
|
@@ -1603,9 +1604,9 @@ let Ie = class extends le {
|
|
|
1603
1604
|
this._renderManagerService = e, this._configService = t, this._univerInstanceService = n, this._editorService = r, this._initialize();
|
|
1604
1605
|
}
|
|
1605
1606
|
_initialize() {
|
|
1606
|
-
this._renderManagerService.createRender$.pipe(
|
|
1607
|
+
this._renderManagerService.createRender$.pipe(le(this.dispose$)).subscribe((e) => {
|
|
1607
1608
|
this._create(e);
|
|
1608
|
-
}), this._univerInstanceService.getCurrentTypeOfUnit$(m.UNIVER_DOC).pipe(
|
|
1609
|
+
}), this._univerInstanceService.getCurrentTypeOfUnit$(m.UNIVER_DOC).pipe(le(this.dispose$)).subscribe((e) => {
|
|
1609
1610
|
this._create(e == null ? void 0 : e.getUnitId());
|
|
1610
1611
|
}), this._univerInstanceService.getAllUnitsForType(m.UNIVER_DOC).forEach((e) => {
|
|
1611
1612
|
this._create(e.getUnitId());
|
|
@@ -1660,10 +1661,10 @@ let Ie = class extends le {
|
|
|
1660
1661
|
};
|
|
1661
1662
|
Ie = br([
|
|
1662
1663
|
L(B.Starting, Ie),
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1664
|
+
ve(0, H),
|
|
1665
|
+
ve(1, Wt),
|
|
1666
|
+
ve(2, U),
|
|
1667
|
+
ve(3, $)
|
|
1667
1668
|
], Ie);
|
|
1668
1669
|
var yr = Object.defineProperty, Mr = Object.getOwnPropertyDescriptor, Er = (i, e, t, n) => {
|
|
1669
1670
|
for (var r = n > 1 ? void 0 : n ? Mr(e, t) : e, o = i.length - 1, s; o >= 0; o--)
|
|
@@ -1690,9 +1691,9 @@ let be = class extends ee {
|
|
|
1690
1691
|
return;
|
|
1691
1692
|
const { mainComponent: s, components: a, scene: c } = o, l = s, { left: u, top: h } = l;
|
|
1692
1693
|
e.forEach((f) => {
|
|
1693
|
-
const { unitId: g, subUnitId: S, floatingObjectId: d, floatingObject: _ } = f, { left: O = 0, top: E = 0, width: N = 0, height: F = 0, angle: w, flipX: Y, flipY: G, skewX:
|
|
1694
|
+
const { unitId: g, subUnitId: S, floatingObjectId: d, floatingObject: _ } = f, { left: O = 0, top: E = 0, width: N = 0, height: F = 0, angle: w, flipX: Y, flipY: G, skewX: _e, skewY: pe } = _, x = this._pageMarginCache.get(d), fe = (x == null ? void 0 : x.marginLeft) || 0, Ve = (x == null ? void 0 : x.marginTop) || 0;
|
|
1694
1695
|
r == null || r.getViewModel().getDataModel().updateDrawing(d, {
|
|
1695
|
-
left: O - u -
|
|
1696
|
+
left: O - u - fe,
|
|
1696
1697
|
top: E - h - Ve,
|
|
1697
1698
|
height: F,
|
|
1698
1699
|
width: N
|
|
@@ -1744,7 +1745,7 @@ let be = class extends ee {
|
|
|
1744
1745
|
for (let d = 0, _ = g.length; d < _; d++) {
|
|
1745
1746
|
const O = g[d], { skeDrawings: E, marginLeft: N, marginTop: F } = O;
|
|
1746
1747
|
this._liquid.translatePagePadding(O), E.forEach((w) => {
|
|
1747
|
-
const { aLeft: Y, aTop: G, height:
|
|
1748
|
+
const { aLeft: Y, aTop: G, height: _e, width: pe, objectId: x, drawingOrigin: fe } = w, Ve = fe.layoutType === kt.WRAP_NONE && fe.behindDoc === C.TRUE;
|
|
1748
1749
|
S.push({
|
|
1749
1750
|
unitId: e,
|
|
1750
1751
|
subUnitId: zt,
|
|
@@ -1753,8 +1754,8 @@ let be = class extends ee {
|
|
|
1753
1754
|
floatingObject: {
|
|
1754
1755
|
left: Y + c + this._liquid.x,
|
|
1755
1756
|
top: G + l + this._liquid.y,
|
|
1756
|
-
width:
|
|
1757
|
-
height:
|
|
1757
|
+
width: pe,
|
|
1758
|
+
height: _e
|
|
1758
1759
|
}
|
|
1759
1760
|
}), this._pageMarginCache.set(x, {
|
|
1760
1761
|
marginLeft: this._liquid.x,
|
|
@@ -2020,7 +2021,7 @@ Me = Ar([
|
|
|
2020
2021
|
z(1, U),
|
|
2021
2022
|
z(2, v),
|
|
2022
2023
|
z(3, H),
|
|
2023
|
-
z(4,
|
|
2024
|
+
z(4, he),
|
|
2024
2025
|
z(5, R(ne)),
|
|
2025
2026
|
z(6, $)
|
|
2026
2027
|
], Me);
|
|
@@ -2030,12 +2031,12 @@ var Lr = Object.defineProperty, Br = Object.getOwnPropertyDescriptor, $r = (i, e
|
|
|
2030
2031
|
return n && r && Lr(e, t, r), r;
|
|
2031
2032
|
}, se = (i, e) => (t, n) => e(t, n, i);
|
|
2032
2033
|
const Ot = 1.5;
|
|
2033
|
-
let Ee = class extends
|
|
2034
|
+
let Ee = class extends de {
|
|
2034
2035
|
constructor(i, e, t, n, r) {
|
|
2035
2036
|
super(), this._docSkeletonManagerService = i, this._textSelectionManagerService = e, this._editorService = t, this._univerInstanceService = n, this._renderManagerService = r, this._init();
|
|
2036
2037
|
}
|
|
2037
2038
|
_init() {
|
|
2038
|
-
this._textSelectionManagerService.textSelection$.pipe(
|
|
2039
|
+
this._textSelectionManagerService.textSelection$.pipe(le(this.dispose$)).subscribe((i) => {
|
|
2039
2040
|
if (i == null)
|
|
2040
2041
|
return;
|
|
2041
2042
|
const { isEditing: e, unitId: t } = i;
|
|
@@ -2061,10 +2062,10 @@ let Ee = class extends le {
|
|
|
2061
2062
|
bottom: w
|
|
2062
2063
|
} = _.getBounding().viewBound;
|
|
2063
2064
|
let Y = 0, G = 0;
|
|
2064
|
-
const
|
|
2065
|
-
d < N ? Y = d - N : d > w - g && (Y = d - w + g +
|
|
2066
|
-
const
|
|
2067
|
-
_.scrollBy(
|
|
2065
|
+
const _e = O ? 0 : 100;
|
|
2066
|
+
d < N ? Y = d - N : d > w - g && (Y = d - w + g + _e), S < E ? G = S - E : S > F - Ot && (G = S - F + Ot);
|
|
2067
|
+
const pe = _.getBarScroll(G, Y);
|
|
2068
|
+
_.scrollBy(pe);
|
|
2068
2069
|
}
|
|
2069
2070
|
_getDocObject() {
|
|
2070
2071
|
return xt(this._univerInstanceService, this._renderManagerService);
|
|
@@ -2082,12 +2083,10 @@ var Fr = Object.defineProperty, wr = Object.getOwnPropertyDescriptor, jr = (i, e
|
|
|
2082
2083
|
for (var r = n > 1 ? void 0 : n ? wr(e, t) : e, o = i.length - 1, s; o >= 0; o--)
|
|
2083
2084
|
(s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
|
|
2084
2085
|
return n && r && Fr(e, t, r), r;
|
|
2085
|
-
}, ze = (i, e) => (t, n) => e(t, n, i),
|
|
2086
|
-
let Rt = (
|
|
2086
|
+
}, ze = (i, e) => (t, n) => e(t, n, i), Ce;
|
|
2087
|
+
let Rt = (Ce = class extends Yt {
|
|
2087
2088
|
constructor(i, e, t, n) {
|
|
2088
|
-
super(), this._config = i, this._injector = e, this._localeService = t, this._logService = n, this._localeService.load({
|
|
2089
|
-
zhCN: ki
|
|
2090
|
-
}), this._config = qe.deepMerge({}, Gn, this._config), this._initDependencies(e), this._initializeCommands();
|
|
2089
|
+
super(), this._config = i, this._injector = e, this._localeService = t, this._logService = n, this._localeService.load({ zhCN: ki }), this._config = qe.deepMerge({}, Gn, this._config), this._initDependencies(e), this._initializeCommands();
|
|
2091
2090
|
}
|
|
2092
2091
|
onRendered() {
|
|
2093
2092
|
this._initModules(), this._markDocAsFocused();
|
|
@@ -2113,7 +2112,12 @@ let Rt = (ve = class extends Yt {
|
|
|
2113
2112
|
_initDependencies(i) {
|
|
2114
2113
|
[
|
|
2115
2114
|
// Controller
|
|
2116
|
-
[
|
|
2115
|
+
[
|
|
2116
|
+
ce,
|
|
2117
|
+
{
|
|
2118
|
+
useFactory: () => this._injector.createInstance(ce, this._config)
|
|
2119
|
+
}
|
|
2120
|
+
],
|
|
2117
2121
|
[Oe],
|
|
2118
2122
|
[Re],
|
|
2119
2123
|
[Te],
|
|
@@ -2129,7 +2133,7 @@ let Rt = (ve = class extends Yt {
|
|
|
2129
2133
|
}
|
|
2130
2134
|
],
|
|
2131
2135
|
[
|
|
2132
|
-
|
|
2136
|
+
ge,
|
|
2133
2137
|
{
|
|
2134
2138
|
useClass: Xe
|
|
2135
2139
|
}
|
|
@@ -2155,7 +2159,7 @@ let Rt = (ve = class extends Yt {
|
|
|
2155
2159
|
_initModules() {
|
|
2156
2160
|
this._injector.get(ae);
|
|
2157
2161
|
}
|
|
2158
|
-
}, p(
|
|
2162
|
+
}, p(Ce, "pluginName", Xn), p(Ce, "type", m.UNIVER_DOC), Ce);
|
|
2159
2163
|
Rt = jr([
|
|
2160
2164
|
ze(1, R(Ue)),
|
|
2161
2165
|
ze(2, R(Ze)),
|
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
1
|
+
import { MenuConfig } from '@univerjs/ui';
|
|
2
|
+
|
|
16
3
|
export interface ILayout {
|
|
17
4
|
docContainerConfig?: DocContainerConfig;
|
|
18
5
|
toolbarConfig?: DocToolbarConfig;
|
|
19
6
|
}
|
|
20
7
|
export interface IUniverDocsUIConfig {
|
|
8
|
+
menu?: MenuConfig;
|
|
21
9
|
container?: HTMLElement | string;
|
|
22
10
|
layout?: ILayout;
|
|
23
11
|
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ComponentManager, IEditorService, ILayoutService, IMenuService, IUIPartsService } from '@univerjs/ui';
|
|
3
3
|
import { Injector } from '@wendellhu/redi';
|
|
4
|
+
import { IUniverDocsUIConfig } from '../basics';
|
|
4
5
|
|
|
5
6
|
export declare class DocUIController extends Disposable {
|
|
7
|
+
private readonly _config;
|
|
6
8
|
private readonly _injector;
|
|
7
9
|
private readonly _componentManager;
|
|
8
10
|
private readonly _layoutService;
|
|
9
11
|
private readonly _editorService;
|
|
10
12
|
private readonly _menuService;
|
|
11
|
-
private readonly
|
|
13
|
+
private readonly _uiPartsService;
|
|
12
14
|
private readonly _univerInstanceService;
|
|
13
|
-
constructor(_injector: Injector, _componentManager: ComponentManager, _layoutService: ILayoutService, _editorService: IEditorService, _menuService: IMenuService,
|
|
15
|
+
constructor(_config: Partial<IUniverDocsUIConfig>, _injector: Injector, _componentManager: ComponentManager, _layoutService: ILayoutService, _editorService: IEditorService, _menuService: IMenuService, _uiPartsService: IUIPartsService, _univerInstanceService: IUniverInstanceService);
|
|
14
16
|
private _initCustomComponents;
|
|
15
17
|
private _initMenus;
|
|
16
18
|
private _init;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(S,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("@univerjs/docs"),require("@wendellhu/redi/react-bindings"),require("@univerjs/engine-render"),require("react"),require("rxjs"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","@univerjs/docs","@wendellhu/redi/react-bindings","@univerjs/engine-render","react","rxjs","@univerjs/design"],a):(S=typeof globalThis<"u"?globalThis:S||self,a(S.UniverDocsUi={},S.UniverCore,S["@wendellhu/redi"],S.UniverUi,S.UniverDocs,S["@wendellhu/redi/react-bindings"],S.UniverEngineRender,S.React,S.rxjs,S.UniverDesign))})(this,function(S,a,v,l,d,je,m,Ve,b,We){"use strict";var Rn=Object.defineProperty;var En=(S,a,v)=>a in S?Rn(S,a,{enumerable:!0,configurable:!0,writable:!0,value:v}):S[a]=v;var T=(S,a,v)=>(En(S,typeof a!="symbol"?a+"":a,v),v);var ce;const Ce={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},Ie={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},Oe={layout:{docContainerConfig:Ie,toolbarConfig:Ce}},Te="DocUI";function E(r){return r.getContextValue(a.FOCUSING_DOC)&&r.getContextValue(a.FOCUSING_UNIVER_EDITOR)}function ke(r){return r.getContextValue(a.FOCUSING_DOC)&&r.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!r.getContextValue(a.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE)}const He={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_UP,preconditions:E,staticParameters:{direction:a.Direction.UP}},ze={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_DOWN,preconditions:E,staticParameters:{direction:a.Direction.DOWN}},Ye={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_LEFT,preconditions:E,staticParameters:{direction:a.Direction.LEFT}},Ge={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_RIGHT,preconditions:E,staticParameters:{direction:a.Direction.RIGHT}},Ke={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_UP|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.UP}},Xe={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_DOWN|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.DOWN}},qe={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_LEFT|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.LEFT}},Ze={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_RIGHT|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.RIGHT}},Je={id:d.SelectAllOperation.id,binding:l.KeyCode.A|l.MetaKeys.CTRL_COMMAND,preconditions:r=>r.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&(r.getContextValue(a.FOCUSING_DOC)||r.getContextValue(a.EDITOR_ACTIVATED))};var Qe=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(r,e,t,n)=>{for(var i=n>1?void 0:n?et(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Qe(e,t,i),i},be=(r,e)=>(t,n)=>e(t,n,r);let he=class{constructor(r,e,t){T(this,"_docContainer");T(this,"getComponent",r=>{if(this._docContainer=r,!r.getContentRef().current)throw new Error("container is not ready")});T(this,"changeLocale",r=>{this._localeService.setLocale(r)});this._config=r,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(r){if(this._docContainer)return r(this._docContainer)}getDocContainer(){return this._docContainer}};he=tt([be(1,v.Inject(a.LocaleService)),be(2,v.Inject(v.Injector))],he);var nt=Object.defineProperty,it=Object.getOwnPropertyDescriptor,rt=(r,e,t,n)=>{for(var i=n>1?void 0:n?it(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&nt(e,t,i),i},
|
|
1
|
+
(function(S,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("@univerjs/docs"),require("@wendellhu/redi/react-bindings"),require("@univerjs/engine-render"),require("react"),require("rxjs"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","@univerjs/docs","@wendellhu/redi/react-bindings","@univerjs/engine-render","react","rxjs","@univerjs/design"],a):(S=typeof globalThis<"u"?globalThis:S||self,a(S.UniverDocsUi={},S.UniverCore,S["@wendellhu/redi"],S.UniverUi,S.UniverDocs,S["@wendellhu/redi/react-bindings"],S.UniverEngineRender,S.React,S.rxjs,S.UniverDesign))})(this,function(S,a,v,l,d,je,m,Ve,b,We){"use strict";var Rn=Object.defineProperty;var En=(S,a,v)=>a in S?Rn(S,a,{enumerable:!0,configurable:!0,writable:!0,value:v}):S[a]=v;var T=(S,a,v)=>(En(S,typeof a!="symbol"?a+"":a,v),v);var ce;const Ce={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},Ie={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},Oe={layout:{docContainerConfig:Ie,toolbarConfig:Ce}},Te="DocUI";function E(r){return r.getContextValue(a.FOCUSING_DOC)&&r.getContextValue(a.FOCUSING_UNIVER_EDITOR)}function ke(r){return r.getContextValue(a.FOCUSING_DOC)&&r.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!r.getContextValue(a.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE)}const He={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_UP,preconditions:E,staticParameters:{direction:a.Direction.UP}},ze={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_DOWN,preconditions:E,staticParameters:{direction:a.Direction.DOWN}},Ye={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_LEFT,preconditions:E,staticParameters:{direction:a.Direction.LEFT}},Ge={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_RIGHT,preconditions:E,staticParameters:{direction:a.Direction.RIGHT}},Ke={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_UP|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.UP}},Xe={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_DOWN|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.DOWN}},qe={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_LEFT|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.LEFT}},Ze={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_RIGHT|l.MetaKeys.SHIFT,preconditions:E,staticParameters:{direction:a.Direction.RIGHT}},Je={id:d.SelectAllOperation.id,binding:l.KeyCode.A|l.MetaKeys.CTRL_COMMAND,preconditions:r=>r.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&(r.getContextValue(a.FOCUSING_DOC)||r.getContextValue(a.EDITOR_ACTIVATED))};var Qe=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(r,e,t,n)=>{for(var i=n>1?void 0:n?et(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Qe(e,t,i),i},be=(r,e)=>(t,n)=>e(t,n,r);let he=class{constructor(r,e,t){T(this,"_docContainer");T(this,"getComponent",r=>{if(this._docContainer=r,!r.getContentRef().current)throw new Error("container is not ready")});T(this,"changeLocale",r=>{this._localeService.setLocale(r)});this._config=r,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(r){if(this._docContainer)return r(this._docContainer)}getDocContainer(){return this._docContainer}};he=tt([be(1,v.Inject(a.LocaleService)),be(2,v.Inject(v.Injector))],he);var nt=Object.defineProperty,it=Object.getOwnPropertyDescriptor,rt=(r,e,t,n)=>{for(var i=n>1?void 0:n?it(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&nt(e,t,i),i},G=(r,e)=>(t,n)=>e(t,n,r);let V=class extends a.RxDisposable{constructor(e,t,n,i,o){super();T(this,"_docContainerController");T(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._localeService=t,this._injector=n,this._textSelectionRenderManager=i,this._layoutService=o,this._docContainerController=this._injector.createInstance(he,e),this._registerContainer()}_registerContainer(){this._layoutService&&this.disposeWithMe(this._layoutService.registerContainerElement(this._textSelectionRenderManager.__getEditorContainer()))}getDocContainerController(){return this._docContainerController}};V=rt([G(1,v.Inject(a.LocaleService)),G(2,v.Inject(v.Injector)),G(3,m.ITextSelectionRenderManager),G(4,v.Optional(l.ILayoutService))],V);const K="UI_PLUGIN_DOCS",ge=`${K}_COLOR_PICKER_COMPONENT`,Me=`${K}_FONT_FAMILY_COMPONENT`,ye=`${K}_FONT_FAMILY_ITEM_COMPONENT`,Re=`${K}_FONT_SIZE_COMPONENT`;var Ee={exports:{}},X={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var ot=Ve,st=Symbol.for("react.element"),at=Symbol.for("react.fragment"),ct=Object.prototype.hasOwnProperty,lt=ot.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,dt={key:!0,ref:!0,__self:!0,__source:!0};function De(r,e,t){var n,i={},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)ct.call(e,n)&&!dt.hasOwnProperty(n)&&(i[n]=e[n]);if(r&&r.defaultProps)for(n in e=r.defaultProps,e)i[n]===void 0&&(i[n]=e[n]);return{$$typeof:st,type:r,key:o,ref:s,props:i,_owner:lt.current}}K.Fragment=at,K.jsx=De,K.jsxs=De,Ee.exports=K;var ut=Ee.exports;const ht={docsUiCanvasBackground:"univer-docs-ui-canvas-background"},pt=()=>ut.jsx("div",{className:ht.docsUiCanvasBackground});function gt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function _t(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function St(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function ft(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function mt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function vt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Ct(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,label:Me,positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_FAMILY_LIST.map(t=>({label:{name:ye,hoverable:!0},value:t.value})),value$:new b.Observable(t=>{const n=l.FONT_FAMILY_LIST[0].value,i=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatFontFamilyCommand.id){const u=U(r);if(u==null)return;const p=(c=u.ts)==null?void 0:c.ff;t.next(p!=null?p:n)}});return t.next(n),i.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function It(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatFontSizeCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Re,props:{min:1,max:400}},positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_SIZE_LIST,value$:new b.Observable(t=>{const i=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatFontSizeCommand.id){const u=U(r);if(u==null)return;const p=(c=u.ts)==null?void 0:c.fs;t.next(p!=null?p:14)}});return t.next(14),i.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function Ot(r){const e=r.get(a.ICommandService),t=r.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:pe,hoverable:!1}}],value$:new b.Observable(n=>{const i=t.getCurrentTheme().textColor,o=e.onCommandExecuted(s=>{if(s.id===d.SetInlineFormatTextColorCommand.id){const c=s.params.value;n.next(c!=null?c:i)}});return n.next(i),o.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function Tt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=X(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function bt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=X(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Mt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=X(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function yt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=X(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Rt(r){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(r,a.UniverInstanceType.UNIVER_DOC)}}function Et(r){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(r,a.UniverInstanceType.UNIVER_DOC)}}function Dt(r){return{id:d.ResetInlineFormatTextBackgroundColorCommand.id,type:l.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:d.SetInlineFormatTextBackgroundColorCommand.id}}function Ut(r){const e=r.get(a.ICommandService),t=r.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:pe,hoverable:!1}}],value$:new b.Observable(n=>{const i=t.getCurrentTheme().primaryColor,o=e.onCommandExecuted(s=>{if(s.id===d.SetInlineFormatTextBackgroundColorCommand.id){const c=s.params.value;n.next(c!=null?c:i)}});return n.next(i),o.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function U(r){var u;const e=r.get(a.IUniverInstanceService),t=r.get(d.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),i=t.getActiveRange();if(n==null||i==null)return;const o=(u=n.getBody())==null?void 0:u.textRuns;if(o==null)return;const{startOffset:s}=i;return o.find(({st:p,ed:g})=>s>=p&&s<g)}function X(r){var u;const e=r.get(a.IUniverInstanceService),t=r.get(d.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),i=t.getActiveRange();if(n==null||i==null)return;const o=(u=n.getBody())==null?void 0:u.paragraphs;if(o==null)return;const{startOffset:s}=i;let c=-1;for(const p of o){const{startIndex:g}=p;if(s>c&&s<=g)return p;c=g}return null}var Pt=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,xt=(r,e,t,n)=>{for(var i=n>1?void 0:n?Nt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Pt(e,t,i),i},x=(r,e)=>(t,n)=>e(t,n,r);let q=class extends a.Disposable{constructor(r,e,t,n,i,o,s){super(),this._injector=r,this._componentManager=e,this._layoutService=t,this._editorService=n,this._menuService=i,this._uiController=o,this._univerInstanceService=s,this._init()}_initCustomComponents(){const r=this._componentManager;this.disposeWithMe(r.register(pe,We.ColorPicker)),this.disposeWithMe(r.register(Me,l.FontFamily)),this.disposeWithMe(r.register(ye,l.FontFamilyItem)),this.disposeWithMe(r.register(Re,l.FontSize))}_initMenus(){[gt,_t,St,ft,mt,vt,It,Ct,Ot,Tt,bt,Mt,yt,Rt,Et,Dt,Ut].forEach(r=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(r)))})}_init(){this._initCustomComponents(),this._initMenus(),this._initDocBackground(),this._initFocusHandler()}_initDocBackground(){const r=this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_DOC)[0].getUnitId();if(r==null)return;this._editorService.isEditor(r)||this.disposeWithMe(this._uiController.registerComponent(l.DesktopUIPart.CONTENT,()=>je.connectInjector(pt,this._injector)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(a.UniverInstanceType.UNIVER_DOC,()=>{this._injector.get(m.ITextSelectionRenderManager).focus()}))}};q=xt([a.OnLifecycle(a.LifecycleStages.Rendered,q),x(0,v.Inject(v.Injector)),x(1,v.Inject(l.ComponentManager)),x(2,l.ILayoutService),x(3,l.IEditorService),x(4,l.IMenuService),x(5,l.IUIController),x(6,a.IUniverInstanceService)],q);const Lt={toolbar:{undo:"Undo",redo:"Redo",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},fillColor:{main:"Text Background color",right:"Choose color"},resetColor:"Reset",order:"Ordered list",unorder:"Unordered list",alignLeft:"Align Left",alignCenter:"Align Center",alignRight:"Align Right",alignJustify:"Justify"}},Ue={toolbar:{undo:"撤销",redo:"重做",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},fillColor:{main:"文本背景色",right:"背景色选择"},resetColor:"重置颜色",order:"有序列表",unorder:"无序列表",alignLeft:"左对齐",alignCenter:"居中对齐",alignRight:"右对齐",alignJustify:"两端对齐"}},At={toolbar:{undo:"Отменить",redo:"Повторить",font:"Шрифт",fontSize:"Размер шрифта",bold:"Полужирный",italic:"Курсив",strikethrough:"Зачеркнутый",subscript:"Нижний индекс",superscript:"Верхний индекс",underline:"Подчеркнутый",textColor:{main:"Цвет текста",right:"Выбрать цвет"},fillColor:{main:"Цвет фона текста",right:"Выбрать цвет"},resetColor:"Сбросить",order:"Упорядоченный список",unorder:"Неупорядоченный список",alignLeft:"Выровнять по левому краю",alignCenter:"Выровнять по центру",alignRight:"Выровнять по правому краю",alignJustify:"Выровнять по ширине"}},Bt={id:d.BreakLineCommand.id,preconditions:ke,binding:l.KeyCode.ENTER},Ft={id:d.DeleteLeftCommand.id,preconditions:E,binding:l.KeyCode.BACKSPACE},$t={id:d.DeleteRightCommand.id,preconditions:E,binding:l.KeyCode.DELETE},wt=10,jt=6;function Vt(){return a.Tools.generateRandomId(jt)}function Wt(r){const e=r.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class kt{constructor(){T(this,"_cache",new a.LRUMap(wt))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}clear(){this._cache.clear()}}const Pe=new kt;function ge(r){const e=r.style,t={},n=r.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 i=0;i<e.length;i++){const o=e[i],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=m.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 Ht(r){const e=new DOMParser,t=`<x-univer id="univer-root">${r}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function Ne(r,e){const t=r.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(r)}const ae=class ae{constructor(){T(this,"_styleCache",new Map);T(this,"_styleRules",[]);T(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=ae._pluginList.find(o=>o.checkPasteType(e)),n=Ht(e),i={dataStream:"",textRuns:[]};return t&&(this._styleRules=[...t.stylesRules],this._afterProcessRules=[...t.afterProcessRules]),this._styleCache.clear(),this._process(null,n==null?void 0:n.childNodes,i),this._styleCache.clear(),this._styleRules=[],this._afterProcessRules=[],i}_process(e,t,n){var i;for(const o of t)if(o.nodeType===Node.TEXT_NODE){const s=(i=o.nodeValue)==null?void 0:i.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:_})=>Ne(o,_)),u=c?c.getStyle(o):ge(o);this._styleCache.set(o,{...s,...u});const{childNodes:p}=o;this._process(o,p,n);const g=this._afterProcessRules.find(({filter:_})=>Ne(o,_));g&&g.handler(n,o)}}};T(ae,"_pluginList",[]);let A=ae;const xe={name:"univer-doc-paste-plugin-lark",checkPasteType(r){return/lark-record-clipboard/i.test(r)},stylesRules:[{filter:["s"],getStyle(r){const e=ge(r);return{st:{s:a.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(r){return r.tagName==="DIV"&&/ace-line/i.test(r.className)},handler(r){r.paragraphs==null&&(r.paragraphs=[]),r.paragraphs.push({startIndex:r.dataStream.length}),r.dataStream+="\r"}}]};function Le(r){const e=r.style,t={};for(let n=0;n<e.length;n++){const i=e[n],o=e.getPropertyValue(i);switch(i){case"margin-top":{const s=Number.parseInt(o);t.spaceAbove=/pt/.test(o)?m.ptToPixel(s):s;break}case"margin-bottom":{const s=Number.parseInt(o);t.spaceBelow=/pt/.test(o)?m.ptToPixel(s):s;break}case"line-height":{const s=Number.parseFloat(o);t.lineSpacing=s;break}}}return Object.getOwnPropertyNames(t).length?t:null}const Ae={name:"univer-doc-paste-plugin-word",checkPasteType(r){return/word|mso/i.test(r)},stylesRules:[{filter:["b"],getStyle(r){const e=ge(r);return{bl:a.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(r){return r.tagName==="P"&&/mso/i.test(r.className)},handler(r,e){r.paragraphs==null&&(r.paragraphs=[]);const t={startIndex:r.dataStream.length},n=Le(e);n&&(t.paragraphStyle=n),r.paragraphs.push(t),r.dataStream+="\r"}}]},Be={name:"univer-doc-paste-plugin-univer",checkPasteType(r){return/UniverNormal/i.test(r)},stylesRules:[],afterProcessRules:[{filter(r){return r.tagName==="P"&&/UniverNormal/i.test(r.className)},handler(r,e){r.paragraphs==null&&(r.paragraphs=[]);const t={startIndex:r.dataStream.length},n=Le(e);n&&(t.paragraphStyle=n),r.paragraphs.push(t),r.dataStream+="\r"}}]};function Fe(r,e){const{st:t,ed:n,ts:i={}}=e,{ff:o,fs:s,it:c,bl:u,ul:p,st:g,ol:_,bg:C,cl:f,va:I}=i;let h=r.slice(t,n);const O=[];return c===a.BooleanNumber.TRUE&&(h=`<i>${h}</i>`),I===a.BaselineOffset.SUPERSCRIPT?h=`<sup>${h}</sup>`:I===a.BaselineOffset.SUBSCRIPT&&(h=`<sub>${h}</sub>`),(p==null?void 0:p.s)===a.BooleanNumber.TRUE&&(h=`<u>${h}</u>`),(g==null?void 0:g.s)===a.BooleanNumber.TRUE&&(h=`<s>${h}</s>`),u===a.BooleanNumber.TRUE&&(h=`<strong>${h}</strong>`),o&&O.push(`font-family: ${o}`),f&&O.push(`color: ${f.rgb}`),s&&O.push(`font-size: ${s}pt`),_&&O.push("text-decoration: overline"),C&&O.push(`background: ${C.rgb}`),O.length?`<span style="${O.join("; ")};">${h}</span>`:h}function _e(r,e,t){const{dataStream:n,textRuns:i=[]}=r;let o=e;const s=[];for(const c of i){const{st:u,ed:p}=c;a.Tools.hasIntersectionBetweenTwoRanges(e,t,u,p)&&(u>o?(s.push(n.slice(o,u)),s.push(Fe(n,{...c,ed:Math.min(p,t)}))):s.push(Fe(n,{...c,st:o,ed:Math.min(p,t)}))),o=Math.max(e,Math.min(p,t))}return o!==t&&s.push(n.slice(o,t)),s.join("")}function $e(r,e=!0){var t;if(e&&((t=r.paragraphs)!=null&&t.length)){const{dataStream:n,paragraphs:i=[]}=r;let o="",s=-1;for(const c of i){const{startIndex:u,paragraphStyle:p={}}=c,{spaceAbove:g,spaceBelow:_,lineSpacing:C}=p,f=[];g!=null&&(typeof g=="number"?f.push(`margin-top: ${g}px`):f.push(`margin-top: ${g.v}px`)),_!=null&&(typeof _=="number"?f.push(`margin-bottom: ${_}px`):f.push(`margin-bottom: ${_.v}px`)),C!=null&&f.push(`line-height: ${C}`),u>s+1?o+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}>${_e(r,s+1,u)}</p>`:o+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}></p>`,s=u}return s!==n.length&&(o+=_e(r,s,n.length)),o}else return _e(r,0,r.dataStream.length)}class zt{convert(e){if(e.length===0)throw new Error("The bodyList length at least to be 1");if(e.length===1)return $e(e[0]);let t="";for(const n of e)t+='<p className="UniverNormal">',t+=$e(n,!1),t+="</p>";return t}}var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Kt=(r,e,t,n)=>{for(var i=n>1?void 0:n?Gt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Yt(e,t,i),i},W=(r,e)=>(t,n)=>e(t,n,r);A.use(Ae),A.use(xe),A.use(Be);function Xt(r){const e=r.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=v.createIdentifier("doc.clipboard-service");let Se=class extends a.Disposable{constructor(e,t,n,i,o){super();T(this,"_clipboardHooks",[]);T(this,"_htmlToUDM",new A);T(this,"_umdToHtml",new zt);this._univerInstanceService=e,this._logService=t,this._commandService=n,this._clipboardInterfaceService=i,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:{},i=this._textSelectionManagerService.getSelections();if(e==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),t==null||i==null)return!1;this.copy();try{let s=t;for(const u of i){const{startOffset:p,endOffset:g}=u;p==null||g==null||g<=t&&(s-=g-p)}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:i}=(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 p of o){const{startOffset:g,endOffset:_}=p;g==null||_==null||_<=n&&(c+=e.dataStream.length-(_-g))}const u=[{startOffset:c,endOffset:c,style:i}];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=Vt(),n=e.length>1?e.map(o=>o.dataStream).join(`
|
|
10
|
-
`):e[0].dataStream;let i=this._umdToHtml.convert(e);return e.length===1&&(i=i.replace(/(<[a-z]+)/,(o,s)=>`${s} data-copy-id="${t}"`),Pe.set(t,e[0])),this._clipboardInterfaceService.write(n,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._univerInstanceService.getCurrentUniverDocInstance(),n=[];if(e==null||!t)return n;for(const i of e){const{startOffset:o,endOffset:s,collapsed:c}=i;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 i of e)for(const o of i.types)o===l.PLAIN_TEXT_CLIPBOARD_MIME_TYPE?n=await i.getType(o).then(s=>s&&s.text()):o===l.HTML_CLIPBOARD_MIME_TYPE&&(t=await i.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 Xt(t);throw new Error("[DocClipboardService] html and text cannot be both empty!")}const n=Wt(e);if(n){const i=Pe.get(n);if(i)return i}return this._htmlToUDM.convert(e)}};Se=Kt([W(0,a.IUniverInstanceService),W(1,a.ILogService),W(2,a.ICommandService),W(3,l.IClipboardInterfaceService),W(4,v.Inject(d.TextSelectionManagerService))],Se);function Z(r){return r.getContextValue(a.FOCUSING_DOC)||r.getContextValue(a.EDITOR_ACTIVATED)}const fe=999,qt={id:l.CopyCommand.id,name:"doc.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:Z,handler:async r=>r.get(k).copy()},Zt={id:l.CutCommand.id,name:"doc.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:Z,handler:async r=>r.get(k).cut()},Jt={id:l.PasteCommand.id,name:"doc.command.paste",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:Z,handler:async r=>{const e=r.get(k),n=await r.get(l.IClipboardInterfaceService).read();return n.length===0?!1:e.paste(n)}};var Qt=Object.defineProperty,en=Object.getOwnPropertyDescriptor,tn=(r,e,t,n)=>{for(var i=n>1?void 0:n?en(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Qt(e,t,i),i},H=(r,e)=>(t,n)=>e(t,n,r);let J=class extends a.RxDisposable{constructor(r,e,t,n,i){super(),this._commandService=r,this._clipboardInterfaceService=e,this._docClipboardService=t,this._textSelectionRenderManager=n,this._contextService=i,this._init()}_init(){[qt,Zt,Jt].forEach(r=>this.disposeWithMe(this._commandService.registerMultipleCommand(r))),[d.InnerPasteCommand,d.CutContentCommand].forEach(r=>this.disposeWithMe(this._commandService.registerCommand(r))),this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var r;(r=this._textSelectionRenderManager)==null||r.onPaste$.pipe(b.takeUntil(this.dispose$)).subscribe(e=>{var o,s;if(!Z(this._contextService))return;e.event.preventDefault();const t=e.event,n=(o=t.clipboardData)==null?void 0:o.getData("text/html"),i=(s=t.clipboardData)==null?void 0:s.getData("text/plain");this._docClipboardService.legacyPaste(n,i)})}};J=tn([a.OnLifecycle(a.LifecycleStages.Rendered,J),H(0,a.ICommandService),H(1,l.IClipboardInterfaceService),H(2,k),H(3,m.ITextSelectionRenderManager),H(4,a.IContextService)],J);var nn=Object.defineProperty,rn=Object.getOwnPropertyDescriptor,on=(r,e,t,n)=>{for(var i=n>1?void 0:n?rn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&nn(e,t,i),i},B=(r,e)=>(t,n)=>e(t,n,r);let Q=class extends a.Disposable{constructor(e,t,n,i,o,s){super();T(this,"_initialEditors",new Set);this._univerInstanceService=e,this._docSkeletonManagerService=t,this._editorService=n,this._commandService=i,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 D,P,N;if(e==null)return;const t=this._editorService.getEditor(e);if((t==null?void 0:t.cancelDefaultResizeListener)===!0)return;const n=(D=this._docSkeletonManagerService.getSkeletonByUnitId(e))==null?void 0:D.skeleton,i=this._univerInstanceService.getUniverDocInstance(e);if(t==null||t.render==null||n==null||i==null)return;n.calculate();const{marginTop:o=0,marginBottom:s=0,marginLeft:c=0,marginRight:u=0}=i.getSnapshot().documentStyle,{scene:p,mainComponent:g}=t.render;let{actualHeight:_,actualWidth:C}=n.getActualSize();_+=o+s,C+=c+u;const{width:f,height:I}=t.getBoundingClientRect(),h=p.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);let O=h==null?void 0:h.getScrollBar();const M=Math.max(C,f),y=Math.max(_,I);p.transformByState({width:M,height:y}),g==null||g.resize(M,y),t.isSingle()?C>f?O==null?h&&new m.ScrollBar(h,{barSize:8,enableVertical:!1}):h==null||h.resetSizeAndScrollBar():(O=null,h==null||h.scrollTo({x:0,y:0}),(N=h==null?void 0:h.getScrollBar())==null||N.dispose()):_>I?O==null?h&&new m.ScrollBar(h,{enableHorizontal:!1,barSize:8}):h==null||h.resetSizeAndScrollBar():(O=null,h==null||h.scrollTo({x:0,y:0}),(P=h==null?void 0:h.getScrollBar())==null||P.dispose())}_initialSetValue(){this.disposeWithMe(this._editorService.setValue$.subscribe(e=>{this._commandService.executeCommand(d.CoverContentCommand.id,{unitId:e.editorUnitId,body:e.body,segmentId:null})}))}_initialBlur(){this.disposeWithMe(this._editorService.blur$.subscribe(()=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.blur()})),this.disposeWithMe(this._textSelectionRenderManager.onBlur$.subscribe(()=>{var i;const e=(i=this._univerInstanceService.getCurrentUniverDocInstance())==null?void 0:i.getUnitId();if(e==null)return;const t=this._editorService.getEditor(e),n=this._editorService.getFocusEditor();t==null||t.isSheetEditor()||n&&n.editorUnitId===e||this._editorService.blur()}))}_initialFocus(){this.disposeWithMe(this._editorService.focus$.subscribe(n=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.addTextRanges([n])}));const e=["univer-formula-search","univer-formula-help","formula-help-decorator","univer-formula-help-param"];this.disposeWithMe(b.fromEvent(window,"mousedown").subscribe(n=>{const 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 i=n.getUnitId(),o=this._renderManagerService.getRenderById(i),s=o==null?void 0:o.engine.getCanvas().getCanvasEle();s!=null&&b.fromEvent(s,"mousedown").subscribe(c=>{this._editorService.changeSpreadsheetFocusState(!0),c.stopPropagation()})})}_initialValueChange(){this.disposeWithMe(this._textSelectionRenderManager.onCompositionupdate$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onInput$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onKeydown$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onPaste$.subscribe(this._valueChange.bind(this)))}_valueChange(){var n;const e=(n=this._univerInstanceService.getCurrentUniverDocInstance())==null?void 0:n.getUnitId();if(e==null)return;const t=this._editorService.getEditor(e);t==null||t.isSheetEditor()||this._editorService.refreshValueChange(e)}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id,l.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{unitId:i}=n;if(this._editorService.isSheetEditor(i))return;this._resize(i),this._valueChange()}}))}};Q=on([a.OnLifecycle(a.LifecycleStages.Rendered,Q),B(0,a.IUniverInstanceService),B(1,v.Inject(d.DocSkeletonManagerService)),B(2,l.IEditorService),B(3,a.ICommandService),B(4,m.ITextSelectionRenderManager),B(5,m.IRenderManagerService)],Q);var sn=Object.defineProperty,an=Object.getOwnPropertyDescriptor,cn=(r,e,t,n)=>{for(var i=n>1?void 0:n?an(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&sn(e,t,i),i},ee=(r,e)=>(t,n)=>e(t,n,r);let te=class extends a.RxDisposable{constructor(e,t,n,i){super();T(this,"_docRenderMap",new Set);this._docSkeletonManagerService=e,this._renderManagerService=t,this._commandService=n,this._editorService=i,this._initialRenderRefresh(),this._commandExecutedListener()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.pipe(b.takeUntil(this.dispose$)).subscribe(e=>{this._create(e)})}_create(e){if(e==null)return;const{skeleton:t,unitId:n}=e;let i=this._renderManagerService.getRenderById(n);i==null&&(this._renderManagerService.create(n),i=this._renderManagerService.getRenderById(n));const{mainComponent:o,components:s}=i,c=o,u=s.get(d.DOCS_VIEW_KEY.BACKGROUND);c.changeSkeleton(t),u.changeSkeleton(t),this._recalculateSizeBySkeleton(i,t)}_recalculateSizeBySkeleton(e,t){var C;const{mainComponent:n,scene:i,unitId:o,components:s}=e,c=n,u=s.get(d.DOCS_VIEW_KEY.BACKGROUND),p=(C=t.getSkeletonData())==null?void 0:C.pages;if(p==null)return;let g=0,_=0;for(let f=0,I=p.length;f<I;f++){const h=p[f],{pageWidth:O,pageHeight:M}=h;c.pageLayoutType===m.PageLayoutType.VERTICAL?(_+=M,_+=c.pageMarginTop,f===I-1&&(_+=c.pageMarginTop),g=Math.max(g,O)):c.pageLayoutType===m.PageLayoutType.HORIZONTAL&&(g+=O,f!==I-1&&(g+=c.pageMarginLeft),_=Math.max(_,M))}c.resize(g,_),u.resize(g,_),this._editorService.isEditor(o)||i.resize(g,_)}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const i=t.params,{unitId:o}=i,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)}}))}};te=cn([a.OnLifecycle(a.LifecycleStages.Rendered,te),ee(0,v.Inject(d.DocSkeletonManagerService)),ee(1,m.IRenderManagerService),ee(2,a.ICommandService),ee(3,l.IEditorService)],te);var ln=Object.defineProperty,dn=Object.getOwnPropertyDescriptor,un=(r,e,t,n)=>{for(var i=n>1?void 0:n?dn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&ln(e,t,i),i},ne=(r,e)=>(t,n)=>e(t,n,r);S.DocCanvasView=class extends a.RxDisposable{constructor(t,n,i,o){super();T(this,"_scene");T(this,"_currentDocumentModel");T(this,"_fps$",new b.BehaviorSubject(""));T(this,"fps$",this._fps$.asObservable());this._renderManagerService=t,this._configService=n,this._univerInstanceService=i,this._editorService=o,this._initialize()}_initialize(){this._renderManagerService.createRender$.pipe(b.takeUntil(this.dispose$)).subscribe(t=>{this._create(t)}),this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_DOC).pipe(b.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 i=this._renderManagerService.getRenderById(n);if(i==null)return;const{scene:o,engine:s}=i;o.openTransformer(),this._scene=o;const c=new m.Viewport(d.VIEWPORT_KEY.VIEW_MAIN,o,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});o.attachControl(),o.on(m.EVENT_TYPE.wheel,(g,_)=>{const C=g;if(C.ctrlKey){const f=Math.abs(C.deltaX);let I=f<40?.2:f<80?.4:.2;I*=C.deltaY>0?-1:1,o.scaleX<1&&(I/=2),o.scaleX+I>4?o.scale(4,4):o.scaleX+I<.1?o.scale(.1,.1):C.preventDefault()}else c.onMouseWheel(C,_)}),this._configService.getConfig("hasScroll")!==!1&&new m.ScrollBar(c),o.addLayer(new m.Layer(o,[],d.DOCS_COMPONENT_MAIN_LAYER_INDEX),new m.Layer(o,[],d.DOCS_COMPONENT_HEADER_LAYER_INDEX)),this._addComponent(i),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,i=this._currentDocumentModel,o={pageMarginLeft:i.documentStyle.marginLeft||0,pageMarginTop:i.documentStyle.marginTop||0},s=new m.Documents(d.DOCS_VIEW_KEY.MAIN,void 0,o),c=new m.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(i.getUnitId())==null&&n.enableLayerCache(d.DOCS_COMPONENT_MAIN_LAYER_INDEX)}},S.DocCanvasView=un([a.OnLifecycle(a.LifecycleStages.Starting,S.DocCanvasView),ne(0,m.IRenderManagerService),ne(1,a.IConfigService),ne(2,a.IUniverInstanceService),ne(3,l.IEditorService)],S.DocCanvasView);var hn=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,gn=(r,e,t,n)=>{for(var i=n>1?void 0:n?pn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&hn(e,t,i),i},F=(r,e)=>(t,n)=>e(t,n,r);let ie=class extends a.Disposable{constructor(e,t,n,i,o,s){super();T(this,"_liquid",new m.Liquid);T(this,"_pageMarginCache",new Map);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._renderManagerService=n,this._commandService=i,this._floatingObjectManagerService=o,this._editorService=s,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh(),this._updateOnPluginChange()}_updateOnPluginChange(){this._floatingObjectManagerService.pluginUpdate$.subscribe(e=>{const t=this._docSkeletonManagerService.getCurrent();if(t==null)return;const{unitId:n,skeleton:i}=t,o=this._renderManagerService.getRenderById(n);if(o==null)return;const{mainComponent:s,components:c,scene:u}=o,p=s,{left:g,top:_}=p;e.forEach(C=>{const{unitId:f,subUnitId:I,floatingObjectId:h,floatingObject:O}=C,{left:M=0,top:y=0,width:D=0,height:P=0,angle:N,flipX:w,flipY:j,skewX:le,skewY:de}=O,R=this._pageMarginCache.get(h),ue=(R==null?void 0:R.marginLeft)||0,ve=(R==null?void 0:R.marginTop)||0;i==null||i.getViewModel().getDataModel().updateDrawing(h,{left:M-g-ue,top:y-_-ve,height:P,width:D})}),i==null||i.calculate(),s==null||s.makeDirty()})}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{skeleton:t,unitId:n}=e,i=this._renderManagerService.getRenderById(n);if(i==null)return;const{mainComponent:o}=i;o.changeSkeleton(t),this._refreshFloatingObject(n,t,i)})}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id,d.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const i=t.params,{unitId:o}=i,s=this._docSkeletonManagerService.getCurrent();if(s==null)return;const{unitId:c,skeleton:u}=s;if(o!==c)return;const p=this._renderManagerService.getRenderById(c);if(p==null)return;if(this._editorService.isEditor(c)){(n=p.mainComponent)==null||n.makeDirty();return}this._refreshFloatingObject(c,u,p)}}))}_refreshFloatingObject(e,t,n){const i=t==null?void 0:t.getSkeletonData(),{mainComponent:o,scene:s}=n,c=o;if(!i)return;const{left:u,top:p,pageLayoutType:g,pageMarginLeft:_,pageMarginTop:C}=c,{pages:f}=i,I=[];s.getAncestorScale(),this._liquid.reset(),this._pageMarginCache.clear();for(let h=0,O=f.length;h<O;h++){const M=f[h],{skeDrawings:y,marginLeft:D,marginTop:P}=M;this._liquid.translatePagePadding(M),y.forEach(N=>{const{aLeft:w,aTop:j,height:le,width:de,objectId:R,drawingOrigin:ue}=N,ve=ue.layoutType===a.PositionedObjectLayoutType.WRAP_NONE&&ue.behindDoc===a.BooleanNumber.TRUE;I.push({unitId:e,subUnitId:a.DEFAULT_DOCUMENT_SUB_COMPONENT_ID,floatingObjectId:R,behindText:ve,floatingObject:{left:w+u+this._liquid.x,top:j+p+this._liquid.y,width:de,height:le}}),this._pageMarginCache.set(R,{marginLeft:this._liquid.x,marginTop:this._liquid.y})}),this._liquid.restorePagePadding(M),this._liquid.translatePage(M,g,_,C)}this._floatingObjectManagerService.batchAddOrUpdate(I)}};ie=gn([a.OnLifecycle(a.LifecycleStages.Steady,ie),F(0,v.Inject(d.DocSkeletonManagerService)),F(1,a.IUniverInstanceService),F(2,m.IRenderManagerService),F(3,a.ICommandService),F(4,a.IFloatingObjectManagerService),F(5,l.IEditorService)],ie);var _n=Object.defineProperty,Sn=Object.getOwnPropertyDescriptor,fn=(r,e,t,n)=>{for(var i=n>1?void 0:n?Sn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&_n(e,t,i),i},$=(r,e)=>(t,n)=>e(t,n,r);let re=class extends a.Disposable{constructor(e,t,n,i,o,s){super();T(this,"_initializedRender",new Set);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._commandService=n,this._renderManagerService=i,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:i}=n;this.disposeWithMe(a.toDisposable(i.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,i.scaleX<1&&(u/=2);const p=s.zoomRatio;let g=+Number.parseFloat(`${p+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 i=t.params,{unitId:o}=i;if(o!==n.getUnitId())return;const s=n.zoomRatio||1;this._updateViewZoom(s)}}))}_updateViewZoom(e,t=!0){var i;const n=this._getDocObject();n!=null&&(n.scene.scale(e,e),this._calculatePagePosition(n,e),t&&this._textSelectionManagerService.refreshSelection(),(i=n.scene.getTransformer())==null||i.hideControl())}_calculatePagePosition(e,t){const{document:n,scene:i,docBackground:o}=e,s=i==null?void 0:i.getParent(),{width:c,height:u,pageMarginLeft:p,pageMarginTop:g}=n;if(s==null||c===Number.POSITIVE_INFINITY||u===Number.POSITIVE_INFINITY)return;const{width:_,height:C}=s;let f=0,I=0,h=0,O=0,M=Number.POSITIVE_INFINITY;_>(c+p*2)*t?(f=_/2-c*t/2,f/=t,h=(_-p*2)/t,M=0):(f=p,h=c+p*2,M=(h-_/t)/2),C>u?(I=C/2-u/2,O=(C-g*2)/t):(I=g,O=u+g*2),i.resize(h,O+200),n.translate(f,I),o.translate(f,I);const y=i.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);if(M!==Number.POSITIVE_INFINITY&&y!=null){const D=y.getBarScroll(M,0).x;y.scrollTo({x:D})}return this}_getDocObject(){return d.getDocObject(this._univerInstanceService,this._renderManagerService)}};re=fn([a.OnLifecycle(a.LifecycleStages.Rendered,re),$(0,v.Inject(d.DocSkeletonManagerService)),$(1,a.IUniverInstanceService),$(2,a.ICommandService),$(3,m.IRenderManagerService),$(4,v.Inject(d.TextSelectionManagerService)),$(5,l.IEditorService)],re);var mn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,Cn=(r,e,t,n)=>{for(var i=n>1?void 0:n?vn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&mn(e,t,i),i},L=(r,e)=>(t,n)=>e(t,n,r);let oe=class extends a.Disposable{constructor(e,t,n,i,o,s,c){super();T(this,"_loadedMap",new WeakSet);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._commandService=n,this._renderManagerService=i,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:i}=t;this.disposeWithMe(a.toDisposable(n.onPointerEnterObserver.add(()=>{this._isEditorReadOnly(e)||(n.cursor=m.CURSOR_TYPE.TEXT)}))),this.disposeWithMe(a.toDisposable(n.onPointerLeaveObserver.add(()=>{n.cursor=m.CURSOR_TYPE.DEFAULT,i.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:p}=o;this._editorService.getEditor(e)&&(this._setEditorFocus(e),setTimeout(()=>{this._setEditorFocus(e),this._textSelectionRenderManager.setCursorManually(u,p)},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 i=t.params,{unitId:o}=i,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,i=this._renderManagerService.getRenderById(t);if(i==null)return;const{scene:o,mainComponent:s}=i;this._textSelectionRenderManager.changeRuntime(n,o,s),this._textSelectionManagerService.setCurrentSelectionNotRefresh({unitId:t,subUnitId:""})}))}_getDocObjectById(e){return this._univerInstanceService.getUnitType(e)!==a.UniverInstanceType.UNIVER_DOC?null:d.getDocObjectById(e,this._renderManagerService)}};oe=Cn([a.OnLifecycle(a.LifecycleStages.Rendered,oe),L(0,v.Inject(d.DocSkeletonManagerService)),L(1,a.IUniverInstanceService),L(2,a.ICommandService),L(3,m.IRenderManagerService),L(4,m.ITextSelectionRenderManager),L(5,v.Inject(d.TextSelectionManagerService)),L(6,l.IEditorService)],oe);var In=Object.defineProperty,On=Object.getOwnPropertyDescriptor,Tn=(r,e,t,n)=>{for(var i=n>1?void 0:n?On(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&In(e,t,i),i},z=(r,e)=>(t,n)=>e(t,n,r);const we=1.5;let se=class extends a.RxDisposable{constructor(r,e,t,n,i){super(),this._docSkeletonManagerService=r,this._textSelectionManagerService=e,this._editorService=t,this._univerInstanceService=n,this._renderManagerService=i,this._init()}_init(){this._textSelectionManagerService.textSelection$.pipe(b.takeUntil(this.dispose$)).subscribe(r=>{if(r==null)return;const{isEditing:e,unitId:t}=r;e&&this._scrollToSelection(t)})}_scrollToSelection(r){var R;const e=this._textSelectionManagerService.getActiveRange(),t=this._getDocObject(),n=(R=this._docSkeletonManagerService.getCurrent())==null?void 0:R.skeleton;if(e==null||t==null||n==null)return;const{collapsed:i,startNodePosition:o}=e;if(!i)return;const s=t.document.getOffsetConfig(),{docsLeft:c,docsTop:u}=s,p=new m.NodePositionConvertToCursor(s,n),{contentBoxPointGroup:g}=p.getRangePointData(o,o),{left:_,top:C,height:f}=m.getAnchorBounding(g),I=_+c,h=C+u,O=t.scene.getViewport(d.VIEWPORT_KEY.VIEW_MAIN),M=!!this._editorService.getEditor(r);if(O==null)return;const{left:y,top:D,right:P,bottom:N}=O.getBounding().viewBound;let w=0,j=0;const le=M?0:100;h<D?w=h-D:h>N-f&&(w=h-N+f+le),I<y?j=I-y:I>P-we&&(j=I-P+we);const de=O.getBarScroll(j,w);O.scrollBy(de)}_getDocObject(){return d.getDocObject(this._univerInstanceService,this._renderManagerService)}};se=Tn([a.OnLifecycle(a.LifecycleStages.Rendered,se),z(0,v.Inject(d.DocSkeletonManagerService)),z(1,v.Inject(d.TextSelectionManagerService)),z(2,l.IEditorService),z(3,a.IUniverInstanceService),z(4,m.IRenderManagerService)],se);var bn=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,yn=(r,e,t,n)=>{for(var i=n>1?void 0:n?Mn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&bn(e,t,i),i},me=(r,e)=>(t,n)=>e(t,n,r);S.UniverDocsUIPlugin=(ce=class extends a.Plugin{constructor(e,t,n,i){super(),this._config=e,this._injector=t,this._localeService=n,this._logService=i,this._localeService.load({zhCN:Ue}),this._config=a.Tools.deepMerge({},Oe,this._config),this._initDependencies(t),this._initializeCommands()}onRendered(){this._initModules(),this._markDocAsFocused()}_initializeCommands(){[He,ze,Ge,Ye,Ke,Xe,qe,Ze,Je,Ft,$t,Bt].forEach(e=>{this._injector.get(l.IShortcutService).registerShortcut(e)})}_initDependencies(e){[[q],[J],[Q],[te],[ie],[re],[oe],[se],[V,{useFactory:()=>this._injector.createInstance(V,this._config)}],[k,{useClass:Se}],[S.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 i=n.getUnitId();t.isEditor(i)||e.focusUnit(n.getUnitId())}catch(n){this._logService.warn(n)}}_initModules(){this._injector.get(V)}},T(ce,"pluginName",Te),T(ce,"type",a.UniverInstanceType.UNIVER_DOC),ce),S.UniverDocsUIPlugin=yn([me(1,v.Inject(v.Injector)),me(2,v.Inject(a.LocaleService)),me(3,a.ILogService)],S.UniverDocsUIPlugin),S.DOC_UI_PLUGIN_NAME=Te,S.DefaultDocContainerConfig=Ie,S.DefaultDocUiConfig=Oe,S.DefaultToolbarConfig=Ce,S.PastePluginLark=xe,S.PastePluginUniver=Be,S.PastePluginWord=Ae,S.enUS=Lt,S.ruRU=At,S.zhCN=Ue,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var ot=Ve,st=Symbol.for("react.element"),at=Symbol.for("react.fragment"),ct=Object.prototype.hasOwnProperty,lt=ot.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,dt={key:!0,ref:!0,__self:!0,__source:!0};function De(r,e,t){var n,i={},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)ct.call(e,n)&&!dt.hasOwnProperty(n)&&(i[n]=e[n]);if(r&&r.defaultProps)for(n in e=r.defaultProps,e)i[n]===void 0&&(i[n]=e[n]);return{$$typeof:st,type:r,key:o,ref:s,props:i,_owner:lt.current}}X.Fragment=at,X.jsx=De,X.jsxs=De,Ee.exports=X;var ut=Ee.exports;const ht={docsUiCanvasBackground:"univer-docs-ui-canvas-background"},gt=()=>ut.jsx("div",{className:ht.docsUiCanvasBackground});function pt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function _t(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function St(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function ft(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function mt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function vt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=U(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Ct(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,label:Me,positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_FAMILY_LIST.map(t=>({label:{name:ye,hoverable:!0},value:t.value})),value$:new b.Observable(t=>{const n=l.FONT_FAMILY_LIST[0].value,i=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatFontFamilyCommand.id){const u=U(r);if(u==null)return;const g=(c=u.ts)==null?void 0:c.ff;t.next(g!=null?g:n)}});return t.next(n),i.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function It(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatFontSizeCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Re,props:{min:1,max:400}},positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_SIZE_LIST,value$:new b.Observable(t=>{const i=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatFontSizeCommand.id){const u=U(r);if(u==null)return;const g=(c=u.ts)==null?void 0:c.fs;t.next(g!=null?g:14)}});return t.next(14),i.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function Ot(r){const e=r.get(a.ICommandService),t=r.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:ge,hoverable:!1}}],value$:new b.Observable(n=>{const i=t.getCurrentTheme().textColor,o=e.onCommandExecuted(s=>{if(s.id===d.SetInlineFormatTextColorCommand.id){const c=s.params.value;n.next(c!=null?c:i)}});return n.next(i),o.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function Tt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=q(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function bt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=q(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Mt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=q(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function yt(r){const e=r.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 b.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.AlignOperationCommand.id){const c=q(r);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(r,a.UniverInstanceType.UNIVER_DOC)}}function Rt(r){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(r,a.UniverInstanceType.UNIVER_DOC)}}function Et(r){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(r,a.UniverInstanceType.UNIVER_DOC)}}function Dt(r){return{id:d.ResetInlineFormatTextBackgroundColorCommand.id,type:l.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:d.SetInlineFormatTextBackgroundColorCommand.id}}function Ut(r){const e=r.get(a.ICommandService),t=r.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:ge,hoverable:!1}}],value$:new b.Observable(n=>{const i=t.getCurrentTheme().primaryColor,o=e.onCommandExecuted(s=>{if(s.id===d.SetInlineFormatTextBackgroundColorCommand.id){const c=s.params.value;n.next(c!=null?c:i)}});return n.next(i),o.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_DOC)}}function U(r){var u;const e=r.get(a.IUniverInstanceService),t=r.get(d.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),i=t.getActiveRange();if(n==null||i==null)return;const o=(u=n.getBody())==null?void 0:u.textRuns;if(o==null)return;const{startOffset:s}=i;return o.find(({st:g,ed:p})=>s>=g&&s<p)}function q(r){var u;const e=r.get(a.IUniverInstanceService),t=r.get(d.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),i=t.getActiveRange();if(n==null||i==null)return;const o=(u=n.getBody())==null?void 0:u.paragraphs;if(o==null)return;const{startOffset:s}=i;let c=-1;for(const g of o){const{startIndex:p}=g;if(s>c&&s<=p)return g;c=p}return null}var Pt=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,xt=(r,e,t,n)=>{for(var i=n>1?void 0:n?Nt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Pt(e,t,i),i},x=(r,e)=>(t,n)=>e(t,n,r);let W=class extends a.Disposable{constructor(r,e,t,n,i,o,s,c){super(),this._config=r,this._injector=e,this._componentManager=t,this._layoutService=n,this._editorService=i,this._menuService=o,this._uiPartsService=s,this._univerInstanceService=c,this._init()}_initCustomComponents(){const r=this._componentManager;this.disposeWithMe(r.register(ge,We.ColorPicker)),this.disposeWithMe(r.register(Me,l.FontFamily)),this.disposeWithMe(r.register(ye,l.FontFamilyItem)),this.disposeWithMe(r.register(Re,l.FontSize))}_initMenus(){const{menu:r={}}=this._config;[pt,_t,St,ft,mt,vt,It,Ct,Ot,Tt,bt,Mt,yt,Rt,Et,Dt,Ut].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e),r))})}_init(){this._initCustomComponents(),this._initMenus(),this._initDocBackground(),this._initFocusHandler()}_initDocBackground(){const r=this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_DOC)[0].getUnitId();if(r==null)return;this._editorService.isEditor(r)||this.disposeWithMe(this._uiPartsService.registerComponent(l.BuiltInUIPart.CONTENT,()=>je.connectInjector(gt,this._injector)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(a.UniverInstanceType.UNIVER_DOC,()=>{this._injector.get(m.ITextSelectionRenderManager).focus()}))}};W=xt([a.OnLifecycle(a.LifecycleStages.Rendered,W),x(1,v.Inject(v.Injector)),x(2,v.Inject(l.ComponentManager)),x(3,l.ILayoutService),x(4,l.IEditorService),x(5,l.IMenuService),x(6,l.IUIPartsService),x(7,a.IUniverInstanceService)],W);const Lt={toolbar:{undo:"Undo",redo:"Redo",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},fillColor:{main:"Text Background color",right:"Choose color"},resetColor:"Reset",order:"Ordered list",unorder:"Unordered list",alignLeft:"Align Left",alignCenter:"Align Center",alignRight:"Align Right",alignJustify:"Justify"}},Ue={toolbar:{undo:"撤销",redo:"重做",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},fillColor:{main:"文本背景色",right:"背景色选择"},resetColor:"重置颜色",order:"有序列表",unorder:"无序列表",alignLeft:"左对齐",alignCenter:"居中对齐",alignRight:"右对齐",alignJustify:"两端对齐"}},At={toolbar:{undo:"Отменить",redo:"Повторить",font:"Шрифт",fontSize:"Размер шрифта",bold:"Полужирный",italic:"Курсив",strikethrough:"Зачеркнутый",subscript:"Нижний индекс",superscript:"Верхний индекс",underline:"Подчеркнутый",textColor:{main:"Цвет текста",right:"Выбрать цвет"},fillColor:{main:"Цвет фона текста",right:"Выбрать цвет"},resetColor:"Сбросить",order:"Упорядоченный список",unorder:"Неупорядоченный список",alignLeft:"Выровнять по левому краю",alignCenter:"Выровнять по центру",alignRight:"Выровнять по правому краю",alignJustify:"Выровнять по ширине"}},Bt={id:d.BreakLineCommand.id,preconditions:ke,binding:l.KeyCode.ENTER},Ft={id:d.DeleteLeftCommand.id,preconditions:E,binding:l.KeyCode.BACKSPACE},$t={id:d.DeleteRightCommand.id,preconditions:E,binding:l.KeyCode.DELETE},wt=10,jt=6;function Vt(){return a.Tools.generateRandomId(jt)}function Wt(r){const e=r.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class kt{constructor(){T(this,"_cache",new a.LRUMap(wt))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}clear(){this._cache.clear()}}const Pe=new kt;function pe(r){const e=r.style,t={},n=r.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 i=0;i<e.length;i++){const o=e[i],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=m.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 Ht(r){const e=new DOMParser,t=`<x-univer id="univer-root">${r}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function Ne(r,e){const t=r.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(r)}const ae=class ae{constructor(){T(this,"_styleCache",new Map);T(this,"_styleRules",[]);T(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=ae._pluginList.find(o=>o.checkPasteType(e)),n=Ht(e),i={dataStream:"",textRuns:[]};return t&&(this._styleRules=[...t.stylesRules],this._afterProcessRules=[...t.afterProcessRules]),this._styleCache.clear(),this._process(null,n==null?void 0:n.childNodes,i),this._styleCache.clear(),this._styleRules=[],this._afterProcessRules=[],i}_process(e,t,n){var i;for(const o of t)if(o.nodeType===Node.TEXT_NODE){const s=(i=o.nodeValue)==null?void 0:i.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:_})=>Ne(o,_)),u=c?c.getStyle(o):pe(o);this._styleCache.set(o,{...s,...u});const{childNodes:g}=o;this._process(o,g,n);const p=this._afterProcessRules.find(({filter:_})=>Ne(o,_));p&&p.handler(n,o)}}};T(ae,"_pluginList",[]);let A=ae;const xe={name:"univer-doc-paste-plugin-lark",checkPasteType(r){return/lark-record-clipboard/i.test(r)},stylesRules:[{filter:["s"],getStyle(r){const e=pe(r);return{st:{s:a.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(r){return r.tagName==="DIV"&&/ace-line/i.test(r.className)},handler(r){r.paragraphs==null&&(r.paragraphs=[]),r.paragraphs.push({startIndex:r.dataStream.length}),r.dataStream+="\r"}}]};function Le(r){const e=r.style,t={};for(let n=0;n<e.length;n++){const i=e[n],o=e.getPropertyValue(i);switch(i){case"margin-top":{const s=Number.parseInt(o);t.spaceAbove=/pt/.test(o)?m.ptToPixel(s):s;break}case"margin-bottom":{const s=Number.parseInt(o);t.spaceBelow=/pt/.test(o)?m.ptToPixel(s):s;break}case"line-height":{const s=Number.parseFloat(o);t.lineSpacing=s;break}}}return Object.getOwnPropertyNames(t).length?t:null}const Ae={name:"univer-doc-paste-plugin-word",checkPasteType(r){return/word|mso/i.test(r)},stylesRules:[{filter:["b"],getStyle(r){const e=pe(r);return{bl:a.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(r){return r.tagName==="P"&&/mso/i.test(r.className)},handler(r,e){r.paragraphs==null&&(r.paragraphs=[]);const t={startIndex:r.dataStream.length},n=Le(e);n&&(t.paragraphStyle=n),r.paragraphs.push(t),r.dataStream+="\r"}}]},Be={name:"univer-doc-paste-plugin-univer",checkPasteType(r){return/UniverNormal/i.test(r)},stylesRules:[],afterProcessRules:[{filter(r){return r.tagName==="P"&&/UniverNormal/i.test(r.className)},handler(r,e){r.paragraphs==null&&(r.paragraphs=[]);const t={startIndex:r.dataStream.length},n=Le(e);n&&(t.paragraphStyle=n),r.paragraphs.push(t),r.dataStream+="\r"}}]};function Fe(r,e){const{st:t,ed:n,ts:i={}}=e,{ff:o,fs:s,it:c,bl:u,ul:g,st:p,ol:_,bg:C,cl:f,va:I}=i;let h=r.slice(t,n);const O=[];return c===a.BooleanNumber.TRUE&&(h=`<i>${h}</i>`),I===a.BaselineOffset.SUPERSCRIPT?h=`<sup>${h}</sup>`:I===a.BaselineOffset.SUBSCRIPT&&(h=`<sub>${h}</sub>`),(g==null?void 0:g.s)===a.BooleanNumber.TRUE&&(h=`<u>${h}</u>`),(p==null?void 0:p.s)===a.BooleanNumber.TRUE&&(h=`<s>${h}</s>`),u===a.BooleanNumber.TRUE&&(h=`<strong>${h}</strong>`),o&&O.push(`font-family: ${o}`),f&&O.push(`color: ${f.rgb}`),s&&O.push(`font-size: ${s}pt`),_&&O.push("text-decoration: overline"),C&&O.push(`background: ${C.rgb}`),O.length?`<span style="${O.join("; ")};">${h}</span>`:h}function _e(r,e,t){const{dataStream:n,textRuns:i=[]}=r;let o=e;const s=[];for(const c of i){const{st:u,ed:g}=c;a.Tools.hasIntersectionBetweenTwoRanges(e,t,u,g)&&(u>o?(s.push(n.slice(o,u)),s.push(Fe(n,{...c,ed:Math.min(g,t)}))):s.push(Fe(n,{...c,st:o,ed:Math.min(g,t)}))),o=Math.max(e,Math.min(g,t))}return o!==t&&s.push(n.slice(o,t)),s.join("")}function $e(r,e=!0){var t;if(e&&((t=r.paragraphs)!=null&&t.length)){const{dataStream:n,paragraphs:i=[]}=r;let o="",s=-1;for(const c of i){const{startIndex:u,paragraphStyle:g={}}=c,{spaceAbove:p,spaceBelow:_,lineSpacing:C}=g,f=[];p!=null&&(typeof p=="number"?f.push(`margin-top: ${p}px`):f.push(`margin-top: ${p.v}px`)),_!=null&&(typeof _=="number"?f.push(`margin-bottom: ${_}px`):f.push(`margin-bottom: ${_.v}px`)),C!=null&&f.push(`line-height: ${C}`),u>s+1?o+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}>${_e(r,s+1,u)}</p>`:o+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}></p>`,s=u}return s!==n.length&&(o+=_e(r,s,n.length)),o}else return _e(r,0,r.dataStream.length)}class zt{convert(e){if(e.length===0)throw new Error("The bodyList length at least to be 1");if(e.length===1)return $e(e[0]);let t="";for(const n of e)t+='<p className="UniverNormal">',t+=$e(n,!1),t+="</p>";return t}}var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Kt=(r,e,t,n)=>{for(var i=n>1?void 0:n?Gt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Yt(e,t,i),i},k=(r,e)=>(t,n)=>e(t,n,r);A.use(Ae),A.use(xe),A.use(Be);function Xt(r){const e=r.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 H=v.createIdentifier("doc.clipboard-service");let Se=class extends a.Disposable{constructor(e,t,n,i,o){super();T(this,"_clipboardHooks",[]);T(this,"_htmlToUDM",new A);T(this,"_umdToHtml",new zt);this._univerInstanceService=e,this._logService=t,this._commandService=n,this._clipboardInterfaceService=i,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:{},i=this._textSelectionManagerService.getSelections();if(e==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),t==null||i==null)return!1;this.copy();try{let s=t;for(const u of i){const{startOffset:g,endOffset:p}=u;g==null||p==null||p<=t&&(s-=p-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){var s;const{segmentId:t,endOffset:n,style:i}=(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 g of o){const{startOffset:p,endOffset:_}=g;p==null||_==null||_<=n&&(c+=e.dataStream.length-(_-p))}const u=[{startOffset:c,endOffset:c,style:i}];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=Vt(),n=e.length>1?e.map(o=>o.dataStream).join(`
|
|
10
|
+
`):e[0].dataStream;let i=this._umdToHtml.convert(e);return e.length===1&&(i=i.replace(/(<[a-z]+)/,(o,s)=>`${s} data-copy-id="${t}"`),Pe.set(t,e[0])),this._clipboardInterfaceService.write(n,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._univerInstanceService.getCurrentUniverDocInstance(),n=[];if(e==null||!t)return n;for(const i of e){const{startOffset:o,endOffset:s,collapsed:c}=i;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 i of e)for(const o of i.types)o===l.PLAIN_TEXT_CLIPBOARD_MIME_TYPE?n=await i.getType(o).then(s=>s&&s.text()):o===l.HTML_CLIPBOARD_MIME_TYPE&&(t=await i.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 Xt(t);throw new Error("[DocClipboardService] html and text cannot be both empty!")}const n=Wt(e);if(n){const i=Pe.get(n);if(i)return i}return this._htmlToUDM.convert(e)}};Se=Kt([k(0,a.IUniverInstanceService),k(1,a.ILogService),k(2,a.ICommandService),k(3,l.IClipboardInterfaceService),k(4,v.Inject(d.TextSelectionManagerService))],Se);function Z(r){return r.getContextValue(a.FOCUSING_DOC)||r.getContextValue(a.EDITOR_ACTIVATED)}const fe=999,qt={id:l.CopyCommand.id,name:"doc.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:Z,handler:async r=>r.get(H).copy()},Zt={id:l.CutCommand.id,name:"doc.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:Z,handler:async r=>r.get(H).cut()},Jt={id:l.PasteCommand.id,name:"doc.command.paste",type:a.CommandType.COMMAND,multi:!0,priority:fe,preconditions:Z,handler:async r=>{const e=r.get(H),n=await r.get(l.IClipboardInterfaceService).read();return n.length===0?!1:e.paste(n)}};var Qt=Object.defineProperty,en=Object.getOwnPropertyDescriptor,tn=(r,e,t,n)=>{for(var i=n>1?void 0:n?en(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Qt(e,t,i),i},z=(r,e)=>(t,n)=>e(t,n,r);let J=class extends a.RxDisposable{constructor(r,e,t,n,i){super(),this._commandService=r,this._clipboardInterfaceService=e,this._docClipboardService=t,this._textSelectionRenderManager=n,this._contextService=i,this._init()}_init(){[qt,Zt,Jt].forEach(r=>this.disposeWithMe(this._commandService.registerMultipleCommand(r))),[d.InnerPasteCommand,d.CutContentCommand].forEach(r=>this.disposeWithMe(this._commandService.registerCommand(r))),this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var r;(r=this._textSelectionRenderManager)==null||r.onPaste$.pipe(b.takeUntil(this.dispose$)).subscribe(e=>{var o,s;if(!Z(this._contextService))return;e.event.preventDefault();const t=e.event,n=(o=t.clipboardData)==null?void 0:o.getData("text/html"),i=(s=t.clipboardData)==null?void 0:s.getData("text/plain");this._docClipboardService.legacyPaste(n,i)})}};J=tn([a.OnLifecycle(a.LifecycleStages.Rendered,J),z(0,a.ICommandService),z(1,l.IClipboardInterfaceService),z(2,H),z(3,m.ITextSelectionRenderManager),z(4,a.IContextService)],J);var nn=Object.defineProperty,rn=Object.getOwnPropertyDescriptor,on=(r,e,t,n)=>{for(var i=n>1?void 0:n?rn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&nn(e,t,i),i},B=(r,e)=>(t,n)=>e(t,n,r);let Q=class extends a.Disposable{constructor(e,t,n,i,o,s){super();T(this,"_initialEditors",new Set);this._univerInstanceService=e,this._docSkeletonManagerService=t,this._editorService=n,this._commandService=i,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 D,P,N;if(e==null)return;const t=this._editorService.getEditor(e);if((t==null?void 0:t.cancelDefaultResizeListener)===!0)return;const n=(D=this._docSkeletonManagerService.getSkeletonByUnitId(e))==null?void 0:D.skeleton,i=this._univerInstanceService.getUniverDocInstance(e);if(t==null||t.render==null||n==null||i==null)return;n.calculate();const{marginTop:o=0,marginBottom:s=0,marginLeft:c=0,marginRight:u=0}=i.getSnapshot().documentStyle,{scene:g,mainComponent:p}=t.render;let{actualHeight:_,actualWidth:C}=n.getActualSize();_+=o+s,C+=c+u;const{width:f,height:I}=t.getBoundingClientRect(),h=g.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);let O=h==null?void 0:h.getScrollBar();const M=Math.max(C,f),y=Math.max(_,I);g.transformByState({width:M,height:y}),p==null||p.resize(M,y),t.isSingle()?C>f?O==null?h&&new m.ScrollBar(h,{barSize:8,enableVertical:!1}):h==null||h.resetSizeAndScrollBar():(O=null,h==null||h.scrollTo({x:0,y:0}),(N=h==null?void 0:h.getScrollBar())==null||N.dispose()):_>I?O==null?h&&new m.ScrollBar(h,{enableHorizontal:!1,barSize:8}):h==null||h.resetSizeAndScrollBar():(O=null,h==null||h.scrollTo({x:0,y:0}),(P=h==null?void 0:h.getScrollBar())==null||P.dispose())}_initialSetValue(){this.disposeWithMe(this._editorService.setValue$.subscribe(e=>{this._commandService.executeCommand(d.CoverContentCommand.id,{unitId:e.editorUnitId,body:e.body,segmentId:null})}))}_initialBlur(){this.disposeWithMe(this._editorService.blur$.subscribe(()=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.blur()})),this.disposeWithMe(this._textSelectionRenderManager.onBlur$.subscribe(()=>{var i;const e=(i=this._univerInstanceService.getCurrentUniverDocInstance())==null?void 0:i.getUnitId();if(e==null)return;const t=this._editorService.getEditor(e),n=this._editorService.getFocusEditor();t==null||t.isSheetEditor()||n&&n.editorUnitId===e||this._editorService.blur()}))}_initialFocus(){this.disposeWithMe(this._editorService.focus$.subscribe(n=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.addTextRanges([n])}));const e=["univer-formula-search","univer-formula-help","formula-help-decorator","univer-formula-help-param"];this.disposeWithMe(b.fromEvent(window,"mousedown").subscribe(n=>{const 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 i=n.getUnitId(),o=this._renderManagerService.getRenderById(i),s=o==null?void 0:o.engine.getCanvas().getCanvasEle();s!=null&&b.fromEvent(s,"mousedown").subscribe(c=>{this._editorService.changeSpreadsheetFocusState(!0),c.stopPropagation()})})}_initialValueChange(){this.disposeWithMe(this._textSelectionRenderManager.onCompositionupdate$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onInput$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onKeydown$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onPaste$.subscribe(this._valueChange.bind(this)))}_valueChange(){var n;const e=(n=this._univerInstanceService.getCurrentUniverDocInstance())==null?void 0:n.getUnitId();if(e==null)return;const t=this._editorService.getEditor(e);t==null||t.isSheetEditor()||this._editorService.refreshValueChange(e)}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id,l.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{unitId:i}=n;if(this._editorService.isSheetEditor(i))return;this._resize(i),this._valueChange()}}))}};Q=on([a.OnLifecycle(a.LifecycleStages.Rendered,Q),B(0,a.IUniverInstanceService),B(1,v.Inject(d.DocSkeletonManagerService)),B(2,l.IEditorService),B(3,a.ICommandService),B(4,m.ITextSelectionRenderManager),B(5,m.IRenderManagerService)],Q);var sn=Object.defineProperty,an=Object.getOwnPropertyDescriptor,cn=(r,e,t,n)=>{for(var i=n>1?void 0:n?an(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&sn(e,t,i),i},ee=(r,e)=>(t,n)=>e(t,n,r);let te=class extends a.RxDisposable{constructor(e,t,n,i){super();T(this,"_docRenderMap",new Set);this._docSkeletonManagerService=e,this._renderManagerService=t,this._commandService=n,this._editorService=i,this._initialRenderRefresh(),this._commandExecutedListener()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.pipe(b.takeUntil(this.dispose$)).subscribe(e=>{this._create(e)})}_create(e){if(e==null)return;const{skeleton:t,unitId:n}=e;let i=this._renderManagerService.getRenderById(n);i==null&&(this._renderManagerService.create(n),i=this._renderManagerService.getRenderById(n));const{mainComponent:o,components:s}=i,c=o,u=s.get(d.DOCS_VIEW_KEY.BACKGROUND);c.changeSkeleton(t),u.changeSkeleton(t),this._recalculateSizeBySkeleton(i,t)}_recalculateSizeBySkeleton(e,t){var C;const{mainComponent:n,scene:i,unitId:o,components:s}=e,c=n,u=s.get(d.DOCS_VIEW_KEY.BACKGROUND),g=(C=t.getSkeletonData())==null?void 0:C.pages;if(g==null)return;let p=0,_=0;for(let f=0,I=g.length;f<I;f++){const h=g[f],{pageWidth:O,pageHeight:M}=h;c.pageLayoutType===m.PageLayoutType.VERTICAL?(_+=M,_+=c.pageMarginTop,f===I-1&&(_+=c.pageMarginTop),p=Math.max(p,O)):c.pageLayoutType===m.PageLayoutType.HORIZONTAL&&(p+=O,f!==I-1&&(p+=c.pageMarginLeft),_=Math.max(_,M))}c.resize(p,_),u.resize(p,_),this._editorService.isEditor(o)||i.resize(p,_)}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const i=t.params,{unitId:o}=i,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)}}))}};te=cn([a.OnLifecycle(a.LifecycleStages.Rendered,te),ee(0,v.Inject(d.DocSkeletonManagerService)),ee(1,m.IRenderManagerService),ee(2,a.ICommandService),ee(3,l.IEditorService)],te);var ln=Object.defineProperty,dn=Object.getOwnPropertyDescriptor,un=(r,e,t,n)=>{for(var i=n>1?void 0:n?dn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&ln(e,t,i),i},ne=(r,e)=>(t,n)=>e(t,n,r);S.DocCanvasView=class extends a.RxDisposable{constructor(t,n,i,o){super();T(this,"_scene");T(this,"_currentDocumentModel");T(this,"_fps$",new b.BehaviorSubject(""));T(this,"fps$",this._fps$.asObservable());this._renderManagerService=t,this._configService=n,this._univerInstanceService=i,this._editorService=o,this._initialize()}_initialize(){this._renderManagerService.createRender$.pipe(b.takeUntil(this.dispose$)).subscribe(t=>{this._create(t)}),this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_DOC).pipe(b.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 i=this._renderManagerService.getRenderById(n);if(i==null)return;const{scene:o,engine:s}=i;o.openTransformer(),this._scene=o;const c=new m.Viewport(d.VIEWPORT_KEY.VIEW_MAIN,o,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});o.attachControl(),o.on(m.EVENT_TYPE.wheel,(p,_)=>{const C=p;if(C.ctrlKey){const f=Math.abs(C.deltaX);let I=f<40?.2:f<80?.4:.2;I*=C.deltaY>0?-1:1,o.scaleX<1&&(I/=2),o.scaleX+I>4?o.scale(4,4):o.scaleX+I<.1?o.scale(.1,.1):C.preventDefault()}else c.onMouseWheel(C,_)}),this._configService.getConfig("hasScroll")!==!1&&new m.ScrollBar(c),o.addLayer(new m.Layer(o,[],d.DOCS_COMPONENT_MAIN_LAYER_INDEX),new m.Layer(o,[],d.DOCS_COMPONENT_HEADER_LAYER_INDEX)),this._addComponent(i),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,i=this._currentDocumentModel,o={pageMarginLeft:i.documentStyle.marginLeft||0,pageMarginTop:i.documentStyle.marginTop||0},s=new m.Documents(d.DOCS_VIEW_KEY.MAIN,void 0,o),c=new m.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(i.getUnitId())==null&&n.enableLayerCache(d.DOCS_COMPONENT_MAIN_LAYER_INDEX)}},S.DocCanvasView=un([a.OnLifecycle(a.LifecycleStages.Starting,S.DocCanvasView),ne(0,m.IRenderManagerService),ne(1,a.IConfigService),ne(2,a.IUniverInstanceService),ne(3,l.IEditorService)],S.DocCanvasView);var hn=Object.defineProperty,gn=Object.getOwnPropertyDescriptor,pn=(r,e,t,n)=>{for(var i=n>1?void 0:n?gn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&hn(e,t,i),i},F=(r,e)=>(t,n)=>e(t,n,r);let ie=class extends a.Disposable{constructor(e,t,n,i,o,s){super();T(this,"_liquid",new m.Liquid);T(this,"_pageMarginCache",new Map);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._renderManagerService=n,this._commandService=i,this._floatingObjectManagerService=o,this._editorService=s,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh(),this._updateOnPluginChange()}_updateOnPluginChange(){this._floatingObjectManagerService.pluginUpdate$.subscribe(e=>{const t=this._docSkeletonManagerService.getCurrent();if(t==null)return;const{unitId:n,skeleton:i}=t,o=this._renderManagerService.getRenderById(n);if(o==null)return;const{mainComponent:s,components:c,scene:u}=o,g=s,{left:p,top:_}=g;e.forEach(C=>{const{unitId:f,subUnitId:I,floatingObjectId:h,floatingObject:O}=C,{left:M=0,top:y=0,width:D=0,height:P=0,angle:N,flipX:w,flipY:j,skewX:le,skewY:de}=O,R=this._pageMarginCache.get(h),ue=(R==null?void 0:R.marginLeft)||0,ve=(R==null?void 0:R.marginTop)||0;i==null||i.getViewModel().getDataModel().updateDrawing(h,{left:M-p-ue,top:y-_-ve,height:P,width:D})}),i==null||i.calculate(),s==null||s.makeDirty()})}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{skeleton:t,unitId:n}=e,i=this._renderManagerService.getRenderById(n);if(i==null)return;const{mainComponent:o}=i;o.changeSkeleton(t),this._refreshFloatingObject(n,t,i)})}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id,d.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const i=t.params,{unitId:o}=i,s=this._docSkeletonManagerService.getCurrent();if(s==null)return;const{unitId:c,skeleton:u}=s;if(o!==c)return;const g=this._renderManagerService.getRenderById(c);if(g==null)return;if(this._editorService.isEditor(c)){(n=g.mainComponent)==null||n.makeDirty();return}this._refreshFloatingObject(c,u,g)}}))}_refreshFloatingObject(e,t,n){const i=t==null?void 0:t.getSkeletonData(),{mainComponent:o,scene:s}=n,c=o;if(!i)return;const{left:u,top:g,pageLayoutType:p,pageMarginLeft:_,pageMarginTop:C}=c,{pages:f}=i,I=[];s.getAncestorScale(),this._liquid.reset(),this._pageMarginCache.clear();for(let h=0,O=f.length;h<O;h++){const M=f[h],{skeDrawings:y,marginLeft:D,marginTop:P}=M;this._liquid.translatePagePadding(M),y.forEach(N=>{const{aLeft:w,aTop:j,height:le,width:de,objectId:R,drawingOrigin:ue}=N,ve=ue.layoutType===a.PositionedObjectLayoutType.WRAP_NONE&&ue.behindDoc===a.BooleanNumber.TRUE;I.push({unitId:e,subUnitId:a.DEFAULT_DOCUMENT_SUB_COMPONENT_ID,floatingObjectId:R,behindText:ve,floatingObject:{left:w+u+this._liquid.x,top:j+g+this._liquid.y,width:de,height:le}}),this._pageMarginCache.set(R,{marginLeft:this._liquid.x,marginTop:this._liquid.y})}),this._liquid.restorePagePadding(M),this._liquid.translatePage(M,p,_,C)}this._floatingObjectManagerService.batchAddOrUpdate(I)}};ie=pn([a.OnLifecycle(a.LifecycleStages.Steady,ie),F(0,v.Inject(d.DocSkeletonManagerService)),F(1,a.IUniverInstanceService),F(2,m.IRenderManagerService),F(3,a.ICommandService),F(4,a.IFloatingObjectManagerService),F(5,l.IEditorService)],ie);var _n=Object.defineProperty,Sn=Object.getOwnPropertyDescriptor,fn=(r,e,t,n)=>{for(var i=n>1?void 0:n?Sn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&_n(e,t,i),i},$=(r,e)=>(t,n)=>e(t,n,r);let re=class extends a.Disposable{constructor(e,t,n,i,o,s){super();T(this,"_initializedRender",new Set);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._commandService=n,this._renderManagerService=i,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:i}=n;this.disposeWithMe(a.toDisposable(i.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,i.scaleX<1&&(u/=2);const g=s.zoomRatio;let p=+Number.parseFloat(`${g+u}`).toFixed(1);p=p>=4?4:p<=.1?.1:p,this._commandService.executeCommand(d.SetDocZoomRatioCommand.id,{zoomRatio:p,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 i=t.params,{unitId:o}=i;if(o!==n.getUnitId())return;const s=n.zoomRatio||1;this._updateViewZoom(s)}}))}_updateViewZoom(e,t=!0){var i;const n=this._getDocObject();n!=null&&(n.scene.scale(e,e),this._calculatePagePosition(n,e),t&&this._textSelectionManagerService.refreshSelection(),(i=n.scene.getTransformer())==null||i.hideControl())}_calculatePagePosition(e,t){const{document:n,scene:i,docBackground:o}=e,s=i==null?void 0:i.getParent(),{width:c,height:u,pageMarginLeft:g,pageMarginTop:p}=n;if(s==null||c===Number.POSITIVE_INFINITY||u===Number.POSITIVE_INFINITY)return;const{width:_,height:C}=s;let f=0,I=0,h=0,O=0,M=Number.POSITIVE_INFINITY;_>(c+g*2)*t?(f=_/2-c*t/2,f/=t,h=(_-g*2)/t,M=0):(f=g,h=c+g*2,M=(h-_/t)/2),C>u?(I=C/2-u/2,O=(C-p*2)/t):(I=p,O=u+p*2),i.resize(h,O+200),n.translate(f,I),o.translate(f,I);const y=i.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);if(M!==Number.POSITIVE_INFINITY&&y!=null){const D=y.getBarScroll(M,0).x;y.scrollTo({x:D})}return this}_getDocObject(){return d.getDocObject(this._univerInstanceService,this._renderManagerService)}};re=fn([a.OnLifecycle(a.LifecycleStages.Rendered,re),$(0,v.Inject(d.DocSkeletonManagerService)),$(1,a.IUniverInstanceService),$(2,a.ICommandService),$(3,m.IRenderManagerService),$(4,v.Inject(d.TextSelectionManagerService)),$(5,l.IEditorService)],re);var mn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,Cn=(r,e,t,n)=>{for(var i=n>1?void 0:n?vn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&mn(e,t,i),i},L=(r,e)=>(t,n)=>e(t,n,r);let oe=class extends a.Disposable{constructor(e,t,n,i,o,s,c){super();T(this,"_loadedMap",new WeakSet);this._docSkeletonManagerService=e,this._univerInstanceService=t,this._commandService=n,this._renderManagerService=i,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:i}=t;this.disposeWithMe(a.toDisposable(n.onPointerEnterObserver.add(()=>{this._isEditorReadOnly(e)||(n.cursor=m.CURSOR_TYPE.TEXT)}))),this.disposeWithMe(a.toDisposable(n.onPointerLeaveObserver.add(()=>{n.cursor=m.CURSOR_TYPE.DEFAULT,i.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:g}=o;this._editorService.getEditor(e)&&(this._setEditorFocus(e),setTimeout(()=>{this._setEditorFocus(e),this._textSelectionRenderManager.setCursorManually(u,g)},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 i=t.params,{unitId:o}=i,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,i=this._renderManagerService.getRenderById(t);if(i==null)return;const{scene:o,mainComponent:s}=i;this._textSelectionRenderManager.changeRuntime(n,o,s),this._textSelectionManagerService.setCurrentSelectionNotRefresh({unitId:t,subUnitId:""})}))}_getDocObjectById(e){return this._univerInstanceService.getUnitType(e)!==a.UniverInstanceType.UNIVER_DOC?null:d.getDocObjectById(e,this._renderManagerService)}};oe=Cn([a.OnLifecycle(a.LifecycleStages.Rendered,oe),L(0,v.Inject(d.DocSkeletonManagerService)),L(1,a.IUniverInstanceService),L(2,a.ICommandService),L(3,m.IRenderManagerService),L(4,m.ITextSelectionRenderManager),L(5,v.Inject(d.TextSelectionManagerService)),L(6,l.IEditorService)],oe);var In=Object.defineProperty,On=Object.getOwnPropertyDescriptor,Tn=(r,e,t,n)=>{for(var i=n>1?void 0:n?On(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&In(e,t,i),i},Y=(r,e)=>(t,n)=>e(t,n,r);const we=1.5;let se=class extends a.RxDisposable{constructor(r,e,t,n,i){super(),this._docSkeletonManagerService=r,this._textSelectionManagerService=e,this._editorService=t,this._univerInstanceService=n,this._renderManagerService=i,this._init()}_init(){this._textSelectionManagerService.textSelection$.pipe(b.takeUntil(this.dispose$)).subscribe(r=>{if(r==null)return;const{isEditing:e,unitId:t}=r;e&&this._scrollToSelection(t)})}_scrollToSelection(r){var R;const e=this._textSelectionManagerService.getActiveRange(),t=this._getDocObject(),n=(R=this._docSkeletonManagerService.getCurrent())==null?void 0:R.skeleton;if(e==null||t==null||n==null)return;const{collapsed:i,startNodePosition:o}=e;if(!i)return;const s=t.document.getOffsetConfig(),{docsLeft:c,docsTop:u}=s,g=new m.NodePositionConvertToCursor(s,n),{contentBoxPointGroup:p}=g.getRangePointData(o,o),{left:_,top:C,height:f}=m.getAnchorBounding(p),I=_+c,h=C+u,O=t.scene.getViewport(d.VIEWPORT_KEY.VIEW_MAIN),M=!!this._editorService.getEditor(r);if(O==null)return;const{left:y,top:D,right:P,bottom:N}=O.getBounding().viewBound;let w=0,j=0;const le=M?0:100;h<D?w=h-D:h>N-f&&(w=h-N+f+le),I<y?j=I-y:I>P-we&&(j=I-P+we);const de=O.getBarScroll(j,w);O.scrollBy(de)}_getDocObject(){return d.getDocObject(this._univerInstanceService,this._renderManagerService)}};se=Tn([a.OnLifecycle(a.LifecycleStages.Rendered,se),Y(0,v.Inject(d.DocSkeletonManagerService)),Y(1,v.Inject(d.TextSelectionManagerService)),Y(2,l.IEditorService),Y(3,a.IUniverInstanceService),Y(4,m.IRenderManagerService)],se);var bn=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,yn=(r,e,t,n)=>{for(var i=n>1?void 0:n?Mn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&bn(e,t,i),i},me=(r,e)=>(t,n)=>e(t,n,r);S.UniverDocsUIPlugin=(ce=class extends a.Plugin{constructor(e,t,n,i){super(),this._config=e,this._injector=t,this._localeService=n,this._logService=i,this._localeService.load({zhCN:Ue}),this._config=a.Tools.deepMerge({},Oe,this._config),this._initDependencies(t),this._initializeCommands()}onRendered(){this._initModules(),this._markDocAsFocused()}_initializeCommands(){[He,ze,Ge,Ye,Ke,Xe,qe,Ze,Je,Ft,$t,Bt].forEach(e=>{this._injector.get(l.IShortcutService).registerShortcut(e)})}_initDependencies(e){[[W,{useFactory:()=>this._injector.createInstance(W,this._config)}],[J],[Q],[te],[ie],[re],[oe],[se],[V,{useFactory:()=>this._injector.createInstance(V,this._config)}],[H,{useClass:Se}],[S.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 i=n.getUnitId();t.isEditor(i)||e.focusUnit(n.getUnitId())}catch(n){this._logService.warn(n)}}_initModules(){this._injector.get(V)}},T(ce,"pluginName",Te),T(ce,"type",a.UniverInstanceType.UNIVER_DOC),ce),S.UniverDocsUIPlugin=yn([me(1,v.Inject(v.Injector)),me(2,v.Inject(a.LocaleService)),me(3,a.ILogService)],S.UniverDocsUIPlugin),S.DOC_UI_PLUGIN_NAME=Te,S.DefaultDocContainerConfig=Ie,S.DefaultDocUiConfig=Oe,S.DefaultToolbarConfig=Ce,S.PastePluginLark=xe,S.PastePluginUniver=Be,S.PastePluginWord=Ae,S.enUS=Lt,S.ruRU=At,S.zhCN=Ue,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer normal ui-plugin-docs",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,30 +53,30 @@
|
|
|
53
53
|
"npm": ">=8.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@wendellhu/redi": "
|
|
56
|
+
"@wendellhu/redi": "0.15.2",
|
|
57
57
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
58
58
|
"rxjs": ">=7.0.0",
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/docs": "0.1.
|
|
62
|
-
"@univerjs/engine-render": "0.1.
|
|
63
|
-
"@univerjs/ui": "0.1.
|
|
59
|
+
"@univerjs/core": "0.1.12",
|
|
60
|
+
"@univerjs/design": "0.1.12",
|
|
61
|
+
"@univerjs/docs": "0.1.12",
|
|
62
|
+
"@univerjs/engine-render": "0.1.12",
|
|
63
|
+
"@univerjs/ui": "0.1.12"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/react": "^18.2.79",
|
|
67
|
-
"@wendellhu/redi": "
|
|
67
|
+
"@wendellhu/redi": "0.15.2",
|
|
68
68
|
"less": "^4.2.0",
|
|
69
69
|
"react": "18.2.0",
|
|
70
70
|
"rxjs": "^7.8.1",
|
|
71
71
|
"typescript": "^5.4.5",
|
|
72
72
|
"vite": "^5.2.11",
|
|
73
73
|
"vitest": "^1.6.0",
|
|
74
|
-
"@univerjs/
|
|
75
|
-
"@univerjs/
|
|
76
|
-
"@univerjs/design": "0.1.
|
|
77
|
-
"@univerjs/
|
|
78
|
-
"@univerjs/
|
|
79
|
-
"@univerjs/
|
|
74
|
+
"@univerjs/core": "0.1.12",
|
|
75
|
+
"@univerjs/engine-render": "0.1.12",
|
|
76
|
+
"@univerjs/design": "0.1.12",
|
|
77
|
+
"@univerjs/shared": "0.1.12",
|
|
78
|
+
"@univerjs/ui": "0.1.12",
|
|
79
|
+
"@univerjs/docs": "0.1.12"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"test": "vitest run",
|