@univerjs/docs 1.0.0-insiders.20260813-7c9aa50 → 1.0.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 (55) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +0 -1
  3. package/lib/cjs/facade.js +395 -78
  4. package/lib/cjs/index.js +2734 -100
  5. package/lib/es/facade.js +390 -80
  6. package/lib/es/index.js +2703 -105
  7. package/lib/facade.js +390 -80
  8. package/lib/index.js +2703 -105
  9. package/lib/types/commands/commands/core-editing.command.d.ts +5 -1
  10. package/lib/types/commands/commands/set-document-permission.command.d.ts +27 -0
  11. package/lib/types/commands/commands/set-document-permissions.command.d.ts +17 -0
  12. package/lib/types/commands/mutations/core-editing.mutation-id.d.ts +16 -0
  13. package/lib/types/commands/mutations/core-editing.mutation.d.ts +22 -1
  14. package/lib/types/commands/mutations/doc-structure-mutation-validation.d.ts +18 -0
  15. package/lib/types/commands/mutations/set-document-permission-rule.mutation.d.ts +17 -0
  16. package/lib/types/commands/mutations/set-document-permission-rules.mutation.d.ts +17 -0
  17. package/lib/types/controllers/doc-permission.controller.d.ts +26 -0
  18. package/lib/types/facade/f-document-paragraph.d.ts +15 -2
  19. package/lib/types/facade/f-document-permission.d.ts +177 -0
  20. package/lib/types/facade/f-document-section.d.ts +43 -2
  21. package/lib/types/facade/f-document-text-range.d.ts +7 -1
  22. package/lib/types/facade/f-document.d.ts +63 -15
  23. package/lib/types/facade/f-univer.d.ts +5 -4
  24. package/lib/types/facade/index.d.ts +1 -0
  25. package/lib/types/facade/utils.d.ts +2 -1
  26. package/lib/types/index.d.ts +13 -1
  27. package/lib/types/layout-worker/config/config.d.ts +32 -0
  28. package/lib/types/layout-worker/document-font-metrics.d.ts +18 -0
  29. package/lib/types/layout-worker/font-loader.d.ts +26 -0
  30. package/lib/types/layout-worker/index.d.ts +73 -0
  31. package/lib/types/layout-worker/performance-tracker.d.ts +27 -0
  32. package/lib/types/layout-worker/protocol.d.ts +37 -0
  33. package/lib/types/layout-worker/worker.d.ts +51 -0
  34. package/lib/types/plugin.d.ts +1 -0
  35. package/lib/types/services/doc-interceptor/interceptor-const.d.ts +2 -1
  36. package/lib/types/services/doc-layout-executor.service.d.ts +224 -0
  37. package/lib/types/services/doc-selection-manager.service.d.ts +7 -1
  38. package/lib/types/services/doc-skeleton-manager.service.d.ts +6 -1
  39. package/lib/types/services/doc-state-change-manager.service.d.ts +3 -0
  40. package/lib/types/services/doc-state-emit.service.d.ts +1 -0
  41. package/lib/types/services/document-layout-snapshot.d.ts +22 -0
  42. package/lib/types/services/permission/document-permission-resolver.d.ts +27 -0
  43. package/lib/types/services/permission/document-permission-rule.model.d.ts +19 -0
  44. package/lib/types/services/permission/document-permission.d.ts +35 -0
  45. package/lib/types/services/permission/permission-point/document/comment.d.ts +27 -0
  46. package/lib/types/services/permission/permission-point/document/copy.d.ts +27 -0
  47. package/lib/types/services/permission/permission-point/document/editable.d.ts +27 -0
  48. package/lib/types/services/permission/permission-point/document/export.d.ts +27 -0
  49. package/lib/types/services/permission/permission-point/document/print.d.ts +27 -0
  50. package/lib/types/services/permission/permission-point/entity/edit.d.ts +28 -0
  51. package/lib/types/services/permission/permission-point/paragraph/edit.d.ts +28 -0
  52. package/lib/types/services/permission/permission-point/section/edit.d.ts +28 -0
  53. package/lib/umd/facade.js +3 -3
  54. package/lib/umd/index.js +2 -2
  55. package/package.json +7 -5
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { ICommand, IDocumentBody, IDocumentData, ITextRange, UpdateDocsAttributeType } from '@univerjs/core';
16
+ import type { ICommand, IDocumentBody, IDocumentData, ITextRange, Nullable, UpdateDocsAttributeType } from '@univerjs/core';
17
17
  import type { ITextRangeWithStyle } from '@univerjs/engine-render';
