@univerjs/core 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +15 -9
- package/lib/cjs/index.js +906 -694
- package/lib/es/facade.js +15 -9
- package/lib/es/index.js +897 -695
- package/lib/facade.js +15 -9
- package/lib/index.js +897 -695
- package/lib/types/common/url.d.ts +1 -0
- package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +3 -1
- package/lib/types/docs/data-model/text-x/utils.d.ts +3 -2
- package/lib/types/docs/data-model/types.d.ts +3 -0
- package/lib/types/facade/f-univer.d.ts +9 -3
- package/lib/types/index.d.ts +1 -1
- package/lib/types/shared/index.d.ts +1 -1
- package/lib/types/shared/numfmt.d.ts +2 -1
- package/lib/types/shared/tools.d.ts +5 -0
- package/lib/types/types/const/const.d.ts +3 -0
- package/lib/types/types/const/page-size.d.ts +7 -0
- package/lib/types/types/enum/locale-type.d.ts +8 -1
- package/lib/types/types/interfaces/i-document-data.d.ts +7 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +10 -9
- package/package.json +5 -5
- package/lib/types/shared/coder.d.ts +0 -17
|
@@ -22,4 +22,5 @@ export declare function normalizeUrl(urlStr: string): string;
|
|
|
22
22
|
* @param {string} baseURL - The base URL to use for resolution.
|
|
23
23
|
* @returns {string} - The resolved URL.
|
|
24
24
|
*/
|
|
25
|
+
export declare function isSafeUrl(url: string): boolean;
|
|
25
26
|
export declare function resolveWithBasePath(url: string, baseURL: string): string;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { ICustomBlock, ICustomDecoration, ICustomRange, ICustomTable, IDocumentBody, IParagraph, ISectionBreak, ITextRun } from '../../../../types/interfaces';
|
|
16
|
+
import type { ICustomBlock, ICustomDecoration, ICustomRange, ICustomTable, IDocumentBlockRange, IDocumentBody, IParagraph, ISectionBreak, ITextRun } from '../../../../types/interfaces';
|
|
17
17
|
export declare function normalizeTextRuns(textRuns: ITextRun[], reserveEmptyTextRun?: boolean): ITextRun[];
|
|
18
18
|
/**
|
|
19
19
|
* Inserting styled text content into the current document model.
|
|
@@ -35,6 +35,7 @@ export declare function insertParagraphs(body: IDocumentBody, insertBody: IDocum
|
|
|
35
35
|
export declare function insertSectionBreaks(body: IDocumentBody, insertBody: IDocumentBody, textLength: number, currentIndex: number): void;
|
|
36
36
|
export declare function insertCustomBlocks(body: IDocumentBody, insertBody: IDocumentBody, textLength: number, currentIndex: number): void;
|
|
37
37
|
export declare function insertTables(body: IDocumentBody, insertBody: IDocumentBody, textLength: number, currentIndex: number): void;
|
|
38
|
+
export declare function insertBlockRanges(body: IDocumentBody, insertBody: IDocumentBody, textLength: number, currentIndex: number): void;
|
|
38
39
|
export declare function sliceByParagraph(body: IDocumentBody): IDocumentBody[];
|
|
39
40
|
export declare function mergeContinuousRanges(ranges: ICustomRange[]): ICustomRange[];
|
|
40
41
|
export declare function splitCustomRangesByIndex(customRanges: ICustomRange[], currentIndex: number): void;
|
|
@@ -49,4 +50,5 @@ export declare function deleteSectionBreaks(body: IDocumentBody, textLength: num
|
|
|
49
50
|
export declare function deleteCustomBlocks(body: IDocumentBody, textLength: number, currentIndex: number): ICustomBlock[];
|
|
50
51
|
export declare function deleteTables(body: IDocumentBody, textLength: number, currentIndex: number): ICustomTable[];
|
|
51
52
|
export declare function deleteCustomRanges(body: IDocumentBody, textLength: number, currentIndex: number): ICustomRange<Record<string, any>>[];
|
|
53
|
+
export declare function deleteBlockRanges(body: IDocumentBody, textLength: number, currentIndex: number): IDocumentBlockRange[];
|
|
52
54
|
export declare function deleteCustomDecorations(body: IDocumentBody, textLength: number, currentIndex: number, needOffset?: boolean): ICustomDecoration[];
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { ICustomDecoration, IDocumentBody, ITextRun } from '../../../types/interfaces/i-document-data';
|
|
16
|
+
import type { ICustomDecoration, IDocumentBlockRange, IDocumentBody, ITextRun } from '../../../types/interfaces/i-document-data';
|
|
17
17
|
import type { IRetainAction } from './action-types';
|
|
18
18
|
import { UpdateDocsAttributeType } from '../../../shared/command-enum';
|
|
19
19
|
export declare enum SliceBodyType {
|
|
@@ -26,7 +26,8 @@ export declare function getTableSlice(body: IDocumentBody, startOffset: number,
|
|
|
26
26
|
endIndex: number;
|
|
27
27
|
tableId: string;
|
|
28
28
|
}[];
|
|
29
|
-
export declare function
|
|
29
|
+
export declare function getBlockRangeSlice(body: IDocumentBody, startOffset: number, endOffset: number): IDocumentBlockRange[];
|
|
30
|
+
export declare function getParagraphsSlice(body: IDocumentBody, startOffset: number, endOffset: number, type?: SliceBodyType): {
|
|
30
31
|
startIndex: number;
|
|
31
32
|
paragraphStyle?: import("../../..").IParagraphStyle;
|
|
32
33
|
bullet?: import("../../..").IBullet;
|
|
@@ -19,6 +19,7 @@ export declare enum DataStreamTreeNodeType {
|
|
|
19
19
|
TABLE = "TABLE",
|
|
20
20
|
TABLE_ROW = "TABLE_ROW",
|
|
21
21
|
TABLE_CELL = "TABLE_CELL",
|
|
22
|
+
BLOCK = "BLOCK",
|
|
22
23
|
CUSTOM_BLOCK = "CUSTOM_BLOCK"
|
|
23
24
|
}
|
|
24
25
|
export declare enum DataStreamTreeTokenType {
|
|
@@ -30,6 +31,8 @@ export declare enum DataStreamTreeTokenType {
|
|
|
30
31
|
TABLE_CELL_END = "\u001D",// table cell end
|
|
31
32
|
TABLE_ROW_END = "\u000E",// table row end
|
|
32
33
|
TABLE_END = "\u000F",// table end
|
|
34
|
+
BLOCK_START = "\u0010",// block start
|
|
35
|
+
BLOCK_END = "\u0011",// block end
|
|
33
36
|
/**
|
|
34
37
|
* @deprecated
|
|
35
38
|
*/
|
|
@@ -244,7 +244,9 @@ export declare class FUniver extends Disposable {
|
|
|
244
244
|
* @example
|
|
245
245
|
* ```ts
|
|
246
246
|
* const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
|
|
247
|
-
* const
|
|
247
|
+
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
248
|
+
* if (!fWorksheet) return;
|
|
249
|
+
* const range = fWorksheet.getRange('A1');
|
|
248
250
|
* range.setRichTextValueForCell(richText);
|
|
249
251
|
* ```
|
|
250
252
|
*/
|
|
@@ -256,7 +258,9 @@ export declare class FUniver extends Disposable {
|
|
|
256
258
|
* @example
|
|
257
259
|
* ```ts
|
|
258
260
|
* const richTextValue = univerAPI.newRichTextValue({ body: { dataStream: 'Hello World\r\n' } });
|
|
259
|
-
* const
|
|
261
|
+
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
262
|
+
* if (!fWorksheet) return;
|
|
263
|
+
* const range = fWorksheet.getRange('A1');
|
|
260
264
|
* range.setRichTextValueForCell(richTextValue);
|
|
261
265
|
* ```
|
|
262
266
|
*/
|
|
@@ -270,7 +274,9 @@ export declare class FUniver extends Disposable {
|
|
|
270
274
|
* const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
|
|
271
275
|
* const paragraphStyle = univerAPI.newParagraphStyle({ textStyle: { ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE } });
|
|
272
276
|
* richText.insertParagraph(paragraphStyle);
|
|
273
|
-
* const
|
|
277
|
+
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
278
|
+
* if (!fWorksheet) return;
|
|
279
|
+
* const range = fWorksheet.getRange('A1');
|
|
274
280
|
* range.setRichTextValueForCell(richText);
|
|
275
281
|
* ```
|
|
276
282
|
*/
|
package/lib/types/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export { requestImmediateMacroTask } from './common/request-immediate-macro-task
|
|
|
36
36
|
export { type ISequenceExecuteResult, sequence, sequenceAsync } from './common/sequence';
|
|
37
37
|
export { mergeSets } from './common/set';
|
|
38
38
|
export { UnitModel, UniverInstanceType } from './common/unit';
|
|
39
|
-
export { resolveWithBasePath } from './common/url';
|
|
39
|
+
export { isSafeUrl, normalizeUrl, resolveWithBasePath } from './common/url';
|
|
40
40
|
export * from './docs/data-model';
|
|
41
41
|
export { JSON1, JSONX } from './docs/data-model/json-x/json-x';
|
|
42
42
|
export type { JSONXActions, JSONXPath } from './docs/data-model/json-x/json-x';
|
|
@@ -32,7 +32,7 @@ export * from './locale';
|
|
|
32
32
|
export { LRUHelper, LRUMap } from './lru/lru-map';
|
|
33
33
|
export * from './max-row-column';
|
|
34
34
|
export type { INumfmtLocaleTag } from './numfmt';
|
|
35
|
-
export { DEFAULT_NUMBER_FORMAT, DEFAULT_TEXT_FORMAT, DEFAULT_TEXT_FORMAT_EXCEL, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isTextFormat, numfmt, } from './numfmt';
|
|
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
37
|
export { queryObjectMatrix } from './object-matrix-query';
|
|
38
38
|
export { moveRangeByOffset, splitIntoGrid } from './range';
|
|
@@ -20,13 +20,14 @@ export declare const DEFAULT_TEXT_FORMAT_EXCEL = "@";
|
|
|
20
20
|
export declare const DEFAULT_NUMBER_FORMAT = "General";
|
|
21
21
|
export declare function isTextFormat(pattern: string | undefined): pattern is "@@@" | "@";
|
|
22
22
|
export declare function isDefaultFormat(pattern?: string | null): pattern is "General" | null | undefined;
|
|
23
|
-
export type INumfmtLocaleTag = 'zh-CN' | 'zh-TW' | 'cs' | 'da' | 'nl' | 'en' | 'fi' | 'fr' | 'de' | 'el' | 'hu' | 'is' | 'id' | 'it' | 'ja' | 'ko' | 'nb' | 'pl' | 'pt' | 'ru' | 'sk' | 'es' | 'sv' | 'th' | 'tr' | 'vi';
|
|
23
|
+
export type INumfmtLocaleTag = 'zh-CN' | 'zh-TW' | 'zh-HK' | 'ar' | 'cs' | 'da' | 'nl' | 'en' | 'fi' | 'fr' | 'de' | 'el' | 'hu' | 'is' | 'id' | 'it' | 'ja' | 'ko' | 'nb' | 'pl' | 'pt' | 'ru' | 'sk' | 'es' | 'sv' | 'th' | 'tr' | 'vi';
|
|
24
24
|
/**
|
|
25
25
|
* Determines whether two patterns are equal, excluding differences in decimal places.
|
|
26
26
|
* This function ignores the decimal part of the patterns and the positive color will be ignored but negative color will be considered.
|
|
27
27
|
* more info can check the test case.
|
|
28
28
|
*/
|
|
29
29
|
export declare const isPatternEqualWithoutDecimal: (patternA: string, patternB: string) => boolean;
|
|
30
|
+
export declare const currencySymbols: string[];
|
|
30
31
|
/**
|
|
31
32
|
* Get the numfmt parse value, and filter out the parse error.
|
|
32
33
|
*/
|
|
@@ -92,3 +92,8 @@ export declare const isNodeEnv: () => boolean;
|
|
|
92
92
|
* @returns {RegExp} The generated regular expression
|
|
93
93
|
*/
|
|
94
94
|
export declare function createREGEXFromWildChar(wildChar: string): RegExp;
|
|
95
|
+
/**
|
|
96
|
+
* Escapes characters that have special meaning in a regular expression so the
|
|
97
|
+
* returned string can be safely embedded in a RegExp pattern as literal text.
|
|
98
|
+
*/
|
|
99
|
+
export declare function escapeRegExp(str: string): string;
|
|
@@ -157,6 +157,9 @@ export declare const DEFAULT_STYLES: {
|
|
|
157
157
|
};
|
|
158
158
|
export declare const SHEET_EDITOR_UNITS: string[];
|
|
159
159
|
export declare const NAMED_STYLE_MAP: Record<NamedStyleType, Nullable<ITextStyle>>;
|
|
160
|
+
export declare const DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING = 1.5;
|
|
161
|
+
export declare const DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE = 0;
|
|
162
|
+
export declare const DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW = 8;
|
|
160
163
|
export declare const NAMED_STYLE_SPACE_MAP: Record<NamedStyleType, Nullable<IParagraphStyle>>;
|
|
161
164
|
export declare const PRINT_CHART_COMPONENT_KEY = "univer-sheets-chart-print-chart";
|
|
162
165
|
export declare const DOC_DRAWING_PRINTING_COMPONENT_KEY = "univer-docs-drawing-printing";
|
|
@@ -16,3 +16,10 @@
|
|
|
16
16
|
import type { ISize } from '../../shared';
|
|
17
17
|
import { PaperType } from '../interfaces';
|
|
18
18
|
export declare const PAGE_SIZE: Record<PaperType, Required<ISize>>;
|
|
19
|
+
export declare enum ModernDocumentWidthMode {
|
|
20
|
+
NARROW = "narrow",
|
|
21
|
+
MEDIUM = "medium",
|
|
22
|
+
WIDE = "wide"
|
|
23
|
+
}
|
|
24
|
+
export declare const MODERN_DOCUMENT_WIDTH: Record<ModernDocumentWidthMode, number>;
|
|
25
|
+
export declare const MODERN_DOCUMENT_DEFAULT_MARGIN: number;
|
|
@@ -22,11 +22,18 @@ export declare enum LocaleType {
|
|
|
22
22
|
ZH_CN = "zhCN",
|
|
23
23
|
RU_RU = "ruRU",
|
|
24
24
|
ZH_TW = "zhTW",
|
|
25
|
+
ZH_HK = "zhHK",
|
|
25
26
|
VI_VN = "viVN",
|
|
26
27
|
FA_IR = "faIR",
|
|
27
28
|
JA_JP = "jaJP",
|
|
28
29
|
KO_KR = "koKR",
|
|
29
30
|
ES_ES = "esES",
|
|
30
31
|
CA_ES = "caES",
|
|
31
|
-
SK_SK = "skSK"
|
|
32
|
+
SK_SK = "skSK",
|
|
33
|
+
PT_BR = "ptBR",
|
|
34
|
+
DE_DE = "deDE",
|
|
35
|
+
IT_IT = "itIT",
|
|
36
|
+
ID_ID = "idID",
|
|
37
|
+
PL_PL = "plPL",
|
|
38
|
+
AR_SA = "arSA"
|
|
32
39
|
}
|
|
@@ -116,6 +116,7 @@ export interface IDocumentBody {
|
|
|
116
116
|
sectionBreaks?: ISectionBreak[];
|
|
117
117
|
customBlocks?: ICustomBlock[];
|
|
118
118
|
tables?: ICustomTable[];
|
|
119
|
+
blockRanges?: IDocumentBlockRange[];
|
|
119
120
|
customRanges?: ICustomRange[];
|
|
120
121
|
customDecorations?: ICustomDecoration[];
|
|
121
122
|
/**
|
|
@@ -302,6 +303,12 @@ export type IHyperLinkCustomRange = ICustomRange<{
|
|
|
302
303
|
url: string;
|
|
303
304
|
}>;
|
|
304
305
|
export type IMentionCustomRange = ICustomRange<IMention>;
|
|
306
|
+
export interface IDocumentBlockRange {
|
|
307
|
+
startIndex: number;
|
|
308
|
+
endIndex: number;
|
|
309
|
+
blockId: string;
|
|
310
|
+
blockType: string;
|
|
311
|
+
}
|
|
305
312
|
export declare enum CustomRangeType {
|
|
306
313
|
HYPERLINK = 0,
|
|
307
314
|
FIELD = 1,// 17.16 Fields and Hyperlinks
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=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 i=Symbol(`initializers`),a=Symbol(`manualInit`);var o=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[a])return;let t=this,n=Object.getPrototypeOf(this)[i];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[i];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[a]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[i];t||(t=[],this.prototype[i]=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])})}};function s(e,t){return function(n,r){t(n,r,e)}}function c(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 l;let u=l=class extends r{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(l,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==null?`text/plain`:t});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}};u=l=c([s(1,(0,t.Inject)(t.Injector))],u);function d(e){"@babel/helpers - typeof";return d=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},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}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 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 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}};m(h,`_instance`,void 0);var g=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`}};m(g,`_instance`,void 0);let _=class extends r{constructor(e,t){super(),this._injector=e,this._lifecycleService=t}onStarting(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Starting)).subscribe(e))}onReady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Ready)).subscribe(e))}onRendered(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Rendered)).subscribe(e))}onSteady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Steady)).subscribe(e))}onBeforeUndo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onUndo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onBeforeRedo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}onRedo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}};_=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.LifecycleService))],_);let v=class extends o{constructor(e,t){super(t),this.doc=e}};v=c([s(1,(0,t.Inject)(t.Injector))],v);var y=class{constructor(){m(this,`_eventRegistry`,new Map),m(this,`_eventHandlerMap`,new Map),m(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 b=class extends r{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};b=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.UserManagerService))],b);var x=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}};m(x,`_instance`,void 0);var S;let C=Symbol(`initializers`),w=S=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(S)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[C];t||(t=[],this.prototype[C]=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,m(this,`_eventRegistry`,new y),m(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)[C];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(v,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)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((t,n)=>{e(t,n)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((t,n)=>{e(t,n)})}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}getHooks(){return this._injector.createInstance(_)}get Enum(){return h.get()}get Event(){return g.get()}get Util(){return x.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(b)}newBlob(){return this._injector.createInstance(u,null)}newRichText(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)}};w=S=c([s(0,(0,t.Inject)(t.Injector)),s(1,t.ICommandService),s(2,t.IUniverInstanceService),s(3,(0,t.Inject)(t.LifecycleService))],w),e.FBase=r,e.FBaseInitialable=o,Object.defineProperty(e,`FBlob`,{enumerable:!0,get:function(){return u}}),e.FEnum=h,e.FEventName=g,Object.defineProperty(e,`FHooks`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,`FUniver`,{enumerable:!0,get:function(){return w}}),e.FUtil=x});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=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 i=Symbol(`initializers`),a=Symbol(`manualInit`);var o=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[a])return;let t=this,n=Object.getPrototypeOf(this)[i];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[i];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[a]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[i];t||(t=[],this.prototype[i]=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])})}};function s(e,t){return function(n,r){t(n,r,e)}}function c(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 l;let u=l=class extends r{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(l,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==null?`text/plain`:t});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}};u=l=c([s(1,(0,t.Inject)(t.Injector))],u);function d(e){"@babel/helpers - typeof";return d=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},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}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 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 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}};m(h,`_instance`,void 0);var g=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`}};m(g,`_instance`,void 0);let _=class extends r{constructor(e,t){super(),this._injector=e,this._lifecycleService=t}onStarting(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Starting)).subscribe(e))}onReady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Ready)).subscribe(e))}onRendered(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Rendered)).subscribe(e))}onSteady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Steady)).subscribe(e))}onBeforeUndo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onUndo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onBeforeRedo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}onRedo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}};_=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.LifecycleService))],_);let v=class extends o{constructor(e,t){super(t),this.doc=e}};v=c([s(1,(0,t.Inject)(t.Injector))],v);var y=class{constructor(){m(this,`_eventRegistry`,new Map),m(this,`_eventHandlerMap`,new Map),m(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 b=class extends r{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};b=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.UserManagerService))],b);var x=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}};m(x,`_instance`,void 0);var S;let C=Symbol(`initializers`),w=S=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(S)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[C];t||(t=[],this.prototype[C]=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,m(this,`_eventRegistry`,new y),m(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)[C];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(v,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)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((t,n)=>{e(t,n)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((t,n)=>{e(t,n)})}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}getHooks(){return this._injector.createInstance(_)}get Enum(){return h.get()}get Event(){return g.get()}get Util(){return x.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(b)}newBlob(){return this._injector.createInstance(u,null)}newRichText(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)}};w=S=c([s(0,(0,t.Inject)(t.Injector)),s(1,t.ICommandService),s(2,t.IUniverInstanceService),s(3,(0,t.Inject)(t.LifecycleService))],w),e.FBase=r,e.FBaseInitialable=o,Object.defineProperty(e,"FBlob",{enumerable:!0,get:function(){return u}}),e.FEnum=h,e.FEventName=g,Object.defineProperty(e,"FHooks",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"FUniver",{enumerable:!0,get:function(){return w}}),e.FUtil=x});
|