usfm-editor
Version:
A WYSIWYG editor component for USFM
240 lines (239 loc) • 14.3 kB
TypeScript
import { Editor, Path, Node, NodeEntry, Element } from "slate";
import { ReactEditor } from "slate-react";
import { DOMNode } from "slate-react/dist/utils/dom";
import { IdentificationHeaders } from "../../UsfmEditor";
export declare const MyEditor: {
isMatchingNodeSelected: typeof isMatchingNodeSelected;
isVerseOrChapterNumberSelected: typeof isVerseOrChapterNumberSelected;
areMultipleBlocksSelected: typeof areMultipleBlocksSelected;
isNearbyBlockAnInlineContainer: typeof isNearbyBlockAnInlineContainer;
isNearbyBlockAnEmptyInlineContainer: typeof isNearbyBlockAnEmptyInlineContainer;
isNearbyBlockAVerseNumber: typeof isNearbyBlockAVerseNumber;
isNearbyBlockAVerseOrChapterNumberOrNull: typeof isNearbyBlockAVerseOrChapterNumberOrNull;
getPreviousBlock: typeof getPreviousBlock;
getCurrentBlock: typeof getCurrentBlock;
getNextBlock: typeof getNextBlock;
getVerseNode: typeof getVerseNode;
getPreviousVerse: typeof getPreviousVerse;
getChapterNode: typeof getChapterNode;
getLastVerse: typeof getLastVerse;
getLastVerseNumberOrRange: typeof getLastVerseNumberOrRange;
getPathFromDOMNode: typeof getPathFromDOMNode;
identification: typeof identification;
findVersePath: typeof findVersePath;
above: <T extends import("slate").Ancestor>(editor: import("slate").BaseEditor & ReactEditor, options?: {
at?: import("slate").Location | undefined;
match?: import("slate").NodeMatch<T> | undefined;
mode?: "highest" | "lowest" | undefined;
voids?: boolean | undefined;
} | undefined) => NodeEntry<T> | undefined;
addMark: (editor: import("slate").BaseEditor & ReactEditor, key: string, value: any) => void;
after: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location, options?: {
distance?: number | undefined;
unit?: "line" | "character" | "offset" | "word" | "block" | undefined;
voids?: boolean | undefined;
} | undefined) => import("slate").BasePoint | undefined;
before: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location, options?: {
distance?: number | undefined;
unit?: "line" | "character" | "offset" | "word" | "block" | undefined;
voids?: boolean | undefined;
} | undefined) => import("slate").BasePoint | undefined;
deleteBackward: (editor: import("slate").BaseEditor & ReactEditor, options?: {
unit?: "line" | "character" | "word" | "block" | undefined;
} | undefined) => void;
deleteForward: (editor: import("slate").BaseEditor & ReactEditor, options?: {
unit?: "line" | "character" | "word" | "block" | undefined;
} | undefined) => void;
deleteFragment: (editor: import("slate").BaseEditor & ReactEditor, options?: {
direction?: "forward" | "backward" | undefined;
} | undefined) => void;
edges: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location) => [import("slate").BasePoint, import("slate").BasePoint];
end: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location) => import("slate").BasePoint;
/**
* Finds the parent block of the text node at the current selection's anchor point,
* then returns the previous node
*/
first: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location) => NodeEntry<Node>;
fragment: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location) => import("slate").Descendant[];
hasBlocks: (editor: import("slate").BaseEditor & ReactEditor, element: import("slate").BaseElement & {
type: string;
}) => boolean;
hasInlines: (editor: import("slate").BaseEditor & ReactEditor, element: import("slate").BaseElement & {
type: string;
}) => boolean;
hasPath: (editor: import("slate").BaseEditor & ReactEditor, path: Path) => boolean;
hasTexts: (editor: import("slate").BaseEditor & ReactEditor, element: import("slate").BaseElement & {
type: string;
}) => boolean;
insertBreak: (editor: import("slate").BaseEditor & ReactEditor) => void;
insertFragment: (editor: import("slate").BaseEditor & ReactEditor, fragment: Node[]) => void;
insertNode: (editor: import("slate").BaseEditor & ReactEditor, node: Node) => void;
insertText: (editor: import("slate").BaseEditor & ReactEditor, text: string) => void;
isBlock: (editor: import("slate").BaseEditor & ReactEditor, value: any) => value is import("slate").BaseElement & {
type: string;
};
isEditor: (value: any) => value is import("slate").BaseEditor & ReactEditor;
isEnd: (editor: import("slate").BaseEditor & ReactEditor, point: import("slate").BasePoint, at: import("slate").Location) => boolean;
isEdge: (editor: import("slate").BaseEditor & ReactEditor, point: import("slate").BasePoint, at: import("slate").Location) => boolean;
isEmpty: (editor: import("slate").BaseEditor & ReactEditor, element: import("slate").BaseElement & {
type: string;
}) => boolean;
isInline: (editor: import("slate").BaseEditor & ReactEditor, value: any) => value is import("slate").BaseElement & {
type: string;
};
isNormalizing: (editor: import("slate").BaseEditor & ReactEditor) => boolean;
isStart: (editor: import("slate").BaseEditor & ReactEditor, point: import("slate").BasePoint, at: import("slate").Location) => boolean;
isVoid: (editor: import("slate").BaseEditor & ReactEditor, value: any) => value is import("slate").BaseElement & {
type: string;
};
last: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location) => NodeEntry<Node>;
leaf: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location, options?: {
depth?: number | undefined;
edge?: "end" | "start" | undefined;
} | undefined) => NodeEntry<import("slate").BaseText & {
[key: string]: string | boolean;
}>;
levels: <T_1 extends Node>(editor: import("slate").BaseEditor & ReactEditor, options?: {
at?: import("slate").Location | undefined;
match?: import("slate").NodeMatch<T_1> | undefined;
reverse?: boolean | undefined;
voids?: boolean | undefined;
} | undefined) => Generator<NodeEntry<T_1>, void, undefined>;
marks: (editor: import("slate").BaseEditor & ReactEditor) => Omit<import("slate").BaseText & {
[key: string]: string | boolean;
}, "text"> | null;
next: <T_2 extends import("slate").Descendant>(editor: import("slate").BaseEditor & ReactEditor, options?: {
at?: import("slate").Location | undefined;
match?: import("slate").NodeMatch<T_2> | undefined;
mode?: "highest" | "lowest" | "all" | undefined;
voids?: boolean | undefined;
} | undefined) => NodeEntry<T_2> | undefined;
node: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location, options?: {
depth?: number | undefined;
edge?: "end" | "start" | undefined;
} | undefined) => NodeEntry<Node>;
nodes: <T_3 extends Node>(editor: import("slate").BaseEditor & ReactEditor, options?: {
at?: import("slate").Location | import("slate").Span | undefined;
match?: import("slate").NodeMatch<T_3> | undefined;
mode?: "highest" | "lowest" | "all" | undefined;
universal?: boolean | undefined;
reverse?: boolean | undefined;
voids?: boolean | undefined;
} | undefined) => Generator<NodeEntry<T_3>, void, undefined>;
normalize: (editor: import("slate").BaseEditor & ReactEditor, options?: {
force?: boolean | undefined;
} | undefined) => void;
parent: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location, options?: {
depth?: number | undefined;
edge?: "end" | "start" | undefined;
} | undefined) => NodeEntry<import("slate").Ancestor>;
path: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location, options?: {
depth?: number | undefined;
edge?: "end" | "start" | undefined;
} | undefined) => Path;
pathRef: (editor: import("slate").BaseEditor & ReactEditor, path: Path, options?: {
affinity?: "forward" | "backward" | null | undefined;
} | undefined) => import("slate").PathRef;
pathRefs: (editor: import("slate").BaseEditor & ReactEditor) => Set<import("slate").PathRef>;
point: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location, options?: {
edge?: "end" | "start" | undefined;
} | undefined) => import("slate").BasePoint;
pointRef: (editor: import("slate").BaseEditor & ReactEditor, point: import("slate").BasePoint, options?: {
affinity?: "forward" | "backward" | null | undefined;
} | undefined) => import("slate").PointRef;
pointRefs: (editor: import("slate").BaseEditor & ReactEditor) => Set<import("slate").PointRef>;
positions: (editor: import("slate").BaseEditor & ReactEditor, options?: {
at?: import("slate").Location | undefined;
unit?: "line" | "character" | "offset" | "word" | "block" | undefined;
reverse?: boolean | undefined;
voids?: boolean | undefined;
} | undefined) => Generator<import("slate").BasePoint, void, undefined>;
previous: <T_4 extends Node>(editor: import("slate").BaseEditor & ReactEditor, options?: {
at?: import("slate").Location | undefined;
match?: import("slate").NodeMatch<T_4> | undefined;
mode?: "highest" | "lowest" | "all" | undefined;
voids?: boolean | undefined;
} | undefined) => NodeEntry<T_4> | undefined;
range: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location, to?: import("slate").Location | undefined) => import("slate").BaseRange;
rangeRef: (editor: import("slate").BaseEditor & ReactEditor, range: import("slate").BaseRange, options?: {
affinity?: "forward" | "backward" | "outward" | "inward" | null | undefined;
} | undefined) => import("slate").RangeRef;
rangeRefs: (editor: import("slate").BaseEditor & ReactEditor) => Set<import("slate").RangeRef>;
removeMark: (editor: import("slate").BaseEditor & ReactEditor, key: string) => void;
setNormalizing: (editor: import("slate").BaseEditor & ReactEditor, isNormalizing: boolean) => void;
start: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location) => import("slate").BasePoint;
string: (editor: import("slate").BaseEditor & ReactEditor, at: import("slate").Location, options?: {
voids?: boolean | undefined;
} | undefined) => string;
unhangRange: (editor: import("slate").BaseEditor & ReactEditor, range: import("slate").BaseRange, options?: {
voids?: boolean | undefined;
} | undefined) => import("slate").BaseRange;
void: (editor: import("slate").BaseEditor & ReactEditor, options?: {
at?: import("slate").Location | undefined;
mode?: "highest" | "lowest" | undefined;
voids?: boolean | undefined;
} | undefined) => NodeEntry<import("slate").BaseElement & {
type: string;
}> | undefined;
withoutNormalizing: (editor: import("slate").BaseEditor & ReactEditor, fn: () => void) => void;
};
declare function isMatchingNodeSelected(editor: Editor, matchFcn: ((node: Node) => boolean) | ((node: Node) => node is Node)): boolean;
declare function isVerseOrChapterNumberSelected(editor: Editor): boolean;
declare function areMultipleBlocksSelected(editor: Editor): boolean;
declare function isNearbyBlockAnInlineContainer(editor: Editor, direction: "previous" | "current" | "next"): boolean;
declare function isNearbyBlockAnEmptyInlineContainer(editor: Editor, direction: "previous" | "current" | "next"): boolean;
declare function isNearbyBlockAVerseNumber(editor: Editor, direction: "previous" | "current" | "next"): boolean;
declare function isNearbyBlockAVerseOrChapterNumberOrNull(editor: Editor, direction: "previous" | "current" | "next"): boolean;
/**
* Finds the parent block of the text node at the current selection's anchor point,
* then returns the previous node
*/
declare function getPreviousBlock(editor: Editor): NodeEntry | undefined;
/**
* Finds the parent block of the text node at the current selection's anchor point
*/
declare function getCurrentBlock(editor: Editor): NodeEntry | undefined;
/**
* Finds the parent block of the text node at the current selection's anchor point,
* then returns the next node
*/
declare function getNextBlock(editor: Editor): NodeEntry | undefined;
/**
* Get the verse corresponding to the given path.
* The verse node must be above the given path in the slate tree.
* If no path is given, the verse above the current selection will be returned.
*/
declare function getVerseNode(editor: Editor, path?: Path): NodeEntry<Element> | undefined;
/**
* Get the previous verse node (before the given path),
* optionally including the "front" verse (default is false)
*/
declare function getPreviousVerse(editor: Editor, path: Path, includeFront?: boolean): NodeEntry<Element> | undefined;
/**
* Get the chapter corresponding to the given path.
* The chapter node must be above the given path in the slate tree.
* If no path is given, the chapter above the current selection will be returned.
*/
declare function getChapterNode(editor: Editor, path?: Path): NodeEntry | undefined;
/**
* Get the last verse of the chapter above the given path.
*/
declare function getLastVerse(editor: Editor, path: Path): NodeEntry | undefined;
/**
* Get the last verse number/range (string) of the chapter above the given path.
*/
declare function getLastVerseNumberOrRange(editor: Editor, path: Path): string | undefined;
/**
* Get the slate path for a given DOMNode
*/
declare function getPathFromDOMNode(editor: ReactEditor, domNode: DOMNode): Path;
/**
* Gets the identification headers in json format
*/
declare function identification(editor: Editor): IdentificationHeaders;
/**
* Finds the path of a verse that matches the given chapter and
* verse numbers. A value of "0" indicates "front".
*/
declare function findVersePath(editor: Editor, chapterNum: number, verseNum: number): Path | undefined;
export {};