@univerjs/docs-ui 0.1.0-alpha.2 → 0.1.0-beta.0
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 +160 -98
- package/lib/types/controllers/menu/menu.d.ts +4 -0
- package/lib/types/docs-ui-plugin.d.ts +3 -2
- 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 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 { 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 H = {
|
|
|
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 H = {
|
|
|
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 &&
|
|
58
|
+
return n && r && ee(t, o, r), r;
|
|
59
59
|
}, v = (e, t) => (o, n) => t(o, n, e);
|
|
60
|
-
let
|
|
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
|
-
v(1, s(
|
|
101
|
-
v(2, s(
|
|
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,99 +115,155 @@ let _ = 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:
|
|
134
|
-
|
|
133
|
+
id: H.id,
|
|
134
|
+
group: a.TOOLBAR_FORMAT,
|
|
135
|
+
type: u.BUTTON,
|
|
135
136
|
icon: "BoldSingle",
|
|
136
137
|
title: "Set bold",
|
|
137
138
|
tooltip: "toolbar.bold",
|
|
138
|
-
positions: [
|
|
139
|
+
positions: [_.TOOLBAR_START],
|
|
140
|
+
hidden$: d(e, l.DOC)
|
|
139
141
|
};
|
|
140
142
|
}
|
|
141
|
-
function
|
|
143
|
+
function se(e) {
|
|
142
144
|
return {
|
|
143
|
-
id:
|
|
144
|
-
|
|
145
|
+
id: Y.id,
|
|
146
|
+
group: a.TOOLBAR_FORMAT,
|
|
147
|
+
type: u.BUTTON,
|
|
145
148
|
icon: "ItalicSingle",
|
|
146
149
|
title: "Set italic",
|
|
147
150
|
tooltip: "toolbar.italic",
|
|
148
|
-
positions: [
|
|
151
|
+
positions: [_.TOOLBAR_START],
|
|
152
|
+
hidden$: d(e, l.DOC)
|
|
149
153
|
};
|
|
150
154
|
}
|
|
151
|
-
function
|
|
155
|
+
function le(e) {
|
|
152
156
|
return {
|
|
153
|
-
id:
|
|
154
|
-
|
|
157
|
+
id: G.id,
|
|
158
|
+
group: a.TOOLBAR_FORMAT,
|
|
159
|
+
type: u.BUTTON,
|
|
155
160
|
icon: "UnderlineSingle",
|
|
156
161
|
title: "Set underline",
|
|
157
162
|
tooltip: "toolbar.underline",
|
|
158
|
-
positions: [
|
|
163
|
+
positions: [_.TOOLBAR_START],
|
|
164
|
+
hidden$: d(e, l.DOC)
|
|
159
165
|
};
|
|
160
166
|
}
|
|
161
|
-
function
|
|
167
|
+
function ae(e) {
|
|
162
168
|
return {
|
|
163
|
-
id:
|
|
164
|
-
|
|
169
|
+
id: K.id,
|
|
170
|
+
group: a.TOOLBAR_FORMAT,
|
|
171
|
+
type: u.BUTTON,
|
|
165
172
|
icon: "StrikethroughSingle",
|
|
166
173
|
title: "Set strike through",
|
|
167
174
|
tooltip: "toolbar.strikethrough",
|
|
168
|
-
positions: [
|
|
175
|
+
positions: [_.TOOLBAR_START],
|
|
176
|
+
hidden$: d(e, l.DOC)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function ue(e) {
|
|
180
|
+
return {
|
|
181
|
+
id: W.id,
|
|
182
|
+
group: a.TOOLBAR_FORMAT,
|
|
183
|
+
type: u.BUTTON,
|
|
184
|
+
icon: "SubscriptSingle",
|
|
185
|
+
tooltip: "toolbar.subscript",
|
|
186
|
+
positions: [_.TOOLBAR_START],
|
|
187
|
+
hidden$: d(e, l.DOC)
|
|
169
188
|
};
|
|
170
189
|
}
|
|
171
|
-
|
|
172
|
-
|
|
190
|
+
function _e(e) {
|
|
191
|
+
return {
|
|
192
|
+
id: q.id,
|
|
193
|
+
group: a.TOOLBAR_FORMAT,
|
|
194
|
+
type: u.BUTTON,
|
|
195
|
+
icon: "SuperscriptSingle",
|
|
196
|
+
tooltip: "toolbar.superscript",
|
|
197
|
+
positions: [_.TOOLBAR_START],
|
|
198
|
+
hidden$: d(e, l.DOC)
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function de(e) {
|
|
202
|
+
return {
|
|
203
|
+
id: J.id,
|
|
204
|
+
group: a.TOOLBAR_LAYOUT,
|
|
205
|
+
type: u.BUTTON,
|
|
206
|
+
icon: "OrderSingle",
|
|
207
|
+
tooltip: "toolbar.superscript",
|
|
208
|
+
positions: [_.TOOLBAR_START],
|
|
209
|
+
hidden$: d(e, l.DOC)
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function pe(e) {
|
|
213
|
+
return {
|
|
214
|
+
id: Q.id,
|
|
215
|
+
group: a.TOOLBAR_LAYOUT,
|
|
216
|
+
type: u.BUTTON,
|
|
217
|
+
icon: "UnorderSingle",
|
|
218
|
+
tooltip: "toolbar.superscript",
|
|
219
|
+
positions: [_.TOOLBAR_START],
|
|
220
|
+
hidden$: d(e, l.DOC)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
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--)
|
|
173
225
|
(c = e[i]) && (r = (n ? c(t, o, r) : c(r)) || r);
|
|
174
|
-
return n && r &&
|
|
175
|
-
},
|
|
176
|
-
let
|
|
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 {
|
|
177
229
|
constructor(e, t, o, n, r, i) {
|
|
178
230
|
super(), this._injector = e, this._componentManager = t, this._commandService = o, this._shortcutService = n, this._menuService = r, this._uiController = i, this._init();
|
|
179
231
|
}
|
|
180
232
|
_init() {
|
|
181
233
|
[
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
234
|
+
ce,
|
|
235
|
+
se,
|
|
236
|
+
le,
|
|
237
|
+
ae,
|
|
238
|
+
ue,
|
|
239
|
+
_e,
|
|
240
|
+
de,
|
|
241
|
+
pe
|
|
186
242
|
].forEach((e) => {
|
|
187
243
|
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e)));
|
|
188
244
|
});
|
|
189
245
|
}
|
|
190
246
|
};
|
|
191
|
-
|
|
192
|
-
U(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
],
|
|
200
|
-
const
|
|
201
|
-
var
|
|
202
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
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)
|
|
255
|
+
], f);
|
|
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--)
|
|
203
259
|
(c = e[i]) && (r = (n ? c(t, o, r) : c(r)) || r);
|
|
204
|
-
return n && r &&
|
|
205
|
-
},
|
|
206
|
-
let
|
|
207
|
-
constructor(e, t, o) {
|
|
208
|
-
super(
|
|
209
|
-
zhCN:
|
|
210
|
-
}), 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);
|
|
211
267
|
}
|
|
212
268
|
onRendered() {
|
|
213
269
|
this._initModules(), this._markDocAsFocused();
|
|
@@ -216,12 +272,12 @@ let S = (p = class extends R {
|
|
|
216
272
|
}
|
|
217
273
|
_initDependencies(e) {
|
|
218
274
|
[
|
|
219
|
-
[
|
|
275
|
+
[f],
|
|
220
276
|
[
|
|
221
277
|
// controllers
|
|
222
|
-
|
|
278
|
+
O,
|
|
223
279
|
{
|
|
224
|
-
useFactory: () => this._injector.createInstance(
|
|
280
|
+
useFactory: () => this._injector.createInstance(O, this._config)
|
|
225
281
|
}
|
|
226
282
|
]
|
|
227
283
|
].forEach((o) => {
|
|
@@ -229,23 +285,29 @@ let S = (p = class extends R {
|
|
|
229
285
|
});
|
|
230
286
|
}
|
|
231
287
|
_markDocAsFocused() {
|
|
232
|
-
const e = this._injector.get(
|
|
233
|
-
|
|
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
|
+
}
|
|
234
295
|
}
|
|
235
296
|
_initModules() {
|
|
236
|
-
this._injector.get(
|
|
297
|
+
this._injector.get(O);
|
|
237
298
|
}
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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);
|
|
243
305
|
export {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
|
251
313
|
};
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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,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.0",
|
|
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/
|
|
51
|
-
"@univerjs/
|
|
52
|
-
"@univerjs/docs": "0.1.0-
|
|
53
|
-
"@univerjs/engine-render": "0.1.0-
|
|
54
|
-
"@univerjs/ui": "0.1.0-
|
|
49
|
+
"vitest": "^1.0.4",
|
|
50
|
+
"@univerjs/design": "0.1.0-beta.0",
|
|
51
|
+
"@univerjs/core": "0.1.0-beta.0",
|
|
52
|
+
"@univerjs/docs": "0.1.0-beta.0",
|
|
53
|
+
"@univerjs/engine-render": "0.1.0-beta.0",
|
|
54
|
+
"@univerjs/ui": "0.1.0-beta.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@wendellhu/redi": ">=0.12.12",
|
|
58
58
|
"react": ">=16.9.0",
|
|
59
|
-
"@univerjs/core": "0.1.0-
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/ui": "0.1.0-
|
|
63
|
-
"@univerjs/
|
|
59
|
+
"@univerjs/core": "0.1.0-beta.0",
|
|
60
|
+
"@univerjs/design": "0.1.0-beta.0",
|
|
61
|
+
"@univerjs/docs": "0.1.0-beta.0",
|
|
62
|
+
"@univerjs/ui": "0.1.0-beta.0",
|
|
63
|
+
"@univerjs/engine-render": "0.1.0-beta.0"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"test": "vitest run",
|