@univerjs/docs-ui 0.1.0-beta.3 → 0.1.0-beta.4
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 +1 -1
- package/lib/es/index.js +50 -50
- package/lib/umd/index.js +1 -1
- package/package.json +12 -12
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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 T=(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"),p=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){T(this,"_docContainer");T(this,"getComponent",e=>{if(this._docContainer=e,!e.getContentRef().current)throw new Error("container is not ready")});T(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){T(this,"_docContainerController");T(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 p.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=O(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 p.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=O(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 p.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=O(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 p.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=O(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 p.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=O(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 p.Observable(t=>{const o=n.onCommandExecuted(i=>{var s;const c=i.id;if(c===l.SetTextSelectionsOperation.id||c===l.SetInlineFormatCommand.id){const u=O(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 p.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=O(e);if(d==null)return;const S=(u=d.ts)==null?void 0:u.ff;t.next(S??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 p.Observable(t=>{const i=n.onCommandExecuted(c=>{var u;const s=c.id;if(s===l.SetTextSelectionsOperation.id||s===l.SetInlineFormatFontSizeCommand.id){const d=O(e);if(d==null)return;const S=(u=d.ts)==null?void 0:u.fs;t.next(S??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 p.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??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 O(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:S,ed:E})=>s>=S&&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},_=(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),_(0,m.Inject(m.Injector)),_(1,m.Inject(r.ComponentManager)),_(2,a.ICommandService),_(3,r.IShortcutService),_(4,r.IMenuService),_(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)}},T(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 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;
|
package/lib/es/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var K = Object.defineProperty;
|
|
2
2
|
var G = (e, n, t) => n in e ? K(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
|
|
3
|
-
var
|
|
3
|
+
var h = (e, n, t) => (G(e, typeof n != "symbol" ? n + "" : n, t), t);
|
|
4
4
|
import { LocaleService as U, ICommandService as O, BooleanNumber as M, UniverInstanceType as a, BaselineOffset as j, ThemeService as V, IUniverInstanceService as w, Disposable as X, OnLifecycle as q, LifecycleStages as J, Plugin as Q, Tools as k, PluginType as ee, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as te, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as ne, ILogService as oe } from "@univerjs/core";
|
|
5
5
|
import { Inject as f, Injector as F } from "@wendellhu/redi";
|
|
6
6
|
import { MenuGroup as d, MenuItemType as u, MenuPosition as _, getMenuHiddenObservable as p, FONT_FAMILY_LIST as E, FONT_SIZE_LIST as ie, FontFamily as re, FontFamilyItem as se, FontSize as ce, ComponentManager as le, IShortcutService as ae, IMenuService as de, IUIController as ue } from "@univerjs/ui";
|
|
7
|
-
import { SetInlineFormatBoldCommand as _e, SetTextSelectionsOperation as
|
|
8
|
-
import { Observable as
|
|
7
|
+
import { SetInlineFormatBoldCommand as _e, SetTextSelectionsOperation as C, SetInlineFormatCommand as v, SetInlineFormatItalicCommand as pe, SetInlineFormatUnderlineCommand as Oe, SetInlineFormatStrikethroughCommand as me, SetInlineFormatSubscriptCommand as Te, SetInlineFormatSuperscriptCommand as fe, SetInlineFormatFontFamilyCommand as B, SetInlineFormatFontSizeCommand as N, SetInlineFormatTextColorCommand as P, OrderListCommand as Ce, BulletListCommand as Se, TextSelectionManagerService as he } from "@univerjs/docs";
|
|
8
|
+
import { Observable as T } from "rxjs";
|
|
9
9
|
import { ColorPicker as ge } from "@univerjs/design";
|
|
10
10
|
const ve = {
|
|
11
11
|
undo: !0,
|
|
@@ -61,9 +61,9 @@ var Fe = Object.defineProperty, Ae = Object.getOwnPropertyDescriptor, Le = (e, n
|
|
|
61
61
|
}, b = (e, n) => (t, i) => n(t, i, e);
|
|
62
62
|
let D = class {
|
|
63
63
|
constructor(e, n, t) {
|
|
64
|
-
|
|
64
|
+
h(this, "_docContainer");
|
|
65
65
|
// 获取SheetContainer组件
|
|
66
|
-
|
|
66
|
+
h(this, "getComponent", (e) => {
|
|
67
67
|
if (this._docContainer = e, !e.getContentRef().current)
|
|
68
68
|
throw new Error("container is not ready");
|
|
69
69
|
});
|
|
@@ -74,7 +74,7 @@ let D = class {
|
|
|
74
74
|
* e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
|
|
75
75
|
*
|
|
76
76
|
*/
|
|
77
|
-
|
|
77
|
+
h(this, "changeLocale", (e) => {
|
|
78
78
|
this._localeService.setLocale(e);
|
|
79
79
|
});
|
|
80
80
|
this._config = e, this._localeService = n, this._injector = t;
|
|
@@ -109,7 +109,7 @@ var xe = Object.defineProperty, De = Object.getOwnPropertyDescriptor, Ue = (e, n
|
|
|
109
109
|
}, y = (e, n) => (t, i) => n(t, i, e);
|
|
110
110
|
let R = class {
|
|
111
111
|
constructor(e, n, t) {
|
|
112
|
-
|
|
112
|
+
h(this, "_docContainerController");
|
|
113
113
|
/**
|
|
114
114
|
* Change language
|
|
115
115
|
* @param {String} locale new language
|
|
@@ -117,7 +117,7 @@ let R = class {
|
|
|
117
117
|
* e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
|
|
118
118
|
*
|
|
119
119
|
*/
|
|
120
|
-
|
|
120
|
+
h(this, "changeLocale", (e) => {
|
|
121
121
|
this._localeService.setLocale(e);
|
|
122
122
|
});
|
|
123
123
|
this._localeService = n, this._injector = t, this._docContainerController = this._injector.createInstance(D, e);
|
|
@@ -141,12 +141,12 @@ function Ee(e) {
|
|
|
141
141
|
title: "Set bold",
|
|
142
142
|
tooltip: "toolbar.bold",
|
|
143
143
|
positions: [_.TOOLBAR_START],
|
|
144
|
-
activated$: new
|
|
144
|
+
activated$: new T((t) => {
|
|
145
145
|
const i = n.onCommandExecuted((o) => {
|
|
146
146
|
var r;
|
|
147
147
|
const s = o.id;
|
|
148
|
-
if (s ===
|
|
149
|
-
const c =
|
|
148
|
+
if (s === C.id || s === v.id) {
|
|
149
|
+
const c = S(e);
|
|
150
150
|
if (c == null)
|
|
151
151
|
return;
|
|
152
152
|
const l = (r = c.ts) == null ? void 0 : r.bl;
|
|
@@ -168,12 +168,12 @@ function Be(e) {
|
|
|
168
168
|
title: "Set italic",
|
|
169
169
|
tooltip: "toolbar.italic",
|
|
170
170
|
positions: [_.TOOLBAR_START],
|
|
171
|
-
activated$: new
|
|
171
|
+
activated$: new T((t) => {
|
|
172
172
|
const i = n.onCommandExecuted((o) => {
|
|
173
173
|
var r;
|
|
174
174
|
const s = o.id;
|
|
175
|
-
if (s ===
|
|
176
|
-
const c =
|
|
175
|
+
if (s === C.id || s === v.id) {
|
|
176
|
+
const c = S(e);
|
|
177
177
|
if (c == null)
|
|
178
178
|
return;
|
|
179
179
|
const l = (r = c.ts) == null ? void 0 : r.it;
|
|
@@ -195,12 +195,12 @@ function Ne(e) {
|
|
|
195
195
|
title: "Set underline",
|
|
196
196
|
tooltip: "toolbar.underline",
|
|
197
197
|
positions: [_.TOOLBAR_START],
|
|
198
|
-
activated$: new
|
|
198
|
+
activated$: new T((t) => {
|
|
199
199
|
const i = n.onCommandExecuted((o) => {
|
|
200
200
|
var r;
|
|
201
201
|
const s = o.id;
|
|
202
|
-
if (s ===
|
|
203
|
-
const c =
|
|
202
|
+
if (s === C.id || s === v.id) {
|
|
203
|
+
const c = S(e);
|
|
204
204
|
if (c == null)
|
|
205
205
|
return;
|
|
206
206
|
const l = (r = c.ts) == null ? void 0 : r.ul;
|
|
@@ -222,12 +222,12 @@ function Pe(e) {
|
|
|
222
222
|
title: "Set strike through",
|
|
223
223
|
tooltip: "toolbar.strikethrough",
|
|
224
224
|
positions: [_.TOOLBAR_START],
|
|
225
|
-
activated$: new
|
|
225
|
+
activated$: new T((t) => {
|
|
226
226
|
const i = n.onCommandExecuted((o) => {
|
|
227
227
|
var r;
|
|
228
228
|
const s = o.id;
|
|
229
|
-
if (s ===
|
|
230
|
-
const c =
|
|
229
|
+
if (s === C.id || s === v.id) {
|
|
230
|
+
const c = S(e);
|
|
231
231
|
if (c == null)
|
|
232
232
|
return;
|
|
233
233
|
const l = (r = c.ts) == null ? void 0 : r.st;
|
|
@@ -242,18 +242,18 @@ function Pe(e) {
|
|
|
242
242
|
function be(e) {
|
|
243
243
|
const n = e.get(O);
|
|
244
244
|
return {
|
|
245
|
-
id:
|
|
245
|
+
id: Te.id,
|
|
246
246
|
group: d.TOOLBAR_FORMAT,
|
|
247
247
|
type: u.BUTTON,
|
|
248
248
|
icon: "SubscriptSingle",
|
|
249
249
|
tooltip: "toolbar.subscript",
|
|
250
250
|
positions: [_.TOOLBAR_START],
|
|
251
|
-
activated$: new
|
|
251
|
+
activated$: new T((t) => {
|
|
252
252
|
const i = n.onCommandExecuted((o) => {
|
|
253
253
|
var r;
|
|
254
254
|
const s = o.id;
|
|
255
|
-
if (s ===
|
|
256
|
-
const c =
|
|
255
|
+
if (s === C.id || s === v.id) {
|
|
256
|
+
const c = S(e);
|
|
257
257
|
if (c == null)
|
|
258
258
|
return;
|
|
259
259
|
const l = (r = c.ts) == null ? void 0 : r.va;
|
|
@@ -268,18 +268,18 @@ function be(e) {
|
|
|
268
268
|
function ye(e) {
|
|
269
269
|
const n = e.get(O);
|
|
270
270
|
return {
|
|
271
|
-
id:
|
|
271
|
+
id: fe.id,
|
|
272
272
|
group: d.TOOLBAR_FORMAT,
|
|
273
273
|
type: u.BUTTON,
|
|
274
274
|
icon: "SuperscriptSingle",
|
|
275
275
|
tooltip: "toolbar.superscript",
|
|
276
276
|
positions: [_.TOOLBAR_START],
|
|
277
|
-
activated$: new
|
|
277
|
+
activated$: new T((t) => {
|
|
278
278
|
const i = n.onCommandExecuted((o) => {
|
|
279
279
|
var r;
|
|
280
280
|
const s = o.id;
|
|
281
|
-
if (s ===
|
|
282
|
-
const c =
|
|
281
|
+
if (s === C.id || s === v.id) {
|
|
282
|
+
const c = S(e);
|
|
283
283
|
if (c == null)
|
|
284
284
|
return;
|
|
285
285
|
const l = (r = c.ts) == null ? void 0 : r.va;
|
|
@@ -308,16 +308,16 @@ function $e(e) {
|
|
|
308
308
|
value: t.value
|
|
309
309
|
})),
|
|
310
310
|
// disabled$: getCurrentSheetDisabled$(accessor),
|
|
311
|
-
value$: new
|
|
311
|
+
value$: new T((t) => {
|
|
312
312
|
const i = E[0].value, o = n.onCommandExecuted((s) => {
|
|
313
313
|
var c;
|
|
314
314
|
const r = s.id;
|
|
315
|
-
if (r ===
|
|
316
|
-
const l =
|
|
315
|
+
if (r === C.id || r === B.id) {
|
|
316
|
+
const l = S(e);
|
|
317
317
|
if (l == null)
|
|
318
318
|
return;
|
|
319
|
-
const
|
|
320
|
-
t.next(
|
|
319
|
+
const m = (c = l.ts) == null ? void 0 : c.ff;
|
|
320
|
+
t.next(m != null ? m : i);
|
|
321
321
|
}
|
|
322
322
|
});
|
|
323
323
|
return t.next(i), o.dispose;
|
|
@@ -343,16 +343,16 @@ function je(e) {
|
|
|
343
343
|
positions: [_.TOOLBAR_START],
|
|
344
344
|
selections: ie,
|
|
345
345
|
// disabled$,
|
|
346
|
-
value$: new
|
|
346
|
+
value$: new T((t) => {
|
|
347
347
|
const o = n.onCommandExecuted((s) => {
|
|
348
348
|
var c;
|
|
349
349
|
const r = s.id;
|
|
350
|
-
if (r ===
|
|
351
|
-
const l =
|
|
350
|
+
if (r === C.id || r === N.id) {
|
|
351
|
+
const l = S(e);
|
|
352
352
|
if (l == null)
|
|
353
353
|
return;
|
|
354
|
-
const
|
|
355
|
-
t.next(
|
|
354
|
+
const m = (c = l.ts) == null ? void 0 : c.fs;
|
|
355
|
+
t.next(m != null ? m : 14);
|
|
356
356
|
}
|
|
357
357
|
});
|
|
358
358
|
return t.next(14), o.dispose;
|
|
@@ -377,11 +377,11 @@ function we(e) {
|
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
379
|
],
|
|
380
|
-
value$: new
|
|
380
|
+
value$: new T((i) => {
|
|
381
381
|
const o = t.getCurrentTheme().textColor, s = n.onCommandExecuted((r) => {
|
|
382
382
|
if (r.id === P.id) {
|
|
383
383
|
const c = r.params.value;
|
|
384
|
-
i.next(c
|
|
384
|
+
i.next(c != null ? c : o);
|
|
385
385
|
}
|
|
386
386
|
});
|
|
387
387
|
return i.next(o), s.dispose;
|
|
@@ -412,7 +412,7 @@ function Ye(e) {
|
|
|
412
412
|
hidden$: p(e, a.DOC)
|
|
413
413
|
};
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function S(e) {
|
|
416
416
|
var l;
|
|
417
417
|
const n = e.get(w), t = e.get(he), i = n.getCurrentUniverDocInstance(), o = t.getActiveRange();
|
|
418
418
|
if (i == null || o == null)
|
|
@@ -421,13 +421,13 @@ function C(e) {
|
|
|
421
421
|
if (s == null)
|
|
422
422
|
return;
|
|
423
423
|
const { startOffset: r } = o;
|
|
424
|
-
return s.find(({ st:
|
|
424
|
+
return s.find(({ st: m, ed: H }) => r >= m && r < H);
|
|
425
425
|
}
|
|
426
426
|
var We = Object.defineProperty, Ze = Object.getOwnPropertyDescriptor, He = (e, n, t, i) => {
|
|
427
427
|
for (var o = i > 1 ? void 0 : i ? Ze(n, t) : n, s = e.length - 1, r; s >= 0; s--)
|
|
428
428
|
(r = e[s]) && (o = (i ? r(n, t, o) : r(o)) || o);
|
|
429
429
|
return i && o && We(n, t, o), o;
|
|
430
|
-
},
|
|
430
|
+
}, g = (e, n) => (t, i) => n(t, i, e);
|
|
431
431
|
let I = class extends X {
|
|
432
432
|
constructor(e, n, t, i, o, s) {
|
|
433
433
|
super(), this._injector = e, this._componentManager = n, this._commandService = t, this._shortcutService = i, this._menuService = o, this._uiController = s, this._init();
|
|
@@ -459,12 +459,12 @@ let I = class extends X {
|
|
|
459
459
|
};
|
|
460
460
|
I = He([
|
|
461
461
|
q(J.Rendered, I),
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
462
|
+
g(0, f(F)),
|
|
463
|
+
g(1, f(le)),
|
|
464
|
+
g(2, O),
|
|
465
|
+
g(3, ae),
|
|
466
|
+
g(4, de),
|
|
467
|
+
g(5, ue)
|
|
468
468
|
], I);
|
|
469
469
|
const ot = {
|
|
470
470
|
toolbar: {
|
|
@@ -548,7 +548,7 @@ let $ = (x = class extends Q {
|
|
|
548
548
|
_initModules() {
|
|
549
549
|
this._injector.get(R);
|
|
550
550
|
}
|
|
551
|
-
},
|
|
551
|
+
}, h(x, "type", ee.Doc), x);
|
|
552
552
|
$ = Xe([
|
|
553
553
|
L(1, f(F)),
|
|
554
554
|
L(2, f(U)),
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(d,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","@univerjs/docs","rxjs","@univerjs/design"],r):(d=typeof globalThis<"u"?globalThis:d||self,r(d.UniverDocsUi={},d.UniverCore,d["@wendellhu/redi"],d.UniverUi,d.UniverDocs,d.rxjs,d.UniverDesign))})(this,function(d,r,p,s,c,O,N){"use strict";var le=Object.defineProperty;var ce=(d,r,p)=>r in d?le(d,r,{enumerable:!0,configurable:!0,writable:!0,value:p}):d[r]=p;var _=(d,r,p)=>(ce(d,typeof r!="symbol"?r+"":r,p),p);var M;const R={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},U={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},F={layout:{docContainerConfig:U,toolbarConfig:R}},b="DocUI";var B=Object.defineProperty,$=Object.getOwnPropertyDescriptor,j=(e,n,t,o)=>{for(var i=o>1?void 0:o?$(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&B(n,t,i),i},L=(e,n)=>(t,o)=>n(t,o,e);let g=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}};g=j([L(1,p.Inject(r.LocaleService)),L(2,p.Inject(p.Injector))],g);var w=Object.defineProperty,z=Object.getOwnPropertyDescriptor,G=(e,n,t,o)=>{for(var i=o>1?void 0:o?z(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&w(n,t,i),i},A=(e,n)=>(t,o)=>n(t,o,e);let v=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(g,e)}getDocContainerController(){return this._docContainerController}};v=G([A(1,p.Inject(r.LocaleService)),A(2,p.Inject(p.Injector))],v);const C="UI_PLUGIN_DOCS",y=`${C}_COLOR_PICKER_COMPONENT`,D=`${C}_FONT_FAMILY_COMPONENT`,P=`${C}_FONT_FAMILY_ITEM_COMPONENT`,x=`${C}_FONT_SIZE_COMPONENT`;function H(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatBoldCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.bl;t.next(m===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Y(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatItalicCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.it;t.next(m===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function q(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatUnderlineCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.ul;t.next((m==null?void 0:m.s)===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function W(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatStrikethroughCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.st;t.next((m==null?void 0:m.s)===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Z(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatSubscriptCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"SubscriptSingle",tooltip:"toolbar.subscript",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.va;t.next(m===r.BaselineOffset.SUBSCRIPT)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function K(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatSuperscriptCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"SuperscriptSingle",tooltip:"toolbar.superscript",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.va;t.next(m===r.BaselineOffset.SUPERSCRIPT)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function V(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.SELECTOR,label:D,positions:[s.MenuPosition.TOOLBAR_START],selections:s.FONT_FAMILY_LIST.map(t=>({label:{name:P,hoverable:!0},value:t.value})),value$:new O.Observable(t=>{const o=s.FONT_FAMILY_LIST[0].value,i=n.onCommandExecuted(l=>{var u;const a=l.id;if(a===c.SetTextSelectionsOperation.id||a===c.SetInlineFormatFontFamilyCommand.id){const m=T(e);if(m==null)return;const f=(u=m.ts)==null?void 0:u.ff;t.next(f??o)}});return t.next(o),i.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function X(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatFontSizeCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:x,props:{min:1,max:400}},positions:[s.MenuPosition.TOOLBAR_START],selections:s.FONT_SIZE_LIST,value$:new O.Observable(t=>{const i=n.onCommandExecuted(l=>{var u;const a=l.id;if(a===c.SetTextSelectionsOperation.id||a===c.SetInlineFormatFontSizeCommand.id){const m=T(e);if(m==null)return;const f=(u=m.ts)==null?void 0:u.fs;t.next(f??14)}});return t.next(14),i.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function J(e){const n=e.get(r.ICommandService),t=e.get(r.ThemeService);return{id:c.SetInlineFormatTextColorCommand.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON_SELECTOR,positions:[s.MenuPosition.TOOLBAR_START],selections:[{label:{name:y,hoverable:!1}}],value$:new O.Observable(o=>{const i=t.getCurrentTheme().textColor,l=n.onCommandExecuted(a=>{if(a.id===c.SetInlineFormatTextColorCommand.id){const u=a.params.value;o.next(u??i)}});return o.next(i),l.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Q(e){return{id:c.OrderListCommand.id,group:s.MenuGroup.TOOLBAR_LAYOUT,type:s.MenuItemType.BUTTON,icon:"OrderSingle",tooltip:"toolbar.order",positions:[s.MenuPosition.TOOLBAR_START],hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function k(e){return{id:c.BulletListCommand.id,group:s.MenuGroup.TOOLBAR_LAYOUT,type:s.MenuItemType.BUTTON,icon:"UnorderSingle",tooltip:"toolbar.unorder",positions:[s.MenuPosition.TOOLBAR_START],hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function T(e){var m;const n=e.get(r.IUniverInstanceService),t=e.get(c.TextSelectionManagerService),o=n.getCurrentUniverDocInstance(),i=t.getActiveRange();if(o==null||i==null)return;const l=(m=o.getBody())==null?void 0:m.textRuns;if(l==null)return;const{startOffset:a}=i;return l.find(({st:f,ed:ae})=>a>=f&&a<ae)}var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(e,n,t,o)=>{for(var i=o>1?void 0:o?te(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&ee(n,t,i),i},S=(e,n)=>(t,o)=>n(t,o,e);let I=class extends r.Disposable{constructor(e,n,t,o,i,l){super(),this._injector=e,this._componentManager=n,this._commandService=t,this._shortcutService=o,this._menuService=i,this._uiController=l,this._init()}_initCustomComponents(){const e=this._componentManager;this.disposeWithMe(e.register(y,N.ColorPicker)),this.disposeWithMe(e.register(D,s.FontFamily)),this.disposeWithMe(e.register(P,s.FontFamilyItem)),this.disposeWithMe(e.register(x,s.FontSize))}_initMenus(){[H,Y,q,W,Z,K,X,V,J,Q,k].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e)))})}_init(){this._initCustomComponents(),this._initMenus()}};I=ne([r.OnLifecycle(r.LifecycleStages.Rendered,I),S(0,p.Inject(p.Injector)),S(1,p.Inject(s.ComponentManager)),S(2,r.ICommandService),S(3,s.IShortcutService),S(4,s.IMenuService),S(5,s.IUIController)],I);const oe={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"}},E={toolbar:{undo:"撤销",redo:"重做",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",order:"有序列表",unorder:"无序列表"}};var ie=Object.defineProperty,re=Object.getOwnPropertyDescriptor,se=(e,n,t,o)=>{for(var i=o>1?void 0:o?re(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&ie(n,t,i),i},h=(e,n)=>(t,o)=>n(t,o,e);d.UniverDocsUIPlugin=(M=class extends r.Plugin{constructor(n,t,o,i){super(b),this._config=n,this._injector=t,this._localeService=o,this._logService=i,this._localeService.load({zhCN:E}),this._config=r.Tools.deepMerge({},F,this._config),this._initDependencies(t)}onRendered(){this._initModules(),this._markDocAsFocused()}onDestroy(){}_initDependencies(n){[[I],[v,{useFactory:()=>this._injector.createInstance(v,this._config)}]].forEach(o=>{n.add(o)})}_markDocAsFocused(){const n=this._injector.get(r.IUniverInstanceService);try{const t=n.getCurrentUniverDocInstance(),o=t.getUnitId();o!==r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&o!==r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&n.focusUniverInstance(t.getUnitId())}catch(t){this._logService.warn(t)}}_initModules(){this._injector.get(v)}},_(M,"type",r.PluginType.Doc),M),d.UniverDocsUIPlugin=se([h(1,p.Inject(p.Injector)),h(2,p.Inject(r.LocaleService)),h(3,r.ILogService)],d.UniverDocsUIPlugin),d.DOC_UI_PLUGIN_NAME=b,d.DefaultDocContainerConfig=U,d.DefaultDocUiConfig=F,d.DefaultToolbarConfig=R,d.enUS=oe,d.zhCN=E,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(u,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","@univerjs/docs","rxjs","@univerjs/design"],r):(u=typeof globalThis<"u"?globalThis:u||self,r(u.UniverDocsUi={},u.UniverCore,u["@wendellhu/redi"],u.UniverUi,u.UniverDocs,u.rxjs,u.UniverDesign))})(this,function(u,r,p,s,c,O,N){"use strict";var le=Object.defineProperty;var ce=(u,r,p)=>r in u?le(u,r,{enumerable:!0,configurable:!0,writable:!0,value:p}):u[r]=p;var S=(u,r,p)=>(ce(u,typeof r!="symbol"?r+"":r,p),p);var M;const R={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},U={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},F={layout:{docContainerConfig:U,toolbarConfig:R}},b="DocUI";var B=Object.defineProperty,$=Object.getOwnPropertyDescriptor,j=(e,n,t,o)=>{for(var i=o>1?void 0:o?$(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&B(n,t,i),i},L=(e,n)=>(t,o)=>n(t,o,e);let g=class{constructor(e,n,t){S(this,"_docContainer");S(this,"getComponent",e=>{if(this._docContainer=e,!e.getContentRef().current)throw new Error("container is not ready")});S(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}};g=j([L(1,p.Inject(r.LocaleService)),L(2,p.Inject(p.Injector))],g);var w=Object.defineProperty,z=Object.getOwnPropertyDescriptor,G=(e,n,t,o)=>{for(var i=o>1?void 0:o?z(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&w(n,t,i),i},A=(e,n)=>(t,o)=>n(t,o,e);let C=class{constructor(e,n,t){S(this,"_docContainerController");S(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._localeService=n,this._injector=t,this._docContainerController=this._injector.createInstance(g,e)}getDocContainerController(){return this._docContainerController}};C=G([A(1,p.Inject(r.LocaleService)),A(2,p.Inject(p.Injector))],C);const I="UI_PLUGIN_DOCS",y=`${I}_COLOR_PICKER_COMPONENT`,D=`${I}_FONT_FAMILY_COMPONENT`,P=`${I}_FONT_FAMILY_ITEM_COMPONENT`,x=`${I}_FONT_SIZE_COMPONENT`;function H(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatBoldCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const d=_(e);if(d==null)return;const m=(a=d.ts)==null?void 0:a.bl;t.next(m===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Y(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatItalicCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const d=_(e);if(d==null)return;const m=(a=d.ts)==null?void 0:a.it;t.next(m===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function q(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatUnderlineCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const d=_(e);if(d==null)return;const m=(a=d.ts)==null?void 0:a.ul;t.next((m==null?void 0:m.s)===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function W(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatStrikethroughCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const d=_(e);if(d==null)return;const m=(a=d.ts)==null?void 0:a.st;t.next((m==null?void 0:m.s)===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Z(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatSubscriptCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"SubscriptSingle",tooltip:"toolbar.subscript",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const d=_(e);if(d==null)return;const m=(a=d.ts)==null?void 0:a.va;t.next(m===r.BaselineOffset.SUBSCRIPT)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function K(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatSuperscriptCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"SuperscriptSingle",tooltip:"toolbar.superscript",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const d=_(e);if(d==null)return;const m=(a=d.ts)==null?void 0:a.va;t.next(m===r.BaselineOffset.SUPERSCRIPT)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function V(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.SELECTOR,label:D,positions:[s.MenuPosition.TOOLBAR_START],selections:s.FONT_FAMILY_LIST.map(t=>({label:{name:P,hoverable:!0},value:t.value})),value$:new O.Observable(t=>{const o=s.FONT_FAMILY_LIST[0].value,i=n.onCommandExecuted(l=>{var d;const a=l.id;if(a===c.SetTextSelectionsOperation.id||a===c.SetInlineFormatFontFamilyCommand.id){const m=_(e);if(m==null)return;const T=(d=m.ts)==null?void 0:d.ff;t.next(T!=null?T:o)}});return t.next(o),i.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function X(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatFontSizeCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:x,props:{min:1,max:400}},positions:[s.MenuPosition.TOOLBAR_START],selections:s.FONT_SIZE_LIST,value$:new O.Observable(t=>{const i=n.onCommandExecuted(l=>{var d;const a=l.id;if(a===c.SetTextSelectionsOperation.id||a===c.SetInlineFormatFontSizeCommand.id){const m=_(e);if(m==null)return;const T=(d=m.ts)==null?void 0:d.fs;t.next(T!=null?T:14)}});return t.next(14),i.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function J(e){const n=e.get(r.ICommandService),t=e.get(r.ThemeService);return{id:c.SetInlineFormatTextColorCommand.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON_SELECTOR,positions:[s.MenuPosition.TOOLBAR_START],selections:[{label:{name:y,hoverable:!1}}],value$:new O.Observable(o=>{const i=t.getCurrentTheme().textColor,l=n.onCommandExecuted(a=>{if(a.id===c.SetInlineFormatTextColorCommand.id){const d=a.params.value;o.next(d!=null?d:i)}});return o.next(i),l.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Q(e){return{id:c.OrderListCommand.id,group:s.MenuGroup.TOOLBAR_LAYOUT,type:s.MenuItemType.BUTTON,icon:"OrderSingle",tooltip:"toolbar.order",positions:[s.MenuPosition.TOOLBAR_START],hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function k(e){return{id:c.BulletListCommand.id,group:s.MenuGroup.TOOLBAR_LAYOUT,type:s.MenuItemType.BUTTON,icon:"UnorderSingle",tooltip:"toolbar.unorder",positions:[s.MenuPosition.TOOLBAR_START],hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function _(e){var m;const n=e.get(r.IUniverInstanceService),t=e.get(c.TextSelectionManagerService),o=n.getCurrentUniverDocInstance(),i=t.getActiveRange();if(o==null||i==null)return;const l=(m=o.getBody())==null?void 0:m.textRuns;if(l==null)return;const{startOffset:a}=i;return l.find(({st:T,ed:ae})=>a>=T&&a<ae)}var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(e,n,t,o)=>{for(var i=o>1?void 0:o?te(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&ee(n,t,i),i},v=(e,n)=>(t,o)=>n(t,o,e);let f=class extends r.Disposable{constructor(e,n,t,o,i,l){super(),this._injector=e,this._componentManager=n,this._commandService=t,this._shortcutService=o,this._menuService=i,this._uiController=l,this._init()}_initCustomComponents(){const e=this._componentManager;this.disposeWithMe(e.register(y,N.ColorPicker)),this.disposeWithMe(e.register(D,s.FontFamily)),this.disposeWithMe(e.register(P,s.FontFamilyItem)),this.disposeWithMe(e.register(x,s.FontSize))}_initMenus(){[H,Y,q,W,Z,K,X,V,J,Q,k].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e)))})}_init(){this._initCustomComponents(),this._initMenus()}};f=ne([r.OnLifecycle(r.LifecycleStages.Rendered,f),v(0,p.Inject(p.Injector)),v(1,p.Inject(s.ComponentManager)),v(2,r.ICommandService),v(3,s.IShortcutService),v(4,s.IMenuService),v(5,s.IUIController)],f);const oe={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"}},E={toolbar:{undo:"撤销",redo:"重做",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",order:"有序列表",unorder:"无序列表"}};var ie=Object.defineProperty,re=Object.getOwnPropertyDescriptor,se=(e,n,t,o)=>{for(var i=o>1?void 0:o?re(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&ie(n,t,i),i},h=(e,n)=>(t,o)=>n(t,o,e);u.UniverDocsUIPlugin=(M=class extends r.Plugin{constructor(n,t,o,i){super(b),this._config=n,this._injector=t,this._localeService=o,this._logService=i,this._localeService.load({zhCN:E}),this._config=r.Tools.deepMerge({},F,this._config),this._initDependencies(t)}onRendered(){this._initModules(),this._markDocAsFocused()}onDestroy(){}_initDependencies(n){[[f],[C,{useFactory:()=>this._injector.createInstance(C,this._config)}]].forEach(o=>{n.add(o)})}_markDocAsFocused(){const n=this._injector.get(r.IUniverInstanceService);try{const t=n.getCurrentUniverDocInstance(),o=t.getUnitId();o!==r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&o!==r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&n.focusUniverInstance(t.getUnitId())}catch(t){this._logService.warn(t)}}_initModules(){this._injector.get(C)}},S(M,"type",r.PluginType.Doc),M),u.UniverDocsUIPlugin=se([h(1,p.Inject(p.Injector)),h(2,p.Inject(r.LocaleService)),h(3,r.ILogService)],u.UniverDocsUIPlugin),u.DOC_UI_PLUGIN_NAME=b,u.DefaultDocContainerConfig=U,u.DefaultDocUiConfig=F,u.DefaultToolbarConfig=R,u.enUS=oe,u.zhCN=E,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-ui",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer normal ui-plugin-docs",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@wendellhu/redi": ">=0.12.13",
|
|
43
43
|
"react": ">=16.9.0",
|
|
44
|
-
"@univerjs/
|
|
45
|
-
"@univerjs/
|
|
46
|
-
"@univerjs/
|
|
47
|
-
"@univerjs/
|
|
48
|
-
"@univerjs/
|
|
44
|
+
"@univerjs/core": "0.1.0-beta.4",
|
|
45
|
+
"@univerjs/design": "0.1.0-beta.4",
|
|
46
|
+
"@univerjs/docs": "0.1.0-beta.4",
|
|
47
|
+
"@univerjs/ui": "0.1.0-beta.4",
|
|
48
|
+
"@univerjs/engine-render": "0.1.0-beta.4"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {},
|
|
51
51
|
"devDependencies": {
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"typescript": "^5.3.3",
|
|
58
58
|
"vite": "^5.0.12",
|
|
59
59
|
"vitest": "^1.2.1",
|
|
60
|
-
"@univerjs/core": "0.1.0-beta.
|
|
61
|
-
"@univerjs/design": "0.1.0-beta.
|
|
62
|
-
"@univerjs/docs": "0.1.0-beta.
|
|
63
|
-
"@univerjs/
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/ui": "0.1.0-beta.
|
|
60
|
+
"@univerjs/core": "0.1.0-beta.4",
|
|
61
|
+
"@univerjs/design": "0.1.0-beta.4",
|
|
62
|
+
"@univerjs/docs": "0.1.0-beta.4",
|
|
63
|
+
"@univerjs/engine-render": "0.1.0-beta.4",
|
|
64
|
+
"@univerjs/shared": "0.1.0-beta.4",
|
|
65
|
+
"@univerjs/ui": "0.1.0-beta.4"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"test": "vitest run",
|