lakelib
Version:
Lake is a rich text editor built for modern applications that require content creation like blog posts, user comments, and email composition.
1,975 lines (1,962 loc) • 84.2 kB
TypeScript
import EventEmitter from 'eventemitter3';
import { LocalizedString, RequiredParams } from 'typesafe-i18n';
type KeyValue = Record<string, string>;
type ContentStyleValue = string | string[] | RegExp;
type ContentStyle = Record<string, ContentStyleValue>;
type ContentAttributeValue = string | string[] | RegExp | ContentStyle;
type ContentAttribute = Record<string, ContentAttributeValue>;
type ContentRules = Record<string, string | ContentAttribute>;
interface EventItem {
type: string;
listener: EventListener;
}
/**
* The Nodes interface represents a collection of the nodes.
* It is similar to jQuery, but its implementation is much simpler.
* Its methods can be considered aliases of native DOM interfaces, designed to simplify DOM manipulation.
*/
declare class Nodes {
/**
* A list of native nodes.
*/
private readonly nodeList;
/**
* The number of nodes in the Nodes object.
*/
readonly length: number;
constructor(node?: Node | Node[] | null);
/**
* The unique ID of the first node.
*/
get id(): number;
/**
* The name of the first node.
*/
get name(): string;
/**
* A boolean value indicating whether the first node is an element.
*/
get isElement(): boolean;
/**
* A boolean value indicating whether the first node is a text.
*/
get isText(): boolean;
/**
* A boolean value indicating whether the first node is a block.
*/
get isBlock(): boolean;
/**
* A boolean value indicating whether the first node is a mark.
*/
get isMark(): boolean;
/**
* A boolean value indicating whether the first node is a void element that cannot have any child nodes.
*/
get isVoid(): boolean;
/**
* A boolean value indicating whether the first node is a heading.
*/
get isHeading(): boolean;
/**
* A boolean value indicating whether the first node is a list.
*/
get isList(): boolean;
/**
* A boolean value indicating whether the first node is a table.
*/
get isTable(): boolean;
/**
* A boolean value indicating whether the first node is a bookmark element.
*/
get isBookmark(): boolean;
/**
* A boolean value indicating whether the first node is a box element.
*/
get isBox(): boolean;
/**
* A boolean value indicating whether the first node is an inline box element.
*/
get isInlineBox(): boolean;
/**
* A boolean value indicating whether the first node is a block box element.
*/
get isBlockBox(): boolean;
/**
* A boolean value indicating whether the first node is a contenteditable element where users can edit the content.
*/
get isContainer(): boolean;
/**
* A boolean value indicating whether the first node does not have an ancestor element which contenteditable attribute is true.
*/
get isOutside(): boolean;
/**
* A boolean value indicating whether the first node has an ancestor element which contenteditable attribute is true.
*/
get isInside(): boolean;
/**
* A boolean value indicating whether the first node's parent element is an element which contenteditable attribute is true.
*/
get isTopInside(): boolean;
/**
* A boolean value indicating whether the first node is editable.
*/
get isContentEditable(): boolean;
/**
* A boolean value indicating whether the first node is indivisible.
*/
get isIndivisible(): boolean;
/**
* A boolean value indicating whether the first node is empty.
*/
get isEmpty(): boolean;
/**
* Returns a native node at the specified index.
*/
get(index: number): Node;
/**
* Returns all native nodes.
*/
getAll(): Node[];
/**
* Returns a new Nodes object that includes only the node at the specified index.
*/
eq(index: number): Nodes;
/**
* Executes a provided function once for each node.
*/
each(callback: (node: Node, index: number) => boolean | void): this;
/**
* Executes a provided function once for each element.
*/
eachElement(callback: (element: Element, index: number) => boolean | void): this;
/**
* Returns a new Nodes object with the nodes in reversed order.
*/
reverse(): Nodes;
/**
* Tests whether the first node would be selected by the specified CSS selector.
*/
matches(selector: string): boolean;
/**
* Returns a boolean value indicating whether the given node is a descendant of the first node,
* that is the node itself, one of its direct children (childNodes), one of the children's direct children, and so on.
*/
contains(otherNode: Nodes): boolean;
/**
* Returns a boolean value indicating whether the first node and a given node are siblings.
*/
isSibling(otherNode: Nodes): boolean;
/**
* Returns the descendants of the first node that match the specified CSS selector or node path.
*/
find(selector: string | NodePath): Nodes;
/**
* Traverses the first node and its parents (heading toward the document root) until it finds an element that matches the specified CSS selector.
*/
closest(selector: string): Nodes;
/**
* Traverses the first node and its parents until it finds a block element.
*/
closestBlock(): Nodes;
/**
* Traverses the first node and its parents until it finds an operable block.
*/
closestOperableBlock(): Nodes;
/**
* Traverses the first node and its parents until it finds a div element which contenteditable attribute is true.
*/
closestContainer(): Nodes;
/**
* Traverses the first node and its parents until it finds an element which can scroll.
*/
closestScroller(): Nodes;
/**
* Returns the parent of the first node.
*/
parent(): Nodes;
/**
* Returns the immediately preceding sibling of the first node.
*/
prev(): Nodes;
/**
* Returns the immediately following sibling of the first node.
*/
next(): Nodes;
/**
* Returns the first child of the first node.
*/
first(): Nodes;
/**
* Returns the last child of the first node.
*/
last(): Nodes;
/**
* Returns a number indicating the position of the first node relative to its sibling nodes.
*/
index(): number;
/**
* Returns the path of the first node.
*/
path(): NodePath;
/**
* Returns a list which contains all of the child nodes of the first node.
*/
children(): Nodes[];
/**
* Returns a generator that iterates over the descendants of the first node.
*/
getWalker(): Generator<Nodes>;
/**
* Sets up an event listener for each element.
*/
on(type: string, listener: EventListener): this;
/**
* Removes event listeners previously registered with on() method.
*/
off(type?: string, listener?: EventListener): this;
/**
* Executes all event listeners attached to all nodes for the given event type.
*/
emit(type: string, event?: Event): this;
/**
* Returns all event listeners attached to the node at the specified index.
*/
getEventListeners(index: number): EventItem[];
/**
* Sets focus on the specified node, if it can be focused.
*/
focus(): this;
/**
* Removes focus from the specified node.
*/
blur(): this;
/**
* Returns a copy of the first node. If deep is true, the copy also includes the node's descendants.
*/
clone(deep?: boolean): Nodes;
/**
* Returns a boolean value indicating whether the first node has the specified attribute or not.
*/
hasAttr(attributeName: string): boolean;
/**
* Returns the value of the specified attribute from the first node, or sets the values of attributes for all elements.
*/
attr(attributeName: string): string;
attr(attributeName: string, value: string): this;
attr(attributeName: KeyValue): this;
/**
* Removes the attribute with the specified name from every element.
*/
removeAttr(attributeName: string): this;
/**
* Returns a boolean value indicating whether the first node has the specified class or not.
*/
hasClass(className: string): boolean;
/**
* Adds the given class to every element.
*/
addClass(className: string | string[]): this;
/**
* Removes the given class from every element.
*/
removeClass(className: string | string[]): this;
/**
* Returns the value of the given CSS property of the first node,
* after applying active stylesheets and resolving any basic computation this value may contain.
*/
computedCSS(propertyName: string): string;
/**
* Returns the value of the given CSS property of the first node, or sets the values of CSS properties for all elements.
*/
css(propertyName: string): string;
css(propertyName: KeyValue): this;
css(propertyName: string, value: string): this;
/**
* Returns the width of of the first node.
*/
width(): number;
/**
* Returns the interior width of the first node, which does not include padding.
*/
innerWidth(): number;
/**
* Returns the height of of the first node.
*/
height(): number;
/**
* Displays all nodes.
*/
show(displayType?: string): this;
/**
* Hides all nodes.
*/
hide(): this;
/**
* Returns the HTML string contained within the first node, or sets the HTML string for all elements.
*/
html(): string;
html(value: string): this;
/**
* Returns the rendered text content of the first node, or sets the rendered text content for all elements.
*/
text(): string;
text(value: string): this;
/**
* Returns the value of the first node, which must be an input element, or sets the value for all input elements.
*/
value(): string;
value(value: string): this;
/**
* Returns the HTML string describing the first node including its descendants.
*/
outerHTML(): string;
/**
* Removes all child nodes for each element.
*/
empty(): this;
/**
* Inserts the specified content just inside the first node, before its first child.
*/
prepend(content: string | Node | DocumentFragment | Nodes): this;
/**
* Inserts the specified content just inside the first node, after its last child.
*/
append(content: string | Node | DocumentFragment | Nodes): this;
/**
* Inserts the specified content before the first node.
*/
before(content: string | Node | DocumentFragment | Nodes): this;
/**
* Inserts the specified content after the first node.
*/
after(content: string | Node | DocumentFragment | Nodes): this;
/**
* Replaces the first node with the given new content.
*/
replaceWith(newContent: string | Node | Nodes): this;
/**
* Removes all nodes from the DOM.
*/
remove(keepChildren?: boolean): this;
/**
* Splits the first node, which must be a text node, into two nodes at the specified offset, keeping both as siblings in the tree.
*/
splitText(offset: number): Nodes;
/**
* Returns information about the first node, which is used for debugging.
*/
toString(): string;
/**
* Prints information about the first node, which is used for debugging.
*/
info(): void;
}
interface TwoParts {
start: Nodes | null;
end: Nodes | null;
}
interface ThreeParts extends TwoParts {
center: Nodes | null;
}
type NodePath = number[];
interface ActiveItem {
node: Nodes;
name: string;
attributes: KeyValue;
styles: KeyValue;
}
interface SelectionState {
activeItems: ActiveItem[];
disabledNameMap?: Map<string, boolean>;
selectedNameMap?: Map<string, boolean>;
selectedValuesMap?: Map<string, string[]>;
}
type Translation = RootTranslation;
type RootTranslation = {
toolbar: {
/**
* Undo (mod+Z)
*/
undo: string;
/**
* Redo (mod+Y)
*/
redo: string;
/**
* Select all (mod+A)
*/
selectAll: string;
/**
* Paragraph
*/
paragraph: string;
/**
* Block quotation
*/
blockQuote: string;
/**
* Numbered list
*/
numberedList: string;
/**
* Bulleted list
*/
bulletedList: string;
/**
* Checklist
*/
checklist: string;
/**
* Align left
*/
alignLeft: string;
/**
* Align center
*/
alignCenter: string;
/**
* Align right
*/
alignRight: string;
/**
* Justify
*/
alignJustify: string;
/**
* Increase indent
*/
increaseIndent: string;
/**
* Decrease indent
*/
decreaseIndent: string;
/**
* Bold (mod+B)
*/
bold: string;
/**
* Italic (mod+I)
*/
italic: string;
/**
* Underline (mod+U)
*/
underline: string;
/**
* Strikethrough
*/
strikethrough: string;
/**
* Superscript
*/
superscript: string;
/**
* Subscript
*/
subscript: string;
/**
* Inline code
*/
code: string;
/**
* Remove format
*/
removeFormat: string;
/**
* Format painter
*/
formatPainter: string;
/**
* Link
*/
link: string;
/**
* Horizontal line
*/
hr: string;
/**
* YouTube
*/
video: string;
/**
* Code block
*/
codeBlock: string;
/**
* Heading
*/
heading: string;
/**
* Heading 1
*/
heading1: string;
/**
* Heading 2
*/
heading2: string;
/**
* Heading 3
*/
heading3: string;
/**
* Heading 4
*/
heading4: string;
/**
* Heading 5
*/
heading5: string;
/**
* Heading 6
*/
heading6: string;
/**
* List
*/
list: string;
/**
* Table
*/
table: string;
/**
* Alignment
*/
align: string;
/**
* Indent
*/
indent: string;
/**
* Font family
*/
fontFamily: string;
/**
* Font size
*/
fontSize: string;
/**
* More style
*/
moreStyle: string;
/**
* Font color
*/
fontColor: string;
/**
* Highlight
*/
highlight: string;
/**
* Image
*/
image: string;
/**
* Video
*/
media: string;
/**
* File
*/
file: string;
/**
* Emoji
*/
emoji: string;
/**
* Mathematical formula
*/
equation: string;
/**
* X (Tweet)
*/
twitter: string;
/**
* Remove color
*/
removeColor: string;
};
slash: {
/**
* Heading 1
*/
heading1: string;
/**
* Create a heading level 1
*/
heading1Desc: string;
/**
* Heading 2
*/
heading2: string;
/**
* Create a heading level 2
*/
heading2Desc: string;
/**
* Heading 3
*/
heading3: string;
/**
* Create a heading level 3
*/
heading3Desc: string;
/**
* Heading 4
*/
heading4: string;
/**
* Create a heading level 4
*/
heading4Desc: string;
/**
* Heading 5
*/
heading5: string;
/**
* Create a heading level 5
*/
heading5Desc: string;
/**
* Heading 6
*/
heading6: string;
/**
* Create a heading level 6
*/
heading6Desc: string;
/**
* Paragraph
*/
paragraph: string;
/**
* Create a paragraph
*/
paragraphDesc: string;
/**
* Block quotation
*/
blockQuote: string;
/**
* Create a block quotation
*/
blockQuoteDesc: string;
/**
* Numbered list
*/
numberedList: string;
/**
* Create a numbered list
*/
numberedListDesc: string;
/**
* Bulleted list
*/
bulletedList: string;
/**
* Create a bulleted list
*/
bulletedListDesc: string;
/**
* Checklist
*/
checklist: string;
/**
* Create a checklist
*/
checklistDesc: string;
/**
* Table
*/
table: string;
/**
* Insert a table
*/
tableDesc: string;
/**
* Info alert
*/
infoAlert: string;
/**
* Create an info alert
*/
infoAlertDesc: string;
/**
* Tip alert
*/
tipAlert: string;
/**
* Create a tip alert
*/
tipAlertDesc: string;
/**
* Warning alert
*/
warningAlert: string;
/**
* Create a warning alert
*/
warningAlertDesc: string;
/**
* Danger alert
*/
dangerAlert: string;
/**
* Create a danger alert
*/
dangerAlertDesc: string;
/**
* Horizontal line
*/
hr: string;
/**
* Insert a horizontal line
*/
hrDesc: string;
/**
* Code block
*/
codeBlock: string;
/**
* Insert a code block
*/
codeBlockDesc: string;
/**
* YouTube
*/
video: string;
/**
* Insert a YouTube video
*/
videoDesc: string;
/**
* Mathematical formula
*/
equation: string;
/**
* Insert a TeX expression
*/
equationDesc: string;
/**
* Tweet
*/
twitter: string;
/**
* Insert an X (Tweet)
*/
twitterDesc: string;
/**
* Image
*/
image: string;
/**
* Upload an image
*/
imageDesc: string;
/**
* File
*/
file: string;
/**
* Upload a file
*/
fileDesc: string;
};
link: {
/**
* New link
*/
newLink: string;
/**
* Link URL
*/
url: string;
/**
* Text to display
*/
title: string;
/**
* Copy link to clipboard
*/
copy: string;
/**
* Open link in new tab
*/
open: string;
/**
* Save
*/
save: string;
/**
* Remove link
*/
unlink: string;
};
table: {
/**
* Fit table to page width
*/
fitTable: string;
/**
* Cell background color
*/
cellBackground: string;
/**
* Column
*/
column: string;
/**
* Insert column left
*/
insertColumnLeft: string;
/**
* Insert column right
*/
insertColumnRight: string;
/**
* Delete column
*/
deleteColumn: string;
/**
* Row
*/
row: string;
/**
* Insert row above
*/
insertRowAbove: string;
/**
* Insert row below
*/
insertRowBelow: string;
/**
* Delete row
*/
deleteRow: string;
/**
* Merge cells
*/
merge: string;
/**
* Merge cell up
*/
mergeUp: string;
/**
* Merge cell right
*/
mergeRight: string;
/**
* Merge cell down
*/
mergeDown: string;
/**
* Merge cell left
*/
mergeLeft: string;
/**
* Split cell
*/
split: string;
/**
* Split cell left and right
*/
splitLeftRight: string;
/**
* Split cell top and bottom
*/
splitTopBottom: string;
/**
* Remove table
*/
remove: string;
};
image: {
/**
* Full screen
*/
view: string;
/**
* Delete
*/
remove: string;
/**
* Previous
*/
previous: string;
/**
* Next
*/
next: string;
/**
* Close (Esc)
*/
close: string;
/**
* Unable to load image.
*/
loadingError: string;
/**
* Zoom out
*/
zoomOut: string;
/**
* Zoom in
*/
zoomIn: string;
/**
* Alignment
*/
align: string;
/**
* Align left
*/
alignLeft: string;
/**
* Align center
*/
alignCenter: string;
/**
* Align right
*/
alignRight: string;
/**
* Resize image
*/
resize: string;
/**
* Page width
*/
pageWidth: string;
/**
* Original image width
*/
originalWidth: string;
/**
* {0} image width
* @param {unknown} 0
*/
imageWidth: RequiredParams<'0'>;
/**
* Open image in new tab
*/
open: string;
/**
* Caption
*/
caption: string;
/**
* Write a caption...
*/
captionPlaceholder: string;
};
media: {
/**
* Download
*/
download: string;
/**
* Delete
*/
remove: string;
};
file: {
/**
* Download
*/
download: string;
/**
* Delete
*/
remove: string;
};
video: {
/**
* Embed video
*/
embed: string;
/**
* Delete
*/
remove: string;
/**
* Paste your YouTube link below.
*/
description: string;
/**
* Link
*/
url: string;
/**
* Please enter a valid link.
*/
urlError: string;
};
codeBlock: {
/**
* Select language
*/
langType: string;
};
equation: {
/**
* Done
*/
save: string;
/**
* Supported functions
*/
help: string;
/**
* Type a TeX expression...
*/
placeholder: string;
};
twitter: {
/**
* Embed Tweet
*/
embed: string;
/**
* Delete
*/
remove: string;
/**
* Paste your X (Twitter) link below.
*/
description: string;
/**
* Link
*/
url: string;
/**
* Please enter a valid link.
*/
urlError: string;
};
};
type TranslationFunctions = {
toolbar: {
/**
* Undo (mod+Z)
*/
undo: () => LocalizedString;
/**
* Redo (mod+Y)
*/
redo: () => LocalizedString;
/**
* Select all (mod+A)
*/
selectAll: () => LocalizedString;
/**
* Paragraph
*/
paragraph: () => LocalizedString;
/**
* Block quotation
*/
blockQuote: () => LocalizedString;
/**
* Numbered list
*/
numberedList: () => LocalizedString;
/**
* Bulleted list
*/
bulletedList: () => LocalizedString;
/**
* Checklist
*/
checklist: () => LocalizedString;
/**
* Align left
*/
alignLeft: () => LocalizedString;
/**
* Align center
*/
alignCenter: () => LocalizedString;
/**
* Align right
*/
alignRight: () => LocalizedString;
/**
* Justify
*/
alignJustify: () => LocalizedString;
/**
* Increase indent
*/
increaseIndent: () => LocalizedString;
/**
* Decrease indent
*/
decreaseIndent: () => LocalizedString;
/**
* Bold (mod+B)
*/
bold: () => LocalizedString;
/**
* Italic (mod+I)
*/
italic: () => LocalizedString;
/**
* Underline (mod+U)
*/
underline: () => LocalizedString;
/**
* Strikethrough
*/
strikethrough: () => LocalizedString;
/**
* Superscript
*/
superscript: () => LocalizedString;
/**
* Subscript
*/
subscript: () => LocalizedString;
/**
* Inline code
*/
code: () => LocalizedString;
/**
* Remove format
*/
removeFormat: () => LocalizedString;
/**
* Format painter
*/
formatPainter: () => LocalizedString;
/**
* Link
*/
link: () => LocalizedString;
/**
* Horizontal line
*/
hr: () => LocalizedString;
/**
* YouTube
*/
video: () => LocalizedString;
/**
* Code block
*/
codeBlock: () => LocalizedString;
/**
* Heading
*/
heading: () => LocalizedString;
/**
* Heading 1
*/
heading1: () => LocalizedString;
/**
* Heading 2
*/
heading2: () => LocalizedString;
/**
* Heading 3
*/
heading3: () => LocalizedString;
/**
* Heading 4
*/
heading4: () => LocalizedString;
/**
* Heading 5
*/
heading5: () => LocalizedString;
/**
* Heading 6
*/
heading6: () => LocalizedString;
/**
* List
*/
list: () => LocalizedString;
/**
* Table
*/
table: () => LocalizedString;
/**
* Alignment
*/
align: () => LocalizedString;
/**
* Indent
*/
indent: () => LocalizedString;
/**
* Font family
*/
fontFamily: () => LocalizedString;
/**
* Font size
*/
fontSize: () => LocalizedString;
/**
* More style
*/
moreStyle: () => LocalizedString;
/**
* Font color
*/
fontColor: () => LocalizedString;
/**
* Highlight
*/
highlight: () => LocalizedString;
/**
* Image
*/
image: () => LocalizedString;
/**
* Video
*/
media: () => LocalizedString;
/**
* File
*/
file: () => LocalizedString;
/**
* Emoji
*/
emoji: () => LocalizedString;
/**
* Mathematical formula
*/
equation: () => LocalizedString;
/**
* X (Tweet)
*/
twitter: () => LocalizedString;
/**
* Remove color
*/
removeColor: () => LocalizedString;
};
slash: {
/**
* Heading 1
*/
heading1: () => LocalizedString;
/**
* Create a heading level 1
*/
heading1Desc: () => LocalizedString;
/**
* Heading 2
*/
heading2: () => LocalizedString;
/**
* Create a heading level 2
*/
heading2Desc: () => LocalizedString;
/**
* Heading 3
*/
heading3: () => LocalizedString;
/**
* Create a heading level 3
*/
heading3Desc: () => LocalizedString;
/**
* Heading 4
*/
heading4: () => LocalizedString;
/**
* Create a heading level 4
*/
heading4Desc: () => LocalizedString;
/**
* Heading 5
*/
heading5: () => LocalizedString;
/**
* Create a heading level 5
*/
heading5Desc: () => LocalizedString;
/**
* Heading 6
*/
heading6: () => LocalizedString;
/**
* Create a heading level 6
*/
heading6Desc: () => LocalizedString;
/**
* Paragraph
*/
paragraph: () => LocalizedString;
/**
* Create a paragraph
*/
paragraphDesc: () => LocalizedString;
/**
* Block quotation
*/
blockQuote: () => LocalizedString;
/**
* Create a block quotation
*/
blockQuoteDesc: () => LocalizedString;
/**
* Numbered list
*/
numberedList: () => LocalizedString;
/**
* Create a numbered list
*/
numberedListDesc: () => LocalizedString;
/**
* Bulleted list
*/
bulletedList: () => LocalizedString;
/**
* Create a bulleted list
*/
bulletedListDesc: () => LocalizedString;
/**
* Checklist
*/
checklist: () => LocalizedString;
/**
* Create a checklist
*/
checklistDesc: () => LocalizedString;
/**
* Table
*/
table: () => LocalizedString;
/**
* Insert a table
*/
tableDesc: () => LocalizedString;
/**
* Info alert
*/
infoAlert: () => LocalizedString;
/**
* Create an info alert
*/
infoAlertDesc: () => LocalizedString;
/**
* Tip alert
*/
tipAlert: () => LocalizedString;
/**
* Create a tip alert
*/
tipAlertDesc: () => LocalizedString;
/**
* Warning alert
*/
warningAlert: () => LocalizedString;
/**
* Create a warning alert
*/
warningAlertDesc: () => LocalizedString;
/**
* Danger alert
*/
dangerAlert: () => LocalizedString;
/**
* Create a danger alert
*/
dangerAlertDesc: () => LocalizedString;
/**
* Horizontal line
*/
hr: () => LocalizedString;
/**
* Insert a horizontal line
*/
hrDesc: () => LocalizedString;
/**
* Code block
*/
codeBlock: () => LocalizedString;
/**
* Insert a code block
*/
codeBlockDesc: () => LocalizedString;
/**
* YouTube
*/
video: () => LocalizedString;
/**
* Insert a YouTube video
*/
videoDesc: () => LocalizedString;
/**
* Mathematical formula
*/
equation: () => LocalizedString;
/**
* Insert a TeX expression
*/
equationDesc: () => LocalizedString;
/**
* Tweet
*/
twitter: () => LocalizedString;
/**
* Insert an X (Tweet)
*/
twitterDesc: () => LocalizedString;
/**
* Image
*/
image: () => LocalizedString;
/**
* Upload an image
*/
imageDesc: () => LocalizedString;
/**
* File
*/
file: () => LocalizedString;
/**
* Upload a file
*/
fileDesc: () => LocalizedString;
};
link: {
/**
* New link
*/
newLink: () => LocalizedString;
/**
* Link URL
*/
url: () => LocalizedString;
/**
* Text to display
*/
title: () => LocalizedString;
/**
* Copy link to clipboard
*/
copy: () => LocalizedString;
/**
* Open link in new tab
*/
open: () => LocalizedString;
/**
* Save
*/
save: () => LocalizedString;
/**
* Remove link
*/
unlink: () => LocalizedString;
};
table: {
/**
* Fit table to page width
*/
fitTable: () => LocalizedString;
/**
* Cell background color
*/
cellBackground: () => LocalizedString;
/**
* Column
*/
column: () => LocalizedString;
/**
* Insert column left
*/
insertColumnLeft: () => LocalizedString;
/**
* Insert column right
*/
insertColumnRight: () => LocalizedString;
/**
* Delete column
*/
deleteColumn: () => LocalizedString;
/**
* Row
*/
row: () => LocalizedString;
/**
* Insert row above
*/
insertRowAbove: () => LocalizedString;
/**
* Insert row below
*/
insertRowBelow: () => LocalizedString;
/**
* Delete row
*/
deleteRow: () => LocalizedString;
/**
* Merge cells
*/
merge: () => LocalizedString;
/**
* Merge cell up
*/
mergeUp: () => LocalizedString;
/**
* Merge cell right
*/
mergeRight: () => LocalizedString;
/**
* Merge cell down
*/
mergeDown: () => LocalizedString;
/**
* Merge cell left
*/
mergeLeft: () => LocalizedString;
/**
* Split cell
*/
split: () => LocalizedString;
/**
* Split cell left and right
*/
splitLeftRight: () => LocalizedString;
/**
* Split cell top and bottom
*/
splitTopBottom: () => LocalizedString;
/**
* Remove table
*/
remove: () => LocalizedString;
};
image: {
/**
* Full screen
*/
view: () => LocalizedString;
/**
* Delete
*/
remove: () => LocalizedString;
/**
* Previous
*/
previous: () => LocalizedString;
/**
* Next
*/
next: () => LocalizedString;
/**
* Close (Esc)
*/
close: () => LocalizedString;
/**
* Unable to load image.
*/
loadingError: () => LocalizedString;
/**
* Zoom out
*/
zoomOut: () => LocalizedString;
/**
* Zoom in
*/
zoomIn: () => LocalizedString;
/**
* Alignment
*/
align: () => LocalizedString;
/**
* Align left
*/
alignLeft: () => LocalizedString;
/**
* Align center
*/
alignCenter: () => LocalizedString;
/**
* Align right
*/
alignRight: () => LocalizedString;
/**
* Resize image
*/
resize: () => LocalizedString;
/**
* Page width
*/
pageWidth: () => LocalizedString;
/**
* Original image width
*/
originalWidth: () => LocalizedString;
/**
* {0} image width
*/
imageWidth: (arg0: unknown) => LocalizedString;
/**
* Open image in new tab
*/
open: () => LocalizedString;
/**
* Caption
*/
caption: () => LocalizedString;
/**
* Write a caption...
*/
captionPlaceholder: () => LocalizedString;
};
media: {
/**
* Download
*/
download: () => LocalizedString;
/**
* Delete
*/
remove: () => LocalizedString;
};
file: {
/**
* Download
*/
download: () => LocalizedString;
/**
* Delete
*/
remove: () => LocalizedString;
};
video: {
/**
* Embed video
*/
embed: () => LocalizedString;
/**
* Delete
*/
remove: () => LocalizedString;
/**
* Paste your YouTube link below.
*/
description: () => LocalizedString;
/**
* Link
*/
url: () => LocalizedString;
/**
* Please enter a valid link.
*/
urlError: () => LocalizedString;
};
codeBlock: {
/**
* Select language
*/
langType: () => LocalizedString;
};
equation: {
/**
* Done
*/
save: () => LocalizedString;
/**
* Supported functions
*/
help: () => LocalizedString;
/**
* Type a TeX expression...
*/
placeholder: () => LocalizedString;
};
twitter: {
/**
* Embed Tweet
*/
embed: () => LocalizedString;
/**
* Delete
*/
remove: () => LocalizedString;
/**
* Paste your X (Twitter) link below.
*/
description: () => LocalizedString;
/**
* Link
*/
url: () => LocalizedString;
/**
* Please enter a valid link.
*/
urlError: () => LocalizedString;
};
};
/**
* The LocaleManager interface manages a collection of Translation objects.
* It allows you to add and retrieve the names of locales.
*/
declare class LocaleManager {
/**
* Adds a Translation to the collection.
*/
add(locale: string, translation: Translation): void;
/**
* Returns a list of all locale names.
*/
getNames(): string[];
}
type NativeRange = Range;
/**
* The Range interface represents a fragment of a document that can contain nodes and parts of text nodes.
* Its interface is similar to the native Range, with some additional properties and methods specifically designed for more efficient manipulation.
*/
declare class Range$1 {
/**
* A native Range object.
*/
private readonly range;
constructor(range?: NativeRange);
/**
* A node within which the range starts.
*/
get startNode(): Nodes;
/**
* A number representing where in the startNode the range starts.
*/
get startOffset(): number;
/**
* A node within which the range ends.
*/
get endNode(): Nodes;
/**
* A number representing where in the endNode the range ends.
*/
get endOffset(): number;
/**
* The deepest node, or the lowest point in the document tree, that contains both boundary points of the range.
*/
get commonAncestor(): Nodes;
/**
* A boolean value indicating whether the range's start and end points are at the same position.
*/
get isCollapsed(): boolean;
/**
* A boolean value indicating whether the range's start point is in a box.
*/
get isBox(): boolean;
/**
* A boolean value indicating whether the commonAncestor is in the start position of a box.
*/
get isBoxStart(): boolean;
/**
* A boolean value indicating whether the commonAncestor is in the center position of a box.
*/
get isBoxCenter(): boolean;
/**
* A boolean value indicating whether commonAncestor is in the end position of a box.
*/
get isBoxEnd(): boolean;
/**
* A boolean value indicating whether commonAncestor is inside the container of a box.
*/
get isInsideBox(): boolean;
/**
* A boolean value indicating whether the range is inoperative.
*/
get isInoperative(): boolean;
/**
* Returns a native Range object from the range.
*/
get(): NativeRange;
/**
* Returns the size and position of the range.
*/
getRect(): DOMRect;
/**
* Returns -1, 0, or 1 depending on whether the specified node is before, the same as, or after the range.
* −1 if the point is before the range. 0 if the point is in the range. 1 if the point is after the range.
*/
comparePoint(node: Nodes, offset: number): number;
/**
* Returns -1, 0, or 1 depending on whether the beginning of the specified node is before, the same as, or after the range.
* −1 if the beginning of the node is before the range. 0 if the beginning of the node is in the range. 1 if the beginning of the node is after the range.
*/
compareBeforeNode(node: Nodes): number;
/**
* Returns -1, 0, or 1 depending on whether the end of the specified node is before, the same as, or after the range.
* −1 if the end of the node is before the range. 0 if the end of the node is in the range. 1 if the end of the node is after the range.
*/
compareAfterNode(node: Nodes): number;
/**
* Returns a boolean value indicating whether the specified node is part of the range or intersects the range.
*/
intersectsNode(node: Nodes): boolean;
/**
* Sets the start position of the range.
*/
setStart(node: Nodes, offset: number): void;
/**
* Sets the start position of the range to the beginning of the specified node.
*/
setStartBefore(node: Nodes): void;
/**
* Sets the start position of the range to the end of the specified node.
*/
setStartAfter(node: Nodes): void;
/**
* Sets the end position of the range.
*/
setEnd(node: Nodes, offset: number): void;
/**
* Sets the end position of the range to the beginning of the specified node.
*/
setEndBefore(node: Nodes): void;
/**
* Sets the end position of the range to the end of the specified node.
*/
setEndAfter(node: Nodes): void;
/**
* Collapses the range to its start.
*/
collapseToStart(): void;
/**
* Collapses the range to its end.
*/
collapseToEnd(): void;
/**
* Sets the range to contain the specified node and its contents.
*/
selectNode(node: Nodes): void;
/**
* Sets the range to contain the contents of the specified node.
*/
selectNodeContents(node: Nodes): void;
/**
* Collapses the range to the center position of the specified box.
*/
selectBox(boxNode: Nodes): void;
/**
* Collapses the range to the start position of the specified box.
*/
selectBoxStart(boxNode: Nodes): void;
/**
* Collapses the range to the end position of the specified box.
*/
selectBoxEnd(boxNode: Nodes): void;
/**
* Collapses the range to the deepest point at the beginning of the contents of the specified node.
*/
shrinkBefore(node: Nodes): void;
/**
* Collapses the range to the deepest point at the end of the contents of the specified node.
*/
shrinkAfter(node: Nodes): void;
/**
* Sets the start and end positions of the range to the deepest start position and end position of the contents of the specified node.
*/
shrink(): void;
/**
* Relocates the start and end positions of the range for boxes.
*/
adjustBox(): void;
/**
* Relocates the start and end positions of the range for tables.
*/
adjustTable(): void;
/**
* Relocates the start and end positions of the range for blocks.
*/
adjustBlock(): void;
/**
* Relocates the start and end positions of the range for boxes, tables, and blocks.
*/
adjust(): void;
/**
* Relocates the start and end positions of the range for <br /> elements.
*/
adjustBr(): void;
/**
* Returns the node immediately preceding the start position of the range.
*/
getPrevNode(): Nodes;
/**
* Returns the node immediately following the end position of the range.
*/
getNextNode(): Nodes;
/**
* Returns the boxes contained within or intersected by the range.
*/
getBoxes(): Nodes[];
/**
* Returns the blocks contained within or intersected by the range.
*/
getBlocks(): Nodes[];
/**
* Returns the marks and text nodes contained within or intersected by the range.
*/
getMarks(hasText?: boolean): Nodes[];
/**
* Returns the text from the start position of the closest block to the start position of the range.
*/
getStartText(): string;
/**
* Returns the text from the end position of the range to the end position of the closest block.
*/
getEndText(): string;
/**
* Returns a new range from the specified character to the start position of the range.
* The specified character must be preceded by a whitespace or be at the beginning of a paragraph,
* without being adjacent to other characters. It will return null if not.
*/
getCharacterRange(character: string): Range$1 | null;
/**
* Returns a copy of the range.
*/
clone(): Range$1;
/**
* Returns a DocumentFragment object copying the nodes included in the range.
*/
cloneContents(): DocumentFragment;
/**
* Prints information about the range, which is used for debugging.
*/
info(): void;
}
/**
* Inserts a bookmark at the cursor position or a pair of bookmarks at the beginning and end of the range.
*/
declare function insertBookmark(range: Range$1): {
anchor: Nodes;
focus: Nodes;
};
/**
* Changes the specified range to a range represented by the provided bookmark.
*/
declare function toBookmark(range: Range$1, bookmark: {
anchor: Nodes;
focus: Nodes;
}): void;
/**
* The Fragment interface represents a lightweight document object that has no parent.
* It is designed for efficient manipulation of document structures without affecting the main DOM.
*/
declare class Fragment {
/**
* A native DocumentFragment object.
*/
private readonly fragment;
constructor(fragment?: DocumentFragment);
/**
* Returns a native DocumentFragment object from the fragment.
*/
get(): DocumentFragment;
/**
* Finds and returns descendants of the fragment that match the specified CSS selector.
*/
find(selector: string): Nodes;
/**
* Inserts the specified content just inside the fragment, after its last child.
*/
append(content: string | Node | Nodes): void;