@univerjs/core 1.0.0-alpha.8 → 1.0.0-beta.1

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 (31) hide show
  1. package/lib/cjs/facade.js +43 -1
  2. package/lib/cjs/index.js +6660 -6243
  3. package/lib/es/facade.js +43 -1
  4. package/lib/es/index.js +6646 -6249
  5. package/lib/facade.js +43 -1
  6. package/lib/index.js +6646 -6249
  7. package/lib/types/bases/formula-table-name.d.ts +28 -0
  8. package/lib/types/bases/index.d.ts +4 -2
  9. package/lib/types/bases/record-identity.d.ts +22 -0
  10. package/lib/types/bases/typedef.d.ts +265 -32
  11. package/lib/types/common/drawing-order.d.ts +20 -0
  12. package/lib/types/docs/data-model/document-data-model.d.ts +16 -0
  13. package/lib/types/{shared/object-matrix-query.d.ts → docs/data-model/document-statistics.d.ts} +2 -7
  14. package/lib/types/docs/data-model/index.d.ts +1 -1
  15. package/lib/types/docs/data-model/rich-text-builder.d.ts +17 -8
  16. package/lib/types/docs/data-model/types.d.ts +0 -6
  17. package/lib/types/facade/f-event.d.ts +9 -9
  18. package/lib/types/facade/f-univer.d.ts +37 -0
  19. package/lib/types/index.d.ts +1 -0
  20. package/lib/types/services/undoredo/undoredo.service.d.ts +14 -1
  21. package/lib/types/shared/cache/image-cache.d.ts +1 -1
  22. package/lib/types/shared/index.d.ts +0 -1
  23. package/lib/types/sheets/sheet-skeleton.d.ts +1 -1
  24. package/lib/types/types/enum/text-style.d.ts +3 -1
  25. package/lib/types/types/interfaces/i-document-data.d.ts +56 -0
  26. package/lib/types/types/interfaces/i-need-check-disposable.d.ts +1 -1
  27. package/lib/types/types/interfaces/i-style-data.d.ts +3 -1
  28. package/lib/types/univer.d.ts +6 -0
  29. package/lib/umd/facade.js +1 -1
  30. package/lib/umd/index.js +24 -21
  31. package/package.json +4 -4
@@ -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 { IBaseSnapshot, ITableSnapshot } from './typedef';
17
+ type BaseFormulaTable = Pick<ITableSnapshot, 'id' | 'name' | 'formulaName'>;
18
+ interface IBaseFormulaSnapshot {
19
+ tables: Record<string, BaseFormulaTable>;
20
+ }
21
+ export declare function normalizeBaseFormulaTableName(displayName: string): string;
22
+ export declare function createBaseFormulaTableNameMap(snapshot: IBaseFormulaSnapshot): ReadonlyMap<string, string>;
23
+ export declare function allocateBaseFormulaTableName(displayName: string, existingNames: Iterable<string>, preferredName?: string): string;
24
+ export declare function getBaseFormulaTableName(table: BaseFormulaTable, snapshot: IBaseFormulaSnapshot): string;
25
+ export declare function normalizeBaseFormulaTableReferences(formula: string, snapshot: IBaseFormulaSnapshot): string;
26
+ export declare function createBaseFormulaTableReferenceNormalizer(snapshot: IBaseFormulaSnapshot, formulaNames?: ReadonlyMap<string, string>): (formula: string) => string;
27
+ export declare function migrateBaseFormulaTableNames(snapshot: IBaseSnapshot): void;
28
+ export {};
@@ -15,5 +15,7 @@
15
15
  */
16
16
  export { BaseDataModel } from './base-data-model';
17
17
  export { createDefaultBaseTableSnapshot, getEmptySnapshot as getBasesEmptySnapshot, type ICreateDefaultBaseTableSnapshotOptions, } from './empty-snapshot';
