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