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