europa-core
Version:
Europa core engine for converting HTML into valid Markdown
59 lines (58 loc) • 2.36 kB
TypeScript
import { DomElement } from "./DomElement";
import { DomNode } from "./DomNode";
import { DomRoot } from "./DomRoot";
/**
* A wrapper for a DOM that supports multiple environments within {@link EuropaCore} and its plugin/preset ecosystem.
*
* To begin using the DOM wrapper, first call {@link Dom#createRoot} to create a wrapper for the DOM root containing the
* desired children.
*/
export interface Dom<N, E extends N, R extends DomRoot> {
/**
* Creates a wrapper for the specified DOM `element` in the `root` provided.
*
* @param element - The DOM element to be wrapped.
* @param root - The DOM root wrapper in which `element` exists.
* @return The wrapped DOM `element`.
*/
createElement(element: E, root: R): DomElement;
/**
* Creates a wrapper for the specified DOM `node` in the `root` provided.
*
* @param node - The DOM node to be wrapped.
* @param root - The DOM root wrapper in which `node` exists.
* @return The wrapped DOM `node`.
*/
createNode(node: N, root: R): DomNode;
/**
* Creates a DOM root wrapper containing the specified `contents`.
*
* @param contents - The DOM node(s) or HTML string to be appended to the created DOM root wrapper.
* @return A DOM root wrapper containing `contents`.
*/
createRoot(contents: N | N[] | string): R;
/**
* Checks whether the specified DOM `node` is a DOM element in the `root` provided.
*
* @param node - The DOM node to be checked.
* @param root - The DOM root wrapper to be checked.
* @return `true` if `node` is a DOM element; otherwise `false`.
*/
isElement(node: N, root: R): node is E;
/**
* Checks whether the specified DOM `node` is the same as that of the `root` provided.
*
* @param node - The DOM node to be checked.
* @param root - The DOM root wrapper to be checked.
* @return `true` if `node` is the DOM root node; otherwise `false`.
*/
isRoot(node: N, root: R): boolean;
/**
* Checks whether the specified DOM `node` is a DOM text node in the `root` provided.
*
* @param node - The DOM node to be checked.
* @param root - The DOM root wrapper to the checked.
* @return `true` if `node` is a DOM text node; otherwise `false`.
*/
isText(node: N, root: R): boolean;
}