slate-hyperscript
Version:
A hyperscript helper for creating Slate documents.
55 lines • 1.58 kB
TypeScript
import { Path, Text } from 'slate';
import { HyperscriptPointRef, HyperscriptRangeRef } from './refs';
/**
* All tokens inherit from a single constructor for `instanceof` checking.
*/
export declare class Token<Ref = unknown> {
offset?: number;
path?: Path;
ref?: Ref;
constructor(props?: {
offset?: number;
path?: Path;
ref?: Ref;
});
}
/**
* Anchor tokens represent the selection's anchor point.
*/
export declare class AnchorToken extends Token<HyperscriptRangeRef> {
}
/**
* Focus tokens represent the selection's focus point.
*/
export declare class FocusToken extends Token<HyperscriptRangeRef> {
}
/**
* Point tokens represent arbitrary points.
*/
export declare class PointToken extends Token<HyperscriptPointRef> {
}
/**
* Add an anchor token to the end of a text node.
*/
export declare function addAnchorToken(text: Text, token: AnchorToken): void;
/**
* Get the associated anchor tokens for a text node.
*/
export declare function getAnchors(text: Text): AnchorToken[];
/**
* Add a focus token to the end of a text node.
*/
export declare function addFocusToken(text: Text, token: FocusToken): void;
/**
* Get the associated focus tokens for a text node.
*/
export declare function getFoci(text: Text): FocusToken[];
/**
* Add a point token to the end of a text node.
*/
export declare function addPointToken(text: Text, token: PointToken): void;
/**
* Get the associated point tokens for a text node.
*/
export declare function getPoints(text: Text): PointToken[];
//# sourceMappingURL=tokens.d.ts.map