18
18
  import { DeleteDirection } from '@univerjs/core';
19
19
  export interface IInsertTextCommandParams {
@@ -22,6 +22,10 @@ export interface IInsertTextCommandParams {
22
22
  range: ITextRange;
23
23
  segmentId?: string;
24
24
  cursorOffset?: number;
25
+ debounce?: boolean;
26
+ textRanges?: Nullable<ITextRangeWithStyle[]>;
27
+ noNeedSetTextRange?: boolean;
28
+ isEditing?: boolean;
25
29
  }
26
30
  /**
27
31
  * The command to insert text. The changed range could be non-collapsed, mainly use in line break and normal input.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { ICommand, IObjectPermissionPolicy } from '@univerjs/core';
17
+ import type { DocumentUnitPermissionAction } from '../../services/permission/document-permission';
18
+ export interface ISetDocumentPermissionCommandParams {
19
+ unitId: string;
20
+ objectId: string;
21
+ action: DocumentUnitPermissionAction;
22
+ value: boolean;
23
+ policy?: IObjectPermissionPolicy;
24
+ /** Remove the child permission rule and restore inherited rights; never deletes content. */
25
+ remove?: boolean;
26
+ }
27
+ export declare const SetDocumentPermissionCommand: ICommand<ISetDocumentPermissionCommandParams>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { ICommand, IObjectPermissionBatchResult, ISetObjectPermissionsCommandParams } from '@univerjs/core';
17
+ export declare const SetDocumentPermissionsCommand: ICommand<ISetObjectPermissionsCommandParams, IObjectPermissionBatchResult>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare const RICH_TEXT_EDITING_MUTATION_ID = "doc.mutation.rich-text-editing";
@@ -13,10 +13,25 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { IMutation, IMutationCommonParams, JSONXActions, Nullable } from '@univerjs/core';
16
+ import type { IMutation, IMutationCommonParams, JSONXActions, Nullable, TPriority } from '@univerjs/core';
17
17
  import type { ITextRangeWithStyle } from '@univerjs/engine-render';
