diff options
Diffstat (limited to 'srcs/wordpress/wp-includes/js/dist/rich-text.js')
| -rw-r--r-- | srcs/wordpress/wp-includes/js/dist/rich-text.js | 5293 |
1 files changed, 0 insertions, 5293 deletions
diff --git a/srcs/wordpress/wp-includes/js/dist/rich-text.js b/srcs/wordpress/wp-includes/js/dist/rich-text.js deleted file mode 100644 index dac7c8f..0000000 --- a/srcs/wordpress/wp-includes/js/dist/rich-text.js +++ /dev/null @@ -1,5293 +0,0 @@ -this["wp"] = this["wp"] || {}; this["wp"]["richText"] = -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 346); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ 0: -/***/ (function(module, exports) { - -(function() { module.exports = this["wp"]["element"]; }()); - -/***/ }), - -/***/ 10: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -/***/ }), - -/***/ 11: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; }); -function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } -} - -function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; -} - -/***/ }), - -/***/ 12: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; }); -function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -} - -/***/ }), - -/***/ 13: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; }); -/* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(31); -/* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5); - - -function _possibleConstructorReturn(self, call) { - if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) { - return call; - } - - return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self); -} - -/***/ }), - -/***/ 14: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; }); -function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); -} - -/***/ }), - -/***/ 15: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; - -// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js -function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); -} -// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; }); - -function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - if (superClass) _setPrototypeOf(subClass, superClass); -} - -/***/ }), - -/***/ 16: -/***/ (function(module, exports, __webpack_require__) { - -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! - Copyright (c) 2017 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/ -/* global define */ - -(function () { - 'use strict'; - - var hasOwn = {}.hasOwnProperty; - - function classNames () { - var classes = []; - - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) continue; - - var argType = typeof arg; - - if (argType === 'string' || argType === 'number') { - classes.push(arg); - } else if (Array.isArray(arg) && arg.length) { - var inner = classNames.apply(null, arg); - if (inner) { - classes.push(inner); - } - } else if (argType === 'object') { - for (var key in arg) { - if (hasOwn.call(arg, key) && arg[key]) { - classes.push(key); - } - } - } - } - - return classes.join(' '); - } - - if ( true && module.exports) { - classNames.default = classNames; - module.exports = classNames; - } else if (true) { - // register as 'classnames', consistent with npm package name - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { - return classNames; - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}()); - - -/***/ }), - -/***/ 17: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; - -// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js -function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) { - for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { - arr2[i] = arr[i]; - } - - return arr2; - } -} -// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js -var iterableToArray = __webpack_require__(30); - -// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js -function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance"); -} -// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; }); - - - -function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread(); -} - -/***/ }), - -/***/ 18: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); -function _extends() { - _extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - - return target; - }; - - return _extends.apply(this, arguments); -} - -/***/ }), - -/***/ 19: -/***/ (function(module, exports) { - -(function() { module.exports = this["wp"]["keycodes"]; }()); - -/***/ }), - -/***/ 2: -/***/ (function(module, exports) { - -(function() { module.exports = this["lodash"]; }()); - -/***/ }), - -/***/ 21: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; - -// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js -function _objectWithoutPropertiesLoose(source, excluded) { - if (source == null) return {}; - var target = {}; - var sourceKeys = Object.keys(source); - var key, i; - - for (i = 0; i < sourceKeys.length; i++) { - key = sourceKeys[i]; - if (excluded.indexOf(key) >= 0) continue; - target[key] = source[key]; - } - - return target; -} -// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutProperties; }); - -function _objectWithoutProperties(source, excluded) { - if (source == null) return {}; - var target = _objectWithoutPropertiesLoose(source, excluded); - var key, i; - - if (Object.getOwnPropertySymbols) { - var sourceSymbolKeys = Object.getOwnPropertySymbols(source); - - for (i = 0; i < sourceSymbolKeys.length; i++) { - key = sourceSymbolKeys[i]; - if (excluded.indexOf(key) >= 0) continue; - if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; - target[key] = source[key]; - } - } - - return target; -} - -/***/ }), - -/***/ 27: -/***/ (function(module, exports) { - -(function() { module.exports = this["wp"]["hooks"]; }()); - -/***/ }), - -/***/ 30: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); -function _iterableToArray(iter) { - if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); -} - -/***/ }), - -/***/ 31: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; }); -function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } - -function _typeof(obj) { - if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { - _typeof = function _typeof(obj) { - return _typeof2(obj); - }; - } else { - _typeof = function _typeof(obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); - }; - } - - return _typeof(obj); -} - -/***/ }), - -/***/ 346: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -var selectors_namespaceObject = {}; -__webpack_require__.r(selectors_namespaceObject); -__webpack_require__.d(selectors_namespaceObject, "getFormatTypes", function() { return getFormatTypes; }); -__webpack_require__.d(selectors_namespaceObject, "getFormatType", function() { return getFormatType; }); -__webpack_require__.d(selectors_namespaceObject, "getFormatTypeForBareElement", function() { return getFormatTypeForBareElement; }); -__webpack_require__.d(selectors_namespaceObject, "getFormatTypeForClassName", function() { return getFormatTypeForClassName; }); -var actions_namespaceObject = {}; -__webpack_require__.r(actions_namespaceObject); -__webpack_require__.d(actions_namespaceObject, "addFormatTypes", function() { return addFormatTypes; }); -__webpack_require__.d(actions_namespaceObject, "removeFormatTypes", function() { return removeFormatTypes; }); - -// EXTERNAL MODULE: external {"this":["wp","data"]} -var external_this_wp_data_ = __webpack_require__(4); - -// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js -var objectSpread = __webpack_require__(7); - -// EXTERNAL MODULE: external "lodash" -var external_lodash_ = __webpack_require__(2); - -// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/reducer.js - - -/** - * External dependencies - */ - -/** - * WordPress dependencies - */ - - -/** - * Reducer managing the format types - * - * @param {Object} state Current state. - * @param {Object} action Dispatched action. - * - * @return {Object} Updated state. - */ - -function reducer_formatTypes() { - var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var action = arguments.length > 1 ? arguments[1] : undefined; - - switch (action.type) { - case 'ADD_FORMAT_TYPES': - return Object(objectSpread["a" /* default */])({}, state, Object(external_lodash_["keyBy"])(action.formatTypes, 'name')); - - case 'REMOVE_FORMAT_TYPES': - return Object(external_lodash_["omit"])(state, action.names); - } - - return state; -} -/* harmony default export */ var reducer = (Object(external_this_wp_data_["combineReducers"])({ - formatTypes: reducer_formatTypes -})); - -// EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js -var rememo = __webpack_require__(36); - -// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js -/** - * External dependencies - */ - - -/** - * Returns all the available format types. - * - * @param {Object} state Data state. - * - * @return {Array} Format types. - */ - -var getFormatTypes = Object(rememo["a" /* default */])(function (state) { - return Object.values(state.formatTypes); -}, function (state) { - return [state.formatTypes]; -}); -/** - * Returns a format type by name. - * - * @param {Object} state Data state. - * @param {string} name Format type name. - * - * @return {Object?} Format type. - */ - -function getFormatType(state, name) { - return state.formatTypes[name]; -} -/** - * 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. - * - * @param {Object} state Data state. - * @param {string} bareElementTagName The tag name of the element to find a - * format type for. - * @return {?Object} Format type. - */ - -function getFormatTypeForBareElement(state, bareElementTagName) { - return Object(external_lodash_["find"])(getFormatTypes(state), function (_ref) { - var className = _ref.className, - tagName = _ref.tagName; - return className === null && bareElementTagName === tagName; - }); -} -/** - * Gets the format type, if any, that can handle an element, given its classes. - * - * @param {Object} state Data state. - * @param {string} elementClassName The classes of the element to find a format - * type for. - * @return {?Object} Format type. - */ - -function getFormatTypeForClassName(state, elementClassName) { - return Object(external_lodash_["find"])(getFormatTypes(state), function (_ref2) { - var className = _ref2.className; - - if (className === null) { - return false; - } - - return " ".concat(elementClassName, " ").indexOf(" ".concat(className, " ")) >= 0; - }); -} - -// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/actions.js -/** - * External dependencies - */ - -/** - * Returns an action object used in signalling that format types have been - * added. - * - * @param {Array|Object} formatTypes Format types received. - * - * @return {Object} Action object. - */ - -function addFormatTypes(formatTypes) { - return { - type: 'ADD_FORMAT_TYPES', - formatTypes: Object(external_lodash_["castArray"])(formatTypes) - }; -} -/** - * Returns an action object used to remove a registered format type. - * - * @param {string|Array} names Format name. - * - * @return {Object} Action object. - */ - -function removeFormatTypes(names) { - return { - type: 'REMOVE_FORMAT_TYPES', - names: Object(external_lodash_["castArray"])(names) - }; -} - -// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/index.js -/** - * WordPress dependencies - */ - -/** - * Internal dependencies - */ - - - - -Object(external_this_wp_data_["registerStore"])('core/rich-text', { - reducer: reducer, - selectors: selectors_namespaceObject, - actions: actions_namespaceObject -}); - -// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules -var toConsumableArray = __webpack_require__(17); - -// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-format-equal.js -/** - * Optimised equality check for format objects. - * - * @param {?Object} format1 Format to compare. - * @param {?Object} format2 Format to compare. - * - * @return {boolean} True if formats are equal, false if not. - */ -function isFormatEqual(format1, format2) { - // Both not defined. - if (format1 === format2) { - return true; - } // Either not defined. - - - if (!format1 || !format2) { - return false; - } - - if (format1.type !== format2.type) { - return false; - } - - var attributes1 = format1.attributes; - var attributes2 = format2.attributes; // Both not defined. - - if (attributes1 === attributes2) { - return true; - } // Either not defined. - - - if (!attributes1 || !attributes2) { - return false; - } - - var keys1 = Object.keys(attributes1); - var keys2 = Object.keys(attributes2); - - if (keys1.length !== keys2.length) { - return false; - } - - var length = keys1.length; // Optimise for speed. - - for (var i = 0; i < length; i++) { - var name = keys1[i]; - - if (attributes1[name] !== attributes2[name]) { - return false; - } - } - - return true; -} - -// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/normalise-formats.js - - -/** - * Internal dependencies - */ - -/** - * Normalises formats: ensures subsequent adjacent equal formats have the same - * reference. - * - * @param {Object} value Value to normalise formats of. - * - * @return {Object} New value with normalised formats. - */ - -function normaliseFormats(value) { - var newFormats = value.formats.slice(); - newFormats.forEach(function (formatsAtIndex, index) { - var formatsAtPreviousIndex = newFormats[index - 1]; - - if (formatsAtPreviousIndex) { - var newFormatsAtIndex = formatsAtIndex.slice(); - newFormatsAtIndex.forEach(function (format, formatIndex) { - var previousFormat = formatsAtPreviousIndex[formatIndex]; - - if (isFormatEqual(format, previousFormat)) { - newFormatsAtIndex[formatIndex] = previousFormat; - } - }); - newFormats[index] = newFormatsAtIndex; - } - }); - return Object(objectSpread["a" /* default */])({}, value, { - formats: newFormats - }); -} - -// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/apply-format.js - - - -/** - * External dependencies - */ - -/** - * Internal dependencies - */ - - - -function replace(array, index, value) { - array = array.slice(); - array[index] = value; - return array; -} -/** - * 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. - * - * @param {Object} value Value to modify. - * @param {Object} format Format to apply. - * @param {number} [startIndex] Start index. - * @param {number} [endIndex] End index. - * - * @return {Object} A new value with the format applied. - */ - - -function applyFormat(value, format) { - var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.start; - var endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : value.end; - var formats = value.formats, - activeFormats = value.activeFormats; - var newFormats = formats.slice(); // The selection is collapsed. - - if (startIndex === endIndex) { - var startFormat = Object(external_lodash_["find"])(newFormats[startIndex], { - type: format.type - }); // If the caret is at a format of the same type, expand start and end to - // the edges of the format. This is useful to apply new attributes. - - if (startFormat) { - var index = newFormats[startIndex].indexOf(startFormat); - - while (newFormats[startIndex] && newFormats[startIndex][index] === startFormat) { - newFormats[startIndex] = replace(newFormats[startIndex], index, format); - startIndex--; - } - - endIndex++; - - while (newFormats[endIndex] && newFormats[endIndex][index] === startFormat) { - newFormats[endIndex] = replace(newFormats[endIndex], index, format); - endIndex++; - } - } - } else { - // Determine the highest position the new format can be inserted at. - var position = +Infinity; - - for (var _index = startIndex; _index < endIndex; _index++) { - if (newFormats[_index]) { - newFormats[_index] = newFormats[_index].filter(function (_ref) { - var type = _ref.type; - return type !== format.type; - }); - var length = newFormats[_index].length; - - if (length < position) { - position = length; - } - } else { - newFormats[_index] = []; - position = 0; - } - } - - for (var _index2 = startIndex; _index2 < endIndex; _index2++) { - newFormats[_index2].splice(position, 0, format); - } - } - - return normaliseFormats(Object(objectSpread["a" /* default */])({}, value, { - formats: newFormats, - // Always revise active formats. This serves as a placeholder for new - // inputs with the format so new input appears with the format applied, - // and ensures a format of the same type uses the latest values. - activeFormats: [].concat(Object(toConsumableArray["a" /* default */])(Object(external_lodash_["reject"])(activeFormats, { - type: format.type - })), [format]) - })); -} - -// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js -var esm_typeof = __webpack_require__(31); - -// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create-element.js -/** - * 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. - * - * @param {HTMLDocument} document The HTML document to use to parse. - * @param {string} html The HTML to parse. - * - * @return {HTMLBodyElement} Body element with parsed HTML. - */ -function createElement(_ref, html) { - var implementation = _ref.implementation; - - // Because `createHTMLDocument` is an expensive operation, and with this - // function being internal to `rich-text` (full control in avoiding a risk - // of asynchronous operations on the shared reference), a single document - // is reused and reset for each call to the function. - if (!createElement.body) { - createElement.body = implementation.createHTMLDocument('').body; - } - - createElement.body.innerHTML = html; - return createElement.body; -} - -// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/special-characters.js -/** - * Line separator character, used for multiline text. - */ -var LINE_SEPARATOR = "\u2028"; -/** - * Object replacement character, used as a placeholder for objects. - */ - -var OBJECT_REPLACEMENT_CHARACTER = "\uFFFC"; -/** - * Zero width non-breaking space, used as padding in the editable DOM tree when - * it is empty otherwise. - */ - -var ZWNBSP = "\uFEFF"; - -// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create.js - - - - -/** - * WordPress dependencies - */ - -/** - * Internal dependencies - */ - - - - - -/** - * Browser dependencies - */ - -var _window$Node = window.Node, - TEXT_NODE = _window$Node.TEXT_NODE, - ELEMENT_NODE = _window$Node.ELEMENT_NODE; - -function createEmptyValue() { - return { - formats: [], - replacements: [], - text: '' - }; -} - -function simpleFindKey(object, value) { - for (var key in object) { - if (object[key] === value) { - return key; - } - } -} - -function toFormat(_ref) { - var type = _ref.type, - attributes = _ref.attributes; - var formatType; - - if (attributes && attributes.class) { - formatType = Object(external_this_wp_data_["select"])('core/rich-text').getFormatTypeForClassName(attributes.class); - - if (formatType) { - // Preserve any additional classes. - attributes.class = " ".concat(attributes.class, " ").replace(" ".concat(formatType.className, " "), ' ').trim(); - - if (!attributes.class) { - delete attributes.class; - } - } - } - - if (!formatType) { - formatType = Object(external_this_wp_data_["select"])('core/rich-text').getFormatTypeForBareElement(type); - } - - if (!formatType) { - return attributes ? { - type: type, - attributes: attributes - } : { - type: type - }; - } - - if (formatType.__experimentalCreatePrepareEditableTree && !formatType.__experimentalCreateOnChangeEditableValue) { - return null; - } - - if (!attributes) { - return { - type: formatType.name - }; - } - - var registeredAttributes = {}; - var unregisteredAttributes = {}; - - for (var name in attributes) { - var key = simpleFindKey(formatType.attributes, name); - - if (key) { - registeredAttributes[key] = attributes[name]; - } else { - unregisteredAttributes[name] = attributes[name]; - } - } - - return { - type: formatType.name, - attributes: registeredAttributes, - unregisteredAttributes: unregisteredAttributes - }; -} -/** - * 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. - * - * @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 - * multiline. - * @param {Array} [$1.multilineWrapperTags] Tags where lines can be found if - * nesting is possible. - * - * @return {Object} A rich text value. - */ - - -function create() { - var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - element = _ref2.element, - text = _ref2.text, - html = _ref2.html, - range = _ref2.range, - multilineTag = _ref2.multilineTag, - multilineWrapperTags = _ref2.multilineWrapperTags, - isEditableTree = _ref2.__unstableIsEditableTree; - - if (typeof text === 'string' && text.length > 0) { - return { - formats: Array(text.length), - replacements: Array(text.length), - text: text - }; - } - - if (typeof html === 'string' && html.length > 0) { - element = createElement(document, html); - } - - if (Object(esm_typeof["a" /* default */])(element) !== 'object') { - return createEmptyValue(); - } - - if (!multilineTag) { - return createFromElement({ - element: element, - range: range, - isEditableTree: isEditableTree - }); - } - - return createFromMultilineElement({ - element: element, - range: range, - multilineTag: multilineTag, - multilineWrapperTags: multilineWrapperTags, - isEditableTree: isEditableTree - }); -} -/** - * 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. - */ - -function accumulateSelection(accumulator, node, range, value) { - if (!range) { - return; - } - - var parentNode = node.parentNode; - var startContainer = range.startContainer, - startOffset = range.startOffset, - endContainer = range.endContainer, - endOffset = range.endOffset; - var currentLength = accumulator.text.length; // Selection can be extracted from value. - - if (value.start !== undefined) { - accumulator.start = currentLength + value.start; // Range indicates that the current node has selection. - } else if (node === startContainer && node.nodeType === TEXT_NODE) { - accumulator.start = currentLength + startOffset; // Range indicates that the current node is selected. - } else if (parentNode === startContainer && node === startContainer.childNodes[startOffset]) { - accumulator.start = currentLength; // Range indicates that the selection is after the current node. - } else if (parentNode === startContainer && node === startContainer.childNodes[startOffset - 1]) { - accumulator.start = currentLength + value.text.length; // Fallback if no child inside handled the selection. - } else if (node === startContainer) { - accumulator.start = currentLength; - } // Selection can be extracted from value. - - - if (value.end !== undefined) { - accumulator.end = currentLength + value.end; // Range indicates that the current node has selection. - } else if (node === endContainer && node.nodeType === TEXT_NODE) { - accumulator.end = currentLength + endOffset; // Range indicates that the current node is selected. - } else if (parentNode === endContainer && node === endContainer.chi |
