@univerjs/core 1.0.0-beta.0 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +45 -3
- package/lib/cjs/index.js +5415 -5012
- package/lib/es/facade.js +45 -3
- package/lib/es/index.js +6639 -6251
- package/lib/facade.js +45 -3
- package/lib/index.js +6639 -6251
- package/lib/types/bases/formula-table-name.d.ts +28 -0
- package/lib/types/bases/index.d.ts +1 -0
- package/lib/types/bases/typedef.d.ts +24 -0
- package/lib/types/common/drawing-order.d.ts +20 -0
- package/lib/types/common/lodash.d.ts +1 -1
- package/lib/types/docs/data-model/document-data-model.d.ts +16 -0
- package/lib/types/{shared/object-matrix-query.d.ts → docs/data-model/document-statistics.d.ts} +2 -7
- package/lib/types/docs/data-model/rich-text-builder.d.ts +48 -4
- package/lib/types/docs/data-model/text-x/build-utils/drawings.d.ts +2 -1
- package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +2 -0
- package/lib/types/docs/data-model/types.d.ts +0 -6
- package/lib/types/facade/f-univer.d.ts +40 -3
- package/lib/types/index.d.ts +1 -0
- package/lib/types/services/undoredo/undoredo.service.d.ts +14 -1
- package/lib/types/shared/index.d.ts +0 -1
- package/lib/types/sheets/typedef.d.ts +2 -0
- package/lib/types/types/interfaces/i-document-data.d.ts +36 -0
- package/lib/types/types/interfaces/i-style-data.d.ts +3 -1
- package/lib/types/univer.d.ts +6 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +24 -22
- 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,6 +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 { allocateBaseFormulaTableName, createBaseFormulaTableNameMap, createBaseFormulaTableReferenceNormalizer, getBaseFormulaTableName, migrateBaseFormulaTableNames, normalizeBaseFormulaTableName, normalizeBaseFormulaTableReferences, } from './formula-table-name';
|
|
18
19
|
export { assertBaseTableRecordIdentity, BASE_RECORD_ID_FIELD_ID, BASE_RECORD_ID_FIELD_NAME, createBaseRecordIdField, isBaseRecordIdFieldName, isValidBaseRecordId, } from './record-identity';
|
|
19
20
|
export { BaseConditionalColorOperator, BaseConditionalColorTarget, BaseConditionalDateMode, BaseFieldType, BaseFilterConjunction, BaseFilterOperator, BaseHierarchyInvalidReason, BaseRecordLinkRole, BaseSortDirection, BaseViewType, } from './typedef';
|
|
20
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';
|
|
@@ -276,7 +276,19 @@ export interface IBaseSnapshot {
|
|
|
276
276
|
}
|
|
277
277
|
export interface ITableSnapshot {
|
|
278
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
|
+
*/
|
|
279
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;
|
|
280
292
|
fields: Record<FieldId, IFieldSnapshot>;
|
|
281
293
|
fieldOrder: FieldId[];
|
|
282
294
|
records: Record<RecordId, IRecordSnapshot>;
|
|
@@ -725,6 +737,18 @@ export type BaseHitTestResult = {
|
|
|
725
737
|
type: 'empty';
|
|
726
738
|
x: number;
|
|
727
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;
|
|
728
752
|
} | {
|
|
729
753
|
type: 'grid-fill-handle';
|
|
730
754
|
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 {};
|
package/lib/types/{shared/object-matrix-query.d.ts → docs/data-model/document-statistics.d.ts}
RENAMED
|
@@ -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 {
|
|
17
|
-
|
|
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>;
|
|
@@ -1558,6 +1558,24 @@ export declare class RichTextBuilder extends RichTextValue {
|
|
|
1558
1558
|
* ```
|
|
1559
1559
|
*/
|
|
1560
1560
|
code(text: string): RichTextBuilder;
|
|
1561
|
+
/**
|
|
1562
|
+
* Appends linked text.
|
|
1563
|
+
*
|
|
1564
|
+
* This is the agent-friendly alias of `insertLink(text, url)`. Use `setLink(start, end, url)` only when applying a
|
|
1565
|
+
* link to text that is already present and numeric offsets are unavoidable.
|
|
1566
|
+
*
|
|
1567
|
+
* @param text Visible link text to append. An empty string is ignored.
|
|
1568
|
+
* @param url Link destination.
|
|
1569
|
+
* @returns The current builder for chaining.
|
|
1570
|
+
* @example
|
|
1571
|
+
* ```ts
|
|
1572
|
+
* const richText = univerAPI.newRichText()
|
|
1573
|
+
* .text('Read ')
|
|
1574
|
+
* .link('Univer documentation', 'https://docs.univer.ai')
|
|
1575
|
+
* .text(' for details.');
|
|
1576
|
+
* ```
|
|
1577
|
+
*/
|
|
1578
|
+
link(text: string, url: string): RichTextBuilder;
|
|
1561
1579
|
/**
|
|
1562
1580
|
* Appends one ordered, unordered, or checklist paragraph.
|
|
1563
1581
|
*
|
|
@@ -1745,6 +1763,28 @@ export declare class RichTextBuilder extends RichTextValue {
|
|
|
1745
1763
|
* ```
|
|
1746
1764
|
*/
|
|
1747
1765
|
cancelLink(start: number, end: number): RichTextBuilder;
|
|
1766
|
+
/**
|
|
1767
|
+
* Removes a link while preserving its visible text.
|
|
1768
|
+
*
|
|
1769
|
+
* Link ids are available from `getLinks()`. This readable alias avoids exposing text offsets for the common case.
|
|
1770
|
+
* Use `cancelLink(start, end)` only when removing every link in a known text range.
|
|
1771
|
+
*
|
|
1772
|
+
* @param id Link range id returned by `getLinks()`.
|
|
1773
|
+
* @returns The current builder for chaining.
|
|
1774
|
+
* @example
|
|
1775
|
+
* ```ts
|
|
1776
|
+
* const richText = univerAPI.newRichText().link('Univer', 'https://univer.ai');
|
|
1777
|
+
* const [link] = richText.getLinks();
|
|
1778
|
+
* if (link) richText.removeLink(link.rangeId);
|
|
1779
|
+
* ```
|
|
1780
|
+
*/
|
|
1781
|
+
removeLink(id: string): RichTextBuilder;
|
|
1782
|
+
/**
|
|
1783
|
+
* Updates a link destination while preserving its visible text.
|
|
1784
|
+
* @param id Link range id returned by `getLinks()`.
|
|
1785
|
+
* @param url New link destination.
|
|
1786
|
+
* @returns The current builder for chaining.
|
|
1787
|
+
*/
|
|
1748
1788
|
updateLink(id: string, url: string): RichTextBuilder;
|
|
1749
1789
|
/**
|
|
1750
1790
|
* Inserts a new paragraph to the end
|
|
@@ -1770,10 +1810,14 @@ export declare class RichTextBuilder extends RichTextValue {
|
|
|
1770
1810
|
*/
|
|
1771
1811
|
insertParagraph(start: number, paragraphStyle: ParagraphStyleBuilder): RichTextBuilder;
|
|
1772
1812
|
/**
|
|
1773
|
-
* Inserts
|
|
1774
|
-
*
|
|
1775
|
-
*
|
|
1776
|
-
*
|
|
1813
|
+
* Inserts linked text at the end of the builder or at an explicit text offset.
|
|
1814
|
+
*
|
|
1815
|
+
* Application and agent code should prefer `link(text, url)` for left-to-right construction. The positional
|
|
1816
|
+
* overload remains available for advanced document-model integrations.
|
|
1817
|
+
*
|
|
1818
|
+
* @param text Visible link text to insert.
|
|
1819
|
+
* @param url Link destination.
|
|
1820
|
+
* @returns The current builder for chaining.
|
|
1777
1821
|
*/
|
|
1778
1822
|
insertLink(text: string, url: string): RichTextBuilder;
|
|
1779
1823
|
insertLink(start: number, text: string, url: string): RichTextBuilder;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { ITextRange, ITextRangeParam } from '../../../../sheets/typedef';
|
|
17
|
-
import type { IDocumentBody, IDrawingParam } from '../../../../types/interfaces';
|
|
17
|
+
import type { IDocumentBody, IDocumentData, IDrawingParam } from '../../../../types/interfaces';
|
|
18
18
|
import type { DocumentDataModel } from '../../document-data-model';
|
|
19
19
|
import type { JSONXActions } from '../../json-x/json-x';
|
|
20
20
|
export interface IAddDrawingParam {
|
|
@@ -23,4 +23,5 @@ export interface IAddDrawingParam {
|
|
|
23
23
|
drawings: IDrawingParam[];
|
|
24
24
|
}
|
|
25
25
|
export declare function getCustomBlockIdsInSelections(body: IDocumentBody, selections: ITextRange[]): string[];
|
|
26
|
+
export declare function removeDrawingReferences(documentData: Pick<IDocumentData, 'body' | 'drawings' | 'drawingsOrder'>, selections: ITextRange[], body?: IDocumentBody | undefined): JSONXActions[];
|
|
26
27
|
export declare const addDrawing: (param: IAddDrawingParam) => false | JSONXActions;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { addCustomDecorationTextX, deleteCustomDecorationTextX } from './custom-decoration';
|
|
17
17
|
import { copyCustomRange, getCustomRangesInterestsWithSelection, isIntersecting } from './custom-range';
|
|
18
|
+
import { removeDrawingReferences } from './drawings';
|
|
18
19
|
import { getParagraphsInRange, getParagraphsInRanges, isSegmentIntersects, makeSelection, normalizeSelection, transformParagraphs } from './selection';
|
|
19
20
|
import { addCustomRangeTextX, deleteCustomRangeTextX, deleteSelectionTextX, retainSelectionTextX } from './text-x-utils';
|
|
20
21
|
export declare class BuildTextUtils {
|
|
@@ -65,6 +66,7 @@ export declare class BuildTextUtils {
|
|
|
65
66
|
};
|
|
66
67
|
static drawing: {
|
|
67
68
|
add: (param: import("./drawings").IAddDrawingParam) => false | import("ot-json1").JSONOp;
|
|
69
|
+
remove: typeof removeDrawingReferences;
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
72
|
export { getSingleDataStreamChange } from './data-stream-change';
|
|
@@ -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
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IDisposable, IDocumentData, IExecutionOptions, ILanguagePack, IParagraphStyle, ITextDecoration, ITextStyle, LifecycleStages } from '@univerjs/core';
|
|
17
|
+
import type { Theme } from '@univerjs/themes';
|
|
17
18
|
import type { Subscription } from 'rxjs';
|
|
18
19
|
import type { IEventParamConfig } from './f-event';
|
|
19
20
|
import { Disposable, ICommandService, Injector, IUniverInstanceService, LifecycleService, ParagraphStyleBuilder, ParagraphStyleValue, RichTextBuilder, RichTextValue, TextDecorationBuilder, TextStyleBuilder, TextStyleValue, Univer } from '@univerjs/core';
|
|
@@ -112,6 +113,42 @@ export declare class FUniver extends Disposable {
|
|
|
112
113
|
* ```
|
|
113
114
|
*/
|
|
114
115
|
redo(): Promise<boolean>;
|
|
116
|
+
/**
|
|
117
|
+
* Set the theme used by Univer.
|
|
118
|
+
* @param {Theme} theme - The complete theme to use.
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { defaultTheme } from '@univerjs/themes';
|
|
122
|
+
*
|
|
123
|
+
* univerAPI.setTheme({
|
|
124
|
+
* ...defaultTheme,
|
|
125
|
+
* primary: {
|
|
126
|
+
* ...defaultTheme.primary,
|
|
127
|
+
* 600: '#274fee',
|
|
128
|
+
* },
|
|
129
|
+
* });
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
setTheme(theme: Theme): void;
|
|
133
|
+
/**
|
|
134
|
+
* Get the theme currently used by Univer.
|
|
135
|
+
* @returns {Theme} The current theme.
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* const theme = univerAPI.getCurrentTheme();
|
|
139
|
+
* console.log(theme.primary[600]);
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
getCurrentTheme(): Theme;
|
|
143
|
+
/**
|
|
144
|
+
* Whether Univer is currently using dark mode.
|
|
145
|
+
* @returns {boolean} Whether dark mode is enabled.
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* const darkMode = univerAPI.isDarkMode();
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
isDarkMode(): boolean;
|
|
115
152
|
/**
|
|
116
153
|
* Toggle dark mode on or off.
|
|
117
154
|
* @param {boolean} isDarkMode - Whether the dark mode is enabled.
|
|
@@ -242,9 +279,9 @@ export declare class FUniver extends Disposable {
|
|
|
242
279
|
* @example
|
|
243
280
|
* ```ts
|
|
244
281
|
* const richText = univerAPI.newRichText()
|
|
245
|
-
* .
|
|
246
|
-
* .
|
|
247
|
-
* .
|
|
282
|
+
* .text('Read ')
|
|
283
|
+
* .link('Univer documentation', 'https://docs.univer.ai')
|
|
284
|
+
* .text(' for details.');
|
|
248
285
|
* ```
|
|
249
286
|
*/
|
|
250
287
|
newRichText(): RichTextBuilder;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export * from './common/async';
|
|
|
19
19
|
export { isBooleanString } from './common/boolean';
|
|
20
20
|
export * from './common/const';
|
|
21
21
|
export * from './common/di';
|
|
22
|
+
export { getDrawingOrderIndex, normalizeDrawingOrderIndex } from './common/drawing-order';
|
|
22
23
|
export { shallowEqual } from './common/equal';
|
|
23
24
|
export { CanceledError, CustomCommandExecutionError } from './common/error';
|
|
24
25
|
export { noop, throttle } from './common/function';
|
|
@@ -20,6 +20,7 @@ import type { IMutationInfo } from '../command/command.service';
|
|
|
20
20
|
import { BehaviorSubject } from 'rxjs';
|
|
21
21
|
import { Disposable } from '../../shared/lifecycle';
|
|
22
22
|
import { CommandType, ICommandService } from '../command/command.service';
|
|
23
|
+
import { IConfigService } from '../config/config.service';
|
|
23
24
|
import { IContextService } from '../context/context.service';
|
|
24
25
|
import { IUniverInstanceService } from '../instance/instance.service';
|
|
25
26
|
export interface IUndoRedoItem {
|
|
@@ -35,6 +36,12 @@ export interface IUndoRedoItem {
|
|
|
35
36
|
export interface IUndoRedoService {
|
|
36
37
|
undoRedoStatus$: Observable<IUndoRedoStatus>;
|
|
37
38
|
pushUndoRedo(item: IUndoRedoItem): void;
|
|
39
|
+
/**
|
|
40
|
+
* Group undo redo items pushed while the returned scope is active.
|
|
41
|
+
* Reusing the same group id joins consecutive scopes without exposing the
|
|
42
|
+
* group to commands or undo redo items.
|
|
43
|
+
*/
|
|
44
|
+
beginUndoRedoGroup(unitId: string, groupId: string, mode?: 'replace' | 'append'): IDisposable;
|
|
38
45
|
/** Pitch the top redo element of the currently focused Univer document instance. */
|
|
39
46
|
pitchTopUndoElement(): Nullable<IUndoRedoItem>;
|
|
40
47
|
/** Pitch the top undo element of the currently focused Univer document instance. */
|
|
@@ -72,6 +79,8 @@ export interface IUndoRedoStatus {
|
|
|
72
79
|
undos: number;
|
|
73
80
|
redos: number;
|
|
74
81
|
}
|
|
82
|
+
export declare const DEFAULT_UNDO_REDO_HISTORY_LIMIT = 50;
|
|
83
|
+
export declare const UNDO_REDO_HISTORY_LIMIT_CONFIG_KEY = "undoRedo.historyLimit";
|
|
75
84
|
export declare const RedoCommandId = "univer.command.redo";
|
|
76
85
|
export declare const UndoCommandId = "univer.command.undo";
|
|
77
86
|
export declare const UndoCommand: {
|
|
@@ -103,8 +112,12 @@ export declare class LocalUndoRedoService extends Disposable implements IUndoRed
|
|
|
103
112
|
protected readonly _undoStacks: Map<string, IUndoRedoItem[]>;
|
|
104
113
|
protected readonly _redoStacks: Map<string, IUndoRedoItem[]>;
|
|
105
114
|
private _batchingStatus;
|
|
106
|
-
|
|
115
|
+
private readonly _activeGroups;
|
|
116
|
+
private readonly _itemGroups;
|
|
117
|
+
private readonly _historyLimit;
|
|
118
|
+
constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _contextService: IContextService, configService: IConfigService);
|
|
107
119
|
pushUndoRedo(item: IUndoRedoItem): void;
|
|
120
|
+
beginUndoRedoGroup(unitId: string, groupId: string, mode?: 'replace' | 'append'): IDisposable;
|
|
108
121
|
clearUndoRedo(unitID: string): void;
|
|
109
122
|
pitchTopUndoElement(): Nullable<IUndoRedoItem>;
|
|
110
123
|
pitchTopRedoElement(): Nullable<IUndoRedoItem>;
|
|
@@ -34,7 +34,6 @@ export * from './max-row-column';
|
|
|
34
34
|
export type { INumfmtLocaleTag } from './numfmt';
|
|
35
35
|
export { currencySymbols, DEFAULT_NUMBER_FORMAT, DEFAULT_TEXT_FORMAT, DEFAULT_TEXT_FORMAT_EXCEL, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isTextFormat, numfmt, } from './numfmt';
|
|
36
36
|
export * from './object-matrix';
|
|
37
|
-
export { queryObjectMatrix } from './object-matrix-query';
|
|
38
37
|
export * from './random-id';
|
|
39
38
|
export { moveRangeByOffset, splitIntoGrid } from './range';
|
|
40
39
|
export * from './rectangle';
|
|
@@ -266,6 +266,8 @@ export interface IFontRenderExtension {
|
|
|
266
266
|
export interface ICellDataForSheetInterceptor extends ICellData {
|
|
267
267
|
interceptorStyle?: Nullable<IStyleData>;
|
|
268
268
|
isInArrayFormulaRange?: Nullable<boolean>;
|
|
269
|
+
/** Marks intercepted cell data prepared for percentage editing. */
|
|
270
|
+
isPercentFormat?: boolean;
|
|
269
271
|
markers?: ICellMarks;
|
|
270
272
|
customRender?: Nullable<ICellCustomRender[]>;
|
|
271
273
|
interceptorAutoHeight?: () => number | undefined;
|
|
@@ -111,6 +111,12 @@ export interface IDocStyles {
|
|
|
111
111
|
*/
|
|
112
112
|
export interface IDocumentBody {
|
|
113
113
|
dataStream: string;
|
|
114
|
+
/**
|
|
115
|
+
* UTF-16 offsets of soft page-break tokens (`\f`) produced by the layout engine that last
|
|
116
|
+
* saved the source document. Renderers may honor them for traditional/paginated fidelity;
|
|
117
|
+
* exporters must keep them soft rather than converting them to authored page breaks.
|
|
118
|
+
*/
|
|
119
|
+
renderedPageBreaks?: number[];
|
|
114
120
|
textRuns?: ITextRun[];
|
|
115
121
|
paragraphs?: IParagraph[];
|
|
116
122
|
sectionBreaks?: ISectionBreak[];
|
|
@@ -413,6 +419,10 @@ export interface IDocStyleBase extends IMargin {
|
|
|
413
419
|
export interface IDocumentLayout {
|
|
414
420
|
defaultTabStop?: number;
|
|
415
421
|
characterSpacingControl?: characterSpacingControlType;
|
|
422
|
+
/** Use the legacy East Asian Word layout rules stored as OOXML `useFELayout`. */
|
|
423
|
+
useFELayout?: BooleanNumber;
|
|
424
|
+
/** Align automatic line height inside tables to the active document line grid. */
|
|
425
|
+
adjustLineHeightInTable?: BooleanNumber;
|
|
416
426
|
paragraphLineGapDefault?: number;
|
|
417
427
|
spaceWidthEastAsian?: BooleanNumber;
|
|
418
428
|
autoHyphenation?: BooleanNumber;
|
|
@@ -566,6 +576,12 @@ export interface IDocDrawingBase extends IDrawingParam {
|
|
|
566
576
|
docTransform: IDocDrawingPosition;
|
|
567
577
|
layoutType: PositionedObjectLayoutType;
|
|
568
578
|
behindDoc?: BooleanNumber;
|
|
579
|
+
/** Keeps the anchor constrained to its containing table cell when enabled. */
|
|
580
|
+
layoutInCell?: BooleanNumber;
|
|
581
|
+
/** Allows this floating object to overlap other floating objects. */
|
|
582
|
+
allowOverlap?: BooleanNumber;
|
|
583
|
+
/** WordprocessingML stacking order for anchored objects. */
|
|
584
|
+
relativeHeight?: number;
|
|
569
585
|
start?: number[];
|
|
570
586
|
lineTo?: number[][];
|
|
571
587
|
wrapText?: WrapTextType;
|
|
@@ -726,6 +742,12 @@ export interface IParagraphProperties extends IIndentStart {
|
|
|
726
742
|
snapToGrid?: BooleanNumber;
|
|
727
743
|
spaceAbove?: INumberUnit;
|
|
728
744
|
spaceBelow?: INumberUnit;
|
|
745
|
+
/** Whether the layout engine should derive paragraph-before spacing from the active compatibility policy. */
|
|
746
|
+
beforeAutoSpacing?: BooleanNumber;
|
|
747
|
+
/** Whether the layout engine should derive paragraph-after spacing from the active compatibility policy. */
|
|
748
|
+
afterAutoSpacing?: BooleanNumber;
|
|
749
|
+
/** Suppresses spacing between consecutive paragraphs that share the same named style. */
|
|
750
|
+
contextualSpacing?: BooleanNumber;
|
|
729
751
|
borderBetween?: IParagraphBorder;
|
|
730
752
|
borderTop?: IParagraphBorder;
|
|
731
753
|
borderBottom?: IParagraphBorder;
|
|
@@ -837,6 +859,7 @@ export declare enum DashStyleType {
|
|
|
837
859
|
export interface ITabStop {
|
|
838
860
|
offset: number;
|
|
839
861
|
alignment: TabStopAlignment;
|
|
862
|
+
leader?: TabStopLeader;
|
|
840
863
|
}
|
|
841
864
|
/**
|
|
842
865
|
* The alignment of the tab stop.
|
|
@@ -847,6 +870,15 @@ export declare enum TabStopAlignment {
|
|
|
847
870
|
CENTER = 2,// The tab stop is aligned to the center of the line.
|
|
848
871
|
END = 3
|
|
849
872
|
}
|
|
873
|
+
export declare enum TabStopLeader {
|
|
874
|
+
TAB_STOP_LEADER_UNSPECIFIED = 0,
|
|
875
|
+
NONE = 1,
|
|
876
|
+
DOT = 2,
|
|
877
|
+
HYPHEN = 3,
|
|
878
|
+
UNDERSCORE = 4,
|
|
879
|
+
HEAVY = 5,
|
|
880
|
+
MIDDLE_DOT = 6
|
|
881
|
+
}
|
|
850
882
|
/**
|
|
851
883
|
* Properties of shading
|
|
852
884
|
*/
|
|
@@ -963,6 +995,10 @@ export interface ITableRow {
|
|
|
963
995
|
* corresponding `TABLE_ROW_START`/`TABLE_ROW_END` pair in `dataStream`.
|
|
964
996
|
*/
|
|
965
997
|
tableCells: ITableCell[];
|
|
998
|
+
/** Number of table-grid columns omitted before the first cell in this row. */
|
|
999
|
+
gridBefore?: number;
|
|
1000
|
+
/** Number of table-grid columns omitted after the last cell in this row. */
|
|
1001
|
+
gridAfter?: number;
|
|
966
1002
|
trHeight: ITableRowSize;
|
|
967
1003
|
cantSplit?: BooleanNumber;
|
|
968
1004
|
isFirstRow?: BooleanNumber;
|
|
@@ -213,6 +213,8 @@ export interface IStyleBase {
|
|
|
213
213
|
* fontFamily
|
|
214
214
|
*/
|
|
215
215
|
ff?: Nullable<string>;
|
|
216
|
+
/** Font family used for East Asian characters in rich text. */
|
|
217
|
+
eastAsiaFontFamily?: Nullable<string>;
|
|
216
218
|
/** Font size in points (pt), where 1 pt is 1/72 inch. */
|
|
217
219
|
fs?: number;
|
|
218
220
|
/**
|
|
@@ -301,7 +303,7 @@ export interface IStyleData extends IStyleBase {
|
|
|
301
303
|
/**
|
|
302
304
|
* Exact keys of {@link IStyleData}.
|
|
303
305
|
*/
|
|
304
|
-
export declare const STYLE_KEYS: readonly ["ff", "fs", "it", "bl", "ul", "bbl", "st", "ol", "bg", "bd", "cl", "va", "n", "stf", "tr", "td", "ht", "vt", "tb", "pd"];
|
|
306
|
+
export declare const STYLE_KEYS: readonly ["ff", "eastAsiaFontFamily", "fs", "it", "bl", "ul", "bbl", "st", "ol", "bg", "bd", "cl", "va", "n", "stf", "tr", "td", "ht", "vt", "tb", "pd"];
|
|
305
307
|
/**
|
|
306
308
|
* Key union of {@link IStyleData}.
|
|
307
309
|
*/
|
package/lib/types/univer.d.ts
CHANGED
|
@@ -59,6 +59,12 @@ export interface IUniverConfig {
|
|
|
59
59
|
* @default false
|
|
60
60
|
*/
|
|
61
61
|
logCommandExecution?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The maximum number of undoable command groups retained for each unit.
|
|
64
|
+
* Set to `0` to disable undo history.
|
|
65
|
+
* @default 50
|
|
66
|
+
*/
|
|
67
|
+
undoRedoHistoryLimit?: number;
|
|
62
68
|
/**
|
|
63
69
|
* The override dependencies of the Univer instance.
|
|
64
70
|
*/
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=class extends t.Disposable{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};let r=Symbol(`initializers`),i=Symbol(`manualInit`);var a=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[i])return;let t=this,n=Object.getPrototypeOf(this)[r];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[r];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[i]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[r];t||(t=[],this.prototype[r]=t),t.push(e.prototype._initialize)}else if(t!==`constructor`){let n=Object.getOwnPropertyDescriptor(e.prototype,t);n?Object.defineProperty(this.prototype,t,n):this.prototype[t]=e.prototype[t]}}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};function o(e,t){return function(n,r){t(n,r,e)}}function s(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var c;let l=c=class extends n{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(c,this._blob)}getAs(e){let t=this.copyBlob();return t.setContentType(e),t}getDataAsString(e){return this._blob===null?Promise.resolve(``):e===void 0?this._blob.text():new Promise((t,n)=>{this._blob.arrayBuffer().then(n=>{t(new TextDecoder(e).decode(n))}).catch(e=>{n(Error(`Failed to read Blob as ArrayBuffer: ${e.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(e=>new Uint8Array(e)):Promise.reject(Error(`Blob is undefined or null.`))}setBytes(e){return this._blob=new Blob([e.buffer]),this}setDataFromString(e,t){let n=new Blob([e],{type:t??`text/plain`});return this._blob=n,this}getContentType(){var e;return(e=this._blob)==null?void 0:e.type}setContentType(e){var t;return this._blob=(t=this._blob)==null?void 0:t.slice(0,this._blob.size,e),this}};l=c=s([o(1,(0,t.Inject)(t.Injector))],l);function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get AbsoluteRefType(){return t.AbsoluteRefType}get UniverInstanceType(){return t.UniverInstanceType}get LifecycleStages(){return t.LifecycleStages}get DataValidationType(){return t.DataValidationType}get DataValidationErrorStyle(){return t.DataValidationErrorStyle}get DataValidationRenderMode(){return t.DataValidationRenderMode}get DataValidationOperator(){return t.DataValidationOperator}get DataValidationStatus(){return t.DataValidationStatus}get CommandType(){return t.CommandType}get BaselineOffset(){return t.BaselineOffset}get BooleanNumber(){return t.BooleanNumber}get HorizontalAlign(){return t.HorizontalAlign}get SpacingRule(){return t.SpacingRule}get NumberUnitType(){return t.NumberUnitType}get PresetListType(){return t.PresetListType}get TextDecoration(){return t.TextDecoration}get TextDirection(){return t.TextDirection}get VerticalAlign(){return t.VerticalAlign}get WrapStrategy(){return t.WrapStrategy}get BorderType(){return t.BorderType}get BorderStyleTypes(){return t.BorderStyleTypes}get AutoFillSeries(){return t.AutoFillSeries}get ColorType(){return t.ColorType}get CommonHideTypes(){return t.CommonHideTypes}get CopyPasteType(){return t.CopyPasteType}get DeleteDirection(){return t.DeleteDirection}get DeveloperMetadataVisibility(){return t.DeveloperMetadataVisibility}get Dimension(){return t.Dimension}get Direction(){return t.Direction}get InterpolationPointType(){return t.InterpolationPointType}get LocaleType(){return t.LocaleType}get MentionType(){return t.MentionType}get ProtectionType(){return t.ProtectionType}get RelativeDate(){return t.RelativeDate}get SheetTypes(){return t.SheetTypes}get ThemeColorType(){return t.ThemeColorType}get ImageSourceType(){return t.ImageSourceType}};p(m,`_instance`,void 0);var h=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get DocCreated(){return`DocCreated`}get DocDisposed(){return`DocDisposed`}get LifeCycleChanged(){return`LifeCycleChanged`}get Redo(){return`Redo`}get Undo(){return`Undo`}get BeforeRedo(){return`BeforeRedo`}get BeforeUndo(){return`BeforeUndo`}get CommandExecuted(){return`CommandExecuted`}get BeforeCommandExecute(){return`BeforeCommandExecute`}};p(h,`_instance`,void 0);let g=class extends a{constructor(e,t){super(t),this.doc=e}};g=s([o(1,(0,t.Inject)(t.Injector))],g);var _=class{constructor(){p(this,`_eventRegistry`,new Map),p(this,`_eventHandlerMap`,new Map),p(this,`_eventHandlerRegisted`,new Map)}_ensureEventRegistry(e){return this._eventRegistry.has(e)||this._eventRegistry.set(e,new t.Registry),this._eventRegistry.get(e)}registerEventHandler(e,n){let r=this._eventHandlerMap.get(e);return r?r.add(n):this._eventHandlerMap.set(e,new Set([n])),this._ensureEventRegistry(e).getData().length&&this._initEventHandler(e),(0,t.toDisposable)(()=>{var t,r,i;(t=this._eventHandlerMap.get(e))==null||t.delete(n),(r=this._eventHandlerRegisted.get(e))==null||(r=r.get(n))==null||r.dispose(),(i=this._eventHandlerRegisted.get(e))==null||i.delete(n)})}removeEvent(e,t){let n=this._ensureEventRegistry(e);if(n.delete(t),n.getData().length===0){let t=this._eventHandlerRegisted.get(e);t==null||t.forEach(e=>e.dispose()),this._eventHandlerRegisted.delete(e)}}_initEventHandler(e){let n=this._eventHandlerRegisted.get(e),r=this._eventHandlerMap.get(e);r&&(!n||n.size===0)&&(n=new Map,this._eventHandlerRegisted.set(e,n),r==null||r.forEach(e=>{n==null||n.set(e,(0,t.toDisposable)(e()))}))}addEvent(e,n){return this._ensureEventRegistry(e).add(n),this._initEventHandler(e),(0,t.toDisposable)(()=>this.removeEvent(e,n))}fireEvent(e,t){var n;return(n=this._eventRegistry.get(e))==null||n.getData().forEach(e=>{e(t)}),t.cancel}};let v=class extends n{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};v=s([o(0,(0,t.Inject)(t.Injector)),o(1,(0,t.Inject)(t.UserManagerService))],v);var y=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}get rectangle(){return t.Rectangle}get numfmt(){return t.numfmt}get tools(){return t.Tools}};p(y,`_instance`,void 0);var b;let x=Symbol(`initializers`),S=b=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(b)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[x];t||(t=[],this.prototype[x]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,p(this,`_eventRegistry`,new _),p(this,`registerEventHandler`,(e,t)=>this._eventRegistry.registerEventHandler(e,t)),this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>(0,t.toDisposable)(this._lifecycleService.lifecycle$.subscribe(e=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:e})})))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});let a=Object.getPrototypeOf(this)[x];if(a){let t=this;a.forEach(function(n){n.apply(t,[e])})}}_initCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Redo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.Undo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Undo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted,()=>n.onCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};this.fireEvent(this.Event.CommandExecuted,e)}})))}_initBeforeCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeRedo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeUndo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>n.beforeCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};if(this.fireEvent(this.Event.BeforeCommandExecute,e),e.cancel)throw new t.CanceledError}})))}_initUnitEvent(e){let n=e.get(t.IUniverInstanceService);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>n.unitDisposed$.subscribe(e=>{e.type===t.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:e.getUnitId(),unitType:e.type,snapshot:e.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>n.unitAdded$.subscribe(n=>{let{unit:r}=n;if(r.type===t.UniverInstanceType.UNIVER_DOC){let t=r,n=e.createInstance(g,t);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:n,unit:n})}})))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(t.LifecycleService).stage}undo(){return this._commandService.executeCommand(t.UndoCommand.id)}redo(){return this._commandService.executeCommand(t.RedoCommand.id)}toggleDarkMode(e){this._injector.get(t.ThemeService).setDarkMode(e)}loadLocales(e,n){this._injector.get(t.LocaleService).load({[e]:n})}setLocale(e){this._injector.get(t.LocaleService).setLocale(e)}getCurrentLocale(){return this._injector.get(t.LocaleService).getCurrentLocale()}getLocales(){return this._injector.get(t.LocaleService).getLocales()}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}get Enum(){return m.get()}get Event(){return h.get()}get Util(){return y.get()}addEvent(e,t){if(!e||!t)throw Error(`Cannot add empty event`);return this._eventRegistry.addEvent(e,t)}fireEvent(e,t){return this._eventRegistry.fireEvent(e,t)}getUserManager(){return this._injector.createInstance(v)}newBlob(){return this._injector.createInstance(l,null)}newRichText(){return t.RichTextBuilder.create()}newRichTextFromDocumentData(e){return t.RichTextBuilder.create(e)}newRichTextValue(e){return t.RichTextValue.create(e)}newParagraphStyle(e){return t.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return t.ParagraphStyleValue.create(e)}newTextStyle(e){return t.TextStyleBuilder.create(e)}newTextStyleValue(e){return t.TextStyleValue.create(e)}newTextDecoration(e){return new t.TextDecorationBuilder(e)}};S=b=s([o(0,(0,t.Inject)(t.Injector)),o(1,t.ICommandService),o(2,t.IUniverInstanceService),o(3,(0,t.Inject)(t.LifecycleService))],S),e.FBase=n,e.FBaseInitialable=a,Object.defineProperty(e,"FBlob",{enumerable:!0,get:function(){return l}}),e.FEnum=m,e.FEventName=h,Object.defineProperty(e,"FUniver",{enumerable:!0,get:function(){return S}}),e.FUtil=y});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=class extends t.Disposable{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};let r=Symbol(`initializers`),i=Symbol(`manualInit`);var a=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[i])return;let t=this,n=Object.getPrototypeOf(this)[r];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[r];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[i]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[r];t||(t=[],this.prototype[r]=t),t.push(e.prototype._initialize)}else if(t!==`constructor`){let n=Object.getOwnPropertyDescriptor(e.prototype,t);n?Object.defineProperty(this.prototype,t,n):this.prototype[t]=e.prototype[t]}}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};function o(e,t){return function(n,r){t(n,r,e)}}function s(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var c;let l=c=class extends n{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(c,this._blob)}getAs(e){let t=this.copyBlob();return t.setContentType(e),t}getDataAsString(e){return this._blob===null?Promise.resolve(``):e===void 0?this._blob.text():new Promise((t,n)=>{this._blob.arrayBuffer().then(n=>{t(new TextDecoder(e).decode(n))}).catch(e=>{n(Error(`Failed to read Blob as ArrayBuffer: ${e.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(e=>new Uint8Array(e)):Promise.reject(Error(`Blob is undefined or null.`))}setBytes(e){return this._blob=new Blob([e.buffer]),this}setDataFromString(e,t){let n=new Blob([e],{type:t??`text/plain`});return this._blob=n,this}getContentType(){var e;return(e=this._blob)==null?void 0:e.type}setContentType(e){var t;return this._blob=(t=this._blob)==null?void 0:t.slice(0,this._blob.size,e),this}};l=c=s([o(1,(0,t.Inject)(t.Injector))],l);function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get AbsoluteRefType(){return t.AbsoluteRefType}get UniverInstanceType(){return t.UniverInstanceType}get LifecycleStages(){return t.LifecycleStages}get DataValidationType(){return t.DataValidationType}get DataValidationErrorStyle(){return t.DataValidationErrorStyle}get DataValidationRenderMode(){return t.DataValidationRenderMode}get DataValidationOperator(){return t.DataValidationOperator}get DataValidationStatus(){return t.DataValidationStatus}get CommandType(){return t.CommandType}get BaselineOffset(){return t.BaselineOffset}get BooleanNumber(){return t.BooleanNumber}get HorizontalAlign(){return t.HorizontalAlign}get SpacingRule(){return t.SpacingRule}get NumberUnitType(){return t.NumberUnitType}get PresetListType(){return t.PresetListType}get TextDecoration(){return t.TextDecoration}get TextDirection(){return t.TextDirection}get VerticalAlign(){return t.VerticalAlign}get WrapStrategy(){return t.WrapStrategy}get BorderType(){return t.BorderType}get BorderStyleTypes(){return t.BorderStyleTypes}get AutoFillSeries(){return t.AutoFillSeries}get ColorType(){return t.ColorType}get CommonHideTypes(){return t.CommonHideTypes}get CopyPasteType(){return t.CopyPasteType}get DeleteDirection(){return t.DeleteDirection}get DeveloperMetadataVisibility(){return t.DeveloperMetadataVisibility}get Dimension(){return t.Dimension}get Direction(){return t.Direction}get InterpolationPointType(){return t.InterpolationPointType}get LocaleType(){return t.LocaleType}get MentionType(){return t.MentionType}get ProtectionType(){return t.ProtectionType}get RelativeDate(){return t.RelativeDate}get SheetTypes(){return t.SheetTypes}get ThemeColorType(){return t.ThemeColorType}get ImageSourceType(){return t.ImageSourceType}};p(m,`_instance`,void 0);var h=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get DocCreated(){return`DocCreated`}get DocDisposed(){return`DocDisposed`}get LifeCycleChanged(){return`LifeCycleChanged`}get Redo(){return`Redo`}get Undo(){return`Undo`}get BeforeRedo(){return`BeforeRedo`}get BeforeUndo(){return`BeforeUndo`}get CommandExecuted(){return`CommandExecuted`}get BeforeCommandExecute(){return`BeforeCommandExecute`}};p(h,`_instance`,void 0);let g=class extends a{constructor(e,t){super(t),this.doc=e}};g=s([o(1,(0,t.Inject)(t.Injector))],g);var _=class{constructor(){p(this,`_eventRegistry`,new Map),p(this,`_eventHandlerMap`,new Map),p(this,`_eventHandlerRegisted`,new Map)}_ensureEventRegistry(e){return this._eventRegistry.has(e)||this._eventRegistry.set(e,new t.Registry),this._eventRegistry.get(e)}registerEventHandler(e,n){let r=this._eventHandlerMap.get(e);return r?r.add(n):this._eventHandlerMap.set(e,new Set([n])),this._ensureEventRegistry(e).getData().length&&this._initEventHandler(e),(0,t.toDisposable)(()=>{var t,r,i;(t=this._eventHandlerMap.get(e))==null||t.delete(n),(r=this._eventHandlerRegisted.get(e))==null||(r=r.get(n))==null||r.dispose(),(i=this._eventHandlerRegisted.get(e))==null||i.delete(n)})}removeEvent(e,t){let n=this._ensureEventRegistry(e);if(n.delete(t),n.getData().length===0){let t=this._eventHandlerRegisted.get(e);t==null||t.forEach(e=>e.dispose()),this._eventHandlerRegisted.delete(e)}}_initEventHandler(e){let n=this._eventHandlerRegisted.get(e),r=this._eventHandlerMap.get(e);r&&(!n||n.size===0)&&(n=new Map,this._eventHandlerRegisted.set(e,n),r==null||r.forEach(e=>{n==null||n.set(e,(0,t.toDisposable)(e()))}))}addEvent(e,n){return this._ensureEventRegistry(e).add(n),this._initEventHandler(e),(0,t.toDisposable)(()=>this.removeEvent(e,n))}fireEvent(e,t){var n;return(n=this._eventRegistry.get(e))==null||n.getData().forEach(e=>{e(t)}),t.cancel}};let v=class extends n{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};v=s([o(0,(0,t.Inject)(t.Injector)),o(1,(0,t.Inject)(t.UserManagerService))],v);var y=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}get rectangle(){return t.Rectangle}get numfmt(){return t.numfmt}get tools(){return t.Tools}};p(y,`_instance`,void 0);var b;let x=Symbol(`initializers`),S=b=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(b)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[x];t||(t=[],this.prototype[x]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,p(this,`_eventRegistry`,new _),p(this,`registerEventHandler`,(e,t)=>this._eventRegistry.registerEventHandler(e,t)),this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>(0,t.toDisposable)(this._lifecycleService.lifecycle$.subscribe(e=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:e})})))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});let a=Object.getPrototypeOf(this)[x];if(a){let t=this;a.forEach(function(n){n.apply(t,[e])})}}_initCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Redo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.Undo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Undo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted,()=>n.onCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};this.fireEvent(this.Event.CommandExecuted,e)}})))}_initBeforeCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeRedo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeUndo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>n.beforeCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};if(this.fireEvent(this.Event.BeforeCommandExecute,e),e.cancel)throw new t.CanceledError}})))}_initUnitEvent(e){let n=e.get(t.IUniverInstanceService);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>n.unitDisposed$.subscribe(e=>{e.type===t.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:e.getUnitId(),unitType:e.type,snapshot:e.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>n.unitAdded$.subscribe(n=>{let{unit:r}=n;if(r.type===t.UniverInstanceType.UNIVER_DOC){let t=r,n=e.createInstance(g,t);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:n,unit:n})}})))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(t.LifecycleService).stage}undo(){return this._commandService.executeCommand(t.UndoCommand.id)}redo(){return this._commandService.executeCommand(t.RedoCommand.id)}setTheme(e){this._injector.get(t.ThemeService).setTheme(e)}getCurrentTheme(){return this._injector.get(t.ThemeService).getCurrentTheme()}isDarkMode(){return this._injector.get(t.ThemeService).darkMode}toggleDarkMode(e){this._injector.get(t.ThemeService).setDarkMode(e)}loadLocales(e,n){this._injector.get(t.LocaleService).load({[e]:n})}setLocale(e){this._injector.get(t.LocaleService).setLocale(e)}getCurrentLocale(){return this._injector.get(t.LocaleService).getCurrentLocale()}getLocales(){return this._injector.get(t.LocaleService).getLocales()}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}get Enum(){return m.get()}get Event(){return h.get()}get Util(){return y.get()}addEvent(e,t){if(!e||!t)throw Error(`Cannot add empty event`);return this._eventRegistry.addEvent(e,t)}fireEvent(e,t){return this._eventRegistry.fireEvent(e,t)}getUserManager(){return this._injector.createInstance(v)}newBlob(){return this._injector.createInstance(l,null)}newRichText(){return t.RichTextBuilder.create()}newRichTextFromDocumentData(e){return t.RichTextBuilder.create(e)}newRichTextValue(e){return t.RichTextValue.create(e)}newParagraphStyle(e){return t.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return t.ParagraphStyleValue.create(e)}newTextStyle(e){return t.TextStyleBuilder.create(e)}newTextStyleValue(e){return t.TextStyleValue.create(e)}newTextDecoration(e){return new t.TextDecorationBuilder(e)}};S=b=s([o(0,(0,t.Inject)(t.Injector)),o(1,t.ICommandService),o(2,t.IUniverInstanceService),o(3,(0,t.Inject)(t.LifecycleService))],S),e.FBase=n,e.FBaseInitialable=a,Object.defineProperty(e,"FBlob",{enumerable:!0,get:function(){return l}}),e.FEnum=m,e.FEventName=h,Object.defineProperty(e,"FUniver",{enumerable:!0,get:function(){return S}}),e.FUtil=y});
|