@univerjs/core 0.6.6 → 0.6.7-experimental.20250328-3aaa828
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 +1 -1
- package/lib/cjs/index.js +9 -9
- package/lib/es/facade.js +170 -159
- package/lib/es/index.js +3578 -3477
- package/lib/facade.js +1428 -0
- package/lib/index.js +18138 -0
- package/lib/types/docs/data-model/document-data-model.d.ts +2 -0
- package/lib/types/docs/data-model/text-x/build-utils/paragraph.d.ts +11 -1
- package/lib/types/docs/data-model/text-x/build-utils/selection.d.ts +3 -0
- package/lib/types/docs/data-model/text-x/build-utils/text-x-utils.d.ts +1 -1
- package/lib/types/facade/f-enum.d.ts +10 -1
- package/lib/types/sheets/worksheet.d.ts +5 -2
- package/lib/types/types/const/const.d.ts +3 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +9 -9
- package/package.json +6 -6
- package/LICENSE +0 -176
- package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +0 -45
|
@@ -41,6 +41,8 @@ declare class DocumentDataModelSimple extends UnitModel<IDocumentData, UniverIns
|
|
|
41
41
|
updateDocumentDataPageSize(width?: number, height?: number): void;
|
|
42
42
|
updateDrawing(id: string, config: IDrawingUpdateConfig): void;
|
|
43
43
|
setZoomRatio(zoomRatio?: number): void;
|
|
44
|
+
setDisabled(disabled: boolean): void;
|
|
45
|
+
getDisabled(): boolean | undefined;
|
|
44
46
|
}
|
|
45
47
|
export declare class DocumentDataModel extends DocumentDataModelSimple {
|
|
46
48
|
private _unitId;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITextRange } from '../../../../sheets/typedef';
|
|
2
|
+
import { ICustomTable, IParagraph, IParagraphStyle, ITextStyle } from '../../../../types/interfaces';
|
|
2
3
|
import { DocumentDataModel } from '../../document-data-model';
|
|
3
4
|
import { TextX } from '../text-x';
|
|
4
5
|
export interface ISwitchParagraphBulletParams {
|
|
@@ -29,3 +30,12 @@ export interface IChangeParagraphBulletNestLevelParams {
|
|
|
29
30
|
}
|
|
30
31
|
export declare function hasParagraphInTable(paragraph: IParagraph, tables: ICustomTable[]): boolean;
|
|
31
32
|
export declare const changeParagraphBulletNestLevel: (params: IChangeParagraphBulletNestLevelParams) => TextX;
|
|
33
|
+
interface ISetParagraphStyleParams {
|
|
34
|
+
textRanges: readonly ITextRange[];
|
|
35
|
+
segmentId?: string;
|
|
36
|
+
document: DocumentDataModel;
|
|
37
|
+
style: IParagraphStyle;
|
|
38
|
+
paragraphTextRun?: ITextStyle;
|
|
39
|
+
}
|
|
40
|
+
export declare const setParagraphStyle: (params: ISetParagraphStyleParams) => TextX;
|
|
41
|
+
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { ITextRange } from '../../../../sheets/typedef';
|
|
2
|
+
import { IParagraph, IParagraphRange } from '../../../../types/interfaces';
|
|
2
3
|
export declare function makeSelection(startOffset: number, endOffset?: number): ITextRange;
|
|
3
4
|
export declare function normalizeSelection(selection: ITextRange): ITextRange;
|
|
4
5
|
export declare function isSegmentIntersects(start: number, end: number, start2: number, end2: number): boolean;
|
|
6
|
+
export declare function getParagraphsInRange(activeRange: ITextRange, paragraphs: IParagraph[]): IParagraphRange[];
|
|
7
|
+
export declare function getParagraphsInRanges(ranges: readonly ITextRange[], paragraphs: IParagraph[]): IParagraphRange[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Nullable } from '../../../../shared';
|
|
1
2
|
import { ITextRange, ITextRangeParam } from '../../../../sheets/typedef';
|
|
2
3
|
import { CustomRangeType, IDocumentBody } from '../../../../types/interfaces';
|
|
3
4
|
import { DocumentDataModel } from '../../document-data-model';
|
|
4
5
|
import { TextXAction } from '../action-types';
|
|
5
6
|
import { TextXSelection, TextX } from '../text-x';
|
|
6
|
-
import { Nullable } from '../../../../shared';
|
|
7
7
|
export interface IDeleteCustomRangeParam {
|
|
8
8
|
rangeId: string;
|
|
9
9
|
segmentId?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AutoFillSeries, BaselineOffset, BooleanNumber, BorderStyleTypes, BorderType, ColorType, CommandType, CommonHideTypes, CopyPasteType, DataValidationErrorStyle, DataValidationOperator, DataValidationRenderMode, DataValidationStatus, DataValidationType, DeleteDirection, DeveloperMetadataVisibility, Dimension, Direction, HorizontalAlign, InterpolationPointType, LifecycleStages, LocaleType, MentionType, ProtectionType, RelativeDate, SheetTypes, TextDecoration, TextDirection, ThemeColorType, UniverInstanceType, VerticalAlign, WrapStrategy } from '@univerjs/core';
|
|
1
|
+
import { AbsoluteRefType, AutoFillSeries, BaselineOffset, BooleanNumber, BorderStyleTypes, BorderType, ColorType, CommandType, CommonHideTypes, CopyPasteType, DataValidationErrorStyle, DataValidationOperator, DataValidationRenderMode, DataValidationStatus, DataValidationType, DeleteDirection, DeveloperMetadataVisibility, Dimension, Direction, HorizontalAlign, InterpolationPointType, LifecycleStages, LocaleType, MentionType, ProtectionType, RelativeDate, SheetTypes, TextDecoration, TextDirection, ThemeColorType, UniverInstanceType, VerticalAlign, WrapStrategy } from '@univerjs/core';
|
|
2
2
|
/**
|
|
3
3
|
* @hideconstructor
|
|
4
4
|
*/
|
|
@@ -13,6 +13,15 @@ export declare class FEnum {
|
|
|
13
13
|
*/
|
|
14
14
|
static extend(source: any): void;
|
|
15
15
|
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Defines different types of absolute references
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* console.log(univerAPI.Enum.AbsoluteRefType);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
get AbsoluteRefType(): typeof AbsoluteRefType;
|
|
16
25
|
/**
|
|
17
26
|
* Defines different types of Univer instances
|
|
18
27
|
*
|
|
@@ -68,7 +68,8 @@ export declare class Worksheet {
|
|
|
68
68
|
* @param {boolean} [keepRaw] If true, return the raw style data, otherwise return the style data object
|
|
69
69
|
* @returns {Nullable<IStyleData>|string} The style of the column
|
|
70
70
|
*/
|
|
71
|
-
getColumnStyle(column: number, keepRaw
|
|
71
|
+
getColumnStyle(column: number, keepRaw: true): string | Nullable<IStyleData>;
|
|
72
|
+
getColumnStyle(column: number): Nullable<IStyleData>;
|
|
72
73
|
/**
|
|
73
74
|
* Set the style of the column.
|
|
74
75
|
* @param {number} column The column index
|
|
@@ -81,7 +82,8 @@ export declare class Worksheet {
|
|
|
81
82
|
* @param {boolean} [keepRaw] If true, return the raw style data, otherwise return the style data object
|
|
82
83
|
* @returns {Nullable<IStyleData>} The style of the row
|
|
83
84
|
*/
|
|
84
|
-
getRowStyle(row: number, keepRaw
|
|
85
|
+
getRowStyle(row: number, keepRaw: true): string | Nullable<IStyleData>;
|
|
86
|
+
getRowStyle(row: number): Nullable<IStyleData>;
|
|
85
87
|
/**
|
|
86
88
|
* Set the style of the row.
|
|
87
89
|
* @param {number} row
|
|
@@ -107,6 +109,7 @@ export declare class Worksheet {
|
|
|
107
109
|
* @param {Nullable<IStyleData>} style The style to be set as default style
|
|
108
110
|
*/
|
|
109
111
|
setDefaultCellStyle(style: Nullable<IStyleData> | string): void;
|
|
112
|
+
getCellStyle(row: number, col: number): Nullable<IStyleData>;
|
|
110
113
|
/**
|
|
111
114
|
* Returns WorkSheet Cell Data Matrix
|
|
112
115
|
* @returns WorkSheet Cell Data Matrix
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Nullable } from '../../shared';
|
|
2
|
+
import { ITextStyle, NamedStyleType } from '../interfaces';
|
|
1
3
|
import { BooleanNumber, HorizontalAlign, TextDirection, VerticalAlign, WrapStrategy } from '../enum';
|
|
2
4
|
/**
|
|
3
5
|
* Used as an illegal range array return value
|
|
@@ -146,3 +148,4 @@ export declare const DEFAULT_SLIDE: {
|
|
|
146
148
|
};
|
|
147
149
|
};
|
|
148
150
|
export declare const SHEET_EDITOR_UNITS: string[];
|
|
151
|
+
export declare const NAMED_STYLE_MAP: Record<NamedStyleType, Nullable<ITextStyle>>;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],n):(c=typeof globalThis<"u"?globalThis:c||self,n(c.UniverCoreFacade={},c.UniverCore,c.rxjs))})(this,function(c,n,p){"use strict";var N=Object.defineProperty;var A=(c,n,p)=>n in c?N(c,n,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[n]=p;var h=(c,n,p)=>A(c,typeof n!="symbol"?n+"":n,p);class v extends n.Disposable{static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}const S=Symbol("initializers");class j extends n.Disposable{constructor(t){super(),this._injector=t;const e=this,i=Object.getPrototypeOf(this)[S];i&&i.forEach(function(r){r.apply(e,[t])})}_initialize(t){}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{if(e==="_initialize"){let i=this.prototype[S];i||(i=[],this.prototype[S]=i),i.push(t.prototype._initialize)}else e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}var B=Object.getOwnPropertyDescriptor,U=(a,t,e,i)=>{for(var r=i>1?void 0:i?B(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},O=(a,t)=>(e,i)=>t(e,i,a);c.FBlob=class extends v{constructor(t,e){super(),this._blob=t,this._injector=e}copyBlob(){return this._injector.createInstance(c.FBlob,this._blob)}getAs(t){const e=this.copyBlob();return e.setContentType(t),e}getDataAsString(t){return this._blob===null?Promise.resolve(""):t===void 0?this._blob.text():new Promise((e,i)=>{this._blob.arrayBuffer().then(r=>{const s=new TextDecoder(t).decode(r);e(s)}).catch(r=>{i(new Error(`Failed to read Blob as ArrayBuffer: ${r.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(t=>new Uint8Array(t)):Promise.reject(new Error("Blob is undefined or null."))}setBytes(t){return this._blob=new Blob([t]),this}setDataFromString(t,e){const i=e!=null?e:"text/plain",r=new Blob([t],{type:i});return this._blob=r,this}getContentType(){var t;return(t=this._blob)==null?void 0:t.type}setContentType(t){var e;return this._blob=(e=this._blob)==null?void 0:e.slice(0,this._blob.size,t),this}},c.FBlob=U([O(1,n.Inject(n.Injector))],c.FBlob);const y=class y{static get(){if(this._instance)return this._instance;const t=new y;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in y.prototype)this[t]=y.prototype[t]}get UniverInstanceType(){return n.UniverInstanceType}get LifecycleStages(){return n.LifecycleStages}get DataValidationType(){return n.DataValidationType}get DataValidationErrorStyle(){return n.DataValidationErrorStyle}get DataValidationRenderMode(){return n.DataValidationRenderMode}get DataValidationOperator(){return n.DataValidationOperator}get DataValidationStatus(){return n.DataValidationStatus}get CommandType(){return n.CommandType}get BaselineOffset(){return n.BaselineOffset}get BooleanNumber(){return n.BooleanNumber}get HorizontalAlign(){return n.HorizontalAlign}get TextDecoration(){return n.TextDecoration}get TextDirection(){return n.TextDirection}get VerticalAlign(){return n.VerticalAlign}get WrapStrategy(){return n.WrapStrategy}get BorderType(){return n.BorderType}get BorderStyleTypes(){return n.BorderStyleTypes}get AutoFillSeries(){return n.AutoFillSeries}get ColorType(){return n.ColorType}get CommonHideTypes(){return n.CommonHideTypes}get CopyPasteType(){return n.CopyPasteType}get DeleteDirection(){return n.DeleteDirection}get DeveloperMetadataVisibility(){return n.DeveloperMetadataVisibility}get Dimension(){return n.Dimension}get Direction(){return n.Direction}get InterpolationPointType(){return n.InterpolationPointType}get LocaleType(){return n.LocaleType}get MentionType(){return n.MentionType}get ProtectionType(){return n.ProtectionType}get RelativeDate(){return n.RelativeDate}get SheetTypes(){return n.SheetTypes}get ThemeColorType(){return n.ThemeColorType}};h(y,"_instance");let f=y;const g=class g{static get(){if(this._instance)return this._instance;const t=new g;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in g.prototype)this[t]=g.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"}};h(g,"_instance");let m=g;var P=Object.getOwnPropertyDescriptor,I=(a,t,e,i)=>{for(var r=i>1?void 0:i?P(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},R=(a,t)=>(e,i)=>t(e,i,a);c.FHooks=class extends v{constructor(t,e){super(),this._injector=t,this._lifecycleService=e}onStarting(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Starting)).subscribe(t))}onReady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Ready)).subscribe(t))}onRendered(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Rendered)).subscribe(t))}onSteady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Steady)).subscribe(t))}onBeforeUndo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onUndo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onBeforeRedo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}onRedo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}},c.FHooks=I([R(0,n.Inject(n.Injector)),R(1,n.Inject(n.LifecycleService))],c.FHooks);var x=Object.getOwnPropertyDescriptor,H=(a,t,e,i)=>{for(var r=i>1?void 0:i?x(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},F=(a,t)=>(e,i)=>t(e,i,a);let C=class extends j{constructor(a,t){super(t),this.doc=a}};C=H([F(1,n.Inject(n.Injector))],C);class V{constructor(){h(this,"_eventRegistry",new Map);h(this,"_eventHandlerMap",new Map);h(this,"_eventHandlerRegisted",new Map)}_ensureEventRegistry(t){return this._eventRegistry.has(t)||this._eventRegistry.set(t,new n.Registry),this._eventRegistry.get(t)}registerEventHandler(t,e){const i=this._eventHandlerMap.get(t);return i?i.add(e):this._eventHandlerMap.set(t,new Set([e])),this._ensureEventRegistry(t).getData().length&&this._initEventHandler(t),n.toDisposable(()=>{var r,s,o,d;(r=this._eventHandlerMap.get(t))==null||r.delete(e),(o=(s=this._eventHandlerRegisted.get(t))==null?void 0:s.get(e))==null||o.dispose(),(d=this._eventHandlerRegisted.get(t))==null||d.delete(e)})}removeEvent(t,e){const i=this._ensureEventRegistry(t);if(i.delete(e),i.getData().length===0){const r=this._eventHandlerRegisted.get(t);r==null||r.forEach(s=>s.dispose()),this._eventHandlerRegisted.delete(t)}}_initEventHandler(t){let e=this._eventHandlerRegisted.get(t);const i=this._eventHandlerMap.get(t);i&&(e||(e=new Map,this._eventHandlerRegisted.set(t,e),i==null||i.forEach(r=>{e==null||e.set(r,n.toDisposable(r()))})))}addEvent(t,e){return this._ensureEventRegistry(t).add(e),this._initEventHandler(t),n.toDisposable(()=>this.removeEvent(t,e))}fireEvent(t,e){var i;return(i=this._eventRegistry.get(t))==null||i.getData().forEach(r=>{r(e)}),e.cancel}}var M=Object.getOwnPropertyDescriptor,$=(a,t,e,i)=>{for(var r=i>1?void 0:i?M(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},w=(a,t)=>(e,i)=>t(e,i,a);let D=class extends v{constructor(a,t){super(),this._injector=a,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};D=$([w(0,n.Inject(n.Injector)),w(1,n.Inject(n.UserManagerService))],D);const b=class b{static get(){if(this._instance)return this._instance;const t=new b;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}get rectangle(){return n.Rectangle}get numfmt(){return n.numfmt}get tools(){return n.Tools}};h(b,"_instance");let _=b;var z=Object.getOwnPropertyDescriptor,L=(a,t,e,i)=>{for(var r=i>1?void 0:i?z(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},E=(a,t)=>(e,i)=>t(e,i,a);const T=Symbol("initializers");c.FUniver=class extends n.Disposable{constructor(e,i,r,s){super();h(this,"_eventRegistry",new V);h(this,"registerEventHandler",(e,i)=>this._eventRegistry.registerEventHandler(e,i));this._injector=e,this._commandService=i,this._univerInstanceService=r,this._lifecycleService=s,this.registerEventHandler(this.Event.LifeCycleChanged,()=>n.toDisposable(this._lifecycleService.lifecycle$.subscribe(d=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:d})}))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});const o=Object.getPrototypeOf(this)[T];if(o){const d=this;o.forEach(function(u){u.apply(d,[e])})}}static newAPI(e){return(e instanceof n.Univer?e.__getInjector():e).createInstance(c.FUniver)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(i=>{if(i==="_initialize"){let r=this.prototype[T];r||(r=[],this.prototype[T]=r),r.push(e.prototype._initialize)}else i!=="constructor"&&(this.prototype[i]=e.prototype[i])}),Object.getOwnPropertyNames(e).forEach(i=>{i!=="prototype"&&i!=="name"&&i!=="length"&&(this[i]=e[i])})}_initCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.Redo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Redo,l)}})),this.registerEventHandler(this.Event.Undo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Undo,l)}})),this.registerEventHandler(this.Event.CommandExecuted,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.CommandExecuted,l)}}))}_initBeforeCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.BeforeRedo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeRedo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeUndo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeUndo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommandExecute,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeCommandExecute,l),l.cancel)throw new n.CanceledError}}))}_initUnitEvent(e){const i=e.get(n.IUniverInstanceService);this.registerEventHandler(this.Event.DocDisposed,()=>i.unitDisposed$.subscribe(r=>{r.type===n.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:r.getUnitId(),unitType:r.type,snapshot:r.getSnapshot()})})),this.registerEventHandler(this.Event.DocCreated,()=>i.unitAdded$.subscribe(r=>{if(r.type===n.UniverInstanceType.UNIVER_DOC){const s=r,o=e.createInstance(C,s);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:o,unit:o})}}))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(n.LifecycleService).stage}undo(){return this._commandService.executeCommand(n.UndoCommand.id)}redo(){return this._commandService.executeCommand(n.RedoCommand.id)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((i,r)=>{e(i,r)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((i,r)=>{e(i,r)})}executeCommand(e,i,r){return this._commandService.executeCommand(e,i,r)}syncExecuteCommand(e,i,r){return this._commandService.syncExecuteCommand(e,i,r)}getHooks(){return this._injector.createInstance(c.FHooks)}get Enum(){return f.get()}get Event(){return m.get()}get Util(){return _.get()}addEvent(e,i){if(!e||!i)throw new Error("Cannot add empty event");return this._eventRegistry.addEvent(e,i)}fireEvent(e,i){return this._eventRegistry.fireEvent(e,i)}getUserManager(){return this._injector.createInstance(D)}newBlob(){return this._injector.createInstance(c.FBlob)}newColor(){return new n.ColorBuilder}newRichText(e){return n.RichTextBuilder.create(e)}newRichTextValue(e){return n.RichTextValue.create(e)}newParagraphStyle(e){return n.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return n.ParagraphStyleValue.create(e)}newTextStyle(e){return n.TextStyleBuilder.create(e)}newTextStyleValue(e){return n.TextStyleValue.create(e)}newTextDecoration(e){return new n.TextDecorationBuilder(e)}},c.FUniver=L([E(0,n.Inject(n.Injector)),E(1,n.ICommandService),E(2,n.IUniverInstanceService),E(3,n.Inject(n.LifecycleService))],c.FUniver),c.FBase=v,c.FBaseInitialable=j,c.FEnum=f,c.FEventName=m,c.FUtil=_,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],n):(c=typeof globalThis<"u"?globalThis:c||self,n(c.UniverCoreFacade={},c.UniverCore,c.rxjs))})(this,function(c,n,p){"use strict";var N=Object.defineProperty;var A=(c,n,p)=>n in c?N(c,n,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[n]=p;var u=(c,n,p)=>A(c,typeof n!="symbol"?n+"":n,p);class v extends n.Disposable{static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}const S=Symbol("initializers");class R extends n.Disposable{constructor(t){super(),this._injector=t;const e=this,i=Object.getPrototypeOf(this)[S];i&&i.forEach(function(r){r.apply(e,[t])})}_initialize(t){}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{if(e==="_initialize"){let i=this.prototype[S];i||(i=[],this.prototype[S]=i),i.push(t.prototype._initialize)}else e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}var B=Object.getOwnPropertyDescriptor,U=(a,t,e,i)=>{for(var r=i>1?void 0:i?B(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},O=(a,t)=>(e,i)=>t(e,i,a);c.FBlob=class extends v{constructor(t,e){super(),this._blob=t,this._injector=e}copyBlob(){return this._injector.createInstance(c.FBlob,this._blob)}getAs(t){const e=this.copyBlob();return e.setContentType(t),e}getDataAsString(t){return this._blob===null?Promise.resolve(""):t===void 0?this._blob.text():new Promise((e,i)=>{this._blob.arrayBuffer().then(r=>{const s=new TextDecoder(t).decode(r);e(s)}).catch(r=>{i(new Error(`Failed to read Blob as ArrayBuffer: ${r.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(t=>new Uint8Array(t)):Promise.reject(new Error("Blob is undefined or null."))}setBytes(t){return this._blob=new Blob([t]),this}setDataFromString(t,e){const i=e!=null?e:"text/plain",r=new Blob([t],{type:i});return this._blob=r,this}getContentType(){var t;return(t=this._blob)==null?void 0:t.type}setContentType(t){var e;return this._blob=(e=this._blob)==null?void 0:e.slice(0,this._blob.size,t),this}},c.FBlob=U([O(1,n.Inject(n.Injector))],c.FBlob);const y=class y{static get(){if(this._instance)return this._instance;const t=new y;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in y.prototype)this[t]=y.prototype[t]}get AbsoluteRefType(){return n.AbsoluteRefType}get UniverInstanceType(){return n.UniverInstanceType}get LifecycleStages(){return n.LifecycleStages}get DataValidationType(){return n.DataValidationType}get DataValidationErrorStyle(){return n.DataValidationErrorStyle}get DataValidationRenderMode(){return n.DataValidationRenderMode}get DataValidationOperator(){return n.DataValidationOperator}get DataValidationStatus(){return n.DataValidationStatus}get CommandType(){return n.CommandType}get BaselineOffset(){return n.BaselineOffset}get BooleanNumber(){return n.BooleanNumber}get HorizontalAlign(){return n.HorizontalAlign}get TextDecoration(){return n.TextDecoration}get TextDirection(){return n.TextDirection}get VerticalAlign(){return n.VerticalAlign}get WrapStrategy(){return n.WrapStrategy}get BorderType(){return n.BorderType}get BorderStyleTypes(){return n.BorderStyleTypes}get AutoFillSeries(){return n.AutoFillSeries}get ColorType(){return n.ColorType}get CommonHideTypes(){return n.CommonHideTypes}get CopyPasteType(){return n.CopyPasteType}get DeleteDirection(){return n.DeleteDirection}get DeveloperMetadataVisibility(){return n.DeveloperMetadataVisibility}get Dimension(){return n.Dimension}get Direction(){return n.Direction}get InterpolationPointType(){return n.InterpolationPointType}get LocaleType(){return n.LocaleType}get MentionType(){return n.MentionType}get ProtectionType(){return n.ProtectionType}get RelativeDate(){return n.RelativeDate}get SheetTypes(){return n.SheetTypes}get ThemeColorType(){return n.ThemeColorType}};u(y,"_instance");let f=y;const g=class g{static get(){if(this._instance)return this._instance;const t=new g;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in g.prototype)this[t]=g.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"}};u(g,"_instance");let m=g;var P=Object.getOwnPropertyDescriptor,I=(a,t,e,i)=>{for(var r=i>1?void 0:i?P(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},j=(a,t)=>(e,i)=>t(e,i,a);c.FHooks=class extends v{constructor(t,e){super(),this._injector=t,this._lifecycleService=e}onStarting(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Starting)).subscribe(t))}onReady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Ready)).subscribe(t))}onRendered(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Rendered)).subscribe(t))}onSteady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Steady)).subscribe(t))}onBeforeUndo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onUndo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onBeforeRedo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}onRedo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}},c.FHooks=I([j(0,n.Inject(n.Injector)),j(1,n.Inject(n.LifecycleService))],c.FHooks);var x=Object.getOwnPropertyDescriptor,H=(a,t,e,i)=>{for(var r=i>1?void 0:i?x(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},F=(a,t)=>(e,i)=>t(e,i,a);let C=class extends R{constructor(a,t){super(t),this.doc=a}};C=H([F(1,n.Inject(n.Injector))],C);class V{constructor(){u(this,"_eventRegistry",new Map);u(this,"_eventHandlerMap",new Map);u(this,"_eventHandlerRegisted",new Map)}_ensureEventRegistry(t){return this._eventRegistry.has(t)||this._eventRegistry.set(t,new n.Registry),this._eventRegistry.get(t)}registerEventHandler(t,e){const i=this._eventHandlerMap.get(t);return i?i.add(e):this._eventHandlerMap.set(t,new Set([e])),this._ensureEventRegistry(t).getData().length&&this._initEventHandler(t),n.toDisposable(()=>{var r,s,o,d;(r=this._eventHandlerMap.get(t))==null||r.delete(e),(o=(s=this._eventHandlerRegisted.get(t))==null?void 0:s.get(e))==null||o.dispose(),(d=this._eventHandlerRegisted.get(t))==null||d.delete(e)})}removeEvent(t,e){const i=this._ensureEventRegistry(t);if(i.delete(e),i.getData().length===0){const r=this._eventHandlerRegisted.get(t);r==null||r.forEach(s=>s.dispose()),this._eventHandlerRegisted.delete(t)}}_initEventHandler(t){let e=this._eventHandlerRegisted.get(t);const i=this._eventHandlerMap.get(t);i&&(e||(e=new Map,this._eventHandlerRegisted.set(t,e),i==null||i.forEach(r=>{e==null||e.set(r,n.toDisposable(r()))})))}addEvent(t,e){return this._ensureEventRegistry(t).add(e),this._initEventHandler(t),n.toDisposable(()=>this.removeEvent(t,e))}fireEvent(t,e){var i;return(i=this._eventRegistry.get(t))==null||i.getData().forEach(r=>{r(e)}),e.cancel}}var M=Object.getOwnPropertyDescriptor,$=(a,t,e,i)=>{for(var r=i>1?void 0:i?M(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},w=(a,t)=>(e,i)=>t(e,i,a);let D=class extends v{constructor(a,t){super(),this._injector=a,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};D=$([w(0,n.Inject(n.Injector)),w(1,n.Inject(n.UserManagerService))],D);const b=class b{static get(){if(this._instance)return this._instance;const t=new b;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}get rectangle(){return n.Rectangle}get numfmt(){return n.numfmt}get tools(){return n.Tools}};u(b,"_instance");let _=b;var z=Object.getOwnPropertyDescriptor,L=(a,t,e,i)=>{for(var r=i>1?void 0:i?z(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},E=(a,t)=>(e,i)=>t(e,i,a);const T=Symbol("initializers");c.FUniver=class extends n.Disposable{constructor(e,i,r,s){super();u(this,"_eventRegistry",new V);u(this,"registerEventHandler",(e,i)=>this._eventRegistry.registerEventHandler(e,i));this._injector=e,this._commandService=i,this._univerInstanceService=r,this._lifecycleService=s,this.registerEventHandler(this.Event.LifeCycleChanged,()=>n.toDisposable(this._lifecycleService.lifecycle$.subscribe(d=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:d})}))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});const o=Object.getPrototypeOf(this)[T];if(o){const d=this;o.forEach(function(h){h.apply(d,[e])})}}static newAPI(e){return(e instanceof n.Univer?e.__getInjector():e).createInstance(c.FUniver)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(i=>{if(i==="_initialize"){let r=this.prototype[T];r||(r=[],this.prototype[T]=r),r.push(e.prototype._initialize)}else i!=="constructor"&&(this.prototype[i]=e.prototype[i])}),Object.getOwnPropertyNames(e).forEach(i=>{i!=="prototype"&&i!=="name"&&i!=="length"&&(this[i]=e[i])})}_initCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.Redo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Redo,l)}})),this.registerEventHandler(this.Event.Undo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Undo,l)}})),this.registerEventHandler(this.Event.CommandExecuted,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.CommandExecuted,l)}}))}_initBeforeCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.BeforeRedo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeRedo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeUndo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeUndo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommandExecute,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeCommandExecute,l),l.cancel)throw new n.CanceledError}}))}_initUnitEvent(e){const i=e.get(n.IUniverInstanceService);this.registerEventHandler(this.Event.DocDisposed,()=>i.unitDisposed$.subscribe(r=>{r.type===n.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:r.getUnitId(),unitType:r.type,snapshot:r.getSnapshot()})})),this.registerEventHandler(this.Event.DocCreated,()=>i.unitAdded$.subscribe(r=>{if(r.type===n.UniverInstanceType.UNIVER_DOC){const s=r,o=e.createInstance(C,s);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:o,unit:o})}}))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(n.LifecycleService).stage}undo(){return this._commandService.executeCommand(n.UndoCommand.id)}redo(){return this._commandService.executeCommand(n.RedoCommand.id)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((i,r)=>{e(i,r)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((i,r)=>{e(i,r)})}executeCommand(e,i,r){return this._commandService.executeCommand(e,i,r)}syncExecuteCommand(e,i,r){return this._commandService.syncExecuteCommand(e,i,r)}getHooks(){return this._injector.createInstance(c.FHooks)}get Enum(){return f.get()}get Event(){return m.get()}get Util(){return _.get()}addEvent(e,i){if(!e||!i)throw new Error("Cannot add empty event");return this._eventRegistry.addEvent(e,i)}fireEvent(e,i){return this._eventRegistry.fireEvent(e,i)}getUserManager(){return this._injector.createInstance(D)}newBlob(){return this._injector.createInstance(c.FBlob)}newColor(){return new n.ColorBuilder}newRichText(e){return n.RichTextBuilder.create(e)}newRichTextValue(e){return n.RichTextValue.create(e)}newParagraphStyle(e){return n.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return n.ParagraphStyleValue.create(e)}newTextStyle(e){return n.TextStyleBuilder.create(e)}newTextStyleValue(e){return n.TextStyleValue.create(e)}newTextDecoration(e){return new n.TextDecorationBuilder(e)}},c.FUniver=L([E(0,n.Inject(n.Injector)),E(1,n.ICommandService),E(2,n.IUniverInstanceService),E(3,n.Inject(n.LifecycleService))],c.FUniver),c.FBase=v,c.FBaseInitialable=R,c.FEnum=f,c.FEventName=m,c.FUtil=_,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|