- It can be accessed from "core.util" or object's "util" property returned after editor creation.
Members
isIE
check IE browser
isIE_Edge
check IE or Edge browser
isOSX_IOS
Check if the current OS is OSX or IOS.
zeroWidthSpace
Unicode Character 'ZERO WIDTH SPACE' (U+200B)
zeroWidthRegExp
Regular expression to find 'zero width space' (/\u200B/g)
onlyZeroWidthRegExp
Regular expression to find only 'zero width space' (/^\u200B+$/)
Methods
onlyZeroWidthSpace(text) → {Boolean}
A method that checks If the text is blank or to see if it contains 'ZERO WIDTH SPACE' or empty (util.zeroWidthSpace)
Parameters:
Name | Type | Description |
---|---|---|
text |
String|Node | String value or Node |
getXMLHttpRequest() → {XMLHttpRequest | ActiveXObject}
Gets XMLHttpRequest object
getValues(obj) → {Array}
Object.values
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object|null | Object parameter. |
camelToKebabCase(param) → {String|Array}
Convert the CamelCase To the KebabCase.
Parameters:
Name | Type | Description |
---|---|---|
param |
String|Array | [Camel string] |
kebabToCamelCase(param) → {String|Array}
Convert the KebabCase To the CamelCase.
Parameters:
Name | Type | Description |
---|---|---|
param |
String|Array | [KebabCase string] |
createElement(elementName) → {Element}
Create Element node
Parameters:
Name | Type | Description |
---|---|---|
elementName |
String | Element name |
createTextNode(text) → {Node}
Create text node
Parameters:
Name | Type | Description |
---|---|---|
text |
String | Text contents |
HTMLEncoder(contents) → {String}
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))
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))
Parameters:
Name | Type | Description |
---|---|---|
contents |
String | HTML or Text string |
HTMLDecoder(contents) → {String}
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))
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))
Parameters:
Name | Type | Description |
---|---|---|
contents |
String | HTML or Text string |
hasOwn(obj, key) → {Boolean}
This method run Object.prototype.hasOwnProperty.call(obj, key)
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | Object |
key |
String | obj.key |
getIncludePath(nameArray, extension) → {String} @deprecated
Get the the tag path of the arguments value
If not found, return the first found value
If not found, return the first found value
Parameters:
Name | Type | Description |
---|---|---|
nameArray |
Array | File name array |
extension |
String | js, css |
getPageStyle(doc) → {String} @deprecated
Returns the Style text that has been applied to the current page.
Parameters:
Name | Type | Description |
---|---|---|
doc |
Document|null | To get the CSS text of an document(core._wd). If null get the current document. |
getIframeDocument(iframe) → {Document}
Get the argument iframe's document object.
Parameters:
Name | Type | Description |
---|---|---|
iframe |
Element | Iframe element (context.element.wysiwygFrame) |
getAttributesToString(element, exceptAttrs) → {String}
Get attributes of argument element to string ('class="---" name="---" ')
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Element object |
exceptAttrs |
Array|null | Array of attribute names to exclude from the result |
getByteLength(text) → {Number}
Get the length in bytes of a string.
referencing code: "https://github.com/shaan1974/myrdin/blob/master/expressions/string.js#L11"
referencing code: "https://github.com/shaan1974/myrdin/blob/master/expressions/string.js#L11"
Parameters:
Name | Type | Description |
---|---|---|
text |
String | String text |
isWysiwygDiv(element) → {Boolean}
It is judged whether it is the edit region top div element or iframe's body tag.
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
isNonEditable(element) → {Boolean}
It is judged whether it is the contenteditable property is false.
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
isTextStyleElement(element) → {Boolean}
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|code)
(strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label|code)
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
isFormatElement(element) → {Boolean}
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"
Format element also contain "free format Element"
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
isRangeFormatElement(element) → {Boolean}
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 include the format element and component.
Range format element is include the format element and component.
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
isClosureRangeFormatElement(element) → {Boolean}
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.
- Range format element is include 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)
Closure range format elements is included in the range format element.
- Range format element is include 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)
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
isFreeFormatElement(element) → {Boolean}
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".
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".
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
isClosureFreeFormatElement(element) → {Boolean}
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)
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)
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
isComponent(element) → {Boolean}
It is judged whether it is the component[img, iframe, video, audio, table] cover(element className - ".se-component") and table, hr
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
isUneditableComponent(element) → {Boolean}
Checks for "__se__uneditable" in the class list.
Components with class "__se__uneditable" cannot be modified.
Components with class "__se__uneditable" cannot be modified.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | The element to check |
isMediaComponent(element) → {Boolean}
It is judged whether it is the component [img, iframe, video, audio] cover(element className - ".se-component")
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
isNotCheckingNode(element) → {Boolean}
It is judged whether it is the not checking node. (class="katex", "__se__tag")
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
getFormatElement(element, validation) → {Element}
If a parent node that contains an argument node finds a format node (util.isFormatElement), it returns that node.
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | Reference element if null or no value, it is relative to the current focus node. |
validation |
Function|null | Additional validation function. |
getRangeFormatElement(element, validation) → {Element|null}
If a parent node that contains an argument node finds a format node (util.isRangeFormatElement), it returns that node.
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | Reference element if null or no value, it is relative to the current focus node. |
validation |
Function|null | Additional validation function. |
getFreeFormatElement(element, validation) → {Element|null}
If a parent node that contains an argument node finds a free format node (util.isFreeFormatElement), it returns that node.
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | Reference element if null or no value, it is relative to the current focus node. |
validation |
Function|null | Additional validation function. |
getClosureFreeFormatElement(element, validation) → {Element|null}
If a parent node that contains an argument node finds a closure free format node (util.isClosureFreeFormatElement), it returns that node.
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | Reference element if null or no value, it is relative to the current focus node. |
validation |
Function|null | Additional validation function. |
copyTagAttributes(originEl, copyEl)
Add style and className of copyEl to originEl. (style, class)
Parameters:
Name | Type | Description |
---|---|---|
originEl |
Element | Origin element |
copyEl |
Element | Element to copy |
copyFormatAttributes(originEl, copyEl)
Copy and apply attributes of format tag that should be maintained. (style, class), Ignore "__se__format__" class
Parameters:
Name | Type | Description |
---|---|---|
originEl |
Element | Origin element |
copyEl |
Element | Element to copy |
getArrayItem(array, validation, multi) → {Array|Node|null}
Get the item from the array that matches the condition.
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array to get item |
validation |
Function|null | Conditional function |
multi |
Boolean |
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. |
arrayIncludes(array, element) → {Boolean}
Check if an array contains an element
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | element array |
element |
Element | Element to check for |
getArrayIndex(array, element) → {Number}
Get the index of the argument value in the element array
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | element array |
element |
Element | Element to find index |
nextIdx(array, element) → {Number}
Get the next index of the argument value in the element array
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | element array |
item |
Node | Element to find index |
prevIdx(array, element) → {Number}
Get the previous index of the argument value in the element array
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | element array |
element |
Node | Element to find index |
getPositionIndex(node) → {Number}
Returns the index compared to other sibling nodes.
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | Node to find index |
getNodePath(node, parentNode, _newOffsets) → {Array}
Returns the position of the "node" in the "parentNode" in a numerical array.
ex) <p><span>aa</span><span>bb</span></p> : (node: "bb", parentNode: "<P>") → [1, 0]
ex) <p><span>aa</span><span>bb</span></p> : (node: "bb", parentNode: "<P>") → [1, 0]
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | The Node to find position path |
parentNode |
Element|null | Parent node. If null, wysiwyg div area |
_newOffsets |
Object|null |
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. |
getNodeFromPath(node, parentNode) → {Array}
Returns the node in the location of the path array obtained from "util.getNodePath".
Parameters:
Name | Type | Description |
---|---|---|
offsets |
Array | Position array, array obtained from "util.getNodePath" |
parentNode |
Element | Base parent element |
isSameAttributes(a, b) → {Boolean}
Compares the style and class for equal values.
Returns true if both are text nodes.
Returns true if both are text nodes.
Parameters:
Name | Type | Description |
---|---|---|
a |
Node | Node object |
b |
Node | Node object |
isEmptyLine(element) → {Boolean}
Check the line element(util.isFormatElement) is empty
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Format element node |
isSpanWithoutAttr(element) → {Boolean}
Check the span's attributes are empty.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element|null | Element node |
isList(node) → {Boolean}
Check the node is a list (ol, ul)
Parameters:
Name | Type | Description |
---|---|---|
node |
Node|String | The element or element name to check |
isListCell(node) → {Boolean}
Check the node is a list cell (li)
Parameters:
Name | Type | Description |
---|---|---|
node |
Node|String | The element or element name to check |
isTable(node) → {Boolean}
Check the node is a list table (table, thead, tbody, tr, th, td)
Parameters:
Name | Type | Description |
---|---|---|
node |
Node|String | The element or element name to check |
isCell(node) → {Boolean}
Check the node is a table cell (td, th)
Parameters:
Name | Type | Description |
---|---|---|
node |
Node|String | The element or element name to check |
isBreak(node) → {Boolean}
Check the node is a break node (BR)
Parameters:
Name | Type | Description |
---|---|---|
node |
Node|String | The element or element name to check |
isAnchor(node) → {Boolean}
Check the node is a anchor node (A)
Parameters:
Name | Type | Description |
---|---|---|
node |
Node|String | The element or element name to check |
isMedia(node) → {Boolean}
Check the node is a media node (img, iframe, audio, video, canvas)
Parameters:
Name | Type | Description |
---|---|---|
node |
Node|String | The element or element name to check |
isNumber(text) → {Boolean}
Checks for numeric (with decimal point).
Parameters:
Name | Type | Description |
---|---|---|
text |
String|Number | Text string or number |
getNumber(text, maxDec) → {Number}
Get a number.
Parameters:
Name | Type | Description |
---|---|---|
text |
String|Number | Text string or number |
maxDec |
Number | maxDec Maximum number of decimal places (-1 : Infinity) |
getListChildren(element, validation) → {Array}
Get all child nodes of the argument value element (Without text node)
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | element to get child node |
validation |
Function | null | Conditional function |
getListChildNodes(element, validation) → {Array}
Get all child nodes of the argument value element (Include text nodes)
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | element to get child node |
validation |
Function | null | Conditional function |
getElementDepth(element) → {Number}
Returns the number of parents nodes.
"0" when the parent node is the WYSIWYG area.
"-1" when the element argument is the WYSIWYG area.
"0" when the parent node is the WYSIWYG area.
"-1" when the element argument is the WYSIWYG area.
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | The element to check |
compareElements(a, b) → {Object}
Compares two elements to find a common ancestor, and returns the order of the two elements.
{ ancesstor, a, b, result: (a > b ? 1 : a < b ? -1 : 0) }
{ ancesstor, a, b, result: (a > b ? 1 : a < b ? -1 : 0) }
Parameters:
Name | Type | Description |
---|---|---|
a |
Node | Node to compare |
b |
Node | Node to compare |
getParentElement(element, query) → {Element}
Get the parent element of the argument value.
A tag that satisfies the query condition is imported.
Returns null if not found.
A tag that satisfies the query condition is imported.
Returns null if not found.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Reference element |
query |
String | Function | Query String (nodeName, .className, #ID, :name) or validation function. Not use it like jquery. Only one condition can be entered at a time. |
getChildElement(element, query, last) → {Element}
Get the parent child of the argument value.
A tag that satisfies the query condition is imported.
Returns null if not found.
A tag that satisfies the query condition is imported.
Returns null if not found.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Reference element |
query |
String | Function | Query String (nodeName, .className, #ID, :name) or validation function. Not use it like jquery. Only one condition can be entered at a time. |
last |
Boolean | If true returns the last node among the found child nodes. (default: first node) |
getEdgeChildNodes(first, last) → {Object}
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" }
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" }
Parameters:
Name | Type | Description |
---|---|---|
first |
Node | First element |
last |
Node | null | Last element |
getOffset(element, wysiwygFrame) → {Object}
Returns the position of the left and top of argument.
{left:0, top:0}
{left:0, top:0}
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | Target node |
wysiwygFrame |
Element|null | When use iframe option, iframe object should be sent (context.element.wysiwygFrame) |
getOverlapRangeAtIndex(aStart, aEnd, bStart, bEnd) → {Number}
It compares the start and end indexes of "a" and "b" and returns the number of overlapping indexes in the range.
ex) 1, 5, 4, 6 => 2 (4 ~ 5)
ex) 1, 5, 4, 6 => 2 (4 ~ 5)
Parameters:
Name | Type | Description |
---|---|---|
aStart |
Number | Start index of "a" |
aEnd |
Number | End index of "a" |
bStart |
Number | Start index of "b" |
bEnd |
Number | End index of "b" |
changeTxt(element, txt)
Set the text content value of the argument value element
Parameters:
Name | Type | Description |
---|---|---|
element |
Node | Elements to replace text content |
txt |
String | Text to be applied |
changeElement(icon, newIcon)
Replace element.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Target element |
newElement |
String|Element | String or element of the new element to apply |
setStyle(element, styleName, value)
Set style, if all styles are deleted, the style properties are deleted.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Element to set style |
styleName |
String | Style attribute name (marginLeft, textAlign...) |
value |
String|Number | Style value |
hasClass(element, className) → {Boolean}
Determine whether any of the matched elements are assigned the given class
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Elements to search class name |
className |
String | Class name to search for |
addClass(element, className)
Append the className value of the argument value element
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Element to add class name |
className |
String | Class name to be add |
removeClass(element, className)
Delete the className value of the argument value element
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Elements to remove class name |
className |
String | Class name to be remove |
toggleClass(element, className)→ {Boolean|undefined}
→ {Boolean}
Argument value If there is no class name, insert it and delete the class name if it exists
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Elements to replace class name |
className |
String | Class name to be change |
setDisabledButtons(disabled)
In the predefined code view mode, the buttons except the executable button are changed to the 'disabled' state.
core.codeViewDisabledButtons (An array of buttons whose className is not "se-code-view-enabled") core.resizingDisabledButtons (An array of buttons whose className is not "se-resizing-enabled") * @param disabled Disabled value * @param buttonList Button array
core.codeViewDisabledButtons (An array of buttons whose className is not "se-code-view-enabled") core.resizingDisabledButtons (An array of buttons whose className is not "se-resizing-enabled") * @param disabled Disabled value * @param buttonList Button array
Parameters:
Name | Type | Description |
---|---|---|
disabled |
Boolean | Disabled value |
buttonList |
Array|HTMLCollection|NodeList | Button array |
removeItem(item)
Delete argumenu value element
Parameters:
Name | Type | Description |
---|---|---|
item |
Node | Element to be remove |
removeItemAllParents(item, validation, stopParent) → {Object|null}
Delete all parent nodes that match the condition.
Returns an {sc: previousSibling, ec: nextSibling}(the deleted node reference) or null.
Returns an {sc: previousSibling, ec: nextSibling}(the deleted node reference) or null.
Parameters:
Name | Type | Description |
---|---|---|
item |
Node | Node to be remove |
validation |
Function|null | Validation function. default(Deleted if it only have breakLine and blanks) |
stopParent |
Element|null | Stop when the parent node reaches stopParent |
detachNestedList(baseNode, all) → {Element}
Detach Nested all nested lists under the "baseNode".
Returns a list with nested removed.
Returns a list with nested removed.
Parameters:
Name | Type | Description |
---|---|---|
baseNode |
Node | Element on which to base. |
all |
Boolean | If true, it also detach all nested lists of a returned list. |
splitElement(baseNode, offset, depth) → {Element}
Split all tags based on "baseNode"
Returns the last element of the splited tag.
Returns the last element of the splited tag.
Parameters:
Name | Type | Description |
---|---|---|
baseNode |
Node | Element or text node on which to base |
offset |
Number|null | Text offset of "baseNode" (Only valid when "baseNode" is a text node) |
depth |
Number | The nesting depth of the element being split. (default: 0) |
mergeSameTags(element, nodePathArray, onlyText) → {Array} [offset, ..]
Use with "npdePath (util.getNodePath)" to merge the same attributes and tags if they are present and modify the nodepath.
If "offset" has been changed, it will return as much "offset" as it has been modified.
An array containing change offsets is returned in the order of the "nodePathArray" array.
If "offset" has been changed, it will return as much "offset" as it has been modified.
An array containing change offsets is returned in the order of the "nodePathArray" array.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Element object |
nodePathArray |
Array|null | Array of util.getNodePath object [util.getNodePath(), ..] |
onlyText |
Boolean | If true, non-text nodes(!util._isIgnoreNodeChange) like 'span', 'strong'.. are ignored. |
mergeNestedTags(element, validation)
Merge nested tags without other child nodes.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Element object |
validation |
Function|String|null | Validation function / String("tag1|tag2..") / If null, all tags are applicable. |
removeEmptyNode(element, notRemoveNode, forceDelete)
Delete a empty child node of argument element
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | Element node |
notRemoveNode |
Node|null | Do not remove node |
forceDelete |
Boolean | When all child nodes are deleted, the parent node is also deleted. |
htmlRemoveWhiteSpace(html) → {String}
Remove whitespace between tags in HTML string.
Parameters:
Name | Type | Description |
---|---|---|
html |
String | HTML string |
htmlCompress(html) → {String}
HTML code compression.
Parameters:
Name | Type | Description |
---|---|---|
html |
String | HTML string |
sortByDepth(array, des)
Sort a element array by depth of element.
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array object |
des |
Boolean | true: descending order / false: ascending order |
createTagsWhitelist(list) → {RegExp}
Create whitelist RegExp object.
Return RegExp format: new RegExp("<\\/?\\b(?!" + list + ")\\b[^>^<]*+>", "gi")
Return RegExp format: new RegExp("<\\/?\\b(?!" + list + ")\\b[^>^<]*+>", "gi")
Parameters:
Name | Type | Description |
---|---|---|
list |
String | Tags list ("br|p|div|pre...") |
createTagsBlacklist(list) → {RegExp}
Create blacklist RegExp object.
Return RegExp format: new RegExp("<\\/?\\b(?:" + list + ")\\b[^>^<]*+>", "gi")
Return RegExp format: new RegExp("<\\/?\\b(?:" + list + ")\\b[^>^<]*+>", "gi")
Parameters:
Name | Type | Description |
---|---|---|
list |
String | Tags list ("br|p|div|pre...") |