18
- export { BaseFieldType, BaseFilterConjunction, BaseFilterOperator, BaseSortDirection, BaseViewType } from './typedef';
19
- export type { BaseCellMatrix, BaseCellPrimitiveValue, CellValue as BaseCellValue, BaseCellValueType, BaseHitTestResult, BaseId, PrimitiveCellValue as BasePrimitiveCellValue, BaseSelection, BaseSnapshot, BaseViewProjection, FieldConfig, FieldId, FieldSnapshot, IBaseAttachment, IBaseCellData, IBaseInvalidation, IBaseRect, IBaseResources, IBaseSnapshot, IBaseViewColorCondition, IBaseViewport, ICalendarEventResizeSelection, ICalendarEventSelection, ICalendarProjection, ICalendarViewConfig, ICardLayoutConfig, IFieldCapabilities, IFieldSnapshot, IFilterCondition, IFilterConfig, IGalleryCardSelection, IGalleryProjection, IGalleryViewConfig, IGanttBarSelection, IGanttCellSelection, IGanttProjection, IGanttTimeColumn, IGanttViewConfig, IGridCellSelection, IGridFieldSelection, IGridGroupSelection, IGridProjection, IGridRecordSelection, IGridViewConfig, IGroupConfig, IInvalidViewProjection, IKanbanCardSelection, IKanbanColumnSetting, IKanbanFieldCardSetting, IKanbanProjection, IKanbanViewConfig, IProjectedField, IProjectedGroup, IProjectedRow, IRecordSnapshot, ISortConfig, ITableSnapshot, IValidationResult, IViewFieldSetting, IViewProjection, IViewSnapshot, KanbanCardLayoutMode, RecordId, RecordSnapshot, TableId, TableSnapshot, ViewId, ViewSnapshot, ViewSpecificConfig, } from './typedef';
18
+ export { allocateBaseFormulaTableName, createBaseFormulaTableNameMap, createBaseFormulaTableReferenceNormalizer, getBaseFormulaTableName, migrateBaseFormulaTableNames, normalizeBaseFormulaTableName, normalizeBaseFormulaTableReferences, } from './formula-table-name';
19
+ export { assertBaseTableRecordIdentity, BASE_RECORD_ID_FIELD_ID, BASE_RECORD_ID_FIELD_NAME, createBaseRecordIdField, isBaseRecordIdFieldName, isValidBaseRecordId, } from './record-identity';
20
+ export { BaseConditionalColorOperator, BaseConditionalColorTarget, BaseConditionalDateMode, BaseFieldType, BaseFilterConjunction, BaseFilterOperator, BaseHierarchyInvalidReason, BaseRecordLinkRole, BaseSortDirection, BaseViewType, } from './typedef';
21
+ export type { BaseCellMatrix, BaseCellPrimitiveValue, CellValue as BaseCellValue, BaseCellValueType, BaseDateHourCycle, BaseHitTestResult, BaseId, PrimitiveCellValue as BasePrimitiveCellValue, BaseSelection, BaseSnapshot, BaseViewProjection, FieldConfig, FieldId, FieldSnapshot, IBaseAttachment, IBaseCellData, IBaseConditionalColoringConfig, IBaseConditionalColorRule, IBaseDateFieldConfig, IBaseHierarchyNodeProjection, IBaseHierarchyProjection, IBaseInvalidation, IBaseRect, IBaseResources, IBaseSnapshot, IBaseViewColorCondition, IBaseViewCommonConfig, IBaseViewport, ICalendarEventResizeSelection, ICalendarEventSelection, ICalendarProjection, ICalendarViewConfig, ICardLayoutConfig, IFieldCapabilities, IFieldSnapshot, IFilterCondition, IFilterConfig, IGalleryCardSelection, IGalleryProjection, IGalleryViewConfig, IGanttBarSelection, IGanttCellSelection, IGanttProjection, IGanttTimeColumn, IGanttViewConfig, IGridCellSelection, IGridFieldSelection, IGridGroupSelection, IGridProjection, IGridRecordSelection, IGridViewConfig, IGroupConfig, IInvalidViewProjection, IKanbanCardSelection, IKanbanColumnSetting, IKanbanFieldCardSetting, IKanbanProjection, IKanbanViewConfig, IProjectedField, IProjectedGroup, IProjectedRow, IRecordLinkFieldConfig, IRecordSnapshot, ISortConfig, ITableSnapshot, IValidationResult, IViewFieldSetting, IViewProjection, IViewSnapshot, KanbanCardLayoutMode, RecordId, RecordSnapshot, TableId, TableSnapshot, ViewId, ViewSnapshot, ViewSpecificConfig, } from './typedef';
@@ -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 { IFieldSnapshot, ITableSnapshot } from './typedef';
17
+ export declare const BASE_RECORD_ID_FIELD_ID = "__record_id";
18
+ export declare const BASE_RECORD_ID_FIELD_NAME = "record-id";
19
+ export declare function createBaseRecordIdField(): IFieldSnapshot;
20
+ export declare function isValidBaseRecordId(recordId: string): boolean;
21
+ export declare function isBaseRecordIdFieldName(name: string): boolean;
22
+ export declare function assertBaseTableRecordIdentity(table: ITableSnapshot): void;
@@ -41,23 +41,41 @@ export interface IBaseResources {
41
41
  attachments?: Record<string, Record<string, unknown>>;
42
42
  }