18
+ export declare enum DocHistoryAction {
19
+ DeleteChart = "delete-chart",
20
+ DeleteDivider = "delete-divider",
21
+ DeleteImage = "delete-image",
22
+ DeleteShape = "delete-shape",
23
+ EditTableCell = "edit-table-cell",
24
+ FormatParagraph = "format-paragraph",
25
+ InsertCustomRange = "insert-custom-range",
26
+ UpdateImage = "update-image",
27
+ UpdatePageLayout = "update-page-layout"
28
+ }
18
29
  export interface IRichTextEditingMutationParams extends IMutationCommonParams {
19
30
  unitId: string;
31
+ /** Host-owned transient layout state, used only by local editor history. */
32
+ layoutState?: unknown;
33
+ historyAction?: string;
34
+ historyActions?: string[];
20
35
  actions: JSONXActions;
21
36
  textRanges: Nullable<ITextRangeWithStyle[]>;
22
37
  segmentId?: string;
@@ -32,6 +47,12 @@ export interface IRichTextEditingMutationParams extends IMutationCommonParams {
32
47
  isEditing?: boolean;
33
48
  syncer?: string;
34
49
  }
50
+ /**
51
+ * Transforms document selections through the same JSONX actions applied by a rich-text mutation.
52
+ * Collaboration and rendering use this shared offset rule so the Main interaction window follows
53
+ * the transformed local caret before an authoritative background layout is published.
54
+ */
55
+ export declare function transformDocumentTextRanges(actions: JSONXActions, textRanges: ITextRangeWithStyle[], priority?: TPriority): ITextRangeWithStyle[];
35
56
  /**
36
57
  * The core mutator to change rich text actions. The execution result would be undo mutation params. Could be directly
37
58
  * send to undo redo service (will be used by the triggering command).
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { DocumentDataModel, JSONXActions } from '@univerjs/core';
17
+ export declare function isDocSdtMutationAllowed(documentDataModel: DocumentDataModel, segmentId: string, actions: JSONXActions): boolean;
18
+ export declare function validateDocStructureMutation(documentDataModel: DocumentDataModel, segmentId: string, actions: JSONXActions, undoActions: JSONXActions, isHistoryReplay?: boolean): boolean;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IMutation, ISetObjectPermissionRuleMutationParams } from '@univerjs/core';
17
+ export declare const SetDocumentPermissionRuleMutation: IMutation<ISetObjectPermissionRuleMutationParams>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IMutation, ISetObjectPermissionRulesMutationParams } from '@univerjs/core';
17
+ export declare const SetDocumentPermissionRulesMutation: IMutation<ISetObjectPermissionRulesMutationParams>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Disposable, ICommandService, Injector, IPermissionService, IUniverInstanceService } from '@univerjs/core';
17
+ export declare class DocPermissionController extends Disposable {
18
+ private readonly _injector;
19
+ private readonly _commandService;
20
+ private readonly _permissionService;
21
+ private readonly _univerInstanceService;
22
+ constructor(_injector: Injector, _commandService: ICommandService, _permissionService: IPermissionService, _univerInstanceService: IUniverInstanceService);
23
+ private _registerUnitPermissionPoints;
24
+ private _check;
25
+ private _resolveTargetObjectIds;
26
+ }
@@ -16,8 +16,9 @@
16
16
  import type { Injector, IParagraph, IParagraphStyle } from '@univerjs/core';
17
17
  import type { FDocument } from './f-document';
18
18
  import type { IFDocumentTextRange } from './utils';
19
- import { ICommandService } from '@univerjs/core';
19
+ import { ICommandService, IPermissionService } from '@univerjs/core';
20
20
  import { FBaseInitialable } from '@univerjs/core/facade';
21
+ import { FDocumentObjectPermission } from './f-document-permission';
21
22
  import { FDocumentTextRange } from './f-document-text-range';
22
23
  /**
23
24
  * Resolved paragraph metadata in the the document body.
@@ -62,7 +63,8 @@ export declare class FDocumentParagraph extends FBaseInitialable {
62
63
  protected readonly _segmentId: string;
63
64
  protected readonly _injector: Injector;
64
65
  private readonly _commandService;
65
- constructor(_document: FDocument, _paragraphId: string, _segmentId: string | undefined, _injector: Injector, _commandService: ICommandService);
66
+ private readonly _permissionService;
67
+ constructor(_document: FDocument, _paragraphId: string, _segmentId: string | undefined, _injector: Injector, _commandService: ICommandService, _permissionService: IPermissionService);
66
68
  /**
67
69
  * Get the persisted paragraph id.
68
70
  * @returns {string} The paragraph id.
@@ -87,6 +89,17 @@ export declare class FDocumentParagraph extends FBaseInitialable {
87
89
  * ```
88
90
  */
89
91
  getSegmentId(): string;
92
+ /**
93
+ * Returns this Paragraph's permission facade.
94
+ * @returns {FDocumentObjectPermission} Permission facade combining Document, Section, and Paragraph Edit points.
95
+ * @example
96
+ * ```ts
97
+ * const paragraph = univerAPI.getActiveDocument()?.getParagraphs()[0];
98
+ * if (!paragraph) throw new Error('Paragraph not found.');
99
+ * await paragraph.getPermission().setReadOnly();
100
+ * ```
101
+ */
102
+ getPermission(): FDocumentObjectPermission;
90
103
  /**
91
104
  * Get this paragraph's metadata.
92
105
  * @returns {IFDocumentParagraphInfo} The paragraph info.
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { ICommandService, IObjectPermissionBatchResult, IObjectPermissionChange, IPermissionService } from '@univerjs/core';
17
+ import type { DocumentUnitPermissionAction } from '@univerjs/docs';
18
+ /**
19
+ * Command-backed permissions for one Document unit.
20
+ * @hideconstructor
21
+ */
22
+ export declare class FDocumentPermission {
23
+ private readonly _unitId;
24
+ private readonly _commandService;
25
+ private readonly _permissionService;
26
+ constructor(_unitId: string, _commandService: ICommandService, _permissionService: IPermissionService);
27
+ /**
28
+ * Creates or updates child-object edit policies in this unit; policy: null removes protection and restores inheritance.
29
+ *
30
+ * Requires Authz support and objectPermissionTypes configured for every target type. File and parent restrictions
31
+ * still apply. Use the exported permission object ID helpers, not raw object IDs or server permission IDs.
32
+ * The batch must be nonempty, contain distinct objects, and belong to this unit; file-wide policies are excluded.
33
+ * Other targets use getDocumentSectionPermissionObjectId and getDocumentEntityPermissionObjectId.
34
+ *
35
+ * edit: 'all' allows Unit editors, 'owner' restricts editing to the object owner, and 'members' selects existing
36
+ * Unit collaborators. Pass their collaborator records from the member service; this does not invite new users.
37
+ * Use strategies: [] for the default Edit strategy; child-object strategies support only UnitAction.Edit.
38
+ *
39
+ * Authz writes execute per object and can partially succeed. Inspect failed before retrying only those objects.
40
+ * refreshError means writes finished but permission readback failed; do not retry succeeded objects for that error.
41
+ * Successful binding changes share one undo entry; existing remote policy edits are not undoable.
42
+ * @param {IObjectPermissionChange[]} changes Permission object IDs and policies to apply.
43
+ * @returns {Promise<IObjectPermissionBatchResult>} Successful object IDs, per-object failures, and optional readback error.
44
+ * @throws {Error} Invalid batches or unsupported object types are rejected before Authz writes.
45
+ * @example Set owner/member editing and remove protection in one batch
46
+ * ```ts
47
+ * import type { ICollaborator } from '@univerjs/protocol';
48
+ * import { getDocumentParagraphPermissionObjectId } from '@univerjs/docs';
49
+ *
50
+ * // selectedMembers comes from the existing Unit collaborator picker/service.
51
+ * async function applyPermissions(selectedMembers: ICollaborator[]) {
52
+ * if (!selectedMembers.length) throw new Error('Select at least one Unit collaborator.');
53
+ * const document = univerAPI.getActiveDocument();
54
+ * if (!document) throw new Error('No active document.');
55
+ * const objects = document.getParagraphs().slice(0, 3);
56
+ * const objectIds = objects.map((paragraph) =>
57
+ * getDocumentParagraphPermissionObjectId(paragraph.getSegmentId(), paragraph.getId()));
58
+ * if (objectIds.length < 3) throw new Error('This example requires three paragraphs.');
59
+ * const result = await document.getPermission().setObjectPermissions([
60
+ * { objectId: objectIds[0], policy: { edit: 'owner', collaborators: [], strategies: [] } },
61
+ * { objectId: objectIds[1], policy: { edit: 'members', collaborators: selectedMembers, strategies: [] } },
62
+ * { objectId: objectIds[2], policy: null },
63
+ * ]);
64
+ * // A policy creates protection if absent, or updates the existing policy when already configured.
65
+ * for (const failure of result.failed) {
66
+ * console.error(failure.objectId, failure.error);
67
+ * }
68
+ * if (result.refreshError) {
69
+ * console.error(result.refreshError);
70
+ * }
71
+ * return result;
72
+ * }
73
+ * ```
74
+ */
75
+ setObjectPermissions(changes: IObjectPermissionChange[]): Promise<IObjectPermissionBatchResult>;
76
+ /**
77
+ * Sets one Document unit permission through the command system.
78
+ *
79
+ * Supported actions are Edit, Copy, Print, Export, and Comment. Await the returned promise
80
+ * before reading the new value or performing an action that depends on it.
81
+ *
82
+ * @param {DocumentUnitPermissionAction} action Unit permission action to update.
83
+ * @param {boolean} value Whether the action is allowed.
84
+ * @returns {Promise<void>} Resolves after the permission command finishes.
85
+ * @example Disable copying while keeping the Document editable
86
+ * ```ts
87
+ * import { UnitAction } from '@univerjs/protocol';
88
+ *
89
+ * const document = univerAPI.getActiveDocument();
90
+ * if (!document) throw new Error('No active Document.');
91
+ * await document.getPermission().setPoint(UnitAction.Copy, false);
92
+ * ```
93
+ */
94
+ setPoint(action: DocumentUnitPermissionAction, value: boolean): Promise<void>;
95
+ /**
96
+ * Returns the current value of one Document unit permission.
97
+ * @param {DocumentUnitPermissionAction} action Unit permission action to query.
98
+ * @returns {boolean} Whether the action is currently allowed.
99
+ * @example
100
+ * ```ts
101
+ * import { UnitAction } from '@univerjs/protocol';
102
+ *
103
+ * const document = univerAPI.getActiveDocument();
104
+ * const canPrint = document?.getPermission().getPoint(UnitAction.Print) ?? false;
105
+ * console.log(canPrint);
106
+ * ```
107
+ */
108
+ getPoint(action: DocumentUnitPermissionAction): boolean;
109
+ /**
110
+ * Enables or disables editing for the whole Document.
111
+ * @param {boolean} [editable] Whether editing is allowed. Defaults to true.
112
+ * @returns {Promise<void>} Resolves after the permission command finishes.
113
+ */
114
+ setEditable(editable?: boolean): Promise<void>;
115
+ /**
116
+ * Makes the whole Document read-only.
117
+ * @returns {Promise<void>} Resolves after the permission command finishes.
118
+ * @example
119
+ * ```ts
120
+ * const document = univerAPI.getActiveDocument();
121
+ * if (!document) throw new Error('No active Document.');
122
+ * await document.getPermission().setReadOnly();
123
+ * ```
124
+ */
125
+ setReadOnly(): Promise<void>;
126
+ /**
127
+ * Returns whether the whole Document is currently editable.
128
+ * @returns {boolean} Whether Document editing is allowed.
129
+ */
130
+ canEdit(): boolean;
131
+ }
132
+ /**
133
+ * Command-backed Edit permission for one stable Document object.
134
+ * @hideconstructor
135
+ */
136
+ export declare class FDocumentObjectPermission {
137
+ private readonly _unitId;
138
+ private readonly _objectId;
139
+ private readonly _commandService;
140
+ private readonly _permissionService;
141
+ private readonly _getParentObjectIds;
142
+ constructor(_unitId: string, _objectId: string, _commandService: ICommandService, _permissionService: IPermissionService, _getParentObjectIds?: () => string[]);
143
+ /**
144
+ * Enables or disables editing for this stable Document object.
145
+ *
146
+ * This changes only the object's Edit point. `canEdit()` also applies the Document unit and
147
+ * parent Section or Paragraph ceilings.
148
+ *
149
+ * @param {boolean} [editable] Whether object editing is allowed. Defaults to true.
150
+ * @returns {Promise<void>} Resolves after the permission command finishes.
151
+ * @example Restore editing for a paragraph
152
+ * ```ts
153
+ * const document = univerAPI.getActiveDocument();
154
+ * const paragraph = document?.getParagraphs()[0];
155
+ * if (!paragraph) throw new Error('Paragraph not found.');
156
+ * await paragraph.getPermission().setEditable();
157
+ * ```
158
+ */
159
+ setEditable(editable?: boolean): Promise<void>;
160
+ /**
161
+ * Makes this stable Document object read-only.
162
+ * @returns {Promise<void>} Resolves after the permission command finishes.
163
+ * @example
164
+ * ```ts
165
+ * const document = univerAPI.getActiveDocument();
166
+ * const section = document?.getSection(0);
167
+ * if (!section) throw new Error('Section not found.');
168
+ * await section.getPermission().setReadOnly();
169
+ * ```
170
+ */
171
+ setReadOnly(): Promise<void>;
172
+ /**
173
+ * Returns the effective Edit result after applying the Document, parent, and object permissions.
174
+ * @returns {boolean} Whether the object is currently editable.
175
+ */
176
+ canEdit(): boolean;
177
+ }
@@ -17,7 +17,8 @@ import type { ISectionBreak, ISectionColumnProperties, SectionHeaderFooterKind,
17
17
  import type { IEffectiveSectionPageSetup, IHeaderFooterProps } from '@univerjs/docs';
18
18
  import type { FDocument } from './f-document';
19
19
  import type { IFDocumentTextRange } from './utils';
20
- import { ColumnSeparatorType, ICommandService, SectionType } from '@univerjs/core';
20
+ import { ColumnSeparatorType, ICommandService, IPermissionService, SectionType } from '@univerjs/core';
21
+ import { FDocumentObjectPermission } from './f-document-permission';
21
22
  export interface IFDocumentSectionColumnOptions {
22
23
  /** Gap after each column except the last, in 96-DPI layout pixels. */
23
24
  gap?: number;
@@ -61,7 +62,8 @@ export declare class FDocumentSection {
61
62
  private readonly _document;
62
63
  private readonly _sectionId;
63
64
  private readonly _commandService;
64
- constructor(_document: FDocument, _sectionId: string, _commandService: ICommandService);
65
+ private readonly _permissionService;
66
+ constructor(_document: FDocument, _sectionId: string, _commandService: ICommandService, _permissionService: IPermissionService);
65
67
  /**
66
68
  * Returns the persisted section id.
67
69
  * @example
@@ -71,6 +73,17 @@ export declare class FDocumentSection {
71
73
  * ```
72
74
  */
73
75
  getId(): string;
76
+ /**
77
+ * Returns this Section's permission facade.
78
+ * @returns {FDocumentObjectPermission} Permission facade combining Document and Section Edit points.
79
+ * @example
80
+ * ```ts
81
+ * const section = univerAPI.getActiveDocument()?.getSection(0);
82
+ * if (!section) throw new Error('Section not found.');
83
+ * await section.getPermission().setReadOnly();
84
+ * ```
85
+ */
86
+ getPermission(): FDocumentObjectPermission;
74
87
  /**
75
88
  * Returns the current zero-based section index.
76
89
  * @example
@@ -121,6 +134,10 @@ export declare class FDocumentSection {
121
134
  * Sets equal or explicitly sized columns for this traditional section.
122
135
  * Use `columnCount = 1` to restore normal single-column layout.
123
136
  * `gap` and `widths` are in 96-DPI layout pixels.
137
+ * @param {number} columnCount Positive integer column count.
138
+ * @param {IFDocumentSectionColumnOptions} [options] Column widths, gap (default 18 pixels), and separator (default none).
139
+ * @returns {boolean} Whether the section update succeeded.
140
+ * @throws {RangeError} If column dimensions or the separator are invalid, or columns exceed the available width.
124
141
  * @example
125
142
  * ```ts
126
143
  * const fDocument = univerAPI.getActiveDocument();
@@ -132,6 +149,10 @@ export declare class FDocumentSection {
132
149
  setColumns(columnCount: number, options?: IFDocumentSectionColumnOptions): boolean;
133
150
  /**
134
151
  * Sets explicit OOXML-compatible column width and trailing-space values in 96-DPI layout pixels.
152
+ * @param {ISectionColumnProperties[]} columns Explicit widths and trailing spaces; an empty array restores a single column.
153
+ * @param {ColumnSeparatorType} [separator] Column separator style. Defaults to `ColumnSeparatorType.NONE`.
154
+ * @returns {boolean} Whether the section update succeeded.
155
+ * @throws {RangeError} If column dimensions or the separator are invalid, or columns exceed the available width.
135
156
  * @example
136
157
  * ```ts
137
158
  * const fDocument = univerAPI.getActiveDocument();
@@ -258,6 +279,8 @@ export declare class FDocumentSection {
258
279
  setPageSetup(pageSetup: FDocumentSectionPageSetup): boolean;
259
280
  /**
260
281
  * Ensures a header segment linked specifically to this section.
282
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
283
+ * @returns {string} The existing or newly created section-specific segment ID.
261
284
  * @example
262
285
  * ```ts
263
286
  * const fDocument = univerAPI.getActiveDocument();
@@ -272,6 +295,8 @@ export declare class FDocumentSection {
272
295
  ensureHeader(variant?: SectionHeaderFooterVariant): string;
273
296
  /**
274
297
  * Ensures a footer segment linked specifically to this section.
298
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
299
+ * @returns {string} The existing or newly created section-specific segment ID.
275
300
  * @example
276
301
  * ```ts
277
302
  * const fDocument = univerAPI.getActiveDocument();
@@ -286,6 +311,8 @@ export declare class FDocumentSection {
286
311
  ensureFooter(variant?: SectionHeaderFooterVariant): string;
287
312
  /**
288
313
  * Returns the effective header id after resolving links to previous sections.
314
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
315
+ * @returns {string | null} The effective segment ID, or `null` if no segment is available.
289
316
  * @example
290
317
  * ```ts
291
318
  * const fDocument = univerAPI.getActiveDocument();
@@ -295,6 +322,8 @@ export declare class FDocumentSection {
295
322
  getHeaderId(variant?: SectionHeaderFooterVariant): string | null;
296
323
  /**
297
324
  * Returns the effective footer id after resolving links to previous sections.
325
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
326
+ * @returns {string | null} The effective segment ID, or `null` if no segment is available.
298
327
  * @example
299
328
  * ```ts
300
329
  * const fDocument = univerAPI.getActiveDocument();
@@ -304,6 +333,8 @@ export declare class FDocumentSection {
304
333
  getFooterId(variant?: SectionHeaderFooterVariant): string | null;
305
334
  /**
306
335
  * Whether this header variant inherits the previous section's reference.
336
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
337
+ * @returns {boolean} Whether this variant inherits from the previous section.
307
338
  * @example
308
339
  * ```ts
309
340
  * const fDocument = univerAPI.getActiveDocument();
@@ -313,6 +344,8 @@ export declare class FDocumentSection {
313
344
  isHeaderLinkedToPrevious(variant?: SectionHeaderFooterVariant): boolean;
314
345
  /**
315
346
  * Whether this footer variant inherits the previous section's reference.
347
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
348
+ * @returns {boolean} Whether this variant inherits from the previous section.
316
349
  * @example
317
350
  * ```ts
318
351
  * const fDocument = univerAPI.getActiveDocument();
@@ -322,6 +355,9 @@ export declare class FDocumentSection {
322
355
  isFooterLinkedToPrevious(variant?: SectionHeaderFooterVariant): boolean;
323
356
  /**
324
357
  * Links or unlinks this header variant. Unlinking clones the inherited header.
358
+ * @param {boolean} linkedToPrevious Whether to inherit the previous section's header/footer.
359
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
360
+ * @returns {boolean} Whether the link update succeeded.
325
361
  * @example
326
362
  * ```ts
327
363
  * const fDocument = univerAPI.getActiveDocument();
@@ -333,6 +369,9 @@ export declare class FDocumentSection {
333
369
  setHeaderLinkedToPrevious(linkedToPrevious: boolean, variant?: SectionHeaderFooterVariant): boolean;
334
370
  /**
335
371
  * Links or unlinks this footer variant. Unlinking clones the inherited footer.
372
+ * @param {boolean} linkedToPrevious Whether to inherit the previous section's header/footer.
373
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
374
+ * @returns {boolean} Whether the link update succeeded.
336
375
  * @example
337
376
  * ```ts
338
377
  * const fDocument = univerAPI.getActiveDocument();
@@ -345,6 +384,8 @@ export declare class FDocumentSection {
345
384
  /**
346
385
  * Updates header/footer switches and margins on this section break.
347
386
  * `marginHeader` and `marginFooter` are in 96-DPI layout pixels.
387
+ * @param {IHeaderFooterProps} options Header/footer switches and margins to update. Omitted properties are preserved.
388
+ * @returns {boolean} Whether the update command succeeded.
348
389
  * @example
349
390
  * ```ts
350
391
  * const fDocument = univerAPI.getActiveDocument();
@@ -16,6 +16,7 @@
16
16
  import type { Injector, ITextStyle } from '@univerjs/core';
17
17
  import type { FDocument } from './f-document';
18
18
  import type { IFDocumentTextRange } from './utils';
19
+ import { ICommandService } from '@univerjs/core';
19
20
  import { FBaseInitialable } from '@univerjs/core/facade';
20
21
  /** A clipped text-style run in document offsets. */
21
22
  export interface IFDocumentTextStyleRun {
@@ -48,7 +49,8 @@ export declare class FDocumentTextRange extends FBaseInitialable {
48
49
  protected readonly _endOffset: number;
49
50
  protected readonly _segmentId: string;
50
51
  protected readonly _injector: Injector;
51
- constructor(_document: FDocument, _startOffset: number, _endOffset: number, _segmentId: string, _injector: Injector);
52
+ private readonly _commandService;
53
+ constructor(_document: FDocument, _startOffset: number, _endOffset: number, _segmentId: string, _injector: Injector, _commandService: ICommandService);
52
54
  /**
53
55
  * Returns the serializable document range.
54
56
  * @example
@@ -106,6 +108,8 @@ export declare class FDocumentTextRange extends FBaseInitialable {
106
108
  * Existing text-run splitting, merging, and normalization are handled by
107
109
  * the document mutation pipeline.
108
110
  * `style.fs` is a font size in points (pt), not CSS pixels.
111
+ * @param {ITextStyle} style Text-style properties to merge into the range.
112
+ * @returns {boolean} Whether the style update succeeded; `false` for an empty range.
109
113
  * @example
110
114
  * ```ts
111
115
  * const fDocument = univerAPI.getActiveDocument();
@@ -116,6 +120,8 @@ export declare class FDocumentTextRange extends FBaseInitialable {
116
120
  setTextStyle(style: ITextStyle): boolean;
117
121
  /**
118
122
  * Replaces the range with plain text while preserving document mutation semantics.
123
+ * @param {string} text Replacement plain text. An empty string deletes the range.
124
+ * @returns {boolean} Whether the replacement succeeded.
119
125
  * @example
120
126
  * ```ts
121
127
  * const fDocument = univerAPI.getActiveDocument();