@univerjs/core 0.20.1 → 0.21.0-insiders.20260422-d7fcb4d
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 +1631 -1
- package/lib/cjs/index.js +20606 -9
- package/lib/es/facade.js +1608 -1
- package/lib/es/index.js +19944 -9
- package/lib/facade.js +1608 -1
- package/lib/index.js +19944 -9
- package/lib/types/common/unit.d.ts +3 -4
- package/lib/types/index.d.ts +1 -2
- package/lib/types/services/instance/instance.service.d.ts +23 -22
- package/lib/types/services/plugin/plugin.service.d.ts +5 -5
- package/lib/types/sheets/sheet-skeleton.d.ts +4 -0
- package/lib/types/slides/slide-data-model.d.ts +27 -0
- package/lib/types/types/const/const.d.ts +0 -8
- package/lib/types/types/enum/index.d.ts +0 -1
- package/lib/types/types/interfaces/i-drawing.d.ts +4 -0
- package/lib/types/types/interfaces/index.d.ts +0 -1
- package/lib/types/univer.d.ts +3 -21
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +9 -9
- package/package.json +7 -7
- package/LICENSE +0 -176
- package/lib/types/slides/slide-model.d.ts +0 -62
- package/lib/types/types/enum/prst-geom-type.d.ts +0 -118
- package/lib/types/types/interfaces/i-slide-data.d.ts +0 -167
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1,1631 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`rxjs`);var n=class extends e.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])})}};const r=Symbol(`initializers`),i=Symbol(`manualInit`);var a=class extends e.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 t!==`constructor`&&(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=t==null?`text/plain`:t;return this._blob=new Blob([e],{type: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,e.Inject)(e.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 t{static get(){if(this._instance)return this._instance;let e=new t;return this._instance=e,e}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 e in t.prototype)this[e]=t.prototype[e]}get AbsoluteRefType(){return e.AbsoluteRefType}get UniverInstanceType(){return e.UniverInstanceType}get LifecycleStages(){return e.LifecycleStages}get DataValidationType(){return e.DataValidationType}get DataValidationErrorStyle(){return e.DataValidationErrorStyle}get DataValidationRenderMode(){return e.DataValidationRenderMode}get DataValidationOperator(){return e.DataValidationOperator}get DataValidationStatus(){return e.DataValidationStatus}get CommandType(){return e.CommandType}get BaselineOffset(){return e.BaselineOffset}get BooleanNumber(){return e.BooleanNumber}get HorizontalAlign(){return e.HorizontalAlign}get TextDecoration(){return e.TextDecoration}get TextDirection(){return e.TextDirection}get VerticalAlign(){return e.VerticalAlign}get WrapStrategy(){return e.WrapStrategy}get BorderType(){return e.BorderType}get BorderStyleTypes(){return e.BorderStyleTypes}get AutoFillSeries(){return e.AutoFillSeries}get ColorType(){return e.ColorType}get CommonHideTypes(){return e.CommonHideTypes}get CopyPasteType(){return e.CopyPasteType}get DeleteDirection(){return e.DeleteDirection}get DeveloperMetadataVisibility(){return e.DeveloperMetadataVisibility}get Dimension(){return e.Dimension}get Direction(){return e.Direction}get InterpolationPointType(){return e.InterpolationPointType}get LocaleType(){return e.LocaleType}get MentionType(){return e.MentionType}get ProtectionType(){return e.ProtectionType}get RelativeDate(){return e.RelativeDate}get SheetTypes(){return e.SheetTypes}get ThemeColorType(){return e.ThemeColorType}};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 n{constructor(e,t){super(),this._injector=e,this._lifecycleService=t}onStarting(n){return(0,e.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,t.filter)(t=>t===e.LifecycleStages.Starting)).subscribe(n))}onReady(n){return(0,e.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,t.filter)(t=>t===e.LifecycleStages.Ready)).subscribe(n))}onRendered(n){return(0,e.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,t.filter)(t=>t===e.LifecycleStages.Rendered)).subscribe(n))}onSteady(n){return(0,e.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,t.filter)(t=>t===e.LifecycleStages.Steady)).subscribe(n))}onBeforeUndo(t){return this._injector.get(e.ICommandService).beforeCommandExecuted(n=>{if(n.id===e.UndoCommand.id){let n=this._injector.get(e.IUndoRedoService).pitchTopUndoElement();n&&t(n)}})}onUndo(t){return this._injector.get(e.ICommandService).onCommandExecuted(n=>{if(n.id===e.UndoCommand.id){let n=this._injector.get(e.IUndoRedoService).pitchTopUndoElement();n&&t(n)}})}onBeforeRedo(t){return this._injector.get(e.ICommandService).beforeCommandExecuted(n=>{if(n.id===e.RedoCommand.id){let n=this._injector.get(e.IUndoRedoService).pitchTopRedoElement();n&&t(n)}})}onRedo(t){return this._injector.get(e.ICommandService).onCommandExecuted(n=>{if(n.id===e.RedoCommand.id){let n=this._injector.get(e.IUndoRedoService).pitchTopRedoElement();n&&t(n)}})}};g=s([o(0,(0,e.Inject)(e.Injector)),o(1,(0,e.Inject)(e.LifecycleService))],g);let _=class extends a{constructor(e,t){super(t),this.doc=e}};_=s([o(1,(0,e.Inject)(e.Injector))],_);var v=class{constructor(){p(this,`_eventRegistry`,new Map),p(this,`_eventHandlerMap`,new Map),p(this,`_eventHandlerRegisted`,new Map)}_ensureEventRegistry(t){return this._eventRegistry.has(t)||this._eventRegistry.set(t,new e.Registry),this._eventRegistry.get(t)}registerEventHandler(t,n){let r=this._eventHandlerMap.get(t);return r?r.add(n):this._eventHandlerMap.set(t,new Set([n])),this._ensureEventRegistry(t).getData().length&&this._initEventHandler(t),(0,e.toDisposable)(()=>{var e,r,i;(e=this._eventHandlerMap.get(t))==null||e.delete(n),(r=this._eventHandlerRegisted.get(t))==null||(r=r.get(n))==null||r.dispose(),(i=this._eventHandlerRegisted.get(t))==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(t){let n=this._eventHandlerRegisted.get(t),r=this._eventHandlerMap.get(t);r&&(!n||n.size===0)&&(n=new Map,this._eventHandlerRegisted.set(t,n),r==null||r.forEach(t=>{n==null||n.set(t,(0,e.toDisposable)(t()))}))}addEvent(t,n){return this._ensureEventRegistry(t).add(n),this._initEventHandler(t),(0,e.toDisposable)(()=>this.removeEvent(t,n))}fireEvent(e,t){var n;return(n=this._eventRegistry.get(e))==null||n.getData().forEach(e=>{e(t)}),t.cancel}};let y=class extends n{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};y=s([o(0,(0,e.Inject)(e.Injector)),o(1,(0,e.Inject)(e.UserManagerService))],y);var b=class t{static get(){if(this._instance)return this._instance;let e=new t;return this._instance=e,e}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 e.Rectangle}get numfmt(){return e.numfmt}get tools(){return e.Tools}};p(b,`_instance`,void 0);var x;const S=Symbol(`initializers`);let C=x=class extends e.Disposable{static newAPI(t){return(t instanceof e.Univer?t.__getInjector():t).createInstance(x)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[S];t||(t=[],this.prototype[S]=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(t,n,r,i){super(),this._injector=t,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,p(this,`_eventRegistry`,new v),p(this,`registerEventHandler`,(e,t)=>this._eventRegistry.registerEventHandler(e,t)),this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>(0,e.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)[S];if(a){let e=this;a.forEach(function(n){n.apply(e,[t])})}}_initCommandEvent(t){let n=t.get(e.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>n.onCommandExecuted(t=>{let{id:n,type:r,params:i}=t;if(t.id===e.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(t=>{let{id:n,type:r,params:i}=t;if(t.id===e.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((t,n)=>{let{id:r,type:i,params:a}=t;if(t.id!==e.RedoCommand.id&&t.id!==e.UndoCommand.id){let e={id:r,type:i,params:a,options:n};this.fireEvent(this.Event.CommandExecuted,e)}})))}_initBeforeCommandEvent(t){let n=t.get(e.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>n.beforeCommandExecuted(t=>{let{id:n,type:r,params:i}=t;if(t.id===e.RedoCommand.id){let t={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeRedo,t),t.cancel)throw new e.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>n.beforeCommandExecuted(t=>{let{id:n,type:r,params:i}=t;if(t.id===e.UndoCommand.id){let t={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeUndo,t),t.cancel)throw new e.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>n.beforeCommandExecuted((t,n)=>{let{id:r,type:i,params:a}=t;if(t.id!==e.RedoCommand.id&&t.id!==e.UndoCommand.id){let t={id:r,type:i,params:a,options:n};if(this.fireEvent(this.Event.BeforeCommandExecute,t),t.cancel)throw new e.CanceledError}})))}_initUnitEvent(t){let n=t.get(e.IUniverInstanceService);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>n.unitDisposed$.subscribe(t=>{t.type===e.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:t.getUnitId(),unitType:t.type,snapshot:t.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>n.unitAdded$.subscribe(n=>{if(n.type===e.UniverInstanceType.UNIVER_DOC){let e=n,r=t.createInstance(_,e);this.fireEvent(this.Event.DocCreated,{unitId:n.getUnitId(),type:n.type,doc:r,unit:r})}})))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(e.LifecycleService).stage}undo(){return this._commandService.executeCommand(e.UndoCommand.id)}redo(){return this._commandService.executeCommand(e.RedoCommand.id)}toggleDarkMode(t){this._injector.get(e.ThemeService).setDarkMode(t)}loadLocales(t,n){this._injector.get(e.LocaleService).load({[t]:n})}setLocale(t){this._injector.get(e.LocaleService).setLocale(t)}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(g)}get Enum(){return m.get()}get Event(){return h.get()}get Util(){return b.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(y)}newBlob(){return this._injector.createInstance(l,null)}newRichText(t){return e.RichTextBuilder.create(t)}newRichTextValue(t){return e.RichTextValue.create(t)}newParagraphStyle(t){return e.ParagraphStyleBuilder.create(t)}newParagraphStyleValue(t){return e.ParagraphStyleValue.create(t)}newTextStyle(t){return e.TextStyleBuilder.create(t)}newTextStyleValue(t){return e.TextStyleValue.create(t)}newTextDecoration(t){return new e.TextDecorationBuilder(t)}};C=x=s([o(0,(0,e.Inject)(e.Injector)),o(1,e.ICommandService),o(2,e.IUniverInstanceService),o(3,(0,e.Inject)(e.LifecycleService))],C),exports.FBase=n,exports.FBaseInitialable=a,Object.defineProperty(exports,`FBlob`,{enumerable:!0,get:function(){return l}}),exports.FEnum=m,exports.FEventName=h,Object.defineProperty(exports,`FHooks`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`FUniver`,{enumerable:!0,get:function(){return C}}),exports.FUtil=b;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _univerjs_core = require("@univerjs/core");
|
|
3
|
+
let rxjs = require("rxjs");
|
|
4
|
+
|
|
5
|
+
//#region src/facade/f-base.ts
|
|
6
|
+
/**
|
|
7
|
+
* `FBase` is a base class for all facade classes.
|
|
8
|
+
* It provides a way to extend classes with static and instance methods.
|
|
9
|
+
* The `_initialize` as a special method that will be called after the constructor. You should never call it directly.
|
|
10
|
+
* @ignore
|
|
11
|
+
*/
|
|
12
|
+
var FBase = class extends _univerjs_core.Disposable {
|
|
13
|
+
/**
|
|
14
|
+
* @ignore
|
|
15
|
+
*/
|
|
16
|
+
static extend(source) {
|
|
17
|
+
Object.getOwnPropertyNames(source.prototype).forEach((name) => {
|
|
18
|
+
if (name !== "constructor") this.prototype[name] = source.prototype[name];
|
|
19
|
+
});
|
|
20
|
+
Object.getOwnPropertyNames(source).forEach((name) => {
|
|
21
|
+
if (name !== "prototype" && name !== "name" && name !== "length") this[name] = source[name];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @ignore
|
|
27
|
+
*/
|
|
28
|
+
const InitializerSymbol$1 = Symbol("initializers");
|
|
29
|
+
/**
|
|
30
|
+
* @ignore
|
|
31
|
+
*/
|
|
32
|
+
const ManualInitSymbol = Symbol("manualInit");
|
|
33
|
+
/**
|
|
34
|
+
* @ignore
|
|
35
|
+
* @hideconstructor
|
|
36
|
+
*/
|
|
37
|
+
var FBaseInitialable = class extends _univerjs_core.Disposable {
|
|
38
|
+
constructor(_injector) {
|
|
39
|
+
super();
|
|
40
|
+
this._injector = _injector;
|
|
41
|
+
const Ctor = this.constructor;
|
|
42
|
+
if (Boolean(Ctor[ManualInitSymbol])) return;
|
|
43
|
+
const self = this;
|
|
44
|
+
const initializers = Object.getPrototypeOf(this)[InitializerSymbol$1];
|
|
45
|
+
if (initializers) initializers.forEach(function(fn) {
|
|
46
|
+
fn.apply(self, [_injector]);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @ignore
|
|
51
|
+
*/
|
|
52
|
+
_initialize(injector, ..._rest) {}
|
|
53
|
+
_runInitializers(...args) {
|
|
54
|
+
const initializers = Object.getPrototypeOf(this)[InitializerSymbol$1];
|
|
55
|
+
if (initializers === null || initializers === void 0 ? void 0 : initializers.length) initializers.forEach((fn) => fn.apply(this, args));
|
|
56
|
+
}
|
|
57
|
+
static _enableManualInit() {
|
|
58
|
+
this[ManualInitSymbol] = true;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @ignore
|
|
62
|
+
*/
|
|
63
|
+
static extend(source) {
|
|
64
|
+
Object.getOwnPropertyNames(source.prototype).forEach((name) => {
|
|
65
|
+
if (name === "_initialize") {
|
|
66
|
+
let initializers = this.prototype[InitializerSymbol$1];
|
|
67
|
+
if (!initializers) {
|
|
68
|
+
initializers = [];
|
|
69
|
+
this.prototype[InitializerSymbol$1] = initializers;
|
|
70
|
+
}
|
|
71
|
+
initializers.push(source.prototype._initialize);
|
|
72
|
+
} else if (name !== "constructor") this.prototype[name] = source.prototype[name];
|
|
73
|
+
});
|
|
74
|
+
Object.getOwnPropertyNames(source).forEach((name) => {
|
|
75
|
+
if (name !== "prototype" && name !== "name" && name !== "length") this[name] = source[name];
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
|
|
82
|
+
function __decorateParam(paramIndex, decorator) {
|
|
83
|
+
return function(target, key) {
|
|
84
|
+
decorator(target, key, paramIndex);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
|
|
90
|
+
function __decorate(decorators, target, key, desc) {
|
|
91
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
92
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
93
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
94
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/facade/f-blob.ts
|
|
99
|
+
var _FBlob;
|
|
100
|
+
let FBlob = _FBlob = class FBlob extends FBase {
|
|
101
|
+
constructor(_blob, _injector) {
|
|
102
|
+
super();
|
|
103
|
+
this._blob = _blob;
|
|
104
|
+
this._injector = _injector;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Returns a copy of this blob.
|
|
108
|
+
* @returns a new blob by copying the current blob
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* const blob = univerAPI.newBlob();
|
|
112
|
+
* const newBlob = blob.copyBlob();
|
|
113
|
+
* console.log(newBlob);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
copyBlob() {
|
|
117
|
+
return this._injector.createInstance(_FBlob, this._blob);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Return the data inside this object as a blob converted to the specified content type.
|
|
121
|
+
* @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
|
|
122
|
+
* @returns a new blob by converting the current blob to the specified content type
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* const blob = univerAPI.newBlob();
|
|
126
|
+
* const newBlob = blob.getAs('text/plain');
|
|
127
|
+
* console.log(newBlob);
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
getAs(contentType) {
|
|
131
|
+
const newBlob = this.copyBlob();
|
|
132
|
+
newBlob.setContentType(contentType);
|
|
133
|
+
return newBlob;
|
|
134
|
+
}
|
|
135
|
+
getDataAsString(charset) {
|
|
136
|
+
if (this._blob === null) return Promise.resolve("");
|
|
137
|
+
if (charset === void 0) return this._blob.text();
|
|
138
|
+
return new Promise((resolve, reject) => {
|
|
139
|
+
this._blob.arrayBuffer().then((arrayBuffer) => {
|
|
140
|
+
resolve(new TextDecoder(charset).decode(arrayBuffer));
|
|
141
|
+
}).catch((error) => {
|
|
142
|
+
reject(/* @__PURE__ */ new Error(`Failed to read Blob as ArrayBuffer: ${error.message}`));
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Gets the data stored in this blob.
|
|
148
|
+
* @returns the blob content as a byte array
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* const blob = univerAPI.newBlob();
|
|
152
|
+
* const bytes = await blob.getBytes();
|
|
153
|
+
* console.log(bytes);
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
getBytes() {
|
|
157
|
+
if (!this._blob) return Promise.reject(/* @__PURE__ */ new Error("Blob is undefined or null."));
|
|
158
|
+
return this._blob.arrayBuffer().then((buffer) => new Uint8Array(buffer));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Sets the data stored in this blob.
|
|
162
|
+
* @param bytes a byte array
|
|
163
|
+
* @returns the blob object
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* const blob = univerAPI.newBlob();
|
|
167
|
+
* const bytes = new Uint8Array(10);
|
|
168
|
+
* blob.setBytes(bytes);
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
setBytes(bytes) {
|
|
172
|
+
this._blob = new Blob([bytes.buffer]);
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
setDataFromString(data, contentType) {
|
|
176
|
+
this._blob = new Blob([data], { type: contentType !== null && contentType !== void 0 ? contentType : "text/plain" });
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Gets the content type of the data stored in this blob.
|
|
181
|
+
* @returns the content type
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* const blob = univerAPI.newBlob();
|
|
185
|
+
* const contentType = blob.getContentType();
|
|
186
|
+
* console.log(contentType);
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
getContentType() {
|
|
190
|
+
var _this$_blob;
|
|
191
|
+
return (_this$_blob = this._blob) === null || _this$_blob === void 0 ? void 0 : _this$_blob.type;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Sets the content type of the data stored in this blob.
|
|
195
|
+
* @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
|
|
196
|
+
* @returns the blob object
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* const blob = univerAPI.newBlob();
|
|
200
|
+
* blob.setContentType('text/plain');
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
setContentType(contentType) {
|
|
204
|
+
var _this$_blob2;
|
|
205
|
+
this._blob = (_this$_blob2 = this._blob) === null || _this$_blob2 === void 0 ? void 0 : _this$_blob2.slice(0, this._blob.size, contentType);
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
FBlob = _FBlob = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector))], FBlob);
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
|
|
213
|
+
function _typeof(o) {
|
|
214
|
+
"@babel/helpers - typeof";
|
|
215
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
216
|
+
return typeof o;
|
|
217
|
+
} : function(o) {
|
|
218
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
219
|
+
}, _typeof(o);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
|
|
224
|
+
function toPrimitive(t, r) {
|
|
225
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
226
|
+
var e = t[Symbol.toPrimitive];
|
|
227
|
+
if (void 0 !== e) {
|
|
228
|
+
var i = e.call(t, r || "default");
|
|
229
|
+
if ("object" != _typeof(i)) return i;
|
|
230
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
231
|
+
}
|
|
232
|
+
return ("string" === r ? String : Number)(t);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
|
|
237
|
+
function toPropertyKey(t) {
|
|
238
|
+
var i = toPrimitive(t, "string");
|
|
239
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
|
|
244
|
+
function _defineProperty(e, r, t) {
|
|
245
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
246
|
+
value: t,
|
|
247
|
+
enumerable: !0,
|
|
248
|
+
configurable: !0,
|
|
249
|
+
writable: !0
|
|
250
|
+
}) : e[r] = t, e;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/facade/f-enum.ts
|
|
255
|
+
/**
|
|
256
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
257
|
+
*
|
|
258
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
259
|
+
* you may not use this file except in compliance with the License.
|
|
260
|
+
* You may obtain a copy of the License at
|
|
261
|
+
*
|
|
262
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
263
|
+
*
|
|
264
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
265
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
266
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
267
|
+
* See the License for the specific language governing permissions and
|
|
268
|
+
* limitations under the License.
|
|
269
|
+
*/
|
|
270
|
+
/**
|
|
271
|
+
* @hideconstructor
|
|
272
|
+
*/
|
|
273
|
+
var FEnum = class FEnum {
|
|
274
|
+
static get() {
|
|
275
|
+
if (this._instance) return this._instance;
|
|
276
|
+
const instance = new FEnum();
|
|
277
|
+
this._instance = instance;
|
|
278
|
+
return instance;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* @ignore
|
|
282
|
+
*/
|
|
283
|
+
static extend(source) {
|
|
284
|
+
Object.getOwnPropertyNames(source.prototype).forEach((name) => {
|
|
285
|
+
if (name !== "constructor") this.prototype[name] = source.prototype[name];
|
|
286
|
+
});
|
|
287
|
+
Object.getOwnPropertyNames(source).forEach((name) => {
|
|
288
|
+
if (name !== "prototype" && name !== "name" && name !== "length") this[name] = source[name];
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
constructor() {
|
|
292
|
+
for (const key in FEnum.prototype) this[key] = FEnum.prototype[key];
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Defines different types of absolute references
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```ts
|
|
299
|
+
* console.log(univerAPI.Enum.AbsoluteRefType);
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
get AbsoluteRefType() {
|
|
303
|
+
return _univerjs_core.AbsoluteRefType;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Defines different types of Univer instances
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* console.log(univerAPI.Enum.UniverInstanceType.UNIVER_SHEET);
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
get UniverInstanceType() {
|
|
314
|
+
return _univerjs_core.UniverInstanceType;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Represents different stages in the lifecycle
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts
|
|
321
|
+
* console.log(univerAPI.Enum.LifecycleStages.Rendered);
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
get LifecycleStages() {
|
|
325
|
+
return _univerjs_core.LifecycleStages;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Different types of data validation
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* console.log(univerAPI.Enum.DataValidationType.LIST);
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
335
|
+
get DataValidationType() {
|
|
336
|
+
return _univerjs_core.DataValidationType;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Different error display styles
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```ts
|
|
343
|
+
* console.log(univerAPI.Enum.DataValidationErrorStyle.WARNING);
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
get DataValidationErrorStyle() {
|
|
347
|
+
return _univerjs_core.DataValidationErrorStyle;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Different validation rendering modes
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```ts
|
|
354
|
+
* console.log(univerAPI.Enum.DataValidationRenderMode.TEXT);
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
get DataValidationRenderMode() {
|
|
358
|
+
return _univerjs_core.DataValidationRenderMode;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Different validation operators
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts
|
|
365
|
+
* console.log(univerAPI.Enum.DataValidationOperator.BETWEEN);
|
|
366
|
+
* ```
|
|
367
|
+
*/
|
|
368
|
+
get DataValidationOperator() {
|
|
369
|
+
return _univerjs_core.DataValidationOperator;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Different validation states
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```ts
|
|
376
|
+
* console.log(univerAPI.Enum.DataValidationStatus.VALID);
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
get DataValidationStatus() {
|
|
380
|
+
return _univerjs_core.DataValidationStatus;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Different types of commands
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```ts
|
|
387
|
+
* console.log(univerAPI.Enum.CommandType.COMMAND);
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
get CommandType() {
|
|
391
|
+
return _univerjs_core.CommandType;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Different baseline offsets for text baseline positioning
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* console.log(univerAPI.Enum.BaselineOffset.SUPERSCRIPT);
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
get BaselineOffset() {
|
|
402
|
+
return _univerjs_core.BaselineOffset;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Boolean number representations
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```ts
|
|
409
|
+
* console.log(univerAPI.Enum.BooleanNumber.TRUE);
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
412
|
+
get BooleanNumber() {
|
|
413
|
+
return _univerjs_core.BooleanNumber;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Different horizontal text alignment options
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```ts
|
|
420
|
+
* console.log(univerAPI.Enum.HorizontalAlign.CENTER);
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
get HorizontalAlign() {
|
|
424
|
+
return _univerjs_core.HorizontalAlign;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Different text decoration styles
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* console.log(univerAPI.Enum.TextDecoration.DOUBLE);
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
get TextDecoration() {
|
|
435
|
+
return _univerjs_core.TextDecoration;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Different text direction options
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* console.log(univerAPI.Enum.TextDirection.LEFT_TO_RIGHT);
|
|
443
|
+
* ```
|
|
444
|
+
*/
|
|
445
|
+
get TextDirection() {
|
|
446
|
+
return _univerjs_core.TextDirection;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Different vertical text alignment options
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```ts
|
|
453
|
+
* console.log(univerAPI.Enum.VerticalAlign.MIDDLE);
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
get VerticalAlign() {
|
|
457
|
+
return _univerjs_core.VerticalAlign;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Different wrap strategy options
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* ```ts
|
|
464
|
+
* console.log(univerAPI.Enum.WrapStrategy.WRAP);
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
get WrapStrategy() {
|
|
468
|
+
return _univerjs_core.WrapStrategy;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Different border types
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```ts
|
|
475
|
+
* console.log(univerAPI.Enum.BorderType.OUTSIDE);
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
478
|
+
get BorderType() {
|
|
479
|
+
return _univerjs_core.BorderType;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Different border style types
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```ts
|
|
486
|
+
* console.log(univerAPI.Enum.BorderStyleTypes.NONE);
|
|
487
|
+
* ```
|
|
488
|
+
*/
|
|
489
|
+
get BorderStyleTypes() {
|
|
490
|
+
return _univerjs_core.BorderStyleTypes;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Auto fill series types
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* console.log(univerAPI.Enum.AutoFillSeries.ALTERNATE_SERIES);
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
500
|
+
get AutoFillSeries() {
|
|
501
|
+
return _univerjs_core.AutoFillSeries;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Color types
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```ts
|
|
508
|
+
* console.log(univerAPI.Enum.ColorType.RGB);
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
get ColorType() {
|
|
512
|
+
return _univerjs_core.ColorType;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Common hide types
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```ts
|
|
519
|
+
* console.log(univerAPI.Enum.CommonHideTypes.ON);
|
|
520
|
+
* ```
|
|
521
|
+
*/
|
|
522
|
+
get CommonHideTypes() {
|
|
523
|
+
return _univerjs_core.CommonHideTypes;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Copy paste types
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* ```ts
|
|
530
|
+
* console.log(univerAPI.Enum.CopyPasteType.PASTE_VALUES);
|
|
531
|
+
* ```
|
|
532
|
+
*/
|
|
533
|
+
get CopyPasteType() {
|
|
534
|
+
return _univerjs_core.CopyPasteType;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Delete direction types
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```ts
|
|
541
|
+
* console.log(univerAPI.Enum.DeleteDirection.LEFT);
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
get DeleteDirection() {
|
|
545
|
+
return _univerjs_core.DeleteDirection;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Developer metadata visibility types
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* ```ts
|
|
552
|
+
* console.log(univerAPI.Enum.DeveloperMetadataVisibility.DOCUMENT);
|
|
553
|
+
* ```
|
|
554
|
+
*/
|
|
555
|
+
get DeveloperMetadataVisibility() {
|
|
556
|
+
return _univerjs_core.DeveloperMetadataVisibility;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Dimension types
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* ```ts
|
|
563
|
+
* console.log(univerAPI.Enum.Dimension.ROWS);
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
566
|
+
get Dimension() {
|
|
567
|
+
return _univerjs_core.Dimension;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Direction types
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```ts
|
|
574
|
+
* console.log(univerAPI.Enum.Direction.UP);
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
get Direction() {
|
|
578
|
+
return _univerjs_core.Direction;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Interpolation point types
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* ```ts
|
|
585
|
+
* console.log(univerAPI.Enum.InterpolationPointType.NUMBER);
|
|
586
|
+
* ```
|
|
587
|
+
*/
|
|
588
|
+
get InterpolationPointType() {
|
|
589
|
+
return _univerjs_core.InterpolationPointType;
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Locale types
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```ts
|
|
596
|
+
* console.log(univerAPI.Enum.LocaleType.EN_US);
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
get LocaleType() {
|
|
600
|
+
return _univerjs_core.LocaleType;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Mention types
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```ts
|
|
607
|
+
* console.log(univerAPI.Enum.MentionType.PERSON);
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
get MentionType() {
|
|
611
|
+
return _univerjs_core.MentionType;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Protection types
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* ```ts
|
|
618
|
+
* console.log(univerAPI.Enum.ProtectionType.RANGE);
|
|
619
|
+
* ```
|
|
620
|
+
*/
|
|
621
|
+
get ProtectionType() {
|
|
622
|
+
return _univerjs_core.ProtectionType;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Relative date types
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* ```ts
|
|
629
|
+
* console.log(univerAPI.Enum.RelativeDate.TODAY);
|
|
630
|
+
* ```
|
|
631
|
+
*/
|
|
632
|
+
get RelativeDate() {
|
|
633
|
+
return _univerjs_core.RelativeDate;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Sheet types
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```ts
|
|
640
|
+
* console.log(univerAPI.Enum.SheetTypes.GRID);
|
|
641
|
+
* ```
|
|
642
|
+
*/
|
|
643
|
+
get SheetTypes() {
|
|
644
|
+
return _univerjs_core.SheetTypes;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Theme color types
|
|
648
|
+
*
|
|
649
|
+
* @example
|
|
650
|
+
* ```ts
|
|
651
|
+
* console.log(univerAPI.Enum.ThemeColorType.ACCENT1);
|
|
652
|
+
* ```
|
|
653
|
+
*/
|
|
654
|
+
get ThemeColorType() {
|
|
655
|
+
return _univerjs_core.ThemeColorType;
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
_defineProperty(FEnum, "_instance", void 0);
|
|
659
|
+
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/facade/f-event.ts
|
|
662
|
+
/**
|
|
663
|
+
* @hideconstructor
|
|
664
|
+
*/
|
|
665
|
+
var FEventName = class FEventName {
|
|
666
|
+
static get() {
|
|
667
|
+
if (this._instance) return this._instance;
|
|
668
|
+
const instance = new FEventName();
|
|
669
|
+
this._instance = instance;
|
|
670
|
+
return instance;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* @ignore
|
|
674
|
+
*/
|
|
675
|
+
static extend(source) {
|
|
676
|
+
Object.getOwnPropertyNames(source.prototype).forEach((name) => {
|
|
677
|
+
if (name !== "constructor") this.prototype[name] = source.prototype[name];
|
|
678
|
+
});
|
|
679
|
+
Object.getOwnPropertyNames(source).forEach((name) => {
|
|
680
|
+
if (name !== "prototype" && name !== "name" && name !== "length") this[name] = source[name];
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
constructor() {
|
|
684
|
+
for (const key in FEventName.prototype) this[key] = FEventName.prototype[key];
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Event fired when a document is created
|
|
688
|
+
* @see {@link IDocCreatedParam}
|
|
689
|
+
* @example
|
|
690
|
+
* ```ts
|
|
691
|
+
* const disposable = univerAPI.addEvent(univerAPI.Event.DocCreated, (params) => {
|
|
692
|
+
* const { unitId, type, doc, unit } = params;
|
|
693
|
+
* console.log('doc created', params);
|
|
694
|
+
* });
|
|
695
|
+
*
|
|
696
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
697
|
+
* ```
|
|
698
|
+
*/
|
|
699
|
+
get DocCreated() {
|
|
700
|
+
return "DocCreated";
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Event fired when a document is disposed
|
|
704
|
+
* @see {@link IDocDisposedEvent}
|
|
705
|
+
* @example
|
|
706
|
+
* ```ts
|
|
707
|
+
* const disposable = univerAPI.addEvent(univerAPI.Event.DocDisposed, (params) => {
|
|
708
|
+
* const { unitId, unitType, snapshot } = params;
|
|
709
|
+
* console.log('doc disposed', params);
|
|
710
|
+
* });
|
|
711
|
+
*
|
|
712
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
713
|
+
* ```
|
|
714
|
+
*/
|
|
715
|
+
get DocDisposed() {
|
|
716
|
+
return "DocDisposed";
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Event fired when life cycle is changed
|
|
720
|
+
* @see {@link ILifeCycleChangedEvent}
|
|
721
|
+
* @example
|
|
722
|
+
* ```ts
|
|
723
|
+
* const disposable = univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (params) => {
|
|
724
|
+
* const { stage } = params;
|
|
725
|
+
* console.log('life cycle changed', params);
|
|
726
|
+
* });
|
|
727
|
+
*
|
|
728
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
729
|
+
* ```
|
|
730
|
+
*/
|
|
731
|
+
get LifeCycleChanged() {
|
|
732
|
+
return "LifeCycleChanged";
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Event fired when a redo command is executed
|
|
736
|
+
* @see {@link ICommandEvent}
|
|
737
|
+
* @example
|
|
738
|
+
* ```ts
|
|
739
|
+
* const disposable = univerAPI.addEvent(univerAPI.Event.Redo, (event) => {
|
|
740
|
+
* const { params, id, type } = event;
|
|
741
|
+
* console.log('redo command executed', event);
|
|
742
|
+
* });
|
|
743
|
+
*
|
|
744
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
745
|
+
* ```
|
|
746
|
+
*/
|
|
747
|
+
get Redo() {
|
|
748
|
+
return "Redo";
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Event fired when an undo command is executed
|
|
752
|
+
* @see {@link ICommandEvent}
|
|
753
|
+
* @example
|
|
754
|
+
* ```ts
|
|
755
|
+
* const disposable = univerAPI.addEvent(univerAPI.Event.Undo, (event) => {
|
|
756
|
+
* const { params, id, type } = event;
|
|
757
|
+
* console.log('undo command executed', event);
|
|
758
|
+
* });
|
|
759
|
+
*
|
|
760
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
761
|
+
* ```
|
|
762
|
+
*/
|
|
763
|
+
get Undo() {
|
|
764
|
+
return "Undo";
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Event fired before a redo command is executed
|
|
768
|
+
* @see {@link ICommandEvent}
|
|
769
|
+
* @example
|
|
770
|
+
* ```ts
|
|
771
|
+
* const disposable = univerAPI.addEvent(univerAPI.Event.BeforeRedo, (event) => {
|
|
772
|
+
* const { params, id, type } = event;
|
|
773
|
+
* console.log('before redo command executed', event);
|
|
774
|
+
*
|
|
775
|
+
* // Cancel the redo operation
|
|
776
|
+
* event.cancel = true;
|
|
777
|
+
* });
|
|
778
|
+
*
|
|
779
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
780
|
+
* ```
|
|
781
|
+
*/
|
|
782
|
+
get BeforeRedo() {
|
|
783
|
+
return "BeforeRedo";
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Event fired before an undo command is executed
|
|
787
|
+
* @see {@link ICommandEvent}
|
|
788
|
+
* @example
|
|
789
|
+
* ```ts
|
|
790
|
+
* const disposable = univerAPI.addEvent(univerAPI.Event.BeforeUndo, (event) => {
|
|
791
|
+
* const { params, id, type } = event;
|
|
792
|
+
* console.log('before undo command executed', event);
|
|
793
|
+
*
|
|
794
|
+
* // Cancel the undo operation
|
|
795
|
+
* event.cancel = true;
|
|
796
|
+
* });
|
|
797
|
+
*
|
|
798
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
get BeforeUndo() {
|
|
802
|
+
return "BeforeUndo";
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Event fired when a command is executed
|
|
806
|
+
* @see {@link ICommandEvent}
|
|
807
|
+
* @example
|
|
808
|
+
* ```ts
|
|
809
|
+
* const disposable = univerAPI.addEvent(univerAPI.Event.CommandExecuted, (event) => {
|
|
810
|
+
* const { params, id, type, options } = event;
|
|
811
|
+
* console.log('command executed', event);
|
|
812
|
+
* });
|
|
813
|
+
*
|
|
814
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
815
|
+
* ```
|
|
816
|
+
*/
|
|
817
|
+
get CommandExecuted() {
|
|
818
|
+
return "CommandExecuted";
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Event fired before a command is executed
|
|
822
|
+
* @see {@link ICommandEvent}
|
|
823
|
+
* @example
|
|
824
|
+
* ```ts
|
|
825
|
+
* const disposable = univerAPI.addEvent(univerAPI.Event.BeforeCommandExecute, (event) => {
|
|
826
|
+
* const { params, id, type, options } = event;
|
|
827
|
+
* console.log('before command executed', event);
|
|
828
|
+
*
|
|
829
|
+
* // Cancel the command execution
|
|
830
|
+
* event.cancel = true;
|
|
831
|
+
* });
|
|
832
|
+
*
|
|
833
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
834
|
+
* ```
|
|
835
|
+
*/
|
|
836
|
+
get BeforeCommandExecute() {
|
|
837
|
+
return "BeforeCommandExecute";
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
_defineProperty(FEventName, "_instance", void 0);
|
|
841
|
+
|
|
842
|
+
//#endregion
|
|
843
|
+
//#region src/facade/f-hooks.ts
|
|
844
|
+
let FHooks = class FHooks extends FBase {
|
|
845
|
+
constructor(_injector, _lifecycleService) {
|
|
846
|
+
super();
|
|
847
|
+
this._injector = _injector;
|
|
848
|
+
this._lifecycleService = _lifecycleService;
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* @param callback
|
|
852
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
853
|
+
*/
|
|
854
|
+
onStarting(callback) {
|
|
855
|
+
return (0, _univerjs_core.toDisposable)(this._lifecycleService.lifecycle$.pipe((0, rxjs.filter)((lifecycle) => lifecycle === _univerjs_core.LifecycleStages.Starting)).subscribe(callback));
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* @param callback
|
|
859
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
860
|
+
*/
|
|
861
|
+
onReady(callback) {
|
|
862
|
+
return (0, _univerjs_core.toDisposable)(this._lifecycleService.lifecycle$.pipe((0, rxjs.filter)((lifecycle) => lifecycle === _univerjs_core.LifecycleStages.Ready)).subscribe(callback));
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* @param callback
|
|
866
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
867
|
+
*/
|
|
868
|
+
onRendered(callback) {
|
|
869
|
+
return (0, _univerjs_core.toDisposable)(this._lifecycleService.lifecycle$.pipe((0, rxjs.filter)((lifecycle) => lifecycle === _univerjs_core.LifecycleStages.Rendered)).subscribe(callback));
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* @param callback
|
|
873
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
874
|
+
*/
|
|
875
|
+
onSteady(callback) {
|
|
876
|
+
return (0, _univerjs_core.toDisposable)(this._lifecycleService.lifecycle$.pipe((0, rxjs.filter)((lifecycle) => lifecycle === _univerjs_core.LifecycleStages.Steady)).subscribe(callback));
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* @param callback
|
|
880
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeUndo, (event) => {})` as instead
|
|
881
|
+
*/
|
|
882
|
+
onBeforeUndo(callback) {
|
|
883
|
+
return this._injector.get(_univerjs_core.ICommandService).beforeCommandExecuted((command) => {
|
|
884
|
+
if (command.id === _univerjs_core.UndoCommand.id) {
|
|
885
|
+
const action = this._injector.get(_univerjs_core.IUndoRedoService).pitchTopUndoElement();
|
|
886
|
+
if (action) callback(action);
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* @param callback
|
|
892
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.Undo, (event) => {})` as instead
|
|
893
|
+
*/
|
|
894
|
+
onUndo(callback) {
|
|
895
|
+
return this._injector.get(_univerjs_core.ICommandService).onCommandExecuted((command) => {
|
|
896
|
+
if (command.id === _univerjs_core.UndoCommand.id) {
|
|
897
|
+
const action = this._injector.get(_univerjs_core.IUndoRedoService).pitchTopUndoElement();
|
|
898
|
+
if (action) callback(action);
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* @param callback
|
|
904
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeRedo, (event) => {})` as instead
|
|
905
|
+
*/
|
|
906
|
+
onBeforeRedo(callback) {
|
|
907
|
+
return this._injector.get(_univerjs_core.ICommandService).beforeCommandExecuted((command) => {
|
|
908
|
+
if (command.id === _univerjs_core.RedoCommand.id) {
|
|
909
|
+
const action = this._injector.get(_univerjs_core.IUndoRedoService).pitchTopRedoElement();
|
|
910
|
+
if (action) callback(action);
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* @param callback
|
|
916
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.Redo, (event) => {})` as instead
|
|
917
|
+
*/
|
|
918
|
+
onRedo(callback) {
|
|
919
|
+
return this._injector.get(_univerjs_core.ICommandService).onCommandExecuted((command) => {
|
|
920
|
+
if (command.id === _univerjs_core.RedoCommand.id) {
|
|
921
|
+
const action = this._injector.get(_univerjs_core.IUndoRedoService).pitchTopRedoElement();
|
|
922
|
+
if (action) callback(action);
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
FHooks = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.LifecycleService))], FHooks);
|
|
928
|
+
|
|
929
|
+
//#endregion
|
|
930
|
+
//#region src/facade/f-doc.ts
|
|
931
|
+
let FDoc = class FDoc extends FBaseInitialable {
|
|
932
|
+
constructor(doc, _injector) {
|
|
933
|
+
super(_injector);
|
|
934
|
+
this.doc = doc;
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
FDoc = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector))], FDoc);
|
|
938
|
+
|
|
939
|
+
//#endregion
|
|
940
|
+
//#region src/facade/f-event-registry.ts
|
|
941
|
+
var FEventRegistry = class {
|
|
942
|
+
constructor() {
|
|
943
|
+
_defineProperty(this, "_eventRegistry", /* @__PURE__ */ new Map());
|
|
944
|
+
_defineProperty(this, "_eventHandlerMap", /* @__PURE__ */ new Map());
|
|
945
|
+
_defineProperty(this, "_eventHandlerRegisted", /* @__PURE__ */ new Map());
|
|
946
|
+
}
|
|
947
|
+
_ensureEventRegistry(event) {
|
|
948
|
+
if (!this._eventRegistry.has(event)) this._eventRegistry.set(event, new _univerjs_core.Registry());
|
|
949
|
+
return this._eventRegistry.get(event);
|
|
950
|
+
}
|
|
951
|
+
registerEventHandler(event, handler) {
|
|
952
|
+
const current = this._eventHandlerMap.get(event);
|
|
953
|
+
if (current) current.add(handler);
|
|
954
|
+
else this._eventHandlerMap.set(event, new Set([handler]));
|
|
955
|
+
if (this._ensureEventRegistry(event).getData().length) this._initEventHandler(event);
|
|
956
|
+
return (0, _univerjs_core.toDisposable)(() => {
|
|
957
|
+
var _this$_eventHandlerMa, _this$_eventHandlerRe, _this$_eventHandlerRe2;
|
|
958
|
+
(_this$_eventHandlerMa = this._eventHandlerMap.get(event)) === null || _this$_eventHandlerMa === void 0 || _this$_eventHandlerMa.delete(handler);
|
|
959
|
+
(_this$_eventHandlerRe = this._eventHandlerRegisted.get(event)) === null || _this$_eventHandlerRe === void 0 || (_this$_eventHandlerRe = _this$_eventHandlerRe.get(handler)) === null || _this$_eventHandlerRe === void 0 || _this$_eventHandlerRe.dispose();
|
|
960
|
+
(_this$_eventHandlerRe2 = this._eventHandlerRegisted.get(event)) === null || _this$_eventHandlerRe2 === void 0 || _this$_eventHandlerRe2.delete(handler);
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
removeEvent(event, callback) {
|
|
964
|
+
const map = this._ensureEventRegistry(event);
|
|
965
|
+
map.delete(callback);
|
|
966
|
+
if (map.getData().length === 0) {
|
|
967
|
+
const disposable = this._eventHandlerRegisted.get(event);
|
|
968
|
+
disposable === null || disposable === void 0 || disposable.forEach((d) => d.dispose());
|
|
969
|
+
this._eventHandlerRegisted.delete(event);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
_initEventHandler(event) {
|
|
973
|
+
let current = this._eventHandlerRegisted.get(event);
|
|
974
|
+
const handlers = this._eventHandlerMap.get(event);
|
|
975
|
+
if (!handlers) return;
|
|
976
|
+
if (!current || current.size === 0) {
|
|
977
|
+
current = /* @__PURE__ */ new Map();
|
|
978
|
+
this._eventHandlerRegisted.set(event, current);
|
|
979
|
+
handlers === null || handlers === void 0 || handlers.forEach((handler) => {
|
|
980
|
+
current === null || current === void 0 || current.set(handler, (0, _univerjs_core.toDisposable)(handler()));
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Add an event listener
|
|
986
|
+
* @param {string} event key of event
|
|
987
|
+
* @param {(params: IEventParamConfig[typeof event]) => void} callback callback when event triggered
|
|
988
|
+
* @returns {Disposable} The Disposable instance, for remove the listener
|
|
989
|
+
* @example
|
|
990
|
+
* ```ts
|
|
991
|
+
* univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (params) => {
|
|
992
|
+
* const { stage } = params;
|
|
993
|
+
* console.log('life cycle changed', params);
|
|
994
|
+
* });
|
|
995
|
+
* ```
|
|
996
|
+
*/
|
|
997
|
+
addEvent(event, callback) {
|
|
998
|
+
this._ensureEventRegistry(event).add(callback);
|
|
999
|
+
this._initEventHandler(event);
|
|
1000
|
+
return (0, _univerjs_core.toDisposable)(() => this.removeEvent(event, callback));
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Fire an event, used in internal only.
|
|
1004
|
+
* @param {string} event key of event
|
|
1005
|
+
* @param {any} params params of event
|
|
1006
|
+
* @returns {boolean} should cancel
|
|
1007
|
+
* @example
|
|
1008
|
+
* ```ts
|
|
1009
|
+
* this.fireEvent(univerAPI.Event.LifeCycleChanged, params);
|
|
1010
|
+
* ```
|
|
1011
|
+
*/
|
|
1012
|
+
fireEvent(event, params) {
|
|
1013
|
+
var _this$_eventRegistry$;
|
|
1014
|
+
(_this$_eventRegistry$ = this._eventRegistry.get(event)) === null || _this$_eventRegistry$ === void 0 || _this$_eventRegistry$.getData().forEach((callback) => {
|
|
1015
|
+
callback(params);
|
|
1016
|
+
});
|
|
1017
|
+
return params.cancel;
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
//#endregion
|
|
1022
|
+
//#region src/facade/f-usermanager.ts
|
|
1023
|
+
let FUserManager = class FUserManager extends FBase {
|
|
1024
|
+
constructor(_injector, _userManagerService) {
|
|
1025
|
+
super();
|
|
1026
|
+
this._injector = _injector;
|
|
1027
|
+
this._userManagerService = _userManagerService;
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Get current user info.
|
|
1031
|
+
* @returns {IUser} Current user info.
|
|
1032
|
+
* @example
|
|
1033
|
+
* ```typescript
|
|
1034
|
+
* univerAPI.getUserManager().getCurrentUser();
|
|
1035
|
+
* ```
|
|
1036
|
+
*/
|
|
1037
|
+
getCurrentUser() {
|
|
1038
|
+
return this._userManagerService.getCurrentUser();
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
FUserManager = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.UserManagerService))], FUserManager);
|
|
1042
|
+
|
|
1043
|
+
//#endregion
|
|
1044
|
+
//#region src/facade/f-util.ts
|
|
1045
|
+
/**
|
|
1046
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1047
|
+
*
|
|
1048
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1049
|
+
* you may not use this file except in compliance with the License.
|
|
1050
|
+
* You may obtain a copy of the License at
|
|
1051
|
+
*
|
|
1052
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1053
|
+
*
|
|
1054
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1055
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1056
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1057
|
+
* See the License for the specific language governing permissions and
|
|
1058
|
+
* limitations under the License.
|
|
1059
|
+
*/
|
|
1060
|
+
/**
|
|
1061
|
+
* @ignore
|
|
1062
|
+
*/
|
|
1063
|
+
var FUtil = class FUtil {
|
|
1064
|
+
static get() {
|
|
1065
|
+
if (this._instance) return this._instance;
|
|
1066
|
+
const instance = new FUtil();
|
|
1067
|
+
this._instance = instance;
|
|
1068
|
+
return instance;
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* @ignore
|
|
1072
|
+
*/
|
|
1073
|
+
static extend(source) {
|
|
1074
|
+
Object.getOwnPropertyNames(source.prototype).forEach((name) => {
|
|
1075
|
+
if (name !== "constructor") this.prototype[name] = source.prototype[name];
|
|
1076
|
+
});
|
|
1077
|
+
Object.getOwnPropertyNames(source).forEach((name) => {
|
|
1078
|
+
if (name !== "prototype" && name !== "name" && name !== "length") this[name] = source[name];
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Rectangle utils, including range operations likes merge, subtract, split
|
|
1083
|
+
*
|
|
1084
|
+
* @example
|
|
1085
|
+
* ```ts
|
|
1086
|
+
* const ranges = [
|
|
1087
|
+
* { startRow: 0, startColumn: 0, endRow: 1, endColumn: 1 },
|
|
1088
|
+
* { startRow: 1, startColumn: 1, endRow: 2, endColumn: 2 }
|
|
1089
|
+
* ];
|
|
1090
|
+
* const merged = univerAPI.Util.rectangle.mergeRanges(ranges);
|
|
1091
|
+
* console.log(merged);
|
|
1092
|
+
* ```
|
|
1093
|
+
*/
|
|
1094
|
+
get rectangle() {
|
|
1095
|
+
return _univerjs_core.Rectangle;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Number format utils, including parse and strigify about date, price, etc
|
|
1099
|
+
*
|
|
1100
|
+
* @example
|
|
1101
|
+
* ```ts
|
|
1102
|
+
* const text = univerAPI.Util.numfmt.format('#,##0.00', 1234.567);
|
|
1103
|
+
* console.log(text);
|
|
1104
|
+
* ```
|
|
1105
|
+
*/
|
|
1106
|
+
get numfmt() {
|
|
1107
|
+
return _univerjs_core.numfmt;
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* common tools
|
|
1111
|
+
*
|
|
1112
|
+
* @example
|
|
1113
|
+
* ```ts
|
|
1114
|
+
* const key = univerAPI.Util.tools.generateRandomId(6);
|
|
1115
|
+
* console.log(key);
|
|
1116
|
+
* ```
|
|
1117
|
+
*/
|
|
1118
|
+
get tools() {
|
|
1119
|
+
return _univerjs_core.Tools;
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
_defineProperty(FUtil, "_instance", void 0);
|
|
1123
|
+
|
|
1124
|
+
//#endregion
|
|
1125
|
+
//#region src/facade/f-univer.ts
|
|
1126
|
+
var _FUniver;
|
|
1127
|
+
/**
|
|
1128
|
+
* @ignore
|
|
1129
|
+
*/
|
|
1130
|
+
const InitializerSymbol = Symbol("initializers");
|
|
1131
|
+
let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
1132
|
+
/**
|
|
1133
|
+
* Create an FUniver instance, if the injector is not provided, it will create a new Univer instance.
|
|
1134
|
+
* @static
|
|
1135
|
+
* @param {Univer | Injector} wrapped - The Univer instance or injector instance.
|
|
1136
|
+
* @returns {FUniver} - The FUniver instance.
|
|
1137
|
+
*
|
|
1138
|
+
* @example
|
|
1139
|
+
* ```ts
|
|
1140
|
+
* const univerAPI = FUniver.newAPI(univer);
|
|
1141
|
+
* ```
|
|
1142
|
+
*/
|
|
1143
|
+
static newAPI(wrapped) {
|
|
1144
|
+
return (wrapped instanceof _univerjs_core.Univer ? wrapped.__getInjector() : wrapped).createInstance(_FUniver);
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* @ignore
|
|
1148
|
+
*/
|
|
1149
|
+
_initialize(injector) {}
|
|
1150
|
+
/**
|
|
1151
|
+
* @ignore
|
|
1152
|
+
*/
|
|
1153
|
+
static extend(source) {
|
|
1154
|
+
Object.getOwnPropertyNames(source.prototype).forEach((name) => {
|
|
1155
|
+
if (name === "_initialize") {
|
|
1156
|
+
let initializers = this.prototype[InitializerSymbol];
|
|
1157
|
+
if (!initializers) {
|
|
1158
|
+
initializers = [];
|
|
1159
|
+
this.prototype[InitializerSymbol] = initializers;
|
|
1160
|
+
}
|
|
1161
|
+
initializers.push(source.prototype._initialize);
|
|
1162
|
+
} else if (name !== "constructor") this.prototype[name] = source.prototype[name];
|
|
1163
|
+
});
|
|
1164
|
+
Object.getOwnPropertyNames(source).forEach((name) => {
|
|
1165
|
+
if (name !== "prototype" && name !== "name" && name !== "length") this[name] = source[name];
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
constructor(_injector, _commandService, _univerInstanceService, _lifecycleService) {
|
|
1169
|
+
super();
|
|
1170
|
+
this._injector = _injector;
|
|
1171
|
+
this._commandService = _commandService;
|
|
1172
|
+
this._univerInstanceService = _univerInstanceService;
|
|
1173
|
+
this._lifecycleService = _lifecycleService;
|
|
1174
|
+
_defineProperty(this, "_eventRegistry", new FEventRegistry());
|
|
1175
|
+
_defineProperty(this, "registerEventHandler", (event, handler) => {
|
|
1176
|
+
return this._eventRegistry.registerEventHandler(event, handler);
|
|
1177
|
+
});
|
|
1178
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged, () => (0, _univerjs_core.toDisposable)(this._lifecycleService.lifecycle$.subscribe((stage) => {
|
|
1179
|
+
this.fireEvent(this.Event.LifeCycleChanged, { stage });
|
|
1180
|
+
}))));
|
|
1181
|
+
this._initUnitEvent(this._injector);
|
|
1182
|
+
this._initBeforeCommandEvent(this._injector);
|
|
1183
|
+
this._initCommandEvent(this._injector);
|
|
1184
|
+
this._injector.onDispose(() => {
|
|
1185
|
+
this.dispose();
|
|
1186
|
+
});
|
|
1187
|
+
const initializers = Object.getPrototypeOf(this)[InitializerSymbol];
|
|
1188
|
+
if (initializers) {
|
|
1189
|
+
const self = this;
|
|
1190
|
+
initializers.forEach(function(fn) {
|
|
1191
|
+
fn.apply(self, [_injector]);
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
_initCommandEvent(injector) {
|
|
1196
|
+
const commandService = injector.get(_univerjs_core.ICommandService);
|
|
1197
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.Redo, () => commandService.onCommandExecuted((commandInfo) => {
|
|
1198
|
+
const { id, type: propType, params } = commandInfo;
|
|
1199
|
+
if (commandInfo.id === _univerjs_core.RedoCommand.id) {
|
|
1200
|
+
const eventParams = {
|
|
1201
|
+
id,
|
|
1202
|
+
type: propType,
|
|
1203
|
+
params
|
|
1204
|
+
};
|
|
1205
|
+
this.fireEvent(this.Event.Redo, eventParams);
|
|
1206
|
+
}
|
|
1207
|
+
})));
|
|
1208
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.Undo, () => commandService.onCommandExecuted((commandInfo) => {
|
|
1209
|
+
const { id, type: propType, params } = commandInfo;
|
|
1210
|
+
if (commandInfo.id === _univerjs_core.UndoCommand.id) {
|
|
1211
|
+
const eventParams = {
|
|
1212
|
+
id,
|
|
1213
|
+
type: propType,
|
|
1214
|
+
params
|
|
1215
|
+
};
|
|
1216
|
+
this.fireEvent(this.Event.Undo, eventParams);
|
|
1217
|
+
}
|
|
1218
|
+
})));
|
|
1219
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted, () => commandService.onCommandExecuted((commandInfo, options) => {
|
|
1220
|
+
const { id, type: propType, params } = commandInfo;
|
|
1221
|
+
if (commandInfo.id !== _univerjs_core.RedoCommand.id && commandInfo.id !== _univerjs_core.UndoCommand.id) {
|
|
1222
|
+
const eventParams = {
|
|
1223
|
+
id,
|
|
1224
|
+
type: propType,
|
|
1225
|
+
params,
|
|
1226
|
+
options
|
|
1227
|
+
};
|
|
1228
|
+
this.fireEvent(this.Event.CommandExecuted, eventParams);
|
|
1229
|
+
}
|
|
1230
|
+
})));
|
|
1231
|
+
}
|
|
1232
|
+
_initBeforeCommandEvent(injector) {
|
|
1233
|
+
const commandService = injector.get(_univerjs_core.ICommandService);
|
|
1234
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
1235
|
+
const { id, type: propType, params } = commandInfo;
|
|
1236
|
+
if (commandInfo.id === _univerjs_core.RedoCommand.id) {
|
|
1237
|
+
const eventParams = {
|
|
1238
|
+
id,
|
|
1239
|
+
type: propType,
|
|
1240
|
+
params
|
|
1241
|
+
};
|
|
1242
|
+
this.fireEvent(this.Event.BeforeRedo, eventParams);
|
|
1243
|
+
if (eventParams.cancel) throw new _univerjs_core.CanceledError();
|
|
1244
|
+
}
|
|
1245
|
+
})));
|
|
1246
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
1247
|
+
const { id, type: propType, params } = commandInfo;
|
|
1248
|
+
if (commandInfo.id === _univerjs_core.UndoCommand.id) {
|
|
1249
|
+
const eventParams = {
|
|
1250
|
+
id,
|
|
1251
|
+
type: propType,
|
|
1252
|
+
params
|
|
1253
|
+
};
|
|
1254
|
+
this.fireEvent(this.Event.BeforeUndo, eventParams);
|
|
1255
|
+
if (eventParams.cancel) throw new _univerjs_core.CanceledError();
|
|
1256
|
+
}
|
|
1257
|
+
})));
|
|
1258
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute, () => commandService.beforeCommandExecuted((commandInfo, options) => {
|
|
1259
|
+
const { id, type: propType, params } = commandInfo;
|
|
1260
|
+
if (commandInfo.id !== _univerjs_core.RedoCommand.id && commandInfo.id !== _univerjs_core.UndoCommand.id) {
|
|
1261
|
+
const eventParams = {
|
|
1262
|
+
id,
|
|
1263
|
+
type: propType,
|
|
1264
|
+
params,
|
|
1265
|
+
options
|
|
1266
|
+
};
|
|
1267
|
+
this.fireEvent(this.Event.BeforeCommandExecute, eventParams);
|
|
1268
|
+
if (eventParams.cancel) throw new _univerjs_core.CanceledError();
|
|
1269
|
+
}
|
|
1270
|
+
})));
|
|
1271
|
+
}
|
|
1272
|
+
_initUnitEvent(injector) {
|
|
1273
|
+
const univerInstanceService = injector.get(_univerjs_core.IUniverInstanceService);
|
|
1274
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed, () => univerInstanceService.unitDisposed$.subscribe((unit) => {
|
|
1275
|
+
if (unit.type === _univerjs_core.UniverInstanceType.UNIVER_DOC) this.fireEvent(this.Event.DocDisposed, {
|
|
1276
|
+
unitId: unit.getUnitId(),
|
|
1277
|
+
unitType: unit.type,
|
|
1278
|
+
snapshot: unit.getSnapshot()
|
|
1279
|
+
});
|
|
1280
|
+
})));
|
|
1281
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated, () => univerInstanceService.unitAdded$.subscribe((unit) => {
|
|
1282
|
+
if (unit.type === _univerjs_core.UniverInstanceType.UNIVER_DOC) {
|
|
1283
|
+
const doc = unit;
|
|
1284
|
+
const docUnit = injector.createInstance(FDoc, doc);
|
|
1285
|
+
this.fireEvent(this.Event.DocCreated, {
|
|
1286
|
+
unitId: unit.getUnitId(),
|
|
1287
|
+
type: unit.type,
|
|
1288
|
+
doc: docUnit,
|
|
1289
|
+
unit: docUnit
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
})));
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Dispose the UniverSheet by the `unitId`. The UniverSheet would be unload from the application.
|
|
1296
|
+
* @param unitId The unit id of the UniverSheet.
|
|
1297
|
+
* @returns Whether the Univer instance is disposed successfully.
|
|
1298
|
+
*
|
|
1299
|
+
* @example
|
|
1300
|
+
* ```ts
|
|
1301
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1302
|
+
* const unitId = fWorkbook?.getId();
|
|
1303
|
+
*
|
|
1304
|
+
* if (unitId) {
|
|
1305
|
+
* univerAPI.disposeUnit(unitId);
|
|
1306
|
+
* }
|
|
1307
|
+
* ```
|
|
1308
|
+
*/
|
|
1309
|
+
disposeUnit(unitId) {
|
|
1310
|
+
return this._univerInstanceService.disposeUnit(unitId);
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Get the current lifecycle stage.
|
|
1314
|
+
* @returns {LifecycleStages} - The current lifecycle stage.
|
|
1315
|
+
*
|
|
1316
|
+
* @example
|
|
1317
|
+
* ```ts
|
|
1318
|
+
* const stage = univerAPI.getCurrentLifecycleStage();
|
|
1319
|
+
* console.log(stage);
|
|
1320
|
+
* ```
|
|
1321
|
+
*/
|
|
1322
|
+
getCurrentLifecycleStage() {
|
|
1323
|
+
return this._injector.get(_univerjs_core.LifecycleService).stage;
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* Undo an editing on the currently focused document.
|
|
1327
|
+
* @returns {Promise<boolean>} undo result
|
|
1328
|
+
*
|
|
1329
|
+
* @example
|
|
1330
|
+
* ```ts
|
|
1331
|
+
* await univerAPI.undo();
|
|
1332
|
+
* ```
|
|
1333
|
+
*/
|
|
1334
|
+
undo() {
|
|
1335
|
+
return this._commandService.executeCommand(_univerjs_core.UndoCommand.id);
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Redo an editing on the currently focused document.
|
|
1339
|
+
* @returns {Promise<boolean>} redo result
|
|
1340
|
+
*
|
|
1341
|
+
* @example
|
|
1342
|
+
* ```ts
|
|
1343
|
+
* await univerAPI.redo();
|
|
1344
|
+
* ```
|
|
1345
|
+
*/
|
|
1346
|
+
redo() {
|
|
1347
|
+
return this._commandService.executeCommand(_univerjs_core.RedoCommand.id);
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Toggle dark mode on or off.
|
|
1351
|
+
* @param {boolean} isDarkMode - Whether the dark mode is enabled.
|
|
1352
|
+
* @example
|
|
1353
|
+
* ```ts
|
|
1354
|
+
* univerAPI.toggleDarkMode(true);
|
|
1355
|
+
* ```
|
|
1356
|
+
*/
|
|
1357
|
+
toggleDarkMode(isDarkMode) {
|
|
1358
|
+
this._injector.get(_univerjs_core.ThemeService).setDarkMode(isDarkMode);
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Load locales for the given locale.
|
|
1362
|
+
* @description This method is utilized to load locales, which can be either built-in or custom-defined.
|
|
1363
|
+
* @param {string} locale - A unique locale identifier.
|
|
1364
|
+
* @param {ILanguagePack} locales - The locales object containing the translations.
|
|
1365
|
+
* @example
|
|
1366
|
+
* ```ts
|
|
1367
|
+
* univerAPI.loadLocales('esES', {
|
|
1368
|
+
* 'Hello World': 'Hola Mundo',
|
|
1369
|
+
* });
|
|
1370
|
+
* ```
|
|
1371
|
+
*/
|
|
1372
|
+
loadLocales(locale, locales) {
|
|
1373
|
+
this._injector.get(_univerjs_core.LocaleService).load({ [locale]: locales });
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Set the current locale.
|
|
1377
|
+
* @param {string} locale - A unique locale identifier.
|
|
1378
|
+
* @example
|
|
1379
|
+
* ```ts
|
|
1380
|
+
* univerAPI.setLocale('esES');
|
|
1381
|
+
* ```
|
|
1382
|
+
*/
|
|
1383
|
+
setLocale(locale) {
|
|
1384
|
+
this._injector.get(_univerjs_core.LocaleService).setLocale(locale);
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Register a callback that will be triggered before invoking a command.
|
|
1388
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeCommandExecute, (event) => {})` instead.
|
|
1389
|
+
* @param {CommandListener} callback The callback.
|
|
1390
|
+
* @returns {IDisposable} The disposable instance.
|
|
1391
|
+
*/
|
|
1392
|
+
onBeforeCommandExecute(callback) {
|
|
1393
|
+
return this._commandService.beforeCommandExecuted((command, options) => {
|
|
1394
|
+
callback(command, options);
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Register a callback that will be triggered when a command is invoked.
|
|
1399
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.CommandExecuted, (event) => {})` instead.
|
|
1400
|
+
* @param {CommandListener} callback The callback.
|
|
1401
|
+
* @returns {IDisposable} The disposable instance.
|
|
1402
|
+
*/
|
|
1403
|
+
onCommandExecuted(callback) {
|
|
1404
|
+
return this._commandService.onCommandExecuted((command, options) => {
|
|
1405
|
+
callback(command, options);
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
/**
|
|
1409
|
+
* Execute a command with the given id and parameters.
|
|
1410
|
+
* @param id Identifier of the command.
|
|
1411
|
+
* @param params Parameters of this execution.
|
|
1412
|
+
* @param options Options of this execution.
|
|
1413
|
+
* @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
|
|
1414
|
+
*
|
|
1415
|
+
* @example
|
|
1416
|
+
* ```ts
|
|
1417
|
+
* univerAPI.executeCommand('sheet.command.set-range-values', {
|
|
1418
|
+
* value: { v: "Hello, Univer!" },
|
|
1419
|
+
* range: { startRow: 0, startColumn: 0, endRow: 0, endColumn: 0 }
|
|
1420
|
+
* });
|
|
1421
|
+
* ```
|
|
1422
|
+
*/
|
|
1423
|
+
executeCommand(id, params, options) {
|
|
1424
|
+
return this._commandService.executeCommand(id, params, options);
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Execute a command with the given id and parameters synchronously.
|
|
1428
|
+
* @param id Identifier of the command.
|
|
1429
|
+
* @param params Parameters of this execution.
|
|
1430
|
+
* @param options Options of this execution.
|
|
1431
|
+
* @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
|
|
1432
|
+
*
|
|
1433
|
+
* @example
|
|
1434
|
+
* ```ts
|
|
1435
|
+
* univerAPI.syncExecuteCommand('sheet.command.set-range-values', {
|
|
1436
|
+
* value: { v: "Hello, Univer!" },
|
|
1437
|
+
* range: { startRow: 0, startColumn: 0, endRow: 0, endColumn: 0 }
|
|
1438
|
+
* });
|
|
1439
|
+
* ```
|
|
1440
|
+
*/
|
|
1441
|
+
syncExecuteCommand(id, params, options) {
|
|
1442
|
+
return this._commandService.syncExecuteCommand(id, params, options);
|
|
1443
|
+
}
|
|
1444
|
+
/**
|
|
1445
|
+
* Get hooks.
|
|
1446
|
+
* @deprecated use `addEvent` instead.
|
|
1447
|
+
* @returns {FHooks} FHooks instance
|
|
1448
|
+
*/
|
|
1449
|
+
getHooks() {
|
|
1450
|
+
return this._injector.createInstance(FHooks);
|
|
1451
|
+
}
|
|
1452
|
+
get Enum() {
|
|
1453
|
+
return FEnum.get();
|
|
1454
|
+
}
|
|
1455
|
+
get Event() {
|
|
1456
|
+
return FEventName.get();
|
|
1457
|
+
}
|
|
1458
|
+
get Util() {
|
|
1459
|
+
return FUtil.get();
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Add an event listener
|
|
1463
|
+
* @param {string} event key of event
|
|
1464
|
+
* @param {(params: IEventParamConfig[typeof event]) => void} callback callback when event triggered
|
|
1465
|
+
* @returns {Disposable} The Disposable instance, for remove the listener
|
|
1466
|
+
* @example
|
|
1467
|
+
* ```ts
|
|
1468
|
+
* // Add life cycle changed event listener
|
|
1469
|
+
* const disposable = univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (params) => {
|
|
1470
|
+
* const { stage } = params;
|
|
1471
|
+
* console.log('life cycle changed', params);
|
|
1472
|
+
* });
|
|
1473
|
+
*
|
|
1474
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
1475
|
+
* ```
|
|
1476
|
+
*/
|
|
1477
|
+
addEvent(event, callback) {
|
|
1478
|
+
if (!event || !callback) throw new Error("Cannot add empty event");
|
|
1479
|
+
return this._eventRegistry.addEvent(event, callback);
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Fire an event, used in internal only.
|
|
1483
|
+
* @param {string} event key of event
|
|
1484
|
+
* @param {any} params params of event
|
|
1485
|
+
* @returns {boolean} should cancel
|
|
1486
|
+
* @example
|
|
1487
|
+
* ```ts
|
|
1488
|
+
* this.fireEvent(univerAPI.Event.LifeCycleChanged, params);
|
|
1489
|
+
* ```
|
|
1490
|
+
*/
|
|
1491
|
+
fireEvent(event, params) {
|
|
1492
|
+
return this._eventRegistry.fireEvent(event, params);
|
|
1493
|
+
}
|
|
1494
|
+
getUserManager() {
|
|
1495
|
+
return this._injector.createInstance(FUserManager);
|
|
1496
|
+
}
|
|
1497
|
+
/**
|
|
1498
|
+
* Create a new blob.
|
|
1499
|
+
* @returns {FBlob} The new blob instance
|
|
1500
|
+
* @example
|
|
1501
|
+
* ```ts
|
|
1502
|
+
* const blob = univerAPI.newBlob();
|
|
1503
|
+
* ```
|
|
1504
|
+
*/
|
|
1505
|
+
newBlob() {
|
|
1506
|
+
return this._injector.createInstance(FBlob, null);
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Create a new rich text.
|
|
1510
|
+
* @param {IDocumentData} data
|
|
1511
|
+
* @returns {RichTextBuilder} The new rich text instance
|
|
1512
|
+
* @example
|
|
1513
|
+
* ```ts
|
|
1514
|
+
* const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
|
|
1515
|
+
* const range = univerAPI.getActiveWorkbook().getActiveSheet().getRange('A1');
|
|
1516
|
+
* range.setRichTextValueForCell(richText);
|
|
1517
|
+
* ```
|
|
1518
|
+
*/
|
|
1519
|
+
newRichText(data) {
|
|
1520
|
+
return _univerjs_core.RichTextBuilder.create(data);
|
|
1521
|
+
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Create a new rich text value.
|
|
1524
|
+
* @param {IDocumentData} data - The rich text data
|
|
1525
|
+
* @returns {RichTextValue} The new rich text value instance
|
|
1526
|
+
* @example
|
|
1527
|
+
* ```ts
|
|
1528
|
+
* const richTextValue = univerAPI.newRichTextValue({ body: { dataStream: 'Hello World\r\n' } });
|
|
1529
|
+
* const range = univerAPI.getActiveWorkbook().getActiveSheet().getRange('A1');
|
|
1530
|
+
* range.setRichTextValueForCell(richTextValue);
|
|
1531
|
+
* ```
|
|
1532
|
+
*/
|
|
1533
|
+
newRichTextValue(data) {
|
|
1534
|
+
return _univerjs_core.RichTextValue.create(data);
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Create a new paragraph style.
|
|
1538
|
+
* @param {IParagraphStyle} style - The paragraph style
|
|
1539
|
+
* @returns {ParagraphStyleBuilder} The new paragraph style instance
|
|
1540
|
+
* @example
|
|
1541
|
+
* ```ts
|
|
1542
|
+
* const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
|
|
1543
|
+
* const paragraphStyle = univerAPI.newParagraphStyle({ textStyle: { ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE } });
|
|
1544
|
+
* richText.insertParagraph(paragraphStyle);
|
|
1545
|
+
* const range = univerAPI.getActiveWorkbook().getActiveSheet().getRange('A1');
|
|
1546
|
+
* range.setRichTextValueForCell(richText);
|
|
1547
|
+
* ```
|
|
1548
|
+
*/
|
|
1549
|
+
newParagraphStyle(style) {
|
|
1550
|
+
return _univerjs_core.ParagraphStyleBuilder.create(style);
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Create a new paragraph style value.
|
|
1554
|
+
* @param {IParagraphStyle} style - The paragraph style
|
|
1555
|
+
* @returns {ParagraphStyleValue} The new paragraph style value instance
|
|
1556
|
+
* @example
|
|
1557
|
+
* ```ts
|
|
1558
|
+
* const paragraphStyleValue = univerAPI.newParagraphStyleValue();
|
|
1559
|
+
* ```
|
|
1560
|
+
*/
|
|
1561
|
+
newParagraphStyleValue(style) {
|
|
1562
|
+
return _univerjs_core.ParagraphStyleValue.create(style);
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Create a new text style.
|
|
1566
|
+
* @param {ITextStyle} style - The text style
|
|
1567
|
+
* @returns {TextStyleBuilder} The new text style instance
|
|
1568
|
+
* @example
|
|
1569
|
+
* ```ts
|
|
1570
|
+
* const textStyle = univerAPI.newTextStyle();
|
|
1571
|
+
* ```
|
|
1572
|
+
*/
|
|
1573
|
+
newTextStyle(style) {
|
|
1574
|
+
return _univerjs_core.TextStyleBuilder.create(style);
|
|
1575
|
+
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Create a new text style value.
|
|
1578
|
+
* @param {ITextStyle} style - The text style
|
|
1579
|
+
* @returns {TextStyleValue} The new text style value instance
|
|
1580
|
+
* @example
|
|
1581
|
+
* ```ts
|
|
1582
|
+
* const textStyleValue = univerAPI.newTextStyleValue();
|
|
1583
|
+
* ```
|
|
1584
|
+
*/
|
|
1585
|
+
newTextStyleValue(style) {
|
|
1586
|
+
return _univerjs_core.TextStyleValue.create(style);
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Create a new text decoration.
|
|
1590
|
+
* @param {ITextDecoration} decoration - The text decoration
|
|
1591
|
+
* @returns {TextDecorationBuilder} The new text decoration instance
|
|
1592
|
+
* @example
|
|
1593
|
+
* ```ts
|
|
1594
|
+
* const decoration = univerAPI.newTextDecoration();
|
|
1595
|
+
* ```
|
|
1596
|
+
*/
|
|
1597
|
+
newTextDecoration(decoration) {
|
|
1598
|
+
return new _univerjs_core.TextDecorationBuilder(decoration);
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1601
|
+
FUniver = _FUniver = __decorate([
|
|
1602
|
+
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
1603
|
+
__decorateParam(1, _univerjs_core.ICommandService),
|
|
1604
|
+
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
1605
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.LifecycleService))
|
|
1606
|
+
], FUniver);
|
|
1607
|
+
|
|
1608
|
+
//#endregion
|
|
1609
|
+
exports.FBase = FBase;
|
|
1610
|
+
exports.FBaseInitialable = FBaseInitialable;
|
|
1611
|
+
Object.defineProperty(exports, 'FBlob', {
|
|
1612
|
+
enumerable: true,
|
|
1613
|
+
get: function () {
|
|
1614
|
+
return FBlob;
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
exports.FEnum = FEnum;
|
|
1618
|
+
exports.FEventName = FEventName;
|
|
1619
|
+
Object.defineProperty(exports, 'FHooks', {
|
|
1620
|
+
enumerable: true,
|
|
1621
|
+
get: function () {
|
|
1622
|
+
return FHooks;
|
|
1623
|
+
}
|
|
1624
|
+
});
|
|
1625
|
+
Object.defineProperty(exports, 'FUniver', {
|
|
1626
|
+
enumerable: true,
|
|
1627
|
+
get: function () {
|
|
1628
|
+
return FUniver;
|
|
1629
|
+
}
|
|
1630
|
+
});
|
|
1631
|
+
exports.FUtil = FUtil;
|