43
43
  export interface IBaseAttachment {
44
- /** Stable attachment identifier. Use the uploaded file id for remote attachments. */
44
+ /**
45
+ * Stable attachment identifier.
46
+ *
47
+ * Keep this value unique within one attachment cell. For an uploaded attachment, use the
48
+ * identifier returned by the attachment service.
49
+ */
45
50
  id: string;
46
- /** Display name, including the file extension when available. */
51
+ /** User-visible file name. Include the extension so clients can classify the file when `mimeType` is absent. */
47
52
  name: string;
48
- /** MIME type used to classify and preview the attachment. */
53
+ /** MIME type used to classify and preview the attachment, for example `image/webp` or `application/pdf`. */
49
54
  mimeType?: string;
50
- /** File size in bytes. */
55
+ /** File size in bytes. This is descriptive metadata and does not affect source loading. */
51
56
  size?: number;
52
- /** Image width in pixels when known. */
57
+ /** Image width in pixels when known. This is descriptive metadata used to reserve preview space. */
53
58
  width?: number;
54
- /** Image height in pixels when known. */
59
+ /** Image height in pixels when known. This is descriptive metadata used to reserve preview space. */
55
60
  height?: number;
56
- /** How to interpret `source`, for example UUID, URL, or Base64 data. */
61
+ /**
62
+ * How clients should resolve `source`.
63
+ *
64
+ * Facade write APIs infer `BASE64` for data URLs and otherwise default to `URL`. Set this
65
+ * explicitly to `UUID` for identifiers managed by an attachment service.
66
+ */
57
67
  sourceType?: ImageSourceType;
58
- /** Canonical attachment source: an uploaded file id, URL, or Base64 data URL. */
68
+ /**
69
+ * Canonical attachment source: an uploaded file id, URL, or Base64 data.
70
+ *
71
+ * Facade write APIs require a non-empty source for every non-empty attachment entry.
72
+ */
59
73
  source?: string;
60
- /** Optional preview source when it is distinct from the canonical attachment source. */
74
+ /**
75
+ * Optional preview source when it differs from `source`.
76
+ *
77
+ * A data URL is treated as Base64; every other value is treated as a URL.
78
+ */
61
79
  thumbnail?: string;
62
80
  }
