@univerjs/docs-ui 0.4.1 → 0.4.2-nightly.202410301606
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/core-editing.command-DAmOCaTR.mjs +1905 -0
- package/lib/es/facade.js +109 -0
- package/lib/es/index.js +577 -2416
- package/lib/locale/en-US.js +85 -0
- package/lib/locale/fa-IR.js +85 -0
- package/lib/locale/ru-RU.js +85 -0
- package/lib/locale/vi-VN.js +85 -0
- package/lib/locale/zh-CN.js +85 -0
- package/lib/locale/zh-TW.js +85 -0
- package/lib/types/basics/paragraph.d.ts +85 -1
- package/lib/types/commands/commands/doc-header-footer.command.d.ts +4 -0
- package/lib/types/commands/commands/paragraph-align.command.d.ts +1 -1
- package/lib/types/commands/commands/switch-doc-mode.command.d.ts +4 -0
- package/lib/types/controllers/doc-header-footer.controller.d.ts +2 -0
- package/lib/types/controllers/menu/menu.d.ts +1 -0
- package/lib/types/controllers/render-controllers/doc-ime-input.controller.d.ts +5 -5
- package/lib/types/controllers/render-controllers/doc-input.controller.d.ts +5 -3
- package/lib/types/controllers/render-controllers/doc.render-controller.d.ts +2 -3
- package/lib/types/controllers/render-controllers/zoom.render-controller.d.ts +2 -2
- package/lib/types/facade/f-document.d.ts +34 -0
- package/lib/types/facade/f-univer.d.ts +34 -0
- package/lib/types/facade/index.d.ts +1 -0
- package/lib/types/index.d.ts +2 -4
- package/lib/types/locale/zh-CN.d.ts +1 -0
- package/lib/types/services/doc-auto-format.service.d.ts +2 -2
- package/lib/types/services/doc-event-manager.service.d.ts +2 -2
- package/lib/types/services/doc-ime-input-manager.service.d.ts +1 -1
- package/lib/types/services/doc-menu-style.service.d.ts +12 -0
- package/lib/types/services/doc-state-change-manager.service.d.ts +10 -0
- package/lib/types/services/editor/editor-manager.service.d.ts +63 -0
- package/lib/types/services/selection/text-range.d.ts +2 -2
- package/lib/types/views/doc-container/DocContainer.d.ts +1 -1
- package/lib/umd/facade.js +19 -0
- package/lib/umd/index.js +14 -14
- package/lib/umd/locale/en-US.js +1 -0
- package/lib/umd/locale/fa-IR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -0
- package/lib/umd/locale/vi-VN.js +1 -0
- package/lib/umd/locale/zh-CN.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -0
- package/package.json +23 -21
- package/LICENSE +0 -176
- package/lib/cjs/index.js +0 -37
- package/lib/locale/en-US.json +0 -81
- package/lib/locale/fa-IR.json +0 -81
- package/lib/locale/ru-RU.json +0 -81
- package/lib/locale/vi-VN.json +0 -81
- package/lib/locale/zh-CN.json +0 -81
- package/lib/locale/zh-TW.json +0 -81
- package/lib/types/basics/custom-range-factory.d.ts +0 -25
- package/lib/types/basics/replace.d.ts +0 -20
- /package/lib/types/commands/commands/{delete.command.d.ts → doc-delete.command.d.ts} +0 -0
package/lib/es/facade.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { Inject, Injector, UniverInstanceType, UndoCommand, RedoCommand, DOC_RANGE_TYPE, IUniverInstanceService, ICommandService, IResourceManagerService, FUniver } from "@univerjs/core";
|
|
6
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
7
|
+
import { I as InsertCommand, D as DocSelectionRenderService } from "../core-editing.command-DAmOCaTR.mjs";
|
|
8
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
9
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
11
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
12
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a;
|
|
13
|
+
let FDocument = (_a = class {
|
|
14
|
+
constructor(_documentDataModel, _injector, _univerInstanceService, _commandService, _resourceManagerService, _renderManagerService) {
|
|
15
|
+
__publicField(this, "id");
|
|
16
|
+
this._documentDataModel = _documentDataModel, this._injector = _injector, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._resourceManagerService = _resourceManagerService, this._renderManagerService = _renderManagerService, this.id = this._documentDataModel.getUnitId();
|
|
17
|
+
}
|
|
18
|
+
getId() {
|
|
19
|
+
return this._documentDataModel.getUnitId();
|
|
20
|
+
}
|
|
21
|
+
getName() {
|
|
22
|
+
return this.getSnapshot().title || "";
|
|
23
|
+
}
|
|
24
|
+
getSnapshot() {
|
|
25
|
+
const resources = this._resourceManagerService.getResourcesByType(this.id, UniverInstanceType.UNIVER_DOC), snapshot = this._documentDataModel.getSnapshot();
|
|
26
|
+
return snapshot.resources = resources, snapshot;
|
|
27
|
+
}
|
|
28
|
+
undo() {
|
|
29
|
+
return this._univerInstanceService.focusUnit(this.id), this._commandService.executeCommand(UndoCommand.id);
|
|
30
|
+
}
|
|
31
|
+
redo() {
|
|
32
|
+
return this._univerInstanceService.focusUnit(this.id), this._commandService.executeCommand(RedoCommand.id);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Adds the specified text to the end of this text region.
|
|
36
|
+
* @param text
|
|
37
|
+
*/
|
|
38
|
+
appendText(text) {
|
|
39
|
+
const unitId = this.id, { body } = this.getSnapshot();
|
|
40
|
+
if (!body)
|
|
41
|
+
throw new Error("The document body is empty");
|
|
42
|
+
const lastPosition = body.dataStream.length - 2, activeRange = {
|
|
43
|
+
startOffset: lastPosition,
|
|
44
|
+
endOffset: lastPosition,
|
|
45
|
+
collapsed: !0,
|
|
46
|
+
segmentId: ""
|
|
47
|
+
}, { segmentId } = activeRange;
|
|
48
|
+
return this._commandService.executeCommand(InsertCommand.id, {
|
|
49
|
+
unitId,
|
|
50
|
+
body: {
|
|
51
|
+
dataStream: text
|
|
52
|
+
},
|
|
53
|
+
range: activeRange,
|
|
54
|
+
segmentId
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Sets the selection to a specified text range in the document.
|
|
59
|
+
*
|
|
60
|
+
* @param startOffset - The starting offset of the selection in the document.
|
|
61
|
+
* @param endOffset - The ending offset of the selection in the document.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* document.setSelection(10, 20);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
setSelection(startOffset, endOffset) {
|
|
69
|
+
var _a2;
|
|
70
|
+
const docSelectionRenderService = (_a2 = this._renderManagerService.getRenderById(this.getId())) == null ? void 0 : _a2.with(DocSelectionRenderService);
|
|
71
|
+
docSelectionRenderService == null || docSelectionRenderService.removeAllRanges(), docSelectionRenderService == null || docSelectionRenderService.addDocRanges(
|
|
72
|
+
[
|
|
73
|
+
{
|
|
74
|
+
startOffset,
|
|
75
|
+
endOffset,
|
|
76
|
+
rangeType: DOC_RANGE_TYPE.TEXT
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
!0
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}, __name(_a, "FDocument"), _a);
|
|
83
|
+
FDocument = __decorateClass([
|
|
84
|
+
__decorateParam(1, Inject(Injector)),
|
|
85
|
+
__decorateParam(2, IUniverInstanceService),
|
|
86
|
+
__decorateParam(3, ICommandService),
|
|
87
|
+
__decorateParam(4, IResourceManagerService),
|
|
88
|
+
__decorateParam(5, IRenderManagerService)
|
|
89
|
+
], FDocument);
|
|
90
|
+
const _FUniverDocsMixin = class _FUniverDocsMixin extends FUniver {
|
|
91
|
+
createUniverDoc(data) {
|
|
92
|
+
const document = this._univerInstanceService.createUnit(UniverInstanceType.UNIVER_DOC, data);
|
|
93
|
+
return this._injector.createInstance(FDocument, document);
|
|
94
|
+
}
|
|
95
|
+
getActiveDocument() {
|
|
96
|
+
const document = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
97
|
+
return document ? this._injector.createInstance(FDocument, document) : null;
|
|
98
|
+
}
|
|
99
|
+
getUniverDoc(id) {
|
|
100
|
+
const document = this._univerInstanceService.getUniverDocInstance(id);
|
|
101
|
+
return document ? this._injector.createInstance(FDocument, document) : null;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
__name(_FUniverDocsMixin, "FUniverDocsMixin");
|
|
105
|
+
let FUniverDocsMixin = _FUniverDocsMixin;
|
|
106
|
+
FUniver.extend(FUniverDocsMixin);
|
|
107
|
+
export {
|
|
108
|
+
FDocument
|
|
109
|
+
};
|