Ink Class
Packages > @fluidframework/ink > Ink
Inking data structure.
Signature:
/** @sealed */
export declare class Ink extends SharedObject<IInkEvents> implements IInk
Extends: SharedObject<IInkEvents>
Implements: IInk
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(runtime, id, attributes) | Create a new Ink. |
Methods
Method | Modifiers | Description |
---|---|---|
appendPointToStroke(point, id) | Append the given point to the indicated stroke. | |
clear() | Clear all strokes. | |
create(runtime, id) | static |
Create a new Ink. |
createStroke(pen) | Create a stroke with the given pen information. | |
getFactory() | static |
Get a factory for Ink to register with the data store. |
getStroke(key) | Get a specific stroke with the given key. | |
getStrokes() | Get the collection of strokes stored in this Ink object. | |
loadCore(branchId, storage) | Allows the distributed data type to perform custom loading | |
onDisconnect() | Called when the object has disconnected from the delta stream. | |
processCore(message, local, localOpMetadata) | Derived classes must override this to do custom processing on a remote message. | |
registerCore() | Allows the distributed data type the ability to perform custom processing once an attach has happened. | |
snapshot() | Gets a form of the object that can be serialized. |
Constructors
Ink.(constructor)
Create a new Ink.
Signature:
constructor(runtime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes);
Parameters
Parameter | Type | Description |
---|---|---|
runtime | IFluidDataStoreRuntime | The runtime the Ink will be associated with |
id | string | Unique ID for the Ink |
attributes | IChannelAttributes |
Methods
appendPointToStroke
Append the given point to the indicated stroke.
Signature:
appendPointToStroke(point: IInkPoint, id: string): IInkStroke;
Parameters
Parameter | Type | Description |
---|---|---|
point | IInkPoint | The point to append |
id | string | The ID for the stroke to append to |
Returns:
The stroke that was updated
clear
Clear all strokes.
Signature:
clear(): void;
Returns:
void
create
Create a new Ink.
Signature:
static create(runtime: IFluidDataStoreRuntime, id?: string): Ink;
Parameters
Parameter | Type | Description |
---|---|---|
runtime | IFluidDataStoreRuntime | Data Store runtime the new Ink belongs to |
id | string | Optional name of the Ink; will be assigned a unique ID if not provided |
Returns:
Newly create Ink object (but not attached yet)
createStroke
Create a stroke with the given pen information.
Signature:
createStroke(pen: IPen): IInkStroke;
Parameters
Parameter | Type | Description |
---|---|---|
pen | IPen | The pen information for this stroke |
Returns:
The stroke that was created
getFactory
Get a factory for Ink to register with the data store.
Signature:
static getFactory(): InkFactory;
Returns:
A factory that creates and loads Ink
getStroke
Get a specific stroke with the given key.
Signature:
getStroke(key: string): IInkStroke;
Parameters
Parameter | Type | Description |
---|---|---|
key | string | ID for the stroke |
Returns:
the requested stroke, or undefined if it does not exist
getStrokes
Get the collection of strokes stored in this Ink object.
Signature:
getStrokes(): IInkStroke[];
Returns:
the array of strokes
loadCore
Allows the distributed data type to perform custom loading
Signature:
protected loadCore(branchId: string | undefined, storage: IChannelStorageService): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
branchId | string | undefined | Branch ID |
storage | IChannelStorageService |
Returns:
Promise<void>
onDisconnect
Called when the object has disconnected from the delta stream.
Signature:
protected onDisconnect(): void;
Returns:
void
processCore
Derived classes must override this to do custom processing on a remote message.
Signature:
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
Parameters
Parameter | Type | Description |
---|---|---|
message | ISequencedDocumentMessage | The message to process |
local | boolean | True if the shared object is local |
localOpMetadata | unknown | For local client messages, this is the metadata that was submitted with the message. For messages from a remote client, this will be undefined. |
Returns:
void
registerCore
Allows the distributed data type the ability to perform custom processing once an attach has happened.
Signature:
protected registerCore(): void;
Returns:
void
snapshot
Gets a form of the object that can be serialized.
Signature:
snapshot(): ITree;
Returns:
A tree representing the snapshot of the shared object