@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
@@ -0,0 +1,224 @@
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 { ICustomRange, IDisposable, IDocumentBody, IDocumentData, ILanguagePack, JSONXActions, LocaleType, Nullable } from '@univerjs/core';
17
+ import type { IDocsCustomBlockRenderViewport, IDocumentLayoutPagePublication, IDocumentLayoutSessionStartOptions, IDocumentLayoutStepResult } from '@univerjs/engine-render';
18
+ import { Disposable, ICommandService, ILogService, IUniverInstanceService, LocaleService } from '@univerjs/core';
19
+ export declare enum DocLayoutExecutorType {
20
+ MAIN_THREAD = "main-thread",
21
+ WORKER = "worker"
22
+ }
23
+ export declare enum DocLayoutSessionStatus {
24
+ ACCEPTED = "accepted",
25
+ NOT_FOUND = "not-found",
26
+ RESNAPSHOT_REQUIRED = "resnapshot-required",
27
+ SUPERSEDED = "superseded"
28
+ }
29
+ export declare enum DocLayoutExecutorState {
30
+ UNREGISTERED = "unregistered",
31
+ INITIALIZING = "initializing",
32
+ ACTIVE = "active",
33
+ RECOVERING = "recovering",
34
+ FAILED = "failed"
35
+ }
36
+ export interface IDocLayoutExecutorStatus {
37
+ state: DocLayoutExecutorState;
38
+ executor: DocLayoutExecutorType | null;
39
+ diagnostic: string | null;
40
+ recoveryUnitId: string | null;
41
+ }
42
+ export interface IDocLayoutPerformanceMetrics {
43
+ hydrationMs: number[];
44
+ mutationTransferMs: number[];
45
+ patchTransferMs: number[];
46
+ snapshotTransferMs: number[];
47
+ }
48
+ export interface IDocLayoutCreateSessionRequest {
49
+ normalFontLineHeights?: Record<string, number>;
50
+ unitId: string;
51
+ sessionEpoch: number;
52
+ snapshot: IDocumentData;
53
+ modelRevision: number;
54
+ locale: LocaleType;
55
+ localeData?: ILanguagePack;
56
+ direction: 'ltr' | 'rtl';
57
+ }
58
+ export interface IDocLayoutDisposeSessionRequest {
59
+ unitId: string;
60
+ sessionEpoch: number;
61
+ }
62
+ export interface IDocLayoutMutationProjection {
63
+ baseRevision: number;
64
+ modelRevision: number;
65
+ actions: JSONXActions;
66
+ }
67
+ export interface IDocLayoutMountIdentity {
68
+ unitId: string;
69
+ mountId: string;
70
+ mountEpoch: number;
71
+ viewportEpoch: number;
72
+ }
73
+ export interface IDocLayoutStartRequest extends IDocLayoutMountIdentity {
74
+ normalFontLineHeights?: Record<string, number>;
75
+ metricsRevision: number;
76
+ baseRevision: number;
77
+ modelRevision: number;
78
+ mutations: IDocLayoutMutationProjection[];
79
+ reason: 'initial' | 'edit';
80
+ anchor?: number;
81
+ priorityAnchor?: number;
82
+ invalidation?: IDocumentLayoutSessionStartOptions['invalidation'];
83
+ modernPageWidth?: number;
84
+ modernHorizontalMargin?: number;
85
+ customBlockViewports?: Record<string, IDocsCustomBlockRenderViewport>;
86
+ customBlockViewportPatch?: IDocLayoutRecordPatch<IDocsCustomBlockRenderViewport>;
87
+ customRangePresentations?: IDocLayoutCustomRangePresentationEntry[];
88
+ customRangePresentationPatch?: IDocLayoutCustomRangePresentationPatch;
89
+ budgetMs: number;
90
+ }
91
+ export interface IDocLayoutRecordPatch<T> {
92
+ removals: string[];
93
+ upserts: Record<string, T>;
94
+ }
95
+ export interface IDocLayoutCustomRangePresentation {
96
+ active?: boolean;
97
+ glyphAscentEm?: number;
98
+ glyphDescentEm?: number;
99
+ glyphWidthEm?: number;
100
+ show?: boolean;
101
+ }
102
+ export interface IDocLayoutCustomRangePresentationEntry {
103
+ segmentId: string;
104
+ rangeId: string;
105
+ presentation: IDocLayoutCustomRangePresentation;
106
+ }
107
+ export interface IDocLayoutCustomRangePresentationPatch {
108
+ removals: Array<Pick<IDocLayoutCustomRangePresentationEntry, 'segmentId' | 'rangeId'>>;
109
+ upserts: IDocLayoutCustomRangePresentationEntry[];
110
+ }
111
+ export interface IDocLayoutCustomRangePresentationContext {
112
+ segmentId: string;
113
+ body: IDocumentBody;
114
+ }
115
+ type DocLayoutCustomRangePresentationProvider = (unitId: string, range: ICustomRange, context: IDocLayoutCustomRangePresentationContext) => IDocLayoutCustomRangePresentation | null | undefined;
116
+ export type IDocLayoutStartResult = {
117
+ status: DocLayoutSessionStatus.ACCEPTED;
118
+ step: IDocLayoutStepResult;
119
+ } | {
120
+ status: DocLayoutSessionStatus.NOT_FOUND;
121
+ } | {
122
+ status: DocLayoutSessionStatus.SUPERSEDED;
123
+ } | {
124
+ status: DocLayoutSessionStatus.RESNAPSHOT_REQUIRED;
125
+ modelRevision: number;
126
+ };
127
+ export interface IDocLayoutStepRequest extends IDocLayoutMountIdentity {
128
+ generation: number;
129
+ budgetMs: number;
130
+ }
131
+ export interface IDocLayoutPageRequest extends IDocLayoutMountIdentity {
132
+ pageIndex: number;
133
+ }
134
+ export interface IDocLayoutPageResult extends IDocLayoutMountIdentity {
135
+ modelRevision: number;
136
+ metricsRevision: number;
137
+ page: IDocumentLayoutPagePublication | null;
138
+ }
139
+ export interface IDocLayoutCancelRequest extends IDocLayoutMountIdentity {
140
+ generation?: number;
141
+ }
142
+ export type IDocLayoutDisposeMountRequest = IDocLayoutMountIdentity;
143
+ export interface IDocLayoutStepResult extends IDocumentLayoutStepResult, IDocLayoutMountIdentity {
144
+ modelRevision: number;
145
+ metricsRevision: number;
146
+ }
147
+ export interface IDocLayoutExecutor {
148
+ readonly type: DocLayoutExecutorType;
149
+ /** When present, foreground layout must wait for the configured rendering and Worker fonts. */
150
+ readonly renderingFontsReady?: Promise<void>;
151
+ initialize(): Promise<void>;
152
+ recover(): Promise<void>;
153
+ /**
154
+ * Capture the request synchronously before returning. The source document model remains mutable
155
+ * while the returned promise tracks remote session creation.
156
+ */
157
+ createSession(request: IDocLayoutCreateSessionRequest): Promise<void>;
158
+ startLayout(request: IDocLayoutStartRequest): Promise<IDocLayoutStartResult>;
159
+ stepLayout(request: IDocLayoutStepRequest): Promise<IDocLayoutStepResult>;
160
+ publishBacklog(request: Omit<IDocLayoutStepRequest, 'budgetMs'>): Promise<IDocLayoutStepResult>;
161
+ getLayoutPage(request: IDocLayoutPageRequest): Promise<IDocLayoutPageResult>;
162
+ cancelLayout(request: IDocLayoutCancelRequest): Promise<void>;
163
+ getPerformanceMetrics(unitId: string): Promise<Omit<IDocLayoutPerformanceMetrics, 'hydrationMs'>>;
164
+ resetPerformanceMetrics(unitId: string): Promise<void>;
165
+ disposeLayoutMount(request: IDocLayoutDisposeMountRequest): Promise<void>;
166
+ disposeSession(request: IDocLayoutDisposeSessionRequest): Promise<void>;
167
+ }
168
+ export interface IDocLayoutStartOptions {
169
+ reason: 'initial' | 'edit';
170
+ anchor?: number;
171
+ priorityAnchor?: number;
172
+ invalidation?: IDocumentLayoutSessionStartOptions['invalidation'];
173
+ modernPageWidth?: number;
174
+ modernHorizontalMargin?: number;
175
+ }
176
+ export declare class DocLayoutExecutorService extends Disposable {
177
+ private readonly _univerInstanceService;
178
+ private readonly _commandService;
179
+ private readonly _localeService;
180
+ private readonly _logService;
181
+ private static readonly _performanceSampleLimit;
182
+ private _executor;
183
+ private _executorReady;
184
+ private _recoveryFailure;
185
+ private _sessionEpoch;
186
+ private readonly _sessions;
187
+ private readonly _hydrationSamples;
188
+ private readonly _customRangePresentationProviders;
189
+ private readonly _executorStatus$;
190
+ readonly executorStatus$: import("rxjs").Observable<IDocLayoutExecutorStatus>;
191
+ constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _localeService: LocaleService, _logService: ILogService);
192
+ register(executor: IDocLayoutExecutor): IDisposable;
193
+ getExecutor(): Nullable<IDocLayoutExecutor>;
194
+ getExecutorStatus(): IDocLayoutExecutorStatus;
195
+ registerCustomRangePresentationProvider(provider: DocLayoutCustomRangePresentationProvider): IDisposable;
196
+ getPerformanceMetrics(unitId: string): Promise<IDocLayoutPerformanceMetrics>;
197
+ resetPerformanceMetrics(unitId: string): Promise<void>;
198
+ recordHydrationDuration(unitId: string, durationMs: number): void;
199
+ recoverExecutor(unitId: string, diagnostic: string): Promise<void>;
200
+ completeRecovery(unitId: string): void;
201
+ startLayout(identity: IDocLayoutMountIdentity, options: IDocLayoutStartOptions, budgetMs: number): Promise<IDocLayoutStartResult | null>;
202
+ stepLayout(request: IDocLayoutStepRequest): Promise<IDocLayoutStepResult>;
203
+ publishBacklog(request: Omit<IDocLayoutStepRequest, 'budgetMs'>): Promise<IDocLayoutStepResult>;
204
+ getLayoutPage(request: IDocLayoutPageRequest): Promise<IDocLayoutPageResult>;
205
+ cancelLayout(request: IDocLayoutCancelRequest): Promise<void>;
206
+ disposeLayoutMount(request: IDocLayoutDisposeMountRequest): Promise<void>;
207
+ dispose(): void;
208
+ private _createSessionIfEligible;
209
+ private _enqueueCommittedMutation;
210
+ private _startSynchronizedLayout;
211
+ private _createLayoutProjectionPayload;
212
+ private _replaceSession;
213
+ private _disposeSession;
214
+ private _getEligibleModel;
215
+ private _getRequiredModel;
216
+ private _collectCustomRangePresentations;
217
+ private _isEligible;
218
+ private _requireExecutor;
219
+ private _appendPerformanceSample;
220
+ private _createSessionOnNextMacroTask;
221
+ private _markSessionDisposed;
222
+ private _disposeManagedSessions;
223
+ }
224
+ export {};
@@ -50,7 +50,7 @@ export declare class DocSelectionManagerService extends RxDisposable {
50
50
  private _listenCurrentUnit;
51
51
  __getCurrentSelection(): Nullable<IDocSelectionManagerSearchParam>;
52
52
  getSelectionInfo(params?: Nullable<IDocSelectionManagerSearchParam>): IDocSelectionInnerParam | undefined;
53
- refreshSelection(params?: Nullable<IDocSelectionManagerSearchParam>): void;
53
+ refreshSelection(params?: Nullable<IDocSelectionManagerSearchParam>, isEditing?: boolean): void;
54
54
  __TEST_ONLY_setCurrentSelection(param: IDocSelectionManagerSearchParam): void;
55
55
  getTextRanges(params?: Nullable<IDocSelectionManagerSearchParam>): Readonly<Nullable<ITextRangeWithStyle[]>>;
56
56
  getRectRanges(params?: Nullable<IDocSelectionManagerSearchParam>): Readonly<Nullable<IRectRangeWithStyle[]>>;
@@ -60,6 +60,12 @@ export declare class DocSelectionManagerService extends RxDisposable {
60
60
  replaceDocRanges(docRanges: ISuccinctDocRangeParam[], params?: Nullable<IDocSelectionManagerSearchParam>, isEditing?: boolean, options?: {
61
61
  [key: string]: boolean;
62
62
  }): void;
63
+ /**
64
+ * Replaces logical selection state without rebuilding render ranges. Atomic
65
+ * external mutations use this before applying document actions so layout can
66
+ * follow transformed offsets, then refresh after new geometry is available.
67
+ */
68
+ replaceSelectionInfoWithoutRefresh(selectionInfo: IDocSelectionInnerParam, params?: Nullable<IDocSelectionManagerSearchParam>): void;
63
69
  __replaceTextRangesWithNoRefresh(textSelectionInfo: IDocSelectionInnerParam, search: IDocSelectionManagerSearchParam): void;
64
70
  dispose(): void;
65
71
  private _setCurrentSelectionNotRefresh;
@@ -17,6 +17,7 @@ import type { DocumentDataModel, Nullable } from '@univerjs/core';
17
17
  import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';
18
18
  import { IUniverInstanceService, LocaleService, RxDisposable } from '@univerjs/core';
19
19
  import { DocumentSkeleton, DocumentViewModel } from '@univerjs/engine-render';
20
+ import { DocLayoutExecutorService } from './doc-layout-executor.service';
20
21
  /**
21
22
  * This service is for document build and manage doc skeletons. It also manages
22
23
  * DocumentViewModels.
@@ -25,6 +26,7 @@ export declare class DocSkeletonManagerService extends RxDisposable implements I
25
26
  private readonly _context;
26
27
  private readonly _localeService;
27
28
  private readonly _univerInstanceService;
29
+ private readonly _docLayoutExecutorService;
28
30
  private _skeleton;
29
31
  private _docViewModel;
30
32
  private readonly _currentSkeleton$;
@@ -33,11 +35,14 @@ export declare class DocSkeletonManagerService extends RxDisposable implements I
33
35
  readonly currentSkeletonBefore$: import("rxjs").Observable<Nullable<DocumentSkeleton>>;
34
36
  private readonly _currentViewModel$;
35
37
  readonly currentViewModel$: import("rxjs").Observable<Nullable<DocumentViewModel>>;
36
- constructor(_context: IRenderContext<DocumentDataModel>, _localeService: LocaleService, _univerInstanceService: IUniverInstanceService);
38
+ constructor(_context: Pick<IRenderContext<DocumentDataModel>, 'type' | 'unit' | 'unitId'>, _localeService: LocaleService, _univerInstanceService: IUniverInstanceService, _docLayoutExecutorService: DocLayoutExecutorService);
37
39
  dispose(): void;
38
40
  getSkeleton(): DocumentSkeleton;
39
41
  getViewModel(): DocumentViewModel;
42
+ getLayoutPerformanceMetrics(): ReturnType<DocLayoutExecutorService['getPerformanceMetrics']>;
43
+ supportsIncrementalLayout(): boolean;
40
44
  recalculate(): DocumentSkeleton;
45
+ private _publishSkeleton;
41
46
  private _init;
42
47
  private _update;
43
48
  private _buildSkeleton;
@@ -38,11 +38,14 @@ export declare class DocStateChangeManagerService extends RxDisposable {
38
38
  private _historyTimer;
39
39
  private _changeStateCacheTimer;
40
40
  constructor(_undoRedoService: Nullable<IUndoRedoService>, _commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _docStateEmitService: DocStateEmitService, _docStateChangeInterceptorService?: IDocStateChangeInterceptorService | undefined);
41
+ dispose(): void;
41
42
  getStateCache(unitId: string): {
42
43
  history: IDocStateChangeParams[];
43
44
  collaboration: IDocStateChangeParams[];
44
45
  };
45
46
  setStateCache(unitId: string, cache: IStateCache): void;
47
+ clearHistory(unitId: string): void;
48
+ flushPendingChanges(unitId: string): void;
46
49
  private _setChangeState;
47
50
  private _initialize;
48
51
  private _listenDocStateChange;
@@ -17,6 +17,7 @@ import type { JSONXActions, Nullable } from '@univerjs/core';
17
17
  import type { ITextRangeWithStyle } from '@univerjs/engine-render';
18
18
  import { RxDisposable } from '@univerjs/core';
19
19
  interface IDocChangeState {
20
+ layoutState?: unknown;
20
21
  actions: JSONXActions;
21
22
  textRanges: Nullable<ITextRangeWithStyle[]>;
22
23
  options?: {
@@ -0,0 +1,22 @@
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 { IDocumentData } from '@univerjs/core';
17
+ /**
18
+ * Builds the model snapshot owned by the layout Worker. Exchange-only payloads
19
+ * remain in the authoritative Main model and are deliberately excluded from
20
+ * the structured-clone boundary because they do not affect document geometry.
21
+ */
22
+ export declare function createDocumentLayoutSnapshot(snapshot: IDocumentData): IDocumentData;
@@ -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 { DocumentDataModel, IDocumentBody, JSONXActions } from '@univerjs/core';
17
+ export interface IDocumentPermissionRange {
18
+ startOffset: number;
19
+ endOffset: number;
20
+ }
21
+ export declare function getDocumentDrawingSegmentId(documentDataModel: DocumentDataModel, drawingId: string): string;
22
+ export declare function getDocumentEditTargetObjectIds(documentDataModel: DocumentDataModel, segmentId: string, range: IDocumentPermissionRange): string[];
23
+ export declare function getDocumentEditTargetObjectIdsFromActions(documentDataModel: DocumentDataModel, segmentId: string, actions: JSONXActions): string[];
24
+ export declare function getDocumentEntityParentPermissionObjectIds(documentDataModel: DocumentDataModel, segmentId: string, entityType: string, entityId: string): string[];
25
+ export declare function getDocumentParagraphParentPermissionObjectIds(documentDataModel: DocumentDataModel, segmentId: string, paragraphId: string): string[];
26
+ export declare function getDocumentSectionPermissionObjectIdsByIds(sectionIds: Iterable<string>): string[];
27
+ export declare function getDocumentSectionIdsAtOffset(body: IDocumentBody, offset: number): string[];
@@ -0,0 +1,19 @@
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 { IResourceManagerService, ObjectPermissionRuleModel } from '@univerjs/core';
17
+ export declare class DocumentPermissionRuleModel extends ObjectPermissionRuleModel {
18
+ constructor(resources: IResourceManagerService);
19
+ }
@@ -0,0 +1,35 @@
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 { IPermissionService } from '@univerjs/core';
17
+ import { UnitAction } from '@univerjs/protocol';
18
+ import { DocumentCommentPermission } from './permission-point/document/comment';
19
+ import { DocumentCopyPermission } from './permission-point/document/copy';
20
+ import { DocumentEditablePermission } from './permission-point/document/editable';
21
+ import { DocumentExportPermission } from './permission-point/document/export';
22
+ import { DocumentPrintPermission } from './permission-point/document/print';
23
+ import { DocumentEntityEditPermission } from './permission-point/entity/edit';
24
+ import { DocumentParagraphEditPermission } from './permission-point/paragraph/edit';
25
+ import { DocumentSectionEditPermission } from './permission-point/section/edit';
26
+ export declare const DOCUMENT_UNIT_PERMISSION_ACTIONS: readonly [UnitAction.Edit, UnitAction.Copy, UnitAction.Print, UnitAction.Export, UnitAction.Comment];
27
+ export type DocumentUnitPermissionAction = typeof DOCUMENT_UNIT_PERMISSION_ACTIONS[number];
28
+ export declare function getDocumentSectionPermissionObjectId(segmentId: string, sectionId: string): string;
29
+ export declare function getDocumentParagraphPermissionObjectId(segmentId: string, paragraphId: string): string;
30
+ export declare function getDocumentEntityPermissionObjectId(segmentId: string, entityType: string, entityId: string): string;
31
+ export declare function createDocumentPermissionPoint(unitId: string, objectId: string, action: UnitAction): DocumentCommentPermission | DocumentCopyPermission | DocumentEditablePermission | DocumentExportPermission | DocumentPrintPermission | DocumentEntityEditPermission | DocumentParagraphEditPermission | DocumentSectionEditPermission;
32
+ export declare function getDocumentPermissionValue(permissionService: IPermissionService, unitId: string, objectId: string, action: UnitAction): boolean;
33
+ export declare function setDocumentPermissionValue(permissionService: IPermissionService, unitId: string, objectId: string, action: UnitAction, value: boolean): void;
34
+ export declare function clearDocumentPermissionValuesForUnit(permissionService: IPermissionService, unitId: string): void;
35
+ export declare function canEditDocumentTargets(permissionService: IPermissionService, unitId: string, objectIds: Iterable<string>): boolean;
@@ -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 { IPermissionPoint } from '@univerjs/core';
17
+ import { PermissionStatus } from '@univerjs/core';
18
+ import { UnitAction, UnitObject } from '@univerjs/protocol';
19
+ export declare class DocumentCommentPermission implements IPermissionPoint {
20
+ readonly unitId: string;
21
+ readonly type = UnitObject.Document;
22
+ readonly subType = UnitAction.Comment;
23
+ readonly status = PermissionStatus.INIT;
24
+ readonly id: string;
25
+ value: boolean;
26
+ constructor(unitId: string);
27
+ }
@@ -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 { IPermissionPoint } from '@univerjs/core';
17
+ import { PermissionStatus } from '@univerjs/core';
18
+ import { UnitAction, UnitObject } from '@univerjs/protocol';
19
+ export declare class DocumentCopyPermission implements IPermissionPoint {
20
+ readonly unitId: string;
21
+ readonly type = UnitObject.Document;
22
+ readonly subType = UnitAction.Copy;
23
+ readonly status = PermissionStatus.INIT;
24
+ readonly id: string;
25
+ value: boolean;
26
+ constructor(unitId: string);
27
+ }
@@ -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 { IPermissionPoint } from '@univerjs/core';
17
+ import { PermissionStatus } from '@univerjs/core';
18
+ import { UnitAction, UnitObject } from '@univerjs/protocol';
19
+ export declare class DocumentEditablePermission implements IPermissionPoint {
20
+ readonly unitId: string;
21
+ readonly type = UnitObject.Document;
22
+ readonly subType = UnitAction.Edit;
23
+ readonly status = PermissionStatus.INIT;
24
+ readonly id: string;
25
+ value: boolean;
26
+ constructor(unitId: string);
27
+ }
@@ -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 { IPermissionPoint } from '@univerjs/core';
17
+ import { PermissionStatus } from '@univerjs/core';
18
+ import { UnitAction, UnitObject } from '@univerjs/protocol';
19
+ export declare class DocumentExportPermission implements IPermissionPoint {
20
+ readonly unitId: string;
21
+ readonly type = UnitObject.Document;
22
+ readonly subType = UnitAction.Export;
23
+ readonly status = PermissionStatus.INIT;
24
+ readonly id: string;
25
+ value: boolean;
26
+ constructor(unitId: string);
27
+ }
@@ -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 { IPermissionPoint } from '@univerjs/core';
17
+ import { PermissionStatus } from '@univerjs/core';
18
+ import { UnitAction, UnitObject } from '@univerjs/protocol';
19
+ export declare class DocumentPrintPermission implements IPermissionPoint {
20
+ readonly unitId: string;
21
+ readonly type = UnitObject.Document;
22
+ readonly subType = UnitAction.Print;
23
+ readonly status = PermissionStatus.INIT;
24
+ readonly id: string;
25
+ value: boolean;
26
+ constructor(unitId: string);
27
+ }
@@ -0,0 +1,28 @@
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 { IPermissionPoint } from '@univerjs/core';
17
+ import { PermissionStatus } from '@univerjs/core';
18
+ import { UnitAction, UnitObject } from '@univerjs/protocol';
19
+ export declare class DocumentEntityEditPermission implements IPermissionPoint {
20
+ readonly unitId: string;
21
+ readonly objectId: string;
22
+ readonly type = UnitObject.DocumentEntity;
23
+ readonly subType = UnitAction.Edit;
24
+ readonly status = PermissionStatus.INIT;
25
+ readonly id: string;
26
+ value: boolean;
27
+ constructor(unitId: string, objectId: string);
28
+ }
@@ -0,0 +1,28 @@
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 { IPermissionPoint } from '@univerjs/core';
17
+ import { PermissionStatus } from '@univerjs/core';
18
+ import { UnitAction, UnitObject } from '@univerjs/protocol';
19
+ export declare class DocumentParagraphEditPermission implements IPermissionPoint {
20
+ readonly unitId: string;
21
+ readonly objectId: string;
22
+ readonly type = UnitObject.DocumentParagraph;
23
+ readonly subType = UnitAction.Edit;
24
+ readonly status = PermissionStatus.INIT;
25
+ readonly id: string;
26
+ value: boolean;
27
+ constructor(unitId: string, objectId: string);
28
+ }
@@ -0,0 +1,28 @@
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 { IPermissionPoint } from '@univerjs/core';
17
+ import { PermissionStatus } from '@univerjs/core';
18
+ import { UnitAction, UnitObject } from '@univerjs/protocol';
19
+ export declare class DocumentSectionEditPermission implements IPermissionPoint {
20
+ readonly unitId: string;
21
+ readonly objectId: string;
22
+ readonly type = UnitObject.DocumentSection;
23
+ readonly subType = UnitAction.Edit;
24
+ readonly status = PermissionStatus.INIT;
25
+ readonly id: string;
26
+ value: boolean;
27
+ constructor(unitId: string, objectId: string);
28
+ }