@univerjs/docs 1.5.1 → 1.6.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 +9 -9
- package/lib/cjs/index.js +20 -16
- package/lib/cjs/{protocol-DG4ZNc9h.js → protocol-BfcveOck.js} +8 -7
- package/lib/cjs/worker.js +4 -6
- package/lib/es/facade.js +10 -10
- package/lib/es/index.js +23 -20
- package/lib/es/{protocol-Cwx95k-U.js → protocol-RIk-lM8_.js} +8 -7
- package/lib/es/worker.js +5 -7
- package/lib/facade.js +10 -10
- package/lib/index.js +23 -20
- package/lib/{protocol-Cwx95k-U.js → protocol-RIk-lM8_.js} +8 -7
- package/lib/types/commands/mutations/core-editing.mutation.d.ts +2 -0
- package/lib/types/facade/f-document-paragraph.d.ts +2 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/services/doc-state-change-manager.service.d.ts +1 -1
- package/lib/types/services/doc-state-emit.service.d.ts +1 -0
- package/lib/types/services/permission/document-permission.d.ts +5 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/lib/worker.js +5 -7
- package/package.json +8 -8
package/lib/facade.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BooleanNumber, ColumnSeparatorType, DashStyleType, DataStreamTreeTokenType, DocumentFlavor, ICommandService, IPermissionService, IResourceLoaderService, IUniverInstanceService, Inject, Injector, JSONX, PageOrientType, PresetListType, RESTORE_INSERTED_PARAGRAPH_IDS, RedoCommand, SectionType, TextX, TextXActionType, Tools, UndoCommand, UniverInstanceType, UpdateDocsAttributeType, createParagraphId, createSectionId, generateRandomId, getParagraphContentStartOffset, getRichTextEditPath, getSectionHeaderFooterReferenceKey, regexp, resolveSectionHeaderFooterReference } from "@univerjs/core";
|
|
1
|
+
import { BooleanNumber, ColumnSeparatorType, DashStyleType, DataStreamTreeTokenType, DocumentFlavor, ICommandService, IPermissionService, IResourceLoaderService, IUniverInstanceService, Inject, Injector, JSONX, PageOrientType, PresetListType, RESTORE_INSERTED_PARAGRAPH_IDS, RedoCommand, SectionType, TextX, TextXActionType, Tools, UndoCommand, UniverInstanceType, UpdateDocsAttributeType, createParagraphId, createSectionId, generateRandomId, getParagraphContentStartOffset, getRichTextEditPath, getSectionHeaderFooterReferenceKey, regexp, resolveDocumentParagraphBullet, resolveSectionHeaderFooterReference } from "@univerjs/core";
|
|
2
2
|
import { FBaseInitialable, FEnum, FUniver } from "@univerjs/core/facade";
|
|
3
3
|
import { CreateHeaderFooterCommand, DeleteDocumentSectionBreakCommand, HeaderFooterType, InsertDocumentColumnBreakCommand, InsertDocumentSectionBreakCommand, InsertTextCommand, RichTextEditingMutation, SetDocumentNameCommand, SetDocumentPermissionCommand, SetDocumentPermissionsCommand, SetSectionHeaderFooterLinkCommand, UpdateDocumentParagraphStyleCommand, UpdateDocumentSectionCommand, canEditDocumentTargets, createSectionColumnProperties, generateParagraphs, getDocumentEntityParentPermissionObjectIds, getDocumentEntityPermissionObjectId, getDocumentParagraphParentPermissionObjectIds, getDocumentParagraphPermissionObjectId, getDocumentPermissionValue, getDocumentSectionPermissionObjectId, getEffectiveSectionPageSetup, getSectionContentWidth, getTopLevelSectionBreaks } from "@univerjs/docs";
|
|
4
4
|
import { UnitAction } from "@univerjs/protocol";
|
|
@@ -301,14 +301,14 @@ function stripBlockTokens(text) {
|
|
|
301
301
|
return Array.from(text).map((char) => char === DataStreamTreeTokenType.PARAGRAPH ? "\n" : char).filter((char) => char !== DataStreamTreeTokenType.BLOCK_START && char !== DataStreamTreeTokenType.BLOCK_END && char !== DataStreamTreeTokenType.SECTION_BREAK).join("").replace(/\n$/, "");
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
// \0@oxc-project+runtime@0.
|
|
304
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorateParam.js
|
|
305
305
|
function __decorateParam(paramIndex, decorator) {
|
|
306
306
|
return function(target, key) {
|
|
307
307
|
decorator(target, key, paramIndex);
|
|
308
308
|
};
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
// \0@oxc-project+runtime@0.
|
|
311
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorate.js
|
|
312
312
|
function __decorate(decorators, target, key, desc) {
|
|
313
313
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
314
314
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -781,7 +781,7 @@ let FDocumentParagraph = class FDocumentParagraph extends FBaseInitialable {
|
|
|
781
781
|
*/
|
|
782
782
|
isListItem() {
|
|
783
783
|
const { paragraph } = this.getInfo();
|
|
784
|
-
return Boolean(
|
|
784
|
+
return Boolean(resolveDocumentParagraphBullet(this._document.getDocumentDataModel().getSnapshot(), paragraph));
|
|
785
785
|
}
|
|
786
786
|
/**
|
|
787
787
|
* Check whether this paragraph is a task/checklist item.
|
|
@@ -794,9 +794,9 @@ let FDocumentParagraph = class FDocumentParagraph extends FBaseInitialable {
|
|
|
794
794
|
* ```
|
|
795
795
|
*/
|
|
796
796
|
isTask() {
|
|
797
|
-
var
|
|
797
|
+
var _resolveDocumentParag;
|
|
798
798
|
const { paragraph } = this.getInfo();
|
|
799
|
-
const listType = (
|
|
799
|
+
const listType = (_resolveDocumentParag = resolveDocumentParagraphBullet(this._document.getDocumentDataModel().getSnapshot(), paragraph)) === null || _resolveDocumentParag === void 0 ? void 0 : _resolveDocumentParag.listType;
|
|
800
800
|
return listType === PresetListType.CHECK_LIST || listType === PresetListType.CHECK_LIST_CHECKED;
|
|
801
801
|
}
|
|
802
802
|
/**
|
|
@@ -1446,7 +1446,7 @@ let FDocumentSection = class FDocumentSection {
|
|
|
1446
1446
|
};
|
|
1447
1447
|
FDocumentSection = __decorate([__decorateParam(2, ICommandService), __decorateParam(3, IPermissionService)], FDocumentSection);
|
|
1448
1448
|
|
|
1449
|
-
// \0@oxc-project+runtime@0.
|
|
1449
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/typeof.js
|
|
1450
1450
|
function _typeof(o) {
|
|
1451
1451
|
"@babel/helpers - typeof";
|
|
1452
1452
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -1456,7 +1456,7 @@ function _typeof(o) {
|
|
|
1456
1456
|
}, _typeof(o);
|
|
1457
1457
|
}
|
|
1458
1458
|
|
|
1459
|
-
// \0@oxc-project+runtime@0.
|
|
1459
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
|
|
1460
1460
|
function toPrimitive(t, e) {
|
|
1461
1461
|
if ("object" != _typeof(t) || !t) return t;
|
|
1462
1462
|
var r;
|
|
@@ -1468,13 +1468,13 @@ function toPrimitive(t, e) {
|
|
|
1468
1468
|
return ("string" === e ? String : Number)(t);
|
|
1469
1469
|
}
|
|
1470
1470
|
|
|
1471
|
-
// \0@oxc-project+runtime@0.
|
|
1471
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
|
|
1472
1472
|
function toPropertyKey(t) {
|
|
1473
1473
|
var i = toPrimitive(t, "string");
|
|
1474
1474
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
1475
1475
|
}
|
|
1476
1476
|
|
|
1477
|
-
// \0@oxc-project+runtime@0.
|
|
1477
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
|
|
1478
1478
|
function _defineProperty(e, r, t) {
|
|
1479
1479
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
1480
1480
|
value: t,
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as _defineProperty, c as name, d as DocLayoutExecutorState, f as DocLayoutExecutorType, g as __decorateParam, h as __decorate, i as DOCS_PLUGIN_CONFIG_KEY, l as version, m as RICH_TEXT_EDITING_MUTATION_ID, n as DocsLayoutWorkerPerformanceTracker, o as defaultPluginConfig, p as DocLayoutSessionStatus, r as DocsLayoutFontLoader, t as DOCS_LAYOUT_WORKER_CHANNEL, u as DocLayoutExecutorService } from "./protocol-
|
|
2
|
-
import { AlignTypeH, BooleanNumber, BuildTextUtils, ColumnSeparatorType, CommandType, CustomCommandExecutionError, CustomRangeType, DEFAULT_STYLES, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DataStreamTreeTokenType, DeleteDirection, DependentOn, Disposable, DisposableCollection, DocumentFlavor, DocxBreakType, DrawingTypeEnum, ErrorService, ICommandService, IConfigService, IPermissionService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, JSON1, JSONX, LocaleService, MemoryCursor, ObjectPermissionRuleModel, ObjectPermissionService, ObjectRelativeFromH, ObjectRelativeFromV, Optional, PAGE_SIZE, PageOrientType, PaperType, PermissionStatus, Plugin, PositionedObjectLayoutType, RESTORE_INSERTED_PARAGRAPH_IDS, RedoCommandId, RxDisposable, SHEET_TEXT_LINE_GAP, SectionType, TRADITIONAL_DOCUMENT_DEFAULT_MARGIN, TextX, TextXActionType, Tools, UndoCommandId, UniverInstanceType, UpdateDocsAttributeType, composeInterceptors, containsInteriorInsertionOffset, createIdentifier, createInterceptorKey, createParagraphId, createSectionId, generateRandomId, getBlockRangeInterval, getColumnGroupRangeInterval, getParagraphContentStartOffset, getParagraphContentStartOffsets, getRichTextEditPath, getSdtBindingKey, getSdtBindingValue, getSectionHeaderFooterReferenceKey, getTableRangeInterval, isInternalEditorID, merge, remove, resolveSectionHeaderFooterReference, toDisposable, validateDocBodyStructure, validateDocumentStructure } from "@univerjs/core";
|
|
3
|
-
import { DocumentSkeleton, DocumentViewModel, FontCache, IRenderManagerService, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, SheetCellDocumentViewModel, getDocumentLayoutPresentation, getFontStyleString } from "@univerjs/engine-render";
|
|
4
|
-
import { BehaviorSubject, Observable, Subject,
|
|
1
|
+
import { _ as _defineProperty, c as name, d as DocLayoutExecutorState, f as DocLayoutExecutorType, g as __decorateParam, h as __decorate, i as DOCS_PLUGIN_CONFIG_KEY, l as version, m as RICH_TEXT_EDITING_MUTATION_ID, n as DocsLayoutWorkerPerformanceTracker, o as defaultPluginConfig, p as DocLayoutSessionStatus, r as DocsLayoutFontLoader, t as DOCS_LAYOUT_WORKER_CHANNEL, u as DocLayoutExecutorService } from "./protocol-RIk-lM8_.js";
|
|
2
|
+
import { AlignTypeH, BooleanNumber, BuildTextUtils, ColumnSeparatorType, CommandType, CustomCommandExecutionError, CustomRangeType, DEFAULT_STYLES, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DataStreamTreeTokenType, DeleteDirection, DependentOn, Disposable, DisposableCollection, DocumentFlavor, DocxBreakType, DrawingTypeEnum, ErrorService, ICommandService, IConfigService, IPermissionService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, JSON1, JSONX, LocaleService, MemoryCursor, ObjectPermissionRuleModel, ObjectPermissionService, ObjectRelativeFromH, ObjectRelativeFromV, Optional, PAGE_SIZE, PageOrientType, PaperType, PermissionStatus, Plugin, PositionedObjectLayoutType, RESTORE_INSERTED_PARAGRAPH_IDS, RedoCommandId, RxDisposable, SHEET_TEXT_LINE_GAP, SectionType, TRADITIONAL_DOCUMENT_DEFAULT_MARGIN, TextX, TextXActionType, Tools, UndoCommandId, UniverInstanceType, UpdateDocsAttributeType, composeInterceptors, containsInteriorInsertionOffset, createIdentifier, createInterceptorKey, createParagraphId, createSectionId, generateRandomId, getBlockRangeInterval, getColumnGroupRangeInterval, getDocumentParagraphStyleForUpdate, getParagraphContentStartOffset, getParagraphContentStartOffsets, getRichTextEditPath, getSdtBindingKey, getSdtBindingValue, getSectionHeaderFooterReferenceKey, getTableRangeInterval, isInternalEditorID, merge, remove, resolveSectionHeaderFooterReference, toDisposable, validateDocBodyStructure, validateDocumentStructure } from "@univerjs/core";
|
|
3
|
+
import { DocumentSkeleton, DocumentViewModel, FontCache, IRenderManagerService, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, SheetCellDocumentViewModel, getDocumentLayoutPresentation, getFontStyleString, hasDocumentHeaderFooterReferenceLayout, hasDocumentReferenceLayout } from "@univerjs/engine-render";
|
|
4
|
+
import { BehaviorSubject, Observable, Subject, share, takeUntil } from "rxjs";
|
|
5
5
|
import { UnitAction, UnitObject } from "@univerjs/protocol";
|
|
6
6
|
import { ChannelService, toModule } from "@univerjs/rpc";
|
|
7
7
|
|
|
@@ -231,7 +231,7 @@ let DocSkeletonManagerService = class DocSkeletonManagerService extends RxDispos
|
|
|
231
231
|
supportsIncrementalLayout() {
|
|
232
232
|
var _this$_context$unit$g;
|
|
233
233
|
const documentFlavor = (_this$_context$unit$g = this._context.unit.getSnapshot().documentStyle) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.documentFlavor;
|
|
234
|
-
return this._docLayoutExecutorService.getExecutor() != null && !isInternalEditorID(this._context.unitId) && !getDocumentLayoutPresentation(this._context.unit) && (documentFlavor === DocumentFlavor.TRADITIONAL || documentFlavor === DocumentFlavor.MODERN);
|
|
234
|
+
return this._docLayoutExecutorService.getExecutor() != null && !isInternalEditorID(this._context.unitId) && !getDocumentLayoutPresentation(this._context.unit) && !hasDocumentHeaderFooterReferenceLayout(this._context.unit) && !hasDocumentReferenceLayout(this._context.unit) && (documentFlavor === DocumentFlavor.TRADITIONAL || documentFlavor === DocumentFlavor.MODERN);
|
|
235
235
|
}
|
|
236
236
|
recalculate() {
|
|
237
237
|
const skeleton = this._skeleton;
|
|
@@ -688,7 +688,7 @@ const RichTextEditingMutation = {
|
|
|
688
688
|
type: CommandType.MUTATION,
|
|
689
689
|
handler: (accessor, params, options) => {
|
|
690
690
|
var _renderManagerService;
|
|
691
|
-
const { unitId, segmentId = "", actions, textRanges, prevTextRanges, trigger, noHistory, isCompositionEnd, debounce, isEditing = true, isSync: paramsIsSync, syncer } = params;
|
|
691
|
+
const { unitId, segmentId = "", actions, textRanges, prevTextRanges, trigger, noHistory, skipHistory, isCompositionEnd, debounce, isEditing = true, isSync: paramsIsSync, syncer } = params;
|
|
692
692
|
const isSync = Boolean(paramsIsSync || (options === null || options === void 0 ? void 0 : options.fromCollab) || (options === null || options === void 0 ? void 0 : options.fromChangeset));
|
|
693
693
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
694
694
|
const renderManagerService = accessor.get(IRenderManagerService);
|
|
@@ -735,6 +735,7 @@ const RichTextEditingMutation = {
|
|
|
735
735
|
segmentId,
|
|
736
736
|
trigger,
|
|
737
737
|
noHistory,
|
|
738
|
+
skipHistory,
|
|
738
739
|
debounce,
|
|
739
740
|
redoState: {
|
|
740
741
|
...presentation ? { layoutState: params.layoutState } : {},
|
|
@@ -1303,6 +1304,13 @@ function getDocumentPermissionValue(permissionService, unitId, objectId, action)
|
|
|
1303
1304
|
var _permissionService$ge;
|
|
1304
1305
|
return ((_permissionService$ge = permissionService.getPermissionPoint(createDocumentPermissionPoint(unitId, objectId, action).id)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value) ?? true;
|
|
1305
1306
|
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Whether comments can be written in the document. Reads are not restricted by
|
|
1309
|
+
* this point; a user who can open the document can also read its comments.
|
|
1310
|
+
*/
|
|
1311
|
+
function getDocumentCommentPermission(permissionService, unitId) {
|
|
1312
|
+
return getDocumentPermissionValue(permissionService, unitId, unitId, UnitAction.Comment);
|
|
1313
|
+
}
|
|
1306
1314
|
function setDocumentPermissionValue(permissionService, unitId, objectId, action, value) {
|
|
1307
1315
|
const point = createDocumentPermissionPoint(unitId, objectId, action);
|
|
1308
1316
|
if (!permissionService.getPermissionPoint(point.id)) permissionService.addPermissionPoint(point);
|
|
@@ -1825,7 +1833,7 @@ function getCurrentParagraph(body, params) {
|
|
|
1825
1833
|
const paragraph = matches[0];
|
|
1826
1834
|
return getParagraphContentStartOffset(body, paragraph) === params.startOffset && paragraph.startIndex === params.endOffset && body.dataStream[params.endOffset] === "\r" ? paragraph : null;
|
|
1827
1835
|
}
|
|
1828
|
-
function createParagraphStyleTextX(body, paragraph, params) {
|
|
1836
|
+
function createParagraphStyleTextX(body, paragraph, params, documentDataModel) {
|
|
1829
1837
|
const textX = new TextX();
|
|
1830
1838
|
const initializesTextRuns = Boolean(params.style.textStyle && params.startOffset < params.endOffset && body.textRuns == null);
|
|
1831
1839
|
if (params.startOffset > 0) textX.push({
|
|
@@ -1854,10 +1862,7 @@ function createParagraphStyleTextX(body, paragraph, params) {
|
|
|
1854
1862
|
paragraphs: [{
|
|
1855
1863
|
...Tools.deepClone(paragraph),
|
|
1856
1864
|
startIndex: 0,
|
|
1857
|
-
paragraphStyle:
|
|
1858
|
-
...Tools.deepClone(paragraph.paragraphStyle ?? {}),
|
|
1859
|
-
...Tools.deepClone(params.style)
|
|
1860
|
-
}
|
|
1865
|
+
paragraphStyle: getDocumentParagraphStyleForUpdate(documentDataModel.getSnapshot(), paragraph, params.style)
|
|
1861
1866
|
}]
|
|
1862
1867
|
};
|
|
1863
1868
|
Object.defineProperty(paragraphBody, RESTORE_INSERTED_PARAGRAPH_IDS, {
|
|
@@ -1889,7 +1894,7 @@ const UpdateDocumentParagraphStyleCommand = {
|
|
|
1889
1894
|
if (!documentDataModel || !body) return false;
|
|
1890
1895
|
const paragraph = getCurrentParagraph(body, params);
|
|
1891
1896
|
if (!paragraph) return false;
|
|
1892
|
-
const { textX, initializesTextRuns } = createParagraphStyleTextX(body, paragraph, params);
|
|
1897
|
+
const { textX, initializesTextRuns } = createParagraphStyleTextX(body, paragraph, params, documentDataModel);
|
|
1893
1898
|
const jsonX = JSONX.getInstance();
|
|
1894
1899
|
const path = getRichTextEditPath(documentDataModel, segmentId);
|
|
1895
1900
|
let actions = jsonX.editOp(textX.serialize(), path);
|
|
@@ -2783,8 +2788,8 @@ let DocStateChangeManagerService = class DocStateChangeManagerService extends Rx
|
|
|
2783
2788
|
});
|
|
2784
2789
|
}
|
|
2785
2790
|
_cacheChangeState(changeState, type = "history") {
|
|
2786
|
-
const { trigger, unitId, noHistory, debounce = false } = changeState;
|
|
2787
|
-
if (noHistory || type === "history" && trigger == null) return;
|
|
2791
|
+
const { trigger, unitId, noHistory, skipHistory, debounce = false } = changeState;
|
|
2792
|
+
if (noHistory || type === "history" && (skipHistory || trigger == null)) return;
|
|
2788
2793
|
if (type === "history" && (trigger === RedoCommandId || trigger === UndoCommandId)) return;
|
|
2789
2794
|
const stateCache = type === "history" ? this._historyStateCache : this._changeStateCache;
|
|
2790
2795
|
const cb = type === "history" ? this._pushHistory.bind(this) : this._emitChangeState.bind(this);
|
|
@@ -3135,10 +3140,7 @@ function createDocsLayoutWorkerMessageProtocol(worker, performanceTracker) {
|
|
|
3135
3140
|
const handler = (event) => subscriber.next(event.data);
|
|
3136
3141
|
worker.addEventListener("message", handler);
|
|
3137
3142
|
return () => worker.removeEventListener("message", handler);
|
|
3138
|
-
}).pipe(
|
|
3139
|
-
bufferSize: 1,
|
|
3140
|
-
refCount: true
|
|
3141
|
-
}))
|
|
3143
|
+
}).pipe(share())
|
|
3142
3144
|
};
|
|
3143
3145
|
}
|
|
3144
3146
|
var DocsLayoutWorkerClientService = class extends Disposable {
|
|
@@ -3503,7 +3505,8 @@ function generateParagraphs(dataStream, prevParagraph, borderBottom, existingPar
|
|
|
3503
3505
|
});
|
|
3504
3506
|
}
|
|
3505
3507
|
for (const paragraph of paragraphs) {
|
|
3506
|
-
if (prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.
|
|
3508
|
+
if ((prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.styleId) !== void 0) paragraph.styleId = prevParagraph.styleId;
|
|
3509
|
+
if ((prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.bullet) !== void 0) paragraph.bullet = Tools.deepClone(prevParagraph.bullet);
|
|
3507
3510
|
if (prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.paragraphStyle) {
|
|
3508
3511
|
paragraph.paragraphStyle = Tools.deepClone(prevParagraph.paragraphStyle);
|
|
3509
3512
|
delete paragraph.paragraphStyle.borderBottom;
|
|
@@ -3639,4 +3642,4 @@ function normalizeTextRange(textRange) {
|
|
|
3639
3642
|
};
|
|
3640
3643
|
}
|
|
3641
3644
|
|
|
3642
|
-
export { CreateHeaderFooterCommand, DOCUMENT_UNIT_PERMISSION_ACTIONS, DOC_INTERCEPTOR_POINT, DOC_SELECTION_OPTION_PRESERVE_CARET, DeleteDocumentSectionBreakCommand, DeleteTextCommand, DocBlockMoveValidatorService, DocContentInsertService, DocHistoryAction, DocInterceptorService, DocLayoutExecutorService, DocLayoutExecutorState, DocLayoutExecutorType, DocLayoutSessionStatus, DocSelectionManagerService, DocSkeletonManagerService, DocStateChangeManagerService, DocStateEmitService, DocTextResolverService, DocsLayoutWorkerCapabilityError, DocsLayoutWorkerClientService, EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY, HeaderFooterType, IDocStateChangeInterceptorService, InsertDocumentColumnBreakCommand, InsertDocumentSectionBreakCommand, InsertTextCommand, RichTextEditingMutation, SetDocumentDefaultParagraphStyleCommand, SetDocumentNameCommand, SetDocumentPermissionCommand, SetDocumentPermissionRuleMutation, SetDocumentPermissionRulesMutation, SetDocumentPermissionsCommand, SetHeadingCollapsedCommand, SetSectionHeaderFooterLinkCommand, SetTextSelectionsOperation, UniverDocsLayoutWorkerPlugin, UniverDocsPlugin, UpdateDocumentParagraphStyleCommand, UpdateDocumentSectionCommand, UpdateTextCommand, addCustomRangeBySelectionFactory, addCustomRangeFactory, buildDocTransform, canEditDocumentTargets, consumeContentInsertRange, createDocsCustomBlockDrawing, createDocsCustomBlockInsertMutation, createDocsCustomBlockRemoveMutation, createDocumentPermissionPoint, createEmbedDocsCustomBlockData, createInsertCustomBlockActions, createRemoveCustomBlockActions, createSectionColumnProperties, deleteCustomRangeFactory, docDrawingPositionToTransform, generateParagraphs, getContentInsertRange, getDocumentDrawingSegmentId, getDocumentEditTargetObjectIds, getDocumentEntityParentPermissionObjectIds, getDocumentEntityPermissionObjectId, getDocumentParagraphParentPermissionObjectIds, getDocumentParagraphPermissionObjectId, getDocumentPermissionValue, getDocumentSectionPermissionObjectId, getEffectiveSectionPageSetup, getSectionContentWidth, getTopLevelSectionBreaks, isEmbedDocsCustomBlockData, isHeaderFooterSelection, isSheetLikeDocsCustomBlockChildType, normalizeTextRange, replaceSelectionFactory, resolveDocsCustomBlockSize, setDocumentPermissionValue, shouldUseInlineTextSelectionForDocsCustomBlockDrawing, transformDocumentTextRanges, transformToDocDrawingPosition };
|
|
3645
|
+
export { CreateHeaderFooterCommand, DOCUMENT_UNIT_PERMISSION_ACTIONS, DOC_INTERCEPTOR_POINT, DOC_SELECTION_OPTION_PRESERVE_CARET, DeleteDocumentSectionBreakCommand, DeleteTextCommand, DocBlockMoveValidatorService, DocContentInsertService, DocHistoryAction, DocInterceptorService, DocLayoutExecutorService, DocLayoutExecutorState, DocLayoutExecutorType, DocLayoutSessionStatus, DocSelectionManagerService, DocSkeletonManagerService, DocStateChangeManagerService, DocStateEmitService, DocTextResolverService, DocsLayoutWorkerCapabilityError, DocsLayoutWorkerClientService, EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY, HeaderFooterType, IDocStateChangeInterceptorService, InsertDocumentColumnBreakCommand, InsertDocumentSectionBreakCommand, InsertTextCommand, RichTextEditingMutation, SetDocumentDefaultParagraphStyleCommand, SetDocumentNameCommand, SetDocumentPermissionCommand, SetDocumentPermissionRuleMutation, SetDocumentPermissionRulesMutation, SetDocumentPermissionsCommand, SetHeadingCollapsedCommand, SetSectionHeaderFooterLinkCommand, SetTextSelectionsOperation, UniverDocsLayoutWorkerPlugin, UniverDocsPlugin, UpdateDocumentParagraphStyleCommand, UpdateDocumentSectionCommand, UpdateTextCommand, addCustomRangeBySelectionFactory, addCustomRangeFactory, buildDocTransform, canEditDocumentTargets, consumeContentInsertRange, createDocsCustomBlockDrawing, createDocsCustomBlockInsertMutation, createDocsCustomBlockRemoveMutation, createDocumentPermissionPoint, createEmbedDocsCustomBlockData, createInsertCustomBlockActions, createRemoveCustomBlockActions, createSectionColumnProperties, deleteCustomRangeFactory, docDrawingPositionToTransform, generateParagraphs, getContentInsertRange, getDocumentCommentPermission, getDocumentDrawingSegmentId, getDocumentEditTargetObjectIds, getDocumentEntityParentPermissionObjectIds, getDocumentEntityPermissionObjectId, getDocumentParagraphParentPermissionObjectIds, getDocumentParagraphPermissionObjectId, getDocumentPermissionValue, getDocumentSectionPermissionObjectId, getEffectiveSectionPageSetup, getSectionContentWidth, getTopLevelSectionBreaks, isEmbedDocsCustomBlockData, isHeaderFooterSelection, isSheetLikeDocsCustomBlockChildType, normalizeTextRange, replaceSelectionFactory, resolveDocsCustomBlockSize, setDocumentPermissionValue, shouldUseInlineTextSelectionForDocsCustomBlockDrawing, transformDocumentTextRanges, transformToDocDrawingPosition };
|
|
@@ -2,7 +2,7 @@ import { Disposable, DocumentFlavor, ICommandService, ILogService, IUniverInstan
|
|
|
2
2
|
import { FontCache, getDocsCustomBlockRenderViewport } from "@univerjs/engine-render";
|
|
3
3
|
import { BehaviorSubject } from "rxjs";
|
|
4
4
|
|
|
5
|
-
// \0@oxc-project+runtime@0.
|
|
5
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/typeof.js
|
|
6
6
|
function _typeof(o) {
|
|
7
7
|
"@babel/helpers - typeof";
|
|
8
8
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -12,7 +12,7 @@ function _typeof(o) {
|
|
|
12
12
|
}, _typeof(o);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
// \0@oxc-project+runtime@0.
|
|
15
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
|
|
16
16
|
function toPrimitive(t, e) {
|
|
17
17
|
if ("object" != _typeof(t) || !t) return t;
|
|
18
18
|
var r;
|
|
@@ -24,13 +24,13 @@ function toPrimitive(t, e) {
|
|
|
24
24
|
return ("string" === e ? String : Number)(t);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// \0@oxc-project+runtime@0.
|
|
27
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
|
|
28
28
|
function toPropertyKey(t) {
|
|
29
29
|
var i = toPrimitive(t, "string");
|
|
30
30
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// \0@oxc-project+runtime@0.
|
|
33
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
|
|
34
34
|
function _defineProperty(e, r, t) {
|
|
35
35
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
36
36
|
value: t,
|
|
@@ -40,14 +40,14 @@ function _defineProperty(e, r, t) {
|
|
|
40
40
|
}) : e[r] = t, e;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// \0@oxc-project+runtime@0.
|
|
43
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorateParam.js
|
|
44
44
|
function __decorateParam(paramIndex, decorator) {
|
|
45
45
|
return function(target, key) {
|
|
46
46
|
decorator(target, key, paramIndex);
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
// \0@oxc-project+runtime@0.
|
|
50
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorate.js
|
|
51
51
|
function __decorate(decorators, target, key, desc) {
|
|
52
52
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
53
53
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -632,6 +632,7 @@ let DocLayoutExecutorService = _DocLayoutExecutorService = class DocLayoutExecut
|
|
|
632
632
|
collectSegment("", dataModel.getBody());
|
|
633
633
|
for (const [segmentId, headerModel] of dataModel.headerModelMap) collectSegment(segmentId, headerModel.getBody());
|
|
634
634
|
for (const [segmentId, footerModel] of dataModel.footerModelMap) collectSegment(segmentId, footerModel.getBody());
|
|
635
|
+
for (const [segmentId, noteModel] of dataModel.noteModelMap) collectSegment(segmentId, noteModel.getBody());
|
|
635
636
|
return presentations;
|
|
636
637
|
}
|
|
637
638
|
_isEligible(dataModel) {
|
|
@@ -710,7 +711,7 @@ DocLayoutExecutorService = _DocLayoutExecutorService = __decorate([
|
|
|
710
711
|
|
|
711
712
|
// package.json
|
|
712
713
|
var name = "@univerjs/docs";
|
|
713
|
-
var version = "1.
|
|
714
|
+
var version = "1.6.0";
|
|
714
715
|
|
|
715
716
|
// src/config/config.ts
|
|
716
717
|
/**
|
|
@@ -39,6 +39,8 @@ export interface IRichTextEditingMutationParams extends IMutationCommonParams {
|
|
|
39
39
|
noNeedSetTextRange?: boolean;
|
|
40
40
|
isCompositionEnd?: boolean;
|
|
41
41
|
noHistory?: boolean;
|
|
42
|
+
/** Skip automatic undo history while retaining collaboration for a manually owned history item. */
|
|
43
|
+
skipHistory?: boolean;
|
|
42
44
|
debounce?: boolean;
|
|
43
45
|
options?: {
|
|
44
46
|
[key: string]: boolean;
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Injector, IParagraph, IParagraphStyle } from '@univerjs/core';
|
|
17
|
-
import type { FDocument } from './f-document';
|
|
18
|
-
import type { IFDocumentTextRange } from './utils';
|
|
19
17
|
import { ICommandService, IPermissionService } from '@univerjs/core';
|
|
20
18
|
import { FBaseInitialable } from '@univerjs/core/facade';
|
|
19
|
+
import type { FDocument } from './f-document';
|
|
20
|
+
import type { IFDocumentTextRange } from './utils';
|
|
21
21
|
import { FDocumentObjectPermission } from './f-document-permission';
|
|
22
22
|
import { FDocumentTextRange } from './f-document-text-range';
|
|
23
23
|
/**
|
package/lib/types/index.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export type { IDocStateChangeInfo, IDocStateChangeParams } from './services/doc-
|
|
|
58
58
|
export { DocStateEmitService } from './services/doc-state-emit.service';
|
|
59
59
|
export { DocTextResolverService } from './services/doc-text-resolver.service';
|
|
60
60
|
export type { IDocTextReplacement, IDocTextResolver, IResolvedDocText, IResolvedDocTextCharacter, } from './services/doc-text-resolver.service';
|
|
61
|
-
export { canEditDocumentTargets, createDocumentPermissionPoint, DOCUMENT_UNIT_PERMISSION_ACTIONS, getDocumentEntityPermissionObjectId, getDocumentParagraphPermissionObjectId, getDocumentPermissionValue, getDocumentSectionPermissionObjectId, setDocumentPermissionValue, } from './services/permission/document-permission';
|
|
61
|
+
export { canEditDocumentTargets, createDocumentPermissionPoint, DOCUMENT_UNIT_PERMISSION_ACTIONS, getDocumentCommentPermission, getDocumentEntityPermissionObjectId, getDocumentParagraphPermissionObjectId, getDocumentPermissionValue, getDocumentSectionPermissionObjectId, setDocumentPermissionValue, } from './services/permission/document-permission';
|
|
62
62
|
export type { DocumentUnitPermissionAction } from './services/permission/document-permission';
|
|
63
63
|
export { getDocumentDrawingSegmentId, getDocumentEditTargetObjectIds, getDocumentEntityParentPermissionObjectIds, getDocumentParagraphParentPermissionObjectIds, } from './services/permission/document-permission-resolver';
|
|
64
64
|
export { addCustomRangeBySelectionFactory, addCustomRangeFactory, deleteCustomRangeFactory, } from './utils/custom-range-factory';
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Nullable } from '@univerjs/core';
|
|
17
|
-
import type { IDocStateChangeInfo, IDocStateChangeParams } from './doc-state-emit.service';
|
|
18
17
|
import { ICommandService, IUndoRedoService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
|
|
18
|
+
import type { IDocStateChangeInfo, IDocStateChangeParams } from './doc-state-emit.service';
|
|
19
19
|
import { DocStateEmitService } from './doc-state-emit.service';
|
|
20
20
|
interface IStateCache {
|
|
21
21
|
history: IDocStateChangeParams[];
|
|
@@ -30,6 +30,11 @@ export declare function getDocumentParagraphPermissionObjectId(segmentId: string
|
|
|
30
30
|
export declare function getDocumentEntityPermissionObjectId(segmentId: string, entityType: string, entityId: string): string;
|
|
31
31
|
export declare function createDocumentPermissionPoint(unitId: string, objectId: string, action: UnitAction): DocumentCommentPermission | DocumentCopyPermission | DocumentEditablePermission | DocumentEntityEditPermission | DocumentExportPermission | DocumentParagraphEditPermission | DocumentPrintPermission | DocumentSectionEditPermission;
|
|
32
32
|
export declare function getDocumentPermissionValue(permissionService: IPermissionService, unitId: string, objectId: string, action: UnitAction): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether comments can be written in the document. Reads are not restricted by
|
|
35
|
+
* this point; a user who can open the document can also read its comments.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getDocumentCommentPermission(permissionService: IPermissionService, unitId: string): boolean;
|
|
33
38
|
export declare function setDocumentPermissionValue(permissionService: IPermissionService, unitId: string, objectId: string, action: UnitAction, value: boolean): void;
|
|
34
39
|
export declare function clearDocumentPermissionValuesForUnit(permissionService: IPermissionService, unitId: string): void;
|
|
35
40
|
export declare function canEditDocumentTargets(permissionService: IPermissionService, unitId: string, objectIds: Iterable<string>): boolean;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/docs"),require("@univerjs/protocol")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/core/facade`,`@univerjs/docs`,`@univerjs/protocol`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsFacade={},e.UniverCore,e.UniverCoreFacade,e.UniverDocs,e.UniverProtocol))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=class{constructor(e,t,n){this._unitId=e,this._commandService=t,this._permissionService=n}async setObjectPermissions(e){return this._commandService.executeCommand(r.SetDocumentPermissionsCommand.id,{unitId:this._unitId,changes:e})}async setPoint(e,t){await this._commandService.executeCommand(r.SetDocumentPermissionCommand.id,{unitId:this._unitId,objectId:this._unitId,action:e,value:t})}getPoint(e){return(0,r.getDocumentPermissionValue)(this._permissionService,this._unitId,this._unitId,e)}async setEditable(e=!0){await this._commandService.executeCommand(r.SetDocumentPermissionCommand.id,{unitId:this._unitId,objectId:this._unitId,action:i.UnitAction.Edit,value:e})}async setReadOnly(){await this._commandService.executeCommand(r.SetDocumentPermissionCommand.id,{unitId:this._unitId,objectId:this._unitId,action:i.UnitAction.Edit,value:!1})}canEdit(){return(0,r.getDocumentPermissionValue)(this._permissionService,this._unitId,this._unitId,i.UnitAction.Edit)}},o=class{constructor(e,t,n,r,i=()=>[]){this._unitId=e,this._objectId=t,this._commandService=n,this._permissionService=r,this._getParentObjectIds=i}async setEditable(e=!0){await this._commandService.executeCommand(r.SetDocumentPermissionCommand.id,{unitId:this._unitId,objectId:this._objectId,action:i.UnitAction.Edit,value:e})}async setReadOnly(){await this._commandService.executeCommand(r.SetDocumentPermissionCommand.id,{unitId:this._unitId,objectId:this._objectId,action:i.UnitAction.Edit,value:!1})}canEdit(){return(0,r.canEditDocumentTargets)(this._permissionService,this._unitId,[...this._getParentObjectIds(),this._objectId])}};function s(e){return e==null?e:JSON.parse(JSON.stringify(e))}function c(e){return e.replace(/\r\n/g,`\r`).replace(/\n/g,`\r`)}function l(e,t){let n=c(e);return t&&n.length>1&&n.startsWith(`\r`)?1:0}function u(e,n={}){let r=c(e).slice(l(e,n.removeLeadingParagraphBreak)),i={dataStream:r,customDecorations:[],customRanges:[],textRuns:[]},a=[],o=/* @__PURE__ */ new Set;for(let e=0;e<r.length;e++)r[e]===`\r`&&a.push({startIndex:e,paragraphId:(0,t.createParagraphId)(o),...n.paragraphStyle==null?{}:{paragraphStyle:s(n.paragraphStyle)}});return a.length>0&&(i.paragraphs=a),i}function d(e,t,n,i){let{startOffset:a,endOffset:o,segmentId:s}=e;return!!i.syncExecuteCommand(r.InsertTextCommand.id,{unitId:n.getUnitId(),body:t,range:{startOffset:a,endOffset:o,collapsed:a===o,segmentId:s},segmentId:s,debounce:!1,textRanges:[],noNeedSetTextRange:!0,isEditing:!1})}function f(e,n,i,a,o){var s,c;let{startOffset:l,endOffset:u,segmentId:d}=e,f=o.get(t.ICommandService);if((s=n.textRuns)!=null&&s.length&&((c=a.getSelfOrHeaderFooterModel(d))==null||(c=c.getBody())==null?void 0:c.textRuns)==null){let e=t.JSONX.getInstance().replaceOp([...(0,t.getRichTextEditPath)(a,d),`textRuns`],void 0,[]);f.syncExecuteCommand(r.RichTextEditingMutation.id,{unitId:a.getUnitId(),segmentId:d,actions:e,textRanges:[],isEditing:!1})}let p=new t.TextX;l>0&&p.push({t:t.TextXActionType.RETAIN,len:l}),p.push({t:t.TextXActionType.RETAIN,body:n,coverType:i,len:u-l});let m=t.JSONX.getInstance().editOp(p.serialize(),(0,t.getRichTextEditPath)(a,d)),h=f.syncExecuteCommand(r.RichTextEditingMutation.id,{unitId:a.getUnitId(),segmentId:d,actions:m,textRanges:[],isEditing:!1});return!!(h!=null&&h.actions&&h.actions.length>0)}function p(e){return Array.from(e).map(e=>e===t.DataStreamTreeTokenType.PARAGRAPH?`
|
|
2
|
-
`:e).filter(e=>e!==t.DataStreamTreeTokenType.BLOCK_START&&e!==t.DataStreamTreeTokenType.BLOCK_END&&e!==t.DataStreamTreeTokenType.SECTION_BREAK).join(``).replace(/\n$/,``)}function m(e,t){return function(n,r){t(n,r,e)}}function h(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 g=class extends n.FBaseInitialable{constructor(e,t,n,r,i,a){super(i),this._document=e,this._startOffset=t,this._endOffset=n,this._segmentId=r,this._injector=i,this._commandService=a,this._validateRange()}getRange(){return{startOffset:this._startOffset,endOffset:this._endOffset,segmentId:this._segmentId}}getText(){return this._document.getBody(this._segmentId).dataStream.slice(this._startOffset,this._endOffset)}getExplicitTextStyleRuns(){let{textRuns:e=[]}=this._document.getBody(this._segmentId);return e.filter(e=>e.st<this._endOffset&&e.ed>this._startOffset).map(e=>({startOffset:Math.max(e.st,this._startOffset),endOffset:Math.min(e.ed,this._endOffset),textStyle:t.Tools.deepClone(e.ts??{})}))}getCommonExplicitTextStyle(){if(this._startOffset===this._endOffset)return{};let[e,...n]=this._getStyleSegments(),r=t.Tools.deepClone(e.textStyle);for(let e of Object.keys(r))n.some(t=>!_(t.textStyle[e],r[e]))&&delete r[e];return r}describe(){let e=this.getExplicitTextStyleRuns(),t=this.getCommonExplicitTextStyle();return{...this.getRange(),text:this.getText(),length:this._endOffset-this._startOffset,explicitTextStyleRuns:e,commonExplicitTextStyle:t}}setTextStyle(e){return this._startOffset!==this._endOffset&&f(this.getRange(),{dataStream:``,textRuns:[{st:0,ed:this._endOffset-this._startOffset,ts:t.Tools.deepClone(e)}]},t.UpdateDocsAttributeType.COVER,this._document.getDocumentDataModel(),this._injector)}setText(e){return d(this.getRange(),u(e),this._document.getDocumentDataModel(),this._commandService)}_validateRange(){let e=this._document.getBody(this._segmentId).dataStream.length;if(!Number.isInteger(this._startOffset)||!Number.isInteger(this._endOffset)||this._startOffset<0||this._endOffset<this._startOffset||this._endOffset>e)throw RangeError(`Invalid document text range [${this._startOffset}, ${this._endOffset}) for body length ${e}.`)}_getStyleSegments(){let e=this.getExplicitTextStyleRuns(),t=[],n=this._startOffset;for(let r of e)n<r.startOffset&&t.push({startOffset:n,endOffset:r.startOffset,textStyle:{}}),t.push(r),n=r.endOffset;return n<this._endOffset&&t.push({startOffset:n,endOffset:this._endOffset,textStyle:{}}),t}};g=h([m(5,t.ICommandService)],g);function _(e,t){return JSON.stringify(e)===JSON.stringify(t)}let v=class extends n.FBaseInitialable{constructor(e,t,n=``,r,i,a){super(r),this._document=e,this._paragraphId=t,this._segmentId=n,this._injector=r,this._commandService=i,this._permissionService=a}getId(){return this._paragraphId}getSegmentId(){return this._segmentId}getPermission(){return new o(this._document.getId(),(0,r.getDocumentParagraphPermissionObjectId)(this._segmentId,this._paragraphId),this._commandService,this._permissionService,()=>(0,r.getDocumentParagraphParentPermissionObjectIds)(this._document.getDocumentDataModel(),this._segmentId,this._paragraphId))}getInfo(){let e=this._document.getBody(this._segmentId),{paragraphs:n=[]}=e,r=n.map((e,t)=>({paragraph:e,paragraphIndex:t})).filter(({paragraph:e})=>e.paragraphId===this._paragraphId);if(r.length===0)throw Error(`Document paragraph with id ${this._paragraphId} not found`);if(r.length>1)throw Error(`Multiple document paragraphs with id ${this._paragraphId} found`);let{paragraph:i,paragraphIndex:a}=r[0];return{paragraph:i,paragraphIndex:a,startOffset:(0,t.getParagraphContentStartOffset)(e,i),endOffset:i.startIndex}}getRange(){let{startOffset:e,endOffset:t}=this.getInfo();return{startOffset:e,endOffset:t,segmentId:this._segmentId}}getTextRange(){let{startOffset:e,endOffset:t}=this.getInfo();return this._injector.createInstance(g,this._document,e,t,this._segmentId,this._injector)}findText(e,t={}){let n=t.occurrence??0;if(!Number.isInteger(n)||n<0)throw RangeError(`Text occurrence must be a non-negative integer.`);return this.findAllText(e,t)[n]??null}findAllText(e,n={}){if(e.length===0)throw TypeError(`Text to find must not be empty.`);let r=n.matchCase??!0,i=this.getText(),a=t.regexp.createLiteralRegExp(e,r?`gu`:`giu`),{startOffset:o}=this.getInfo(),s=[];for(let e of i.matchAll(a)){let t=o+e.index;s.push(this._injector.createInstance(g,this._document,t,t+e[0].length,this._segmentId,this._injector))}return s}getText(){let{dataStream:e}=this._document.getBody(this._segmentId),{startOffset:t,endOffset:n}=this.getInfo();return e.slice(t,n)}setText(e){let{startOffset:t,endOffset:n}=this.getInfo();return d({startOffset:t,endOffset:n,segmentId:this._segmentId},u(e),this._document.getDocumentDataModel(),this._commandService)}appendText(e){let{endOffset:t}=this.getInfo();return this._document.insertText(t,e,this._segmentId)}setStyle(e){let{startOffset:t,endOffset:n}=this.getInfo();return this._commandService.syncExecuteCommand(r.UpdateDocumentParagraphStyleCommand.id,{unitId:this._document.getId(),segmentId:this._segmentId,paragraphId:this._paragraphId,startOffset:t,endOffset:n,style:e})}isListItem(){let{paragraph:e}=this.getInfo();return!!e.bullet}isTask(){var e;let{paragraph:n}=this.getInfo(),r=(e=n.bullet)==null?void 0:e.listType;return r===t.PresetListType.CHECK_LIST||r===t.PresetListType.CHECK_LIST_CHECKED}setTaskChecked(e){if(!this.isTask())return!1;let{paragraph:n,endOffset:r}=this.getInfo(),i=n.bullet,a={dataStream:``,paragraphs:[{...n,startIndex:0,bullet:{...i,listType:e?t.PresetListType.CHECK_LIST_CHECKED:t.PresetListType.CHECK_LIST}}]};return this._preserveExplicitParagraphIds(a),f({startOffset:r,endOffset:r+1,segmentId:this._segmentId},a,t.UpdateDocsAttributeType.REPLACE,this._document.getDocumentDataModel(),this._injector)}remove(){let{startOffset:e,endOffset:t}=this.getInfo();return this._document.deleteRange({startOffset:e,endOffset:t+1,segmentId:this._segmentId})}_preserveExplicitParagraphIds(e){e[t.RESTORE_INSERTED_PARAGRAPH_IDS]=!0}};v=h([m(4,t.ICommandService),m(5,t.IPermissionService)],v);function y(e){return typeof e!=`object`||!e?!1:typeof e.getId==`function`&&typeof e.getSegmentId==`function`&&typeof e.getInfo==`function`&&typeof e.getRange==`function`}function b(e){let{pageNumberStart:n,pageSize:r,pageOrient:i,marginTop:a,marginBottom:o,marginLeft:s,marginRight:c}=e;if(n!=null&&(!Number.isInteger(n)||n<1))throw RangeError(`Section page number start must be a positive integer.`);if(r&&[r.width,r.height].some(e=>e!=null&&(!Number.isFinite(e)||e<=0)))throw RangeError(`Section page size must be finite and positive.`);if(i!=null&&!Object.values(t.PageOrientType).includes(i))throw RangeError(`Invalid section page orientation.`);if([a,o,s,c].some(e=>e!=null&&(!Number.isFinite(e)||e<0)))throw RangeError(`Section page margins must be finite and non-negative.`)}var x=class extends Error{constructor(){super(`Section column APIs are supported only in traditional documents. Use ColumnGroup APIs for modern documents, or resolve an unspecified document flavor first.`),this.name=`DocsSectionUnsupportedDocumentFlavorError`}};let S=class{constructor(e,t,n,r){this._document=e,this._sectionId=t,this._commandService=n,this._permissionService=r}getId(){return this._sectionId}getPermission(){return new o(this._document.getId(),(0,r.getDocumentSectionPermissionObjectId)(``,this._sectionId),this._commandService,this._permissionService)}getIndex(){return this._resolve().index}getConfig(){return this._getConfigSnapshot()}getRange(){return this._getRange(this._resolve().index)}getColumns(){return t.Tools.deepClone(this._getConfigSnapshot().columnProperties??[])}describe(){let{index:e}=this._resolve(),n=this._getConfigSnapshot(),r=n.columnProperties??[],i={defaultHeader:this._describeHeaderFooterReference(`header`,`default`),defaultFooter:this._describeHeaderFooterReference(`footer`,`default`),firstHeader:this._describeHeaderFooterReference(`header`,`first`),firstFooter:this._describeHeaderFooterReference(`footer`,`first`),evenHeader:this._describeHeaderFooterReference(`header`,`even`),evenFooter:this._describeHeaderFooterReference(`footer`,`even`)};return{sectionId:this._sectionId,index:e,range:this._getRange(e),columnCount:r.length||1,columns:t.Tools.deepClone(r),columnSeparatorType:n.columnSeparatorType??t.ColumnSeparatorType.NONE,sectionType:n.sectionType??t.SectionType.SECTION_TYPE_UNSPECIFIED,headerFooter:i,config:n}}setColumns(e,n={}){if(this._assertTraditionalDocument(),!Number.isInteger(e)||e<1)throw RangeError(`Section column count must be a positive integer.`);if(n.widths&&n.widths.length!==e)throw RangeError(`Section column widths must match the column count.`);if(n.gap!=null&&(!Number.isFinite(n.gap)||n.gap<0))throw RangeError(`Section column gap must be finite and non-negative.`);let i=Math.max(0,n.gap??18),a=this._getConfigSnapshot(),o=(0,r.createSectionColumnProperties)(this._document.getDocumentDataModel().getSnapshot().documentStyle,a,e,i,n.widths),s=typeof n.separator==`boolean`?n.separator?t.ColumnSeparatorType.BETWEEN_EACH_COLUMN:t.ColumnSeparatorType.NONE:n.separator??t.ColumnSeparatorType.NONE;if(!Object.values(t.ColumnSeparatorType).includes(s))throw RangeError(`Invalid section column separator type.`);return this._update({columnProperties:o,columnSeparatorType:s})}setColumnProperties(e,n=t.ColumnSeparatorType.NONE){if(this._assertTraditionalDocument(),!Object.values(t.ColumnSeparatorType).includes(n))throw RangeError(`Invalid section column separator type.`);if(e.some(({width:e,paddingEnd:t})=>!Number.isFinite(e)||!Number.isFinite(t)||e<0||t<0))throw RangeError(`Section column widths and padding must be finite and non-negative.`);let i=(0,r.getSectionContentWidth)(this._document.getDocumentDataModel().getSnapshot().documentStyle,this._getConfigSnapshot());if(e.reduce((e,{width:t,paddingEnd:n})=>e+t+n,0)>i)throw RangeError(`Section columns exceed the available page content width.`);return this._update({columnProperties:t.Tools.deepClone(e),columnSeparatorType:n})}setSectionType(e){if(this._assertTraditionalDocument(),!Object.values(t.SectionType).includes(e))throw RangeError(`Invalid section type.`);return this._update({sectionType:e})}getPageSetup(){let{pageNumberStart:e,pageSize:n,pageOrient:r,marginTop:i,marginBottom:a,marginLeft:o,marginRight:s}=this._getConfigSnapshot();return t.Tools.deepClone({pageNumberStart:e,pageSize:n,pageOrient:r,marginTop:i,marginBottom:a,marginLeft:o,marginRight:s})}getEffectivePageSetup(){this._assertTraditionalDocument();let e=this._document.getDocumentDataModel().getSnapshot().documentStyle;return t.Tools.deepClone((0,r.getEffectiveSectionPageSetup)(e,this._getConfigSnapshot()))}setPageSetup(e){this._assertTraditionalDocument(),b(e);let n=t.Tools.deepClone(e);t.Tools.removeNull(n);let i=this._document.getDocumentDataModel().getSnapshot().documentStyle;return(0,r.getEffectiveSectionPageSetup)(i,{...this._getConfigSnapshot(),...n}),this._update(n)}ensureHeader(e=`default`){return this._ensureHeaderFooter(`header`,e)}ensureFooter(e=`default`){return this._ensureHeaderFooter(`footer`,e)}getHeaderId(e=`default`){return this._getHeaderFooterReference(`header`,e).segmentId??null}getFooterId(e=`default`){return this._getHeaderFooterReference(`footer`,e).segmentId??null}isHeaderLinkedToPrevious(e=`default`){return this._getHeaderFooterReference(`header`,e).linkedToPrevious}isFooterLinkedToPrevious(e=`default`){return this._getHeaderFooterReference(`footer`,e).linkedToPrevious}setHeaderLinkedToPrevious(e,t=`default`){return this._setHeaderFooterLinkedToPrevious(`header`,t,e)}setFooterLinkedToPrevious(e,t=`default`){return this._setHeaderFooterLinkedToPrevious(`footer`,t,e)}setHeaderFooterOptions(e){return this._assertTraditionalDocument(),this._update(e)}remove(){return this._assertTraditionalDocument(),this._commandService.syncExecuteCommand(r.DeleteDocumentSectionBreakCommand.id,{unitId:this._document.getId(),sectionId:this._sectionId})}_update(e){let{sectionId:t,startIndex:n,...i}=e;return this._commandService.syncExecuteCommand(r.UpdateDocumentSectionCommand.id,{unitId:this._document.getId(),updates:[{sectionId:this._sectionId,config:i}]})}_ensureHeaderFooter(e,n){this._assertTraditionalDocument();let{index:i}=this._resolve(),a=this._getConfigSnapshot()[(0,t.getSectionHeaderFooterReferenceKey)(e,n)];if(typeof a==`string`&&a)return a;if(i>0){let i=(0,t.generateRandomId)(6);if(!this._commandService.syncExecuteCommand(r.SetSectionHeaderFooterLinkCommand.id,{unitId:this._document.getId(),sectionId:this._sectionId,kind:e,variant:n,linkedToPrevious:!1,segmentId:i}))throw Error(`Failed to create section ${e}.`);return i}let o={default:e===`header`?r.HeaderFooterType.DEFAULT_HEADER:r.HeaderFooterType.DEFAULT_FOOTER,first:e===`header`?r.HeaderFooterType.FIRST_PAGE_HEADER:r.HeaderFooterType.FIRST_PAGE_FOOTER,even:e===`header`?r.HeaderFooterType.EVEN_PAGE_HEADER:r.HeaderFooterType.EVEN_PAGE_FOOTER},s=(0,t.generateRandomId)(6);if(!this._commandService.syncExecuteCommand(r.CreateHeaderFooterCommand.id,{unitId:this._document.getId(),segmentId:s,createType:o[n],sectionId:this._sectionId}))throw Error(`Failed to create section ${e}.`);return s}_getHeaderFooterReference(e,n){let{index:i}=this._resolve(),a=this._document.getDocumentDataModel().getSnapshot();return(0,t.resolveSectionHeaderFooterReference)(a.documentStyle,(0,r.getTopLevelSectionBreaks)(this._document.getBody()),i,(0,t.getSectionHeaderFooterReferenceKey)(e,n))}_describeHeaderFooterReference(e,t){let n=this._getHeaderFooterReference(e,t);return{segmentId:n.segmentId??null,linkedToPrevious:n.linkedToPrevious}}_setHeaderFooterLinkedToPrevious(e,n,i){return this._assertTraditionalDocument(),this._commandService.syncExecuteCommand(r.SetSectionHeaderFooterLinkCommand.id,{unitId:this._document.getId(),sectionId:this._sectionId,kind:e,variant:n,linkedToPrevious:i,...i?{}:{segmentId:(0,t.generateRandomId)(6)}})}_assertTraditionalDocument(){if(this._document.getDocumentDataModel().getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)throw new x}_getConfigSnapshot(){return t.Tools.deepClone(this._resolve().sectionBreak)}_getRange(e){let t=(0,r.getTopLevelSectionBreaks)(this._document.getBody());return{startOffset:e===0?0:t[e-1].startIndex+1,endOffset:t[e].startIndex,segmentId:``}}_resolve(){this._assertTraditionalDocument();let e=(0,r.getTopLevelSectionBreaks)(this._document.getBody()),t=e.findIndex(e=>e.sectionId===this._sectionId);if(t<0)throw Error(`Document section with id ${this._sectionId} not found.`);return{index:t,sectionBreak:e[t]}}};S=h([m(2,t.ICommandService),m(3,t.IPermissionService)],S);function C(e){"@babel/helpers - typeof";return C=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},C(e)}function w(e,t){if(C(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(C(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function T(e){var t=w(e,`string`);return C(t)==`symbol`?t:t+``}function E(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=class extends n.FBaseInitialable{constructor(e,t,n,r,i,a){super(t),this._documentDataModel=e,this._injector=t,this._univerInstanceService=n,this._resourceLoaderService=r,this._commandService=i,this._permissionService=a,E(this,`id`,void 0),this.id=this._documentDataModel.getUnitId()}getDocumentDataModel(e=``){let t=this._documentDataModel.getSelfOrHeaderFooterModel(e);if(!t)throw Error(e===``?`Document data model is not found.`:`Document data model is not found in the segment: ${e}`);return t}getCustomBlockLayout(){var e;return{blocks:(((e=this._documentDataModel.getBody())==null?void 0:e.customBlocks)??[]).map(({blockId:e,startIndex:t},n)=>({blockId:e,startIndex:t,index:n}))}}getBody(e=``){var t;let n=(t=this._documentDataModel.getSelfOrHeaderFooterModel(e))==null?void 0:t.getBody();if(!n)throw Error(e===``?`Body is not found in the document.`:`Body is not found in the segment: ${e}`);return n}dispose(){super.dispose()}getId(){return this.id}getPermission(){return new a(this.id,this._commandService,this._permissionService)}getEntityPermission(e,t,n){return new o(this.id,(0,r.getDocumentEntityPermissionObjectId)(e,t,n),this._commandService,this._permissionService,()=>(0,r.getDocumentEntityParentPermissionObjectIds)(this._documentDataModel,e,t,n))}getName(){return this._documentDataModel.getTitle()||``}setName(e){return this._commandService.syncExecuteCommand(r.SetDocumentNameCommand.id,{unitId:this.id,name:e}),this}getDocumentFlavor(){return this._resolveDocumentFlavor()}isTraditional(){return this._resolveDocumentFlavor()===t.DocumentFlavor.TRADITIONAL}isModern(){return this._resolveDocumentFlavor()===t.DocumentFlavor.MODERN}_resolveDocumentFlavor(){return this._documentDataModel.getSnapshot().documentStyle.documentFlavor??t.DocumentFlavor.UNSPECIFIED}save(){return this._resourceLoaderService.saveUnit(this._documentDataModel.getUnitId())}undo(){return this._univerInstanceService.focusUnit(this.id),this._commandService.syncExecuteCommand(t.UndoCommand.id)}redo(){return this._univerInstanceService.focusUnit(this.id),this._commandService.syncExecuteCommand(t.RedoCommand.id)}ensurePageHeader(e=0){return this._ensureHeaderFooter(`header`,e)}ensurePageFooter(e=0){return this._ensureHeaderFooter(`footer`,e)}insertText(e,t,n=``){return d({startOffset:e,endOffset:e,segmentId:n},u(t),this._documentDataModel,this._commandService)}getHeaderFooterOptions(){let e=this._documentDataModel.getSnapshot().documentStyle;return{marginHeader:e.marginHeader,marginFooter:e.marginFooter,useFirstPageHeaderFooter:e.useFirstPageHeaderFooter,evenAndOddHeaders:e.evenAndOddHeaders}}setHeaderFooterOptions(e){if(this.isModern())throw Error(`The document is a modern document, header/footer is not supported.`);return this._commandService.syncExecuteCommand(r.CreateHeaderFooterCommand.id,{unitId:this.getId(),headerFooterProps:e})}getTextRange(e,t,n=``){return this._injector.createInstance(g,this,e,t,n,this._injector)}getSections(){return this._documentDataModel.getSnapshot().documentStyle.documentFlavor===t.DocumentFlavor.TRADITIONAL?(0,r.getTopLevelSectionBreaks)(this.getBody()).map(e=>this._injector.createInstance(S,this,e.sectionId)):[]}getSection(e){return this.getSections()[e]??null}getSectionAt(e){return this.getSections().find(t=>{let n=t.getRange();return e>=n.startOffset&&e<n.endOffset})??null}insertSectionBreak(e,n={}){if(this._documentDataModel.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)throw new x;let{nextSectionType:i,...a}=n,o=(0,t.createSectionId)(new Set((this.getBody().sectionBreaks??[]).map(e=>e.sectionId)));return this._commandService.syncExecuteCommand(r.InsertDocumentSectionBreakCommand.id,{unitId:this.getId(),offset:e,sectionId:o,config:a,nextSectionType:i})?this._injector.createInstance(S,this,o):null}insertColumnBreak(e){if(this._documentDataModel.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)throw new x;return this._commandService.syncExecuteCommand(r.InsertDocumentColumnBreakCommand.id,{unitId:this.getId(),offset:e})}insertHorizontalRule(e,n={padding:5,color:{rgb:`#CDD0D8`},width:1,dashStyle:t.DashStyleType.SOLID},i=``){var a;let o=this.getBody(i),s=(0,r.generateParagraphs)(t.DataStreamTreeTokenType.PARAGRAPH,void 0,n,(a=o.paragraphs)==null?void 0:a.map(e=>e.paragraphId)),c=s[0].paragraphId;return d({startOffset:e,endOffset:e,segmentId:i},{dataStream:t.DataStreamTreeTokenType.PARAGRAPH,paragraphs:s},this._documentDataModel,this._commandService)?this.getParagraph(c,i):null}getParagraphs(e=``){let{paragraphs:t=[]}=this.getBody(e);return t.map(t=>this._createFDocumentParagraph(t.paragraphId,e))}getParagraph(e,t=``){let{paragraphs:n=[]}=this.getBody(t);return n.find(t=>t.paragraphId===e)?this._createFDocumentParagraph(e,t):null}findParagraphByText(e,t=``){return this.findParagraphs({text:e,segmentId:t})[0]||null}findParagraphs(e){let{text:t,paragraphId:n,segmentId:r=``}=typeof e==`string`?{text:e}:e;return this.getParagraphs(r).filter(e=>!(n&&e.getId()!==n||t&&!e.getText().includes(t)))}insertParagraph(e,t=``,n=``){let r=this._getParagraphInsertOffset(e,n);if(!d({startOffset:r,endOffset:r,segmentId:n},u(`${t}\r`),this._documentDataModel,this._commandService))throw Error(`Failed to insert paragraph.`);let{paragraphs:i=[]}=this.getBody(n),a=i[e];if(!a)throw Error(`Failed to insert paragraph.`);return this._createFDocumentParagraph(a.paragraphId,n)}appendParagraph(e=``,t=``){let{paragraphs:n=[]}=this.getBody(t);return this.insertParagraph(n.length,e,t)}deleteRange(e){let t=this._normalizeDeleteRange(e);return t.startOffset>=t.endOffset?!1:d(t,{dataStream:``},this._documentDataModel,this._commandService)}_createFDocumentParagraph(e,t=``){return this._injector.createInstance(v,this,e,t,this._injector)}_normalizeDeleteRange(e){let t=this.getBody(e.segmentId),n=t.dataStream.endsWith(`\r
|
|
2
|
+
`:e).filter(e=>e!==t.DataStreamTreeTokenType.BLOCK_START&&e!==t.DataStreamTreeTokenType.BLOCK_END&&e!==t.DataStreamTreeTokenType.SECTION_BREAK).join(``).replace(/\n$/,``)}function m(e,t){return function(n,r){t(n,r,e)}}function h(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 g=class extends n.FBaseInitialable{constructor(e,t,n,r,i,a){super(i),this._document=e,this._startOffset=t,this._endOffset=n,this._segmentId=r,this._injector=i,this._commandService=a,this._validateRange()}getRange(){return{startOffset:this._startOffset,endOffset:this._endOffset,segmentId:this._segmentId}}getText(){return this._document.getBody(this._segmentId).dataStream.slice(this._startOffset,this._endOffset)}getExplicitTextStyleRuns(){let{textRuns:e=[]}=this._document.getBody(this._segmentId);return e.filter(e=>e.st<this._endOffset&&e.ed>this._startOffset).map(e=>({startOffset:Math.max(e.st,this._startOffset),endOffset:Math.min(e.ed,this._endOffset),textStyle:t.Tools.deepClone(e.ts??{})}))}getCommonExplicitTextStyle(){if(this._startOffset===this._endOffset)return{};let[e,...n]=this._getStyleSegments(),r=t.Tools.deepClone(e.textStyle);for(let e of Object.keys(r))n.some(t=>!_(t.textStyle[e],r[e]))&&delete r[e];return r}describe(){let e=this.getExplicitTextStyleRuns(),t=this.getCommonExplicitTextStyle();return{...this.getRange(),text:this.getText(),length:this._endOffset-this._startOffset,explicitTextStyleRuns:e,commonExplicitTextStyle:t}}setTextStyle(e){return this._startOffset!==this._endOffset&&f(this.getRange(),{dataStream:``,textRuns:[{st:0,ed:this._endOffset-this._startOffset,ts:t.Tools.deepClone(e)}]},t.UpdateDocsAttributeType.COVER,this._document.getDocumentDataModel(),this._injector)}setText(e){return d(this.getRange(),u(e),this._document.getDocumentDataModel(),this._commandService)}_validateRange(){let e=this._document.getBody(this._segmentId).dataStream.length;if(!Number.isInteger(this._startOffset)||!Number.isInteger(this._endOffset)||this._startOffset<0||this._endOffset<this._startOffset||this._endOffset>e)throw RangeError(`Invalid document text range [${this._startOffset}, ${this._endOffset}) for body length ${e}.`)}_getStyleSegments(){let e=this.getExplicitTextStyleRuns(),t=[],n=this._startOffset;for(let r of e)n<r.startOffset&&t.push({startOffset:n,endOffset:r.startOffset,textStyle:{}}),t.push(r),n=r.endOffset;return n<this._endOffset&&t.push({startOffset:n,endOffset:this._endOffset,textStyle:{}}),t}};g=h([m(5,t.ICommandService)],g);function _(e,t){return JSON.stringify(e)===JSON.stringify(t)}let v=class extends n.FBaseInitialable{constructor(e,t,n=``,r,i,a){super(r),this._document=e,this._paragraphId=t,this._segmentId=n,this._injector=r,this._commandService=i,this._permissionService=a}getId(){return this._paragraphId}getSegmentId(){return this._segmentId}getPermission(){return new o(this._document.getId(),(0,r.getDocumentParagraphPermissionObjectId)(this._segmentId,this._paragraphId),this._commandService,this._permissionService,()=>(0,r.getDocumentParagraphParentPermissionObjectIds)(this._document.getDocumentDataModel(),this._segmentId,this._paragraphId))}getInfo(){let e=this._document.getBody(this._segmentId),{paragraphs:n=[]}=e,r=n.map((e,t)=>({paragraph:e,paragraphIndex:t})).filter(({paragraph:e})=>e.paragraphId===this._paragraphId);if(r.length===0)throw Error(`Document paragraph with id ${this._paragraphId} not found`);if(r.length>1)throw Error(`Multiple document paragraphs with id ${this._paragraphId} found`);let{paragraph:i,paragraphIndex:a}=r[0];return{paragraph:i,paragraphIndex:a,startOffset:(0,t.getParagraphContentStartOffset)(e,i),endOffset:i.startIndex}}getRange(){let{startOffset:e,endOffset:t}=this.getInfo();return{startOffset:e,endOffset:t,segmentId:this._segmentId}}getTextRange(){let{startOffset:e,endOffset:t}=this.getInfo();return this._injector.createInstance(g,this._document,e,t,this._segmentId,this._injector)}findText(e,t={}){let n=t.occurrence??0;if(!Number.isInteger(n)||n<0)throw RangeError(`Text occurrence must be a non-negative integer.`);return this.findAllText(e,t)[n]??null}findAllText(e,n={}){if(e.length===0)throw TypeError(`Text to find must not be empty.`);let r=n.matchCase??!0,i=this.getText(),a=t.regexp.createLiteralRegExp(e,r?`gu`:`giu`),{startOffset:o}=this.getInfo(),s=[];for(let e of i.matchAll(a)){let t=o+e.index;s.push(this._injector.createInstance(g,this._document,t,t+e[0].length,this._segmentId,this._injector))}return s}getText(){let{dataStream:e}=this._document.getBody(this._segmentId),{startOffset:t,endOffset:n}=this.getInfo();return e.slice(t,n)}setText(e){let{startOffset:t,endOffset:n}=this.getInfo();return d({startOffset:t,endOffset:n,segmentId:this._segmentId},u(e),this._document.getDocumentDataModel(),this._commandService)}appendText(e){let{endOffset:t}=this.getInfo();return this._document.insertText(t,e,this._segmentId)}setStyle(e){let{startOffset:t,endOffset:n}=this.getInfo();return this._commandService.syncExecuteCommand(r.UpdateDocumentParagraphStyleCommand.id,{unitId:this._document.getId(),segmentId:this._segmentId,paragraphId:this._paragraphId,startOffset:t,endOffset:n,style:e})}isListItem(){let{paragraph:e}=this.getInfo();return!!(0,t.resolveDocumentParagraphBullet)(this._document.getDocumentDataModel().getSnapshot(),e)}isTask(){var e;let{paragraph:n}=this.getInfo(),r=(e=(0,t.resolveDocumentParagraphBullet)(this._document.getDocumentDataModel().getSnapshot(),n))==null?void 0:e.listType;return r===t.PresetListType.CHECK_LIST||r===t.PresetListType.CHECK_LIST_CHECKED}setTaskChecked(e){if(!this.isTask())return!1;let{paragraph:n,endOffset:r}=this.getInfo(),i=n.bullet,a={dataStream:``,paragraphs:[{...n,startIndex:0,bullet:{...i,listType:e?t.PresetListType.CHECK_LIST_CHECKED:t.PresetListType.CHECK_LIST}}]};return this._preserveExplicitParagraphIds(a),f({startOffset:r,endOffset:r+1,segmentId:this._segmentId},a,t.UpdateDocsAttributeType.REPLACE,this._document.getDocumentDataModel(),this._injector)}remove(){let{startOffset:e,endOffset:t}=this.getInfo();return this._document.deleteRange({startOffset:e,endOffset:t+1,segmentId:this._segmentId})}_preserveExplicitParagraphIds(e){e[t.RESTORE_INSERTED_PARAGRAPH_IDS]=!0}};v=h([m(4,t.ICommandService),m(5,t.IPermissionService)],v);function y(e){return typeof e!=`object`||!e?!1:typeof e.getId==`function`&&typeof e.getSegmentId==`function`&&typeof e.getInfo==`function`&&typeof e.getRange==`function`}function b(e){let{pageNumberStart:n,pageSize:r,pageOrient:i,marginTop:a,marginBottom:o,marginLeft:s,marginRight:c}=e;if(n!=null&&(!Number.isInteger(n)||n<1))throw RangeError(`Section page number start must be a positive integer.`);if(r&&[r.width,r.height].some(e=>e!=null&&(!Number.isFinite(e)||e<=0)))throw RangeError(`Section page size must be finite and positive.`);if(i!=null&&!Object.values(t.PageOrientType).includes(i))throw RangeError(`Invalid section page orientation.`);if([a,o,s,c].some(e=>e!=null&&(!Number.isFinite(e)||e<0)))throw RangeError(`Section page margins must be finite and non-negative.`)}var x=class extends Error{constructor(){super(`Section column APIs are supported only in traditional documents. Use ColumnGroup APIs for modern documents, or resolve an unspecified document flavor first.`),this.name=`DocsSectionUnsupportedDocumentFlavorError`}};let S=class{constructor(e,t,n,r){this._document=e,this._sectionId=t,this._commandService=n,this._permissionService=r}getId(){return this._sectionId}getPermission(){return new o(this._document.getId(),(0,r.getDocumentSectionPermissionObjectId)(``,this._sectionId),this._commandService,this._permissionService)}getIndex(){return this._resolve().index}getConfig(){return this._getConfigSnapshot()}getRange(){return this._getRange(this._resolve().index)}getColumns(){return t.Tools.deepClone(this._getConfigSnapshot().columnProperties??[])}describe(){let{index:e}=this._resolve(),n=this._getConfigSnapshot(),r=n.columnProperties??[],i={defaultHeader:this._describeHeaderFooterReference(`header`,`default`),defaultFooter:this._describeHeaderFooterReference(`footer`,`default`),firstHeader:this._describeHeaderFooterReference(`header`,`first`),firstFooter:this._describeHeaderFooterReference(`footer`,`first`),evenHeader:this._describeHeaderFooterReference(`header`,`even`),evenFooter:this._describeHeaderFooterReference(`footer`,`even`)};return{sectionId:this._sectionId,index:e,range:this._getRange(e),columnCount:r.length||1,columns:t.Tools.deepClone(r),columnSeparatorType:n.columnSeparatorType??t.ColumnSeparatorType.NONE,sectionType:n.sectionType??t.SectionType.SECTION_TYPE_UNSPECIFIED,headerFooter:i,config:n}}setColumns(e,n={}){if(this._assertTraditionalDocument(),!Number.isInteger(e)||e<1)throw RangeError(`Section column count must be a positive integer.`);if(n.widths&&n.widths.length!==e)throw RangeError(`Section column widths must match the column count.`);if(n.gap!=null&&(!Number.isFinite(n.gap)||n.gap<0))throw RangeError(`Section column gap must be finite and non-negative.`);let i=Math.max(0,n.gap??18),a=this._getConfigSnapshot(),o=(0,r.createSectionColumnProperties)(this._document.getDocumentDataModel().getSnapshot().documentStyle,a,e,i,n.widths),s=typeof n.separator==`boolean`?n.separator?t.ColumnSeparatorType.BETWEEN_EACH_COLUMN:t.ColumnSeparatorType.NONE:n.separator??t.ColumnSeparatorType.NONE;if(!Object.values(t.ColumnSeparatorType).includes(s))throw RangeError(`Invalid section column separator type.`);return this._update({columnProperties:o,columnSeparatorType:s})}setColumnProperties(e,n=t.ColumnSeparatorType.NONE){if(this._assertTraditionalDocument(),!Object.values(t.ColumnSeparatorType).includes(n))throw RangeError(`Invalid section column separator type.`);if(e.some(({width:e,paddingEnd:t})=>!Number.isFinite(e)||!Number.isFinite(t)||e<0||t<0))throw RangeError(`Section column widths and padding must be finite and non-negative.`);let i=(0,r.getSectionContentWidth)(this._document.getDocumentDataModel().getSnapshot().documentStyle,this._getConfigSnapshot());if(e.reduce((e,{width:t,paddingEnd:n})=>e+t+n,0)>i)throw RangeError(`Section columns exceed the available page content width.`);return this._update({columnProperties:t.Tools.deepClone(e),columnSeparatorType:n})}setSectionType(e){if(this._assertTraditionalDocument(),!Object.values(t.SectionType).includes(e))throw RangeError(`Invalid section type.`);return this._update({sectionType:e})}getPageSetup(){let{pageNumberStart:e,pageSize:n,pageOrient:r,marginTop:i,marginBottom:a,marginLeft:o,marginRight:s}=this._getConfigSnapshot();return t.Tools.deepClone({pageNumberStart:e,pageSize:n,pageOrient:r,marginTop:i,marginBottom:a,marginLeft:o,marginRight:s})}getEffectivePageSetup(){this._assertTraditionalDocument();let e=this._document.getDocumentDataModel().getSnapshot().documentStyle;return t.Tools.deepClone((0,r.getEffectiveSectionPageSetup)(e,this._getConfigSnapshot()))}setPageSetup(e){this._assertTraditionalDocument(),b(e);let n=t.Tools.deepClone(e);t.Tools.removeNull(n);let i=this._document.getDocumentDataModel().getSnapshot().documentStyle;return(0,r.getEffectiveSectionPageSetup)(i,{...this._getConfigSnapshot(),...n}),this._update(n)}ensureHeader(e=`default`){return this._ensureHeaderFooter(`header`,e)}ensureFooter(e=`default`){return this._ensureHeaderFooter(`footer`,e)}getHeaderId(e=`default`){return this._getHeaderFooterReference(`header`,e).segmentId??null}getFooterId(e=`default`){return this._getHeaderFooterReference(`footer`,e).segmentId??null}isHeaderLinkedToPrevious(e=`default`){return this._getHeaderFooterReference(`header`,e).linkedToPrevious}isFooterLinkedToPrevious(e=`default`){return this._getHeaderFooterReference(`footer`,e).linkedToPrevious}setHeaderLinkedToPrevious(e,t=`default`){return this._setHeaderFooterLinkedToPrevious(`header`,t,e)}setFooterLinkedToPrevious(e,t=`default`){return this._setHeaderFooterLinkedToPrevious(`footer`,t,e)}setHeaderFooterOptions(e){return this._assertTraditionalDocument(),this._update(e)}remove(){return this._assertTraditionalDocument(),this._commandService.syncExecuteCommand(r.DeleteDocumentSectionBreakCommand.id,{unitId:this._document.getId(),sectionId:this._sectionId})}_update(e){let{sectionId:t,startIndex:n,...i}=e;return this._commandService.syncExecuteCommand(r.UpdateDocumentSectionCommand.id,{unitId:this._document.getId(),updates:[{sectionId:this._sectionId,config:i}]})}_ensureHeaderFooter(e,n){this._assertTraditionalDocument();let{index:i}=this._resolve(),a=this._getConfigSnapshot()[(0,t.getSectionHeaderFooterReferenceKey)(e,n)];if(typeof a==`string`&&a)return a;if(i>0){let i=(0,t.generateRandomId)(6);if(!this._commandService.syncExecuteCommand(r.SetSectionHeaderFooterLinkCommand.id,{unitId:this._document.getId(),sectionId:this._sectionId,kind:e,variant:n,linkedToPrevious:!1,segmentId:i}))throw Error(`Failed to create section ${e}.`);return i}let o={default:e===`header`?r.HeaderFooterType.DEFAULT_HEADER:r.HeaderFooterType.DEFAULT_FOOTER,first:e===`header`?r.HeaderFooterType.FIRST_PAGE_HEADER:r.HeaderFooterType.FIRST_PAGE_FOOTER,even:e===`header`?r.HeaderFooterType.EVEN_PAGE_HEADER:r.HeaderFooterType.EVEN_PAGE_FOOTER},s=(0,t.generateRandomId)(6);if(!this._commandService.syncExecuteCommand(r.CreateHeaderFooterCommand.id,{unitId:this._document.getId(),segmentId:s,createType:o[n],sectionId:this._sectionId}))throw Error(`Failed to create section ${e}.`);return s}_getHeaderFooterReference(e,n){let{index:i}=this._resolve(),a=this._document.getDocumentDataModel().getSnapshot();return(0,t.resolveSectionHeaderFooterReference)(a.documentStyle,(0,r.getTopLevelSectionBreaks)(this._document.getBody()),i,(0,t.getSectionHeaderFooterReferenceKey)(e,n))}_describeHeaderFooterReference(e,t){let n=this._getHeaderFooterReference(e,t);return{segmentId:n.segmentId??null,linkedToPrevious:n.linkedToPrevious}}_setHeaderFooterLinkedToPrevious(e,n,i){return this._assertTraditionalDocument(),this._commandService.syncExecuteCommand(r.SetSectionHeaderFooterLinkCommand.id,{unitId:this._document.getId(),sectionId:this._sectionId,kind:e,variant:n,linkedToPrevious:i,...i?{}:{segmentId:(0,t.generateRandomId)(6)}})}_assertTraditionalDocument(){if(this._document.getDocumentDataModel().getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)throw new x}_getConfigSnapshot(){return t.Tools.deepClone(this._resolve().sectionBreak)}_getRange(e){let t=(0,r.getTopLevelSectionBreaks)(this._document.getBody());return{startOffset:e===0?0:t[e-1].startIndex+1,endOffset:t[e].startIndex,segmentId:``}}_resolve(){this._assertTraditionalDocument();let e=(0,r.getTopLevelSectionBreaks)(this._document.getBody()),t=e.findIndex(e=>e.sectionId===this._sectionId);if(t<0)throw Error(`Document section with id ${this._sectionId} not found.`);return{index:t,sectionBreak:e[t]}}};S=h([m(2,t.ICommandService),m(3,t.IPermissionService)],S);function C(e){"@babel/helpers - typeof";return C=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},C(e)}function w(e,t){if(C(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(C(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function T(e){var t=w(e,`string`);return C(t)==`symbol`?t:t+``}function E(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=class extends n.FBaseInitialable{constructor(e,t,n,r,i,a){super(t),this._documentDataModel=e,this._injector=t,this._univerInstanceService=n,this._resourceLoaderService=r,this._commandService=i,this._permissionService=a,E(this,`id`,void 0),this.id=this._documentDataModel.getUnitId()}getDocumentDataModel(e=``){let t=this._documentDataModel.getSelfOrHeaderFooterModel(e);if(!t)throw Error(e===``?`Document data model is not found.`:`Document data model is not found in the segment: ${e}`);return t}getCustomBlockLayout(){var e;return{blocks:(((e=this._documentDataModel.getBody())==null?void 0:e.customBlocks)??[]).map(({blockId:e,startIndex:t},n)=>({blockId:e,startIndex:t,index:n}))}}getBody(e=``){var t;let n=(t=this._documentDataModel.getSelfOrHeaderFooterModel(e))==null?void 0:t.getBody();if(!n)throw Error(e===``?`Body is not found in the document.`:`Body is not found in the segment: ${e}`);return n}dispose(){super.dispose()}getId(){return this.id}getPermission(){return new a(this.id,this._commandService,this._permissionService)}getEntityPermission(e,t,n){return new o(this.id,(0,r.getDocumentEntityPermissionObjectId)(e,t,n),this._commandService,this._permissionService,()=>(0,r.getDocumentEntityParentPermissionObjectIds)(this._documentDataModel,e,t,n))}getName(){return this._documentDataModel.getTitle()||``}setName(e){return this._commandService.syncExecuteCommand(r.SetDocumentNameCommand.id,{unitId:this.id,name:e}),this}getDocumentFlavor(){return this._resolveDocumentFlavor()}isTraditional(){return this._resolveDocumentFlavor()===t.DocumentFlavor.TRADITIONAL}isModern(){return this._resolveDocumentFlavor()===t.DocumentFlavor.MODERN}_resolveDocumentFlavor(){return this._documentDataModel.getSnapshot().documentStyle.documentFlavor??t.DocumentFlavor.UNSPECIFIED}save(){return this._resourceLoaderService.saveUnit(this._documentDataModel.getUnitId())}undo(){return this._univerInstanceService.focusUnit(this.id),this._commandService.syncExecuteCommand(t.UndoCommand.id)}redo(){return this._univerInstanceService.focusUnit(this.id),this._commandService.syncExecuteCommand(t.RedoCommand.id)}ensurePageHeader(e=0){return this._ensureHeaderFooter(`header`,e)}ensurePageFooter(e=0){return this._ensureHeaderFooter(`footer`,e)}insertText(e,t,n=``){return d({startOffset:e,endOffset:e,segmentId:n},u(t),this._documentDataModel,this._commandService)}getHeaderFooterOptions(){let e=this._documentDataModel.getSnapshot().documentStyle;return{marginHeader:e.marginHeader,marginFooter:e.marginFooter,useFirstPageHeaderFooter:e.useFirstPageHeaderFooter,evenAndOddHeaders:e.evenAndOddHeaders}}setHeaderFooterOptions(e){if(this.isModern())throw Error(`The document is a modern document, header/footer is not supported.`);return this._commandService.syncExecuteCommand(r.CreateHeaderFooterCommand.id,{unitId:this.getId(),headerFooterProps:e})}getTextRange(e,t,n=``){return this._injector.createInstance(g,this,e,t,n,this._injector)}getSections(){return this._documentDataModel.getSnapshot().documentStyle.documentFlavor===t.DocumentFlavor.TRADITIONAL?(0,r.getTopLevelSectionBreaks)(this.getBody()).map(e=>this._injector.createInstance(S,this,e.sectionId)):[]}getSection(e){return this.getSections()[e]??null}getSectionAt(e){return this.getSections().find(t=>{let n=t.getRange();return e>=n.startOffset&&e<n.endOffset})??null}insertSectionBreak(e,n={}){if(this._documentDataModel.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)throw new x;let{nextSectionType:i,...a}=n,o=(0,t.createSectionId)(new Set((this.getBody().sectionBreaks??[]).map(e=>e.sectionId)));return this._commandService.syncExecuteCommand(r.InsertDocumentSectionBreakCommand.id,{unitId:this.getId(),offset:e,sectionId:o,config:a,nextSectionType:i})?this._injector.createInstance(S,this,o):null}insertColumnBreak(e){if(this._documentDataModel.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)throw new x;return this._commandService.syncExecuteCommand(r.InsertDocumentColumnBreakCommand.id,{unitId:this.getId(),offset:e})}insertHorizontalRule(e,n={padding:5,color:{rgb:`#CDD0D8`},width:1,dashStyle:t.DashStyleType.SOLID},i=``){var a;let o=this.getBody(i),s=(0,r.generateParagraphs)(t.DataStreamTreeTokenType.PARAGRAPH,void 0,n,(a=o.paragraphs)==null?void 0:a.map(e=>e.paragraphId)),c=s[0].paragraphId;return d({startOffset:e,endOffset:e,segmentId:i},{dataStream:t.DataStreamTreeTokenType.PARAGRAPH,paragraphs:s},this._documentDataModel,this._commandService)?this.getParagraph(c,i):null}getParagraphs(e=``){let{paragraphs:t=[]}=this.getBody(e);return t.map(t=>this._createFDocumentParagraph(t.paragraphId,e))}getParagraph(e,t=``){let{paragraphs:n=[]}=this.getBody(t);return n.find(t=>t.paragraphId===e)?this._createFDocumentParagraph(e,t):null}findParagraphByText(e,t=``){return this.findParagraphs({text:e,segmentId:t})[0]||null}findParagraphs(e){let{text:t,paragraphId:n,segmentId:r=``}=typeof e==`string`?{text:e}:e;return this.getParagraphs(r).filter(e=>!(n&&e.getId()!==n||t&&!e.getText().includes(t)))}insertParagraph(e,t=``,n=``){let r=this._getParagraphInsertOffset(e,n);if(!d({startOffset:r,endOffset:r,segmentId:n},u(`${t}\r`),this._documentDataModel,this._commandService))throw Error(`Failed to insert paragraph.`);let{paragraphs:i=[]}=this.getBody(n),a=i[e];if(!a)throw Error(`Failed to insert paragraph.`);return this._createFDocumentParagraph(a.paragraphId,n)}appendParagraph(e=``,t=``){let{paragraphs:n=[]}=this.getBody(t);return this.insertParagraph(n.length,e,t)}deleteRange(e){let t=this._normalizeDeleteRange(e);return t.startOffset>=t.endOffset?!1:d(t,{dataStream:``},this._documentDataModel,this._commandService)}_createFDocumentParagraph(e,t=``){return this._injector.createInstance(v,this,e,t,this._injector)}_normalizeDeleteRange(e){let t=this.getBody(e.segmentId),n=t.dataStream.endsWith(`\r
|
|
3
3
|
`)?Math.max(0,t.dataStream.length-2):t.dataStream.length,r=Math.min(Math.max(e.endOffset,0),n);return{...e,startOffset:Math.min(Math.max(e.startOffset,0),r),endOffset:r}}_getParagraphInsertOffset(e,n=``){if(e<=0)return 0;let r=this.getBody(n),{dataStream:i,paragraphs:a=[]}=r;return a.length===0?Math.max(0,i.length-1):e>=a.length?a[a.length-1].startIndex+1:(0,t.getParagraphContentStartOffset)(r,a[e])}_ensureHeaderFooter(e,n){if(this.isModern())throw Error(`The document is a modern document, header/footer is not supported.`);let{createType:i,segmentId:a}=this._getHeaderFooterCreateInfo(e,n);if(a)return a;let o=(0,t.generateRandomId)(6);if(!this._commandService.syncExecuteCommand(r.CreateHeaderFooterCommand.id,{unitId:this.getId(),segmentId:o,createType:i}))throw Error(`Failed to create page ${e}.`);return o}_getHeaderFooterCreateInfo(e,n){let{documentStyle:i}=this._documentDataModel.getSnapshot(),a=n===0,o=(n+1)%2==0;return a&&i.useFirstPageHeaderFooter===t.BooleanNumber.TRUE?e===`header`?{createType:r.HeaderFooterType.FIRST_PAGE_HEADER,segmentId:i.firstPageHeaderId??``}:{createType:r.HeaderFooterType.FIRST_PAGE_FOOTER,segmentId:i.firstPageFooterId??``}:o&&i.evenAndOddHeaders===t.BooleanNumber.TRUE?e===`header`?{createType:r.HeaderFooterType.EVEN_PAGE_HEADER,segmentId:i.evenPageHeaderId??``}:{createType:r.HeaderFooterType.EVEN_PAGE_FOOTER,segmentId:i.evenPageFooterId??``}:e===`header`?{createType:r.HeaderFooterType.DEFAULT_HEADER,segmentId:i.defaultHeaderId??``}:{createType:r.HeaderFooterType.DEFAULT_FOOTER,segmentId:i.defaultFooterId??``}}};D=h([m(1,(0,t.Inject)(t.Injector)),m(2,t.IUniverInstanceService),m(3,(0,t.Inject)(t.IResourceLoaderService)),m(4,t.ICommandService),m(5,t.IPermissionService)],D);var O=class extends n.FUniver{createDocument(e,n){let r=this._injector.get(t.IUniverInstanceService).createUnit(t.UniverInstanceType.UNIVER_DOC,e,n);return this._injector.createInstance(D,r)}getActiveDocument(){let e=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);return e?this._injector.createInstance(D,e):null}getDocument(e){let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);return n?this._injector.createInstance(D,n):null}};n.FUniver.extend(O);var k=class extends n.FEnum{get DocumentFlavor(){return t.DocumentFlavor}get SectionType(){return t.SectionType}get ColumnSeparatorType(){return t.ColumnSeparatorType}};n.FEnum.extend(k),e.DocsSectionUnsupportedDocumentFlavorError=x,e.FDocsEnumMixin=k,Object.defineProperty(e,"FDocument",{enumerable:!0,get:function(){return D}}),e.FDocumentObjectPermission=o,Object.defineProperty(e,"FDocumentParagraph",{enumerable:!0,get:function(){return v}}),e.FDocumentPermission=a,Object.defineProperty(e,"FDocumentSection",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"FDocumentTextRange",{enumerable:!0,get:function(){return g}}),e.isParagraphFacade=y,e.stripBlockTokens=p});
|