@univerjs/docs-ui 0.1.0-alpha.3 → 0.1.0-beta.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 +1 -1
- package/lib/es/index.js +130 -116
- package/lib/types/docs-ui-plugin.d.ts +3 -2
- package/lib/umd/index.js +1 -1
- package/package.json +19 -17
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var U=Object.defineProperty;var D=(e,t,n)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var d=(e,t,n)=>(D(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),a=require("@wendellhu/redi"),r=require("@univerjs/ui"),l=require("@univerjs/docs"),v={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},C={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},M={layout:{docContainerConfig:C,toolbarConfig:v}},S="DocUI";var b=Object.defineProperty,R=Object.getOwnPropertyDescriptor,y=(e,t,n,o)=>{for(var i=o>1?void 0:o?R(t,n):t,s=e.length-1,u;s>=0;s--)(u=e[s])&&(i=(o?u(t,n,i):u(i))||i);return o&&i&&b(t,n,i),i},f=(e,t)=>(n,o)=>t(n,o,e);let T=class{constructor(e,t,n){d(this,"_docContainer");d(this,"getComponent",e=>{if(this._docContainer=e,!e.getContentRef().current)throw new Error("container is not ready")});d(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._config=e,this._localeService=t,this._injector=n}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}};T=y([f(1,a.Inject(c.LocaleService)),f(2,a.Inject(a.Injector))],T);var A=Object.defineProperty,L=Object.getOwnPropertyDescriptor,P=(e,t,n,o)=>{for(var i=o>1?void 0:o?L(t,n):t,s=e.length-1,u;s>=0;s--)(u=e[s])&&(i=(o?u(t,n,i):u(i))||i);return o&&i&&A(t,n,i),i},I=(e,t)=>(n,o)=>t(n,o,e);let _=class{constructor(e,t,n){d(this,"_docContainerController");d(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._localeService=t,this._injector=n,this._docContainerController=this._injector.createInstance(T,e)}getDocContainerController(){return this._docContainerController}};_=P([I(1,a.Inject(c.LocaleService)),I(2,a.Inject(a.Injector))],_);function j(e){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],hidden$:r.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function B(e){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],hidden$:r.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function F(e){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],hidden$:r.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function $(e){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],hidden$:r.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function N(e){return{id:l.SetInlineFormatSubscriptCommand.id,group:r.MenuGroup.TOOLBAR_FORMAT,type:r.MenuItemType.BUTTON,icon:"SubscriptSingle",tooltip:"toolbar.subscript",positions:[r.MenuPosition.TOOLBAR_START],hidden$:r.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function w(e){return{id:l.SetInlineFormatSuperscriptCommand.id,group:r.MenuGroup.TOOLBAR_FORMAT,type:r.MenuItemType.BUTTON,icon:"SuperscriptSingle",tooltip:"toolbar.superscript",positions:[r.MenuPosition.TOOLBAR_START],hidden$:r.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function H(e){return{id:l.OrderListCommand.id,group:r.MenuGroup.TOOLBAR_LAYOUT,type:r.MenuItemType.BUTTON,icon:"OrderSingle",tooltip:"toolbar.superscript",positions:[r.MenuPosition.TOOLBAR_START],hidden$:r.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function G(e){return{id:l.BulletListCommand.id,group:r.MenuGroup.TOOLBAR_LAYOUT,type:r.MenuItemType.BUTTON,icon:"UnorderSingle",tooltip:"toolbar.superscript",positions:[r.MenuPosition.TOOLBAR_START],hidden$:r.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}var E=Object.defineProperty,z=Object.getOwnPropertyDescriptor,x=(e,t,n,o)=>{for(var i=o>1?void 0:o?z(t,n):t,s=e.length-1,u;s>=0;s--)(u=e[s])&&(i=(o?u(t,n,i):u(i))||i);return o&&i&&E(t,n,i),i},p=(e,t)=>(n,o)=>t(n,o,e);let O=class extends c.Disposable{constructor(e,t,n,o,i,s){super(),this._injector=e,this._componentManager=t,this._commandService=n,this._shortcutService=o,this._menuService=i,this._uiController=s,this._init()}_init(){[j,B,F,$,N,w,H,G].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e)))})}};O=x([c.OnLifecycle(c.LifecycleStages.Rendered,O),p(0,a.Inject(a.Injector)),p(1,a.Inject(r.ComponentManager)),p(2,c.ICommandService),p(3,r.IShortcutService),p(4,r.IMenuService),p(5,r.IUIController)],O);const q={},m={};var Y=Object.defineProperty,K=Object.getOwnPropertyDescriptor,W=(e,t,n,o)=>{for(var i=o>1?void 0:o?K(t,n):t,s=e.length-1,u;s>=0;s--)(u=e[s])&&(i=(o?u(t,n,i):u(i))||i);return o&&i&&Y(t,n,i),i},g=(e,t)=>(n,o)=>t(n,o,e),h;exports.UniverDocsUIPlugin=(h=class extends c.Plugin{constructor(t,n,o,i){super(S),this._config=t,this._injector=n,this._localeService=o,this._logService=i,this._localeService.load({zhCN:m}),this._config=c.Tools.deepMerge({},M,this._config),this._initDependencies(n)}onRendered(){this._initModules(),this._markDocAsFocused()}onDestroy(){}_initDependencies(t){[[O],[_,{useFactory:()=>this._injector.createInstance(_,this._config)}]].forEach(o=>{t.add(o)})}_markDocAsFocused(){const t=this._injector.get(c.IUniverInstanceService);try{const n=t.getCurrentUniverDocInstance(),o=n.getUnitId();o!==c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&o!==c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&t.focusUniverInstance(n.getUnitId())}catch(n){this._logService.warn(n)}}_initModules(){this._injector.get(_)}},d(h,"type",c.PluginType.Doc),h);exports.UniverDocsUIPlugin=W([g(1,a.Inject(a.Injector)),g(2,a.Inject(c.LocaleService)),g(3,c.ILogService)],exports.UniverDocsUIPlugin);exports.DOC_UI_PLUGIN_NAME=S;exports.DefaultDocContainerConfig=C;exports.DefaultDocUiConfig=M;exports.DefaultToolbarConfig=v;exports.enUS=q;exports.zhCN=m;
|
package/lib/es/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { LocaleService as
|
|
5
|
-
import { Inject as s, Injector as
|
|
6
|
-
import { MenuGroup as a, MenuItemType as
|
|
7
|
-
import { SetInlineFormatBoldCommand as
|
|
8
|
-
const
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var A = (e, t, o) => t in e ? D(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
|
3
|
+
var p = (e, t, o) => (A(e, typeof t != "symbol" ? t + "" : t, o), o);
|
|
4
|
+
import { LocaleService as m, UniverInstanceType as l, Disposable as L, OnLifecycle as U, LifecycleStages as M, ICommandService as B, Plugin as b, Tools as y, PluginType as P, IUniverInstanceService as F, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as j, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as $, ILogService as N } from "@univerjs/core";
|
|
5
|
+
import { Inject as s, Injector as g } from "@wendellhu/redi";
|
|
6
|
+
import { MenuGroup as a, MenuItemType as u, MenuPosition as _, getMenuHiddenObservable as d, ComponentManager as w, IShortcutService as E, IMenuService as z, IUIController as x } from "@univerjs/ui";
|
|
7
|
+
import { SetInlineFormatBoldCommand as H, SetInlineFormatItalicCommand as Y, SetInlineFormatUnderlineCommand as G, SetInlineFormatStrikethroughCommand as K, SetInlineFormatSubscriptCommand as W, SetInlineFormatSuperscriptCommand as q, OrderListCommand as J, BulletListCommand as Q } from "@univerjs/docs";
|
|
8
|
+
const V = {
|
|
9
9
|
undo: !0,
|
|
10
10
|
redo: !0,
|
|
11
11
|
// Undo redo
|
|
@@ -33,7 +33,7 @@ const q = {
|
|
|
33
33
|
// 'Wrap mode'
|
|
34
34
|
textRotateMode: !0
|
|
35
35
|
// 'Text Rotation Mode'
|
|
36
|
-
},
|
|
36
|
+
}, X = {
|
|
37
37
|
outerLeft: !1,
|
|
38
38
|
outerRight: !1,
|
|
39
39
|
header: !0,
|
|
@@ -46,22 +46,22 @@ const q = {
|
|
|
46
46
|
frozenContent: !1,
|
|
47
47
|
infoBar: !0,
|
|
48
48
|
toolbar: !0
|
|
49
|
-
},
|
|
49
|
+
}, Z = {
|
|
50
50
|
layout: {
|
|
51
|
-
docContainerConfig:
|
|
52
|
-
toolbarConfig:
|
|
51
|
+
docContainerConfig: X,
|
|
52
|
+
toolbarConfig: V
|
|
53
53
|
}
|
|
54
|
-
},
|
|
55
|
-
var
|
|
56
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
54
|
+
}, k = "DocUI";
|
|
55
|
+
var ee = Object.defineProperty, te = Object.getOwnPropertyDescriptor, oe = (e, t, o, n) => {
|
|
56
|
+
for (var r = n > 1 ? void 0 : n ? te(t, o) : t, i = e.length - 1, c; i >= 0; i--)
|
|
57
57
|
(c = e[i]) && (r = (n ? c(t, o, r) : c(r)) || r);
|
|
58
|
-
return n && r &&
|
|
59
|
-
},
|
|
60
|
-
let
|
|
58
|
+
return n && r && ee(t, o, r), r;
|
|
59
|
+
}, v = (e, t) => (o, n) => t(o, n, e);
|
|
60
|
+
let S = class {
|
|
61
61
|
constructor(e, t, o) {
|
|
62
|
-
|
|
62
|
+
p(this, "_docContainer");
|
|
63
63
|
// 获取SheetContainer组件
|
|
64
|
-
|
|
64
|
+
p(this, "getComponent", (e) => {
|
|
65
65
|
if (this._docContainer = e, !e.getContentRef().current)
|
|
66
66
|
throw new Error("container is not ready");
|
|
67
67
|
});
|
|
@@ -72,7 +72,7 @@ let g = class {
|
|
|
72
72
|
* e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
|
|
73
73
|
*
|
|
74
74
|
*/
|
|
75
|
-
|
|
75
|
+
p(this, "changeLocale", (e) => {
|
|
76
76
|
this._localeService.setLocale(e);
|
|
77
77
|
});
|
|
78
78
|
this._config = e, this._localeService = t, this._injector = o;
|
|
@@ -96,18 +96,18 @@ let g = class {
|
|
|
96
96
|
return this._docContainer;
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
],
|
|
103
|
-
var
|
|
104
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
99
|
+
S = oe([
|
|
100
|
+
v(1, s(m)),
|
|
101
|
+
v(2, s(g))
|
|
102
|
+
], S);
|
|
103
|
+
var re = Object.defineProperty, ne = Object.getOwnPropertyDescriptor, ie = (e, t, o, n) => {
|
|
104
|
+
for (var r = n > 1 ? void 0 : n ? ne(t, o) : t, i = e.length - 1, c; i >= 0; i--)
|
|
105
105
|
(c = e[i]) && (r = (n ? c(t, o, r) : c(r)) || r);
|
|
106
|
-
return n && r &&
|
|
107
|
-
},
|
|
108
|
-
let
|
|
106
|
+
return n && r && re(t, o, r), r;
|
|
107
|
+
}, I = (e, t) => (o, n) => t(o, n, e);
|
|
108
|
+
let O = class {
|
|
109
109
|
constructor(e, t, o) {
|
|
110
|
-
|
|
110
|
+
p(this, "_docContainerController");
|
|
111
111
|
/**
|
|
112
112
|
* Change language
|
|
113
113
|
* @param {String} locale new language
|
|
@@ -115,147 +115,155 @@ let d = class {
|
|
|
115
115
|
* e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
|
|
116
116
|
*
|
|
117
117
|
*/
|
|
118
|
-
|
|
118
|
+
p(this, "changeLocale", (e) => {
|
|
119
119
|
this._localeService.setLocale(e);
|
|
120
120
|
});
|
|
121
|
-
this._localeService = t, this._injector = o, this._docContainerController = this._injector.createInstance(
|
|
121
|
+
this._localeService = t, this._injector = o, this._docContainerController = this._injector.createInstance(S, e);
|
|
122
122
|
}
|
|
123
123
|
getDocContainerController() {
|
|
124
124
|
return this._docContainerController;
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
],
|
|
131
|
-
function
|
|
127
|
+
O = ie([
|
|
128
|
+
I(1, s(m)),
|
|
129
|
+
I(2, s(g))
|
|
130
|
+
], O);
|
|
131
|
+
function ce(e) {
|
|
132
132
|
return {
|
|
133
|
-
id:
|
|
133
|
+
id: H.id,
|
|
134
134
|
group: a.TOOLBAR_FORMAT,
|
|
135
|
-
type:
|
|
135
|
+
type: u.BUTTON,
|
|
136
136
|
icon: "BoldSingle",
|
|
137
137
|
title: "Set bold",
|
|
138
138
|
tooltip: "toolbar.bold",
|
|
139
|
-
positions: [
|
|
139
|
+
positions: [_.TOOLBAR_START],
|
|
140
|
+
hidden$: d(e, l.DOC)
|
|
140
141
|
};
|
|
141
142
|
}
|
|
142
|
-
function
|
|
143
|
+
function se(e) {
|
|
143
144
|
return {
|
|
144
|
-
id:
|
|
145
|
+
id: Y.id,
|
|
145
146
|
group: a.TOOLBAR_FORMAT,
|
|
146
|
-
type:
|
|
147
|
+
type: u.BUTTON,
|
|
147
148
|
icon: "ItalicSingle",
|
|
148
149
|
title: "Set italic",
|
|
149
150
|
tooltip: "toolbar.italic",
|
|
150
|
-
positions: [
|
|
151
|
+
positions: [_.TOOLBAR_START],
|
|
152
|
+
hidden$: d(e, l.DOC)
|
|
151
153
|
};
|
|
152
154
|
}
|
|
153
|
-
function
|
|
155
|
+
function le(e) {
|
|
154
156
|
return {
|
|
155
|
-
id:
|
|
157
|
+
id: G.id,
|
|
156
158
|
group: a.TOOLBAR_FORMAT,
|
|
157
|
-
type:
|
|
159
|
+
type: u.BUTTON,
|
|
158
160
|
icon: "UnderlineSingle",
|
|
159
161
|
title: "Set underline",
|
|
160
162
|
tooltip: "toolbar.underline",
|
|
161
|
-
positions: [
|
|
163
|
+
positions: [_.TOOLBAR_START],
|
|
164
|
+
hidden$: d(e, l.DOC)
|
|
162
165
|
};
|
|
163
166
|
}
|
|
164
|
-
function
|
|
167
|
+
function ae(e) {
|
|
165
168
|
return {
|
|
166
|
-
id:
|
|
169
|
+
id: K.id,
|
|
167
170
|
group: a.TOOLBAR_FORMAT,
|
|
168
|
-
type:
|
|
171
|
+
type: u.BUTTON,
|
|
169
172
|
icon: "StrikethroughSingle",
|
|
170
173
|
title: "Set strike through",
|
|
171
174
|
tooltip: "toolbar.strikethrough",
|
|
172
|
-
positions: [
|
|
175
|
+
positions: [_.TOOLBAR_START],
|
|
176
|
+
hidden$: d(e, l.DOC)
|
|
173
177
|
};
|
|
174
178
|
}
|
|
175
|
-
function
|
|
179
|
+
function ue(e) {
|
|
176
180
|
return {
|
|
177
|
-
id:
|
|
181
|
+
id: W.id,
|
|
178
182
|
group: a.TOOLBAR_FORMAT,
|
|
179
|
-
type:
|
|
180
|
-
icon: "
|
|
183
|
+
type: u.BUTTON,
|
|
184
|
+
icon: "SubscriptSingle",
|
|
181
185
|
tooltip: "toolbar.subscript",
|
|
182
|
-
positions: [
|
|
186
|
+
positions: [_.TOOLBAR_START],
|
|
187
|
+
hidden$: d(e, l.DOC)
|
|
183
188
|
};
|
|
184
189
|
}
|
|
185
|
-
function
|
|
190
|
+
function _e(e) {
|
|
186
191
|
return {
|
|
187
|
-
id:
|
|
192
|
+
id: q.id,
|
|
188
193
|
group: a.TOOLBAR_FORMAT,
|
|
189
|
-
type:
|
|
190
|
-
icon: "
|
|
194
|
+
type: u.BUTTON,
|
|
195
|
+
icon: "SuperscriptSingle",
|
|
191
196
|
tooltip: "toolbar.superscript",
|
|
192
|
-
positions: [
|
|
197
|
+
positions: [_.TOOLBAR_START],
|
|
198
|
+
hidden$: d(e, l.DOC)
|
|
193
199
|
};
|
|
194
200
|
}
|
|
195
|
-
function
|
|
201
|
+
function de(e) {
|
|
196
202
|
return {
|
|
197
|
-
id:
|
|
203
|
+
id: J.id,
|
|
198
204
|
group: a.TOOLBAR_LAYOUT,
|
|
199
|
-
type:
|
|
205
|
+
type: u.BUTTON,
|
|
200
206
|
icon: "OrderSingle",
|
|
201
207
|
tooltip: "toolbar.superscript",
|
|
202
|
-
positions: [
|
|
208
|
+
positions: [_.TOOLBAR_START],
|
|
209
|
+
hidden$: d(e, l.DOC)
|
|
203
210
|
};
|
|
204
211
|
}
|
|
205
|
-
function
|
|
212
|
+
function pe(e) {
|
|
206
213
|
return {
|
|
207
|
-
id:
|
|
214
|
+
id: Q.id,
|
|
208
215
|
group: a.TOOLBAR_LAYOUT,
|
|
209
|
-
type:
|
|
216
|
+
type: u.BUTTON,
|
|
210
217
|
icon: "UnorderSingle",
|
|
211
218
|
tooltip: "toolbar.superscript",
|
|
212
|
-
positions: [
|
|
219
|
+
positions: [_.TOOLBAR_START],
|
|
220
|
+
hidden$: d(e, l.DOC)
|
|
213
221
|
};
|
|
214
222
|
}
|
|
215
|
-
var
|
|
216
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
223
|
+
var he = Object.defineProperty, Oe = Object.getOwnPropertyDescriptor, fe = (e, t, o, n) => {
|
|
224
|
+
for (var r = n > 1 ? void 0 : n ? Oe(t, o) : t, i = e.length - 1, c; i >= 0; i--)
|
|
217
225
|
(c = e[i]) && (r = (n ? c(t, o, r) : c(r)) || r);
|
|
218
|
-
return n && r &&
|
|
219
|
-
},
|
|
220
|
-
let f = class extends
|
|
226
|
+
return n && r && he(t, o, r), r;
|
|
227
|
+
}, h = (e, t) => (o, n) => t(o, n, e);
|
|
228
|
+
let f = class extends L {
|
|
221
229
|
constructor(e, t, o, n, r, i) {
|
|
222
230
|
super(), this._injector = e, this._componentManager = t, this._commandService = o, this._shortcutService = n, this._menuService = r, this._uiController = i, this._init();
|
|
223
231
|
}
|
|
224
232
|
_init() {
|
|
225
233
|
[
|
|
226
|
-
re,
|
|
227
|
-
ne,
|
|
228
|
-
ie,
|
|
229
234
|
ce,
|
|
230
235
|
se,
|
|
231
|
-
ae,
|
|
232
236
|
le,
|
|
233
|
-
|
|
237
|
+
ae,
|
|
238
|
+
ue,
|
|
239
|
+
_e,
|
|
240
|
+
de,
|
|
241
|
+
pe
|
|
234
242
|
].forEach((e) => {
|
|
235
243
|
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e)));
|
|
236
244
|
});
|
|
237
245
|
}
|
|
238
246
|
};
|
|
239
|
-
f =
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
+
f = fe([
|
|
248
|
+
U(M.Rendered, f),
|
|
249
|
+
h(0, s(g)),
|
|
250
|
+
h(1, s(w)),
|
|
251
|
+
h(2, B),
|
|
252
|
+
h(3, E),
|
|
253
|
+
h(4, z),
|
|
254
|
+
h(5, x)
|
|
247
255
|
], f);
|
|
248
|
-
const
|
|
249
|
-
var
|
|
250
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
256
|
+
const Ae = {}, ge = {};
|
|
257
|
+
var Te = Object.defineProperty, Ce = Object.getOwnPropertyDescriptor, Se = (e, t, o, n) => {
|
|
258
|
+
for (var r = n > 1 ? void 0 : n ? Ce(t, o) : t, i = e.length - 1, c; i >= 0; i--)
|
|
251
259
|
(c = e[i]) && (r = (n ? c(t, o, r) : c(r)) || r);
|
|
252
|
-
return n && r &&
|
|
253
|
-
},
|
|
254
|
-
let
|
|
255
|
-
constructor(e, t, o) {
|
|
256
|
-
super(
|
|
257
|
-
zhCN:
|
|
258
|
-
}), this._config =
|
|
260
|
+
return n && r && Te(t, o, r), r;
|
|
261
|
+
}, T = (e, t) => (o, n) => t(o, n, e), C;
|
|
262
|
+
let R = (C = class extends b {
|
|
263
|
+
constructor(e, t, o, n) {
|
|
264
|
+
super(k), this._config = e, this._injector = t, this._localeService = o, this._logService = n, this._localeService.load({
|
|
265
|
+
zhCN: ge
|
|
266
|
+
}), this._config = y.deepMerge({}, Z, this._config), this._initDependencies(t);
|
|
259
267
|
}
|
|
260
268
|
onRendered() {
|
|
261
269
|
this._initModules(), this._markDocAsFocused();
|
|
@@ -267,9 +275,9 @@ let v = (h = class extends M {
|
|
|
267
275
|
[f],
|
|
268
276
|
[
|
|
269
277
|
// controllers
|
|
270
|
-
|
|
278
|
+
O,
|
|
271
279
|
{
|
|
272
|
-
useFactory: () => this._injector.createInstance(
|
|
280
|
+
useFactory: () => this._injector.createInstance(O, this._config)
|
|
273
281
|
}
|
|
274
282
|
]
|
|
275
283
|
].forEach((o) => {
|
|
@@ -277,23 +285,29 @@ let v = (h = class extends M {
|
|
|
277
285
|
});
|
|
278
286
|
}
|
|
279
287
|
_markDocAsFocused() {
|
|
280
|
-
const e = this._injector.get(F)
|
|
281
|
-
|
|
288
|
+
const e = this._injector.get(F);
|
|
289
|
+
try {
|
|
290
|
+
const t = e.getCurrentUniverDocInstance(), o = t.getUnitId();
|
|
291
|
+
o !== j && o !== $ && e.focusUniverInstance(t.getUnitId());
|
|
292
|
+
} catch (t) {
|
|
293
|
+
this._logService.warn(t);
|
|
294
|
+
}
|
|
282
295
|
}
|
|
283
296
|
_initModules() {
|
|
284
|
-
this._injector.get(
|
|
297
|
+
this._injector.get(O);
|
|
285
298
|
}
|
|
286
|
-
},
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
299
|
+
}, p(C, "type", P.Doc), C);
|
|
300
|
+
R = Se([
|
|
301
|
+
T(1, s(g)),
|
|
302
|
+
T(2, s(m)),
|
|
303
|
+
T(3, N)
|
|
304
|
+
], R);
|
|
291
305
|
export {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
306
|
+
k as DOC_UI_PLUGIN_NAME,
|
|
307
|
+
X as DefaultDocContainerConfig,
|
|
308
|
+
Z as DefaultDocUiConfig,
|
|
309
|
+
V as DefaultToolbarConfig,
|
|
310
|
+
R as UniverDocsUIPlugin,
|
|
311
|
+
Ae as enUS,
|
|
312
|
+
ge as zhCN
|
|
299
313
|
};
|
|
@@ -13,15 +13,16 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { LocaleService, Plugin, PluginType } from '@univerjs/core';
|
|
16
|
+
import { ILogService, LocaleService, Plugin, PluginType } from '@univerjs/core';
|
|
17
17
|
import { Injector } from '@wendellhu/redi';
|
|
18
18
|
import type { IUniverDocsUIConfig } from './basics';
|
|
19
19
|
export declare class UniverDocsUIPlugin extends Plugin {
|
|
20
20
|
private readonly _config;
|
|
21
21
|
_injector: Injector;
|
|
22
22
|
private readonly _localeService;
|
|
23
|
+
private _logService;
|
|
23
24
|
static type: PluginType;
|
|
24
|
-
constructor(_config: IUniverDocsUIConfig, _injector: Injector, _localeService: LocaleService);
|
|
25
|
+
constructor(_config: IUniverDocsUIConfig, _injector: Injector, _localeService: LocaleService, _logService: ILogService);
|
|
25
26
|
onRendered(): void;
|
|
26
27
|
onDestroy(): void;
|
|
27
28
|
private _initDependencies;
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","@univerjs/docs"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.UniverDocsUi={},s.UniverCore,s["@wendellhu/redi"],s.UniverUi,s.UniverDocs))})(this,function(s,c,l,
|
|
1
|
+
(function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","@univerjs/docs"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.UniverDocsUi={},s.UniverCore,s["@wendellhu/redi"],s.UniverUi,s.UniverDocs))})(this,function(s,c,l,o,d){"use strict";var J=Object.defineProperty;var Q=(s,c,l)=>c in s?J(s,c,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[c]=l;var _=(s,c,l)=>(Q(s,typeof c!="symbol"?c+"":c,l),l);var v;const g={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},I={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},C={layout:{docContainerConfig:I,toolbarConfig:g}},M="DocUI";var D=Object.defineProperty,y=Object.getOwnPropertyDescriptor,R=(e,t,n,r)=>{for(var i=r>1?void 0:r?y(t,n):t,a=e.length-1,u;a>=0;a--)(u=e[a])&&(i=(r?u(t,n,i):u(i))||i);return r&&i&&D(t,n,i),i},S=(e,t)=>(n,r)=>t(n,r,e);let h=class{constructor(e,t,n){_(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=t,this._injector=n}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=R([S(1,l.Inject(c.LocaleService)),S(2,l.Inject(l.Injector))],h);var b=Object.defineProperty,A=Object.getOwnPropertyDescriptor,L=(e,t,n,r)=>{for(var i=r>1?void 0:r?A(t,n):t,a=e.length-1,u;a>=0;a--)(u=e[a])&&(i=(r?u(t,n,i):u(i))||i);return r&&i&&b(t,n,i),i},m=(e,t)=>(n,r)=>t(n,r,e);let f=class{constructor(e,t,n){_(this,"_docContainerController");_(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._localeService=t,this._injector=n,this._docContainerController=this._injector.createInstance(h,e)}getDocContainerController(){return this._docContainerController}};f=L([m(1,l.Inject(c.LocaleService)),m(2,l.Inject(l.Injector))],f);function j(e){return{id:d.SetInlineFormatBoldCommand.id,group:o.MenuGroup.TOOLBAR_FORMAT,type:o.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[o.MenuPosition.TOOLBAR_START],hidden$:o.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function P(e){return{id:d.SetInlineFormatItalicCommand.id,group:o.MenuGroup.TOOLBAR_FORMAT,type:o.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[o.MenuPosition.TOOLBAR_START],hidden$:o.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function B(e){return{id:d.SetInlineFormatUnderlineCommand.id,group:o.MenuGroup.TOOLBAR_FORMAT,type:o.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[o.MenuPosition.TOOLBAR_START],hidden$:o.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function F(e){return{id:d.SetInlineFormatStrikethroughCommand.id,group:o.MenuGroup.TOOLBAR_FORMAT,type:o.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[o.MenuPosition.TOOLBAR_START],hidden$:o.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function $(e){return{id:d.SetInlineFormatSubscriptCommand.id,group:o.MenuGroup.TOOLBAR_FORMAT,type:o.MenuItemType.BUTTON,icon:"SubscriptSingle",tooltip:"toolbar.subscript",positions:[o.MenuPosition.TOOLBAR_START],hidden$:o.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function N(e){return{id:d.SetInlineFormatSuperscriptCommand.id,group:o.MenuGroup.TOOLBAR_FORMAT,type:o.MenuItemType.BUTTON,icon:"SuperscriptSingle",tooltip:"toolbar.superscript",positions:[o.MenuPosition.TOOLBAR_START],hidden$:o.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function w(e){return{id:d.OrderListCommand.id,group:o.MenuGroup.TOOLBAR_LAYOUT,type:o.MenuItemType.BUTTON,icon:"OrderSingle",tooltip:"toolbar.superscript",positions:[o.MenuPosition.TOOLBAR_START],hidden$:o.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}function H(e){return{id:d.BulletListCommand.id,group:o.MenuGroup.TOOLBAR_LAYOUT,type:o.MenuItemType.BUTTON,icon:"UnorderSingle",tooltip:"toolbar.superscript",positions:[o.MenuPosition.TOOLBAR_START],hidden$:o.getMenuHiddenObservable(e,c.UniverInstanceType.DOC)}}var G=Object.defineProperty,E=Object.getOwnPropertyDescriptor,z=(e,t,n,r)=>{for(var i=r>1?void 0:r?E(t,n):t,a=e.length-1,u;a>=0;a--)(u=e[a])&&(i=(r?u(t,n,i):u(i))||i);return r&&i&&G(t,n,i),i},p=(e,t)=>(n,r)=>t(n,r,e);let O=class extends c.Disposable{constructor(e,t,n,r,i,a){super(),this._injector=e,this._componentManager=t,this._commandService=n,this._shortcutService=r,this._menuService=i,this._uiController=a,this._init()}_init(){[j,P,B,F,$,N,w,H].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e)))})}};O=z([c.OnLifecycle(c.LifecycleStages.Rendered,O),p(0,l.Inject(l.Injector)),p(1,l.Inject(o.ComponentManager)),p(2,c.ICommandService),p(3,o.IShortcutService),p(4,o.IMenuService),p(5,o.IUIController)],O);const q={},U={};var Y=Object.defineProperty,K=Object.getOwnPropertyDescriptor,W=(e,t,n,r)=>{for(var i=r>1?void 0:r?K(t,n):t,a=e.length-1,u;a>=0;a--)(u=e[a])&&(i=(r?u(t,n,i):u(i))||i);return r&&i&&Y(t,n,i),i},T=(e,t)=>(n,r)=>t(n,r,e);s.UniverDocsUIPlugin=(v=class extends c.Plugin{constructor(t,n,r,i){super(M),this._config=t,this._injector=n,this._localeService=r,this._logService=i,this._localeService.load({zhCN:U}),this._config=c.Tools.deepMerge({},C,this._config),this._initDependencies(n)}onRendered(){this._initModules(),this._markDocAsFocused()}onDestroy(){}_initDependencies(t){[[O],[f,{useFactory:()=>this._injector.createInstance(f,this._config)}]].forEach(r=>{t.add(r)})}_markDocAsFocused(){const t=this._injector.get(c.IUniverInstanceService);try{const n=t.getCurrentUniverDocInstance(),r=n.getUnitId();r!==c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&r!==c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&t.focusUniverInstance(n.getUnitId())}catch(n){this._logService.warn(n)}}_initModules(){this._injector.get(f)}},_(v,"type",c.PluginType.Doc),v),s.UniverDocsUIPlugin=W([T(1,l.Inject(l.Injector)),T(2,l.Inject(c.LocaleService)),T(3,c.ILogService)],s.UniverDocsUIPlugin),s.DOC_UI_PLUGIN_NAME=M,s.DefaultDocContainerConfig=I,s.DefaultDocUiConfig=C,s.DefaultToolbarConfig=g,s.enUS=q,s.zhCN=U,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-ui",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
4
|
"description": "Univer normal ui-plugin-docs",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -34,33 +34,35 @@
|
|
|
34
34
|
"**/*.css"
|
|
35
35
|
],
|
|
36
36
|
"private": false,
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@wendellhu/redi": "^0.12.12",
|
|
39
|
+
"react": "^18.2.0",
|
|
40
|
+
"@univerjs/docs": "0.1.0-beta.1",
|
|
41
|
+
"@univerjs/core": "0.1.0-beta.1",
|
|
42
|
+
"@univerjs/design": "0.1.0-beta.1",
|
|
43
|
+
"@univerjs/ui": "0.1.0-beta.1",
|
|
44
|
+
"@univerjs/engine-render": "0.1.0-beta.1"
|
|
45
|
+
},
|
|
37
46
|
"devDependencies": {
|
|
38
|
-
"@types/react": "^18.2.
|
|
47
|
+
"@types/react": "^18.2.45",
|
|
39
48
|
"@vitejs/plugin-react": "^4.2.1",
|
|
40
|
-
"@vitest/coverage-istanbul": "^1.0
|
|
41
|
-
"@wendellhu/redi": "^0.12.12",
|
|
49
|
+
"@vitest/coverage-istanbul": "^1.1.0",
|
|
42
50
|
"happy-dom": "^12.10.3",
|
|
43
51
|
"less": "^4.2.0",
|
|
44
|
-
"react": "^18.2.0",
|
|
45
52
|
"typescript": "^5.3.3",
|
|
46
|
-
"vite": "^5.0.
|
|
53
|
+
"vite": "^5.0.10",
|
|
47
54
|
"vite-plugin-dts": "^3.6.4",
|
|
48
55
|
"vite-plugin-externals": "^0.6.2",
|
|
49
|
-
"vitest": "^1.0
|
|
50
|
-
"@univerjs/core": "0.1.0-alpha.3",
|
|
51
|
-
"@univerjs/docs": "0.1.0-alpha.3",
|
|
52
|
-
"@univerjs/ui": "0.1.0-alpha.3",
|
|
53
|
-
"@univerjs/engine-render": "0.1.0-alpha.3",
|
|
54
|
-
"@univerjs/design": "0.1.0-alpha.3"
|
|
56
|
+
"vitest": "^1.1.0"
|
|
55
57
|
},
|
|
56
58
|
"peerDependencies": {
|
|
57
59
|
"@wendellhu/redi": ">=0.12.12",
|
|
58
60
|
"react": ">=16.9.0",
|
|
59
|
-
"@univerjs/core": "0.1.0-
|
|
60
|
-
"@univerjs/design": "0.1.0-
|
|
61
|
-
"@univerjs/engine-render": "0.1.0-
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/
|
|
61
|
+
"@univerjs/core": "0.1.0-beta.1",
|
|
62
|
+
"@univerjs/design": "0.1.0-beta.1",
|
|
63
|
+
"@univerjs/engine-render": "0.1.0-beta.1",
|
|
64
|
+
"@univerjs/docs": "0.1.0-beta.1",
|
|
65
|
+
"@univerjs/ui": "0.1.0-beta.1"
|
|
64
66
|
},
|
|
65
67
|
"scripts": {
|
|
66
68
|
"test": "vitest run",
|