[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> rich-text.js (summary)

(no description)

File Size: 3732 lines (114 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 106 functions

  __webpack_require__()
  getDefault()
  getModuleExports()
  _defineProperty()
  _arrayWithoutHoles()
  _nonIterableSpread()
  _toConsumableArray()
  _extends()
  arrayOf()
  isObjectLike()
  createCache()
  isShallowEqual()
  getRootCache()
  getWeakMapCache()
  clear()
  callSelector()
  _typeof2()
  _typeof()
  _iterableToArray()
  reducer_formatTypes()
  getFormatType()
  getFormatTypeForBareElement()
  getFormatTypeForClassName()
  addFormatTypes()
  removeFormatTypes()
  isFormatEqual()
  normaliseFormats()
  applyFormat()
  applyFormats()
  charAt()
  createElement()
  createEmptyValue()
  simpleFindKey()
  toFormat()
  create()
  accumulateSelection()
  filterRange()
  filterString()
  createFromElement()
  createFromMultilineElement()
  getAttributes()
  mergePair()
  concat()
  getActiveFormats()
  getActiveFormat()
  getActiveObject()
  getSelectionEnd()
  getSelectionStart()
  getTextContent()
  isCollapsed()
  isEmpty()
  isEmptyLine()
  join()
  registerFormatType()
  removeFormat()
  filterFormats()
  insert()
  remove_remove()
  replace()
  insertLineBreak()
  insertLineSeparator()
  insertObject()
  slice()
  split()
  splitAtSelection()
  get_format_type_getFormatType()
  fromFormat()
  toTree()
  createPathToNode()
  getNodeByPath()
  to_dom_append()
  to_dom_appendText()
  to_dom_getLastChild()
  to_dom_getParent()
  to_dom_isText()
  to_dom_getText()
  to_dom_remove()
  prepareFormats()
  toDom()
  apply()
  applyValue()
  isRangeEqual()
  applySelection()
  toHTMLString()
  to_html_string_createEmpty()
  to_html_string_getLastChild()
  to_html_string_append()
  to_html_string_appendText()
  to_html_string_getParent()
  to_html_string_isText()
  to_html_string_getText()
  to_html_string_remove()
  createElementHTML()
  createChildrenHTML()
  toggleFormat()
  unregisterFormatType()
  getLineIndex()
  getTargetLevelLineIndex()
  indentListItems()
  getParentLineIndex()
  getLastChildIndex()
  outdentListItems()
  changeListType()
  updateFormats()
  memoized()
  _objectSpread()

Functions
Functions that are not part of a class:

__webpack_require__(moduleId)   X-Ref
No description

getDefault()   X-Ref
No description

getModuleExports()   X-Ref
No description

_defineProperty(obj, key, value)   X-Ref
No description

_arrayWithoutHoles(arr)   X-Ref
No description

_nonIterableSpread()   X-Ref
No description

_toConsumableArray(arr)   X-Ref
No description

_extends()   X-Ref
No description

arrayOf( value )   X-Ref
Returns the first argument as the sole entry in an array.

return: {Array} Value returned as entry in array.
param: {*} value Value to return.

isObjectLike( value )   X-Ref
Returns true if the value passed is object-like, or false otherwise. A value
is object-like if it can support property assignment, e.g. object or array.

return: {boolean} Whether value is object-like.
param: {*} value Value to test.

createCache()   X-Ref
Creates and returns a new cache object.

return: {Object} Cache object.

isShallowEqual( a, b, fromIndex )   X-Ref
Returns true if entries within the two arrays are strictly equal by
reference from a starting index.

return: {boolean} Whether arrays are shallowly equal.
param: {Array}  a         First array.
param: {Array}  b         Second array.
param: {number} fromIndex Index from which to start comparison.

getRootCache()   X-Ref
Returns the root cache. If WeakMap is supported, this is assigned to the
root WeakMap cache set, otherwise it is a shared instance of the default
cache object.

return: {(WeakMap|Object)} Root cache object.

getWeakMapCache( dependants )   X-Ref
Returns the cache for a given dependants array. When possible, a WeakMap
will be used to create a unique cache for each set of dependants. This
is feasible due to the nature of WeakMap in allowing garbage collection
to occur on entries where the key object is no longer referenced. Since
WeakMap requires the key to be an object, this is only possible when the
dependant is object-like. The root cache is created as a hierarchy where
each top-level key is the first entry in a dependants set, the value a
WeakMap where each key is the next dependant, and so on. This continues
so long as the dependants are object-like. If no dependants are object-
like, then the cache is shared across all invocations.

return: {Object} Cache object.
param: {Array} dependants Selector dependants.

clear()   X-Ref
Resets root memoization cache.


callSelector( )   X-Ref
The augmented selector call, considering first whether dependants have
changed before passing it to underlying memoize function.

return: {*} Selector result.
param: {Object} source    Source object for derivation.
param: {...*}   extraArgs Additional arguments to pass to selector.

_typeof2(obj)   X-Ref
No description

_typeof(obj)   X-Ref
No description

_iterableToArray(iter)   X-Ref
No description

reducer_formatTypes()   X-Ref
Reducer managing the format types

return: {Object} Updated state.
param: {Object} state  Current state.
param: {Object} action Dispatched action.

getFormatType(state, name)   X-Ref
Returns a format type by name.

return: {Object?} Format type.
param: {Object} state Data state.
param: {string} name Format type name.

getFormatTypeForBareElement(state, bareElementTagName)   X-Ref
Gets the format type, if any, that can handle a bare element (without a
data-format-type attribute), given the tag name of this element.

return: {?Object} Format type.
param: {Object} state              Data state.
param: {string} bareElementTagName The tag name of the element to find a

getFormatTypeForClassName(state, elementClassName)   X-Ref
Gets the format type, if any, that can handle an element, given its classes.

return: {?Object} Format type.
param: {Object} state            Data state.
param: {string} elementClassName The classes of the element to find a format

addFormatTypes(formatTypes)   X-Ref
Returns an action object used in signalling that format types have been
added.

return: {Object} Action object.
param: {Array|Object} formatTypes Format types received.

removeFormatTypes(names)   X-Ref
Returns an action object used to remove a registered format type.

return: {Object} Action object.
param: {string|Array} names Format name.

isFormatEqual(format1, format2)   X-Ref
Optimised equality check for format objects.

return: {boolean} True if formats are equal, false if not.
param: {?Object} format1 Format to compare.
param: {?Object} format2 Format to compare.

normaliseFormats(value)   X-Ref
Normalises formats: ensures subsequent adjacent equal formats have the same
reference.

return: {Object} New value with normalised formats.
param: {Object} value Value to normalise formats of.

applyFormat(value, format)   X-Ref
Apply a format object to a Rich Text value from the given `startIndex` to the
given `endIndex`. Indices are retrieved from the selection if none are
provided.

return: {Object} A new value with the format applied.
param: {Object} value        Value to modify.
param: {Object} format       Format to apply.
param: {number} [startIndex] Start index.
param: {number} [endIndex]   End index.

applyFormats(formats, index, format)   X-Ref
No description

charAt(_ref, index)   X-Ref
Gets the character at the specified index, or returns `undefined` if no
character was found.

return: {string|undefined} A one character long string, or undefined.
param: {Object} value Value to get the character from.
param: {string} index Index to use.

createElement(_ref, html)   X-Ref
Parse the given HTML into a body element.

Note: The current implementation will return a shared reference, reset on
each call to `createElement`. Therefore, you should not hold a reference to
the value to operate upon asynchronously, as it may have unexpected results.

return: {HTMLBodyElement} Body element with parsed HTML.
param: {HTMLDocument} document The HTML document to use to parse.
param: {string}       html     The HTML to parse.

createEmptyValue()   X-Ref
No description

simpleFindKey(object, value)   X-Ref
No description

toFormat(_ref)   X-Ref
No description

create()   X-Ref
Create a RichText value from an `Element` tree (DOM), an HTML string or a
plain text string, with optionally a `Range` object to set the selection. If
called without any input, an empty value will be created. If
`multilineTag` is provided, any content of direct children whose type matches
`multilineTag` will be separated by two newlines. The optional functions can
be used to filter out content.

A value will have the following shape, which you are strongly encouraged not
to modify without the use of helper functions:

```js
{
text: string,
formats: Array,
replacements: Array,
?start: number,
?end: number,
}
```

As you can see, text and formatting are separated. `text` holds the text,
including any replacement characters for objects and lines. `formats`,
`objects` and `lines` are all sparse arrays of the same length as `text`. It
holds information about the formatting at the relevant text indices. Finally
`start` and `end` state which text indices are selected. They are only
provided if a `Range` was given.

return: {Object} A rich text value.
param: {Object}  [$1]                      Optional named arguments.
param: {Element} [$1.element]              Element to create value from.
param: {string}  [$1.text]                 Text to create value from.
param: {string}  [$1.html]                 HTML to create value from.
param: {Range}   [$1.range]                Range to create value from.
param: {string}  [$1.multilineTag]         Multiline tag if the structure is
param: {Array}   [$1.multilineWrapperTags] Tags where lines can be found if

accumulateSelection(accumulator, node, range, value)   X-Ref
Helper to accumulate the value's selection start and end from the current
node and range.

param: {Object} accumulator Object to accumulate into.
param: {Node}   node        Node to create value with.
param: {Range}  range       Range to create value with.
param: {Object} value       Value that is being accumulated.

filterRange(node, range, filter)   X-Ref
Adjusts the start and end offsets from a range based on a text filter.

return: {?Object} Object containing range properties.
param: {Node}     node   Node of which the text should be filtered.
param: {Range}    range  The range to filter.
param: {Function} filter Function to use to filter the text.

filterString(string)   X-Ref
No description

createFromElement(_ref3)   X-Ref
Creates a Rich Text value from a DOM element and range.

return: {Object} A rich text value.
param: {Object}    $1                      Named argements.
param: {?Element}  $1.element              Element to create value from.
param: {?Range}    $1.range                Range to create value from.
param: {?string}   $1.multilineTag         Multiline tag if the structure is
param: {?Array}    $1.multilineWrapperTags Tags where lines can be found if

createFromMultilineElement(_ref4)   X-Ref
Creates a rich text value from a DOM element and range that should be
multiline.

return: {Object} A rich text value.
param: {Object}    $1                      Named argements.
param: {?Element}  $1.element              Element to create value from.
param: {?Range}    $1.range                Range to create value from.
param: {?string}   $1.multilineTag         Multiline tag if the structure is
param: {?Array}    $1.multilineWrapperTags Tags where lines can be found if
param: {boolean}   $1.currentWrapperTags   Whether to prepend a line

getAttributes(_ref5)   X-Ref
Gets the attributes of an element in object shape.

return: {?Object} Attribute object or `undefined` if the element has no
param: {Object}    $1                 Named argements.
param: {Element}   $1.element         Element to get attributes from.

mergePair(a, b)   X-Ref
Concats a pair of rich text values. Not that this mutates `a` and does NOT
normalise formats!

return: {Object} `a`, mutated.
param: {Object} a Value to mutate.
param: {Object} b Value to add read from.

concat()   X-Ref
Combine all Rich Text values into one. This is similar to
`String.prototype.concat`.

return: {Object} A new value combining all given records.
param: {...Object} values Objects to combine.

getActiveFormats(_ref)   X-Ref
Gets the all format objects at the start of the selection.

return: {?Object} Active format objects.
param: {Object} value Value to inspect.

getActiveFormat(value, formatType)   X-Ref
Gets the format object by type at the start of the selection. This can be
used to get e.g. the URL of a link format at the current selection, but also
to check if a format is active at the selection. Returns undefined if there
is no format at the selection.

return: {Object|undefined} Active format object of the specified type, or undefined.
param: {Object} value      Value to inspect.
param: {string} formatType Format type to look for.

getActiveObject(_ref)   X-Ref
Gets the active object, if there is any.

return: {?Object} Active object, or undefined.
param: {Object} value Value to inspect.

getSelectionEnd(_ref)   X-Ref
Gets the end index of the current selection, or returns `undefined` if no
selection exists. The selection ends right before the character at this
index.

return: {number|undefined} Index where the selection ends.
param: {Object} value Value to get the selection from.

getSelectionStart(_ref)   X-Ref
Gets the start index of the current selection, or returns `undefined` if no
selection exists. The selection starts right before the character at this
index.

return: {number|undefined} Index where the selection starts.
param: {Object} value Value to get the selection from.

getTextContent(_ref)   X-Ref
Get the textual content of a Rich Text value. This is similar to
`Element.textContent`.

return: {string} The text content.
param: {Object} value Value to use.

isCollapsed(_ref)   X-Ref
Check if the selection of a Rich Text value is collapsed or not. Collapsed
means that no characters are selected, but there is a caret present. If there
is no selection, `undefined` will be returned. This is similar to
`window.getSelection().isCollapsed()`.

return: {boolean|undefined} True if the selection is collapsed, false if not,
param: {Object} value The rich text value to check.

isEmpty(_ref)   X-Ref
Check if a Rich Text value is Empty, meaning it contains no text or any
objects (such as images).

return: {boolean} True if the value is empty, false if not.
param: {Object} value Value to use.

isEmptyLine(_ref2)   X-Ref
Check if the current collapsed selection is on an empty line in case of a
multiline value.

return: {boolean} True if the line is empty, false if not.
param: {Object} value Value te check.

join(values)   X-Ref
Combine an array of Rich Text values into one, optionally separated by
`separator`, which can be a Rich Text value, HTML string, or plain text
string. This is similar to `Array.prototype.join`.

return: {Object} A new combined value.
param: {Array<Object>} values      An array of values to join.
param: {string|Object} [separator] Separator string or value.

registerFormatType(name, settings)   X-Ref
Registers a new format provided a unique name and an object defining its
behavior.

return: {WPFormat|undefined} The format, if it has been successfully registered;
param: {string}   name                 Format name.
param: {Object}   settings             Format settings.
param: {string}   settings.tagName     The HTML tag this format will wrap the selection with.
param: {string}   [settings.className] A class to match the format.
param: {string}   settings.title       Name of the format.
param: {Function} settings.edit        Should return a component for the user to interact with the new registered format.

removeFormat(value, formatType)   X-Ref
Remove any format object from a Rich Text value by type from the given
`startIndex` to the given `endIndex`. Indices are retrieved from the
selection if none are provided.

return: {Object} A new value with the format applied.
param: {Object} value        Value to modify.
param: {string} formatType   Format type to remove.
param: {number} [startIndex] Start index.
param: {number} [endIndex]   End index.

filterFormats(formats, index, formatType)   X-Ref
No description

insert(value, valueToInsert)   X-Ref
Insert a Rich Text value, an HTML string, or a plain text string, into a
Rich Text value at the given `startIndex`. Any content between `startIndex`
and `endIndex` will be removed. Indices are retrieved from the selection if
none are provided.

return: {Object} A new value with the value inserted.
param: {Object}        value         Value to modify.
param: {Object|string} valueToInsert Value to insert.
param: {number}        [startIndex]  Start index.
param: {number}        [endIndex]    End index.

remove_remove(value, startIndex, endIndex)   X-Ref
Remove content from a Rich Text value between the given `startIndex` and
`endIndex`. Indices are retrieved from the selection if none are provided.

return: {Object} A new value with the content removed.
param: {Object} value        Value to modify.
param: {number} [startIndex] Start index.
param: {number} [endIndex]   End index.

replace(_ref, pattern, replacement)   X-Ref
Search a Rich Text value and replace the match(es) with `replacement`. This
is similar to `String.prototype.replace`.

return: {Object} A new value with replacements applied.
param: {Object}         value        The value to modify.
param: {RegExp|string}  pattern      A RegExp object or literal. Can also be
param: {Function|string} replacement The match or matches are replaced with

insertLineBreak(value)   X-Ref
Inserts a line break at the given or selected position.

return: {Object} The value with the line break inserted.
param: {Object} value Value to modify.

insertLineSeparator(value)   X-Ref
Insert a line break character into a Rich Text value at the given
`startIndex`. Any content between `startIndex` and `endIndex` will be
removed. Indices are retrieved from the selection if none are provided.

return: {Object} A new value with the value inserted.
param: {Object} value        Value to modify.
param: {number} [startIndex] Start index.
param: {number} [endIndex]   End index.

insertObject(value, formatToInsert, startIndex, endIndex)   X-Ref
Insert a format as an object into a Rich Text value at the given
`startIndex`. Any content between `startIndex` and `endIndex` will be
removed. Indices are retrieved from the selection if none are provided.

return: {Object} A new value with the object inserted.
param: {Object} value          Value to modify.
param: {Object} formatToInsert Format to insert as object.
param: {number} [startIndex]   Start index.
param: {number} [endIndex]     End index.

slice(value)   X-Ref
Slice a Rich Text value from `startIndex` to `endIndex`. Indices are
retrieved from the selection if none are provided. This is similar to
`String.prototype.slice`.

return: {Object} A new extracted value.
param: {Object} value        Value to modify.
param: {number} [startIndex] Start index.
param: {number} [endIndex]   End index.

split(_ref, string)   X-Ref
Split a Rich Text value in two at the given `startIndex` and `endIndex`, or
split at the given separator. This is similar to `String.prototype.split`.
Indices are retrieved from the selection if none are provided.

return: {Array} An array of new values.
param: {Object}        value    Value to modify.
param: {number|string} [string] Start index, or string at which to split.
param: {number}        [endStr] End index.

splitAtSelection(_ref2)   X-Ref
No description

get_format_type_getFormatType(name)   X-Ref
Returns a registered format type.

return: {?Object} Format type.
param: {string} name Format name.

fromFormat(_ref)   X-Ref
Converts a format object to information that can be used to create an element
from (type, attributes and object).

return: {Object}                            Information to be used for
param: {Object}  $1                        Named parameters.
param: {string}  $1.type                   The format type.
param: {Object}  $1.attributes             The format attributes.
param: {Object}  $1.unregisteredAttributes The unregistered format
param: {boolean} $1.object                 Wether or not it is an object
param: {boolean} $1.boundaryClass          Wether or not to apply a boundary

toTree(_ref2)   X-Ref
No description

createPathToNode(node, rootNode, path)   X-Ref
Creates a path as an array of indices from the given root node to the given
node.

return: {Array} The path from the root node to the node.
param: {Node}        node     Node to find the path of.
param: {HTMLElement} rootNode Root node to find the path from.
param: {Array}       path     Initial path to build on.

getNodeByPath(node, path)   X-Ref
Gets a node given a path (array of indices) from the given node.

return: {Object} Object with the found node and the remaining offset (if any).
param: {HTMLElement} node Root node to find the wanted node in.
param: {Array}       path Path (indices) to the wanted node.

to_dom_append(element, child)   X-Ref
No description

to_dom_appendText(node, text)   X-Ref
No description

to_dom_getLastChild(_ref)   X-Ref
No description

to_dom_getParent(_ref2)   X-Ref
No description

to_dom_isText(_ref3)   X-Ref
No description

to_dom_getText(_ref4)   X-Ref
No description

to_dom_remove(node)   X-Ref
No description

prepareFormats()   X-Ref
No description

toDom(_ref5)   X-Ref
No description

apply(_ref6)   X-Ref
Create an `Element` tree from a Rich Text value and applies the difference to
the `Element` tree contained by `current`. If a `multilineTag` is provided,
text separated by two new lines will be wrapped in an `Element` of that type.

param: {Object}      $1                        Named arguments.
param: {Object}      $1.value                  Value to apply.
param: {HTMLElement} $1.current                The live root node to apply the element tree to.
param: {string}      [$1.multilineTag]         Multiline tag.
param: {Array}       [$1.multilineWrapperTags] Tags where lines can be found if nesting is possible.

applyValue(future, current)   X-Ref
No description

isRangeEqual(a, b)   X-Ref
Returns true if two ranges are equal, or false otherwise. Ranges are
considered equal if their start and end occur in the same container and
offset.

return: {boolean} Whether the two ranges are equal.
param: {Range} a First range object to test.
param: {Range} b First range object to test.

applySelection(_ref7, current)   X-Ref
No description

toHTMLString(_ref)   X-Ref
Create an HTML string from a Rich Text value. If a `multilineTag` is
provided, text separated by a line separator will be wrapped in it.

return: {string} HTML string.
param: {Object} $1                        Named argements.
param: {Object} $1.value                  Rich text value.
param: {string} [$1.multilineTag]         Multiline tag.

to_html_string_createEmpty()   X-Ref
No description

to_html_string_getLastChild(_ref2)   X-Ref
No description

to_html_string_append(parent, object)   X-Ref
No description

to_html_string_appendText(object, text)   X-Ref
No description

to_html_string_getParent(_ref3)   X-Ref
No description

to_html_string_isText(_ref4)   X-Ref
No description

to_html_string_getText(_ref5)   X-Ref
No description

to_html_string_remove(object)   X-Ref
No description

createElementHTML(_ref6)   X-Ref
No description

createChildrenHTML()   X-Ref
No description

toggleFormat(value, format)   X-Ref
Toggles a format object to a Rich Text value at the current selection.

return: {Object} A new value with the format applied or removed.
param: {Object} value  Value to modify.
param: {Object} format Format to apply or remove.

unregisterFormatType(name)   X-Ref
Unregisters a format.

return: {WPFormat|undefined} The previous format value, if it has been successfully
param: {string} name Format name.

getLineIndex(_ref)   X-Ref
Gets the currently selected line index, or the first line index if the
selection spans over multiple items.

return: {?boolean} The line index. Undefined if not found.
param: {Object}  value      Value to get the line index from.
param: {boolean} startIndex Optional index that should be contained by the

getTargetLevelLineIndex(_ref, lineIndex)   X-Ref
Gets the line index of the first previous list item with higher indentation.

return: {boolean} The line index.
param: {Object} value      Value to search.
param: {number} lineIndex  Line index of the list item to compare with.

indentListItems(value, rootFormat)   X-Ref
Indents any selected list items if possible.

return: {Object} The changed value.
param: {Object} value      Value to change.
param: {Object} rootFormat Root format.

getParentLineIndex(_ref, lineIndex)   X-Ref
Gets the index of the first parent list. To get the parent list formats, we
go through every list item until we find one with exactly one format type
less.

return: {Array} The parent list line index.
param: {Object} value     Value to search.
param: {number} lineIndex Line index of a child list item.

getLastChildIndex(_ref, lineIndex)   X-Ref
Gets the line index of the last child in the list.

return: {Array} The index of the last child.
param: {Object} value     Value to search.
param: {number} lineIndex Line index of a list item in the list.

outdentListItems(value)   X-Ref
Outdents any selected list items if possible.

return: {Object} The changed value.
param: {Object} value Value to change.

changeListType(value, newFormat)   X-Ref
Changes the list type of the selected indented list, if any. Looks at the
currently selected list item and takes the parent list, then changes the list
type of this list. When multiple lines are selected, the parent lists are
takes and changed.

return: {Object} The changed value.
param: {Object} value     Value to change.
param: {Object} newFormat The new list format object. Choose between

updateFormats(_ref)   X-Ref
Efficiently updates all the formats from `start` (including) until `end`
(excluding) with the active formats. Mutates `value`.

return: {Object} Mutated value.
param: {Object} $1         Named paramentes.
param: {Object} $1.value   Value te update.
param: {number} $1.start   Index to update from.
param: {number} $1.end     Index to update until.
param: {Array}  $1.formats Replacement formats.

memoized( )   X-Ref
No description

_objectSpread(target)   X-Ref
No description



Generated: Mon Sep 16 01:00:03 2019 Cross-referenced by PHPXref 0.7.1