@univerjs/core 1.0.0-alpha.6 → 1.0.0-alpha.8
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 +6 -138
- package/lib/cjs/index.js +379 -510
- package/lib/es/facade.js +8 -134
- package/lib/es/index.js +372 -508
- package/lib/facade.js +8 -134
- package/lib/index.js +372 -508
- package/lib/types/bases/index.d.ts +1 -1
- package/lib/types/bases/typedef.d.ts +31 -0
- package/lib/types/docs/data-model/paragraph-style.d.ts +7 -1
- package/lib/types/docs/data-model/rich-text-builder.d.ts +11 -1
- package/lib/types/docs/data-model/text-x/build-utils/data-stream-change.d.ts +3 -3
- package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/utils.d.ts +1 -0
- package/lib/types/docs/data-model/types.d.ts +0 -2
- package/lib/types/facade/f-univer.d.ts +1 -22
- package/lib/types/facade/index.d.ts +0 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/services/context/context.d.ts +1 -2
- package/lib/types/services/instance/instance.service.d.ts +0 -8
- package/lib/types/services/region/region.service.d.ts +28 -0
- package/lib/types/shared/common.d.ts +0 -5
- package/lib/types/shared/object-matrix.d.ts +0 -14
- package/lib/types/shared/rectangle.d.ts +0 -15
- package/lib/types/shared/tools.d.ts +0 -2
- package/lib/types/sheets/sheet-skeleton.d.ts +2 -6
- package/lib/types/sheets/typedef.d.ts +0 -14
- package/lib/types/sheets/workbook.d.ts +0 -2
- package/lib/types/sheets/worksheet.d.ts +0 -6
- package/lib/types/types/const/page-size.d.ts +2 -0
- package/lib/types/types/enum/theme-color-type.d.ts +0 -4
- package/lib/types/types/interfaces/i-cell-custom-render.d.ts +0 -2
- package/lib/types/types/interfaces/i-document-data-interceptor.d.ts +2 -0
- package/lib/types/types/interfaces/i-document-data.d.ts +93 -12
- package/lib/types/types/interfaces/i-style-data.d.ts +43 -0
- package/lib/types/univer.d.ts +5 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +21 -21
- package/package.json +4 -4
- package/lib/types/facade/f-hooks.d.ts +0 -74
|
@@ -19,7 +19,7 @@ import type { ISize } from '../../shared/shape';
|
|
|
19
19
|
import type { BooleanNumber, CellValueType, HorizontalAlign, LocaleType, TextDirection, VerticalAlign, WrapStrategy } from '../enum';
|
|
20
20
|
import type { IDrawingParam } from './i-drawing';
|
|
21
21
|
import type { IMention } from './i-mention';
|
|
22
|
-
import type { IColorStyle, IStyleBase } from './i-style-data';
|
|
22
|
+
import type { IColorStyle, IGlowEffect, IShadowEffect, IStyleBase } from './i-style-data';
|
|
23
23
|
/**
|
|
24
24
|
* Properties of document
|
|
25
25
|
*/
|
|
@@ -32,6 +32,8 @@ export interface IDocumentData extends IReferenceSource {
|
|
|
32
32
|
title?: string;
|
|
33
33
|
body?: IDocumentBody;
|
|
34
34
|
documentStyle: IDocumentStyle;
|
|
35
|
+
/** OOXML-compatible named document styles keyed by stable style id. */
|
|
36
|
+
styles?: IDocStyles;
|
|
35
37
|
settings?: IDocumentSettings;
|
|
36
38
|
resources?: IResources;
|
|
37
39
|
disabled?: boolean;
|
|
@@ -137,10 +139,11 @@ export declare enum DocumentBlockType {
|
|
|
137
139
|
}
|
|
138
140
|
export interface IDocStyle {
|
|
139
141
|
name: string;
|
|
140
|
-
basedOn
|
|
141
|
-
link
|
|
142
|
+
basedOn?: string;
|
|
143
|
+
link?: string;
|
|
142
144
|
type: DocStyleType;
|
|
143
|
-
textStyle
|
|
145
|
+
textStyle?: ITextStyle;
|
|
146
|
+
paragraphStyle?: IParagraphStyle;
|
|
144
147
|
}
|
|
145
148
|
export declare enum DocStyleType {
|
|
146
149
|
character = 0,
|
|
@@ -270,9 +273,13 @@ export declare enum BulletAlignment {
|
|
|
270
273
|
BOTH = 4
|
|
271
274
|
}
|
|
272
275
|
export interface IMargin {
|
|
276
|
+
/** Top page margin in 96-DPI layout pixels. */
|
|
273
277
|
marginTop?: number;
|
|
278
|
+
/** Bottom page margin in 96-DPI layout pixels. */
|
|
274
279
|
marginBottom?: number;
|
|
280
|
+
/** Right page margin in 96-DPI layout pixels. */
|
|
275
281
|
marginRight?: number;
|
|
282
|
+
/** Left page margin in 96-DPI layout pixels. */
|
|
276
283
|
marginLeft?: number;
|
|
277
284
|
}
|
|
278
285
|
export interface ITableOfContent {
|
|
@@ -341,6 +348,10 @@ export declare enum CustomRangeType {
|
|
|
341
348
|
UNI_FORMULA = 7,
|
|
342
349
|
DELTED = 9999
|
|
343
350
|
}
|
|
351
|
+
export declare enum DocxBreakType {
|
|
352
|
+
COLUMN = "column",
|
|
353
|
+
TEXT_WRAPPING = "textWrapping"
|
|
354
|
+
}
|
|
344
355
|
/**
|
|
345
356
|
* Custom Block
|
|
346
357
|
*/
|
|
@@ -389,12 +400,13 @@ export declare enum DocumentFlavor {
|
|
|
389
400
|
*/
|
|
390
401
|
export interface IDocStyleBase extends IMargin {
|
|
391
402
|
pageNumberStart?: number;
|
|
403
|
+
/** Page size in 96-DPI layout pixels. */
|
|
392
404
|
pageSize?: ISize;
|
|
393
405
|
pageOrient?: PageOrientType;
|
|
394
406
|
documentFlavor?: DocumentFlavor;
|
|
395
|
-
/** Distance from the page edge to the header, in
|
|
407
|
+
/** Distance from the page edge to the header, in 96-DPI layout pixels. */
|
|
396
408
|
marginHeader?: number;
|
|
397
|
-
/** Distance from the page edge to the footer, in
|
|
409
|
+
/** Distance from the page edge to the footer, in 96-DPI layout pixels. */
|
|
398
410
|
marginFooter?: number;
|
|
399
411
|
renderConfig?: IDocumentRenderConfig;
|
|
400
412
|
}
|
|
@@ -474,9 +486,10 @@ export interface ISectionBreak extends IDocStyleBase, ISectionBreakBase, IHeader
|
|
|
474
486
|
export declare enum SectionType {
|
|
475
487
|
SECTION_TYPE_UNSPECIFIED = 0,// The section type is unspecified.
|
|
476
488
|
CONTINUOUS = 1,// The section starts immediately after the last paragraph of the previous section.
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
489
|
+
NEXT_COLUMN = 2,// The section starts in the next column, or on the next page when no column remains.
|
|
490
|
+
NEXT_PAGE = 3,// The section starts on the next page.
|
|
491
|
+
EVEN_PAGE = 4,// The section starts on the next even-numbered page.
|
|
492
|
+
ODD_PAGE = 5
|
|
480
493
|
}
|
|
481
494
|
/**
|
|
482
495
|
* The style of column separators between columns.
|
|
@@ -498,14 +511,16 @@ export declare enum TextDirectionType {
|
|
|
498
511
|
* Properties of section column
|
|
499
512
|
*/
|
|
500
513
|
export interface ISectionColumnProperties {
|
|
501
|
-
/** Column width in
|
|
514
|
+
/** Column width in 96-DPI layout pixels. */
|
|
502
515
|
width: number;
|
|
503
|
-
/** Trailing space after the column in
|
|
516
|
+
/** Trailing space after the column in 96-DPI layout pixels. */
|
|
504
517
|
paddingEnd: number;
|
|
505
518
|
}
|
|
506
519
|
export interface IParagraph {
|
|
507
520
|
startIndex: number;
|
|
508
521
|
paragraphId: string;
|
|
522
|
+
/** Optional stable named-style reference. Direct paragraph style has higher precedence. */
|
|
523
|
+
styleId?: string;
|
|
509
524
|
paragraphStyle?: IParagraphStyle;
|
|
510
525
|
bullet?: IBullet;
|
|
511
526
|
}
|
|
@@ -565,15 +580,25 @@ export declare enum WrapTextType {
|
|
|
565
580
|
LARGEST = 3
|
|
566
581
|
}
|
|
567
582
|
/**
|
|
568
|
-
*
|
|
583
|
+
* Controls how a positioned object participates in document text layout.
|
|
584
|
+
*
|
|
585
|
+
* `WRAP_NONE` does not by itself determine whether the object is in front of or behind text. Drawing data uses
|
|
586
|
+
* `behindDoc` for that stacking choice.
|
|
569
587
|
*/
|
|
570
588
|
export declare enum PositionedObjectLayoutType {
|
|
589
|
+
/** Places the object in the text flow like a character and lets it affect the containing line's metrics. */
|
|
571
590
|
INLINE = 0,
|
|
591
|
+
/** Floats the object without reflowing text. The object and text can overlap. */
|
|
572
592
|
WRAP_NONE = 1,
|
|
593
|
+
/** Floats the object and wraps text around the custom polygon defined by its wrap path. */
|
|
573
594
|
WRAP_POLYGON = 2,
|
|
595
|
+
/** Floats the object and wraps text around its rectangular bounds. */
|
|
574
596
|
WRAP_SQUARE = 3,
|
|
597
|
+
/** Floats the object and allows text to flow through eligible open regions in its wrap contour. */
|
|
575
598
|
WRAP_THROUGH = 4,
|
|
599
|
+
/** Floats the object and wraps text closely around its contour instead of its rectangular bounds. */
|
|
576
600
|
WRAP_TIGHT = 5,
|
|
601
|
+
/** Floats the object in a horizontal band, leaving text only above and below it. */
|
|
577
602
|
WRAP_TOP_AND_BOTTOM = 6
|
|
578
603
|
}
|
|
579
604
|
/**
|
|
@@ -638,6 +663,20 @@ export interface ITextStyle extends IStyleBase {
|
|
|
638
663
|
pos?: number;
|
|
639
664
|
sa?: number;
|
|
640
665
|
textFill?: IDocTextFill;
|
|
666
|
+
/**
|
|
667
|
+
* DrawingML-style glow around the rendered glyphs.
|
|
668
|
+
*
|
|
669
|
+
* This is primarily intended for embedded rich text such as Shape text. A standalone document product may
|
|
670
|
+
* preserve and render the value without exposing dedicated authoring controls.
|
|
671
|
+
*/
|
|
672
|
+
glow?: IGlowEffect;
|
|
673
|
+
/**
|
|
674
|
+
* DrawingML-style outer shadow around the rendered glyphs.
|
|
675
|
+
*
|
|
676
|
+
* This is primarily intended for embedded rich text such as Shape text. A standalone document product may
|
|
677
|
+
* preserve and render the value without exposing dedicated authoring controls.
|
|
678
|
+
*/
|
|
679
|
+
outerShadow?: IShadowEffect;
|
|
641
680
|
}
|
|
642
681
|
export interface IIndentStart {
|
|
643
682
|
indentFirstLine?: INumberUnit;
|
|
@@ -672,9 +711,51 @@ export interface IParagraphProperties extends IIndentStart {
|
|
|
672
711
|
borderBottom?: IParagraphBorder;
|
|
673
712
|
borderLeft?: IParagraphBorder;
|
|
674
713
|
borderRight?: IParagraphBorder;
|
|
714
|
+
/**
|
|
715
|
+
* Keeps all measured lines of this paragraph on one physical page when they fit.
|
|
716
|
+
*
|
|
717
|
+
* `undefined` inherits, `TRUE` enables, and an explicit `FALSE` disables an
|
|
718
|
+
* inherited value. An oversized paragraph still splits after starting on a
|
|
719
|
+
* fresh page. This Word-compatible pagination rule is rendered only by
|
|
720
|
+
* Traditional Docs.
|
|
721
|
+
*
|
|
722
|
+
* OOXML: 17.3.1.14 `keepLines`.
|
|
723
|
+
*/
|
|
675
724
|
keepLines?: BooleanNumber;
|
|
725
|
+
/**
|
|
726
|
+
* Keeps this paragraph with the following paragraph when they fit together.
|
|
727
|
+
*
|
|
728
|
+
* Consecutive `TRUE` values form a bounded keep chain. Set the final
|
|
729
|
+
* paragraph to `FALSE` when it must terminate an inherited or authored chain.
|
|
730
|
+
* `undefined` inherits. This Word-compatible pagination rule is rendered only
|
|
731
|
+
* by Traditional Docs.
|
|
732
|
+
*
|
|
733
|
+
* OOXML: 17.3.1.15 `keepNext`.
|
|
734
|
+
*/
|
|
676
735
|
keepNext?: BooleanNumber;
|
|
736
|
+
/**
|
|
737
|
+
* Starts this paragraph on the next physical page unless it is already at a
|
|
738
|
+
* page boundary.
|
|
739
|
+
*
|
|
740
|
+
* `undefined` inherits, `TRUE` enables, and an explicit `FALSE` disables an
|
|
741
|
+
* inherited value. Use a Section Break instead when the following content
|
|
742
|
+
* also needs different page geometry, columns, headers, or footers. This
|
|
743
|
+
* Word-compatible pagination rule is rendered only by Traditional Docs.
|
|
744
|
+
*
|
|
745
|
+
* OOXML: 17.3.1.23 `pageBreakBefore`.
|
|
746
|
+
*/
|
|
747
|
+
pageBreakBefore?: BooleanNumber;
|
|
677
748
|
wordWrap?: BooleanNumber;
|
|
749
|
+
/**
|
|
750
|
+
* Avoids leaving a single measured first or last line on a separate page
|
|
751
|
+
* when the paragraph can be adjusted without violating stronger keep rules.
|
|
752
|
+
*
|
|
753
|
+
* `undefined` inherits, `TRUE` enables, and an explicit `FALSE` disables an
|
|
754
|
+
* inherited value. This Word-compatible pagination rule is rendered only by
|
|
755
|
+
* Traditional Docs.
|
|
756
|
+
*
|
|
757
|
+
* OOXML: 17.3.1.44 `widowControl`.
|
|
758
|
+
*/
|
|
678
759
|
widowControl?: BooleanNumber;
|
|
679
760
|
shading?: IShading;
|
|
680
761
|
suppressHyphenation?: BooleanNumber;
|
|
@@ -76,6 +76,49 @@ export interface IColor {
|
|
|
76
76
|
b: number;
|
|
77
77
|
a?: number;
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Glow applied around drawing content.
|
|
81
|
+
*
|
|
82
|
+
* Dimensional values use the owning unit's drawing coordinate system.
|
|
83
|
+
*/
|
|
84
|
+
export interface IGlowEffect {
|
|
85
|
+
/** Glow color as a CSS color string. */
|
|
86
|
+
color: string;
|
|
87
|
+
/** Glow radius. */
|
|
88
|
+
radius?: number;
|
|
89
|
+
}
|
|
90
|
+
export type OuterShadowAlignment = 'tl' | 't' | 'tr' | 'l' | 'ctr' | 'r' | 'bl' | 'b' | 'br';
|
|
91
|
+
/**
|
|
92
|
+
* Outer shadow applied to drawing content.
|
|
93
|
+
*
|
|
94
|
+
* Dimensional values use the owning unit's drawing coordinate system.
|
|
95
|
+
*/
|
|
96
|
+
export interface IShadowEffect {
|
|
97
|
+
/** Shadow color as a CSS color string. */
|
|
98
|
+
color: string;
|
|
99
|
+
/** OOXML preset shadow token, when the effect originated from `prstShdw`. */
|
|
100
|
+
preset?: string;
|
|
101
|
+
/** Shadow opacity, from 0 (transparent) to 1 (opaque). */
|
|
102
|
+
opacity?: number;
|
|
103
|
+
/** Blur radius. */
|
|
104
|
+
blurRadius?: number;
|
|
105
|
+
/** Direction in degrees, with 0 pointing right and 90 pointing down. */
|
|
106
|
+
direction?: number;
|
|
107
|
+
/** Offset distance from the source. */
|
|
108
|
+
distance?: number;
|
|
109
|
+
/** Horizontal scale factor; 1 means 100%. */
|
|
110
|
+
sx?: number;
|
|
111
|
+
/** Vertical scale factor; 1 means 100%. */
|
|
112
|
+
sy?: number;
|
|
113
|
+
/** Horizontal skew angle in degrees. */
|
|
114
|
+
skewX?: number;
|
|
115
|
+
/** Vertical skew angle in degrees. */
|
|
116
|
+
skewY?: number;
|
|
117
|
+
/** Alignment point used while scaling or skewing the shadow. */
|
|
118
|
+
alignment?: OuterShadowAlignment;
|
|
119
|
+
/** Whether the shadow rotates together with its source. */
|
|
120
|
+
rotateWithShape?: boolean;
|
|
121
|
+
}
|
|
79
122
|
/**
|
|
80
123
|
* Style properties of border
|
|
81
124
|
*/
|
package/lib/types/univer.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ export interface IUniverConfig {
|
|
|
37
37
|
* The locale of the Univer instance.
|
|
38
38
|
*/
|
|
39
39
|
locale?: LocaleType;
|
|
40
|
+
/**
|
|
41
|
+
* The region of the Univer instance. It follows locale until explicitly configured.
|
|
42
|
+
*/
|
|
43
|
+
region?: LocaleType;
|
|
40
44
|
/**
|
|
41
45
|
* The direction of the Univer instance.
|
|
42
46
|
* @default 'ltr'
|
|
@@ -90,6 +94,7 @@ export declare class Univer implements IDisposable {
|
|
|
90
94
|
onDispose(callback: () => void): IDisposable;
|
|
91
95
|
dispose(): void;
|
|
92
96
|
setLocale(locale: LocaleType): void;
|
|
97
|
+
setRegion(region: LocaleType): void;
|
|
93
98
|
createUnit<T, U extends UnitModel>(type: UniverInstanceType, data: Partial<T>): U;
|
|
94
99
|
private _init;
|
|
95
100
|
private _tryProgressToReady;
|
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 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 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 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}};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)}getCurrentLocale(){return this._injector.get(t.LocaleService).getCurrentLocale()}getLocales(){return this._injector.get(t.LocaleService).getLocales()}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(){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)}};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")):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==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}};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});
|