@univerjs/docs-ui 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +16 -0
- package/lib/cjs/index.js +514 -0
- package/lib/cjs/locale/en-US.js +26 -0
- package/lib/cjs/locale/zh-CN.js +26 -0
- package/lib/esm/index.js +500 -0
- package/lib/esm/locale/en-US.js +5 -0
- package/lib/esm/locale/zh-CN.js +5 -0
- package/lib/types/basics/const/default-univer-doc-config.d.ts +65 -0
- package/lib/types/basics/const/default-univer-doc-config.d.ts.map +1 -0
- package/lib/types/basics/const/index.d.ts +3 -0
- package/lib/types/basics/const/index.d.ts.map +1 -0
- package/lib/types/basics/const/plugin-name.d.ts +2 -0
- package/lib/types/basics/const/plugin-name.d.ts.map +1 -0
- package/lib/types/basics/index.d.ts +3 -0
- package/lib/types/basics/index.d.ts.map +1 -0
- package/lib/types/basics/interfaces/component-config/i-doc-ui-plugin-config.d.ts +48 -0
- package/lib/types/basics/interfaces/component-config/i-doc-ui-plugin-config.d.ts.map +1 -0
- package/lib/types/basics/interfaces/component-config/index.d.ts +2 -0
- package/lib/types/basics/interfaces/component-config/index.d.ts.map +1 -0
- package/lib/types/basics/interfaces/index.d.ts +2 -0
- package/lib/types/basics/interfaces/index.d.ts.map +1 -0
- package/lib/types/controllers/app-ui-controller.d.ts +20 -0
- package/lib/types/controllers/app-ui-controller.d.ts.map +1 -0
- package/lib/types/controllers/doc-container-ui-controller.d.ts +31 -0
- package/lib/types/controllers/doc-container-ui-controller.d.ts.map +1 -0
- package/lib/types/controllers/doc-ui.controller.d.ts +15 -0
- package/lib/types/controllers/doc-ui.controller.d.ts.map +1 -0
- package/lib/types/controllers/index.d.ts +3 -0
- package/lib/types/controllers/index.d.ts.map +1 -0
- package/lib/types/controllers/menu/menu.d.ts +7 -0
- package/lib/types/controllers/menu/menu.d.ts.map +1 -0
- package/lib/types/docs-ui-plugin.d.ts +16 -0
- package/lib/types/docs-ui-plugin.d.ts.map +1 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/locale/en-US.d.ts +3 -0
- package/lib/types/locale/en-US.d.ts.map +1 -0
- package/lib/types/locale/index.d.ts +3 -0
- package/lib/types/locale/index.d.ts.map +1 -0
- package/lib/types/locale/zh-CN.d.ts +3 -0
- package/lib/types/locale/zh-CN.d.ts.map +1 -0
- package/lib/types/views/doc-container/DocContainer.d.ts +49 -0
- package/lib/types/views/doc-container/DocContainer.d.ts.map +1 -0
- package/lib/types/views/doc-container/index.d.ts +2 -0
- package/lib/types/views/doc-container/index.d.ts.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-present, DreamNum
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# @univerjs/docs-ui
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.org/packages/@univerjs/docs-ui)
|
|
4
|
+
[](https://img.shields.io/npm/l/@univerjs/docs-ui)
|
|
5
|
+
|
|
6
|
+
## Introduction
|
|
7
|
+
|
|
8
|
+
> UI plugin for Univer Docs.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
### Installation
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
npm i @univerjs/docs-ui
|
|
16
|
+
```
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _assert_this_initialized(self) {
|
|
3
|
+
if (self === void 0) {
|
|
4
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
5
|
+
}
|
|
6
|
+
return self;
|
|
7
|
+
}
|
|
8
|
+
function _class_call_check(instance, Constructor) {
|
|
9
|
+
if (!(instance instanceof Constructor)) {
|
|
10
|
+
throw new TypeError("Cannot call a class as a function");
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function _defineProperties(target, props) {
|
|
14
|
+
for(var i = 0; i < props.length; i++){
|
|
15
|
+
var descriptor = props[i];
|
|
16
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
17
|
+
descriptor.configurable = true;
|
|
18
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
19
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
23
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
24
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
25
|
+
return Constructor;
|
|
26
|
+
}
|
|
27
|
+
function _define_property(obj, key, value) {
|
|
28
|
+
if (key in obj) {
|
|
29
|
+
Object.defineProperty(obj, key, {
|
|
30
|
+
value: value,
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
obj[key] = value;
|
|
37
|
+
}
|
|
38
|
+
return obj;
|
|
39
|
+
}
|
|
40
|
+
function _get_prototype_of(o) {
|
|
41
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
42
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
43
|
+
};
|
|
44
|
+
return _get_prototype_of(o);
|
|
45
|
+
}
|
|
46
|
+
function _inherits(subClass, superClass) {
|
|
47
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
48
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
49
|
+
}
|
|
50
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
51
|
+
constructor: {
|
|
52
|
+
value: subClass,
|
|
53
|
+
writable: true,
|
|
54
|
+
configurable: true
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
58
|
+
}
|
|
59
|
+
function _possible_constructor_return(self, call) {
|
|
60
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
61
|
+
return call;
|
|
62
|
+
}
|
|
63
|
+
return _assert_this_initialized(self);
|
|
64
|
+
}
|
|
65
|
+
function _set_prototype_of(o, p) {
|
|
66
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
67
|
+
o.__proto__ = p;
|
|
68
|
+
return o;
|
|
69
|
+
};
|
|
70
|
+
return _set_prototype_of(o, p);
|
|
71
|
+
}
|
|
72
|
+
function _type_of(obj) {
|
|
73
|
+
"@swc/helpers - typeof";
|
|
74
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
75
|
+
}
|
|
76
|
+
function _is_native_reflect_construct() {
|
|
77
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
78
|
+
if (Reflect.construct.sham) return false;
|
|
79
|
+
if (typeof Proxy === "function") return true;
|
|
80
|
+
try {
|
|
81
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
82
|
+
return true;
|
|
83
|
+
} catch (e) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function _create_super(Derived) {
|
|
88
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
89
|
+
return function _createSuperInternal() {
|
|
90
|
+
var Super = _get_prototype_of(Derived), result;
|
|
91
|
+
if (hasNativeReflectConstruct) {
|
|
92
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
93
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
94
|
+
} else {
|
|
95
|
+
result = Super.apply(this, arguments);
|
|
96
|
+
}
|
|
97
|
+
return _possible_constructor_return(this, result);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
var _import_core4_Plugin, _class;
|
|
101
|
+
var __defProp = Object.defineProperty;
|
|
102
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
103
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
104
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
105
|
+
var __export = function(target, all) {
|
|
106
|
+
for(var name in all)__defProp(target, name, {
|
|
107
|
+
get: all[name],
|
|
108
|
+
enumerable: true
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
var __copyProps = function(to, from, except, desc) {
|
|
112
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
113
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
114
|
+
try {
|
|
115
|
+
var _loop = function() {
|
|
116
|
+
var key = _step.value;
|
|
117
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
118
|
+
get: function() {
|
|
119
|
+
return from[key];
|
|
120
|
+
},
|
|
121
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
125
|
+
} catch (err) {
|
|
126
|
+
_didIteratorError = true;
|
|
127
|
+
_iteratorError = err;
|
|
128
|
+
} finally{
|
|
129
|
+
try {
|
|
130
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
131
|
+
_iterator.return();
|
|
132
|
+
}
|
|
133
|
+
} finally{
|
|
134
|
+
if (_didIteratorError) {
|
|
135
|
+
throw _iteratorError;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return to;
|
|
141
|
+
};
|
|
142
|
+
var __toCommonJS = function(mod) {
|
|
143
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
144
|
+
value: true
|
|
145
|
+
}), mod);
|
|
146
|
+
};
|
|
147
|
+
var __decorateClass = function(decorators, target, key, kind) {
|
|
148
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
149
|
+
for(var i = decorators.length - 1, decorator; i >= 0; i--)if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
150
|
+
if (kind && result) __defProp(target, key, result);
|
|
151
|
+
return result;
|
|
152
|
+
};
|
|
153
|
+
var __decorateParam = function(index, decorator) {
|
|
154
|
+
return function(target, key) {
|
|
155
|
+
return decorator(target, key, index);
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
// src/index.ts
|
|
159
|
+
var src_exports = {};
|
|
160
|
+
__export(src_exports, {
|
|
161
|
+
DOC_UI_PLUGIN_NAME: function() {
|
|
162
|
+
return DOC_UI_PLUGIN_NAME;
|
|
163
|
+
},
|
|
164
|
+
DefaultDocContainerConfig: function() {
|
|
165
|
+
return DefaultDocContainerConfig;
|
|
166
|
+
},
|
|
167
|
+
DefaultDocUiConfig: function() {
|
|
168
|
+
return DefaultDocUiConfig;
|
|
169
|
+
},
|
|
170
|
+
DefaultToolbarConfig: function() {
|
|
171
|
+
return DefaultToolbarConfig;
|
|
172
|
+
},
|
|
173
|
+
DocsUIPlugin: function() {
|
|
174
|
+
return DocsUIPlugin;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
module.exports = __toCommonJS(src_exports);
|
|
178
|
+
// src/basics/const/default-univer-doc-config.ts
|
|
179
|
+
var DefaultToolbarConfig = {
|
|
180
|
+
undo: true,
|
|
181
|
+
redo: true,
|
|
182
|
+
// Undo redo
|
|
183
|
+
font: true,
|
|
184
|
+
// 'font'
|
|
185
|
+
fontSize: true,
|
|
186
|
+
// 'Font size'
|
|
187
|
+
bold: true,
|
|
188
|
+
// 'Bold (Ctrl+B)'
|
|
189
|
+
italic: true,
|
|
190
|
+
// 'Italic (Ctrl+I)'
|
|
191
|
+
strikethrough: true,
|
|
192
|
+
// 'Strikethrough (Alt+Shift+5)'
|
|
193
|
+
underline: true,
|
|
194
|
+
// 'Underline (Alt+Shift+6)'
|
|
195
|
+
textColor: true,
|
|
196
|
+
// 'Text color'
|
|
197
|
+
fillColor: true,
|
|
198
|
+
// 'Cell color'
|
|
199
|
+
horizontalAlignMode: true,
|
|
200
|
+
// 'Horizontal alignment'
|
|
201
|
+
verticalAlignMode: true,
|
|
202
|
+
// 'Vertical alignment'
|
|
203
|
+
textWrapMode: true,
|
|
204
|
+
// 'Wrap mode'
|
|
205
|
+
textRotateMode: true
|
|
206
|
+
};
|
|
207
|
+
var DefaultDocContainerConfig = {
|
|
208
|
+
outerLeft: false,
|
|
209
|
+
outerRight: false,
|
|
210
|
+
header: true,
|
|
211
|
+
footer: true,
|
|
212
|
+
innerLeft: false,
|
|
213
|
+
innerRight: false,
|
|
214
|
+
frozenHeaderLT: false,
|
|
215
|
+
frozenHeaderRT: false,
|
|
216
|
+
frozenHeaderLM: false,
|
|
217
|
+
frozenContent: false,
|
|
218
|
+
infoBar: true,
|
|
219
|
+
toolbar: true
|
|
220
|
+
};
|
|
221
|
+
var DefaultDocUiConfig = {
|
|
222
|
+
layout: {
|
|
223
|
+
docContainerConfig: DefaultDocContainerConfig,
|
|
224
|
+
toolbarConfig: DefaultToolbarConfig
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
// src/basics/const/plugin-name.ts
|
|
228
|
+
var DOC_UI_PLUGIN_NAME = "DocUI";
|
|
229
|
+
// src/docs-ui-plugin.ts
|
|
230
|
+
var import_core4 = require("@univerjs/core");
|
|
231
|
+
var import_redi4 = require("@wendellhu/redi");
|
|
232
|
+
// src/controllers/app-ui-controller.ts
|
|
233
|
+
var import_core2 = require("@univerjs/core");
|
|
234
|
+
var import_redi2 = require("@wendellhu/redi");
|
|
235
|
+
// src/controllers/doc-container-ui-controller.ts
|
|
236
|
+
var import_core = require("@univerjs/core");
|
|
237
|
+
var import_redi = require("@wendellhu/redi");
|
|
238
|
+
var DocContainerUIController = /*#__PURE__*/ function() {
|
|
239
|
+
function DocContainerUIController(_config, _localeService, _injector) {
|
|
240
|
+
var _this = this;
|
|
241
|
+
_class_call_check(this, DocContainerUIController);
|
|
242
|
+
_define_property(this, "_docContainer", void 0);
|
|
243
|
+
// 获取SheetContainer组件
|
|
244
|
+
_define_property(this, "getComponent", function(ref) {
|
|
245
|
+
_this._docContainer = ref;
|
|
246
|
+
var container = ref.getContentRef().current;
|
|
247
|
+
if (!container) {
|
|
248
|
+
throw new Error("container is not ready");
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
/**
|
|
252
|
+
* Change language
|
|
253
|
+
* @param {String} lang new language
|
|
254
|
+
*
|
|
255
|
+
* e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
|
|
256
|
+
*
|
|
257
|
+
*/ _define_property(this, "changeLocale", function(locale) {
|
|
258
|
+
_this._localeService.setLocale(locale);
|
|
259
|
+
});
|
|
260
|
+
this._config = _config;
|
|
261
|
+
this._localeService = _localeService;
|
|
262
|
+
this._injector = _injector;
|
|
263
|
+
}
|
|
264
|
+
_create_class(DocContainerUIController, [
|
|
265
|
+
{
|
|
266
|
+
key: "getUIConfig",
|
|
267
|
+
value: function getUIConfig() {
|
|
268
|
+
var config = {
|
|
269
|
+
injector: this._injector,
|
|
270
|
+
config: this._config,
|
|
271
|
+
changeLocale: this.changeLocale,
|
|
272
|
+
getComponent: this.getComponent
|
|
273
|
+
};
|
|
274
|
+
return config;
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
key: "getContentRef",
|
|
279
|
+
value: function getContentRef() {
|
|
280
|
+
return this._docContainer.getContentRef();
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
key: "UIDidMount",
|
|
285
|
+
value: function UIDidMount(cb) {
|
|
286
|
+
if (this._docContainer) {
|
|
287
|
+
return cb(this._docContainer);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
key: "getDocContainer",
|
|
293
|
+
value: function getDocContainer() {
|
|
294
|
+
return this._docContainer;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
]);
|
|
298
|
+
return DocContainerUIController;
|
|
299
|
+
}();
|
|
300
|
+
DocContainerUIController = __decorateClass([
|
|
301
|
+
__decorateParam(1, (0, import_redi.Inject)(import_core.LocaleService)),
|
|
302
|
+
__decorateParam(2, (0, import_redi.Inject)(import_redi.Injector))
|
|
303
|
+
], DocContainerUIController);
|
|
304
|
+
// src/controllers/app-ui-controller.ts
|
|
305
|
+
var AppUIController = /*#__PURE__*/ function() {
|
|
306
|
+
function AppUIController(_config, _localeService, _injector) {
|
|
307
|
+
var _this = this;
|
|
308
|
+
_class_call_check(this, AppUIController);
|
|
309
|
+
_define_property(this, "_docContainerController", void 0);
|
|
310
|
+
/**
|
|
311
|
+
* Change language
|
|
312
|
+
* @param {String} locale new language
|
|
313
|
+
*
|
|
314
|
+
* e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
|
|
315
|
+
*
|
|
316
|
+
*/ _define_property(this, "changeLocale", function(locale) {
|
|
317
|
+
_this._localeService.setLocale(locale);
|
|
318
|
+
});
|
|
319
|
+
this._localeService = _localeService;
|
|
320
|
+
this._injector = _injector;
|
|
321
|
+
this._docContainerController = this._injector.createInstance(DocContainerUIController, _config);
|
|
322
|
+
}
|
|
323
|
+
_create_class(AppUIController, [
|
|
324
|
+
{
|
|
325
|
+
key: "getDocContainerController",
|
|
326
|
+
value: function getDocContainerController() {
|
|
327
|
+
return this._docContainerController;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
]);
|
|
331
|
+
return AppUIController;
|
|
332
|
+
}();
|
|
333
|
+
AppUIController = __decorateClass([
|
|
334
|
+
__decorateParam(1, (0, import_redi2.Inject)(import_core2.LocaleService)),
|
|
335
|
+
__decorateParam(2, (0, import_redi2.Inject)(import_redi2.Injector))
|
|
336
|
+
], AppUIController);
|
|
337
|
+
// src/controllers/doc-ui.controller.ts
|
|
338
|
+
var import_core3 = require("@univerjs/core");
|
|
339
|
+
var import_ui2 = require("@univerjs/ui");
|
|
340
|
+
var import_redi3 = require("@wendellhu/redi");
|
|
341
|
+
// src/controllers/menu/menu.ts
|
|
342
|
+
var import_docs = require("@univerjs/docs");
|
|
343
|
+
var import_ui = require("@univerjs/ui");
|
|
344
|
+
function BoldMenuItemFactory(accessor) {
|
|
345
|
+
return {
|
|
346
|
+
id: import_docs.SetInlineFormatBoldCommand.id,
|
|
347
|
+
type: import_ui.MenuItemType.BUTTON,
|
|
348
|
+
icon: "BoldSingle",
|
|
349
|
+
title: "Set bold",
|
|
350
|
+
tooltip: "toolbar.bold",
|
|
351
|
+
positions: [
|
|
352
|
+
import_ui.MenuPosition.TOOLBAR_START
|
|
353
|
+
]
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
function ItalicMenuItemFactory(accessor) {
|
|
357
|
+
return {
|
|
358
|
+
id: import_docs.SetInlineFormatItalicCommand.id,
|
|
359
|
+
type: import_ui.MenuItemType.BUTTON,
|
|
360
|
+
icon: "ItalicSingle",
|
|
361
|
+
title: "Set italic",
|
|
362
|
+
tooltip: "toolbar.italic",
|
|
363
|
+
positions: [
|
|
364
|
+
import_ui.MenuPosition.TOOLBAR_START
|
|
365
|
+
]
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function UnderlineMenuItemFactory(accessor) {
|
|
369
|
+
return {
|
|
370
|
+
id: import_docs.SetInlineFormatUnderlineCommand.id,
|
|
371
|
+
type: import_ui.MenuItemType.BUTTON,
|
|
372
|
+
icon: "UnderlineSingle",
|
|
373
|
+
title: "Set underline",
|
|
374
|
+
tooltip: "toolbar.underline",
|
|
375
|
+
positions: [
|
|
376
|
+
import_ui.MenuPosition.TOOLBAR_START
|
|
377
|
+
]
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
function StrikeThroughMenuItemFactory(accessor) {
|
|
381
|
+
return {
|
|
382
|
+
id: import_docs.SetInlineFormatStrikethroughCommand.id,
|
|
383
|
+
type: import_ui.MenuItemType.BUTTON,
|
|
384
|
+
icon: "StrikethroughSingle",
|
|
385
|
+
title: "Set strike through",
|
|
386
|
+
tooltip: "toolbar.strikethrough",
|
|
387
|
+
positions: [
|
|
388
|
+
import_ui.MenuPosition.TOOLBAR_START
|
|
389
|
+
]
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
// src/controllers/doc-ui.controller.ts
|
|
393
|
+
var DocUIController = /*#__PURE__*/ function(_import_core3_Disposable) {
|
|
394
|
+
_inherits(DocUIController, _import_core3_Disposable);
|
|
395
|
+
var _super = _create_super(DocUIController);
|
|
396
|
+
function DocUIController(_injector, _componentManager, _commandService, _shortcutService, _menuService, _uiController) {
|
|
397
|
+
_class_call_check(this, DocUIController);
|
|
398
|
+
var _this;
|
|
399
|
+
_this = _super.call(this);
|
|
400
|
+
_this._injector = _injector;
|
|
401
|
+
_this._componentManager = _componentManager;
|
|
402
|
+
_this._commandService = _commandService;
|
|
403
|
+
_this._shortcutService = _shortcutService;
|
|
404
|
+
_this._menuService = _menuService;
|
|
405
|
+
_this._uiController = _uiController;
|
|
406
|
+
_this._init();
|
|
407
|
+
return _this;
|
|
408
|
+
}
|
|
409
|
+
_create_class(DocUIController, [
|
|
410
|
+
{
|
|
411
|
+
key: "_init",
|
|
412
|
+
value: function _init() {
|
|
413
|
+
var _this = this;
|
|
414
|
+
[
|
|
415
|
+
BoldMenuItemFactory,
|
|
416
|
+
ItalicMenuItemFactory,
|
|
417
|
+
UnderlineMenuItemFactory,
|
|
418
|
+
StrikeThroughMenuItemFactory
|
|
419
|
+
].forEach(function(factory) {
|
|
420
|
+
_this.disposeWithMe(_this._menuService.addMenuItem(_this._injector.invoke(factory)));
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
]);
|
|
425
|
+
return DocUIController;
|
|
426
|
+
}(import_core3.Disposable);
|
|
427
|
+
DocUIController = __decorateClass([
|
|
428
|
+
(0, import_core3.OnLifecycle)(import_core3.LifecycleStages.Rendered, DocUIController),
|
|
429
|
+
__decorateParam(0, (0, import_redi3.Inject)(import_redi3.Injector)),
|
|
430
|
+
__decorateParam(1, (0, import_redi3.Inject)(import_ui2.ComponentManager)),
|
|
431
|
+
__decorateParam(2, import_core3.ICommandService),
|
|
432
|
+
__decorateParam(3, import_ui2.IShortcutService),
|
|
433
|
+
__decorateParam(4, import_ui2.IMenuService),
|
|
434
|
+
__decorateParam(5, import_ui2.IUIController)
|
|
435
|
+
], DocUIController);
|
|
436
|
+
// src/locale/en-US.ts
|
|
437
|
+
var en_US_default = {};
|
|
438
|
+
// src/docs-ui-plugin.ts
|
|
439
|
+
var DocsUIPlugin = (_class = /*#__PURE__*/ function(_superClass) {
|
|
440
|
+
_inherits(_class, _superClass);
|
|
441
|
+
var _super = _create_super(_class);
|
|
442
|
+
function _class(_config, _injector, _localeService) {
|
|
443
|
+
_class_call_check(this, _class);
|
|
444
|
+
var _this;
|
|
445
|
+
_this = _super.call(this, DOC_UI_PLUGIN_NAME);
|
|
446
|
+
_this._config = _config;
|
|
447
|
+
_this._injector = _injector;
|
|
448
|
+
_this._localeService = _localeService;
|
|
449
|
+
_this._localeService.load({
|
|
450
|
+
enUS: en_US_default
|
|
451
|
+
});
|
|
452
|
+
_this._config = import_core4.Tools.deepMerge({}, DefaultDocUiConfig, _this._config);
|
|
453
|
+
_this._initDependencies(_injector);
|
|
454
|
+
return _this;
|
|
455
|
+
}
|
|
456
|
+
_create_class(_class, [
|
|
457
|
+
{
|
|
458
|
+
key: "onRendered",
|
|
459
|
+
value: function onRendered() {
|
|
460
|
+
this._initModules();
|
|
461
|
+
this._markDocAsFocused();
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
key: "onDestroy",
|
|
466
|
+
value: function onDestroy() {}
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
key: "_initDependencies",
|
|
470
|
+
value: function _initDependencies(injector) {
|
|
471
|
+
var _this = this;
|
|
472
|
+
var dependencies = [
|
|
473
|
+
[
|
|
474
|
+
DocUIController
|
|
475
|
+
],
|
|
476
|
+
[
|
|
477
|
+
// controllers
|
|
478
|
+
AppUIController,
|
|
479
|
+
{
|
|
480
|
+
useFactory: function() {
|
|
481
|
+
return _this._injector.createInstance(AppUIController, _this._config);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
]
|
|
485
|
+
];
|
|
486
|
+
dependencies.forEach(function(d) {
|
|
487
|
+
injector.add(d);
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
key: "_markDocAsFocused",
|
|
493
|
+
value: function _markDocAsFocused() {
|
|
494
|
+
var currentService = this._injector.get(import_core4.IUniverInstanceService);
|
|
495
|
+
var doc = currentService.getCurrentUniverDocInstance();
|
|
496
|
+
var id = doc.getUnitId();
|
|
497
|
+
if (id !== import_core4.DOCS_NORMAL_EDITOR_UNIT_ID_KEY && id !== import_core4.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) {
|
|
498
|
+
currentService.focusUniverInstance(doc.getUnitId());
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
key: "_initModules",
|
|
504
|
+
value: function _initModules() {
|
|
505
|
+
this._injector.get(AppUIController);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
]);
|
|
509
|
+
return _class;
|
|
510
|
+
}(_import_core4_Plugin = import_core4.Plugin), _define_property(_class, "type", import_core4.PluginType.Doc), _class);
|
|
511
|
+
DocsUIPlugin = __decorateClass([
|
|
512
|
+
__decorateParam(1, (0, import_redi4.Inject)(import_redi4.Injector)),
|
|
513
|
+
__decorateParam(2, (0, import_redi4.Inject)(import_core4.LocaleService))
|
|
514
|
+
], DocsUIPlugin);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/locale/en-US.ts
|
|
21
|
+
var en_US_exports = {};
|
|
22
|
+
__export(en_US_exports, {
|
|
23
|
+
default: () => en_US_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(en_US_exports);
|
|
26
|
+
var en_US_default = {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/locale/zh-CN.ts
|
|
21
|
+
var zh_CN_exports = {};
|
|
22
|
+
__export(zh_CN_exports, {
|
|
23
|
+
default: () => zh_CN_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(zh_CN_exports);
|
|
26
|
+
var zh_CN_default = {};
|