Skip to content 

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

List of constructors for this class
Constructor Modifiers Description
(constructor)(runtime, id, attributes) Create a new Ink.

Methods

List of methods on this class
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

List of 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

List of parameters
Parameter Type Description
point IInkPoint The point to append
id string The ID for the stroke to append to

Returns:

IInkStroke

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

List of 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:

Ink

Newly create Ink object (but not attached yet)

createStroke

Create a stroke with the given pen information.

Signature:

createStroke(pen: IPen): IInkStroke;

Parameters

List of parameters
Parameter Type Description
pen IPen The pen information for this stroke

Returns:

IInkStroke

The stroke that was created

getFactory

Get a factory for Ink to register with the data store.

Signature:

static getFactory(): InkFactory;

Returns:

InkFactory

A factory that creates and loads Ink

getStroke

Get a specific stroke with the given key.

Signature:

getStroke(key: string): IInkStroke;

Parameters

List of parameters
Parameter Type Description
key string ID for the stroke

Returns:

IInkStroke

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:

IInkStroke[]

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

List of 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

List of 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:

ITree

A tree representing the snapshot of the shared object