Blob & File
| Packages | @univerjs/core |
|---|
This class should not be instantiated directly. Use factory methods on
univerAPIinstead.
Overview
@univerjs/core
| Method | Description |
|---|---|
copyBlob | Returns a copy of this blob |
extend | - |
get | - |
getAs | Return the data inside this object as a blob converted to the specified content type |
getBytes | Gets the data stored in this blob |
getContentType | Gets the content type of the data stored in this blob |
getDataAsString | - |
onBeforeRedo | - |
onBeforeUndo | - |
onReady | - |
onRedo | - |
onRendered | - |
onStarting | - |
onSteady | - |
onUndo | - |
setBytes | Sets the data stored in this blob |
setContentType | Sets the content type of the data stored in this blob |
setDataFromString | - |
APIs
Getters & Queries
get
Signature
static get(): FUtilReturns
FUtil— See signature above.
@univerjs/core
getAs
Return the data inside this object as a blob converted to the specified content type.
Signature
getAs(contentType: string): FBlobParameters
contentTypestring— No description
Returns
FBlob— a new blob by converting the current blob to the specified content type
Examples
const blob = univerAPI.newBlob();
const newBlob = blob.getAs('text/plain');
console.log(newBlob);@univerjs/core
getBytes
Gets the data stored in this blob.
Signature
getBytes(): Promise<Uint8Array>Returns
Promise<Uint8Array<ArrayBufferLike>>— the blob content as a byte array
Examples
const blob = univerAPI.newBlob();
const bytes = await blob.getBytes();
console.log(bytes);@univerjs/core
getContentType
Gets the content type of the data stored in this blob.
Signature
getContentType(): string | undefinedReturns
string— the content type
Examples
const blob = univerAPI.newBlob();
const contentType = blob.getContentType();
console.log(contentType);@univerjs/core
getDataAsString
Signature
getDataAsString(charset?: string): Promise<string>Parameters
charsetstring(optional) — No description
Returns
Promise<string>— See signature above.
@univerjs/core
Setters & Modifiers
setBytes
Sets the data stored in this blob.
Signature
setBytes(bytes: Uint8Array): FBlobParameters
bytesUint8Array<ArrayBufferLike>— No description
Returns
FBlob— the blob object
Examples
const blob = univerAPI.newBlob();
const bytes = new Uint8Array(10);
blob.setBytes(bytes);@univerjs/core
setContentType
Sets the content type of the data stored in this blob.
Signature
setContentType(contentType: string): FBlobParameters
contentTypestring— No description
Returns
FBlob— the blob object
Examples
const blob = univerAPI.newBlob();
blob.setContentType('text/plain');@univerjs/core
setDataFromString
Signature
setDataFromString(data: string, contentType?: string): FBlobParameters
datastring— No descriptioncontentTypestring(optional) — No description
Returns
FBlob— See signature above.
@univerjs/core
Actions & Operations
copyBlob
Returns a copy of this blob.
Signature
copyBlob(): FBlobReturns
FBlob— a new blob by copying the current blob
Examples
const blob = univerAPI.newBlob();
const newBlob = blob.copyBlob();
console.log(newBlob);@univerjs/core
Events
onBeforeRedo
univerAPI.addEvent(univerAPI.Event.BeforeRedo, (event) => {}) as insteadSignature
onBeforeRedo(callback: (action: IUndoRedoItem) => void): IDisposableParameters
callback(action: IUndoRedoItem) => void— No description
Returns
IDisposable— See signature above.
@univerjs/core
onBeforeUndo
univerAPI.addEvent(univerAPI.Event.BeforeUndo, (event) => {}) as insteadSignature
onBeforeUndo(callback: (action: IUndoRedoItem) => void): IDisposableParameters
callback(action: IUndoRedoItem) => void— No description
Returns
IDisposable— See signature above.
@univerjs/core
onReady
univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {}) as insteadSignature
onReady(callback: () => void): IDisposableParameters
callback() => void— No description
Returns
IDisposable— See signature above.
@univerjs/core
onRedo
univerAPI.addEvent(univerAPI.Event.Redo, (event) => {}) as insteadSignature
onRedo(callback: (action: IUndoRedoItem) => void): IDisposableParameters
callback(action: IUndoRedoItem) => void— No description
Returns
IDisposable— See signature above.
@univerjs/core
onRendered
univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {}) as insteadSignature
onRendered(callback: () => void): IDisposableParameters
callback() => void— No description
Returns
IDisposable— See signature above.
@univerjs/core
onStarting
univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {}) as insteadSignature
onStarting(callback: () => void): IDisposableParameters
callback() => void— No description
Returns
IDisposable— See signature above.
@univerjs/core
onSteady
univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {}) as insteadSignature
onSteady(callback: () => void): IDisposableParameters
callback() => void— No description
Returns
IDisposable— See signature above.
@univerjs/core
onUndo
univerAPI.addEvent(univerAPI.Event.Undo, (event) => {}) as insteadSignature
onUndo(callback: (action: IUndoRedoItem) => void): IDisposableParameters
callback(action: IUndoRedoItem) => void— No description
Returns
IDisposable— See signature above.
@univerjs/core
Miscellaneous
extend
Signature
static extend(source: any): voidParameters
sourceany— No description
@univerjs/core