63
81
  export declare enum BaseFieldType {
@@ -72,24 +90,50 @@ export declare enum BaseFieldType {
72
90
  Checkbox = "checkbox",
73
91
  Link = "link",
74
92
  Formula = "formula",
75
- Lookup = "lookup",
76
- Flow = "flow",
77
- Button = "button",
78
93
  Numbering = "numbering",
79
94
  Phone = "phone",
80
95
  Email = "email",
81
- Location = "location",
82
- Barcode = "barcode",
83
96
  Progress = "progress",
84
97
  Currency = "currency",
85
98
  Rating = "rating",
86
- TwoWayLink = "twoWayLink",
99
+ RecordLink = "recordLink",
87
100
  RecordId = "recordId",
88
101
  CreatedBy = "createdBy",
89
102
  UpdatedBy = "updatedBy",
90
103
  CreatedAt = "createdAt",
91
- UpdatedAt = "updatedAt",
92
- Summary = "summary"
104
+ UpdatedAt = "updatedAt"
105
+ }
106
+ /** Semantic roles supported by Base RecordLink fields. */
107
+ export declare enum BaseRecordLinkRole {
108
+ Parent = "parent"
109
+ }
110
+ /**
111
+ * Configuration for a RecordLink field.
112
+ *
113
+ * A RecordLink points to records in another table in the same Base. The cell
114
+ * stores target record IDs, while the UI resolves those IDs to the configured
115
+ * display field. Prefer the dedicated RecordLink Facade methods instead of
116
+ * reading or writing the canonical cell string directly.
117
+ */
118
+ export interface IRecordLinkFieldConfig extends Record<string, unknown> {
119
+ /** ID of the target table. The table must belong to the same Base. */
120
+ targetTableId: TableId;
121
+ /** `false` allows one linked record; `true` allows an ordered list of linked records. */
122
+ multiple: boolean;
123
+ /**
124
+ * Target-table field used as the visible label in cells, cards, and record details.
125
+ * Defaults to the target table's primary field. The field must exist and must not
126
+ * be a system field such as `record-id`.
127
+ */
128
+ displayFieldId?: FieldId;
129
+ /**
130
+ * Ordered target-table fields shown as secondary context in the record picker.
131
+ * These fields help users distinguish records; they do not change the stored link
132
+ * or add more labels to the cell. IDs must be unique, existing, non-system fields.
133
+ */
134
+ pickerFieldIds?: FieldId[];
135
+ /** Optional table-level semantic role of this link. */
136
+ relationRole?: BaseRecordLinkRole;
93
137
  }
94
138
  export declare enum BaseViewType {
95
139
  Grid = "grid",
@@ -99,7 +143,123 @@ export declare enum BaseViewType {
99
143
  Gallery = "gallery"
100
144
  }
101
145
  export type FieldConfig = Record<string, unknown>;
102
- export type ViewSpecificConfig = IGridViewConfig | IKanbanViewConfig | ICalendarViewConfig | IGanttViewConfig | IGalleryViewConfig | Record<string, unknown>;
146
+ export type BaseDateHourCycle = 'h12' | 'h24';
147
+ /** Where a Base conditional color is painted when its condition matches. */
148
+ export declare const BaseConditionalColorTarget: {
149
+ /** Paint only the cell in the rule's field. */
150
+ readonly CELL: "cell";
151
+ /** Paint the complete record row. */
152
+ readonly ROW: "row";
153
+ /** Paint the rule's field column unconditionally; operator, operand, and date mode are ignored. */
154
+ readonly COLUMN: "column";
155
+ };
156
+ export type BaseConditionalColorTarget = typeof BaseConditionalColorTarget[keyof typeof BaseConditionalColorTarget];
157
+ /**
158
+ * Operators supported by Base conditional coloring rules.
159
+ *
160
+ * Text, select, person, and similar fields support equality, containment, and
161
+ * empty checks. Number, currency, progress, and rating fields support equality,
162
+ * numeric comparison, and empty checks. Date-like fields support equality,
163
+ * before/after, and empty checks. Checkbox fields support equality only.
164
+ */
165
+ export declare const BaseConditionalColorOperator: {
166
+ readonly IS: "is";
167
+ readonly IS_NOT: "isNot";
168
+ readonly CONTAINS: "contains";
169
+ readonly NOT_CONTAINS: "notContains";
170
+ readonly IS_EMPTY: "isEmpty";
171
+ readonly IS_NOT_EMPTY: "isNotEmpty";
172
+ readonly GREATER_THAN: "greaterThan";
173
+ readonly LESS_THAN: "lessThan";
174
+ readonly BEFORE: "before";
175
+ readonly AFTER: "after";
176
+ };
177
+ export type BaseConditionalColorOperator = typeof BaseConditionalColorOperator[keyof typeof BaseConditionalColorOperator];
178
+ /**
179
+ * Relative or exact date windows supported by date conditional coloring rules.
180
+ *
181
+ * With `IS`, dates inside the selected window match. `IS_NOT` matches dates
182
+ * outside it, `BEFORE` matches dates before its start, and `AFTER` matches
183
+ * dates after its end. Relative windows do not use an operand; `EXACT` does.
184
+ */
185
+ export declare const BaseConditionalDateMode: {
186
+ readonly EXACT: "exact";
187
+ readonly TODAY: "today";
188
+ readonly TOMORROW: "tomorrow";
189
+ readonly YESTERDAY: "yesterday";
190
+ readonly THIS_WEEK: "thisWeek";
191
+ readonly LAST_WEEK: "lastWeek";
192
+ readonly THIS_MONTH: "thisMonth";
193
+ readonly LAST_MONTH: "lastMonth";
194
+ readonly PAST_7_DAYS: "past7";
195
+ readonly NEXT_7_DAYS: "next7";
196
+ readonly PAST_30_DAYS: "past30";
197
+ readonly NEXT_30_DAYS: "next30";
198
+ };
199
+ export type BaseConditionalDateMode = typeof BaseConditionalDateMode[keyof typeof BaseConditionalDateMode];
200
+ /**
201
+ * A color condition stored by a Base view.
202
+ *
203
+ * Rules are evaluated in array order. Earlier matching rules are painted last
204
+ * and therefore have higher visual priority than later matching rules.
205
+ */
206
+ export interface IBaseViewColorCondition {
207
+ /** Stable id unique within the view. */
208
+ id: string;
209
+ /** Valid CSS color rendered for a match, for example `#fde9e9` or `rgba(255, 0, 0, 0.2)`. */
210
+ color: string;
211
+ /** Paint target. Gantt color conditions may omit it for legacy snapshots. */
212
+ target?: BaseConditionalColorTarget;
213
+ /** Field whose value is evaluated for cell/row targets, or whose column is painted for a column target. */
214
+ fieldId: FieldId;
215
+ /** Comparison performed against the field value. Ignored for a column target. */
216
+ operator: BaseConditionalColorOperator;
217
+ /**
218
+ * Comparison value in the field's normal value shape: number for numeric
219
+ * fields, boolean for checkbox fields, text/option ids for text and select
220
+ * fields, or a date-compatible value for an exact date comparison. Ignored
221
+ * by empty checks, relative date modes, and column targets.
222
+ */
223
+ operand?: unknown;
224
+ /**
225
+ * Exact or relative date window for Date, CreatedAt, and UpdatedAt fields.
226
+ * Defaults to `EXACT` when omitted. Ignored for a column target.
227
+ */
228
+ dateMode?: BaseConditionalDateMode;
229
+ }
230
+ /** A complete Base conditional coloring rule used by Grid and other Base views. */
231
+ export interface IBaseConditionalColorRule extends IBaseViewColorCondition {
232
+ /** Paint target for the matching rule. */
233
+ target: BaseConditionalColorTarget;
234
+ }
235
+ /** Persisted conditional coloring configuration for one Base view. */
236
+ export interface IBaseConditionalColoringConfig {
237
+ /** Rules in descending visual-priority order. */
238
+ rules: IBaseConditionalColorRule[];
239
+ }
240
+ /** Configuration shared by every Base view type. */
241
+ export interface IBaseViewCommonConfig {
242
+ /** Conditional coloring rules, or `null` when the feature is cleared. */
243
+ conditionalColoring?: IBaseConditionalColoringConfig | null;
244
+ }
245
+ /**
246
+ * Display options for Date, CreatedAt, and UpdatedAt fields.
247
+ */
248
+ export interface IBaseDateFieldConfig extends FieldConfig {
249
+ /**
250
+ * Date-only display pattern, such as `yyyy/mm/dd`.
251
+ */
252
+ pattern?: string;
253
+ /**
254
+ * Whether to append a time to the formatted date.
255
+ */
256
+ includeTime?: boolean;
257
+ /**
258
+ * Explicit 12-hour or 24-hour time format.
259
+ */
260
+ hourCycle?: BaseDateHourCycle;
261
+ }
262
+ export type ViewSpecificConfig = IGridViewConfig | IKanbanViewConfig | ICalendarViewConfig | IGanttViewConfig | IGalleryViewConfig | (IBaseViewCommonConfig & Record<string, unknown>);
103
263
  export interface IBaseSnapshot {
104
264
  id: BaseId;
105
265
  name: string;
@@ -116,7 +276,19 @@ export interface IBaseSnapshot {
116
276
  }
117
277
  export interface ITableSnapshot {
118
278
  id: TableId;
279
+ /**
280
+ * Human-readable display name, subject to Excel worksheet name rules because
281
+ * each Base table is exported as a worksheet. Names must be unique within the
282
+ * Base, ignoring case. Do not use this value as a structured-reference identifier.
283
+ */
119
284
  name: string;
285
+ /**
286
+ * Persisted stable identifier used by formulas and exported structured references.
287
+ *
288
+ * Historical snapshots may omit this field. Use `getBaseFormulaTableName()` when a
289
+ * resolved formula identifier is required.
290
+ */
291
+ formulaName?: string;
120
292
  fields: Record<FieldId, IFieldSnapshot>;
121
293
  fieldOrder: FieldId[];
122
294
  records: Record<RecordId, IRecordSnapshot>;
@@ -232,7 +404,7 @@ export interface IGroupConfig {
232
404
  direction?: BaseSortDirection;
233
405
  hideEmptyGroup?: boolean;
234
406
  }
235
- export interface IGridViewConfig {
407
+ export interface IGridViewConfig extends IBaseViewCommonConfig {
236
408
  frozenFieldCount?: number;
237
409
  showRecordIndex?: boolean;
238
410
  rowHeight?: 'short' | 'medium' | 'tall' | 'extraTall';
@@ -252,7 +424,7 @@ export interface IKanbanColumnSetting {
252
424
  color?: string;
253
425
  collapsed?: boolean;
254
426
  }
255
- export interface IKanbanViewConfig {
427
+ export interface IKanbanViewConfig extends IBaseViewCommonConfig {
256
428
  groupFieldId: FieldId;
257
429
  coverFieldId?: FieldId | null;
258
430
  cardLayout?: KanbanCardLayoutMode;
@@ -261,7 +433,7 @@ export interface IKanbanViewConfig {
261
433
  columnSettings?: Record<string, IKanbanColumnSetting>;
262
434
  card?: ICardLayoutConfig;
263
435
  }
264
- export interface ICalendarViewConfig {
436
+ export interface ICalendarViewConfig extends IBaseViewCommonConfig {
265
437
  startDateFieldId: FieldId;
266
438
  endDateFieldId?: FieldId;
267
439
  titleFieldId?: FieldId;
@@ -281,16 +453,7 @@ export interface ICalendarViewConfig {
281
453
  order?: number;
282
454
  }>;
283
455
  }
284
- export interface IBaseViewColorCondition {
285
- id: string;
286
- color: string;
287
- target?: 'cell' | 'row' | 'column';
288
- fieldId: FieldId;
289
- operator: 'is' | 'isNot' | 'contains' | 'notContains' | 'isEmpty' | 'isNotEmpty' | 'greaterThan' | 'lessThan' | 'before' | 'after';
290
- operand?: unknown;
291
- dateMode?: 'exact' | 'today' | 'tomorrow' | 'yesterday' | 'thisWeek' | 'lastWeek' | 'thisMonth' | 'lastMonth' | 'past7' | 'next7' | 'past30' | 'next30';
292
- }
293
- export interface IGanttViewConfig {
456
+ export interface IGanttViewConfig extends IBaseViewCommonConfig {
294
457
  startDateFieldId: FieldId;
295
458
  endDateFieldId: FieldId;
296
459
  titleFieldId?: FieldId;
@@ -326,7 +489,7 @@ export interface IGanttViewConfig {
326
489
  }>;
327
490
  };
328
491
  }
329
- export interface IGalleryViewConfig {
492
+ export interface IGalleryViewConfig extends IBaseViewCommonConfig {
330
493
  card: ICardLayoutConfig;
331
494
  coverFieldId?: FieldId | null;
332
495
  cardLayout?: KanbanCardLayoutMode;
@@ -362,13 +525,37 @@ export interface IProjectedGroup {
362
525
  level?: number;
363
526
  children?: IProjectedGroup[];
364
527
  }
528
+ /** Why a stored Parent link cannot participate in the effective hierarchy. */
529
+ export declare enum BaseHierarchyInvalidReason {
530
+ MissingParent = "missingParent",
531
+ SelfParent = "selfParent",
532
+ Cycle = "cycle",
533
+ MaxDepth = "maxDepth"
534
+ }
535
+ export interface IBaseHierarchyNodeProjection {
536
+ recordId: RecordId;
537
+ parentRecordId: RecordId | null;
538
+ depth: number;
539
+ directChildCount: number;
540
+ subtreeHeight: number;
541
+ subtreeEndIndex: number;
542
+ invalidReason?: BaseHierarchyInvalidReason;
543
+ }
544
+ export interface IBaseHierarchyProjection {
545
+ fieldId: FieldId;
546
+ rootRecordIds: RecordId[];
547
+ orderedRecordIds: RecordId[];
548
+ nodes: Record<RecordId, IBaseHierarchyNodeProjection>;
549
+ }
365
550
  export interface IGridProjection extends IViewProjection {
366
551
  type: BaseViewType.Grid;
367
552
  frozenFieldCount?: number;
553
+ hierarchy?: IBaseHierarchyProjection;
368
554
  }
369
555
  export interface IKanbanProjection extends IViewProjection {
370
556
  type: BaseViewType.Kanban;
371
557
  groupFieldId: FieldId;
558
+ titleFieldId?: FieldId;
372
559
  coverFieldId?: FieldId | null;
373
560
  cardLayout: KanbanCardLayoutMode;
374
561
  showFieldNames: boolean;
@@ -433,6 +620,7 @@ export interface IGanttProjection extends IViewProjection {
433
620
  }
434
621
  export interface IGalleryProjection extends IViewProjection {
435
622
  type: BaseViewType.Gallery;
623
+ titleFieldId?: FieldId;
436
624
  coverFieldId?: FieldId | null;
437
625
  cardLayout: KanbanCardLayoutMode;
438
626
  showFieldNames: boolean;
@@ -549,6 +737,18 @@ export type BaseHitTestResult = {
549
737
  type: 'empty';
550
738
  x: number;
551
739
  y: number;
740
+ } | {
741
+ type: 'grid-text-preview';
742
+ tableId: TableId;
743
+ viewId: ViewId;
744
+ recordId: RecordId;
745
+ fieldId: FieldId;
746
+ virtual?: boolean;
747
+ x: number;
748
+ y: number;
749
+ width: number;
750
+ height: number;
751
+ maxScroll: number;
552
752
  } | {
553
753
  type: 'grid-fill-handle';
554
754
  tableId: TableId;
@@ -572,6 +772,39 @@ export type BaseHitTestResult = {
572
772
  tableId: TableId;
573
773
  viewId: ViewId;
574
774
  recordId: RecordId;
775
+ } | {
776
+ type: 'grid-hierarchy-toggle' | 'grid-hierarchy-add-child';
777
+ tableId: TableId;
778
+ viewId: ViewId;
779
+ recordId: RecordId;
780
+ } | {
781
+ type: 'grid-cell-checkbox';
782
+ tableId: TableId;
783
+ viewId: ViewId;
784
+ recordId: RecordId;
785
+ fieldId: FieldId;
786
+ } | {
787
+ type: 'grid-rating-icon';
788
+ tableId: TableId;
789
+ viewId: ViewId;
790
+ recordId: RecordId;
791
+ fieldId: FieldId;
792
+ value: number;
793
+ } | {
794
+ type: 'grid-row-header' | 'grid-row-checkbox';
795
+ tableId: TableId;
796
+ viewId: ViewId;
797
+ recordId: RecordId;
798
+ } | {
799
+ type: 'grid-row-header-select-all';
800
+ tableId: TableId;
801
+ viewId: ViewId;
802
+ } | {
803
+ type: 'grid-row-drag-handle';
804
+ tableId: TableId;
805
+ viewId: ViewId;
806
+ recordId: RecordId;
807
+ disabled: boolean;
575
808
  } | {
576
809
  type: 'kanban-add-record';
577
810
  tableId: TableId;
@@ -0,0 +1,20 @@
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 { ArrangeTypeEnum } from '../types/interfaces/i-drawing';
17
+ /** Clamps a requested zero-based index to an available drawing order. */
18
+ export declare function normalizeDrawingOrderIndex(index: number, length: number): number;
19
+ /** Resolves a relative drawing arrangement to its zero-based target index. */
20
+ export declare function getDrawingOrderIndex(currentIndex: number, length: number, arrangeType: ArrangeTypeEnum): number;
@@ -14,6 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { Nullable } from '../../shared';
17
+ import type { ITextRangeParam } from '../../sheets/typedef';
18
+ import type { LocaleType } from '../../types/enum';
17
19
  import type { IDocumentBody, IDocumentData, IDocumentRenderConfig, IDocumentStyle, IDrawings, IListData } from '../../types/interfaces/i-document-data';
18
20
  import type { IPaddingData } from '../../types/interfaces/i-style-data';
19
21
  import type { JSONXActions } from './json-x/json-x';
@@ -24,6 +26,19 @@ export declare const DEFAULT_DOC: {
24
26
  id: string;
25
27
  documentStyle: {};
26
28
  };
29
+ export interface IDocumentStatistics {
30
+ words: number;
31
+ charactersWithoutSpaces: number;
32
+ charactersWithSpaces: number;
33
+ paragraphs: number;
34
+ nonAsianWords: number;
35
+ asianCharactersAndKoreanWords: number;
36
+ }
37
+ export interface IDocumentStatisticsOptions {
38
+ locale?: LocaleType;
39
+ ranges?: Readonly<ITextRangeParam[]>;
40
+ signal?: AbortSignal;
41
+ }
27
42
  interface IDrawingUpdateConfig {
28
43
  left: number;
29
44
  top: number;
@@ -81,5 +96,6 @@ export declare class DocumentDataModel extends DocumentDataModelSimple {
81
96
  private _initializeHeaderFooterModel;
82
97
  updateDocumentId(unitId: string): void;
83
98
  getPlainText(): string;
99
+ getStatistics(options?: IDocumentStatisticsOptions): Promise<IDocumentStatistics>;
84
100
  }
85
101
  export {};
@@ -13,10 +13,5 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { IRange } from '../sheets/typedef';
17
- import { ObjectMatrix } from './object-matrix';
18
- /**
19
- * @deprecated this function could cause memory out of use in large range.
20
- */
21
- export declare function queryObjectMatrix<T>(matrix: ObjectMatrix<T>, match: (value: T) => boolean): IRange[];
22
- export declare function multiSubtractMultiRanges(ranges1: IRange[], ranges2: IRange[]): IRange[];
16
+ import type { IDocumentStatistics, IDocumentStatisticsOptions } from './document-data-model';
17
+ export declare function calculateDocumentStatistics(dataStream: string, options: IDocumentStatisticsOptions): Promise<IDocumentStatistics>;
@@ -27,7 +27,7 @@ export { DEFAULT_DOCUMENT_SUB_COMPONENT_ID } from './subdocument';
27
27
  export { ActionIterator } from './text-x/action-iterator';
28
28
  export { PRESERVE_INSERTED_PARAGRAPH_IDS, TextXActionType } from './text-x/action-types';
29
29
  export type { IDeleteAction, IInsertAction, IRetainAction, TextXAction } from './text-x/action-types';
30
- export { normalizeInsertedSectionIdsForDocument, normalizeTextRuns, RESTORE_INSERTED_PARAGRAPH_IDS } from './text-x/apply-utils/common';
30
+ export { normalizeInsertedSectionIdsForDocument, normalizeTextRuns, RESTORE_INSERTED_PARAGRAPH_IDS, } from './text-x/apply-utils/common';
31
31
  export { updateAttributeByDelete } from './text-x/apply-utils/delete-apply';
32
32
  export { updateAttributeByInsert } from './text-x/apply-utils/insert-apply';
33
33
  export * from './text-x/build-utils';
@@ -1385,12 +1385,15 @@ export declare class RichTextBuilder extends RichTextValue {
1385
1385
  static create(data?: IDocumentData): RichTextBuilder;
1386
1386
  private _doc;
1387
1387
  private readonly _trackedRanges;
1388
+ private _childHandleRevision;
1388
1389
  constructor(data: IDocumentData);
1389
1390
  /**
1390
1391
  * Returns editable paragraph handles backed by this detached rich-text builder.
1391
1392
  *
1392
- * Paragraph boundaries come from the document model rather than splitting plain text. Each handle stays aligned
1393
- * when text in this builder grows or shrinks, so callers can safely iterate from the first paragraph to the last.
1393
+ * Paragraph boundaries come from the document model rather than splitting plain text. Handles stay aligned across
1394
+ * edits made through their child run handles, so callers can safely iterate from the first paragraph to the last.
1395
+ * Direct builder edits that change text or run boundaries invalidate previously returned paragraph and run handles;
1396
+ * query them again after calling methods such as `insertText()`, `setStyle()`, `setLink()`, or `delete()`.
1394
1397
  *
1395
1398
  * @returns Editable paragraphs in document order.
1396
1399
  * @example
@@ -1426,6 +1429,7 @@ export declare class RichTextBuilder extends RichTextValue {
1426
1429
  private _createParagraphBuilder;
1427
1430
  private _trackRange;
1428
1431
  private _rebaseTrackedRanges;
1432
+ private _invalidateChildHandles;
1429
1433
  /**
1430
1434
  * Appends plain text to the rich text.
1431
1435
  *
@@ -1497,14 +1501,15 @@ export declare class RichTextBuilder extends RichTextValue {
1497
1501
  */
1498
1502
  columns(options: IRichTextColumnsOptions): RichTextBuilder;
1499
1503
  /**
1500
- * Appends one text span with explicit style.
1504
+ * Appends one text span with an optional style.
1501
1505
  *
1502
1506
  * Prefer this method when combining multiple styles, because the style object is local to the inserted text and does
1503
1507
  * not leak into following calls.
1504
1508
  *
1505
1509
  * @param text Text to append.
1506
- * @param style Text style for this span. Agent-friendly aliases such as `bold`, `italic`, `fontFamily`, `fontSize`,
1507
- * `color`, and `background` are supported alongside native document text style fields.
1510
+ * @param style Optional text style for this span. When omitted, the span is appended as unstyled text. Agent-friendly
1511
+ * aliases such as `bold`, `italic`, `fontFamily`, `fontSize`, `color`, and `background` are supported alongside native
1512
+ * document text style fields.
1508
1513
  * @returns The current builder for chaining.
1509
1514
  * @example
1510
1515
  * ```ts
@@ -1513,7 +1518,7 @@ export declare class RichTextBuilder extends RichTextValue {
1513
1518
  * .span('Important', { bold: true, italic: true, color: '#d92d20' });
1514
1519
  * ```
1515
1520
  */
1516
- span(text: string, style: IRichTextSpanStyle): RichTextBuilder;
1521
+ span(text: string, style?: IRichTextSpanStyle): RichTextBuilder;
1517
1522
  /**
1518
1523
  * Appends bold text.
1519
1524
  *
@@ -1783,8 +1788,9 @@ export declare class RichTextParagraphBuilder extends RichTextValue {
1783
1788
  private readonly _owner;
1784
1789
  private readonly _paragraphId;
1785
1790
  private readonly _range;
1791
+ private readonly _revision;
1786
1792
  /** @hideconstructor */
1787
- constructor(_owner: RichTextBuilder, _paragraphId: string, _range: IMutableRichTextRange);
1793
+ constructor(_owner: RichTextBuilder, _paragraphId: string, _range: IMutableRichTextRange, _revision: number);
1788
1794
  /** Returns the persisted paragraph id. */
1789
1795
  getId(): string;
1790
1796
  /** Returns the current paragraph range without its trailing paragraph marker. */
@@ -1813,6 +1819,7 @@ export declare class RichTextParagraphBuilder extends RichTextValue {
1813
1819
  getData(): IDocumentData;
1814
1820
  copy(): RichTextBuilder;
1815
1821
  private _getParagraph;
1822
+ private _assertActive;
1816
1823
  }
1817
1824
  /**
1818
1825
  * An editable text-run handle owned by a detached {@link RichTextBuilder}.
@@ -1826,9 +1833,10 @@ export declare class RichTextRunBuilder {
1826
1833
  private readonly _textStyle;
1827
1834
  private readonly _styleId;
1828
1835
  private readonly _hasExplicitTextStyle;
1836
+ private readonly _revision;
1829
1837
  private _active;
1830
1838
  /** @hideconstructor */
1831
- constructor(_owner: RichTextBuilder, _range: IMutableRichTextRange, _textStyle: ITextStyle | undefined, _styleId: string | undefined, _hasExplicitTextStyle: boolean);
1839
+ constructor(_owner: RichTextBuilder, _range: IMutableRichTextRange, _textStyle: ITextStyle | undefined, _styleId: string | undefined, _hasExplicitTextStyle: boolean, _revision: number);
1832
1840
  /** Inclusive start offset, kept for compatibility with existing `getTextRuns()` callers. */
1833
1841
  get st(): number;
1834
1842
  /** Exclusive end offset, automatically updated after text replacement. */
@@ -1870,5 +1878,6 @@ export declare class RichTextRunBuilder {
1870
1878
  * ```
1871
1879
  */
1872
1880
  setText(text: string): this;
1881
+ private _assertActive;
1873
1882
  }
1874
1883
  export {};
@@ -39,13 +39,7 @@ export declare enum DataStreamTreeTokenType {
39
39
  COLUMN_GROUP_END = "\u0015",// column group end
40
40
  BLOCK_START = "\u0010",// block start
41
41
  BLOCK_END = "\u0011",// block end
42
- /**
43
- * @deprecated
44
- */
45
42
  CUSTOM_RANGE_START = "\u001F",// custom range start
46
- /**
47
- * @deprecated
48
- */
49
43
  CUSTOM_RANGE_END = "\u001E",// custom range end
50
44
  COLUMN_BREAK = "\v",// column break
51
45
  PAGE_BREAK = "\f",// page break