@univerjs/core 0.16.1 → 0.17.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 +1 -1
- package/lib/cjs/index.js +8 -8
- package/lib/es/facade.js +32 -44
- package/lib/es/index.js +3847 -4078
- package/lib/facade.js +32 -44
- package/lib/index.js +3847 -4078
- package/lib/types/facade/f-univer.d.ts +1 -11
- package/lib/types/services/plugin/plugin.service.d.ts +4 -0
- package/lib/types/services/resource-manager/resource-manager.service.d.ts +1 -2
- package/lib/types/shared/compare.d.ts +3 -3
- package/lib/types/shared/index.d.ts +0 -1
- package/lib/types/shared/object-matrix-query.d.ts +1 -1
- package/lib/types/shared/shape.d.ts +6 -0
- package/lib/types/types/interfaces/i-drawing.d.ts +6 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +8 -8
- package/package.json +3 -3
- package/lib/types/shared/color/color.d.ts +0 -84
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandListener, IDisposable, IDocumentData, IExecutionOptions, ILanguagePack, IParagraphStyle, ITextDecoration, ITextStyle, LifecycleStages,
|
|
1
|
+
import { CommandListener, IDisposable, IDocumentData, IExecutionOptions, ILanguagePack, IParagraphStyle, ITextDecoration, ITextStyle, LifecycleStages, Disposable, ICommandService, Injector, IUniverInstanceService, LifecycleService, ParagraphStyleBuilder, ParagraphStyleValue, RichTextBuilder, RichTextValue, TextDecorationBuilder, TextStyleBuilder, TextStyleValue, Univer } from '@univerjs/core';
|
|
2
2
|
import { Subscription } from 'rxjs';
|
|
3
3
|
import { IEventParamConfig, FEventName } from './f-event';
|
|
4
4
|
import { FBlob } from './f-blob';
|
|
@@ -220,16 +220,6 @@ export declare class FUniver extends Disposable {
|
|
|
220
220
|
* ```
|
|
221
221
|
*/
|
|
222
222
|
newBlob(): FBlob;
|
|
223
|
-
/**
|
|
224
|
-
* Create a new color.
|
|
225
|
-
* @returns {ColorBuilder} The new color instance
|
|
226
|
-
* @example
|
|
227
|
-
* ```ts
|
|
228
|
-
* const color = univerAPI.newColor();
|
|
229
|
-
* ```
|
|
230
|
-
* @deprecated
|
|
231
|
-
*/
|
|
232
|
-
newColor(): ColorBuilder;
|
|
233
223
|
/**
|
|
234
224
|
* Create a new rich text.
|
|
235
225
|
* @param {IDocumentData} data
|
|
@@ -7,6 +7,8 @@ export declare const DependentOnSymbol: unique symbol;
|
|
|
7
7
|
export type PluginCtor<T extends Plugin = Plugin> = Ctor<T> & {
|
|
8
8
|
type: UnitType;
|
|
9
9
|
pluginName: string;
|
|
10
|
+
packageName: string;
|
|
11
|
+
version: string;
|
|
10
12
|
[DependentOnSymbol]?: PluginCtor[];
|
|
11
13
|
};
|
|
12
14
|
/**
|
|
@@ -14,6 +16,8 @@ export type PluginCtor<T extends Plugin = Plugin> = Ctor<T> & {
|
|
|
14
16
|
*/
|
|
15
17
|
export declare abstract class Plugin extends Disposable {
|
|
16
18
|
static pluginName: string;
|
|
19
|
+
static packageName: string;
|
|
20
|
+
static version: string;
|
|
17
21
|
static type: UnitType;
|
|
18
22
|
protected abstract _injector: Injector;
|
|
19
23
|
onStarting(): void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UniverInstanceType } from '../../common/unit';
|
|
2
|
-
import { IResources } from '
|
|
3
|
-
import { IResourceHook, IResourceManagerService, IResourceName } from './type';
|
|
2
|
+
import { IResourceHook, IResourceManagerService, IResourceName, IResources } from './type';
|
|
4
3
|
import { Disposable } from '../../shared/lifecycle';
|
|
5
4
|
import { ILogService } from '../log/log.service';
|
|
6
5
|
export declare class ResourceManagerService extends Disposable implements IResourceManagerService {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ITextRun } from '../types/interfaces/i-document-data';
|
|
2
|
-
interface
|
|
3
|
-
[key: number | string]:
|
|
2
|
+
interface IAnyObject {
|
|
3
|
+
[key: number | string]: IAnyObject | IAnyObject[] | Array<[number | string]> | any;
|
|
4
4
|
}
|
|
5
|
-
export declare function deepCompare(arg1:
|
|
5
|
+
export declare function deepCompare(arg1: IAnyObject, arg2: IAnyObject): boolean;
|
|
6
6
|
export declare function isSameStyleTextRun(tr1: ITextRun, tr2: ITextRun): boolean;
|
|
7
7
|
export declare function checkForSubstrings(searchString: string, substrings: string[]): boolean;
|
|
8
8
|
export {};
|
|
@@ -17,7 +17,6 @@ export { afterInitApply } from './after-init-apply';
|
|
|
17
17
|
export * from './array-search';
|
|
18
18
|
export * from './blob';
|
|
19
19
|
export { checkIfMove, MOVE_BUFFER_VALUE, ROTATE_BUFFER_VALUE } from './check-if-move';
|
|
20
|
-
export * from './color/color';
|
|
21
20
|
export { ColorKit, COLORS, type IRgbColor, RGB_PAREN, RGBA_PAREN } from './color/color-kit';
|
|
22
21
|
export * from './command-enum';
|
|
23
22
|
export * from './common';
|
|
@@ -29,6 +29,12 @@ export interface ISrcRect extends IOffset {
|
|
|
29
29
|
right?: number;
|
|
30
30
|
bottom?: number;
|
|
31
31
|
}
|
|
32
|
+
export interface IGroupBaseBound {
|
|
33
|
+
left: number;
|
|
34
|
+
top: number;
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
}
|
|
32
38
|
export interface IAbsoluteTransform extends ISize, IOffset, IScale {
|
|
33
39
|
}
|
|
34
40
|
export interface IRectXYWH {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAbsoluteTransform } from '../../shared/shape';
|
|
1
|
+
import { IAbsoluteTransform, IGroupBaseBound } from '../../shared/shape';
|
|
2
2
|
import { Nullable } from '../../shared/types';
|
|
3
3
|
import { BooleanNumber } from '../enum/text-style';
|
|
4
4
|
/**
|
|
@@ -96,4 +96,9 @@ export interface IDrawingParam extends IDrawingSearch {
|
|
|
96
96
|
isMultiTransform?: BooleanNumber;
|
|
97
97
|
groupId?: string;
|
|
98
98
|
allowTransform?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* The base bound of the group, used to calculate the relative position of children in the group.
|
|
101
|
+
* It is only used when drawingType is DRAWING_GROUP.
|
|
102
|
+
*/
|
|
103
|
+
groupBaseBound?: Nullable<IGroupBaseBound>;
|
|
99
104
|
}
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],i):(c=typeof globalThis<"u"?globalThis:c||self,i(c.UniverCoreFacade={},c.UniverCore,c.rxjs))})(this,(function(c,i,p){"use strict";var W=Object.defineProperty;var k=(c,i,p)=>i in c?W(c,i,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[i]=p;var u=(c,i,p)=>k(c,typeof i!="symbol"?i+"":i,p);class v extends i.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 f=Symbol("initializers"),R=Symbol("manualInit");class w extends i.Disposable{constructor(t){if(super(),this._injector=t,!!this.constructor[R])return;const r=this,s=Object.getPrototypeOf(this)[f];s&&s.forEach(function(o){o.apply(r,[t])})}_initialize(t,...e){}_runInitializers(...t){const e=Object.getPrototypeOf(this)[f];e!=null&&e.length&&e.forEach(n=>n.apply(this,t))}static _enableManualInit(){this[R]=!0}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{if(e==="_initialize"){let n=this.prototype[f];n||(n=[],this.prototype[f]=n),n.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 U=Object.getOwnPropertyDescriptor,I=(a,t,e,n)=>{for(var r=n>1?void 0:n?U(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},P=(a,t)=>(e,n)=>t(e,n,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,n)=>{this._blob.arrayBuffer().then(r=>{const s=new TextDecoder(t).decode(r);e(s)}).catch(r=>{n(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.buffer]),this}setDataFromString(t,e){const n=e!=null?e:"text/plain",r=new Blob([t],{type:n});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=I([P(1,i.Inject(i.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 i.AbsoluteRefType}get UniverInstanceType(){return i.UniverInstanceType}get LifecycleStages(){return i.LifecycleStages}get DataValidationType(){return i.DataValidationType}get DataValidationErrorStyle(){return i.DataValidationErrorStyle}get DataValidationRenderMode(){return i.DataValidationRenderMode}get DataValidationOperator(){return i.DataValidationOperator}get DataValidationStatus(){return i.DataValidationStatus}get CommandType(){return i.CommandType}get BaselineOffset(){return i.BaselineOffset}get BooleanNumber(){return i.BooleanNumber}get HorizontalAlign(){return i.HorizontalAlign}get TextDecoration(){return i.TextDecoration}get TextDirection(){return i.TextDirection}get VerticalAlign(){return i.VerticalAlign}get WrapStrategy(){return i.WrapStrategy}get BorderType(){return i.BorderType}get BorderStyleTypes(){return i.BorderStyleTypes}get AutoFillSeries(){return i.AutoFillSeries}get ColorType(){return i.ColorType}get CommonHideTypes(){return i.CommonHideTypes}get CopyPasteType(){return i.CopyPasteType}get DeleteDirection(){return i.DeleteDirection}get DeveloperMetadataVisibility(){return i.DeveloperMetadataVisibility}get Dimension(){return i.Dimension}get Direction(){return i.Direction}get InterpolationPointType(){return i.InterpolationPointType}get LocaleType(){return i.LocaleType}get MentionType(){return i.MentionType}get ProtectionType(){return i.ProtectionType}get RelativeDate(){return i.RelativeDate}get SheetTypes(){return i.SheetTypes}get ThemeColorType(){return i.ThemeColorType}};u(y,"_instance");let m=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 _=g;var x=Object.getOwnPropertyDescriptor,H=(a,t,e,n)=>{for(var r=n>1?void 0:n?x(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},B=(a,t)=>(e,n)=>t(e,n,a);c.FHooks=class extends v{constructor(t,e){super(),this._injector=t,this._lifecycleService=e}onStarting(t){return i.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===i.LifecycleStages.Starting)).subscribe(t))}onReady(t){return i.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===i.LifecycleStages.Ready)).subscribe(t))}onRendered(t){return i.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===i.LifecycleStages.Rendered)).subscribe(t))}onSteady(t){return i.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===i.LifecycleStages.Steady)).subscribe(t))}onBeforeUndo(t){return this._injector.get(i.ICommandService).beforeCommandExecuted(n=>{if(n.id===i.UndoCommand.id){const s=this._injector.get(i.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onUndo(t){return this._injector.get(i.ICommandService).onCommandExecuted(n=>{if(n.id===i.UndoCommand.id){const s=this._injector.get(i.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onBeforeRedo(t){return this._injector.get(i.ICommandService).beforeCommandExecuted(n=>{if(n.id===i.RedoCommand.id){const s=this._injector.get(i.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}onRedo(t){return this._injector.get(i.ICommandService).onCommandExecuted(n=>{if(n.id===i.RedoCommand.id){const s=this._injector.get(i.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}},c.FHooks=H([B(0,i.Inject(i.Injector)),B(1,i.Inject(i.LifecycleService))],c.FHooks);var M=Object.getOwnPropertyDescriptor,F=(a,t,e,n)=>{for(var r=n>1?void 0:n?M(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},V=(a,t)=>(e,n)=>t(e,n,a);let D=class extends w{constructor(a,t){super(t),this.doc=a}};D=F([V(1,i.Inject(i.Injector))],D);class L{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 i.Registry),this._eventRegistry.get(t)}registerEventHandler(t,e){const n=this._eventHandlerMap.get(t);return n?n.add(e):this._eventHandlerMap.set(t,new Set([e])),this._ensureEventRegistry(t).getData().length&&this._initEventHandler(t),i.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 n=this._ensureEventRegistry(t);if(n.delete(e),n.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 n=this._eventHandlerMap.get(t);n&&(!e||e.size===0)&&(e=new Map,this._eventHandlerRegisted.set(t,e),n==null||n.forEach(r=>{e==null||e.set(r,i.toDisposable(r()))}))}addEvent(t,e){return this._ensureEventRegistry(t).add(e),this._initEventHandler(t),i.toDisposable(()=>this.removeEvent(t,e))}fireEvent(t,e){var n;return(n=this._eventRegistry.get(t))==null||n.getData().forEach(r=>{r(e)}),e.cancel}}var $=Object.getOwnPropertyDescriptor,z=(a,t,e,n)=>{for(var r=n>1?void 0:n?$(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},O=(a,t)=>(e,n)=>t(e,n,a);let j=class extends v{constructor(a,t){super(),this._injector=a,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};j=z([O(0,i.Inject(i.Injector)),O(1,i.Inject(i.UserManagerService))],j);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 i.Rectangle}get numfmt(){return i.numfmt}get tools(){return i.Tools}};u(b,"_instance");let E=b;var N=Object.getOwnPropertyDescriptor,A=(a,t,e,n)=>{for(var r=n>1?void 0:n?N(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},S=(a,t)=>(e,n)=>t(e,n,a);const T=Symbol("initializers");c.FUniver=class extends i.Disposable{constructor(e,n,r,s){super();u(this,"_eventRegistry",new L);u(this,"registerEventHandler",(e,n)=>this._eventRegistry.registerEventHandler(e,n));this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=s,this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>i.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 i.Univer?e.__getInjector():e).createInstance(c.FUniver)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(n=>{if(n==="_initialize"){let r=this.prototype[T];r||(r=[],this.prototype[T]=r),r.push(e.prototype._initialize)}else n!=="constructor"&&(this.prototype[n]=e.prototype[n])}),Object.getOwnPropertyNames(e).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=e[n])})}_initCommandEvent(e){const n=e.get(i.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>n.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===i.RedoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Redo,l)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.Undo,()=>n.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===i.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Undo,l)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted,()=>n.onCommandExecuted((r,s)=>{const{id:o,type:d,params:h}=r;if(r.id!==i.RedoCommand.id&&r.id!==i.UndoCommand.id){const C={id:o,type:d,params:h,options:s};this.fireEvent(this.Event.CommandExecuted,C)}})))}_initBeforeCommandEvent(e){const n=e.get(i.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>n.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===i.RedoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeRedo,l),l.cancel)throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>n.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===i.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeUndo,l),l.cancel)throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>n.beforeCommandExecuted((r,s)=>{const{id:o,type:d,params:h}=r;if(r.id!==i.RedoCommand.id&&r.id!==i.UndoCommand.id){const C={id:o,type:d,params:h,options:s};if(this.fireEvent(this.Event.BeforeCommandExecute,C),C.cancel)throw new i.CanceledError}})))}_initUnitEvent(e){const n=e.get(i.IUniverInstanceService);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>n.unitDisposed$.subscribe(r=>{r.type===i.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:r.getUnitId(),unitType:r.type,snapshot:r.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>n.unitAdded$.subscribe(r=>{if(r.type===i.UniverInstanceType.UNIVER_DOC){const s=r,o=e.createInstance(D,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(i.LifecycleService).stage}undo(){return this._commandService.executeCommand(i.UndoCommand.id)}redo(){return this._commandService.executeCommand(i.RedoCommand.id)}toggleDarkMode(e){this._injector.get(i.ThemeService).setDarkMode(e)}loadLocales(e,n){this._injector.get(i.LocaleService).load({[e]:n})}setLocale(e){this._injector.get(i.LocaleService).setLocale(e)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((n,r)=>{e(n,r)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((n,r)=>{e(n,r)})}executeCommand(e,n,r){return this._commandService.executeCommand(e,n,r)}syncExecuteCommand(e,n,r){return this._commandService.syncExecuteCommand(e,n,r)}getHooks(){return this._injector.createInstance(c.FHooks)}get Enum(){return m.get()}get Event(){return _.get()}get Util(){return E.get()}addEvent(e,n){if(!e||!n)throw new Error("Cannot add empty event");return this._eventRegistry.addEvent(e,n)}fireEvent(e,n){return this._eventRegistry.fireEvent(e,n)}getUserManager(){return this._injector.createInstance(j)}newBlob(){return this._injector.createInstance(c.FBlob)}newColor(){return new i.ColorBuilder}newRichText(e){return i.RichTextBuilder.create(e)}newRichTextValue(e){return i.RichTextValue.create(e)}newParagraphStyle(e){return i.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return i.ParagraphStyleValue.create(e)}newTextStyle(e){return i.TextStyleBuilder.create(e)}newTextStyleValue(e){return i.TextStyleValue.create(e)}newTextDecoration(e){return new i.TextDecorationBuilder(e)}},c.FUniver=A([S(0,i.Inject(i.Injector)),S(1,i.ICommandService),S(2,i.IUniverInstanceService),S(3,i.Inject(i.LifecycleService))],c.FUniver),c.FBase=v,c.FBaseInitialable=w,c.FEnum=m,c.FEventName=_,c.FUtil=E,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(c,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],i):(c=typeof globalThis<"u"?globalThis:c||self,i(c.UniverCoreFacade={},c.UniverCore,c.rxjs))})(this,(function(c,i,p){"use strict";var W=Object.defineProperty;var k=(c,i,p)=>i in c?W(c,i,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[i]=p;var u=(c,i,p)=>k(c,typeof i!="symbol"?i+"":i,p);class v extends i.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 f=Symbol("initializers"),R=Symbol("manualInit");class w extends i.Disposable{constructor(t){if(super(),this._injector=t,!!this.constructor[R])return;const r=this,s=Object.getPrototypeOf(this)[f];s&&s.forEach(function(o){o.apply(r,[t])})}_initialize(t,...e){}_runInitializers(...t){const e=Object.getPrototypeOf(this)[f];e!=null&&e.length&&e.forEach(n=>n.apply(this,t))}static _enableManualInit(){this[R]=!0}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{if(e==="_initialize"){let n=this.prototype[f];n||(n=[],this.prototype[f]=n),n.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 U=Object.getOwnPropertyDescriptor,I=(a,t,e,n)=>{for(var r=n>1?void 0:n?U(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},P=(a,t)=>(e,n)=>t(e,n,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,n)=>{this._blob.arrayBuffer().then(r=>{const s=new TextDecoder(t).decode(r);e(s)}).catch(r=>{n(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.buffer]),this}setDataFromString(t,e){const n=e!=null?e:"text/plain",r=new Blob([t],{type:n});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=I([P(1,i.Inject(i.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 i.AbsoluteRefType}get UniverInstanceType(){return i.UniverInstanceType}get LifecycleStages(){return i.LifecycleStages}get DataValidationType(){return i.DataValidationType}get DataValidationErrorStyle(){return i.DataValidationErrorStyle}get DataValidationRenderMode(){return i.DataValidationRenderMode}get DataValidationOperator(){return i.DataValidationOperator}get DataValidationStatus(){return i.DataValidationStatus}get CommandType(){return i.CommandType}get BaselineOffset(){return i.BaselineOffset}get BooleanNumber(){return i.BooleanNumber}get HorizontalAlign(){return i.HorizontalAlign}get TextDecoration(){return i.TextDecoration}get TextDirection(){return i.TextDirection}get VerticalAlign(){return i.VerticalAlign}get WrapStrategy(){return i.WrapStrategy}get BorderType(){return i.BorderType}get BorderStyleTypes(){return i.BorderStyleTypes}get AutoFillSeries(){return i.AutoFillSeries}get ColorType(){return i.ColorType}get CommonHideTypes(){return i.CommonHideTypes}get CopyPasteType(){return i.CopyPasteType}get DeleteDirection(){return i.DeleteDirection}get DeveloperMetadataVisibility(){return i.DeveloperMetadataVisibility}get Dimension(){return i.Dimension}get Direction(){return i.Direction}get InterpolationPointType(){return i.InterpolationPointType}get LocaleType(){return i.LocaleType}get MentionType(){return i.MentionType}get ProtectionType(){return i.ProtectionType}get RelativeDate(){return i.RelativeDate}get SheetTypes(){return i.SheetTypes}get ThemeColorType(){return i.ThemeColorType}};u(y,"_instance");let m=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 _=g;var x=Object.getOwnPropertyDescriptor,H=(a,t,e,n)=>{for(var r=n>1?void 0:n?x(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},B=(a,t)=>(e,n)=>t(e,n,a);c.FHooks=class extends v{constructor(t,e){super(),this._injector=t,this._lifecycleService=e}onStarting(t){return i.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===i.LifecycleStages.Starting)).subscribe(t))}onReady(t){return i.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===i.LifecycleStages.Ready)).subscribe(t))}onRendered(t){return i.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===i.LifecycleStages.Rendered)).subscribe(t))}onSteady(t){return i.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===i.LifecycleStages.Steady)).subscribe(t))}onBeforeUndo(t){return this._injector.get(i.ICommandService).beforeCommandExecuted(n=>{if(n.id===i.UndoCommand.id){const s=this._injector.get(i.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onUndo(t){return this._injector.get(i.ICommandService).onCommandExecuted(n=>{if(n.id===i.UndoCommand.id){const s=this._injector.get(i.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onBeforeRedo(t){return this._injector.get(i.ICommandService).beforeCommandExecuted(n=>{if(n.id===i.RedoCommand.id){const s=this._injector.get(i.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}onRedo(t){return this._injector.get(i.ICommandService).onCommandExecuted(n=>{if(n.id===i.RedoCommand.id){const s=this._injector.get(i.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}},c.FHooks=H([B(0,i.Inject(i.Injector)),B(1,i.Inject(i.LifecycleService))],c.FHooks);var M=Object.getOwnPropertyDescriptor,F=(a,t,e,n)=>{for(var r=n>1?void 0:n?M(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},V=(a,t)=>(e,n)=>t(e,n,a);let D=class extends w{constructor(a,t){super(t),this.doc=a}};D=F([V(1,i.Inject(i.Injector))],D);class L{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 i.Registry),this._eventRegistry.get(t)}registerEventHandler(t,e){const n=this._eventHandlerMap.get(t);return n?n.add(e):this._eventHandlerMap.set(t,new Set([e])),this._ensureEventRegistry(t).getData().length&&this._initEventHandler(t),i.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 n=this._ensureEventRegistry(t);if(n.delete(e),n.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 n=this._eventHandlerMap.get(t);n&&(!e||e.size===0)&&(e=new Map,this._eventHandlerRegisted.set(t,e),n==null||n.forEach(r=>{e==null||e.set(r,i.toDisposable(r()))}))}addEvent(t,e){return this._ensureEventRegistry(t).add(e),this._initEventHandler(t),i.toDisposable(()=>this.removeEvent(t,e))}fireEvent(t,e){var n;return(n=this._eventRegistry.get(t))==null||n.getData().forEach(r=>{r(e)}),e.cancel}}var $=Object.getOwnPropertyDescriptor,z=(a,t,e,n)=>{for(var r=n>1?void 0:n?$(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},O=(a,t)=>(e,n)=>t(e,n,a);let j=class extends v{constructor(a,t){super(),this._injector=a,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};j=z([O(0,i.Inject(i.Injector)),O(1,i.Inject(i.UserManagerService))],j);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 i.Rectangle}get numfmt(){return i.numfmt}get tools(){return i.Tools}};u(b,"_instance");let E=b;var N=Object.getOwnPropertyDescriptor,A=(a,t,e,n)=>{for(var r=n>1?void 0:n?N(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},S=(a,t)=>(e,n)=>t(e,n,a);const T=Symbol("initializers");c.FUniver=class extends i.Disposable{constructor(e,n,r,s){super();u(this,"_eventRegistry",new L);u(this,"registerEventHandler",(e,n)=>this._eventRegistry.registerEventHandler(e,n));this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=s,this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>i.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 i.Univer?e.__getInjector():e).createInstance(c.FUniver)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(n=>{if(n==="_initialize"){let r=this.prototype[T];r||(r=[],this.prototype[T]=r),r.push(e.prototype._initialize)}else n!=="constructor"&&(this.prototype[n]=e.prototype[n])}),Object.getOwnPropertyNames(e).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=e[n])})}_initCommandEvent(e){const n=e.get(i.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>n.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===i.RedoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Redo,l)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.Undo,()=>n.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===i.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Undo,l)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted,()=>n.onCommandExecuted((r,s)=>{const{id:o,type:d,params:h}=r;if(r.id!==i.RedoCommand.id&&r.id!==i.UndoCommand.id){const C={id:o,type:d,params:h,options:s};this.fireEvent(this.Event.CommandExecuted,C)}})))}_initBeforeCommandEvent(e){const n=e.get(i.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>n.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===i.RedoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeRedo,l),l.cancel)throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>n.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===i.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeUndo,l),l.cancel)throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>n.beforeCommandExecuted((r,s)=>{const{id:o,type:d,params:h}=r;if(r.id!==i.RedoCommand.id&&r.id!==i.UndoCommand.id){const C={id:o,type:d,params:h,options:s};if(this.fireEvent(this.Event.BeforeCommandExecute,C),C.cancel)throw new i.CanceledError}})))}_initUnitEvent(e){const n=e.get(i.IUniverInstanceService);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>n.unitDisposed$.subscribe(r=>{r.type===i.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:r.getUnitId(),unitType:r.type,snapshot:r.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>n.unitAdded$.subscribe(r=>{if(r.type===i.UniverInstanceType.UNIVER_DOC){const s=r,o=e.createInstance(D,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(i.LifecycleService).stage}undo(){return this._commandService.executeCommand(i.UndoCommand.id)}redo(){return this._commandService.executeCommand(i.RedoCommand.id)}toggleDarkMode(e){this._injector.get(i.ThemeService).setDarkMode(e)}loadLocales(e,n){this._injector.get(i.LocaleService).load({[e]:n})}setLocale(e){this._injector.get(i.LocaleService).setLocale(e)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((n,r)=>{e(n,r)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((n,r)=>{e(n,r)})}executeCommand(e,n,r){return this._commandService.executeCommand(e,n,r)}syncExecuteCommand(e,n,r){return this._commandService.syncExecuteCommand(e,n,r)}getHooks(){return this._injector.createInstance(c.FHooks)}get Enum(){return m.get()}get Event(){return _.get()}get Util(){return E.get()}addEvent(e,n){if(!e||!n)throw new Error("Cannot add empty event");return this._eventRegistry.addEvent(e,n)}fireEvent(e,n){return this._eventRegistry.fireEvent(e,n)}getUserManager(){return this._injector.createInstance(j)}newBlob(){return this._injector.createInstance(c.FBlob)}newRichText(e){return i.RichTextBuilder.create(e)}newRichTextValue(e){return i.RichTextValue.create(e)}newParagraphStyle(e){return i.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return i.ParagraphStyleValue.create(e)}newTextStyle(e){return i.TextStyleBuilder.create(e)}newTextStyleValue(e){return i.TextStyleValue.create(e)}newTextDecoration(e){return new i.TextDecorationBuilder(e)}},c.FUniver=A([S(0,i.Inject(i.Injector)),S(1,i.ICommandService),S(2,i.IUniverInstanceService),S(3,i.Inject(i.LifecycleService))],c.FUniver),c.FBase=v,c.FBaseInitialable=w,c.FEnum=m,c.FEventName=_,c.FUtil=E,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|