From 7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 7 Jan 2020 13:06:14 +0100 Subject: Added wordpress --- srcs/wordpress/wp-includes/js/dist/rich-text.js | 5293 +++++++++++++++++++++++ 1 file changed, 5293 insertions(+) create mode 100644 srcs/wordpress/wp-includes/js/dist/rich-text.js (limited to 'srcs/wordpress/wp-includes/js/dist/rich-text.js') diff --git a/srcs/wordpress/wp-includes/js/dist/rich-text.js b/srcs/wordpress/wp-includes/js/dist/rich-text.js new file mode 100644 index 0000000..dac7c8f --- /dev/null +++ b/srcs/wordpress/wp-includes/js/dist/rich-text.js @@ -0,0 +1,5293 @@ +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.childNodes[endOffset - 1]) { + accumulator.end = currentLength + value.text.length; // Range indicates that the selection is before the current node. + } else if (parentNode === endContainer && node === endContainer.childNodes[endOffset]) { + accumulator.end = currentLength; // Fallback if no child inside handled the selection. + } else if (node === endContainer) { + accumulator.end = currentLength + endOffset; + } +} +/** + * Adjusts the start and end offsets from a range based on a text filter. + * + * @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. + * + * @return {?Object} Object containing range properties. + */ + + +function filterRange(node, range, filter) { + if (!range) { + return; + } + + var startContainer = range.startContainer, + endContainer = range.endContainer; + var startOffset = range.startOffset, + endOffset = range.endOffset; + + if (node === startContainer) { + startOffset = filter(node.nodeValue.slice(0, startOffset)).length; + } + + if (node === endContainer) { + endOffset = filter(node.nodeValue.slice(0, endOffset)).length; + } + + return { + startContainer: startContainer, + startOffset: startOffset, + endContainer: endContainer, + endOffset: endOffset + }; +} + +var ZWNBSPRegExp = new RegExp(ZWNBSP, 'g'); + +function filterString(string) { + // Reduce any whitespace used for HTML formatting to one space + // character, because it will also be displayed as such by the browser. + return string.replace(/[\n\r\t]+/g, ' ') // Remove padding added by `toTree`. + .replace(ZWNBSPRegExp, ''); +} +/** + * Creates a Rich Text value from a DOM element and range. + * + * @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 + * multiline. + * @param {?Array} $1.multilineWrapperTags Tags where lines can be found if + * nesting is possible. + * + * @return {Object} A rich text value. + */ + + +function createFromElement(_ref3) { + var element = _ref3.element, + range = _ref3.range, + multilineTag = _ref3.multilineTag, + multilineWrapperTags = _ref3.multilineWrapperTags, + _ref3$currentWrapperT = _ref3.currentWrapperTags, + currentWrapperTags = _ref3$currentWrapperT === void 0 ? [] : _ref3$currentWrapperT, + isEditableTree = _ref3.isEditableTree; + var accumulator = createEmptyValue(); + + if (!element) { + return accumulator; + } + + if (!element.hasChildNodes()) { + accumulateSelection(accumulator, element, range, createEmptyValue()); + return accumulator; + } + + var length = element.childNodes.length; // Optimise for speed. + + var _loop = function _loop(index) { + var node = element.childNodes[index]; + var type = node.nodeName.toLowerCase(); + + if (node.nodeType === TEXT_NODE) { + var text = filterString(node.nodeValue); + range = filterRange(node, range, filterString); + accumulateSelection(accumulator, node, range, { + text: text + }); // Create a sparse array of the same length as `text`, in which + // formats can be added. + + accumulator.formats.length += text.length; + accumulator.replacements.length += text.length; + accumulator.text += text; + return "continue"; + } + + if (node.nodeType !== ELEMENT_NODE) { + return "continue"; + } + + if (isEditableTree && ( // Ignore any placeholders. + node.getAttribute('data-rich-text-placeholder') || // Ignore any line breaks that are not inserted by us. + type === 'br' && !node.getAttribute('data-rich-text-line-break'))) { + accumulateSelection(accumulator, node, range, createEmptyValue()); + return "continue"; + } + + if (type === 'br') { + accumulateSelection(accumulator, node, range, createEmptyValue()); + mergePair(accumulator, create({ + text: '\n' + })); + return "continue"; + } + + var lastFormats = accumulator.formats[accumulator.formats.length - 1]; + var lastFormat = lastFormats && lastFormats[lastFormats.length - 1]; + var newFormat = toFormat({ + type: type, + attributes: getAttributes({ + element: node + }) + }); + var format = isFormatEqual(newFormat, lastFormat) ? lastFormat : newFormat; + + if (multilineWrapperTags && multilineWrapperTags.indexOf(type) !== -1) { + var _value = createFromMultilineElement({ + element: node, + range: range, + multilineTag: multilineTag, + multilineWrapperTags: multilineWrapperTags, + currentWrapperTags: [].concat(Object(toConsumableArray["a" /* default */])(currentWrapperTags), [format]), + isEditableTree: isEditableTree + }); + + accumulateSelection(accumulator, node, range, _value); + mergePair(accumulator, _value); + return "continue"; + } + + var value = createFromElement({ + element: node, + range: range, + multilineTag: multilineTag, + multilineWrapperTags: multilineWrapperTags, + isEditableTree: isEditableTree + }); + accumulateSelection(accumulator, node, range, value); + + if (!format) { + mergePair(accumulator, value); + } else if (value.text.length === 0) { + if (format.attributes) { + mergePair(accumulator, { + formats: [,], + replacements: [format], + text: OBJECT_REPLACEMENT_CHARACTER + }); + } + } else { + mergePair(accumulator, Object(objectSpread["a" /* default */])({}, value, { + formats: Array.from(value.formats, function (formats) { + return formats ? [format].concat(Object(toConsumableArray["a" /* default */])(formats)) : [format]; + }) + })); + } + }; + + for (var index = 0; index < length; index++) { + var _ret = _loop(index); + + if (_ret === "continue") continue; + } + + return accumulator; +} +/** + * Creates a rich text value from a DOM element and range that should be + * multiline. + * + * @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 + * multiline. + * @param {?Array} $1.multilineWrapperTags Tags where lines can be found if + * nesting is possible. + * @param {boolean} $1.currentWrapperTags Whether to prepend a line + * separator. + * + * @return {Object} A rich text value. + */ + + +function createFromMultilineElement(_ref4) { + var element = _ref4.element, + range = _ref4.range, + multilineTag = _ref4.multilineTag, + multilineWrapperTags = _ref4.multilineWrapperTags, + _ref4$currentWrapperT = _ref4.currentWrapperTags, + currentWrapperTags = _ref4$currentWrapperT === void 0 ? [] : _ref4$currentWrapperT, + isEditableTree = _ref4.isEditableTree; + var accumulator = createEmptyValue(); + + if (!element || !element.hasChildNodes()) { + return accumulator; + } + + var length = element.children.length; // Optimise for speed. + + for (var index = 0; index < length; index++) { + var node = element.children[index]; + + if (node.nodeName.toLowerCase() !== multilineTag) { + continue; + } + + var value = createFromElement({ + element: node, + range: range, + multilineTag: multilineTag, + multilineWrapperTags: multilineWrapperTags, + currentWrapperTags: currentWrapperTags, + isEditableTree: isEditableTree + }); // Multiline value text should be separated by a line separator. + + if (index !== 0 || currentWrapperTags.length > 0) { + mergePair(accumulator, { + formats: [,], + replacements: currentWrapperTags.length > 0 ? [currentWrapperTags] : [,], + text: LINE_SEPARATOR + }); + } + + accumulateSelection(accumulator, node, range, value); + mergePair(accumulator, value); + } + + return accumulator; +} +/** + * Gets the attributes of an element in object shape. + * + * @param {Object} $1 Named argements. + * @param {Element} $1.element Element to get attributes from. + * + * @return {?Object} Attribute object or `undefined` if the element has no + * attributes. + */ + + +function getAttributes(_ref5) { + var element = _ref5.element; + + if (!element.hasAttributes()) { + return; + } + + var length = element.attributes.length; + var accumulator; // Optimise for speed. + + for (var i = 0; i < length; i++) { + var _element$attributes$i = element.attributes[i], + name = _element$attributes$i.name, + value = _element$attributes$i.value; + + if (name.indexOf('data-rich-text-') === 0) { + continue; + } + + accumulator = accumulator || {}; + accumulator[name] = value; + } + + return accumulator; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/concat.js +/** + * Internal dependencies + */ + + +/** + * Concats a pair of rich text values. Not that this mutates `a` and does NOT + * normalise formats! + * + * @param {Object} a Value to mutate. + * @param {Object} b Value to add read from. + * + * @return {Object} `a`, mutated. + */ + +function mergePair(a, b) { + a.formats = a.formats.concat(b.formats); + a.replacements = a.replacements.concat(b.replacements); + a.text += b.text; + return a; +} +/** + * Combine all Rich Text values into one. This is similar to + * `String.prototype.concat`. + * + * @param {...Object} values Objects to combine. + * + * @return {Object} A new value combining all given records. + */ + +function concat() { + for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) { + values[_key] = arguments[_key]; + } + + return normaliseFormats(values.reduce(mergePair, create())); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-formats.js +/** + * Gets the all format objects at the start of the selection. + * + * @param {Object} value Value to inspect. + * + * @return {?Object} Active format objects. + */ +function getActiveFormats(_ref) { + var formats = _ref.formats, + start = _ref.start, + end = _ref.end, + activeFormats = _ref.activeFormats; + + if (start === undefined) { + return []; + } + + if (start === end) { + // For a collapsed caret, it is possible to override the active formats. + if (activeFormats) { + return activeFormats; + } + + var formatsBefore = formats[start - 1] || []; + var formatsAfter = formats[start] || []; // By default, select the lowest amount of formats possible (which means + // the caret is positioned outside the format boundary). The user can + // then use arrow keys to define `activeFormats`. + + if (formatsBefore.length < formatsAfter.length) { + return formatsBefore; + } + + return formatsAfter; + } + + return formats[start] || []; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-format.js +/** + * External dependencies + */ + +/** + * Internal dependencies + */ + + +/** + * 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. + * + * @param {Object} value Value to inspect. + * @param {string} formatType Format type to look for. + * + * @return {Object|undefined} Active format object of the specified type, or undefined. + */ + +function getActiveFormat(value, formatType) { + return Object(external_lodash_["find"])(getActiveFormats(value), { + type: formatType + }); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-object.js +/** + * Internal dependencies + */ + +/** + * Gets the active object, if there is any. + * + * @param {Object} value Value to inspect. + * + * @return {?Object} Active object, or undefined. + */ + +function getActiveObject(_ref) { + var start = _ref.start, + end = _ref.end, + replacements = _ref.replacements, + text = _ref.text; + + if (start + 1 !== end || text[start] !== OBJECT_REPLACEMENT_CHARACTER) { + return; + } + + return replacements[start]; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-text-content.js +/** + * Get the textual content of a Rich Text value. This is similar to + * `Element.textContent`. + * + * @param {Object} value Value to use. + * + * @return {string} The text content. + */ +function getTextContent(_ref) { + var text = _ref.text; + return text; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-line-index.js +/** + * Internal dependencies + */ + +/** + * Gets the currently selected line index, or the first line index if the + * selection spans over multiple items. + * + * @param {Object} value Value to get the line index from. + * @param {boolean} startIndex Optional index that should be contained by the + * line. Defaults to the selection start of the + * value. + * + * @return {?boolean} The line index. Undefined if not found. + */ + +function getLineIndex(_ref) { + var start = _ref.start, + text = _ref.text; + var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start; + var index = startIndex; + + while (index--) { + if (text[index] === LINE_SEPARATOR) { + return index; + } + } +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-list-root-selected.js +/** + * Internal dependencies + */ + +/** + * Whether or not the root list is selected. + * + * @param {Object} value The value to check. + * + * @return {boolean} True if the root list or nothing is selected, false if an + * inner list is selected. + */ + +function isListRootSelected(value) { + var replacements = value.replacements, + start = value.start; + var lineIndex = getLineIndex(value, start); + var replacement = replacements[lineIndex]; + return !replacement || replacement.length < 1; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-active-list-type.js +/** + * Internal dependencies + */ + +/** + * Wether or not the selected list has the given tag name. + * + * @param {Object} value The value to check. + * @param {string} type The tag name the list should have. + * @param {string} rootType The current root tag name, to compare with in case + * nothing is selected. + * + * @return {boolean} True if the current list type matches `type`, false if not. + */ + +function isActiveListType(value, type, rootType) { + var replacements = value.replacements, + start = value.start; + var lineIndex = getLineIndex(value, start); + var replacement = replacements[lineIndex]; + + if (!replacement || replacement.length === 0) { + return type === rootType; + } + + var lastFormat = replacement[replacement.length - 1]; + return lastFormat.type === type; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-collapsed.js +/** + * 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()`. + * + * @param {Object} value The rich text value to check. + * + * @return {boolean|undefined} True if the selection is collapsed, false if not, + * undefined if there is no selection. + */ +function isCollapsed(_ref) { + var start = _ref.start, + end = _ref.end; + + if (start === undefined || end === undefined) { + return; + } + + return start === end; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-empty.js +/** + * Internal dependencies + */ + +/** + * Check if a Rich Text value is Empty, meaning it contains no text or any + * objects (such as images). + * + * @param {Object} value Value to use. + * + * @return {boolean} True if the value is empty, false if not. + */ + +function isEmpty(_ref) { + var text = _ref.text; + return text.length === 0; +} +/** + * Check if the current collapsed selection is on an empty line in case of a + * multiline value. + * + * @param {Object} value Value te check. + * + * @return {boolean} True if the line is empty, false if not. + */ + +function isEmptyLine(_ref2) { + var text = _ref2.text, + start = _ref2.start, + end = _ref2.end; + + if (start !== end) { + return false; + } + + if (text.length === 0) { + return true; + } + + if (start === 0 && text.slice(0, 1) === LINE_SEPARATOR) { + return true; + } + + if (start === text.length && text.slice(-1) === LINE_SEPARATOR) { + return true; + } + + return text.slice(start - 1, end + 1) === "".concat(LINE_SEPARATOR).concat(LINE_SEPARATOR); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/join.js +/** + * Internal dependencies + */ + + +/** + * 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`. + * + * @param {Array} values An array of values to join. + * @param {string|Object} [separator] Separator string or value. + * + * @return {Object} A new combined value. + */ + +function join(values) { + var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; + + if (typeof separator === 'string') { + separator = create({ + text: separator + }); + } + + return normaliseFormats(values.reduce(function (accumlator, _ref) { + var formats = _ref.formats, + replacements = _ref.replacements, + text = _ref.text; + return { + formats: accumlator.formats.concat(separator.formats, formats), + replacements: accumlator.replacements.concat(separator.replacements, replacements), + text: accumlator.text + separator.text + text + }; + })); +} + +// EXTERNAL MODULE: external {"this":["wp","element"]} +var external_this_wp_element_ = __webpack_require__(0); + +// EXTERNAL MODULE: external {"this":["wp","hooks"]} +var external_this_wp_hooks_ = __webpack_require__(27); + +// EXTERNAL MODULE: external {"this":["wp","compose"]} +var external_this_wp_compose_ = __webpack_require__(8); + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/register-format-type.js + + + +/** + * External dependencies + */ + +/** + * WordPress dependencies + */ + + + + +/** + * Registers a new format provided a unique name and an object defining its + * behavior. + * + * @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. + * + * @return {WPFormat|undefined} The format, if it has been successfully registered; + * otherwise `undefined`. + */ + +function registerFormatType(name, settings) { + settings = Object(objectSpread["a" /* default */])({ + name: name + }, settings); + + if (typeof settings.name !== 'string') { + window.console.error('Format names must be strings.'); + return; + } + + if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(settings.name)) { + window.console.error('Format names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-format'); + return; + } + + if (Object(external_this_wp_data_["select"])('core/rich-text').getFormatType(settings.name)) { + window.console.error('Format "' + settings.name + '" is already registered.'); + return; + } + + if (typeof settings.tagName !== 'string' || settings.tagName === '') { + window.console.error('Format tag names must be a string.'); + return; + } + + if ((typeof settings.className !== 'string' || settings.className === '') && settings.className !== null) { + window.console.error('Format class names must be a string, or null to handle bare elements.'); + return; + } + + if (!/^[_a-zA-Z]+[a-zA-Z0-9-]*$/.test(settings.className)) { + window.console.error('A class name must begin with a letter, followed by any number of hyphens, letters, or numbers.'); + return; + } + + if (settings.className === null) { + var formatTypeForBareElement = Object(external_this_wp_data_["select"])('core/rich-text').getFormatTypeForBareElement(settings.tagName); + + if (formatTypeForBareElement) { + window.console.error("Format \"".concat(formatTypeForBareElement.name, "\" is already registered to handle bare tag name \"").concat(settings.tagName, "\".")); + return; + } + } else { + var formatTypeForClassName = Object(external_this_wp_data_["select"])('core/rich-text').getFormatTypeForClassName(settings.className); + + if (formatTypeForClassName) { + window.console.error("Format \"".concat(formatTypeForClassName.name, "\" is already registered to handle class name \"").concat(settings.className, "\".")); + return; + } + } + + if (!('title' in settings) || settings.title === '') { + window.console.error('The format "' + settings.name + '" must have a title.'); + return; + } + + if ('keywords' in settings && settings.keywords.length > 3) { + window.console.error('The format "' + settings.name + '" can have a maximum of 3 keywords.'); + return; + } + + if (typeof settings.title !== 'string') { + window.console.error('Format titles must be strings.'); + return; + } + + Object(external_this_wp_data_["dispatch"])('core/rich-text').addFormatTypes(settings); + + if (settings.__experimentalCreatePrepareEditableTree) { + Object(external_this_wp_hooks_["addFilter"])('experimentalRichText', name, function (OriginalComponent) { + var selectPrefix = "format_prepare_props_(".concat(name, ")_"); + var dispatchPrefix = "format_on_change_props_(".concat(name, ")_"); + + var Component = function Component(props) { + var newProps = Object(objectSpread["a" /* default */])({}, props); + + var propsByPrefix = Object.keys(props).reduce(function (accumulator, key) { + if (key.startsWith(selectPrefix)) { + accumulator[key.slice(selectPrefix.length)] = props[key]; + } + + if (key.startsWith(dispatchPrefix)) { + accumulator[key.slice(dispatchPrefix.length)] = props[key]; + } + + return accumulator; + }, {}); + var args = { + richTextIdentifier: props.identifier, + blockClientId: props.clientId + }; + + if (settings.__experimentalCreateOnChangeEditableValue) { + newProps["format_value_functions_(".concat(name, ")")] = settings.__experimentalCreatePrepareEditableTree(propsByPrefix, args); + newProps["format_on_change_functions_(".concat(name, ")")] = settings.__experimentalCreateOnChangeEditableValue(propsByPrefix, args); + } else { + newProps["format_prepare_functions_(".concat(name, ")")] = settings.__experimentalCreatePrepareEditableTree(propsByPrefix, args); + } + + return Object(external_this_wp_element_["createElement"])(OriginalComponent, newProps); + }; + + var hocs = []; + + if (settings.__experimentalGetPropsForEditableTreePreparation) { + hocs.push(Object(external_this_wp_data_["withSelect"])(function (sel, _ref) { + var clientId = _ref.clientId, + identifier = _ref.identifier; + return Object(external_lodash_["mapKeys"])(settings.__experimentalGetPropsForEditableTreePreparation(sel, { + richTextIdentifier: identifier, + blockClientId: clientId + }), function (value, key) { + return selectPrefix + key; + }); + })); + } + + if (settings.__experimentalGetPropsForEditableTreeChangeHandler) { + hocs.push(Object(external_this_wp_data_["withDispatch"])(function (disp, _ref2) { + var clientId = _ref2.clientId, + identifier = _ref2.identifier; + return Object(external_lodash_["mapKeys"])(settings.__experimentalGetPropsForEditableTreeChangeHandler(disp, { + richTextIdentifier: identifier, + blockClientId: clientId + }), function (value, key) { + return dispatchPrefix + key; + }); + })); + } + + return hocs.length ? Object(external_this_wp_compose_["compose"])(hocs)(Component) : Component; + }); + } + + return settings; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove-format.js + + +/** + * External dependencies + */ + +/** + * Internal dependencies + */ + + +/** + * 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. + * + * @param {Object} value Value to modify. + * @param {string} formatType Format type to remove. + * @param {number} [startIndex] Start index. + * @param {number} [endIndex] End index. + * + * @return {Object} A new value with the format applied. + */ + +function removeFormat(value, formatType) { + 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(); // If the selection is collapsed, expand start and end to the edges of the + // format. + + if (startIndex === endIndex) { + var format = Object(external_lodash_["find"])(newFormats[startIndex], { + type: formatType + }); + + if (format) { + while (Object(external_lodash_["find"])(newFormats[startIndex], format)) { + filterFormats(newFormats, startIndex, formatType); + startIndex--; + } + + endIndex++; + + while (Object(external_lodash_["find"])(newFormats[endIndex], format)) { + filterFormats(newFormats, endIndex, formatType); + endIndex++; + } + } + } else { + for (var i = startIndex; i < endIndex; i++) { + if (newFormats[i]) { + filterFormats(newFormats, i, formatType); + } + } + } + + return normaliseFormats(Object(objectSpread["a" /* default */])({}, value, { + formats: newFormats, + activeFormats: Object(external_lodash_["reject"])(activeFormats, { + type: formatType + }) + })); +} + +function filterFormats(formats, index, formatType) { + var newFormats = formats[index].filter(function (_ref) { + var type = _ref.type; + return type !== formatType; + }); + + if (newFormats.length) { + formats[index] = newFormats; + } else { + delete formats[index]; + } +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert.js +/** + * Internal dependencies + */ + + +/** + * 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. + * + * @param {Object} value Value to modify. + * @param {Object|string} valueToInsert Value to insert. + * @param {number} [startIndex] Start index. + * @param {number} [endIndex] End index. + * + * @return {Object} A new value with the value inserted. + */ + +function insert(value, valueToInsert) { + 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, + replacements = value.replacements, + text = value.text; + + if (typeof valueToInsert === 'string') { + valueToInsert = create({ + text: valueToInsert + }); + } + + var index = startIndex + valueToInsert.text.length; + return normaliseFormats({ + formats: formats.slice(0, startIndex).concat(valueToInsert.formats, formats.slice(endIndex)), + replacements: replacements.slice(0, startIndex).concat(valueToInsert.replacements, replacements.slice(endIndex)), + text: text.slice(0, startIndex) + valueToInsert.text + text.slice(endIndex), + start: index, + end: index + }); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove.js +/** + * Internal dependencies + */ + + +/** + * Remove content from a Rich Text value between the given `startIndex` and + * `endIndex`. Indices are retrieved from the selection if none are provided. + * + * @param {Object} value Value to modify. + * @param {number} [startIndex] Start index. + * @param {number} [endIndex] End index. + * + * @return {Object} A new value with the content removed. + */ + +function remove_remove(value, startIndex, endIndex) { + return insert(value, create(), startIndex, endIndex); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/rich-tex