@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.
Files changed (44) hide show
  1. package/lib/cjs/facade.js +175 -1
  2. package/lib/cjs/index.js +15328 -12
  3. package/lib/cjs/locale/ca-ES.js +123 -1
  4. package/lib/cjs/locale/en-US.js +138 -1
  5. package/lib/cjs/locale/es-ES.js +123 -1
  6. package/lib/cjs/locale/fa-IR.js +123 -1
  7. package/lib/cjs/locale/fr-FR.js +123 -1
  8. package/lib/cjs/locale/ja-JP.js +123 -1
  9. package/lib/cjs/locale/ko-KR.js +123 -1
  10. package/lib/cjs/locale/ru-RU.js +123 -1
  11. package/lib/cjs/locale/sk-SK.js +123 -1
  12. package/lib/cjs/locale/vi-VN.js +123 -1
  13. package/lib/cjs/locale/zh-CN.js +123 -1
  14. package/lib/cjs/locale/zh-TW.js +123 -1
  15. package/lib/es/facade.js +169 -1
  16. package/lib/es/index.js +15133 -12
  17. package/lib/es/locale/ca-ES.js +122 -1
  18. package/lib/es/locale/en-US.js +137 -1
  19. package/lib/es/locale/es-ES.js +122 -1
  20. package/lib/es/locale/fa-IR.js +122 -1
  21. package/lib/es/locale/fr-FR.js +122 -1
  22. package/lib/es/locale/ja-JP.js +122 -1
  23. package/lib/es/locale/ko-KR.js +122 -1
  24. package/lib/es/locale/ru-RU.js +122 -1
  25. package/lib/es/locale/sk-SK.js +122 -1
  26. package/lib/es/locale/vi-VN.js +122 -1
  27. package/lib/es/locale/zh-CN.js +122 -1
  28. package/lib/es/locale/zh-TW.js +122 -1
  29. package/lib/facade.js +169 -1
  30. package/lib/index.js +15133 -12
  31. package/lib/locale/ca-ES.js +122 -1
  32. package/lib/locale/en-US.js +137 -1
  33. package/lib/locale/es-ES.js +122 -1
  34. package/lib/locale/fa-IR.js +122 -1
  35. package/lib/locale/fr-FR.js +122 -1
  36. package/lib/locale/ja-JP.js +122 -1
  37. package/lib/locale/ko-KR.js +122 -1
  38. package/lib/locale/ru-RU.js +122 -1
  39. package/lib/locale/sk-SK.js +122 -1
  40. package/lib/locale/vi-VN.js +122 -1
  41. package/lib/locale/zh-CN.js +122 -1
  42. package/lib/locale/zh-TW.js +122 -1
  43. package/lib/umd/index.js +9 -9
  44. package/package.json +11 -11
package/lib/cjs/facade.js CHANGED
@@ -1 +1,175 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/core/facade`),n=require(`@univerjs/docs-ui`),r=require(`@univerjs/engine-render`);function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let u=class{constructor(e,t,n,r,i,a){this._documentDataModel=e,this._injector=t,this._univerInstanceService=n,this._commandService=r,this._resourceManagerService=i,this._renderManagerService=a,s(this,`id`,void 0),this.id=this._documentDataModel.getUnitId()}getId(){return this._documentDataModel.getUnitId()}getName(){return this.getSnapshot().title||``}getSnapshot(){let t=this._resourceManagerService.getResourcesByType(this.id,e.UniverInstanceType.UNIVER_DOC),n=this._documentDataModel.getSnapshot();return n.resources=t,n}undo(){return this._univerInstanceService.focusUnit(this.id),this._commandService.executeCommand(e.UndoCommand.id)}redo(){return this._univerInstanceService.focusUnit(this.id),this._commandService.executeCommand(e.RedoCommand.id)}appendText(e){let t=this.id,{body:r}=this.getSnapshot();if(!r)throw Error(`The document body is empty`);let i=r.dataStream.length-2,a={startOffset:i,endOffset:i,collapsed:!0,segmentId:``},{segmentId:o}=a;return this._commandService.executeCommand(n.InsertCommand.id,{unitId:t,body:{dataStream:e},range:a,segmentId:o})}setSelection(t,r){var i;let a=(i=this._renderManagerService.getRenderById(this.getId()))==null?void 0:i.with(n.DocSelectionRenderService);a==null||a.removeAllRanges(),a==null||a.addDocRanges([{startOffset:t,endOffset:r,rangeType:e.DOC_RANGE_TYPE.TEXT}],!0)}};u=l([c(1,(0,e.Inject)(e.Injector)),c(2,e.IUniverInstanceService),c(3,e.ICommandService),c(4,e.IResourceManagerService),c(5,r.IRenderManagerService)],u);var d=class extends t.FUniver{createUniverDoc(t){let n=this._univerInstanceService.createUnit(e.UniverInstanceType.UNIVER_DOC,t);return this._injector.createInstance(u,n)}getActiveDocument(){let t=this._univerInstanceService.getCurrentUnitForType(e.UniverInstanceType.UNIVER_DOC);return t?this._injector.createInstance(u,t):null}getUniverDoc(e){let t=this._univerInstanceService.getUniverDocInstance(e);return t?this._injector.createInstance(u,t):null}};t.FUniver.extend(d),Object.defineProperty(exports,`FDocument`,{enumerable:!0,get:function(){return u}});
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
+ });