@univerjs/docs-ui 0.20.1 → 0.21.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/lib/cjs/facade.js +175 -1
- package/lib/cjs/index.js +15328 -12
- package/lib/cjs/locale/ca-ES.js +123 -1
- package/lib/cjs/locale/en-US.js +138 -1
- package/lib/cjs/locale/es-ES.js +123 -1
- package/lib/cjs/locale/fa-IR.js +123 -1
- package/lib/cjs/locale/fr-FR.js +123 -1
- package/lib/cjs/locale/ja-JP.js +123 -1
- package/lib/cjs/locale/ko-KR.js +123 -1
- package/lib/cjs/locale/ru-RU.js +123 -1
- package/lib/cjs/locale/sk-SK.js +123 -1
- package/lib/cjs/locale/vi-VN.js +123 -1
- package/lib/cjs/locale/zh-CN.js +123 -1
- package/lib/cjs/locale/zh-TW.js +123 -1
- package/lib/es/facade.js +169 -1
- package/lib/es/index.js +15133 -12
- package/lib/es/locale/ca-ES.js +122 -1
- package/lib/es/locale/en-US.js +137 -1
- package/lib/es/locale/es-ES.js +122 -1
- package/lib/es/locale/fa-IR.js +122 -1
- package/lib/es/locale/fr-FR.js +122 -1
- package/lib/es/locale/ja-JP.js +122 -1
- package/lib/es/locale/ko-KR.js +122 -1
- package/lib/es/locale/ru-RU.js +122 -1
- package/lib/es/locale/sk-SK.js +122 -1
- package/lib/es/locale/vi-VN.js +122 -1
- package/lib/es/locale/zh-CN.js +122 -1
- package/lib/es/locale/zh-TW.js +122 -1
- package/lib/facade.js +169 -1
- package/lib/index.js +15133 -12
- package/lib/locale/ca-ES.js +122 -1
- package/lib/locale/en-US.js +137 -1
- package/lib/locale/es-ES.js +122 -1
- package/lib/locale/fa-IR.js +122 -1
- package/lib/locale/fr-FR.js +122 -1
- package/lib/locale/ja-JP.js +122 -1
- package/lib/locale/ko-KR.js +122 -1
- package/lib/locale/ru-RU.js +122 -1
- package/lib/locale/sk-SK.js +122 -1
- package/lib/locale/vi-VN.js +122 -1
- package/lib/locale/zh-CN.js +122 -1
- package/lib/locale/zh-TW.js +122 -1
- package/lib/umd/index.js +9 -9
- package/package.json +11 -11
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1,175 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _univerjs_core = require("@univerjs/core");
|
|
3
|
+
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
4
|
+
let _univerjs_docs_ui = require("@univerjs/docs-ui");
|
|
5
|
+
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
6
|
+
|
|
7
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
|
|
8
|
+
function _typeof(o) {
|
|
9
|
+
"@babel/helpers - typeof";
|
|
10
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
11
|
+
return typeof o;
|
|
12
|
+
} : function(o) {
|
|
13
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
14
|
+
}, _typeof(o);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
|
|
19
|
+
function toPrimitive(t, r) {
|
|
20
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
21
|
+
var e = t[Symbol.toPrimitive];
|
|
22
|
+
if (void 0 !== e) {
|
|
23
|
+
var i = e.call(t, r || "default");
|
|
24
|
+
if ("object" != _typeof(i)) return i;
|
|
25
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
26
|
+
}
|
|
27
|
+
return ("string" === r ? String : Number)(t);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
|
|
32
|
+
function toPropertyKey(t) {
|
|
33
|
+
var i = toPrimitive(t, "string");
|
|
34
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
|
|
39
|
+
function _defineProperty(e, r, t) {
|
|
40
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
|
+
value: t,
|
|
42
|
+
enumerable: !0,
|
|
43
|
+
configurable: !0,
|
|
44
|
+
writable: !0
|
|
45
|
+
}) : e[r] = t, e;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
|
|
50
|
+
function __decorateParam(paramIndex, decorator) {
|
|
51
|
+
return function(target, key) {
|
|
52
|
+
decorator(target, key, paramIndex);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
|
|
58
|
+
function __decorate(decorators, target, key, desc) {
|
|
59
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
61
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
62
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/facade/f-document.ts
|
|
67
|
+
let FDocument = class FDocument {
|
|
68
|
+
constructor(_documentDataModel, _injector, _univerInstanceService, _commandService, _resourceManagerService, _renderManagerService) {
|
|
69
|
+
this._documentDataModel = _documentDataModel;
|
|
70
|
+
this._injector = _injector;
|
|
71
|
+
this._univerInstanceService = _univerInstanceService;
|
|
72
|
+
this._commandService = _commandService;
|
|
73
|
+
this._resourceManagerService = _resourceManagerService;
|
|
74
|
+
this._renderManagerService = _renderManagerService;
|
|
75
|
+
_defineProperty(this, "id", void 0);
|
|
76
|
+
this.id = this._documentDataModel.getUnitId();
|
|
77
|
+
}
|
|
78
|
+
getId() {
|
|
79
|
+
return this._documentDataModel.getUnitId();
|
|
80
|
+
}
|
|
81
|
+
getName() {
|
|
82
|
+
return this.getSnapshot().title || "";
|
|
83
|
+
}
|
|
84
|
+
getSnapshot() {
|
|
85
|
+
const resources = this._resourceManagerService.getResourcesByType(this.id, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
86
|
+
const snapshot = this._documentDataModel.getSnapshot();
|
|
87
|
+
snapshot.resources = resources;
|
|
88
|
+
return snapshot;
|
|
89
|
+
}
|
|
90
|
+
undo() {
|
|
91
|
+
this._univerInstanceService.focusUnit(this.id);
|
|
92
|
+
return this._commandService.executeCommand(_univerjs_core.UndoCommand.id);
|
|
93
|
+
}
|
|
94
|
+
redo() {
|
|
95
|
+
this._univerInstanceService.focusUnit(this.id);
|
|
96
|
+
return this._commandService.executeCommand(_univerjs_core.RedoCommand.id);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Adds the specified text to the end of this text region.
|
|
100
|
+
* @param text - The text to be added to the end of this text region.
|
|
101
|
+
*/
|
|
102
|
+
appendText(text) {
|
|
103
|
+
const unitId = this.id;
|
|
104
|
+
const { body } = this.getSnapshot();
|
|
105
|
+
if (!body) throw new Error("The document body is empty");
|
|
106
|
+
const lastPosition = body.dataStream.length - 2;
|
|
107
|
+
const activeRange = {
|
|
108
|
+
startOffset: lastPosition,
|
|
109
|
+
endOffset: lastPosition,
|
|
110
|
+
collapsed: true,
|
|
111
|
+
segmentId: ""
|
|
112
|
+
};
|
|
113
|
+
const { segmentId } = activeRange;
|
|
114
|
+
return this._commandService.executeCommand(_univerjs_docs_ui.InsertCommand.id, {
|
|
115
|
+
unitId,
|
|
116
|
+
body: { dataStream: text },
|
|
117
|
+
range: activeRange,
|
|
118
|
+
segmentId
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Sets the selection to a specified text range in the document.
|
|
123
|
+
* @param startOffset - The starting offset of the selection in the document.
|
|
124
|
+
* @param endOffset - The ending offset of the selection in the document.
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* document.setSelection(10, 20);
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
setSelection(startOffset, endOffset) {
|
|
131
|
+
var _this$_renderManagerS;
|
|
132
|
+
const docSelectionRenderService = (_this$_renderManagerS = this._renderManagerService.getRenderById(this.getId())) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_docs_ui.DocSelectionRenderService);
|
|
133
|
+
docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.removeAllRanges();
|
|
134
|
+
docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.addDocRanges([{
|
|
135
|
+
startOffset,
|
|
136
|
+
endOffset,
|
|
137
|
+
rangeType: _univerjs_core.DOC_RANGE_TYPE.TEXT
|
|
138
|
+
}], true);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
FDocument = __decorate([
|
|
142
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
143
|
+
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
144
|
+
__decorateParam(3, _univerjs_core.ICommandService),
|
|
145
|
+
__decorateParam(4, _univerjs_core.IResourceManagerService),
|
|
146
|
+
__decorateParam(5, _univerjs_engine_render.IRenderManagerService)
|
|
147
|
+
], FDocument);
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/facade/f-univer.ts
|
|
151
|
+
var FUniverDocsUIMixin = class extends _univerjs_core_facade.FUniver {
|
|
152
|
+
createUniverDoc(data) {
|
|
153
|
+
const document = this._univerInstanceService.createUnit(_univerjs_core.UniverInstanceType.UNIVER_DOC, data);
|
|
154
|
+
return this._injector.createInstance(FDocument, document);
|
|
155
|
+
}
|
|
156
|
+
getActiveDocument() {
|
|
157
|
+
const document = this._univerInstanceService.getCurrentUnitForType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
158
|
+
if (!document) return null;
|
|
159
|
+
return this._injector.createInstance(FDocument, document);
|
|
160
|
+
}
|
|
161
|
+
getUniverDoc(id) {
|
|
162
|
+
const document = this._univerInstanceService.getUniverDocInstance(id);
|
|
163
|
+
if (!document) return null;
|
|
164
|
+
return this._injector.createInstance(FDocument, document);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
_univerjs_core_facade.FUniver.extend(FUniverDocsUIMixin);
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
Object.defineProperty(exports, 'FDocument', {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
get: function () {
|
|
173
|
+
return FDocument;
|
|
174
|
+
}
|
|
175
|
+
});
|