declare interface util { isIE: boolean; isIE_Edge: boolean; /** * @description Unicode Character 'ZERO WIDTH SPACE' (\u200B) */ zeroWidthSpace: string; /** * @description Regular expression to find 'zero width space' (/\u200B/g) */ zeroWidthRegExp: RegExp; /** * @description Regular expression to find only 'zero width space' (/^\u200B+$/) */ onlyZeroWidthRegExp: RegExp; /** * @description A method that checks If the text is blank or to see if it contains 'ZERO WIDTH SPACE' or empty (util.zeroWidthSpace) * @param text String value or Node * @returns */ onlyZeroWidthSpace(text: string | Node): boolean; /** * @description Gets XMLHttpRequest object * @returns */ getXMLHttpRequest(): XMLHttpRequest | ActiveXObject; /** * @description Object.values * @param obj Object parameter. * @returns */ getValues(obj?: any): any[]; /** * @description Convert the CamelCase To the KebabCase. * @param {String|Array} param [Camel string] */ camelToKebabCase(param: string | string[]): string | string[], /** * @description Convert the KebabCase To the CamelCase. * @param {String|Array} param [KebabCase string] */ kebabToCamelCase(param: string | string[]): string | string[], /** * @description Create Element node * @param elementName Element name * @returns */ createElement(elementName: string): Element; /** * @description Create text node * @param text text contents * @returns */ createTextNode(text: string): Node; /** * @description The editor checks tags by string. * If there is "<" or ">" in the attribute of tag, HTML is broken when checking the tag. * When using an attribute with "<" or ">", use "HTMLEncoder" to save. (ex: math(katex)) * @param contents HTML or Text string * @returns */ HTMLEncoder(contents: string): string; /** * @description The editor checks tags by string. * If there is "<" or ">" in the attribute of tag, HTML is broken when checking the tag. * Decoder of data stored as "HTMLEncoder" (ex: math(katex)) * @param contents HTML or Text string * @returns */ HTMLDecoder(contents: string): string; /** * @description This method run Object.prototype.hasOwnProperty.call(obj, key) * @param obj Object * @param key obj.key * @returns */ hasOwn(obj: any, key: string): boolean; /** * @description Get the the tag path of the arguments value * If not found, return the first found value * @param nameArray File name array * @param extension js, css * @returns */ getIncludePath(nameArray: string[], extension: string): string; /** * @description Returns the CSS text that has been applied to the current page. * @param doc To get the CSS text of an document(core._wd). If null get the current document. * @returns Styles string */ getPageStyle(doc?: Document): string; /** * @description Get the argument iframe's document object * @param iframe Iframe element (context.element.wysiwygFrame) * @returns */ getIframeDocument(iframe: Element): Document; /** * @description Get attributes of argument element to string ('class="---" name="---" ') * @param element Element object * @param exceptAttrs Array of attribute names to exclude from the result * @returns */ getAttributesToString(element: Element, exceptAttrs?: string[]): string; /** * @descriptionGets Get the length in bytes of a string. * referencing code: "https://github.com/shaan1974/myrdin/blob/master/expressions/string.js#L11" * @param text String text * @returns */ getByteLength(text: string): number; /** * @description It is judged whether it is the edit region top div element or iframe's body tag. * @param element The node to check * @returns */ isWysiwygDiv(element: Node): boolean; /** * @description It is judged whether it is the contenteditable property is false. * @param element The node to check * @returns */ isNonEditable(element: Node): boolean; /** * @description It is judged whether it is a node related to the text style. * (strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label) * @param element The node to check * @returns */ isTextStyleElement(element: Node): boolean; /** * @description It is judged whether it is the format element (P, DIV, H[1-6], PRE, LI | class="__se__format__replace_xxx") * Format element also contain "free format Element" * @param element The node to check * @returns */ isFormatElement(element: Node): boolean; /** * @description It is judged whether it is the range format element. (BLOCKQUOTE, OL, UL, FIGCAPTION, TABLE, THEAD, TBODY, TR, TH, TD | class="__se__format__range_xxx") * * Range format element is wrap the format element (util.isFormatElement) * @param element The node to check * @returns */ isRangeFormatElement(element: Node): boolean; /** * @description It is judged whether it is the closure range format element. (TH, TD | class="__se__format__range__closure_xxx") * Closure range format elements is included in the range format element. * - Closure range format element is wrap the "format element" and "component" * ※ You cannot exit this format with the Enter key or Backspace key. * ※ Use it only in special cases. ([ex] format of table cells) * @param element The node to check * @returns */ isClosureRangeFormatElement(element: Node): boolean; /** * @description It is judged whether it is the free format element. (PRE | class="__se__format__free_xxx") * Free format elements is included in the format element. * Free format elements's line break is "BR" tag. * ※ Entering the Enter key in the space on the last line ends "Free Format" and appends "Format". * @param element The node to check * @returns */ isFreeFormatElement(element: Node): boolean; /** * @description It is judged whether it is the closure free format element. (class="__se__format__free__closure_xxx") * Closure free format elements is included in the free format element. * - Closure free format elements's line break is "BR" tag. * ※ You cannot exit this format with the Enter key. * ※ Use it only in special cases. ([ex] format of table cells) * @param element The node to check * @returns */ isClosureFreeFormatElement(element: Node): boolean; /** * @description It is judged whether it is the component [img, iframe, video, audio] cover(class="se-component") and table, hr * @param element The node to check * @returns */ isComponent(element: Node): boolean; /** * @description Checks for "__se__uneditable" in the class list. * Components with class "__se__uneditable" cannot be modified. * @param element The node to check * @returns */ isUneditableComponent(element: Element): boolean; /** * @description It is judged whether it is the not checking node. (class="katex", "__se__tag") * @param element The node to check * @returns */ isMediaComponent(element: Node): boolean; /** * @description It is judged whether it is the component [img, iframe] cover(class="se-component") * @param element The node to check * @returns */ isNotCheckingNode(element: Node): boolean; /** * @description If a parent node that contains an argument node finds a format node (util.isFormatElement), it returns that node. * @param element Reference node. * @param validation Additional validation function. * @returns */ getFormatElement(element: Node, validation?: Function): Element | null; /** * @description If a parent node that contains an argument node finds a format node (util.isRangeFormatElement), it returns that node. * @param element Reference node. * @param validation Additional validation function. * @returns */ getRangeFormatElement(element: Node, validation?: Function): Element | null; /** * @description If a parent node that contains an argument node finds a free format node (util.isFreeFormatElement), it returns that node. * @param element Reference node. * @param validation Additional validation function. * @returns */ getFreeFormatElement(element: Node, validation?: Function): Element | null; /** * @description If a parent node that contains an argument node finds a closure free format node (util.isClosureFreeFormatElement), it returns that node. * @param element Reference node. * @param validation Additional validation function. * @returns */ getClosureFreeFormatElement(element: Node, validation?: Function): Element | null; /** * @description Add style and className of copyEl to originEl * @param originEl Origin element * @param copyEl Element to copy */ copyTagAttributes(originEl: Element, copyEl: Element): void; /** * @description Copy and apply attributes of format tag that should be maintained. (style, class) Ignore "__se__format__" class * @param originEl Origin element * @param copyEl Element to copy */ copyFormatAttributes(originEl: Element, copyEl: Element): void; /** * @description Get the item from the array that matches the condition. * @param array Array to get item * @param validation Conditional function * @param multi If true, returns all items that meet the criteria otherwise, returns an empty array. * If false, returns only one item that meet the criteria otherwise return null. * @returns */ getArrayItem(array: any[] | HTMLCollection | NodeList, validation: Function | null, multi: boolean): any[] | Node | null; /** * @description Check if an array contains an element * @param {Array|HTMLCollection|NodeList} array element array * @param {Node} element The element to find index * @returns {Boolean} */ arrayIncludes(array: any[] | HTMLCollection | NodeList, element: Node): boolean; /** * @description Get the index of the argument value in the element array * @param array element array * @param element The element to find index * @returns */ getArrayIndex(array: any[] | HTMLCollection | NodeList, element: Node): number; /** * @description Get the next index of the argument value in the element array * @param array element array * @param item The element to find index * @returns */ nextIdx(array: any[] | HTMLCollection | NodeList, item: Node): number; /** * @description Get the previous index of the argument value in the element array * @param array Element array * @param item The element to find index * @returns */ prevIdx(array: any[] | HTMLCollection | NodeList, item: Node): number; /** * @description Returns the index compared to other sibling nodes. * @param node The Node to find index * @returns */ getPositionIndex(node: Node): number; /** * @description Returns the position of the "node" in the "parentNode" in a numerical array. * ex)
aabb
: getNodePath(node: "bb", parentNode: "") -> [1, 0]
* @param node The Node to find position path
* @param parentNode Parent node. If null, wysiwyg div area
* @param _newOffsets If you send an object of the form "{s: 0, e: 0}", the text nodes that are attached together are merged into one, centered on the "node" argument.
* "_newOffsets.s" stores the length of the combined characters after "node" and "_newOffsets.e" stores the length of the combined characters before "node".
* Do not use unless absolutely necessary.
* @returns
*/
getNodePath(node: Node, parentNode?: Node, _newOffsets?: { s: number; e: number; }): number[];
/**
* @description Returns the node in the location of the path array obtained from "util.getNodePath".
* @param offsets Position array, array obtained from "util.getNodePath"
* @param parentNode Base parent element
* @returns
*/
getNodeFromPath(offsets: number[], parentNode: Node): Node;
/**
* @description Compares the style and class for equal values.
* Returns true if both are text nodes.
* @param a Node to compare
* @param b Node to compare
* @returns
*/
isSameAttributes(a: Node, b: Node): boolean;
/**
* @description Check the line element(util.isFormatElement) is empty.
* @param {Element} element Format element node
* @returns {Boolean}
*/
isEmptyLine(element: Element): boolean;
/**
* @description Check the span's attributes are empty.
* @param {Element} element Element node
* @returns {Boolean}
*/
isSpanWithoutAttr(element: Element|null): boolean;
/**
* @description Check the node is a list (ol, ul)
* @param node The element or element name to check
* @returns
*/
isList(node: string | Node): boolean;
/**
* @description Check the node is a list cell (li)
* @param node The element or element name to check
* @returns
*/
isListCell(node: string | Node): boolean;
/**
* @description Check the node is a table (table, thead, tbody, tr, th, td)
* @param node The element or element name to check
* @returns
*/
isTable(node: string | Node): boolean;
/**
* @description Check the node is a table cell (td, th)
* @param node The element or element name to check
* @returns
*/
isCell(node: string | Node): boolean;
/**
* @description Check the node is a break node (BR)
* @param node The element or element name to check
* @returns
*/
isBreak(node: string | Node): boolean;
/**
* @description Check the node is a anchor node (A)
* @param node The element or element name to check
* @returns
*/
isAnchor(node: string | Node): boolean;
/**
* @description Check the node is a media node (img, iframe, audio, video, canvas)
* @param node The element or element name to check
* @returns
*/
isMedia(node: string | Node): boolean;
/**
* @description Checks for numeric (with decimal point).
* @param text Text string or number
* @returns
*/
isNumber(text: string | number): boolean;
/**
* @description Get a number.
* @param text Text string or number
* @param maxDec Maximum number of decimal places (-1 : Infinity)
* @returns
*/
getNumber(text: string | number, maxDec: number): number;
/**
* @description Get all "children" of the argument value element (Without text nodes)
* @param element element to get child node
* @param validation Conditional function
* @returns
*/
getListChildren(element: Element, validation?: Function): Element[];
/**
* @description Get all "childNodes" of the argument value element (Include text nodes)
* @param element element to get child node
* @param validation Conditional function
* @returns
*/
getListChildNodes(element: Node, validation?: Function): Node[];
/**
* @description Returns the number of parents nodes.
* "0" when the parent node is the WYSIWYG area.
* "-1" when the element argument is the WYSIWYG area.
* @param element The element to check
* @returns
*/
getElementDepth(element: Node): number;
/**
* @description Compares two elements to find a common ancestor, and returns the order of the two elements.
* @param a Node to compare.
* @param b Node to compare.
* @returns
*/
compareElements(a: Node, b: Node): {ancestor: Element | null, a: Node, b: Node, result: number};
/**
* @description Get the parent element of the argument value.
* A tag that satisfies the query condition is imported.
* Returns null if not found.
* @param element Reference element
* @param query Query String (nodeName, .className, #ID, :name) or validation function.
* Not use it like jquery.
* Only one condition can be entered at a time.
* @returns
*/
getParentElement(element: Node, query: string | Function): Element;
/**
* @description Get the child element of the argument value.
* A tag that satisfies the query condition is imported.
* Returns null if not found.
* @param element Reference element
* @param query Query String (nodeName, .className, #ID, :name) or validation function.
* @param last If true returns the last node among the found child nodes. (default: first node)
* Not use it like jquery.
* Only one condition can be entered at a time.
* @returns
*/
getChildElement(element: Node, query: string | Function, last: boolean): Element;
/**
* @description 1. The first node of all the child nodes of the "first" element is returned.
* 2. The last node of all the child nodes of the "last" element is returned.
* 3. When there is no "last" element, the first and last nodes of all the children of the "first" element are returned.
* { sc: "first", ec: "last" }
* @param first First element
* @param last Last element
* @returns
*/
getEdgeChildNodes(first: Node, last?: Node): {sc: Node; ec: Node | null;};
/**
* @description Returns the position of the left and top of argument. {left:0, top:0}
* @param element Target node
* @param wysiwygFrame When use iframe option, iframe object should be sent (context.element.wysiwygFrame)
* @returns
*/
getOffset(element: Node, wysiwygFrame?: Element): Record