@univerjs/docs-ui 0.1.0-beta.4 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +10 -1
- package/lib/es/index.js +1443 -297
- package/lib/index.css +1 -0
- package/lib/types/commands/commands/clipboard.command.d.ts +20 -0
- package/lib/types/controllers/app-ui-controller.d.ts +9 -4
- package/lib/types/controllers/clipboard.controller.d.ts +29 -0
- package/lib/types/controllers/doc-container-ui-controller.d.ts +1 -1
- package/lib/types/controllers/doc-editor-bridge.controller.d.ts +37 -0
- package/lib/types/controllers/doc-render.controller.d.ts +31 -0
- package/lib/types/controllers/doc-ui.controller.d.ts +6 -5
- package/lib/types/controllers/floating-object.controller.d.ts +35 -0
- package/lib/types/controllers/page-render.controller.d.ts +27 -0
- package/lib/types/controllers/zoom.controller.d.ts +37 -0
- package/lib/types/docs-ui-plugin.d.ts +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +3 -21
- package/lib/types/locale/zh-CN.d.ts +2 -2
- package/lib/types/services/clipboard/__test__/html-and-udm-convert.spec.d.ts +16 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +55 -0
- package/lib/types/services/clipboard/copy-content-cache.d.ts +25 -0
- package/lib/types/services/clipboard/html-to-udm/converter.d.ts +30 -0
- package/lib/types/services/clipboard/html-to-udm/parse-node-style.d.ts +17 -0
- package/lib/types/services/clipboard/html-to-udm/parse-to-dom.d.ts +16 -0
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-lark.d.ts +18 -0
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-word.d.ts +18 -0
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/type.d.ts +30 -0
- package/lib/types/services/clipboard/html-to-udm/utils.d.ts +17 -0
- package/lib/types/services/clipboard/udm-to-html/__test__/convertor.spec.d.ts +16 -0
- package/lib/types/services/clipboard/udm-to-html/convertor.d.ts +19 -0
- package/lib/types/shortcuts/core-editing.shortcut.d.ts +19 -0
- package/lib/types/shortcuts/cursor.shortcut.d.ts +25 -0
- package/lib/types/shortcuts/utils.d.ts +17 -0
- package/lib/types/views/doc-background/DocBackground.d.ts +20 -0
- package/lib/types/views/doc-canvas-view.d.ts +32 -0
- package/lib/umd/index.js +10 -1
- package/package.json +29 -22
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
"use strict";var N=Object.defineProperty;var B=(e,n,t)=>n in e?N(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var _=(e,n,t)=>(B(e,typeof n!="symbol"?n+"":n,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),m=require("@wendellhu/redi"),r=require("@univerjs/ui"),l=require("@univerjs/docs"),O=require("rxjs"),$=require("@univerjs/design"),b={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},F={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},U={layout:{docContainerConfig:F,toolbarConfig:b}},L="DocUI";var j=Object.defineProperty,w=Object.getOwnPropertyDescriptor,z=(e,n,t,o)=>{for(var i=o>1?void 0:o?w(n,t):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&j(n,t,i),i},M=(e,n)=>(t,o)=>n(t,o,e);let h=class{constructor(e,n,t){_(this,"_docContainer");_(this,"getComponent",e=>{if(this._docContainer=e,!e.getContentRef().current)throw new Error("container is not ready")});_(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._config=e,this._localeService=n,this._injector=t}getUIConfig(){return{injector:this._injector,config:this._config,changeLocale:this.changeLocale,getComponent:this.getComponent}}getContentRef(){return this._docContainer.getContentRef()}UIDidMount(e){if(this._docContainer)return e(this._docContainer)}getDocContainer(){return this._docContainer}};h=z([M(1,m.Inject(a.LocaleService)),M(2,m.Inject(m.Injector))],h);var G=Object.defineProperty,H=Object.getOwnPropertyDescriptor,Y=(e,n,t,o)=>{for(var i=o>1?void 0:o?H(n,t):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&G(n,t,i),i},R=(e,n)=>(t,o)=>n(t,o,e);let C=class{constructor(e,n,t){_(this,"_docContainerController");_(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._localeService=n,this._injector=t,this._docContainerController=this._injector.createInstance(h,e)}getDocContainerController(){return this._docContainerController}};C=Y([R(1,m.Inject(a.LocaleService)),R(2,m.Inject(m.Injector))],C);const v="UI_PLUGIN_DOCS",x=`${v}_COLOR_PICKER_COMPONENT`,A=`${v}_FONT_FAMILY_COMPONENT`,y=`${v}_FONT_FAMILY_ITEM_COMPONENT`,D=`${v}_FONT_SIZE_COMPONENT`;function q(e){const n=e.get(a.ICommandService);return{id:l.SetInlineFormatBoldCommand.id,group:r.MenuGroup.TOOLBAR_FORMAT,type:r.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[r.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const d=(s=u.ts)==null?void 0:s.bl;t.next(d===a.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:r.getMenuHiddenObservable(e,a.UniverInstanceType.DOC)}}function W(e){const n=e.get(a.ICommandService);return{id:l.SetInlineFormatItalicCommand.id,group:r.MenuGroup.TOOLBAR_FORMAT,type:r.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[r.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const d=(s=u.ts)==null?void 0:s.it;t.next(d===a.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:r.getMenuHiddenObservable(e,a.UniverInstanceType.DOC)}}function Z(e){const n=e.get(a.ICommandService);return{id:l.SetInlineFormatUnderlineCommand.id,group:r.MenuGroup.TOOLBAR_FORMAT,type:r.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[r.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const d=(s=u.ts)==null?void 0:s.ul;t.next((d==null?void 0:d.s)===a.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:r.getMenuHiddenObservable(e,a.UniverInstanceType.DOC)}}function K(e){const n=e.get(a.ICommandService);return{id:l.SetInlineFormatStrikethroughCommand.id,group:r.MenuGroup.TOOLBAR_FORMAT,type:r.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[r.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const d=(s=u.ts)==null?void 0:s.st;t.next((d==null?void 0:d.s)===a.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:r.getMenuHiddenObservable(e,a.UniverInstanceType.DOC)}}function V(e){const n=e.get(a.ICommandService);return{id:l.SetInlineFormatSubscriptCommand.id,group:r.MenuGroup.TOOLBAR_FORMAT,type:r.MenuItemType.BUTTON,icon:"SubscriptSingle",tooltip:"toolbar.subscript",positions:[r.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const d=(s=u.ts)==null?void 0:s.va;t.next(d===a.BaselineOffset.SUBSCRIPT)}});return t.next(!1),o.dispose}),hidden$:r.getMenuHiddenObservable(e,a.UniverInstanceType.DOC)}}function X(e){const n=e.get(a.ICommandService);return{id:l.SetInlineFormatSuperscriptCommand.id,group:r.MenuGroup.TOOLBAR_FORMAT,type:r.MenuItemType.BUTTON,icon:"SuperscriptSingle",tooltip:"toolbar.superscript",positions:[r.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const d=(s=u.ts)==null?void 0:s.va;t.next(d===a.BaselineOffset.SUPERSCRIPT)}});return t.next(!1),o.dispose}),hidden$:r.getMenuHiddenObservable(e,a.UniverInstanceType.DOC)}}function J(e){const n=e.get(a.ICommandService);return{id:l.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:r.MenuGroup.TOOLBAR_FORMAT,type:r.MenuItemType.SELECTOR,label:A,positions:[r.MenuPosition.TOOLBAR_START],selections:r.FONT_FAMILY_LIST.map(t=>({label:{name:y,hoverable:!0},value:t.value})),value$:new O.Observable(t=>{const o=r.FONT_FAMILY_LIST[0].value,i=n.onCommandExecuted(c=>{var u;const s=c.id;if(s===l.SetTextSelectionsOperation.id||s===l.SetInlineFormatFontFamilyCommand.id){const d=T(e);if(d==null)return;const p=(u=d.ts)==null?void 0:u.ff;t.next(p!=null?p:o)}});return t.next(o),i.dispose}),hidden$:r.getMenuHiddenObservable(e,a.UniverInstanceType.DOC)}}function Q(e){const n=e.get(a.ICommandService);return{id:l.SetInlineFormatFontSizeCommand.id,group:r.MenuGroup.TOOLBAR_FORMAT,type:r.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:D,props:{min:1,max:400}},positions:[r.MenuPosition.TOOLBAR_START],selections:r.FONT_SIZE_LIST,value$:new O.Observable(t=>{const i=n.onCommandExecuted(c=>{var u;const s=c.id;if(s===l.SetTextSelectionsOperation.id||s===l.SetInlineFormatFontSizeCommand.id){const d=T(e);if(d==null)return;const p=(u=d.ts)==null?void 0:u.fs;t.next(p!=null?p:14)}});return t.next(14),i.dispose}),hidden$:r.getMenuHiddenObservable(e,a.UniverInstanceType.DOC)}}function k(e){const n=e.get(a.ICommandService),t=e.get(a.ThemeService);return{id:l.SetInlineFormatTextColorCommand.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:r.MenuGroup.TOOLBAR_FORMAT,type:r.MenuItemType.BUTTON_SELECTOR,positions:[r.MenuPosition.TOOLBAR_START],selections:[{label:{name:x,hoverable:!1}}],value$:new O.Observable(o=>{const i=t.getCurrentTheme().textColor,c=n.onCommandExecuted(s=>{if(s.id===l.SetInlineFormatTextColorCommand.id){const u=s.params.value;o.next(u!=null?u:i)}});return o.next(i),c.dispose}),hidden$:r.getMenuHiddenObservable(e,a.UniverInstanceType.DOC)}}function ee(e){return{id:l.OrderListCommand.id,group:r.MenuGroup.TOOLBAR_LAYOUT,type:r.MenuItemType.BUTTON,icon:"OrderSingle",tooltip:"toolbar.order",positions:[r.MenuPosition.TOOLBAR_START],hidden$:r.getMenuHiddenObservable(e,a.UniverInstanceType.DOC)}}function te(e){return{id:l.BulletListCommand.id,group:r.MenuGroup.TOOLBAR_LAYOUT,type:r.MenuItemType.BUTTON,icon:"UnorderSingle",tooltip:"toolbar.unorder",positions:[r.MenuPosition.TOOLBAR_START],hidden$:r.getMenuHiddenObservable(e,a.UniverInstanceType.DOC)}}function T(e){var d;const n=e.get(a.IUniverInstanceService),t=e.get(l.TextSelectionManagerService),o=n.getCurrentUniverDocInstance(),i=t.getActiveRange();if(o==null||i==null)return;const c=(d=o.getBody())==null?void 0:d.textRuns;if(c==null)return;const{startOffset:s}=i;return c.find(({st:p,ed:E})=>s>=p&&s<E)}var ne=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,ie=(e,n,t,o)=>{for(var i=o>1?void 0:o?oe(n,t):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&ne(n,t,i),i},S=(e,n)=>(t,o)=>n(t,o,e);let I=class extends a.Disposable{constructor(e,n,t,o,i,c){super(),this._injector=e,this._componentManager=n,this._commandService=t,this._shortcutService=o,this._menuService=i,this._uiController=c,this._init()}_initCustomComponents(){const e=this._componentManager;this.disposeWithMe(e.register(x,$.ColorPicker)),this.disposeWithMe(e.register(A,r.FontFamily)),this.disposeWithMe(e.register(y,r.FontFamilyItem)),this.disposeWithMe(e.register(D,r.FontSize))}_initMenus(){[q,W,Z,K,V,X,Q,J,k,ee,te].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e)))})}_init(){this._initCustomComponents(),this._initMenus()}};I=ie([a.OnLifecycle(a.LifecycleStages.Rendered,I),S(0,m.Inject(m.Injector)),S(1,m.Inject(r.ComponentManager)),S(2,a.ICommandService),S(3,r.IShortcutService),S(4,r.IMenuService),S(5,r.IUIController)],I);const re={toolbar:{undo:"Undo",redo:"Redo",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",order:"Ordered list",unorder:"Unordered list"}},P={toolbar:{undo:"撤销",redo:"重做",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",order:"有序列表",unorder:"无序列表"}};var se=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,ae=(e,n,t,o)=>{for(var i=o>1?void 0:o?ce(n,t):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&se(n,t,i),i},f=(e,n)=>(t,o)=>n(t,o,e),g;exports.UniverDocsUIPlugin=(g=class extends a.Plugin{constructor(n,t,o,i){super(L),this._config=n,this._injector=t,this._localeService=o,this._logService=i,this._localeService.load({zhCN:P}),this._config=a.Tools.deepMerge({},U,this._config),this._initDependencies(t)}onRendered(){this._initModules(),this._markDocAsFocused()}onDestroy(){}_initDependencies(n){[[I],[C,{useFactory:()=>this._injector.createInstance(C,this._config)}]].forEach(o=>{n.add(o)})}_markDocAsFocused(){const n=this._injector.get(a.IUniverInstanceService);try{const t=n.getCurrentUniverDocInstance(),o=t.getUnitId();o!==a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&o!==a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&n.focusUniverInstance(t.getUnitId())}catch(t){this._logService.warn(t)}}_initModules(){this._injector.get(C)}},_(g,"type",a.PluginType.Doc),g);exports.UniverDocsUIPlugin=ae([f(1,m.Inject(m.Injector)),f(2,m.Inject(a.LocaleService)),f(3,a.ILogService)],exports.UniverDocsUIPlugin);exports.DOC_UI_PLUGIN_NAME=L;exports.DefaultDocContainerConfig=F;exports.DefaultDocUiConfig=U;exports.DefaultToolbarConfig=b;exports.enUS=re;exports.zhCN=P;
|
|
1
|
+
"use strict";var Ee=Object.defineProperty;var xe=(i,e,t)=>e in i?Ee(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var v=(i,e,t)=>(xe(i,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"),u=require("@univerjs/docs"),C=require("@univerjs/engine-render"),Pe=require("@wendellhu/redi/react-bindings"),Ue=require("@univerjs/design"),Le=require("react"),T=require("rxjs"),me={undo:!0,redo:!0,font:!0,fontSize:!0,bold:!0,italic:!0,strikethrough:!0,underline:!0,textColor:!0,fillColor:!0,horizontalAlignMode:!0,verticalAlignMode:!0,textWrapMode:!0,textRotateMode:!0},fe={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},Se={layout:{docContainerConfig:fe,toolbarConfig:me}},ve="DocUI";function M(i){return i.getContextValue(a.FOCUSING_DOC)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)}const Ne={id:u.MoveCursorOperation.id,binding:l.KeyCode.ARROW_UP,preconditions:M,staticParameters:{direction:a.Direction.UP}},Ae={id:u.MoveCursorOperation.id,binding:l.KeyCode.ARROW_DOWN,preconditions:M,staticParameters:{direction:a.Direction.DOWN}},Be={id:u.MoveCursorOperation.id,binding:l.KeyCode.ARROW_LEFT,preconditions:M,staticParameters:{direction:a.Direction.LEFT}},Fe={id:u.MoveCursorOperation.id,binding:l.KeyCode.ARROW_RIGHT,preconditions:M,staticParameters:{direction:a.Direction.RIGHT}},$e={id:u.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_UP|l.MetaKeys.SHIFT,preconditions:M,staticParameters:{direction:a.Direction.UP}},we={id:u.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_DOWN|l.MetaKeys.SHIFT,preconditions:M,staticParameters:{direction:a.Direction.DOWN}},je={id:u.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_LEFT|l.MetaKeys.SHIFT,preconditions:M,staticParameters:{direction:a.Direction.LEFT}},ze={id:u.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_RIGHT|l.MetaKeys.SHIFT,preconditions:M,staticParameters:{direction:a.Direction.RIGHT}},We={id:u.SelectAllOperation.id,binding:l.KeyCode.A|l.MetaKeys.CTRL_COMMAND,preconditions:i=>i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&(i.getContextValue(a.FOCUSING_DOC)||i.getContextValue(a.EDITOR_ACTIVATED))};var Ve=Object.defineProperty,He=Object.getOwnPropertyDescriptor,ke=(i,e,t,n)=>{for(var r=n>1?void 0:n?He(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ve(e,t,r),r},pe=(i,e)=>(t,n)=>e(t,n,i);let ie=class{constructor(i,e,t){v(this,"_docContainer");v(this,"getComponent",i=>{if(this._docContainer=i,!i.getContentRef().current)throw new Error("container is not ready")});v(this,"changeLocale",i=>{this._localeService.setLocale(i)});this._config=i,this._localeService=e,this._injector=t}getUIConfig(){return{injector:this._injector,config:this._config,changeLocale:this.changeLocale,getComponent:this.getComponent}}getContentRef(){return this._docContainer.getContentRef()}UIDidMount(i){if(this._docContainer)return i(this._docContainer)}getDocContainer(){return this._docContainer}};ie=ke([pe(1,O.Inject(a.LocaleService)),pe(2,O.Inject(O.Injector))],ie);var Ke=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Ge=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ye(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ke(e,t,r),r},z=(i,e)=>(t,n)=>e(t,n,i);let $=class extends a.RxDisposable{constructor(e,t,n,r,o){super();v(this,"_docContainerController");v(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._localeService=t,this._injector=n,this._textSelectionRenderManager=r,this._layoutService=o,this._docContainerController=this._injector.createInstance(ie,e),this._registerContainer()}_registerContainer(){this._layoutService&&this.disposeWithMe(this._layoutService.registerContainerElement(this._textSelectionRenderManager.__getEditorContainer()))}getDocContainerController(){return this._docContainerController}};$=Ge([z(1,O.Inject(a.LocaleService)),z(2,O.Inject(O.Injector)),z(3,C.ITextSelectionRenderManager),z(4,O.Optional(l.ILayoutService))],$);const Z="UI_PLUGIN_DOCS",Ce=`${Z}_COLOR_PICKER_COMPONENT`,Ie=`${Z}_FONT_FAMILY_COMPONENT`,Oe=`${Z}_FONT_FAMILY_ITEM_COMPONENT`,be=`${Z}_FONT_SIZE_COMPONENT`;var Te={exports:{}},J={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var qe=Le,Xe=Symbol.for("react.element"),Ze=Symbol.for("react.fragment"),Je=Object.prototype.hasOwnProperty,Qe=qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,et={key:!0,ref:!0,__self:!0,__source:!0};function Re(i,e,t){var n,r={},o=null,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)Je.call(e,n)&&!et.hasOwnProperty(n)&&(r[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)r[n]===void 0&&(r[n]=e[n]);return{$$typeof:Xe,type:i,key:o,ref:s,props:r,_owner:Qe.current}}J.Fragment=Ze;J.jsx=Re;J.jsxs=Re;Te.exports=J;var tt=Te.exports;const nt="univer-docs-ui-canvas-background",rt={docsUiCanvasBackground:nt},it=()=>tt.jsx("div",{className:rt.docsUiCanvasBackground});function ot(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatBoldCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var s;const o=r.id;if(o===u.SetTextSelectionsOperation.id||o===u.SetInlineFormatCommand.id){const c=D(i);if(c==null)return;const d=(s=c.ts)==null?void 0:s.bl;t.next(d===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.DOC)}}function st(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatItalicCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var s;const o=r.id;if(o===u.SetTextSelectionsOperation.id||o===u.SetInlineFormatCommand.id){const c=D(i);if(c==null)return;const d=(s=c.ts)==null?void 0:s.it;t.next(d===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.DOC)}}function at(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatUnderlineCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var s;const o=r.id;if(o===u.SetTextSelectionsOperation.id||o===u.SetInlineFormatCommand.id){const c=D(i);if(c==null)return;const d=(s=c.ts)==null?void 0:s.ul;t.next((d==null?void 0:d.s)===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.DOC)}}function ct(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatStrikethroughCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var s;const o=r.id;if(o===u.SetTextSelectionsOperation.id||o===u.SetInlineFormatCommand.id){const c=D(i);if(c==null)return;const d=(s=c.ts)==null?void 0:s.st;t.next((d==null?void 0:d.s)===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.DOC)}}function lt(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatSubscriptCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"SubscriptSingle",tooltip:"toolbar.subscript",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var s;const o=r.id;if(o===u.SetTextSelectionsOperation.id||o===u.SetInlineFormatCommand.id){const c=D(i);if(c==null)return;const d=(s=c.ts)==null?void 0:s.va;t.next(d===a.BaselineOffset.SUBSCRIPT)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.DOC)}}function dt(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatSuperscriptCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"SuperscriptSingle",tooltip:"toolbar.superscript",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(r=>{var s;const o=r.id;if(o===u.SetTextSelectionsOperation.id||o===u.SetInlineFormatCommand.id){const c=D(i);if(c==null)return;const d=(s=c.ts)==null?void 0:s.va;t.next(d===a.BaselineOffset.SUPERSCRIPT)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.DOC)}}function ut(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,label:Ie,positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_FAMILY_LIST.map(t=>({label:{name:Oe,hoverable:!0},value:t.value})),value$:new T.Observable(t=>{const n=l.FONT_FAMILY_LIST[0].value,r=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===u.SetTextSelectionsOperation.id||s===u.SetInlineFormatFontFamilyCommand.id){const d=D(i);if(d==null)return;const h=(c=d.ts)==null?void 0:c.ff;t.next(h!=null?h:n)}});return t.next(n),r.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.DOC)}}function pt(i){const e=i.get(a.ICommandService);return{id:u.SetInlineFormatFontSizeCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:be,props:{min:1,max:400}},positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_SIZE_LIST,value$:new T.Observable(t=>{const r=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===u.SetTextSelectionsOperation.id||s===u.SetInlineFormatFontSizeCommand.id){const d=D(i);if(d==null)return;const h=(c=d.ts)==null?void 0:c.fs;t.next(h!=null?h:14)}});return t.next(14),r.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.DOC)}}function ht(i){const e=i.get(a.ICommandService),t=i.get(a.ThemeService);return{id:u.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:Ce,hoverable:!1}}],value$:new T.Observable(n=>{const r=t.getCurrentTheme().textColor,o=e.onCommandExecuted(s=>{if(s.id===u.SetInlineFormatTextColorCommand.id){const c=s.params.value;n.next(c!=null?c:r)}});return n.next(r),o.dispose}),hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.DOC)}}function _t(i){return{id:u.OrderListCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"OrderSingle",tooltip:"toolbar.order",positions:[l.MenuPosition.TOOLBAR_START],hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.DOC)}}function gt(i){return{id:u.BulletListCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"UnorderSingle",tooltip:"toolbar.unorder",positions:[l.MenuPosition.TOOLBAR_START],hidden$:l.getMenuHiddenObservable(i,a.UniverInstanceType.DOC)}}function D(i){var d;const e=i.get(a.IUniverInstanceService),t=i.get(u.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),r=t.getActiveRange();if(n==null||r==null)return;const o=(d=n.getBody())==null?void 0:d.textRuns;if(o==null)return;const{startOffset:s}=r;return o.find(({st:h,ed:_})=>s>=h&&s<_)}var mt=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,St=(i,e,t,n)=>{for(var r=n>1?void 0:n?ft(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&mt(e,t,r),r},E=(i,e)=>(t,n)=>e(t,n,i);let V=class extends a.Disposable{constructor(i,e,t,n,r,o){super(),this._injector=i,this._componentManager=e,this._editorService=t,this._menuService=n,this._uiController=r,this._currentUniverService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ce,Ue.ColorPicker)),this.disposeWithMe(i.register(Ie,l.FontFamily)),this.disposeWithMe(i.register(Oe,l.FontFamilyItem)),this.disposeWithMe(i.register(be,l.FontSize))}_initMenus(){[ot,st,at,ct,lt,dt,pt,ut,ht,_t,gt].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_init(){this._initCustomComponents(),this._initMenus(),this._initDocBackground()}_initDocBackground(){const i=this._currentUniverService.getAllUniverDocsInstance()[0].getUnitId();if(i==null)return;this._editorService.isEditor(i)||this.disposeWithMe(this._uiController.registerContentComponent(()=>Pe.connectInjector(it,this._injector)))}};V=St([a.OnLifecycle(a.LifecycleStages.Rendered,V),E(0,O.Inject(O.Injector)),E(1,O.Inject(l.ComponentManager)),E(2,l.IEditorService),E(3,l.IMenuService),E(4,l.IUIController),E(5,a.IUniverInstanceService)],V);const vt={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"},resetColor:"Reset",order:"Ordered list",unorder:"Unordered list"}},Me={toolbar:{undo:"撤销",redo:"重做",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",order:"有序列表",unorder:"无序列表"}},Ct={id:u.BreakLineCommand.id,preconditions:M,binding:l.KeyCode.ENTER},It={id:u.DeleteLeftCommand.id,preconditions:M,binding:l.KeyCode.BACKSPACE},Ot={id:u.DeleteRightCommand.id,preconditions:M,binding:l.KeyCode.DELETE},bt=10,Tt=6;function Rt(){return a.Tools.generateRandomId(Tt)}function Mt(i){const e=i.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class yt{constructor(){v(this,"_cache",new a.LRUMap(bt))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}clear(){this._cache.clear()}}const he=new yt;function se(i){const e=i.style,t={},n=i.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{t.bl=a.BooleanNumber.TRUE;break}case"s":{t.st={s:a.BooleanNumber.TRUE};break}case"u":{t.ul={s:a.BooleanNumber.TRUE};break}case"i":{t.it=a.BooleanNumber.TRUE;break}case"sub":case"sup":{t.va=n==="sup"?a.BaselineOffset.SUPERSCRIPT:a.BaselineOffset.SUBSCRIPT;break}}for(let r=0;r<e.length;r++){const o=e[r],s=e.getPropertyValue(o);switch(o){case"font-family":{t.ff=s;break}case"font-size":{const c=Number.parseInt(s);Number.isNaN(c)||s.endsWith("pt")&&(t.fs=c);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 Dt(i){const e=new DOMParser,t=`<x-univer id="univer-root">${i}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function _e(i,e){const t=i.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(i)}const X=class X{constructor(){v(this,"_styleCache",new Map);v(this,"_styleRules",[]);v(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=X._pluginList.find(o=>o.checkPasteType(e)),n=Dt(e),r={dataStream:"",textRuns:[]};return t&&(this._styleRules=[...t.stylesRules],this._afterProcessRules=[...t.afterProcessRules]),this._styleCache.clear(),this._process(null,n==null?void 0:n.childNodes,r),this._styleCache.clear(),this._styleRules=[],this._afterProcessRules=[],r}_process(e,t,n){var r;for(const o of t)if(o.nodeType===Node.TEXT_NODE){const s=(r=o.nodeValue)==null?void 0:r.replace(/[\r\n]/g,"");let c;e&&this._styleCache.has(e)&&(c=this._styleCache.get(e)),n.dataStream+=s,c&&Object.getOwnPropertyNames(c).length&&n.textRuns.push({st:n.dataStream.length-s.length,ed:n.dataStream.length,ts:c})}else if(o.nodeType===Node.ELEMENT_NODE){const s=e?this._styleCache.get(e):{},c=this._styleRules.find(({filter:m})=>_e(o,m)),d=c?c.getStyle(o):se(o);this._styleCache.set(o,{...s,...d});const{childNodes:h}=o;this._process(o,h,n);const _=this._afterProcessRules.find(({filter:m})=>_e(o,m));_&&_.handler(n,o)}}};v(X,"_pluginList",[]);let w=X;const Et={name:"univer-doc-paste-plugin-lark",checkPasteType(i){return/lark-record-clipboard/i.test(i)},stylesRules:[{filter:["s"],getStyle(i){const e=se(i);return{st:{s:a.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(i){return i.tagName==="DIV"&&/ace-line/i.test(i.className)},handler(i){i.paragraphs==null&&(i.paragraphs=[]),i.paragraphs.push({startIndex:i.dataStream.length}),i.dataStream+="\r"}}]};function xt(i){const e=i.style,t={};for(let n=0;n<e.length;n++){const r=e[n],o=e.getPropertyValue(r);switch(r){case"margin-top":{const s=Number.parseInt(o);t.spaceAbove=/pt/.test(o)?C.ptToPixel(s):s;break}case"margin-bottom":{const s=Number.parseInt(o);t.spaceBelow=/pt/.test(o)?C.ptToPixel(s):s;break}}}return Object.getOwnPropertyNames(t).length?t:null}const Pt={name:"univer-doc-paste-plugin-word",checkPasteType(i){return/word|mso/i.test(i)},stylesRules:[{filter:["b"],getStyle(i){const e=se(i);return{bl:a.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(i){return i.tagName==="P"&&/mso/i.test(i.className)},handler(i,e){i.paragraphs==null&&(i.paragraphs=[]);const t={startIndex:i.dataStream.length},n=xt(e);n&&(t.paragraphStyle=n),i.paragraphs.push(t),i.dataStream+="\r"}}]};function Ut(i,e){const{st:t,ed:n,ts:r={}}=e,{ff:o,fs:s,it:c,bl:d,ul:h,st:_,ol:m,bg:S,cl:I,va:f}=r;let p=i.slice(t,n);const g=[];return c===a.BooleanNumber.TRUE&&(p=`<i>${p}</i>`),f===a.BaselineOffset.SUPERSCRIPT?p=`<sup>${p}</sup>`:f===a.BaselineOffset.SUBSCRIPT&&(p=`<sub>${p}</sub>`),(h==null?void 0:h.s)===a.BooleanNumber.TRUE&&(p=`<u>${p}</u>`),(_==null?void 0:_.s)===a.BooleanNumber.TRUE&&(p=`<s>${p}</s>`),d===a.BooleanNumber.TRUE&&(p=`<strong>${p}</strong>`),o&&g.push(`font-family: ${o}`),I&&g.push(`color: ${I.rgb}`),s&&g.push(`font-size: ${s}px`),m&&g.push("text-decoration: overline"),S&&g.push(`background: ${S.rgb}`),g.length?`<span style="${g.join(";")}">${p}</span>`:p}function ge(i,e=!0){const{dataStream:t,textRuns:n=[],paragraphs:r=[]}=i;let o=0;const s=[],c=[];for(const d of n){const{st:h,ed:_}=d;if(h!==o&&s.push(t.slice(o,h)),s.push(Ut(t,d)),o=_,e)for(const m of r){const{startIndex:S,paragraphStyle:I={}}=m;if(S>=h&&S<=_){const{spaceAbove:f,spaceBelow:p}=I,g=[];f!=null&&(typeof f=="number"?g.push(`margin-top: ${f}px`):g.push(`margin-top: ${f.v}px`)),p!=null&&(typeof p=="number"?g.push(`margin-bottom: ${p}px`):g.push(`margin-bottom: ${p.v}px`)),c.push(`<p className="UniverNormal" ${g.length?`style="${g.join(";")}"`:""}>${s.join("")}</p>`),s.length=0}}}return o<t.length&&s.push(t.slice(o,t.length)),c.join("")+s.join("")}class Lt{convert(e){if(e.length===0)throw new Error("The bodyList length at least to be 1");if(e.length===1)return ge(e[0]);let t="";for(const n of e)t+='<p className="UniverNormal">',t+=ge(n,!1),t+="</p>";return t}}var Nt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Bt=(i,e,t,n)=>{for(var r=n>1?void 0:n?At(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Nt(e,t,r),r},A=(i,e)=>(t,n)=>e(t,n,i);w.use(Pt);w.use(Et);function Ft(i){const e=i.replace(/\n/g,"\r"),t=[];for(let n=0;n<e.length;n++)e[n]==="\r"&&t.push({startIndex:n});return{dataStream:e,paragraphs:t}}const j=O.createIdentifier("doc.clipboard-service");let oe=class extends a.Disposable{constructor(e,t,n,r,o){super();v(this,"_clipboardHooks",[]);v(this,"_htmlToUDM",new w);v(this,"_umdToHtml",new Lt);this._currentUniverService=e,this._logService=t,this._commandService=n,this._clipboardInterfaceService=r,this._textSelectionManagerService=o}async copy(){const e=this._getDocumentBodyInRanges();try{this._setClipboardData(e)}catch(t){return this._logService.error("[DocClipboardService] copy failed",t),!1}return!0}async cut(){return this._cut()}async paste(e){const t=await this._generateBodyFromClipboardItems(e);return this._paste(t)}async legacyPaste(e,t){const n=this._generateBodyFromHtmlAndText(e,t);return this._paste(n)}async _cut(){var o;const{segmentId:e,endOffset:t,style:n}=(o=this._textSelectionManagerService.getActiveRange())!=null?o:{},r=this._textSelectionManagerService.getSelections();if(e==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),t==null||r==null)return!1;this.copy();try{let s=t;for(const d of r){const{startOffset:h,endOffset:_}=d;h==null||_==null||_<=t&&(s-=_-h)}const c=[{startOffset:s,endOffset:s,style:n}];return this._commandService.executeCommand(u.CutContentCommand.id,{segmentId:e,textRanges:c})}catch{return this._logService.error("[DocClipboardController] cut content failed"),!1}}async _paste(e){var s;const{segmentId:t,endOffset:n,style:r}=(s=this._textSelectionManagerService.getActiveRange())!=null?s:{},o=this._textSelectionManagerService.getSelections();if(t==null&&this._logService.error("[DocClipboardController] segmentId does not exist!"),n==null||o==null)return!1;try{let c=n;for(const h of o){const{startOffset:_,endOffset:m}=h;_==null||m==null||m<=n&&(c+=e.dataStream.length-(m-_))}const d=[{startOffset:c,endOffset:c,style:r}];return this._commandService.executeCommand(u.InnerPasteCommand.id,{body:e,segmentId:t,textRanges:d})}catch{return this._logService.error("[DocClipboardController]","clipboard is empty."),!1}}async _setClipboardData(e){const t=Rt(),n=e.length>1?e.map(o=>o.dataStream).join(`
|
|
10
|
+
`):e[0].dataStream;let r=this._umdToHtml.convert(e);return e.length===1&&(r=r.replace(/(<[a-z]+)/,(o,s)=>`${s} data-copy-id="${t}"`),he.set(t,e[0])),this._clipboardInterfaceService.write(n,r)}addClipboardHook(e){return this._clipboardHooks.push(e),a.toDisposable(()=>{const t=this._clipboardHooks.indexOf(e);t>-1&&this._clipboardHooks.splice(t,1)})}_getDocumentBodyInRanges(){const e=this._textSelectionManagerService.getSelections(),t=this._currentUniverService.getCurrentUniverDocInstance(),n=[];if(e==null)return n;for(const r of e){const{startOffset:o,endOffset:s,collapsed:c}=r;if(c||o==null||s==null)continue;const d=t.sliceBody(o,s);d!=null&&n.push(d)}return n}async _generateBodyFromClipboardItems(e){try{let t="",n="";for(const r of e)for(const o of r.types)o===l.PLAIN_TEXT_CLIPBOARD_MIME_TYPE?n=await r.getType(o).then(s=>s&&s.text()):o===l.HTML_CLIPBOARD_MIME_TYPE&&(t=await r.getType(o).then(s=>s&&s.text()));return this._generateBodyFromHtmlAndText(t,n)}catch(t){return Promise.reject(t)}}_generateBodyFromHtmlAndText(e,t){if(!e){if(t)return Ft(t);throw new Error("[DocClipboardService] html and text cannot be both empty!")}const n=Mt(e);if(n){const r=he.get(n);if(r)return r}return this._htmlToUDM.convert(e)}};oe=Bt([A(0,a.IUniverInstanceService),A(1,a.ILogService),A(2,a.ICommandService),A(3,l.IClipboardInterfaceService),A(4,O.Inject(u.TextSelectionManagerService))],oe);function Q(i){return i.getContextValue(a.FOCUSING_DOC)||i.getContextValue(a.EDITOR_ACTIVATED)}const ae=999,$t={id:l.CopyCommand.id,name:"doc.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:ae,preconditions:Q,handler:async i=>i.get(j).copy()},wt={id:l.CutCommand.id,name:"doc.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:ae,preconditions:Q,handler:async i=>i.get(j).cut()},jt={id:l.PasteCommand.id,name:"doc.command.paste",type:a.CommandType.COMMAND,multi:!0,priority:ae,preconditions:Q,handler:async i=>{const e=i.get(j),n=await i.get(l.IClipboardInterfaceService).read();return n.length===0?!1:e.paste(n)}};var zt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,Vt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Wt(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&zt(e,t,r),r},B=(i,e)=>(t,n)=>e(t,n,i);let H=class extends a.RxDisposable{constructor(i,e,t,n,r){super(),this._commandService=i,this._clipboardInterfaceService=e,this._docClipboardService=t,this._textSelectionRenderManager=n,this._contextService=r,this._init()}_init(){[$t,wt,jt].forEach(i=>this.disposeWithMe(this._commandService.registerMultipleCommand(i))),[u.InnerPasteCommand,u.CutContentCommand].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i))),this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var i;this._clipboardInterfaceService.supportClipboard||(i=this._textSelectionRenderManager)==null||i.onPaste$.pipe(T.takeUntil(this.dispose$)).subscribe(e=>{var o,s;if(!Q(this._contextService))return;e.event.preventDefault();const t=e.event,n=(o=t.clipboardData)==null?void 0:o.getData("text/html"),r=(s=t.clipboardData)==null?void 0:s.getData("text/plain");this._docClipboardService.legacyPaste(n,r)})}};H=Vt([a.OnLifecycle(a.LifecycleStages.Steady,H),B(0,a.ICommandService),B(1,l.IClipboardInterfaceService),B(2,j),B(3,C.ITextSelectionRenderManager),B(4,a.IContextService)],H);var Ht=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,Kt=(i,e,t,n)=>{for(var r=n>1?void 0:n?kt(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ht(e,t,r),r},F=(i,e)=>(t,n)=>e(t,n,i);let k=class extends a.Disposable{constructor(e,t,n,r,o){super();v(this,"_initialEditors",new Set);this._currentUniverService=e,this._docSkeletonManagerService=t,this._editorService=n,this._commandService=r,this._textSelectionRenderManager=o,this._initialize()}_initialize(){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()}_resize(e){var U,L,N;if(e==null)return;const t=this._editorService.getEditor(e);if((t==null?void 0:t.cancelDefaultResizeListener)===!0)return;const n=(U=this._docSkeletonManagerService.getSkeletonByUnitId(e))==null?void 0:U.skeleton,r=this._currentUniverService.getUniverDocInstance(e);if(t==null||t.render==null||n==null||r==null)return;const{marginTop:o=0,marginBottom:s=0,marginLeft:c=0,marginRight:d=0}=r.getSnapshot().documentStyle,{scene:h,mainComponent:_}=t.render;let{actualHeight:m,actualWidth:S}=n.getActualSize();m+=o+s,S+=c+d;const{width:I,height:f}=t.getBoundingClientRect(),p=h.getViewport(u.VIEWPORT_KEY.VIEW_MAIN);let g=p==null?void 0:p.getScrollBar();const b=Math.max(S,I),R=Math.max(m,f);h.transformByState({width:b,height:R}),_==null||_.resize(b,R),t.isSingle===!1?m>f?g==null?p&&new C.ScrollBar(p,{enableHorizontal:!1,barSize:8}):p==null||p.resetSizeAndScrollBar():(g=null,p==null||p.scrollTo({x:0,y:0}),(L=p==null?void 0:p.getScrollBar())==null||L.dispose()):S>I?g==null?p&&new C.ScrollBar(p,{barSize:8,enableVertical:!1}):p==null||p.resetSizeAndScrollBar():(g=null,p==null||p.scrollTo({x:0,y:0}),(N=p==null?void 0:p.getScrollBar())==null||N.dispose())}_initialSetValue(){this._editorService.setValue$.subscribe(e=>{this._commandService.executeCommand(u.CoverContentCommand.id,{unitId:e.editorUnitId,body:e.body,segmentId:null})})}_initialBlur(){this._editorService.blur$.subscribe(()=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.blur()})}_initialFocus(){this._editorService.focus$.subscribe(e=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.addTextRanges([e])})}_commandExecutedListener(){const e=[u.RichTextEditingMutation.id,l.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{unitId:r}=n;if(this._editorService.isSheetEditor(r))return;this._resize(r)}}))}};k=Kt([a.OnLifecycle(a.LifecycleStages.Rendered,k),F(0,a.IUniverInstanceService),F(1,O.Inject(u.DocSkeletonManagerService)),F(2,l.IEditorService),F(3,a.ICommandService),F(4,C.ITextSelectionRenderManager)],k);var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,qt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Gt(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Yt(e,t,r),r},W=(i,e)=>(t,n)=>e(t,n,i);let K=class extends a.RxDisposable{constructor(e,t,n,r){super();v(this,"_docRenderMap",new Set);this._docSkeletonManagerService=e,this._renderManagerService=t,this._commandService=n,this._editorService=r,this._initialRenderRefresh(),this._commandExecutedListener()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.pipe(T.takeUntil(this.dispose$)).subscribe(e=>{this._create(e)})}_create(e){if(e==null)return;const{skeleton:t,unitId:n}=e;let r=this._renderManagerService.getRenderById(n);r==null&&(this._renderManagerService.create(n),r=this._renderManagerService.getRenderById(n));const{mainComponent:o}=r;o.changeSkeleton(t),this._recalculateSizeBySkeleton(r,t)}_recalculateSizeBySkeleton(e,t){var _;const{mainComponent:n,scene:r,unitId:o}=e,s=n,c=(_=t.getSkeletonData())==null?void 0:_.pages;if(c==null)return;let d=0,h=0;for(let m=0,S=c.length;m<S;m++){const I=c[m],{pageWidth:f,pageHeight:p}=I;s.pageLayoutType===C.PageLayoutType.VERTICAL?(h+=p,h+=s.pageMarginTop,m===S-1&&(h+=s.pageMarginTop),d=Math.max(d,f)):s.pageLayoutType===C.PageLayoutType.HORIZONTAL&&(d+=f,m!==S-1&&(d+=s.pageMarginLeft),h=Math.max(h,p))}s.resize(d,h),this._editorService.isEditor(o)||r.resize(d,h)}_commandExecutedListener(){const e=[u.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const r=t.params,{unitId:o}=r,s=this._docSkeletonManagerService.getSkeletonByUnitId(o);if(s==null)return;const{skeleton:c}=s,d=this._renderManagerService.getRenderById(o);if(d==null)return;if(c.calculate(),this._editorService.isEditor(o)){(n=d.mainComponent)==null||n.makeDirty();return}this._recalculateSizeBySkeleton(d,c)}}))}};K=qt([a.OnLifecycle(a.LifecycleStages.Rendered,K),W(0,O.Inject(u.DocSkeletonManagerService)),W(1,C.IRenderManagerService),W(2,a.ICommandService),W(3,l.IEditorService)],K);var Xt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Jt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Zt(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Xt(e,t,r),r},ee=(i,e)=>(t,n)=>e(t,n,i);exports.DocCanvasView=class extends a.RxDisposable{constructor(t,n,r){super();v(this,"_scene");v(this,"_currentDocumentModel");v(this,"_fps$",new T.BehaviorSubject(""));v(this,"fps$",this._fps$.asObservable());this._renderManagerService=t,this._configService=n,this._currentUniverService=r,this._initialize()}_initialize(){this._renderManagerService.createRender$.pipe(T.takeUntil(this.dispose$)).subscribe(t=>{this._create(t)}),this._currentUniverService.currentDoc$.pipe(T.takeUntil(this.dispose$)).subscribe(t=>{this._create(t==null?void 0:t.getUnitId())}),this._currentUniverService.getAllUniverDocsInstance().forEach(t=>{this._create(t.getUnitId())})}dispose(){this._fps$.complete()}_create(t){if(t==null)return;const n=this._currentUniverService.getUniverDocInstance(t);n!=null&&(this._currentDocumentModel=n,this._renderManagerService.has(t)||this._addNewRender())}_addNewRender(){const t=this._currentDocumentModel,n=t.getUnitId(),r=t.getContainer(),o=t.getParentRenderUnitId();if(r!=null&&o!=null)throw new Error("container or parentRenderUnitId can only exist one");r==null&&o!=null?this._renderManagerService.createRenderWithParent(n,o):this._renderManagerService.createRender(n);const s=this._renderManagerService.getRenderById(n);if(s==null)return;const{scene:c,engine:d}=s;c.openTransformer(),this._scene=c;const h=new C.Viewport(u.VIEWPORT_KEY.VIEW_MAIN,c,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});c.attachControl(),c.on(C.EVENT_TYPE.wheel,(S,I)=>{const f=S;if(f.ctrlKey){const p=Math.abs(f.deltaX);let g=p<40?.2:p<80?.4:.2;g*=f.deltaY>0?-1:1,c.scaleX<1&&(g/=2),c.scaleX+g>4?c.scale(4,4):c.scaleX+g<.1?c.scale(.1,.1):f.preventDefault()}else h.onMouseWheel(f,I)}),this._configService.getConfig("hasScroll")!==!1&&new C.ScrollBar(h),c.addLayer(new C.Layer(c,[],u.DOCS_COMPONENT_MAIN_LAYER_INDEX),new C.Layer(c,[],u.DOCS_COMPONENT_HEADER_LAYER_INDEX)),this._addComponent(s),this._currentDocumentModel.getShouldRenderLoopImmediately()&&d.runRenderLoop(()=>{c.render(),this._fps$.next(Math.round(d.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(t){const n=this._scene,r=this._currentDocumentModel,o=new C.Documents(u.DOCS_VIEW_KEY.MAIN,void 0,{pageMarginLeft:r.documentStyle.marginLeft||0,pageMarginTop:r.documentStyle.marginTop||0});o.zIndex=u.DOCS_COMPONENT_DEFAULT_Z_INDEX,t.mainComponent=o,t.components.set(u.DOCS_VIEW_KEY.MAIN,o),n.addObjects([o],u.DOCS_COMPONENT_MAIN_LAYER_INDEX)}};exports.DocCanvasView=Jt([a.OnLifecycle(a.LifecycleStages.Starting,exports.DocCanvasView),ee(0,C.IRenderManagerService),ee(1,a.IConfigService),ee(2,a.IUniverInstanceService)],exports.DocCanvasView);var Qt=Object.defineProperty,en=Object.getOwnPropertyDescriptor,tn=(i,e,t,n)=>{for(var r=n>1?void 0:n?en(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Qt(e,t,r),r},x=(i,e)=>(t,n)=>e(t,n,i);let Y=class extends a.Disposable{constructor(e,t,n,r,o,s){super();v(this,"_liquid",new C.Liquid);v(this,"_pageMarginCache",new Map);this._docSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._commandService=r,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:r}=t,o=this._renderManagerService.getRenderById(n);if(o==null)return;const{mainComponent:s,components:c,scene:d}=o,h=s,{left:_,top:m}=h;e.forEach(S=>{const{unitId:I,subUnitId:f,floatingObjectId:p,floatingObject:g}=S,{left:b=0,top:R=0,width:U=0,height:L=0,angle:N,flipX:ce,flipY:le,skewX:de,skewY:ue}=g,y=this._pageMarginCache.get(p),ye=(y==null?void 0:y.marginLeft)||0,De=(y==null?void 0:y.marginTop)||0;r==null||r.getViewModel().getDataModel().updateDrawing(p,{left:b-_-ye,top:R-m-De,height:L,width:U})}),r==null||r.calculate(),s==null||s.makeDirty()})}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{skeleton:t,unitId:n}=e,r=this._renderManagerService.getRenderById(n);if(r==null)return;const{mainComponent:o}=r;o.changeSkeleton(t),this._refreshFloatingObject(n,t,r)})}_commandExecutedListener(){const e=[u.RichTextEditingMutation.id,u.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const r=t.params,{unitId:o}=r,s=this._docSkeletonManagerService.getCurrent();if(s==null)return;const{unitId:c,skeleton:d}=s;if(o!==c)return;const h=this._renderManagerService.getRenderById(c);if(h==null)return;if(this._editorService.isEditor(c)){(n=h.mainComponent)==null||n.makeDirty();return}this._refreshFloatingObject(c,d,h)}}))}_refreshFloatingObject(e,t,n){const r=t==null?void 0:t.getSkeletonData(),{mainComponent:o,scene:s}=n,c=o;if(!r)return;const{left:d,top:h,pageLayoutType:_,pageMarginLeft:m,pageMarginTop:S}=c,{pages:I}=r,f=[];s.getAncestorScale(),this._liquid.reset(),this._pageMarginCache.clear();for(let p=0,g=I.length;p<g;p++){const b=I[p],{skeDrawings:R,marginLeft:U,marginTop:L}=b;this._liquid.translatePagePadding(b),R.forEach(N=>{const{aLeft:ce,aTop:le,height:de,width:ue,objectId:y}=N;f.push({unitId:e,subUnitId:a.DEFAULT_DOCUMENT_SUB_COMPONENT_ID,floatingObjectId:y,floatingObject:{left:ce+d+this._liquid.x,top:le+h+this._liquid.y,width:ue,height:de}}),this._pageMarginCache.set(y,{marginLeft:this._liquid.x,marginTop:this._liquid.y})}),this._liquid.translatePage(b,_,m,S)}this._floatingObjectManagerService.BatchAddOrUpdate(f)}};Y=tn([a.OnLifecycle(a.LifecycleStages.Steady,Y),x(0,O.Inject(u.DocSkeletonManagerService)),x(1,a.IUniverInstanceService),x(2,C.IRenderManagerService),x(3,a.ICommandService),x(4,a.IFloatingObjectManagerService),x(5,l.IEditorService)],Y);var nn=Object.defineProperty,rn=Object.getOwnPropertyDescriptor,on=(i,e,t,n)=>{for(var r=n>1?void 0:n?rn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&nn(e,t,r),r},te=(i,e)=>(t,n)=>e(t,n,i);const sn="rgba(198, 198, 198, 1)",an="rgba(255, 255, 255, 1)";let G=class extends a.Disposable{constructor(i,e,t){super(),this._renderManagerService=i,this._editorService=e,this._currentUniverService=t,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh()}_initialRenderRefresh(){this._renderManagerService.currentRender$.subscribe(i=>{var o;if(i==null)return;const e=this._renderManagerService.getRenderById(i);if(this._editorService.isEditor(i)||this._currentUniverService.getUniverDocInstance(i)==null||e==null)return;const{mainComponent:t}=e,n=t,r=(o=n.getSkeleton())==null?void 0:o.getPageSize();this.disposeWithMe(a.toDisposable(n.onPageRenderObservable.add(s=>{var p,g,b,R;if(this._editorService.isEditor(i))return;const{page:c,pageLeft:d,pageTop:h,ctx:_}=s,{width:m,pageWidth:S,height:I,pageHeight:f}=c;_.save(),_.translate(d-.5,h-.5),C.Rect.drawWith(_,{width:(g=(p=r==null?void 0:r.width)!=null?p:S)!=null?g:m,height:(R=(b=r==null?void 0:r.height)!=null?b:f)!=null?R:I,strokeWidth:1,stroke:sn,fill:an,zIndex:3}),_.restore()})))})}_commandExecutedListener(){}};G=on([a.OnLifecycle(a.LifecycleStages.Rendered,G),te(0,C.IRenderManagerService),te(1,l.IEditorService),te(2,a.IUniverInstanceService)],G);var cn=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,dn=(i,e,t,n)=>{for(var r=n>1?void 0:n?ln(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&cn(e,t,r),r},P=(i,e)=>(t,n)=>e(t,n,i);let q=class extends a.Disposable{constructor(e,t,n,r,o,s){super();v(this,"_initializedRender",new Set);this._docSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._textSelectionManagerService=o,this._editorService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._initialRenderRefresh()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{unitId:t}=e,n=this._renderManagerService.getRenderById(t);if(n==null||this._initializedRender.has(t)||this._editorService.isEditor(t))return;this._initializedRender.add(t);const{scene:r}=n;this.disposeWithMe(a.toDisposable(r.onMouseWheelObserver.add(o=>{if(!o.ctrlKey)return;const s=Math.abs(o.deltaX);let c=s<40?.2:s<80?.4:.2;c*=o.deltaY>0?-1:1,r.scaleX<1&&(c/=2);const d=this._currentUniverService.getCurrentUniverDocInstance(),h=d.zoomRatio;let _=+Number.parseFloat(`${h+c}`).toFixed(1);_=_>=4?4:_<=.1?.1:_,this._commandService.executeCommand(u.SetDocZoomRatioCommand.id,{zoomRatio:_,unitId:d.getUnitId()}),o.preventDefault()})))})}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const n=this._currentUniverService.getCurrentUniverDocInstance().zoomRatio||1;this._updateViewZoom(n,!1)})))}_commandExecutedListener(){const e=[u.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=this._currentUniverService.getCurrentUniverDocInstance(),r=t.params,{unitId:o}=r;if(o!==n.getUnitId())return;const s=n.zoomRatio||1;this._updateViewZoom(s)}}))}_updateViewZoom(e,t=!0){var r;const n=this._getDocObject();n!=null&&(n.scene.scale(e,e),this._calculatePagePosition(n,e),t&&this._textSelectionManagerService.refreshSelection(),(r=n.scene.getTransformer())==null||r.hideControl())}_calculatePagePosition(e,t){const{document:n,scene:r}=e,o=r==null?void 0:r.getParent(),{width:s,height:c,pageMarginLeft:d,pageMarginTop:h}=n;if(o==null||s===Number.POSITIVE_INFINITY||c===Number.POSITIVE_INFINITY)return;const{width:_,height:m}=o;let S=0,I=0,f=0,p=0,g=Number.POSITIVE_INFINITY;_>(s+d*2)*t?(S=_/2-s*t/2,S/=t,f=(_-d*2)/t,g=0):(S=d,f=s+d*2,g=(f-_/t)/2),m>c?(I=m/2-c/2,p=(m-h*2)/t):(I=h,p=c+h*2),r.resize(f,p+200),n.translate(S,I);const b=r.getViewport(u.VIEWPORT_KEY.VIEW_MAIN);if(g!==Number.POSITIVE_INFINITY&&b!=null){const R=b.getBarScroll(g,0).x;b.scrollTo({x:R})}return this}_getDocObject(){return u.getDocObject(this._currentUniverService,this._renderManagerService)}};q=dn([a.OnLifecycle(a.LifecycleStages.Rendered,q),P(0,O.Inject(u.DocSkeletonManagerService)),P(1,a.IUniverInstanceService),P(2,a.ICommandService),P(3,C.IRenderManagerService),P(4,O.Inject(u.TextSelectionManagerService)),P(5,l.IEditorService)],q);var un=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,hn=(i,e,t,n)=>{for(var r=n>1?void 0:n?pn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&un(e,t,r),r},ne=(i,e)=>(t,n)=>e(t,n,i),re;exports.UniverDocsUIPlugin=(re=class extends a.Plugin{constructor(e,t,n,r){super(ve),this._config=e,this._injector=t,this._localeService=n,this._logService=r,this._localeService.load({zhCN:Me}),this._config=a.Tools.deepMerge({},Se,this._config),this._initDependencies(t),this._initializeCommands()}onRendered(){this._initModules(),this._markDocAsFocused()}onDestroy(){}_initializeCommands(){[Ne,Ae,Fe,Be,$e,we,je,ze,We,It,Ot,Ct].forEach(e=>{this._injector.get(l.IShortcutService).registerShortcut(e)})}_initDependencies(e){[[V],[H],[k],[K],[Y],[G],[q],[$,{useFactory:()=>this._injector.createInstance($,this._config)}],[j,{useClass:oe}],[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(),r=n.getUnitId();t.isEditor(r)||e.focusUniverInstance(n.getUnitId())}catch(n){this._logService.warn(n)}}_initModules(){this._injector.get($)}},v(re,"type",a.PluginType.Doc),re);exports.UniverDocsUIPlugin=hn([ne(1,O.Inject(O.Injector)),ne(2,O.Inject(a.LocaleService)),ne(3,a.ILogService)],exports.UniverDocsUIPlugin);exports.DOC_UI_PLUGIN_NAME=ve;exports.DefaultDocContainerConfig=fe;exports.DefaultDocUiConfig=Se;exports.DefaultToolbarConfig=me;exports.enUS=vt;exports.zhCN=Me;
|