changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
18:be944660c56a | 19:3d72ae0968f4 |
---|---|
1 this["wp"] = this["wp"] || {}; this["wp"]["richText"] = |
1 /******/ (function() { // webpackBootstrap |
2 /******/ (function(modules) { // webpackBootstrap |
2 /******/ "use strict"; |
3 /******/ // The module cache |
3 /******/ // The require scope |
4 /******/ var installedModules = {}; |
4 /******/ var __webpack_require__ = {}; |
5 /******/ |
5 /******/ |
6 /******/ // The require function |
6 /************************************************************************/ |
7 /******/ function __webpack_require__(moduleId) { |
7 /******/ /* webpack/runtime/define property getters */ |
8 /******/ |
8 /******/ !function() { |
9 /******/ // Check if module is in cache |
9 /******/ // define getter functions for harmony exports |
10 /******/ if(installedModules[moduleId]) { |
10 /******/ __webpack_require__.d = function(exports, definition) { |
11 /******/ return installedModules[moduleId].exports; |
11 /******/ for(var key in definition) { |
12 /******/ } |
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
13 /******/ // Create a new module (and put it into the cache) |
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
14 /******/ var module = installedModules[moduleId] = { |
14 /******/ } |
15 /******/ i: moduleId, |
15 /******/ } |
16 /******/ l: false, |
|
17 /******/ exports: {} |
|
18 /******/ }; |
16 /******/ }; |
19 /******/ |
17 /******/ }(); |
20 /******/ // Execute the module function |
18 /******/ |
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
22 /******/ |
20 /******/ !function() { |
23 /******/ // Flag the module as loaded |
21 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
24 /******/ module.l = true; |
22 /******/ }(); |
25 /******/ |
23 /******/ |
26 /******/ // Return the exports of the module |
24 /******/ /* webpack/runtime/make namespace object */ |
27 /******/ return module.exports; |
25 /******/ !function() { |
28 /******/ } |
26 /******/ // define __esModule on exports |
29 /******/ |
27 /******/ __webpack_require__.r = function(exports) { |
30 /******/ |
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
31 /******/ // expose the modules object (__webpack_modules__) |
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
32 /******/ __webpack_require__.m = modules; |
30 /******/ } |
33 /******/ |
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
34 /******/ // expose the module cache |
32 /******/ }; |
35 /******/ __webpack_require__.c = installedModules; |
33 /******/ }(); |
36 /******/ |
34 /******/ |
37 /******/ // define getter function for harmony exports |
|
38 /******/ __webpack_require__.d = function(exports, name, getter) { |
|
39 /******/ if(!__webpack_require__.o(exports, name)) { |
|
40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
|
41 /******/ } |
|
42 /******/ }; |
|
43 /******/ |
|
44 /******/ // define __esModule on exports |
|
45 /******/ __webpack_require__.r = function(exports) { |
|
46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
48 /******/ } |
|
49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
50 /******/ }; |
|
51 /******/ |
|
52 /******/ // create a fake namespace object |
|
53 /******/ // mode & 1: value is a module id, require it |
|
54 /******/ // mode & 2: merge all properties of value into the ns |
|
55 /******/ // mode & 4: return value when already ns object |
|
56 /******/ // mode & 8|1: behave like require |
|
57 /******/ __webpack_require__.t = function(value, mode) { |
|
58 /******/ if(mode & 1) value = __webpack_require__(value); |
|
59 /******/ if(mode & 8) return value; |
|
60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
61 /******/ var ns = Object.create(null); |
|
62 /******/ __webpack_require__.r(ns); |
|
63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
65 /******/ return ns; |
|
66 /******/ }; |
|
67 /******/ |
|
68 /******/ // getDefaultExport function for compatibility with non-harmony modules |
|
69 /******/ __webpack_require__.n = function(module) { |
|
70 /******/ var getter = module && module.__esModule ? |
|
71 /******/ function getDefault() { return module['default']; } : |
|
72 /******/ function getModuleExports() { return module; }; |
|
73 /******/ __webpack_require__.d(getter, 'a', getter); |
|
74 /******/ return getter; |
|
75 /******/ }; |
|
76 /******/ |
|
77 /******/ // Object.prototype.hasOwnProperty.call |
|
78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
79 /******/ |
|
80 /******/ // __webpack_public_path__ |
|
81 /******/ __webpack_require__.p = ""; |
|
82 /******/ |
|
83 /******/ |
|
84 /******/ // Load entry module and return exports |
|
85 /******/ return __webpack_require__(__webpack_require__.s = "yyEc"); |
|
86 /******/ }) |
|
87 /************************************************************************/ |
35 /************************************************************************/ |
88 /******/ ({ |
36 var __webpack_exports__ = {}; |
89 |
37 // ESM COMPAT FLAG |
90 /***/ "1ZqX": |
38 __webpack_require__.r(__webpack_exports__); |
91 /***/ (function(module, exports) { |
39 |
92 |
40 // EXPORTS |
93 (function() { module.exports = window["wp"]["data"]; }()); |
41 __webpack_require__.d(__webpack_exports__, { |
94 |
42 "__UNSTABLE_LINE_SEPARATOR": function() { return /* reexport */ LINE_SEPARATOR; }, |
95 /***/ }), |
43 "__experimentalRichText": function() { return /* reexport */ __experimentalRichText; }, |
96 |
44 "__unstableCanIndentListItems": function() { return /* reexport */ canIndentListItems; }, |
97 /***/ "GRId": |
45 "__unstableCanOutdentListItems": function() { return /* reexport */ canOutdentListItems; }, |
98 /***/ (function(module, exports) { |
46 "__unstableChangeListType": function() { return /* reexport */ changeListType; }, |
99 |
47 "__unstableCreateElement": function() { return /* reexport */ createElement; }, |
100 (function() { module.exports = window["wp"]["element"]; }()); |
48 "__unstableFormatEdit": function() { return /* reexport */ FormatEdit; }, |
101 |
49 "__unstableIndentListItems": function() { return /* reexport */ indentListItems; }, |
102 /***/ }), |
50 "__unstableInsertLineSeparator": function() { return /* reexport */ insertLineSeparator; }, |
103 |
51 "__unstableIsActiveListType": function() { return /* reexport */ isActiveListType; }, |
104 /***/ "K9lf": |
52 "__unstableIsEmptyLine": function() { return /* reexport */ isEmptyLine; }, |
105 /***/ (function(module, exports) { |
53 "__unstableIsListRootSelected": function() { return /* reexport */ isListRootSelected; }, |
106 |
54 "__unstableOutdentListItems": function() { return /* reexport */ outdentListItems; }, |
107 (function() { module.exports = window["wp"]["compose"]; }()); |
55 "__unstableRemoveLineSeparator": function() { return /* reexport */ removeLineSeparator; }, |
108 |
56 "__unstableToDom": function() { return /* reexport */ toDom; }, |
109 /***/ }), |
57 "__unstableUseRichText": function() { return /* reexport */ useRichText; }, |
110 |
58 "applyFormat": function() { return /* reexport */ applyFormat; }, |
111 /***/ "RxS6": |
59 "concat": function() { return /* reexport */ concat; }, |
112 /***/ (function(module, exports) { |
60 "create": function() { return /* reexport */ create; }, |
113 |
61 "getActiveFormat": function() { return /* reexport */ getActiveFormat; }, |
114 (function() { module.exports = window["wp"]["keycodes"]; }()); |
62 "getActiveObject": function() { return /* reexport */ getActiveObject; }, |
115 |
63 "getTextContent": function() { return /* reexport */ getTextContent; }, |
116 /***/ }), |
64 "insert": function() { return /* reexport */ insert; }, |
117 |
65 "insertObject": function() { return /* reexport */ insertObject; }, |
118 /***/ "Vx3V": |
66 "isCollapsed": function() { return /* reexport */ isCollapsed; }, |
119 /***/ (function(module, exports) { |
67 "isEmpty": function() { return /* reexport */ isEmpty; }, |
120 |
68 "join": function() { return /* reexport */ join; }, |
121 (function() { module.exports = window["wp"]["escapeHtml"]; }()); |
69 "registerFormatType": function() { return /* reexport */ registerFormatType; }, |
122 |
70 "remove": function() { return /* reexport */ remove; }, |
123 /***/ }), |
71 "removeFormat": function() { return /* reexport */ removeFormat; }, |
124 |
72 "replace": function() { return /* reexport */ replace_replace; }, |
125 /***/ "YLtl": |
73 "slice": function() { return /* reexport */ slice; }, |
126 /***/ (function(module, exports) { |
74 "split": function() { return /* reexport */ split; }, |
127 |
75 "store": function() { return /* reexport */ store; }, |
128 (function() { module.exports = window["lodash"]; }()); |
76 "toHTMLString": function() { return /* reexport */ toHTMLString; }, |
129 |
77 "toggleFormat": function() { return /* reexport */ toggleFormat; }, |
130 /***/ }), |
78 "unregisterFormatType": function() { return /* reexport */ unregisterFormatType; }, |
131 |
79 "useAnchorRef": function() { return /* reexport */ useAnchorRef; } |
132 /***/ "pPDe": |
80 }); |
133 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
81 |
134 |
82 // NAMESPACE OBJECT: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js |
135 "use strict"; |
83 var selectors_namespaceObject = {}; |
84 __webpack_require__.r(selectors_namespaceObject); |
|
85 __webpack_require__.d(selectors_namespaceObject, { |
|
86 "getFormatType": function() { return getFormatType; }, |
|
87 "getFormatTypeForBareElement": function() { return getFormatTypeForBareElement; }, |
|
88 "getFormatTypeForClassName": function() { return getFormatTypeForClassName; }, |
|
89 "getFormatTypes": function() { return getFormatTypes; } |
|
90 }); |
|
91 |
|
92 // NAMESPACE OBJECT: ./node_modules/@wordpress/rich-text/build-module/store/actions.js |
|
93 var actions_namespaceObject = {}; |
|
94 __webpack_require__.r(actions_namespaceObject); |
|
95 __webpack_require__.d(actions_namespaceObject, { |
|
96 "addFormatTypes": function() { return addFormatTypes; }, |
|
97 "removeFormatTypes": function() { return removeFormatTypes; } |
|
98 }); |
|
99 |
|
100 ;// CONCATENATED MODULE: external ["wp","data"] |
|
101 var external_wp_data_namespaceObject = window["wp"]["data"]; |
|
102 ;// CONCATENATED MODULE: external "lodash" |
|
103 var external_lodash_namespaceObject = window["lodash"]; |
|
104 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/reducer.js |
|
105 /** |
|
106 * External dependencies |
|
107 */ |
|
108 |
|
109 /** |
|
110 * WordPress dependencies |
|
111 */ |
|
112 |
|
113 |
|
114 /** |
|
115 * Reducer managing the format types |
|
116 * |
|
117 * @param {Object} state Current state. |
|
118 * @param {Object} action Dispatched action. |
|
119 * |
|
120 * @return {Object} Updated state. |
|
121 */ |
|
122 |
|
123 function formatTypes() { |
|
124 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
125 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
126 |
|
127 switch (action.type) { |
|
128 case 'ADD_FORMAT_TYPES': |
|
129 return { ...state, |
|
130 ...(0,external_lodash_namespaceObject.keyBy)(action.formatTypes, 'name') |
|
131 }; |
|
132 |
|
133 case 'REMOVE_FORMAT_TYPES': |
|
134 return (0,external_lodash_namespaceObject.omit)(state, action.names); |
|
135 } |
|
136 |
|
137 return state; |
|
138 } |
|
139 /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ |
|
140 formatTypes |
|
141 })); |
|
142 |
|
143 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js |
|
136 |
144 |
137 |
145 |
138 var LEAF_KEY, hasWeakMap; |
146 var LEAF_KEY, hasWeakMap; |
139 |
147 |
140 /** |
148 /** |
228 * reference or array of reference used in |
236 * reference or array of reference used in |
229 * cache bust consideration. |
237 * cache bust consideration. |
230 * |
238 * |
231 * @return {Function} Memoized selector. |
239 * @return {Function} Memoized selector. |
232 */ |
240 */ |
233 /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) { |
241 /* harmony default export */ function rememo(selector, getDependants ) { |
234 var rootCache, getCache; |
242 var rootCache, getCache; |
235 |
243 |
236 // Use object source as dependant if getter not provided |
244 // Use object source as dependant if getter not provided |
237 if ( ! getDependants ) { |
245 if ( ! getDependants ) { |
238 getDependants = arrayOf; |
246 getDependants = arrayOf; |
404 callSelector.getDependants = getDependants; |
412 callSelector.getDependants = getDependants; |
405 callSelector.clear = clear; |
413 callSelector.clear = clear; |
406 clear(); |
414 clear(); |
407 |
415 |
408 return callSelector; |
416 return callSelector; |
409 }); |
417 } |
410 |
418 |
411 |
419 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js |
412 /***/ }), |
|
413 |
|
414 /***/ "yyEc": |
|
415 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
416 |
|
417 "use strict"; |
|
418 // ESM COMPAT FLAG |
|
419 __webpack_require__.r(__webpack_exports__); |
|
420 |
|
421 // EXPORTS |
|
422 __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; }); |
|
423 __webpack_require__.d(__webpack_exports__, "applyFormat", function() { return /* reexport */ applyFormat; }); |
|
424 __webpack_require__.d(__webpack_exports__, "concat", function() { return /* reexport */ concat; }); |
|
425 __webpack_require__.d(__webpack_exports__, "create", function() { return /* reexport */ create; }); |
|
426 __webpack_require__.d(__webpack_exports__, "getActiveFormat", function() { return /* reexport */ getActiveFormat; }); |
|
427 __webpack_require__.d(__webpack_exports__, "getActiveObject", function() { return /* reexport */ getActiveObject; }); |
|
428 __webpack_require__.d(__webpack_exports__, "getTextContent", function() { return /* reexport */ getTextContent; }); |
|
429 __webpack_require__.d(__webpack_exports__, "__unstableIsListRootSelected", function() { return /* reexport */ isListRootSelected; }); |
|
430 __webpack_require__.d(__webpack_exports__, "__unstableIsActiveListType", function() { return /* reexport */ isActiveListType; }); |
|
431 __webpack_require__.d(__webpack_exports__, "isCollapsed", function() { return /* reexport */ isCollapsed; }); |
|
432 __webpack_require__.d(__webpack_exports__, "isEmpty", function() { return /* reexport */ isEmpty; }); |
|
433 __webpack_require__.d(__webpack_exports__, "__unstableIsEmptyLine", function() { return /* reexport */ isEmptyLine; }); |
|
434 __webpack_require__.d(__webpack_exports__, "join", function() { return /* reexport */ join; }); |
|
435 __webpack_require__.d(__webpack_exports__, "registerFormatType", function() { return /* reexport */ registerFormatType; }); |
|
436 __webpack_require__.d(__webpack_exports__, "removeFormat", function() { return /* reexport */ removeFormat; }); |
|
437 __webpack_require__.d(__webpack_exports__, "remove", function() { return /* reexport */ remove_remove; }); |
|
438 __webpack_require__.d(__webpack_exports__, "replace", function() { return /* reexport */ replace_replace; }); |
|
439 __webpack_require__.d(__webpack_exports__, "insert", function() { return /* reexport */ insert; }); |
|
440 __webpack_require__.d(__webpack_exports__, "__unstableInsertLineSeparator", function() { return /* reexport */ insertLineSeparator; }); |
|
441 __webpack_require__.d(__webpack_exports__, "__unstableRemoveLineSeparator", function() { return /* reexport */ removeLineSeparator; }); |
|
442 __webpack_require__.d(__webpack_exports__, "insertObject", function() { return /* reexport */ insertObject; }); |
|
443 __webpack_require__.d(__webpack_exports__, "slice", function() { return /* reexport */ slice; }); |
|
444 __webpack_require__.d(__webpack_exports__, "split", function() { return /* reexport */ split; }); |
|
445 __webpack_require__.d(__webpack_exports__, "__unstableToDom", function() { return /* reexport */ toDom; }); |
|
446 __webpack_require__.d(__webpack_exports__, "toHTMLString", function() { return /* reexport */ toHTMLString; }); |
|
447 __webpack_require__.d(__webpack_exports__, "toggleFormat", function() { return /* reexport */ toggleFormat; }); |
|
448 __webpack_require__.d(__webpack_exports__, "__UNSTABLE_LINE_SEPARATOR", function() { return /* reexport */ LINE_SEPARATOR; }); |
|
449 __webpack_require__.d(__webpack_exports__, "unregisterFormatType", function() { return /* reexport */ unregisterFormatType; }); |
|
450 __webpack_require__.d(__webpack_exports__, "__unstableCanIndentListItems", function() { return /* reexport */ canIndentListItems; }); |
|
451 __webpack_require__.d(__webpack_exports__, "__unstableCanOutdentListItems", function() { return /* reexport */ canOutdentListItems; }); |
|
452 __webpack_require__.d(__webpack_exports__, "__unstableIndentListItems", function() { return /* reexport */ indentListItems; }); |
|
453 __webpack_require__.d(__webpack_exports__, "__unstableOutdentListItems", function() { return /* reexport */ outdentListItems; }); |
|
454 __webpack_require__.d(__webpack_exports__, "__unstableChangeListType", function() { return /* reexport */ changeListType; }); |
|
455 __webpack_require__.d(__webpack_exports__, "__unstableCreateElement", function() { return /* reexport */ createElement; }); |
|
456 __webpack_require__.d(__webpack_exports__, "useAnchorRef", function() { return /* reexport */ useAnchorRef; }); |
|
457 __webpack_require__.d(__webpack_exports__, "__experimentalRichText", function() { return /* reexport */ __experimentalRichText; }); |
|
458 __webpack_require__.d(__webpack_exports__, "__unstableUseRichText", function() { return /* reexport */ useRichText; }); |
|
459 __webpack_require__.d(__webpack_exports__, "__unstableFormatEdit", function() { return /* reexport */ FormatEdit; }); |
|
460 |
|
461 // NAMESPACE OBJECT: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js |
|
462 var selectors_namespaceObject = {}; |
|
463 __webpack_require__.r(selectors_namespaceObject); |
|
464 __webpack_require__.d(selectors_namespaceObject, "getFormatTypes", function() { return getFormatTypes; }); |
|
465 __webpack_require__.d(selectors_namespaceObject, "getFormatType", function() { return getFormatType; }); |
|
466 __webpack_require__.d(selectors_namespaceObject, "getFormatTypeForBareElement", function() { return getFormatTypeForBareElement; }); |
|
467 __webpack_require__.d(selectors_namespaceObject, "getFormatTypeForClassName", function() { return getFormatTypeForClassName; }); |
|
468 |
|
469 // NAMESPACE OBJECT: ./node_modules/@wordpress/rich-text/build-module/store/actions.js |
|
470 var actions_namespaceObject = {}; |
|
471 __webpack_require__.r(actions_namespaceObject); |
|
472 __webpack_require__.d(actions_namespaceObject, "addFormatTypes", function() { return addFormatTypes; }); |
|
473 __webpack_require__.d(actions_namespaceObject, "removeFormatTypes", function() { return removeFormatTypes; }); |
|
474 |
|
475 // EXTERNAL MODULE: external ["wp","data"] |
|
476 var external_wp_data_ = __webpack_require__("1ZqX"); |
|
477 |
|
478 // EXTERNAL MODULE: external "lodash" |
|
479 var external_lodash_ = __webpack_require__("YLtl"); |
|
480 |
|
481 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/reducer.js |
|
482 /** |
420 /** |
483 * External dependencies |
421 * External dependencies |
484 */ |
422 */ |
485 |
423 |
486 /** |
|
487 * WordPress dependencies |
|
488 */ |
|
489 |
|
490 |
|
491 /** |
|
492 * Reducer managing the format types |
|
493 * |
|
494 * @param {Object} state Current state. |
|
495 * @param {Object} action Dispatched action. |
|
496 * |
|
497 * @return {Object} Updated state. |
|
498 */ |
|
499 |
|
500 function reducer_formatTypes(state = {}, action) { |
|
501 switch (action.type) { |
|
502 case 'ADD_FORMAT_TYPES': |
|
503 return { ...state, |
|
504 ...Object(external_lodash_["keyBy"])(action.formatTypes, 'name') |
|
505 }; |
|
506 |
|
507 case 'REMOVE_FORMAT_TYPES': |
|
508 return Object(external_lodash_["omit"])(state, action.names); |
|
509 } |
|
510 |
|
511 return state; |
|
512 } |
|
513 /* harmony default export */ var reducer = (Object(external_wp_data_["combineReducers"])({ |
|
514 formatTypes: reducer_formatTypes |
|
515 })); |
|
516 |
|
517 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
|
518 var rememo = __webpack_require__("pPDe"); |
|
519 |
|
520 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js |
|
521 /** |
|
522 * External dependencies |
|
523 */ |
|
524 |
|
525 |
424 |
526 /** |
425 /** |
527 * Returns all the available format types. |
426 * Returns all the available format types. |
528 * |
427 * |
529 * @param {Object} state Data state. |
428 * @param {Object} state Data state. |
530 * |
429 * |
531 * @return {Array} Format types. |
430 * @return {Array} Format types. |
532 */ |
431 */ |
533 |
432 |
534 const getFormatTypes = Object(rememo["a" /* default */])(state => Object.values(state.formatTypes), state => [state.formatTypes]); |
433 const getFormatTypes = rememo(state => Object.values(state.formatTypes), state => [state.formatTypes]); |
535 /** |
434 /** |
536 * Returns a format type by name. |
435 * Returns a format type by name. |
537 * |
436 * |
538 * @param {Object} state Data state. |
437 * @param {Object} state Data state. |
539 * @param {string} name Format type name. |
438 * @param {string} name Format type name. |
540 * |
439 * |
541 * @return {Object?} Format type. |
440 * @return {Object?} Format type. |
542 */ |
441 */ |
543 |
442 |
544 function getFormatType(state, name) { |
443 function getFormatType(state, name) { |
553 * format type for. |
452 * format type for. |
554 * @return {?Object} Format type. |
453 * @return {?Object} Format type. |
555 */ |
454 */ |
556 |
455 |
557 function getFormatTypeForBareElement(state, bareElementTagName) { |
456 function getFormatTypeForBareElement(state, bareElementTagName) { |
558 return Object(external_lodash_["find"])(getFormatTypes(state), ({ |
457 return (0,external_lodash_namespaceObject.find)(getFormatTypes(state), _ref => { |
559 className, |
458 let { |
560 tagName |
459 className, |
561 }) => { |
460 tagName |
461 } = _ref; |
|
562 return className === null && bareElementTagName === tagName; |
462 return className === null && bareElementTagName === tagName; |
563 }); |
463 }); |
564 } |
464 } |
565 /** |
465 /** |
566 * Gets the format type, if any, that can handle an element, given its classes. |
466 * Gets the format type, if any, that can handle an element, given its classes. |
570 * type for. |
470 * type for. |
571 * @return {?Object} Format type. |
471 * @return {?Object} Format type. |
572 */ |
472 */ |
573 |
473 |
574 function getFormatTypeForClassName(state, elementClassName) { |
474 function getFormatTypeForClassName(state, elementClassName) { |
575 return Object(external_lodash_["find"])(getFormatTypes(state), ({ |
475 return (0,external_lodash_namespaceObject.find)(getFormatTypes(state), _ref2 => { |
576 className |
476 let { |
577 }) => { |
477 className |
478 } = _ref2; |
|
479 |
|
578 if (className === null) { |
480 if (className === null) { |
579 return false; |
481 return false; |
580 } |
482 } |
581 |
483 |
582 return ` ${elementClassName} `.indexOf(` ${className} `) >= 0; |
484 return ` ${elementClassName} `.indexOf(` ${className} `) >= 0; |
583 }); |
485 }); |
584 } |
486 } |
585 |
487 |
586 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/actions.js |
488 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/actions.js |
587 /** |
489 /** |
588 * External dependencies |
490 * External dependencies |
589 */ |
491 */ |
590 |
492 |
591 /** |
493 /** |
598 */ |
500 */ |
599 |
501 |
600 function addFormatTypes(formatTypes) { |
502 function addFormatTypes(formatTypes) { |
601 return { |
503 return { |
602 type: 'ADD_FORMAT_TYPES', |
504 type: 'ADD_FORMAT_TYPES', |
603 formatTypes: Object(external_lodash_["castArray"])(formatTypes) |
505 formatTypes: (0,external_lodash_namespaceObject.castArray)(formatTypes) |
604 }; |
506 }; |
605 } |
507 } |
606 /** |
508 /** |
607 * Returns an action object used to remove a registered format type. |
509 * Returns an action object used to remove a registered format type. |
608 * |
510 * |
612 */ |
514 */ |
613 |
515 |
614 function removeFormatTypes(names) { |
516 function removeFormatTypes(names) { |
615 return { |
517 return { |
616 type: 'REMOVE_FORMAT_TYPES', |
518 type: 'REMOVE_FORMAT_TYPES', |
617 names: Object(external_lodash_["castArray"])(names) |
519 names: (0,external_lodash_namespaceObject.castArray)(names) |
618 }; |
520 }; |
619 } |
521 } |
620 |
522 |
621 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/index.js |
523 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/index.js |
622 /** |
524 /** |
623 * WordPress dependencies |
525 * WordPress dependencies |
624 */ |
526 */ |
625 |
527 |
626 /** |
528 /** |
637 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
539 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
638 * |
540 * |
639 * @type {Object} |
541 * @type {Object} |
640 */ |
542 */ |
641 |
543 |
642 const store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, { |
544 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { |
643 reducer: reducer, |
545 reducer: reducer, |
644 selectors: selectors_namespaceObject, |
546 selectors: selectors_namespaceObject, |
645 actions: actions_namespaceObject |
547 actions: actions_namespaceObject |
646 }); |
548 }); |
647 Object(external_wp_data_["register"])(store); |
549 (0,external_wp_data_namespaceObject.register)(store); |
648 |
550 |
649 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-format-equal.js |
551 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-format-equal.js |
650 /** @typedef {import('./create').RichTextFormat} RichTextFormat */ |
552 /** @typedef {import('./create').RichTextFormat} RichTextFormat */ |
651 |
553 |
652 /** |
554 /** |
653 * Optimised equality check for format objects. |
555 * Optimised equality check for format objects. |
654 * |
556 * |
702 } |
604 } |
703 |
605 |
704 return true; |
606 return true; |
705 } |
607 } |
706 |
608 |
707 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/normalise-formats.js |
609 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/normalise-formats.js |
708 /** |
610 /** |
709 * Internal dependencies |
611 * Internal dependencies |
710 */ |
612 */ |
711 |
613 |
712 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
614 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
740 return { ...value, |
642 return { ...value, |
741 formats: newFormats |
643 formats: newFormats |
742 }; |
644 }; |
743 } |
645 } |
744 |
646 |
745 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/apply-format.js |
647 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/apply-format.js |
746 /** |
648 /** |
747 * External dependencies |
649 * External dependencies |
748 */ |
650 */ |
749 |
651 |
750 /** |
652 /** |
773 * |
675 * |
774 * @return {RichTextValue} A new value with the format applied. |
676 * @return {RichTextValue} A new value with the format applied. |
775 */ |
677 */ |
776 |
678 |
777 |
679 |
778 function applyFormat(value, format, startIndex = value.start, endIndex = value.end) { |
680 function applyFormat(value, format) { |
681 let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.start; |
|
682 let endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : value.end; |
|
779 const { |
683 const { |
780 formats, |
684 formats, |
781 activeFormats |
685 activeFormats |
782 } = value; |
686 } = value; |
783 const newFormats = formats.slice(); // The selection is collapsed. |
687 const newFormats = formats.slice(); // The selection is collapsed. |
784 |
688 |
785 if (startIndex === endIndex) { |
689 if (startIndex === endIndex) { |
786 const startFormat = Object(external_lodash_["find"])(newFormats[startIndex], { |
690 const startFormat = (0,external_lodash_namespaceObject.find)(newFormats[startIndex], { |
787 type: format.type |
691 type: format.type |
788 }); // If the caret is at a format of the same type, expand start and end to |
692 }); // If the caret is at a format of the same type, expand start and end to |
789 // the edges of the format. This is useful to apply new attributes. |
693 // the edges of the format. This is useful to apply new attributes. |
790 |
694 |
791 if (startFormat) { |
695 if (startFormat) { |
807 // Determine the highest position the new format can be inserted at. |
711 // Determine the highest position the new format can be inserted at. |
808 let position = +Infinity; |
712 let position = +Infinity; |
809 |
713 |
810 for (let index = startIndex; index < endIndex; index++) { |
714 for (let index = startIndex; index < endIndex; index++) { |
811 if (newFormats[index]) { |
715 if (newFormats[index]) { |
812 newFormats[index] = newFormats[index].filter(({ |
716 newFormats[index] = newFormats[index].filter(_ref => { |
813 type |
717 let { |
814 }) => type !== format.type); |
718 type |
719 } = _ref; |
|
720 return type !== format.type; |
|
721 }); |
|
815 const length = newFormats[index].length; |
722 const length = newFormats[index].length; |
816 |
723 |
817 if (length < position) { |
724 if (length < position) { |
818 position = length; |
725 position = length; |
819 } |
726 } |
831 return normaliseFormats({ ...value, |
738 return normaliseFormats({ ...value, |
832 formats: newFormats, |
739 formats: newFormats, |
833 // Always revise active formats. This serves as a placeholder for new |
740 // Always revise active formats. This serves as a placeholder for new |
834 // inputs with the format so new input appears with the format applied, |
741 // inputs with the format so new input appears with the format applied, |
835 // and ensures a format of the same type uses the latest values. |
742 // and ensures a format of the same type uses the latest values. |
836 activeFormats: [...Object(external_lodash_["reject"])(activeFormats, { |
743 activeFormats: [...(0,external_lodash_namespaceObject.reject)(activeFormats, { |
837 type: format.type |
744 type: format.type |
838 }), format] |
745 }), format] |
839 }); |
746 }); |
840 } |
747 } |
841 |
748 |
842 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create-element.js |
749 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create-element.js |
843 /** |
750 /** |
844 * Parse the given HTML into a body element. |
751 * Parse the given HTML into a body element. |
845 * |
752 * |
846 * Note: The current implementation will return a shared reference, reset on |
753 * Note: The current implementation will return a shared reference, reset on |
847 * each call to `createElement`. Therefore, you should not hold a reference to |
754 * each call to `createElement`. Therefore, you should not hold a reference to |
850 * @param {HTMLDocument} document The HTML document to use to parse. |
757 * @param {HTMLDocument} document The HTML document to use to parse. |
851 * @param {string} html The HTML to parse. |
758 * @param {string} html The HTML to parse. |
852 * |
759 * |
853 * @return {HTMLBodyElement} Body element with parsed HTML. |
760 * @return {HTMLBodyElement} Body element with parsed HTML. |
854 */ |
761 */ |
855 function createElement({ |
762 function createElement(_ref, html) { |
856 implementation |
763 let { |
857 }, html) { |
764 implementation |
765 } = _ref; |
|
766 |
|
858 // Because `createHTMLDocument` is an expensive operation, and with this |
767 // Because `createHTMLDocument` is an expensive operation, and with this |
859 // function being internal to `rich-text` (full control in avoiding a risk |
768 // function being internal to `rich-text` (full control in avoiding a risk |
860 // of asynchronous operations on the shared reference), a single document |
769 // of asynchronous operations on the shared reference), a single document |
861 // is reused and reset for each call to the function. |
770 // is reused and reset for each call to the function. |
862 if (!createElement.body) { |
771 if (!createElement.body) { |
865 |
774 |
866 createElement.body.innerHTML = html; |
775 createElement.body.innerHTML = html; |
867 return createElement.body; |
776 return createElement.body; |
868 } |
777 } |
869 |
778 |
870 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/special-characters.js |
779 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/special-characters.js |
871 /** |
780 /** |
872 * Line separator character, used for multiline text. |
781 * Line separator character, used for multiline text. |
873 */ |
782 */ |
874 const LINE_SEPARATOR = '\u2028'; |
783 const LINE_SEPARATOR = '\u2028'; |
875 /** |
784 /** |
882 * it is empty otherwise. |
791 * it is empty otherwise. |
883 */ |
792 */ |
884 |
793 |
885 const ZWNBSP = '\ufeff'; |
794 const ZWNBSP = '\ufeff'; |
886 |
795 |
887 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create.js |
796 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create.js |
888 /** |
797 /** |
889 * WordPress dependencies |
798 * WordPress dependencies |
890 */ |
799 */ |
891 |
800 |
892 /** |
801 /** |
923 replacements: [], |
832 replacements: [], |
924 text: '' |
833 text: '' |
925 }; |
834 }; |
926 } |
835 } |
927 |
836 |
928 function simpleFindKey(object, value) { |
837 function toFormat(_ref) { |
929 for (const key in object) { |
838 let { |
930 if (object[key] === value) { |
839 type, |
931 return key; |
840 attributes |
932 } |
841 } = _ref; |
933 } |
|
934 } |
|
935 |
|
936 function toFormat({ |
|
937 type, |
|
938 attributes |
|
939 }) { |
|
940 let formatType; |
842 let formatType; |
941 |
843 |
942 if (attributes && attributes.class) { |
844 if (attributes && attributes.class) { |
943 formatType = Object(external_wp_data_["select"])('core/rich-text').getFormatTypeForClassName(attributes.class); |
845 formatType = (0,external_wp_data_namespaceObject.select)(store).getFormatTypeForClassName(attributes.class); |
944 |
846 |
945 if (formatType) { |
847 if (formatType) { |
946 // Preserve any additional classes. |
848 // Preserve any additional classes. |
947 attributes.class = ` ${attributes.class} `.replace(` ${formatType.className} `, ' ').trim(); |
849 attributes.class = ` ${attributes.class} `.replace(` ${formatType.className} `, ' ').trim(); |
948 |
850 |
951 } |
853 } |
952 } |
854 } |
953 } |
855 } |
954 |
856 |
955 if (!formatType) { |
857 if (!formatType) { |
956 formatType = Object(external_wp_data_["select"])('core/rich-text').getFormatTypeForBareElement(type); |
858 formatType = (0,external_wp_data_namespaceObject.select)(store).getFormatTypeForBareElement(type); |
957 } |
859 } |
958 |
860 |
959 if (!formatType) { |
861 if (!formatType) { |
960 return attributes ? { |
862 return attributes ? { |
961 type, |
863 type, |
975 }; |
877 }; |
976 } |
878 } |
977 |
879 |
978 const registeredAttributes = {}; |
880 const registeredAttributes = {}; |
979 const unregisteredAttributes = {}; |
881 const unregisteredAttributes = {}; |
980 |
882 const _attributes = { ...attributes |
981 for (const name in attributes) { |
883 }; |
982 const key = simpleFindKey(formatType.attributes, name); |
884 |
983 |
885 for (const key in formatType.attributes) { |
984 if (key) { |
886 const name = formatType.attributes[key]; |
985 registeredAttributes[key] = attributes[name]; |
887 registeredAttributes[key] = _attributes[name]; |
986 } else { |
888 |
987 unregisteredAttributes[name] = attributes[name]; |
889 if (formatType.__unstableFilterAttributeValue) { |
988 } |
890 registeredAttributes[key] = formatType.__unstableFilterAttributeValue(key, registeredAttributes[key]); |
891 } // delete the attribute and what's left is considered |
|
892 // to be unregistered. |
|
893 |
|
894 |
|
895 delete _attributes[name]; |
|
896 |
|
897 if (typeof registeredAttributes[key] === 'undefined') { |
|
898 delete registeredAttributes[key]; |
|
899 } |
|
900 } |
|
901 |
|
902 for (const name in _attributes) { |
|
903 unregisteredAttributes[name] = attributes[name]; |
|
989 } |
904 } |
990 |
905 |
991 return { |
906 return { |
992 type: formatType.name, |
907 type: formatType.name, |
993 attributes: registeredAttributes, |
908 attributes: registeredAttributes, |
1020 * `objects` and `lines` are all sparse arrays of the same length as `text`. It |
935 * `objects` and `lines` are all sparse arrays of the same length as `text`. It |
1021 * holds information about the formatting at the relevant text indices. Finally |
936 * holds information about the formatting at the relevant text indices. Finally |
1022 * `start` and `end` state which text indices are selected. They are only |
937 * `start` and `end` state which text indices are selected. They are only |
1023 * provided if a `Range` was given. |
938 * provided if a `Range` was given. |
1024 * |
939 * |
1025 * @param {Object} [$1] Optional named arguments. |
940 * @param {Object} [$1] Optional named arguments. |
1026 * @param {Element} [$1.element] Element to create value from. |
941 * @param {Element} [$1.element] Element to create value from. |
1027 * @param {string} [$1.text] Text to create value from. |
942 * @param {string} [$1.text] Text to create value from. |
1028 * @param {string} [$1.html] HTML to create value from. |
943 * @param {string} [$1.html] HTML to create value from. |
1029 * @param {Range} [$1.range] Range to create value from. |
944 * @param {Range} [$1.range] Range to create value from. |
1030 * @param {string} [$1.multilineTag] Multiline tag if the structure is |
945 * @param {string} [$1.multilineTag] Multiline tag if the structure is |
1031 * multiline. |
946 * multiline. |
1032 * @param {Array} [$1.multilineWrapperTags] Tags where lines can be found if |
947 * @param {Array} [$1.multilineWrapperTags] Tags where lines can be found if |
1033 * nesting is possible. |
948 * nesting is possible. |
1034 * @param {boolean} [$1.preserveWhiteSpace] Whether or not to collapse white |
949 * @param {boolean} [$1.preserveWhiteSpace] Whether or not to collapse white |
1035 * space characters. |
950 * space characters. |
1036 * @param {boolean} [$1.__unstableIsEditableTree] |
951 * @param {boolean} [$1.__unstableIsEditableTree] |
1037 * |
952 * |
1038 * @return {RichTextValue} A rich text value. |
953 * @return {RichTextValue} A rich text value. |
1039 */ |
954 */ |
1040 |
955 |
1041 |
956 |
1042 function create({ |
957 function create() { |
1043 element, |
958 let { |
1044 text, |
959 element, |
1045 html, |
960 text, |
1046 range, |
961 html, |
1047 multilineTag, |
962 range, |
1048 multilineWrapperTags, |
963 multilineTag, |
1049 __unstableIsEditableTree: isEditableTree, |
964 multilineWrapperTags, |
1050 preserveWhiteSpace |
965 __unstableIsEditableTree: isEditableTree, |
1051 } = {}) { |
966 preserveWhiteSpace |
967 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
968 |
|
1052 if (typeof text === 'string' && text.length > 0) { |
969 if (typeof text === 'string' && text.length > 0) { |
1053 return { |
970 return { |
1054 formats: Array(text.length), |
971 formats: Array(text.length), |
1055 replacements: Array(text.length), |
972 replacements: Array(text.length), |
1056 text |
973 text |
1185 |
1102 |
1186 |
1103 |
1187 function collapseWhiteSpace(string) { |
1104 function collapseWhiteSpace(string) { |
1188 return string.replace(/[\n\r\t]+/g, ' '); |
1105 return string.replace(/[\n\r\t]+/g, ' '); |
1189 } |
1106 } |
1190 |
1107 /** |
1191 const ZWNBSPRegExp = new RegExp(ZWNBSP, 'g'); |
1108 * Removes reserved characters used by rich-text (zero width non breaking spaces added by `toTree` and object replacement characters). |
1192 /** |
|
1193 * Removes padding (zero width non breaking spaces) added by `toTree`. |
|
1194 * |
1109 * |
1195 * @param {string} string |
1110 * @param {string} string |
1196 */ |
1111 */ |
1197 |
1112 |
1198 function removePadding(string) { |
1113 |
1199 return string.replace(ZWNBSPRegExp, ''); |
1114 function removeReservedCharacters(string) { |
1115 // with the global flag, note that we should create a new regex each time OR reset lastIndex state. |
|
1116 return string.replace(new RegExp(`[${ZWNBSP}${OBJECT_REPLACEMENT_CHARACTER}]`, 'gu'), ''); |
|
1200 } |
1117 } |
1201 /** |
1118 /** |
1202 * Creates a Rich Text value from a DOM element and range. |
1119 * Creates a Rich Text value from a DOM element and range. |
1203 * |
1120 * |
1204 * @param {Object} $1 Named argements. |
1121 * @param {Object} $1 Named argements. |
1214 * @param {boolean} [$1.isEditableTree] |
1131 * @param {boolean} [$1.isEditableTree] |
1215 * |
1132 * |
1216 * @return {RichTextValue} A rich text value. |
1133 * @return {RichTextValue} A rich text value. |
1217 */ |
1134 */ |
1218 |
1135 |
1219 |
1136 function createFromElement(_ref2) { |
1220 function createFromElement({ |
1137 let { |
1221 element, |
1138 element, |
1222 range, |
1139 range, |
1223 multilineTag, |
1140 multilineTag, |
1224 multilineWrapperTags, |
1141 multilineWrapperTags, |
1225 currentWrapperTags = [], |
1142 currentWrapperTags = [], |
1226 isEditableTree, |
1143 isEditableTree, |
1227 preserveWhiteSpace |
1144 preserveWhiteSpace |
1228 }) { |
1145 } = _ref2; |
1229 const accumulator = createEmptyValue(); |
1146 const accumulator = createEmptyValue(); |
1230 |
1147 |
1231 if (!element) { |
1148 if (!element) { |
1232 return accumulator; |
1149 return accumulator; |
1233 } |
1150 } |
1242 for (let index = 0; index < length; index++) { |
1159 for (let index = 0; index < length; index++) { |
1243 const node = element.childNodes[index]; |
1160 const node = element.childNodes[index]; |
1244 const type = node.nodeName.toLowerCase(); |
1161 const type = node.nodeName.toLowerCase(); |
1245 |
1162 |
1246 if (node.nodeType === node.TEXT_NODE) { |
1163 if (node.nodeType === node.TEXT_NODE) { |
1247 let filter = removePadding; |
1164 let filter = removeReservedCharacters; |
1248 |
1165 |
1249 if (!preserveWhiteSpace) { |
1166 if (!preserveWhiteSpace) { |
1250 filter = string => removePadding(collapseWhiteSpace(string)); |
1167 filter = string => removeReservedCharacters(collapseWhiteSpace(string)); |
1251 } |
1168 } |
1252 |
1169 |
1253 const text = filter(node.nodeValue); |
1170 const text = filter(node.nodeValue); |
1254 range = filterRange(node, range, filter); |
1171 range = filterRange(node, range, filter); |
1255 accumulateSelection(accumulator, node, range, { |
1172 accumulateSelection(accumulator, node, range, { |
1296 text: '\n' |
1213 text: '\n' |
1297 })); |
1214 })); |
1298 continue; |
1215 continue; |
1299 } |
1216 } |
1300 |
1217 |
1301 const lastFormats = accumulator.formats[accumulator.formats.length - 1]; |
1218 const format = toFormat({ |
1302 const lastFormat = lastFormats && lastFormats[lastFormats.length - 1]; |
|
1303 const newFormat = toFormat({ |
|
1304 type, |
1219 type, |
1305 attributes: getAttributes({ |
1220 attributes: getAttributes({ |
1306 element: node |
1221 element: node |
1307 }) |
1222 }) |
1308 }); |
1223 }); |
1309 const format = isFormatEqual(newFormat, lastFormat) ? lastFormat : newFormat; |
|
1310 |
1224 |
1311 if (multilineWrapperTags && multilineWrapperTags.indexOf(type) !== -1) { |
1225 if (multilineWrapperTags && multilineWrapperTags.indexOf(type) !== -1) { |
1312 const value = createFromMultilineElement({ |
1226 const value = createFromMultilineElement({ |
1313 element: node, |
1227 element: node, |
1314 range, |
1228 range, |
1377 * @param {Range} [$1.range] Range to create value from. |
1291 * @param {Range} [$1.range] Range to create value from. |
1378 * @param {string} [$1.multilineTag] Multiline tag if the structure is |
1292 * @param {string} [$1.multilineTag] Multiline tag if the structure is |
1379 * multiline. |
1293 * multiline. |
1380 * @param {Array} [$1.multilineWrapperTags] Tags where lines can be found if |
1294 * @param {Array} [$1.multilineWrapperTags] Tags where lines can be found if |
1381 * nesting is possible. |
1295 * nesting is possible. |
1382 * @param {boolean} [$1.currentWrapperTags] Whether to prepend a line |
1296 * @param {Array} [$1.currentWrapperTags] Whether to prepend a line |
1383 * separator. |
1297 * separator. |
1384 * @param {boolean} [$1.preserveWhiteSpace] Whether or not to collapse white |
1298 * @param {boolean} [$1.preserveWhiteSpace] Whether or not to collapse white |
1385 * space characters. |
1299 * space characters. |
1386 * @param {boolean} [$1.isEditableTree] |
1300 * @param {boolean} [$1.isEditableTree] |
1387 * |
1301 * |
1388 * @return {RichTextValue} A rich text value. |
1302 * @return {RichTextValue} A rich text value. |
1389 */ |
1303 */ |
1390 |
1304 |
1391 |
1305 |
1392 function createFromMultilineElement({ |
1306 function createFromMultilineElement(_ref3) { |
1393 element, |
1307 let { |
1394 range, |
1308 element, |
1395 multilineTag, |
1309 range, |
1396 multilineWrapperTags, |
1310 multilineTag, |
1397 currentWrapperTags = [], |
1311 multilineWrapperTags, |
1398 isEditableTree, |
1312 currentWrapperTags = [], |
1399 preserveWhiteSpace |
1313 isEditableTree, |
1400 }) { |
1314 preserveWhiteSpace |
1315 } = _ref3; |
|
1401 const accumulator = createEmptyValue(); |
1316 const accumulator = createEmptyValue(); |
1402 |
1317 |
1403 if (!element || !element.hasChildNodes()) { |
1318 if (!element || !element.hasChildNodes()) { |
1404 return accumulator; |
1319 return accumulator; |
1405 } |
1320 } |
1446 * @return {Object|void} Attribute object or `undefined` if the element has no |
1361 * @return {Object|void} Attribute object or `undefined` if the element has no |
1447 * attributes. |
1362 * attributes. |
1448 */ |
1363 */ |
1449 |
1364 |
1450 |
1365 |
1451 function getAttributes({ |
1366 function getAttributes(_ref4) { |
1452 element |
1367 let { |
1453 }) { |
1368 element |
1369 } = _ref4; |
|
1370 |
|
1454 if (!element.hasAttributes()) { |
1371 if (!element.hasAttributes()) { |
1455 return; |
1372 return; |
1456 } |
1373 } |
1457 |
1374 |
1458 const length = element.attributes.length; |
1375 const length = element.attributes.length; |
1474 } |
1391 } |
1475 |
1392 |
1476 return accumulator; |
1393 return accumulator; |
1477 } |
1394 } |
1478 |
1395 |
1479 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/concat.js |
1396 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/concat.js |
1480 /** |
1397 /** |
1481 * Internal dependencies |
1398 * Internal dependencies |
1482 */ |
1399 */ |
1483 |
1400 |
1484 |
1401 |
1507 * @param {...RichTextValue} values Objects to combine. |
1424 * @param {...RichTextValue} values Objects to combine. |
1508 * |
1425 * |
1509 * @return {RichTextValue} A new value combining all given records. |
1426 * @return {RichTextValue} A new value combining all given records. |
1510 */ |
1427 */ |
1511 |
1428 |
1512 function concat(...values) { |
1429 function concat() { |
1430 for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) { |
|
1431 values[_key] = arguments[_key]; |
|
1432 } |
|
1433 |
|
1513 return normaliseFormats(values.reduce(mergePair, create())); |
1434 return normaliseFormats(values.reduce(mergePair, create())); |
1514 } |
1435 } |
1515 |
1436 |
1516 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-formats.js |
1437 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-formats.js |
1517 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1438 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1518 |
1439 |
1519 /** @typedef {import('./create').RichTextFormatList} RichTextFormatList */ |
1440 /** @typedef {import('./create').RichTextFormatList} RichTextFormatList */ |
1520 |
1441 |
1521 /** |
1442 /** |
1525 * @param {Array} EMPTY_ACTIVE_FORMATS Array to return if there are no |
1446 * @param {Array} EMPTY_ACTIVE_FORMATS Array to return if there are no |
1526 * active formats. |
1447 * active formats. |
1527 * |
1448 * |
1528 * @return {RichTextFormatList} Active format objects. |
1449 * @return {RichTextFormatList} Active format objects. |
1529 */ |
1450 */ |
1530 function getActiveFormats({ |
1451 function getActiveFormats(_ref) { |
1531 formats, |
1452 let { |
1532 start, |
1453 formats, |
1533 end, |
1454 start, |
1534 activeFormats |
1455 end, |
1535 }, EMPTY_ACTIVE_FORMATS = []) { |
1456 activeFormats |
1457 } = _ref; |
|
1458 let EMPTY_ACTIVE_FORMATS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
1459 |
|
1536 if (start === undefined) { |
1460 if (start === undefined) { |
1537 return EMPTY_ACTIVE_FORMATS; |
1461 return EMPTY_ACTIVE_FORMATS; |
1538 } |
1462 } |
1539 |
1463 |
1540 if (start === end) { |
1464 if (start === end) { |
1556 } |
1480 } |
1557 |
1481 |
1558 return formats[start] || EMPTY_ACTIVE_FORMATS; |
1482 return formats[start] || EMPTY_ACTIVE_FORMATS; |
1559 } |
1483 } |
1560 |
1484 |
1561 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-format.js |
1485 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-format.js |
1562 /** |
1486 /** |
1563 * External dependencies |
1487 * External dependencies |
1564 */ |
1488 */ |
1565 |
1489 |
1566 /** |
1490 /** |
1584 * @return {RichTextFormat|undefined} Active format object of the specified |
1508 * @return {RichTextFormat|undefined} Active format object of the specified |
1585 * type, or undefined. |
1509 * type, or undefined. |
1586 */ |
1510 */ |
1587 |
1511 |
1588 function getActiveFormat(value, formatType) { |
1512 function getActiveFormat(value, formatType) { |
1589 return Object(external_lodash_["find"])(getActiveFormats(value), { |
1513 return (0,external_lodash_namespaceObject.find)(getActiveFormats(value), { |
1590 type: formatType |
1514 type: formatType |
1591 }); |
1515 }); |
1592 } |
1516 } |
1593 |
1517 |
1594 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-object.js |
1518 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-object.js |
1595 /** |
1519 /** |
1596 * Internal dependencies |
1520 * Internal dependencies |
1597 */ |
1521 */ |
1598 |
1522 |
1599 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1523 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1606 * @param {RichTextValue} value Value to inspect. |
1530 * @param {RichTextValue} value Value to inspect. |
1607 * |
1531 * |
1608 * @return {RichTextFormat|void} Active object, or undefined. |
1532 * @return {RichTextFormat|void} Active object, or undefined. |
1609 */ |
1533 */ |
1610 |
1534 |
1611 function getActiveObject({ |
1535 function getActiveObject(_ref) { |
1612 start, |
1536 let { |
1613 end, |
1537 start, |
1614 replacements, |
1538 end, |
1615 text |
1539 replacements, |
1616 }) { |
1540 text |
1541 } = _ref; |
|
1542 |
|
1617 if (start + 1 !== end || text[start] !== OBJECT_REPLACEMENT_CHARACTER) { |
1543 if (start + 1 !== end || text[start] !== OBJECT_REPLACEMENT_CHARACTER) { |
1618 return; |
1544 return; |
1619 } |
1545 } |
1620 |
1546 |
1621 return replacements[start]; |
1547 return replacements[start]; |
1622 } |
1548 } |
1623 |
1549 |
1624 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-text-content.js |
1550 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-text-content.js |
1625 /** |
1551 /** |
1626 * Internal dependencies |
1552 * Internal dependencies |
1627 */ |
1553 */ |
1628 |
1554 |
1629 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1555 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1635 * @param {RichTextValue} value Value to use. |
1561 * @param {RichTextValue} value Value to use. |
1636 * |
1562 * |
1637 * @return {string} The text content. |
1563 * @return {string} The text content. |
1638 */ |
1564 */ |
1639 |
1565 |
1640 function getTextContent({ |
1566 function getTextContent(_ref) { |
1641 text |
1567 let { |
1642 }) { |
1568 text |
1569 } = _ref; |
|
1643 return text.replace(new RegExp(OBJECT_REPLACEMENT_CHARACTER, 'g'), '').replace(new RegExp(LINE_SEPARATOR, 'g'), '\n'); |
1570 return text.replace(new RegExp(OBJECT_REPLACEMENT_CHARACTER, 'g'), '').replace(new RegExp(LINE_SEPARATOR, 'g'), '\n'); |
1644 } |
1571 } |
1645 |
1572 |
1646 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-line-index.js |
1573 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-line-index.js |
1647 /** |
1574 /** |
1648 * Internal dependencies |
1575 * Internal dependencies |
1649 */ |
1576 */ |
1650 |
1577 |
1651 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1578 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1652 |
1579 |
1653 /** |
1580 /** |
1654 * Gets the currently selected line index, or the first line index if the |
1581 * Gets the currently selected line index, or the first line index if the |
1655 * selection spans over multiple items. |
1582 * selection spans over multiple items. |
1656 * |
1583 * |
1657 * @param {RichTextValue} value Value to get the line index from. |
1584 * @param {RichTextValue} value Value to get the line index from. |
1658 * @param {boolean} startIndex Optional index that should be contained by |
1585 * @param {boolean} startIndex Optional index that should be contained by |
1659 * the line. Defaults to the selection start |
1586 * the line. Defaults to the selection start |
1660 * of the value. |
1587 * of the value. |
1661 * |
1588 * |
1662 * @return {number|void} The line index. Undefined if not found. |
1589 * @return {number|void} The line index. Undefined if not found. |
1663 */ |
1590 */ |
1664 |
1591 |
1665 function getLineIndex({ |
1592 function getLineIndex(_ref) { |
1666 start, |
1593 let { |
1667 text |
1594 start, |
1668 }, startIndex = start) { |
1595 text |
1596 } = _ref; |
|
1597 let startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start; |
|
1669 let index = startIndex; |
1598 let index = startIndex; |
1670 |
1599 |
1671 while (index--) { |
1600 while (index--) { |
1672 if (text[index] === LINE_SEPARATOR) { |
1601 if (text[index] === LINE_SEPARATOR) { |
1673 return index; |
1602 return index; |
1674 } |
1603 } |
1675 } |
1604 } |
1676 } |
1605 } |
1677 |
1606 |
1678 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-list-root-selected.js |
1607 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-list-root-selected.js |
1679 /** |
1608 /** |
1680 * Internal dependencies |
1609 * Internal dependencies |
1681 */ |
1610 */ |
1682 |
1611 |
1683 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1612 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1699 const lineIndex = getLineIndex(value, start); |
1628 const lineIndex = getLineIndex(value, start); |
1700 const replacement = replacements[lineIndex]; |
1629 const replacement = replacements[lineIndex]; |
1701 return !replacement || replacement.length < 1; |
1630 return !replacement || replacement.length < 1; |
1702 } |
1631 } |
1703 |
1632 |
1704 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-active-list-type.js |
1633 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-active-list-type.js |
1705 /** |
1634 /** |
1706 * Internal dependencies |
1635 * Internal dependencies |
1707 */ |
1636 */ |
1708 |
1637 |
1709 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1638 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1733 |
1662 |
1734 const lastFormat = replacement[replacement.length - 1]; |
1663 const lastFormat = replacement[replacement.length - 1]; |
1735 return lastFormat.type === type; |
1664 return lastFormat.type === type; |
1736 } |
1665 } |
1737 |
1666 |
1738 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-collapsed.js |
1667 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-collapsed.js |
1739 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1668 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1740 |
1669 |
1741 /** |
1670 /** |
1742 * Check if the selection of a Rich Text value is collapsed or not. Collapsed |
1671 * Check if the selection of a Rich Text value is collapsed or not. Collapsed |
1743 * means that no characters are selected, but there is a caret present. If there |
1672 * means that no characters are selected, but there is a caret present. If there |
1747 * @param {RichTextValue} value The rich text value to check. |
1676 * @param {RichTextValue} value The rich text value to check. |
1748 * |
1677 * |
1749 * @return {boolean|undefined} True if the selection is collapsed, false if not, |
1678 * @return {boolean|undefined} True if the selection is collapsed, false if not, |
1750 * undefined if there is no selection. |
1679 * undefined if there is no selection. |
1751 */ |
1680 */ |
1752 function isCollapsed({ |
1681 function isCollapsed(_ref) { |
1753 start, |
1682 let { |
1754 end |
1683 start, |
1755 }) { |
1684 end |
1685 } = _ref; |
|
1686 |
|
1756 if (start === undefined || end === undefined) { |
1687 if (start === undefined || end === undefined) { |
1757 return; |
1688 return; |
1758 } |
1689 } |
1759 |
1690 |
1760 return start === end; |
1691 return start === end; |
1761 } |
1692 } |
1762 |
1693 |
1763 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-empty.js |
1694 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-empty.js |
1764 /** |
1695 /** |
1765 * Internal dependencies |
1696 * Internal dependencies |
1766 */ |
1697 */ |
1767 |
1698 |
1768 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1699 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
1774 * @param {RichTextValue} value Value to use. |
1705 * @param {RichTextValue} value Value to use. |
1775 * |
1706 * |
1776 * @return {boolean} True if the value is empty, false if not. |
1707 * @return {boolean} True if the value is empty, false if not. |
1777 */ |
1708 */ |
1778 |
1709 |
1779 function isEmpty({ |
1710 function isEmpty(_ref) { |
1780 text |
1711 let { |
1781 }) { |
1712 text |
1713 } = _ref; |
|
1782 return text.length === 0; |
1714 return text.length === 0; |
1783 } |
1715 } |
1784 /** |
1716 /** |
1785 * Check if the current collapsed selection is on an empty line in case of a |
1717 * Check if the current collapsed selection is on an empty line in case of a |
1786 * multiline value. |
1718 * multiline value. |
1787 * |
1719 * |
1788 * @param {RichTextValue} value Value te check. |
1720 * @param {RichTextValue} value Value te check. |
1789 * |
1721 * |
1790 * @return {boolean} True if the line is empty, false if not. |
1722 * @return {boolean} True if the line is empty, false if not. |
1791 */ |
1723 */ |
1792 |
1724 |
1793 function isEmptyLine({ |
1725 function isEmptyLine(_ref2) { |
1794 text, |
1726 let { |
1795 start, |
1727 text, |
1796 end |
1728 start, |
1797 }) { |
1729 end |
1730 } = _ref2; |
|
1731 |
|
1798 if (start !== end) { |
1732 if (start !== end) { |
1799 return false; |
1733 return false; |
1800 } |
1734 } |
1801 |
1735 |
1802 if (text.length === 0) { |
1736 if (text.length === 0) { |
1812 } |
1746 } |
1813 |
1747 |
1814 return text.slice(start - 1, end + 1) === `${LINE_SEPARATOR}${LINE_SEPARATOR}`; |
1748 return text.slice(start - 1, end + 1) === `${LINE_SEPARATOR}${LINE_SEPARATOR}`; |
1815 } |
1749 } |
1816 |
1750 |
1817 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/join.js |
1751 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/join.js |
1818 /** |
1752 /** |
1819 * Internal dependencies |
1753 * Internal dependencies |
1820 */ |
1754 */ |
1821 |
1755 |
1822 |
1756 |
1831 * @param {string|RichTextValue} [separator] Separator string or value. |
1765 * @param {string|RichTextValue} [separator] Separator string or value. |
1832 * |
1766 * |
1833 * @return {RichTextValue} A new combined value. |
1767 * @return {RichTextValue} A new combined value. |
1834 */ |
1768 */ |
1835 |
1769 |
1836 function join(values, separator = '') { |
1770 function join(values) { |
1771 let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; |
|
1772 |
|
1837 if (typeof separator === 'string') { |
1773 if (typeof separator === 'string') { |
1838 separator = create({ |
1774 separator = create({ |
1839 text: separator |
1775 text: separator |
1840 }); |
1776 }); |
1841 } |
1777 } |
1842 |
1778 |
1843 return normaliseFormats(values.reduce((accumlator, { |
1779 return normaliseFormats(values.reduce((accumlator, _ref) => { |
1844 formats, |
1780 let { |
1845 replacements, |
1781 formats, |
1846 text |
1782 replacements, |
1847 }) => ({ |
1783 text |
1848 formats: accumlator.formats.concat(separator.formats, formats), |
1784 } = _ref; |
1849 replacements: accumlator.replacements.concat(separator.replacements, replacements), |
1785 return { |
1850 text: accumlator.text + separator.text + text |
1786 formats: accumlator.formats.concat(separator.formats, formats), |
1851 }))); |
1787 replacements: accumlator.replacements.concat(separator.replacements, replacements), |
1852 } |
1788 text: accumlator.text + separator.text + text |
1853 |
1789 }; |
1854 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/register-format-type.js |
1790 })); |
1791 } |
|
1792 |
|
1793 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/register-format-type.js |
|
1855 /** |
1794 /** |
1856 * WordPress dependencies |
1795 * WordPress dependencies |
1857 */ |
1796 */ |
1858 |
1797 |
1859 /** |
1798 /** |
1876 |
1815 |
1877 /** |
1816 /** |
1878 * Registers a new format provided a unique name and an object defining its |
1817 * Registers a new format provided a unique name and an object defining its |
1879 * behavior. |
1818 * behavior. |
1880 * |
1819 * |
1881 * @param {string} name Format name. |
1820 * @param {string} name Format name. |
1882 * @param {WPFormat} settings Format settings. |
1821 * @param {WPFormat} settings Format settings. |
1883 * |
1822 * |
1884 * @return {WPFormat|undefined} The format, if it has been successfully |
1823 * @return {WPFormat|undefined} The format, if it has been successfully |
1885 * registered; otherwise `undefined`. |
1824 * registered; otherwise `undefined`. |
1886 */ |
1825 */ |
1887 |
1826 |
1899 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(settings.name)) { |
1838 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(settings.name)) { |
1900 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'); |
1839 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'); |
1901 return; |
1840 return; |
1902 } |
1841 } |
1903 |
1842 |
1904 if (Object(external_wp_data_["select"])(store).getFormatType(settings.name)) { |
1843 if ((0,external_wp_data_namespaceObject.select)(store).getFormatType(settings.name)) { |
1905 window.console.error('Format "' + settings.name + '" is already registered.'); |
1844 window.console.error('Format "' + settings.name + '" is already registered.'); |
1906 return; |
1845 return; |
1907 } |
1846 } |
1908 |
1847 |
1909 if (typeof settings.tagName !== 'string' || settings.tagName === '') { |
1848 if (typeof settings.tagName !== 'string' || settings.tagName === '') { |
1920 window.console.error('A class name must begin with a letter, followed by any number of hyphens, letters, or numbers.'); |
1859 window.console.error('A class name must begin with a letter, followed by any number of hyphens, letters, or numbers.'); |
1921 return; |
1860 return; |
1922 } |
1861 } |
1923 |
1862 |
1924 if (settings.className === null) { |
1863 if (settings.className === null) { |
1925 const formatTypeForBareElement = Object(external_wp_data_["select"])(store).getFormatTypeForBareElement(settings.tagName); |
1864 const formatTypeForBareElement = (0,external_wp_data_namespaceObject.select)(store).getFormatTypeForBareElement(settings.tagName); |
1926 |
1865 |
1927 if (formatTypeForBareElement) { |
1866 if (formatTypeForBareElement) { |
1928 window.console.error(`Format "${formatTypeForBareElement.name}" is already registered to handle bare tag name "${settings.tagName}".`); |
1867 window.console.error(`Format "${formatTypeForBareElement.name}" is already registered to handle bare tag name "${settings.tagName}".`); |
1929 return; |
1868 return; |
1930 } |
1869 } |
1931 } else { |
1870 } else { |
1932 const formatTypeForClassName = Object(external_wp_data_["select"])(store).getFormatTypeForClassName(settings.className); |
1871 const formatTypeForClassName = (0,external_wp_data_namespaceObject.select)(store).getFormatTypeForClassName(settings.className); |
1933 |
1872 |
1934 if (formatTypeForClassName) { |
1873 if (formatTypeForClassName) { |
1935 window.console.error(`Format "${formatTypeForClassName.name}" is already registered to handle class name "${settings.className}".`); |
1874 window.console.error(`Format "${formatTypeForClassName.name}" is already registered to handle class name "${settings.className}".`); |
1936 return; |
1875 return; |
1937 } |
1876 } |
1950 if (typeof settings.title !== 'string') { |
1889 if (typeof settings.title !== 'string') { |
1951 window.console.error('Format titles must be strings.'); |
1890 window.console.error('Format titles must be strings.'); |
1952 return; |
1891 return; |
1953 } |
1892 } |
1954 |
1893 |
1955 Object(external_wp_data_["dispatch"])(store).addFormatTypes(settings); |
1894 (0,external_wp_data_namespaceObject.dispatch)(store).addFormatTypes(settings); |
1956 return settings; |
1895 return settings; |
1957 } |
1896 } |
1958 |
1897 |
1959 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove-format.js |
1898 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove-format.js |
1960 /** |
1899 /** |
1961 * External dependencies |
1900 * External dependencies |
1962 */ |
1901 */ |
1963 |
1902 |
1964 /** |
1903 /** |
1979 * @param {number} [endIndex] End index. |
1918 * @param {number} [endIndex] End index. |
1980 * |
1919 * |
1981 * @return {RichTextValue} A new value with the format applied. |
1920 * @return {RichTextValue} A new value with the format applied. |
1982 */ |
1921 */ |
1983 |
1922 |
1984 function removeFormat(value, formatType, startIndex = value.start, endIndex = value.end) { |
1923 function removeFormat(value, formatType) { |
1924 let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.start; |
|
1925 let endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : value.end; |
|
1985 const { |
1926 const { |
1986 formats, |
1927 formats, |
1987 activeFormats |
1928 activeFormats |
1988 } = value; |
1929 } = value; |
1989 const newFormats = formats.slice(); // If the selection is collapsed, expand start and end to the edges of the |
1930 const newFormats = formats.slice(); // If the selection is collapsed, expand start and end to the edges of the |
1990 // format. |
1931 // format. |
1991 |
1932 |
1992 if (startIndex === endIndex) { |
1933 if (startIndex === endIndex) { |
1993 const format = Object(external_lodash_["find"])(newFormats[startIndex], { |
1934 const format = (0,external_lodash_namespaceObject.find)(newFormats[startIndex], { |
1994 type: formatType |
1935 type: formatType |
1995 }); |
1936 }); |
1996 |
1937 |
1997 if (format) { |
1938 if (format) { |
1998 while (Object(external_lodash_["find"])(newFormats[startIndex], format)) { |
1939 while ((0,external_lodash_namespaceObject.find)(newFormats[startIndex], format)) { |
1999 filterFormats(newFormats, startIndex, formatType); |
1940 filterFormats(newFormats, startIndex, formatType); |
2000 startIndex--; |
1941 startIndex--; |
2001 } |
1942 } |
2002 |
1943 |
2003 endIndex++; |
1944 endIndex++; |
2004 |
1945 |
2005 while (Object(external_lodash_["find"])(newFormats[endIndex], format)) { |
1946 while ((0,external_lodash_namespaceObject.find)(newFormats[endIndex], format)) { |
2006 filterFormats(newFormats, endIndex, formatType); |
1947 filterFormats(newFormats, endIndex, formatType); |
2007 endIndex++; |
1948 endIndex++; |
2008 } |
1949 } |
2009 } |
1950 } |
2010 } else { |
1951 } else { |
2015 } |
1956 } |
2016 } |
1957 } |
2017 |
1958 |
2018 return normaliseFormats({ ...value, |
1959 return normaliseFormats({ ...value, |
2019 formats: newFormats, |
1960 formats: newFormats, |
2020 activeFormats: Object(external_lodash_["reject"])(activeFormats, { |
1961 activeFormats: (0,external_lodash_namespaceObject.reject)(activeFormats, { |
2021 type: formatType |
1962 type: formatType |
2022 }) |
1963 }) |
2023 }); |
1964 }); |
2024 } |
1965 } |
2025 |
1966 |
2026 function filterFormats(formats, index, formatType) { |
1967 function filterFormats(formats, index, formatType) { |
2027 const newFormats = formats[index].filter(({ |
1968 const newFormats = formats[index].filter(_ref => { |
2028 type |
1969 let { |
2029 }) => type !== formatType); |
1970 type |
1971 } = _ref; |
|
1972 return type !== formatType; |
|
1973 }); |
|
2030 |
1974 |
2031 if (newFormats.length) { |
1975 if (newFormats.length) { |
2032 formats[index] = newFormats; |
1976 formats[index] = newFormats; |
2033 } else { |
1977 } else { |
2034 delete formats[index]; |
1978 delete formats[index]; |
2035 } |
1979 } |
2036 } |
1980 } |
2037 |
1981 |
2038 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert.js |
1982 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert.js |
2039 /** |
1983 /** |
2040 * Internal dependencies |
1984 * Internal dependencies |
2041 */ |
1985 */ |
2042 |
1986 |
2043 |
1987 |
2055 * @param {number} [endIndex] End index. |
1999 * @param {number} [endIndex] End index. |
2056 * |
2000 * |
2057 * @return {RichTextValue} A new value with the value inserted. |
2001 * @return {RichTextValue} A new value with the value inserted. |
2058 */ |
2002 */ |
2059 |
2003 |
2060 function insert(value, valueToInsert, startIndex = value.start, endIndex = value.end) { |
2004 function insert(value, valueToInsert) { |
2005 let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.start; |
|
2006 let endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : value.end; |
|
2061 const { |
2007 const { |
2062 formats, |
2008 formats, |
2063 replacements, |
2009 replacements, |
2064 text |
2010 text |
2065 } = value; |
2011 } = value; |
2078 start: index, |
2024 start: index, |
2079 end: index |
2025 end: index |
2080 }); |
2026 }); |
2081 } |
2027 } |
2082 |
2028 |
2083 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove.js |
2029 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove.js |
2084 /** |
2030 /** |
2085 * Internal dependencies |
2031 * Internal dependencies |
2086 */ |
2032 */ |
2087 |
2033 |
2088 |
2034 |
2097 * @param {number} [endIndex] End index. |
2043 * @param {number} [endIndex] End index. |
2098 * |
2044 * |
2099 * @return {RichTextValue} A new value with the content removed. |
2045 * @return {RichTextValue} A new value with the content removed. |
2100 */ |
2046 */ |
2101 |
2047 |
2102 function remove_remove(value, startIndex, endIndex) { |
2048 function remove(value, startIndex, endIndex) { |
2103 return insert(value, create(), startIndex, endIndex); |
2049 return insert(value, create(), startIndex, endIndex); |
2104 } |
2050 } |
2105 |
2051 |
2106 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/replace.js |
2052 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/replace.js |
2107 /** |
2053 /** |
2108 * Internal dependencies |
2054 * Internal dependencies |
2109 */ |
2055 */ |
2110 |
2056 |
2111 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
2057 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
2112 |
2058 |
2113 /** |
2059 /** |
2114 * Search a Rich Text value and replace the match(es) with `replacement`. This |
2060 * Search a Rich Text value and replace the match(es) with `replacement`. This |
2115 * is similar to `String.prototype.replace`. |
2061 * is similar to `String.prototype.replace`. |
2116 * |
2062 * |
2117 * @param {RichTextValue} value The value to modify. |
2063 * @param {RichTextValue} value The value to modify. |
2118 * @param {RegExp|string} pattern A RegExp object or literal. Can also be |
2064 * @param {RegExp|string} pattern A RegExp object or literal. Can also be |
2119 * a string. It is treated as a verbatim |
2065 * a string. It is treated as a verbatim |
2120 * string and is not interpreted as a |
2066 * string and is not interpreted as a |
2121 * regular expression. Only the first |
2067 * regular expression. Only the first |
2122 * occurrence will be replaced. |
2068 * occurrence will be replaced. |
2123 * @param {Function|string} replacement The match or matches are replaced with |
2069 * @param {Function|string} replacement The match or matches are replaced with |
2125 * the specified function. |
2071 * the specified function. |
2126 * |
2072 * |
2127 * @return {RichTextValue} A new value with replacements applied. |
2073 * @return {RichTextValue} A new value with replacements applied. |
2128 */ |
2074 */ |
2129 |
2075 |
2130 function replace_replace({ |
2076 function replace_replace(_ref, pattern, replacement) { |
2131 formats, |
2077 let { |
2132 replacements, |
2078 formats, |
2133 text, |
2079 replacements, |
2134 start, |
2080 text, |
2135 end |
2081 start, |
2136 }, pattern, replacement) { |
2082 end |
2137 text = text.replace(pattern, (match, ...rest) => { |
2083 } = _ref; |
2084 text = text.replace(pattern, function (match) { |
|
2085 for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
2086 rest[_key - 1] = arguments[_key]; |
|
2087 } |
|
2088 |
|
2138 const offset = rest[rest.length - 2]; |
2089 const offset = rest[rest.length - 2]; |
2139 let newText = replacement; |
2090 let newText = replacement; |
2140 let newFormats; |
2091 let newFormats; |
2141 let newReplacements; |
2092 let newReplacements; |
2142 |
2093 |
2173 start, |
2124 start, |
2174 end |
2125 end |
2175 }); |
2126 }); |
2176 } |
2127 } |
2177 |
2128 |
2178 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-line-separator.js |
2129 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-line-separator.js |
2179 /** |
2130 /** |
2180 * Internal dependencies |
2131 * Internal dependencies |
2181 */ |
2132 */ |
2182 |
2133 |
2183 |
2134 |
2193 * @param {number} [endIndex] End index. |
2144 * @param {number} [endIndex] End index. |
2194 * |
2145 * |
2195 * @return {RichTextValue} A new value with the value inserted. |
2146 * @return {RichTextValue} A new value with the value inserted. |
2196 */ |
2147 */ |
2197 |
2148 |
2198 function insertLineSeparator(value, startIndex = value.start, endIndex = value.end) { |
2149 function insertLineSeparator(value) { |
2150 let startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : value.start; |
|
2151 let endIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.end; |
|
2199 const beforeText = value.text.slice(0, startIndex); |
2152 const beforeText = value.text.slice(0, startIndex); |
2200 const previousLineSeparatorIndex = beforeText.lastIndexOf(LINE_SEPARATOR); |
2153 const previousLineSeparatorIndex = beforeText.lastIndexOf(LINE_SEPARATOR); |
2201 const previousLineSeparatorFormats = value.replacements[previousLineSeparatorIndex]; |
2154 const previousLineSeparatorFormats = value.replacements[previousLineSeparatorIndex]; |
2202 let replacements = [,]; |
2155 let replacements = [,]; |
2203 |
2156 |
2211 text: LINE_SEPARATOR |
2164 text: LINE_SEPARATOR |
2212 }; |
2165 }; |
2213 return insert(value, valueToInsert, startIndex, endIndex); |
2166 return insert(value, valueToInsert, startIndex, endIndex); |
2214 } |
2167 } |
2215 |
2168 |
2216 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove-line-separator.js |
2169 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove-line-separator.js |
2217 /** |
2170 /** |
2218 * Internal dependencies |
2171 * Internal dependencies |
2219 */ |
2172 */ |
2220 |
2173 |
2221 |
2174 |
2234 * @return {RichTextValue|undefined} A new value with the line separator |
2187 * @return {RichTextValue|undefined} A new value with the line separator |
2235 * removed. Or undefined if no line separator |
2188 * removed. Or undefined if no line separator |
2236 * is found on the position. |
2189 * is found on the position. |
2237 */ |
2190 */ |
2238 |
2191 |
2239 function removeLineSeparator(value, backward = true) { |
2192 function removeLineSeparator(value) { |
2193 let backward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; |
|
2240 const { |
2194 const { |
2241 replacements, |
2195 replacements, |
2242 text, |
2196 text, |
2243 start, |
2197 start, |
2244 end |
2198 end |
2266 newReplacements[index] = replacements[index].slice(0, -1); |
2220 newReplacements[index] = replacements[index].slice(0, -1); |
2267 newValue = { ...value, |
2221 newValue = { ...value, |
2268 replacements: newReplacements |
2222 replacements: newReplacements |
2269 }; |
2223 }; |
2270 } else { |
2224 } else { |
2271 newValue = remove_remove(value, removeStart, removeEnd); |
2225 newValue = remove(value, removeStart, removeEnd); |
2272 } |
2226 } |
2273 |
2227 |
2274 return newValue; |
2228 return newValue; |
2275 } |
2229 } |
2276 |
2230 |
2277 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-object.js |
2231 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-object.js |
2278 /** |
2232 /** |
2279 * Internal dependencies |
2233 * Internal dependencies |
2280 */ |
2234 */ |
2281 |
2235 |
2282 |
2236 |
2304 text: OBJECT_REPLACEMENT_CHARACTER |
2258 text: OBJECT_REPLACEMENT_CHARACTER |
2305 }; |
2259 }; |
2306 return insert(value, valueToInsert, startIndex, endIndex); |
2260 return insert(value, valueToInsert, startIndex, endIndex); |
2307 } |
2261 } |
2308 |
2262 |
2309 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/slice.js |
2263 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/slice.js |
2310 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
2264 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
2311 |
2265 |
2312 /** |
2266 /** |
2313 * Slice a Rich Text value from `startIndex` to `endIndex`. Indices are |
2267 * Slice a Rich Text value from `startIndex` to `endIndex`. Indices are |
2314 * retrieved from the selection if none are provided. This is similar to |
2268 * retrieved from the selection if none are provided. This is similar to |
2318 * @param {number} [startIndex] Start index. |
2272 * @param {number} [startIndex] Start index. |
2319 * @param {number} [endIndex] End index. |
2273 * @param {number} [endIndex] End index. |
2320 * |
2274 * |
2321 * @return {RichTextValue} A new extracted value. |
2275 * @return {RichTextValue} A new extracted value. |
2322 */ |
2276 */ |
2323 function slice(value, startIndex = value.start, endIndex = value.end) { |
2277 function slice(value) { |
2278 let startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : value.start; |
|
2279 let endIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.end; |
|
2324 const { |
2280 const { |
2325 formats, |
2281 formats, |
2326 replacements, |
2282 replacements, |
2327 text |
2283 text |
2328 } = value; |
2284 } = value; |
2337 replacements: replacements.slice(startIndex, endIndex), |
2293 replacements: replacements.slice(startIndex, endIndex), |
2338 text: text.slice(startIndex, endIndex) |
2294 text: text.slice(startIndex, endIndex) |
2339 }; |
2295 }; |
2340 } |
2296 } |
2341 |
2297 |
2342 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/split.js |
2298 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/split.js |
2343 /** |
2299 /** |
2344 * Internal dependencies |
2300 * Internal dependencies |
2345 */ |
2301 */ |
2346 |
2302 |
2347 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
2303 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
2355 * @param {number|string} [string] Start index, or string at which to split. |
2311 * @param {number|string} [string] Start index, or string at which to split. |
2356 * |
2312 * |
2357 * @return {Array<RichTextValue>|undefined} An array of new values. |
2313 * @return {Array<RichTextValue>|undefined} An array of new values. |
2358 */ |
2314 */ |
2359 |
2315 |
2360 function split({ |
2316 function split(_ref, string) { |
2361 formats, |
2317 let { |
2362 replacements, |
2318 formats, |
2363 text, |
2319 replacements, |
2364 start, |
2320 text, |
2365 end |
2321 start, |
2366 }, string) { |
2322 end |
2323 } = _ref; |
|
2324 |
|
2367 if (typeof string !== 'string') { |
2325 if (typeof string !== 'string') { |
2368 return splitAtSelection(...arguments); |
2326 return splitAtSelection(...arguments); |
2369 } |
2327 } |
2370 |
2328 |
2371 let nextStart = 0; |
2329 let nextStart = 0; |
2394 |
2352 |
2395 return value; |
2353 return value; |
2396 }); |
2354 }); |
2397 } |
2355 } |
2398 |
2356 |
2399 function splitAtSelection({ |
2357 function splitAtSelection(_ref2) { |
2400 formats, |
2358 let { |
2401 replacements, |
2359 formats, |
2402 text, |
2360 replacements, |
2403 start, |
2361 text, |
2404 end |
2362 start, |
2405 }, startIndex = start, endIndex = end) { |
2363 end |
2364 } = _ref2; |
|
2365 let startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start; |
|
2366 let endIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : end; |
|
2367 |
|
2406 if (start === undefined || end === undefined) { |
2368 if (start === undefined || end === undefined) { |
2407 return; |
2369 return; |
2408 } |
2370 } |
2409 |
2371 |
2410 const before = { |
2372 const before = { |
2421 }; |
2383 }; |
2422 return [// Ensure newlines are trimmed. |
2384 return [// Ensure newlines are trimmed. |
2423 replace_replace(before, /\u2028+$/, ''), replace_replace(after, /^\u2028+/, '')]; |
2385 replace_replace(before, /\u2028+$/, ''), replace_replace(after, /^\u2028+/, '')]; |
2424 } |
2386 } |
2425 |
2387 |
2426 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-format-type.js |
2388 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-format-type.js |
2427 /** |
2389 /** |
2428 * WordPress dependencies |
2390 * WordPress dependencies |
2429 */ |
2391 */ |
2430 |
2392 |
2431 /** |
2393 /** |
2442 * |
2404 * |
2443 * @return {RichTextFormatType|undefined} Format type. |
2405 * @return {RichTextFormatType|undefined} Format type. |
2444 */ |
2406 */ |
2445 |
2407 |
2446 function get_format_type_getFormatType(name) { |
2408 function get_format_type_getFormatType(name) { |
2447 return Object(external_wp_data_["select"])(store).getFormatType(name); |
2409 return (0,external_wp_data_namespaceObject.select)(store).getFormatType(name); |
2448 } |
2410 } |
2449 |
2411 |
2450 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-tree.js |
2412 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-tree.js |
2451 /** |
2413 /** |
2452 * Internal dependencies |
2414 * Internal dependencies |
2453 */ |
2415 */ |
2454 |
2416 |
2455 |
2417 |
2476 } |
2438 } |
2477 /** |
2439 /** |
2478 * Converts a format object to information that can be used to create an element |
2440 * Converts a format object to information that can be used to create an element |
2479 * from (type, attributes and object). |
2441 * from (type, attributes and object). |
2480 * |
2442 * |
2481 * @param {Object} $1 Named parameters. |
2443 * @param {Object} $1 Named parameters. |
2482 * @param {string} $1.type The format type. |
2444 * @param {string} $1.type The format type. |
2483 * @param {Object} $1.attributes The format attributes. |
2445 * @param {Object} $1.attributes The format attributes. |
2484 * @param {Object} $1.unregisteredAttributes The unregistered format |
2446 * @param {Object} $1.unregisteredAttributes The unregistered format |
2485 * attributes. |
2447 * attributes. |
2486 * @param {boolean} $1.object Whether or not it is an object |
2448 * @param {boolean} $1.object Whether or not it is an object |
2487 * format. |
2449 * format. |
2488 * @param {boolean} $1.boundaryClass Whether or not to apply a boundary |
2450 * @param {boolean} $1.boundaryClass Whether or not to apply a boundary |
2489 * class. |
2451 * class. |
2490 * @param {boolean} $1.isEditableTree |
2452 * @param {boolean} $1.isEditableTree |
2491 * |
2453 * |
2492 * @return {Object} Information to be used for |
2454 * @return {Object} Information to be used for element creation. |
2493 * element creation. |
2455 */ |
2494 */ |
2456 |
2495 |
2457 |
2496 |
2458 function fromFormat(_ref) { |
2497 function fromFormat({ |
2459 let { |
2498 type, |
2460 type, |
2499 attributes, |
2461 attributes, |
2500 unregisteredAttributes, |
2462 unregisteredAttributes, |
2501 object, |
2463 object, |
2502 boundaryClass, |
2464 boundaryClass, |
2503 isEditableTree |
2465 isEditableTree |
2504 }) { |
2466 } = _ref; |
2505 const formatType = get_format_type_getFormatType(type); |
2467 const formatType = get_format_type_getFormatType(type); |
2506 let elementAttributes = {}; |
2468 let elementAttributes = {}; |
2507 |
2469 |
2508 if (boundaryClass) { |
2470 if (boundaryClass) { |
2509 elementAttributes['data-rich-text-format-boundary'] = 'true'; |
2471 elementAttributes['data-rich-text-format-boundary'] = 'true'; |
2568 } while (index--); |
2530 } while (index--); |
2569 |
2531 |
2570 return true; |
2532 return true; |
2571 } |
2533 } |
2572 |
2534 |
2573 function toTree({ |
2535 function toTree(_ref2) { |
2574 value, |
2536 let { |
2575 multilineTag, |
2537 value, |
2576 preserveWhiteSpace, |
2538 multilineTag, |
2577 createEmpty, |
2539 preserveWhiteSpace, |
2578 append, |
2540 createEmpty, |
2579 getLastChild, |
2541 append, |
2580 getParent, |
2542 getLastChild, |
2581 isText, |
2543 getParent, |
2582 getText, |
2544 isText, |
2583 remove, |
2545 getText, |
2584 appendText, |
2546 remove, |
2585 onStartIndex, |
2547 appendText, |
2586 onEndIndex, |
2548 onStartIndex, |
2587 isEditableTree, |
2549 onEndIndex, |
2588 placeholder |
2550 isEditableTree, |
2589 }) { |
2551 placeholder |
2552 } = _ref2; |
|
2590 const { |
2553 const { |
2591 formats, |
2554 formats, |
2592 replacements, |
2555 replacements, |
2593 text, |
2556 text, |
2594 start, |
2557 start, |
2712 onEndIndex(tree, pointer); |
2675 onEndIndex(tree, pointer); |
2713 } |
2676 } |
2714 } |
2677 } |
2715 |
2678 |
2716 if (character === OBJECT_REPLACEMENT_CHARACTER) { |
2679 if (character === OBJECT_REPLACEMENT_CHARACTER) { |
2717 if (!isEditableTree && replacements[i].type === 'script') { |
2680 var _replacements$i; |
2681 |
|
2682 if (!isEditableTree && ((_replacements$i = replacements[i]) === null || _replacements$i === void 0 ? void 0 : _replacements$i.type) === 'script') { |
|
2718 pointer = append(getParent(pointer), fromFormat({ |
2683 pointer = append(getParent(pointer), fromFormat({ |
2719 type: 'script', |
2684 type: 'script', |
2720 isEditableTree |
2685 isEditableTree |
2721 })); |
2686 })); |
2722 append(pointer, { |
2687 append(pointer, { |
2778 } |
2743 } |
2779 |
2744 |
2780 return tree; |
2745 return tree; |
2781 } |
2746 } |
2782 |
2747 |
2783 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-dom.js |
2748 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-dom.js |
2784 /** |
2749 /** |
2785 * Internal dependencies |
2750 * Internal dependencies |
2786 */ |
2751 */ |
2787 |
2752 |
2788 |
2753 |
2836 node, |
2801 node, |
2837 offset: path[0] |
2802 offset: path[0] |
2838 }; |
2803 }; |
2839 } |
2804 } |
2840 |
2805 |
2841 function to_dom_append(element, child) { |
2806 function append(element, child) { |
2842 if (typeof child === 'string') { |
2807 if (typeof child === 'string') { |
2843 child = element.ownerDocument.createTextNode(child); |
2808 child = element.ownerDocument.createTextNode(child); |
2844 } |
2809 } |
2845 |
2810 |
2846 const { |
2811 const { |
2857 } |
2822 } |
2858 |
2823 |
2859 return element.appendChild(child); |
2824 return element.appendChild(child); |
2860 } |
2825 } |
2861 |
2826 |
2862 function to_dom_appendText(node, text) { |
2827 function appendText(node, text) { |
2863 node.appendData(text); |
2828 node.appendData(text); |
2864 } |
2829 } |
2865 |
2830 |
2866 function to_dom_getLastChild({ |
2831 function getLastChild(_ref) { |
2867 lastChild |
2832 let { |
2868 }) { |
2833 lastChild |
2834 } = _ref; |
|
2869 return lastChild; |
2835 return lastChild; |
2870 } |
2836 } |
2871 |
2837 |
2872 function to_dom_getParent({ |
2838 function getParent(_ref2) { |
2873 parentNode |
2839 let { |
2874 }) { |
2840 parentNode |
2841 } = _ref2; |
|
2875 return parentNode; |
2842 return parentNode; |
2876 } |
2843 } |
2877 |
2844 |
2878 function to_dom_isText(node) { |
2845 function isText(node) { |
2879 return node.nodeType === node.TEXT_NODE; |
2846 return node.nodeType === node.TEXT_NODE; |
2880 } |
2847 } |
2881 |
2848 |
2882 function to_dom_getText({ |
2849 function getText(_ref3) { |
2883 nodeValue |
2850 let { |
2884 }) { |
2851 nodeValue |
2852 } = _ref3; |
|
2885 return nodeValue; |
2853 return nodeValue; |
2886 } |
2854 } |
2887 |
2855 |
2888 function to_dom_remove(node) { |
2856 function to_dom_remove(node) { |
2889 return node.parentNode.removeChild(node); |
2857 return node.parentNode.removeChild(node); |
2890 } |
2858 } |
2891 |
2859 |
2892 function toDom({ |
2860 function toDom(_ref4) { |
2893 value, |
2861 let { |
2894 multilineTag, |
2862 value, |
2895 prepareEditableTree, |
2863 multilineTag, |
2896 isEditableTree = true, |
2864 prepareEditableTree, |
2897 placeholder, |
2865 isEditableTree = true, |
2898 doc = document |
2866 placeholder, |
2899 }) { |
2867 doc = document |
2868 } = _ref4; |
|
2900 let startPath = []; |
2869 let startPath = []; |
2901 let endPath = []; |
2870 let endPath = []; |
2902 |
2871 |
2903 if (prepareEditableTree) { |
2872 if (prepareEditableTree) { |
2904 value = { ...value, |
2873 value = { ...value, |
2921 |
2890 |
2922 const tree = toTree({ |
2891 const tree = toTree({ |
2923 value, |
2892 value, |
2924 multilineTag, |
2893 multilineTag, |
2925 createEmpty, |
2894 createEmpty, |
2926 append: to_dom_append, |
2895 append, |
2927 getLastChild: to_dom_getLastChild, |
2896 getLastChild, |
2928 getParent: to_dom_getParent, |
2897 getParent, |
2929 isText: to_dom_isText, |
2898 isText, |
2930 getText: to_dom_getText, |
2899 getText, |
2931 remove: to_dom_remove, |
2900 remove: to_dom_remove, |
2932 appendText: to_dom_appendText, |
2901 appendText, |
2933 |
2902 |
2934 onStartIndex(body, pointer) { |
2903 onStartIndex(body, pointer) { |
2935 startPath = createPathToNode(pointer, body, [pointer.nodeValue.length]); |
2904 startPath = createPathToNode(pointer, body, [pointer.nodeValue.length]); |
2936 }, |
2905 }, |
2937 |
2906 |
2962 * @param {Function} [$1.prepareEditableTree] Function to filter editorable formats. |
2931 * @param {Function} [$1.prepareEditableTree] Function to filter editorable formats. |
2963 * @param {boolean} [$1.__unstableDomOnly] Only apply elements, no selection. |
2932 * @param {boolean} [$1.__unstableDomOnly] Only apply elements, no selection. |
2964 * @param {string} [$1.placeholder] Placeholder text. |
2933 * @param {string} [$1.placeholder] Placeholder text. |
2965 */ |
2934 */ |
2966 |
2935 |
2967 function apply({ |
2936 function apply(_ref5) { |
2968 value, |
2937 let { |
2969 current, |
2938 value, |
2970 multilineTag, |
2939 current, |
2971 prepareEditableTree, |
2940 multilineTag, |
2972 __unstableDomOnly, |
2941 prepareEditableTree, |
2973 placeholder |
2942 __unstableDomOnly, |
2974 }) { |
2943 placeholder |
2944 } = _ref5; |
|
2975 // Construct a new element tree in memory. |
2945 // Construct a new element tree in memory. |
2976 const { |
2946 const { |
2977 body, |
2947 body, |
2978 selection |
2948 selection |
2979 } = toDom({ |
2949 } = toDom({ |
3060 |
3030 |
3061 function isRangeEqual(a, b) { |
3031 function isRangeEqual(a, b) { |
3062 return a.startContainer === b.startContainer && a.startOffset === b.startOffset && a.endContainer === b.endContainer && a.endOffset === b.endOffset; |
3032 return a.startContainer === b.startContainer && a.startOffset === b.startOffset && a.endContainer === b.endContainer && a.endOffset === b.endOffset; |
3063 } |
3033 } |
3064 |
3034 |
3065 function applySelection({ |
3035 function applySelection(_ref6, current) { |
3066 startPath, |
3036 let { |
3067 endPath |
3037 startPath, |
3068 }, current) { |
3038 endPath |
3039 } = _ref6; |
|
3069 const { |
3040 const { |
3070 node: startContainer, |
3041 node: startContainer, |
3071 offset: startOffset |
3042 offset: startOffset |
3072 } = getNodeByPath(current, startPath); |
3043 } = getNodeByPath(current, startPath); |
3073 const { |
3044 const { |
3112 activeElement.focus(); |
3083 activeElement.focus(); |
3113 } |
3084 } |
3114 } |
3085 } |
3115 } |
3086 } |
3116 |
3087 |
3117 // EXTERNAL MODULE: external ["wp","escapeHtml"] |
3088 ;// CONCATENATED MODULE: external ["wp","escapeHtml"] |
3118 var external_wp_escapeHtml_ = __webpack_require__("Vx3V"); |
3089 var external_wp_escapeHtml_namespaceObject = window["wp"]["escapeHtml"]; |
3119 |
3090 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-html-string.js |
3120 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-html-string.js |
|
3121 /** |
3091 /** |
3122 * WordPress dependencies |
3092 * WordPress dependencies |
3123 */ |
3093 */ |
3124 |
3094 |
3125 /** |
3095 /** |
3140 * characters for line breaks. |
3110 * characters for line breaks. |
3141 * |
3111 * |
3142 * @return {string} HTML string. |
3112 * @return {string} HTML string. |
3143 */ |
3113 */ |
3144 |
3114 |
3145 function toHTMLString({ |
3115 function toHTMLString(_ref) { |
3146 value, |
3116 let { |
3147 multilineTag, |
3117 value, |
3148 preserveWhiteSpace |
3118 multilineTag, |
3149 }) { |
3119 preserveWhiteSpace |
3120 } = _ref; |
|
3150 const tree = toTree({ |
3121 const tree = toTree({ |
3151 value, |
3122 value, |
3152 multilineTag, |
3123 multilineTag, |
3153 preserveWhiteSpace, |
3124 preserveWhiteSpace, |
3154 createEmpty: to_html_string_createEmpty, |
3125 createEmpty, |
3155 append: to_html_string_append, |
3126 append: to_html_string_append, |
3156 getLastChild: to_html_string_getLastChild, |
3127 getLastChild: to_html_string_getLastChild, |
3157 getParent: to_html_string_getParent, |
3128 getParent: to_html_string_getParent, |
3158 isText: to_html_string_isText, |
3129 isText: to_html_string_isText, |
3159 getText: to_html_string_getText, |
3130 getText: to_html_string_getText, |
3161 appendText: to_html_string_appendText |
3132 appendText: to_html_string_appendText |
3162 }); |
3133 }); |
3163 return createChildrenHTML(tree.children); |
3134 return createChildrenHTML(tree.children); |
3164 } |
3135 } |
3165 |
3136 |
3166 function to_html_string_createEmpty() { |
3137 function createEmpty() { |
3167 return {}; |
3138 return {}; |
3168 } |
3139 } |
3169 |
3140 |
3170 function to_html_string_getLastChild({ |
3141 function to_html_string_getLastChild(_ref2) { |
3171 children |
3142 let { |
3172 }) { |
3143 children |
3144 } = _ref2; |
|
3173 return children && children[children.length - 1]; |
3145 return children && children[children.length - 1]; |
3174 } |
3146 } |
3175 |
3147 |
3176 function to_html_string_append(parent, object) { |
3148 function to_html_string_append(parent, object) { |
3177 if (typeof object === 'string') { |
3149 if (typeof object === 'string') { |
3188 |
3160 |
3189 function to_html_string_appendText(object, text) { |
3161 function to_html_string_appendText(object, text) { |
3190 object.text += text; |
3162 object.text += text; |
3191 } |
3163 } |
3192 |
3164 |
3193 function to_html_string_getParent({ |
3165 function to_html_string_getParent(_ref3) { |
3194 parent |
3166 let { |
3195 }) { |
3167 parent |
3168 } = _ref3; |
|
3196 return parent; |
3169 return parent; |
3197 } |
3170 } |
3198 |
3171 |
3199 function to_html_string_isText({ |
3172 function to_html_string_isText(_ref4) { |
3200 text |
3173 let { |
3201 }) { |
3174 text |
3175 } = _ref4; |
|
3202 return typeof text === 'string'; |
3176 return typeof text === 'string'; |
3203 } |
3177 } |
3204 |
3178 |
3205 function to_html_string_getText({ |
3179 function to_html_string_getText(_ref5) { |
3206 text |
3180 let { |
3207 }) { |
3181 text |
3182 } = _ref5; |
|
3208 return text; |
3183 return text; |
3209 } |
3184 } |
3210 |
3185 |
3211 function to_html_string_remove(object) { |
3186 function to_html_string_remove(object) { |
3212 const index = object.parent.children.indexOf(object); |
3187 const index = object.parent.children.indexOf(object); |
3216 } |
3191 } |
3217 |
3192 |
3218 return object; |
3193 return object; |
3219 } |
3194 } |
3220 |
3195 |
3221 function createElementHTML({ |
3196 function createElementHTML(_ref6) { |
3222 type, |
3197 let { |
3223 attributes, |
3198 type, |
3224 object, |
3199 attributes, |
3225 children |
3200 object, |
3226 }) { |
3201 children |
3202 } = _ref6; |
|
3227 let attributeString = ''; |
3203 let attributeString = ''; |
3228 |
3204 |
3229 for (const key in attributes) { |
3205 for (const key in attributes) { |
3230 if (!Object(external_wp_escapeHtml_["isValidAttributeName"])(key)) { |
3206 if (!(0,external_wp_escapeHtml_namespaceObject.isValidAttributeName)(key)) { |
3231 continue; |
3207 continue; |
3232 } |
3208 } |
3233 |
3209 |
3234 attributeString += ` ${key}="${Object(external_wp_escapeHtml_["escapeAttribute"])(attributes[key])}"`; |
3210 attributeString += ` ${key}="${(0,external_wp_escapeHtml_namespaceObject.escapeAttribute)(attributes[key])}"`; |
3235 } |
3211 } |
3236 |
3212 |
3237 if (object) { |
3213 if (object) { |
3238 return `<${type}${attributeString}>`; |
3214 return `<${type}${attributeString}>`; |
3239 } |
3215 } |
3240 |
3216 |
3241 return `<${type}${attributeString}>${createChildrenHTML(children)}</${type}>`; |
3217 return `<${type}${attributeString}>${createChildrenHTML(children)}</${type}>`; |
3242 } |
3218 } |
3243 |
3219 |
3244 function createChildrenHTML(children = []) { |
3220 function createChildrenHTML() { |
3221 let children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
3245 return children.map(child => { |
3222 return children.map(child => { |
3246 if (child.html !== undefined) { |
3223 if (child.html !== undefined) { |
3247 return child.html; |
3224 return child.html; |
3248 } |
3225 } |
3249 |
3226 |
3250 return child.text === undefined ? createElementHTML(child) : Object(external_wp_escapeHtml_["escapeEditableHTML"])(child.text); |
3227 return child.text === undefined ? createElementHTML(child) : (0,external_wp_escapeHtml_namespaceObject.escapeEditableHTML)(child.text); |
3251 }).join(''); |
3228 }).join(''); |
3252 } |
3229 } |
3253 |
3230 |
3254 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/toggle-format.js |
3231 ;// CONCATENATED MODULE: external ["wp","a11y"] |
3232 var external_wp_a11y_namespaceObject = window["wp"]["a11y"]; |
|
3233 ;// CONCATENATED MODULE: external ["wp","i18n"] |
|
3234 var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
|
3235 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/toggle-format.js |
|
3236 /** |
|
3237 * WordPress dependencies |
|
3238 */ |
|
3239 |
|
3240 |
|
3255 /** |
3241 /** |
3256 * Internal dependencies |
3242 * Internal dependencies |
3257 */ |
3243 */ |
3244 |
|
3258 |
3245 |
3259 |
3246 |
3260 |
3247 |
3261 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
3248 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
3262 |
3249 |
3271 * @return {RichTextValue} A new value with the format applied or removed. |
3258 * @return {RichTextValue} A new value with the format applied or removed. |
3272 */ |
3259 */ |
3273 |
3260 |
3274 function toggleFormat(value, format) { |
3261 function toggleFormat(value, format) { |
3275 if (getActiveFormat(value, format.type)) { |
3262 if (getActiveFormat(value, format.type)) { |
3263 // For screen readers, will announce if formatting control is disabled. |
|
3264 if (format.title) { |
|
3265 // translators: %s: title of the formatting control |
|
3266 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('%s removed.'), format.title), 'assertive'); |
|
3267 } |
|
3268 |
|
3276 return removeFormat(value, format.type); |
3269 return removeFormat(value, format.type); |
3270 } // For screen readers, will announce if formatting control is enabled. |
|
3271 |
|
3272 |
|
3273 if (format.title) { |
|
3274 // translators: %s: title of the formatting control |
|
3275 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('%s applied.'), format.title), 'assertive'); |
|
3277 } |
3276 } |
3278 |
3277 |
3279 return applyFormat(value, format); |
3278 return applyFormat(value, format); |
3280 } |
3279 } |
3281 |
3280 |
3282 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/unregister-format-type.js |
3281 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/unregister-format-type.js |
3283 /** |
3282 /** |
3284 * WordPress dependencies |
3283 * WordPress dependencies |
3285 */ |
3284 */ |
3286 |
3285 |
3287 /** |
3286 /** |
3300 * been successfully unregistered; |
3299 * been successfully unregistered; |
3301 * otherwise `undefined`. |
3300 * otherwise `undefined`. |
3302 */ |
3301 */ |
3303 |
3302 |
3304 function unregisterFormatType(name) { |
3303 function unregisterFormatType(name) { |
3305 const oldFormat = Object(external_wp_data_["select"])(store).getFormatType(name); |
3304 const oldFormat = (0,external_wp_data_namespaceObject.select)(store).getFormatType(name); |
3306 |
3305 |
3307 if (!oldFormat) { |
3306 if (!oldFormat) { |
3308 window.console.error(`Format ${name} is not registered.`); |
3307 window.console.error(`Format ${name} is not registered.`); |
3309 return; |
3308 return; |
3310 } |
3309 } |
3311 |
3310 |
3312 Object(external_wp_data_["dispatch"])(store).removeFormatTypes(name); |
3311 (0,external_wp_data_namespaceObject.dispatch)(store).removeFormatTypes(name); |
3313 return oldFormat; |
3312 return oldFormat; |
3314 } |
3313 } |
3315 |
3314 |
3316 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/can-indent-list-items.js |
3315 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/can-indent-list-items.js |
3317 /** |
3316 /** |
3318 * Internal dependencies |
3317 * Internal dependencies |
3319 */ |
3318 */ |
3320 |
3319 |
3321 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
3320 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
3344 // then the line cannot be furter indented. |
3343 // then the line cannot be furter indented. |
3345 |
3344 |
3346 return formatsAtLineIndex.length <= formatsAtPreviousLineIndex.length; |
3345 return formatsAtLineIndex.length <= formatsAtPreviousLineIndex.length; |
3347 } |
3346 } |
3348 |
3347 |
3349 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/can-outdent-list-items.js |
3348 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/can-outdent-list-items.js |
3350 /** |
3349 /** |
3351 * Internal dependencies |
3350 * Internal dependencies |
3352 */ |
3351 */ |
3353 |
3352 |
3354 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
3353 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
3368 } = value; |
3367 } = value; |
3369 const startingLineIndex = getLineIndex(value, start); |
3368 const startingLineIndex = getLineIndex(value, start); |
3370 return replacements[startingLineIndex] !== undefined; |
3369 return replacements[startingLineIndex] !== undefined; |
3371 } |
3370 } |
3372 |
3371 |
3373 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/indent-list-items.js |
3372 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/indent-list-items.js |
3374 /** |
3373 /** |
3375 * Internal dependencies |
3374 * Internal dependencies |
3376 */ |
3375 */ |
3377 |
3376 |
3378 |
3377 |
3382 /** @typedef {import('./create').RichTextFormat} RichTextFormat */ |
3381 /** @typedef {import('./create').RichTextFormat} RichTextFormat */ |
3383 |
3382 |
3384 /** |
3383 /** |
3385 * Gets the line index of the first previous list item with higher indentation. |
3384 * Gets the line index of the first previous list item with higher indentation. |
3386 * |
3385 * |
3387 * @param {RichTextValue} value Value to search. |
3386 * @param {RichTextValue} value Value to search. |
3388 * @param {number} lineIndex Line index of the list item to compare |
3387 * @param {number} lineIndex Line index of the list item to compare |
3389 * with. |
3388 * with. |
3390 * |
3389 * |
3391 * @return {number|void} The line index. |
3390 * @return {number|void} The line index. |
3392 */ |
3391 */ |
3393 |
3392 |
3394 function getTargetLevelLineIndex({ |
3393 function getTargetLevelLineIndex(_ref, lineIndex) { |
3395 text, |
3394 let { |
3396 replacements |
3395 text, |
3397 }, lineIndex) { |
3396 replacements |
3397 } = _ref; |
|
3398 const startFormats = replacements[lineIndex] || []; |
3398 const startFormats = replacements[lineIndex] || []; |
3399 let index = lineIndex; |
3399 let index = lineIndex; |
3400 |
3400 |
3401 while (index-- >= 0) { |
3401 while (index-- >= 0) { |
3402 if (text[index] !== LINE_SEPARATOR) { |
3402 if (text[index] !== LINE_SEPARATOR) { |
3458 return { ...value, |
3458 return { ...value, |
3459 replacements: newFormats |
3459 replacements: newFormats |
3460 }; |
3460 }; |
3461 } |
3461 } |
3462 |
3462 |
3463 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-parent-line-index.js |
3463 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-parent-line-index.js |
3464 /** |
3464 /** |
3465 * Internal dependencies |
3465 * Internal dependencies |
3466 */ |
3466 */ |
3467 |
3467 |
3468 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
3468 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
3476 * @param {number} lineIndex Line index of a child list item. |
3476 * @param {number} lineIndex Line index of a child list item. |
3477 * |
3477 * |
3478 * @return {number|void} The parent list line index. |
3478 * @return {number|void} The parent list line index. |
3479 */ |
3479 */ |
3480 |
3480 |
3481 function getParentLineIndex({ |
3481 function getParentLineIndex(_ref, lineIndex) { |
3482 text, |
3482 let { |
3483 replacements |
3483 text, |
3484 }, lineIndex) { |
3484 replacements |
3485 } = _ref; |
|
3485 const startFormats = replacements[lineIndex] || []; |
3486 const startFormats = replacements[lineIndex] || []; |
3486 let index = lineIndex; |
3487 let index = lineIndex; |
3487 |
3488 |
3488 while (index-- >= 0) { |
3489 while (index-- >= 0) { |
3489 if (text[index] !== LINE_SEPARATOR) { |
3490 if (text[index] !== LINE_SEPARATOR) { |
3496 return index; |
3497 return index; |
3497 } |
3498 } |
3498 } |
3499 } |
3499 } |
3500 } |
3500 |
3501 |
3501 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-last-child-index.js |
3502 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-last-child-index.js |
3502 /** |
3503 /** |
3503 * Internal dependencies |
3504 * Internal dependencies |
3504 */ |
3505 */ |
3505 |
3506 |
3506 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
3507 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
3512 * @param {number} lineIndex Line index of a list item in the list. |
3513 * @param {number} lineIndex Line index of a list item in the list. |
3513 * |
3514 * |
3514 * @return {number} The index of the last child. |
3515 * @return {number} The index of the last child. |
3515 */ |
3516 */ |
3516 |
3517 |
3517 function getLastChildIndex({ |
3518 function getLastChildIndex(_ref, lineIndex) { |
3518 text, |
3519 let { |
3519 replacements |
3520 text, |
3520 }, lineIndex) { |
3521 replacements |
3522 } = _ref; |
|
3521 const lineFormats = replacements[lineIndex] || []; // Use the given line index in case there are no next children. |
3523 const lineFormats = replacements[lineIndex] || []; // Use the given line index in case there are no next children. |
3522 |
3524 |
3523 let childIndex = lineIndex; // `lineIndex` could be `undefined` if it's the first line. |
3525 let childIndex = lineIndex; // `lineIndex` could be `undefined` if it's the first line. |
3524 |
3526 |
3525 for (let index = lineIndex || 0; index < text.length; index++) { |
3527 for (let index = lineIndex || 0; index < text.length; index++) { |
3540 |
3542 |
3541 |
3543 |
3542 return childIndex; |
3544 return childIndex; |
3543 } |
3545 } |
3544 |
3546 |
3545 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/outdent-list-items.js |
3547 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/outdent-list-items.js |
3546 /** |
3548 /** |
3547 * Internal dependencies |
3549 * Internal dependencies |
3548 */ |
3550 */ |
3549 |
3551 |
3550 |
3552 |
3599 return { ...value, |
3601 return { ...value, |
3600 replacements: newFormats |
3602 replacements: newFormats |
3601 }; |
3603 }; |
3602 } |
3604 } |
3603 |
3605 |
3604 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/change-list-type.js |
3606 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/change-list-type.js |
3605 /** |
3607 /** |
3606 * Internal dependencies |
3608 * Internal dependencies |
3607 */ |
3609 */ |
3608 |
3610 |
3609 |
3611 |
3667 return { ...value, |
3669 return { ...value, |
3668 replacements: newReplacements |
3670 replacements: newReplacements |
3669 }; |
3671 }; |
3670 } |
3672 } |
3671 |
3673 |
3672 // EXTERNAL MODULE: external ["wp","element"] |
3674 ;// CONCATENATED MODULE: external ["wp","element"] |
3673 var external_wp_element_ = __webpack_require__("GRId"); |
3675 var external_wp_element_namespaceObject = window["wp"]["element"]; |
3674 |
3676 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-anchor-ref.js |
3675 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-anchor-ref.js |
|
3676 /** |
3677 /** |
3677 * WordPress dependencies |
3678 * WordPress dependencies |
3678 */ |
3679 */ |
3679 |
3680 |
3680 /** |
3681 /** |
3701 * @param {RichTextFormatType} $1.settings The format type's settings. |
3702 * @param {RichTextFormatType} $1.settings The format type's settings. |
3702 * |
3703 * |
3703 * @return {Element|Range} The active element or selection range. |
3704 * @return {Element|Range} The active element or selection range. |
3704 */ |
3705 */ |
3705 |
3706 |
3706 function useAnchorRef({ |
3707 function useAnchorRef(_ref) { |
3707 ref, |
3708 let { |
3708 value, |
3709 ref, |
3709 settings = {} |
3710 value, |
3710 }) { |
3711 settings = {} |
3712 } = _ref; |
|
3711 const { |
3713 const { |
3712 tagName, |
3714 tagName, |
3713 className, |
3715 className, |
3714 name |
3716 name |
3715 } = settings; |
3717 } = settings; |
3716 const activeFormat = name ? getActiveFormat(value, name) : undefined; |
3718 const activeFormat = name ? getActiveFormat(value, name) : undefined; |
3717 return Object(external_wp_element_["useMemo"])(() => { |
3719 return (0,external_wp_element_namespaceObject.useMemo)(() => { |
3718 if (!ref.current) return; |
3720 if (!ref.current) return; |
3719 const { |
3721 const { |
3720 ownerDocument: { |
3722 ownerDocument: { |
3721 defaultView |
3723 defaultView |
3722 } |
3724 } |
3743 |
3745 |
3744 return element.closest(tagName + (className ? '.' + className : '')); |
3746 return element.closest(tagName + (className ? '.' + className : '')); |
3745 }, [activeFormat, value.start, value.end, tagName, className]); |
3747 }, [activeFormat, value.start, value.end, tagName, className]); |
3746 } |
3748 } |
3747 |
3749 |
3748 // EXTERNAL MODULE: external ["wp","compose"] |
3750 ;// CONCATENATED MODULE: external ["wp","compose"] |
3749 var external_wp_compose_ = __webpack_require__("K9lf"); |
3751 var external_wp_compose_namespaceObject = window["wp"]["compose"]; |
3750 |
3752 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-default-style.js |
3751 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-default-style.js |
|
3752 /** |
3753 /** |
3753 * WordPress dependencies |
3754 * WordPress dependencies |
3754 */ |
3755 */ |
3755 |
3756 |
3756 /** |
3757 /** |
3780 * to 0 width and hiding the caret. This is useful for inline containers. |
3781 * to 0 width and hiding the caret. This is useful for inline containers. |
3781 */ |
3782 */ |
3782 |
3783 |
3783 const minWidth = '1px'; |
3784 const minWidth = '1px'; |
3784 function useDefaultStyle() { |
3785 function useDefaultStyle() { |
3785 return Object(external_wp_element_["useCallback"])(element => { |
3786 return (0,external_wp_element_namespaceObject.useCallback)(element => { |
3786 if (!element) return; |
3787 if (!element) return; |
3787 element.style.whiteSpace = whiteSpace; |
3788 element.style.whiteSpace = whiteSpace; |
3788 element.style.minWidth = minWidth; |
3789 element.style.minWidth = minWidth; |
3789 }, []); |
3790 }, []); |
3790 } |
3791 } |
3791 |
3792 |
3792 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-boundary-style.js |
3793 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-boundary-style.js |
3793 /** |
3794 /** |
3794 * WordPress dependencies |
3795 * WordPress dependencies |
3795 */ |
3796 */ |
3796 |
3797 |
3797 /* |
3798 /* |
3798 * Calculates and renders the format boundary style when the active formats |
3799 * Calculates and renders the format boundary style when the active formats |
3799 * change. |
3800 * change. |
3800 */ |
3801 */ |
3801 |
3802 |
3802 function useBoundaryStyle({ |
3803 function useBoundaryStyle(_ref) { |
3803 record |
3804 let { |
3804 }) { |
3805 record |
3805 const ref = Object(external_wp_element_["useRef"])(); |
3806 } = _ref; |
3807 const ref = (0,external_wp_element_namespaceObject.useRef)(); |
|
3806 const { |
3808 const { |
3807 activeFormats = [] |
3809 activeFormats = [] |
3808 } = record.current; |
3810 } = record.current; |
3809 Object(external_wp_element_["useEffect"])(() => { |
3811 (0,external_wp_element_namespaceObject.useEffect)(() => { |
3810 // There's no need to recalculate the boundary styles if no formats are |
3812 // There's no need to recalculate the boundary styles if no formats are |
3811 // active, because no boundary styles will be visible. |
3813 // active, because no boundary styles will be visible. |
3812 if (!activeFormats || !activeFormats.length) { |
3814 if (!activeFormats || !activeFormats.length) { |
3813 return; |
3815 return; |
3814 } |
3816 } |
3845 } |
3847 } |
3846 }, [activeFormats]); |
3848 }, [activeFormats]); |
3847 return ref; |
3849 return ref; |
3848 } |
3850 } |
3849 |
3851 |
3850 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-inline-warning.js |
3852 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-copy-handler.js |
3851 /** |
3853 /** |
3852 * WordPress dependencies |
3854 * WordPress dependencies |
3853 */ |
3855 */ |
3854 |
3856 |
3855 const message = 'RichText cannot be used with an inline container. Please use a different display property.'; |
|
3856 function useInlineWarning() { |
|
3857 const ref = Object(external_wp_element_["useRef"])(); |
|
3858 Object(external_wp_element_["useEffect"])(() => { |
|
3859 if (false) {} |
|
3860 }, []); |
|
3861 return ref; |
|
3862 } |
|
3863 |
|
3864 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-copy-handler.js |
|
3865 /** |
|
3866 * WordPress dependencies |
|
3867 */ |
|
3868 |
|
3869 |
3857 |
3870 /** |
3858 /** |
3871 * Internal dependencies |
3859 * Internal dependencies |
3872 */ |
3860 */ |
3873 |
3861 |
3874 |
3862 |
3875 |
3863 |
3876 |
3864 |
3877 |
3865 |
3878 function useCopyHandler(props) { |
3866 function useCopyHandler(props) { |
3879 const propsRef = Object(external_wp_element_["useRef"])(props); |
3867 const propsRef = (0,external_wp_element_namespaceObject.useRef)(props); |
3880 propsRef.current = props; |
3868 propsRef.current = props; |
3881 return Object(external_wp_compose_["useRefEffect"])(element => { |
3869 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { |
3882 function onCopy(event) { |
3870 function onCopy(event) { |
3883 const { |
3871 const { |
3884 record, |
3872 record, |
3885 multilineTag, |
3873 multilineTag, |
3886 preserveWhiteSpace |
3874 preserveWhiteSpace |
3898 preserveWhiteSpace |
3886 preserveWhiteSpace |
3899 }); |
3887 }); |
3900 event.clipboardData.setData('text/plain', plainText); |
3888 event.clipboardData.setData('text/plain', plainText); |
3901 event.clipboardData.setData('text/html', html); |
3889 event.clipboardData.setData('text/html', html); |
3902 event.clipboardData.setData('rich-text', 'true'); |
3890 event.clipboardData.setData('rich-text', 'true'); |
3891 event.clipboardData.setData('rich-text-multi-line-tag', multilineTag || ''); |
|
3903 event.preventDefault(); |
3892 event.preventDefault(); |
3904 } |
3893 } |
3905 |
3894 |
3906 element.addEventListener('copy', onCopy); |
3895 element.addEventListener('copy', onCopy); |
3907 return () => { |
3896 return () => { |
3908 element.removeEventListener('copy', onCopy); |
3897 element.removeEventListener('copy', onCopy); |
3909 }; |
3898 }; |
3910 }, []); |
3899 }, []); |
3911 } |
3900 } |
3912 |
3901 |
3913 // EXTERNAL MODULE: external ["wp","keycodes"] |
3902 ;// CONCATENATED MODULE: external ["wp","keycodes"] |
3914 var external_wp_keycodes_ = __webpack_require__("RxS6"); |
3903 var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; |
3915 |
3904 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-format-boundaries.js |
3916 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-format-boundaries.js |
|
3917 /** |
3905 /** |
3918 * WordPress dependencies |
3906 * WordPress dependencies |
3919 */ |
3907 */ |
3920 |
3908 |
3921 |
3909 |
3925 */ |
3913 */ |
3926 |
3914 |
3927 |
3915 |
3928 const EMPTY_ACTIVE_FORMATS = []; |
3916 const EMPTY_ACTIVE_FORMATS = []; |
3929 function useFormatBoundaries(props) { |
3917 function useFormatBoundaries(props) { |
3930 const [, forceRender] = Object(external_wp_element_["useReducer"])(() => ({})); |
3918 const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(() => ({})); |
3931 const propsRef = Object(external_wp_element_["useRef"])(props); |
3919 const propsRef = (0,external_wp_element_namespaceObject.useRef)(props); |
3932 propsRef.current = props; |
3920 propsRef.current = props; |
3933 return Object(external_wp_compose_["useRefEffect"])(element => { |
3921 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { |
3934 function onKeyDown(event) { |
3922 function onKeyDown(event) { |
3935 const { |
3923 const { |
3936 keyCode, |
3924 keyCode, |
3937 shiftKey, |
3925 shiftKey, |
3938 altKey, |
3926 altKey, |
3939 metaKey, |
3927 metaKey, |
3940 ctrlKey |
3928 ctrlKey |
3941 } = event; |
3929 } = event; |
3942 |
3930 |
3943 if ( // Only override left and right keys without modifiers pressed. |
3931 if ( // Only override left and right keys without modifiers pressed. |
3944 shiftKey || altKey || metaKey || ctrlKey || keyCode !== external_wp_keycodes_["LEFT"] && keyCode !== external_wp_keycodes_["RIGHT"]) { |
3932 shiftKey || altKey || metaKey || ctrlKey || keyCode !== external_wp_keycodes_namespaceObject.LEFT && keyCode !== external_wp_keycodes_namespaceObject.RIGHT) { |
3945 return; |
3933 return; |
3946 } |
3934 } |
3947 |
3935 |
3948 const { |
3936 const { |
3949 record, |
3937 record, |
3965 } = ownerDocument; // To do: ideally, we should look at visual position instead. |
3953 } = ownerDocument; // To do: ideally, we should look at visual position instead. |
3966 |
3954 |
3967 const { |
3955 const { |
3968 direction |
3956 direction |
3969 } = defaultView.getComputedStyle(element); |
3957 } = defaultView.getComputedStyle(element); |
3970 const reverseKey = direction === 'rtl' ? external_wp_keycodes_["RIGHT"] : external_wp_keycodes_["LEFT"]; |
3958 const reverseKey = direction === 'rtl' ? external_wp_keycodes_namespaceObject.RIGHT : external_wp_keycodes_namespaceObject.LEFT; |
3971 const isReverse = event.keyCode === reverseKey; // If the selection is collapsed and at the very start, do nothing if |
3959 const isReverse = event.keyCode === reverseKey; // If the selection is collapsed and at the very start, do nothing if |
3972 // navigating backward. |
3960 // navigating backward. |
3973 // If the selection is collapsed and at the very end, do nothing if |
3961 // If the selection is collapsed and at the very end, do nothing if |
3974 // navigating forward. |
3962 // navigating forward. |
3975 |
3963 |
3990 return; |
3978 return; |
3991 } |
3979 } |
3992 |
3980 |
3993 const formatsBefore = formats[start - 1] || EMPTY_ACTIVE_FORMATS; |
3981 const formatsBefore = formats[start - 1] || EMPTY_ACTIVE_FORMATS; |
3994 const formatsAfter = formats[start] || EMPTY_ACTIVE_FORMATS; |
3982 const formatsAfter = formats[start] || EMPTY_ACTIVE_FORMATS; |
3983 const destination = isReverse ? formatsBefore : formatsAfter; |
|
3984 const isIncreasing = currentActiveFormats.every((format, index) => format === destination[index]); |
|
3995 let newActiveFormatsLength = currentActiveFormats.length; |
3985 let newActiveFormatsLength = currentActiveFormats.length; |
3996 let source = formatsAfter; |
3986 |
3997 |
3987 if (!isIncreasing) { |
3998 if (formatsBefore.length > formatsAfter.length) { |
3988 newActiveFormatsLength--; |
3999 source = formatsBefore; |
3989 } else if (newActiveFormatsLength < destination.length) { |
4000 } // If the amount of formats before the caret and after the caret is |
3990 newActiveFormatsLength++; |
4001 // different, the caret is at a format boundary. |
|
4002 |
|
4003 |
|
4004 if (formatsBefore.length < formatsAfter.length) { |
|
4005 if (!isReverse && currentActiveFormats.length < formatsAfter.length) { |
|
4006 newActiveFormatsLength++; |
|
4007 } |
|
4008 |
|
4009 if (isReverse && currentActiveFormats.length > formatsBefore.length) { |
|
4010 newActiveFormatsLength--; |
|
4011 } |
|
4012 } else if (formatsBefore.length > formatsAfter.length) { |
|
4013 if (!isReverse && currentActiveFormats.length > formatsAfter.length) { |
|
4014 newActiveFormatsLength--; |
|
4015 } |
|
4016 |
|
4017 if (isReverse && currentActiveFormats.length < formatsBefore.length) { |
|
4018 newActiveFormatsLength++; |
|
4019 } |
|
4020 } |
3991 } |
4021 |
3992 |
4022 if (newActiveFormatsLength === currentActiveFormats.length) { |
3993 if (newActiveFormatsLength === currentActiveFormats.length) { |
4023 record.current._newActiveFormats = isReverse ? formatsBefore : formatsAfter; |
3994 record.current._newActiveFormats = destination; |
4024 return; |
3995 return; |
4025 } |
3996 } |
4026 |
3997 |
4027 event.preventDefault(); |
3998 event.preventDefault(); |
3999 const origin = isReverse ? formatsAfter : formatsBefore; |
|
4000 const source = isIncreasing ? destination : origin; |
|
4028 const newActiveFormats = source.slice(0, newActiveFormatsLength); |
4001 const newActiveFormats = source.slice(0, newActiveFormatsLength); |
4029 const newValue = { ...record.current, |
4002 const newValue = { ...record.current, |
4030 activeFormats: newActiveFormats |
4003 activeFormats: newActiveFormats |
4031 }; |
4004 }; |
4032 record.current = newValue; |
4005 record.current = newValue; |
4039 element.removeEventListener('keydown', onKeyDown); |
4012 element.removeEventListener('keydown', onKeyDown); |
4040 }; |
4013 }; |
4041 }, []); |
4014 }, []); |
4042 } |
4015 } |
4043 |
4016 |
4044 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-select-object.js |
4017 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-select-object.js |
4045 /** |
4018 /** |
4046 * WordPress dependencies |
4019 * WordPress dependencies |
4047 */ |
4020 */ |
4048 |
4021 |
4049 function useSelectObject() { |
4022 function useSelectObject() { |
4050 return Object(external_wp_compose_["useRefEffect"])(element => { |
4023 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { |
4051 function onClick(event) { |
4024 function onClick(event) { |
4052 const { |
4025 const { |
4053 target |
4026 target |
4054 } = event; // If the child element has no text content, it must be an object. |
4027 } = event; // If the child element has no text content, it must be an object. |
4055 |
4028 |
4075 element.removeEventListener('click', onClick); |
4048 element.removeEventListener('click', onClick); |
4076 }; |
4049 }; |
4077 }, []); |
4050 }, []); |
4078 } |
4051 } |
4079 |
4052 |
4080 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-indent-list-item-on-space.js |
4053 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-indent-list-item-on-space.js |
4081 /** |
4054 /** |
4082 * WordPress dependencies |
4055 * WordPress dependencies |
4083 */ |
4056 */ |
4084 |
4057 |
4085 |
4058 |
4090 |
4063 |
4091 |
4064 |
4092 |
4065 |
4093 |
4066 |
4094 function useIndentListItemOnSpace(props) { |
4067 function useIndentListItemOnSpace(props) { |
4095 const propsRef = Object(external_wp_element_["useRef"])(props); |
4068 const propsRef = (0,external_wp_element_namespaceObject.useRef)(props); |
4096 propsRef.current = props; |
4069 propsRef.current = props; |
4097 return Object(external_wp_compose_["useRefEffect"])(element => { |
4070 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { |
4098 function onKeyDown(event) { |
4071 function onKeyDown(event) { |
4099 const { |
4072 const { |
4100 keyCode, |
4073 keyCode, |
4101 shiftKey, |
4074 shiftKey, |
4102 altKey, |
4075 altKey, |
4108 createRecord, |
4081 createRecord, |
4109 handleChange |
4082 handleChange |
4110 } = propsRef.current; |
4083 } = propsRef.current; |
4111 |
4084 |
4112 if ( // Only override when no modifiers are pressed. |
4085 if ( // Only override when no modifiers are pressed. |
4113 shiftKey || altKey || metaKey || ctrlKey || keyCode !== external_wp_keycodes_["SPACE"] || multilineTag !== 'li') { |
4086 shiftKey || altKey || metaKey || ctrlKey || keyCode !== external_wp_keycodes_namespaceObject.SPACE || multilineTag !== 'li') { |
4114 return; |
4087 return; |
4115 } |
4088 } |
4116 |
4089 |
4117 const currentValue = createRecord(); |
4090 const currentValue = createRecord(); |
4118 |
4091 |
4141 element.removeEventListener('keydown', onKeyDown); |
4114 element.removeEventListener('keydown', onKeyDown); |
4142 }; |
4115 }; |
4143 }, []); |
4116 }, []); |
4144 } |
4117 } |
4145 |
4118 |
4146 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/update-formats.js |
4119 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/update-formats.js |
4147 /** |
4120 /** |
4148 * Internal dependencies |
4121 * Internal dependencies |
4149 */ |
4122 */ |
4150 |
4123 |
4151 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
4124 /** @typedef {import('./create').RichTextValue} RichTextValue */ |
4152 |
4125 |
4153 /** |
4126 /** |
4154 * Efficiently updates all the formats from `start` (including) until `end` |
4127 * Efficiently updates all the formats from `start` (including) until `end` |
4155 * (excluding) with the active formats. Mutates `value`. |
4128 * (excluding) with the active formats. Mutates `value`. |
4156 * |
4129 * |
4157 * @param {Object} $1 Named paramentes. |
4130 * @param {Object} $1 Named paramentes. |
4158 * @param {RichTextValue} $1.value Value te update. |
4131 * @param {RichTextValue} $1.value Value te update. |
4159 * @param {number} $1.start Index to update from. |
4132 * @param {number} $1.start Index to update from. |
4160 * @param {number} $1.end Index to update until. |
4133 * @param {number} $1.end Index to update until. |
4161 * @param {Array} $1.formats Replacement formats. |
4134 * @param {Array} $1.formats Replacement formats. |
4162 * |
4135 * |
4163 * @return {RichTextValue} Mutated value. |
4136 * @return {RichTextValue} Mutated value. |
4164 */ |
4137 */ |
4165 |
4138 |
4166 function updateFormats({ |
4139 function updateFormats(_ref) { |
4167 value, |
4140 let { |
4168 start, |
4141 value, |
4169 end, |
4142 start, |
4170 formats |
4143 end, |
4171 }) { |
4144 formats |
4172 const formatsBefore = value.formats[start - 1] || []; |
4145 } = _ref; |
4173 const formatsAfter = value.formats[end] || []; // First, fix the references. If any format right before or after are |
4146 // Start and end may be switched in case of delete. |
4147 const min = Math.min(start, end); |
|
4148 const max = Math.max(start, end); |
|
4149 const formatsBefore = value.formats[min - 1] || []; |
|
4150 const formatsAfter = value.formats[max] || []; // First, fix the references. If any format right before or after are |
|
4174 // equal, the replacement format should use the same reference. |
4151 // equal, the replacement format should use the same reference. |
4175 |
4152 |
4176 value.activeFormats = formats.map((format, index) => { |
4153 value.activeFormats = formats.map((format, index) => { |
4177 if (formatsBefore[index]) { |
4154 if (formatsBefore[index]) { |
4178 if (isFormatEqual(format, formatsBefore[index])) { |
4155 if (isFormatEqual(format, formatsBefore[index])) { |
4196 } |
4173 } |
4197 |
4174 |
4198 return value; |
4175 return value; |
4199 } |
4176 } |
4200 |
4177 |
4201 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-input-and-selection.js |
4178 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-input-and-selection.js |
4202 /** |
4179 /** |
4203 * WordPress dependencies |
4180 * WordPress dependencies |
4204 */ |
4181 */ |
4205 |
4182 |
4206 |
4183 |
4246 |
4223 |
4247 selection.collapseToStart(); |
4224 selection.collapseToStart(); |
4248 } |
4225 } |
4249 |
4226 |
4250 function useInputAndSelection(props) { |
4227 function useInputAndSelection(props) { |
4251 const propsRef = Object(external_wp_element_["useRef"])(props); |
4228 const propsRef = (0,external_wp_element_namespaceObject.useRef)(props); |
4252 propsRef.current = props; |
4229 propsRef.current = props; |
4253 return Object(external_wp_compose_["useRefEffect"])(element => { |
4230 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { |
4254 const { |
4231 const { |
4255 ownerDocument |
4232 ownerDocument |
4256 } = element; |
4233 } = element; |
4257 const { |
4234 const { |
4258 defaultView |
4235 defaultView |
4312 * @param {Event|DOMHighResTimeStamp} event |
4289 * @param {Event|DOMHighResTimeStamp} event |
4313 */ |
4290 */ |
4314 |
4291 |
4315 |
4292 |
4316 function handleSelectionChange(event) { |
4293 function handleSelectionChange(event) { |
4317 if (ownerDocument.activeElement !== element) { |
|
4318 return; |
|
4319 } |
|
4320 |
|
4321 const { |
4294 const { |
4322 record, |
4295 record, |
4323 applyRecord, |
4296 applyRecord, |
4324 createRecord, |
4297 createRecord, |
4325 isSelected, |
4298 isSelected, |
4326 onSelectionChange |
4299 onSelectionChange |
4327 } = propsRef.current; |
4300 } = propsRef.current; // Check if the implementor disabled editing. `contentEditable` |
4328 |
|
4329 if (event.type !== 'selectionchange' && !isSelected) { |
|
4330 return; |
|
4331 } // Check if the implementor disabled editing. `contentEditable` |
|
4332 // does disable input, but not text selection, so we must ignore |
4301 // does disable input, but not text selection, so we must ignore |
4333 // selection changes. |
4302 // selection changes. |
4334 |
4303 |
4335 |
|
4336 if (element.contentEditable !== 'true') { |
4304 if (element.contentEditable !== 'true') { |
4305 return; |
|
4306 } // If the selection changes where the active element is a parent of |
|
4307 // the rich text instance (writing flow), call `onSelectionChange` |
|
4308 // for the rich text instance that contains the start or end of the |
|
4309 // selection. |
|
4310 |
|
4311 |
|
4312 if (ownerDocument.activeElement !== element) { |
|
4313 if (!ownerDocument.activeElement.contains(element)) { |
|
4314 return; |
|
4315 } |
|
4316 |
|
4317 const selection = defaultView.getSelection(); |
|
4318 const { |
|
4319 anchorNode, |
|
4320 focusNode |
|
4321 } = selection; |
|
4322 |
|
4323 if (element.contains(anchorNode) && element !== anchorNode && element.contains(focusNode) && element !== focusNode) { |
|
4324 const { |
|
4325 start, |
|
4326 end |
|
4327 } = createRecord(); |
|
4328 record.current.activeFormats = use_input_and_selection_EMPTY_ACTIVE_FORMATS; |
|
4329 onSelectionChange(start, end); |
|
4330 } else if (element.contains(anchorNode) && element !== anchorNode) { |
|
4331 const { |
|
4332 start, |
|
4333 end: offset = start |
|
4334 } = createRecord(); |
|
4335 record.current.activeFormats = use_input_and_selection_EMPTY_ACTIVE_FORMATS; |
|
4336 onSelectionChange(offset); |
|
4337 } else if (element.contains(focusNode) && element !== focusNode) { |
|
4338 const { |
|
4339 start, |
|
4340 end: offset = start |
|
4341 } = createRecord(); |
|
4342 record.current.activeFormats = use_input_and_selection_EMPTY_ACTIVE_FORMATS; |
|
4343 onSelectionChange(undefined, offset); |
|
4344 } |
|
4345 |
|
4346 return; |
|
4347 } |
|
4348 |
|
4349 if (event.type !== 'selectionchange' && !isSelected) { |
|
4337 return; |
4350 return; |
4338 } // In case of a keyboard event, ignore selection changes during |
4351 } // In case of a keyboard event, ignore selection changes during |
4339 // composition. |
4352 // composition. |
4340 |
4353 |
4341 |
4354 |
4388 onSelectionChange(start, end); |
4401 onSelectionChange(start, end); |
4389 } |
4402 } |
4390 |
4403 |
4391 function onCompositionStart() { |
4404 function onCompositionStart() { |
4392 isComposing = true; // Do not update the selection when characters are being composed as |
4405 isComposing = true; // Do not update the selection when characters are being composed as |
4393 // this rerenders the component and might distroy internal browser |
4406 // this rerenders the component and might destroy internal browser |
4394 // editing state. |
4407 // editing state. |
4395 |
4408 |
4396 ownerDocument.removeEventListener('selectionchange', handleSelectionChange); |
4409 ownerDocument.removeEventListener('selectionchange', handleSelectionChange); |
4397 } |
4410 } |
4398 |
4411 |
4409 |
4422 |
4410 function onFocus() { |
4423 function onFocus() { |
4411 const { |
4424 const { |
4412 record, |
4425 record, |
4413 isSelected, |
4426 isSelected, |
4414 onSelectionChange |
4427 onSelectionChange, |
4415 } = propsRef.current; |
4428 applyRecord |
4429 } = propsRef.current; // When the whole editor is editable, let writing flow handle |
|
4430 // selection. |
|
4431 |
|
4432 if (element.parentElement.closest('[contenteditable="true"]')) { |
|
4433 return; |
|
4434 } |
|
4416 |
4435 |
4417 if (!isSelected) { |
4436 if (!isSelected) { |
4418 // We know for certain that on focus, the old selection is invalid. |
4437 // We know for certain that on focus, the old selection is invalid. |
4419 // It will be recalculated on the next mouseup, keyup, or touchend |
4438 // It will be recalculated on the next mouseup, keyup, or touchend |
4420 // event. |
4439 // event. |
4424 end: index, |
4443 end: index, |
4425 activeFormats: use_input_and_selection_EMPTY_ACTIVE_FORMATS |
4444 activeFormats: use_input_and_selection_EMPTY_ACTIVE_FORMATS |
4426 }; |
4445 }; |
4427 onSelectionChange(index, index); |
4446 onSelectionChange(index, index); |
4428 } else { |
4447 } else { |
4448 applyRecord(record.current); |
|
4429 onSelectionChange(record.current.start, record.current.end); |
4449 onSelectionChange(record.current.start, record.current.end); |
4430 } // Update selection as soon as possible, which is at the next animation |
4450 } // Update selection as soon as possible, which is at the next animation |
4431 // frame. The event listener for selection changes may be added too late |
4451 // frame. The event listener for selection changes may be added too late |
4432 // at this point, but this focus event is still too early to calculate |
4452 // at this point, but this focus event is still too early to calculate |
4433 // the selection. |
4453 // the selection. |
4434 |
4454 |
4435 |
4455 |
4436 rafId = defaultView.requestAnimationFrame(handleSelectionChange); |
4456 rafId = defaultView.requestAnimationFrame(handleSelectionChange); |
4437 ownerDocument.addEventListener('selectionchange', handleSelectionChange); |
|
4438 } |
|
4439 |
|
4440 function onBlur() { |
|
4441 ownerDocument.removeEventListener('selectionchange', handleSelectionChange); |
|
4442 } |
4457 } |
4443 |
4458 |
4444 element.addEventListener('input', onInput); |
4459 element.addEventListener('input', onInput); |
4445 element.addEventListener('compositionstart', onCompositionStart); |
4460 element.addEventListener('compositionstart', onCompositionStart); |
4446 element.addEventListener('compositionend', onCompositionEnd); |
4461 element.addEventListener('compositionend', onCompositionEnd); |
4447 element.addEventListener('focus', onFocus); |
4462 element.addEventListener('focus', onFocus); // Selection updates must be done at these events as they |
4448 element.addEventListener('blur', onBlur); // Selection updates must be done at these events as they |
|
4449 // happen before the `selectionchange` event. In some cases, |
4463 // happen before the `selectionchange` event. In some cases, |
4450 // the `selectionchange` event may not even fire, for |
4464 // the `selectionchange` event may not even fire, for |
4451 // example when the window receives focus again on click. |
4465 // example when the window receives focus again on click. |
4452 |
4466 |
4453 element.addEventListener('keyup', handleSelectionChange); |
4467 element.addEventListener('keyup', handleSelectionChange); |
4454 element.addEventListener('mouseup', handleSelectionChange); |
4468 element.addEventListener('mouseup', handleSelectionChange); |
4455 element.addEventListener('touchend', handleSelectionChange); |
4469 element.addEventListener('touchend', handleSelectionChange); |
4470 ownerDocument.addEventListener('selectionchange', handleSelectionChange); |
|
4456 return () => { |
4471 return () => { |
4457 element.removeEventListener('input', onInput); |
4472 element.removeEventListener('input', onInput); |
4458 element.removeEventListener('compositionstart', onCompositionStart); |
4473 element.removeEventListener('compositionstart', onCompositionStart); |
4459 element.removeEventListener('compositionend', onCompositionEnd); |
4474 element.removeEventListener('compositionend', onCompositionEnd); |
4460 element.removeEventListener('focus', onFocus); |
4475 element.removeEventListener('focus', onFocus); |
4461 element.removeEventListener('blur', onBlur); |
|
4462 element.removeEventListener('keyup', handleSelectionChange); |
4476 element.removeEventListener('keyup', handleSelectionChange); |
4463 element.removeEventListener('mouseup', handleSelectionChange); |
4477 element.removeEventListener('mouseup', handleSelectionChange); |
4464 element.removeEventListener('touchend', handleSelectionChange); |
4478 element.removeEventListener('touchend', handleSelectionChange); |
4465 ownerDocument.removeEventListener('selectionchange', handleSelectionChange); |
4479 ownerDocument.removeEventListener('selectionchange', handleSelectionChange); |
4466 defaultView.cancelAnimationFrame(rafId); |
4480 defaultView.cancelAnimationFrame(rafId); |
4467 }; |
4481 }; |
4468 }, []); |
4482 }, []); |
4469 } |
4483 } |
4470 |
4484 |
4471 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-delete.js |
4485 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-delete.js |
4472 /** |
4486 /** |
4473 * WordPress dependencies |
4487 * WordPress dependencies |
4474 */ |
4488 */ |
4475 |
4489 |
4476 |
4490 |
4481 |
4495 |
4482 |
4496 |
4483 |
4497 |
4484 |
4498 |
4485 function useDelete(props) { |
4499 function useDelete(props) { |
4486 const propsRef = Object(external_wp_element_["useRef"])(props); |
4500 const propsRef = (0,external_wp_element_namespaceObject.useRef)(props); |
4487 propsRef.current = props; |
4501 propsRef.current = props; |
4488 return Object(external_wp_compose_["useRefEffect"])(element => { |
4502 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { |
4489 function onKeyDown(event) { |
4503 function onKeyDown(event) { |
4490 const { |
4504 const { |
4491 keyCode |
4505 keyCode |
4492 } = event; |
4506 } = event; |
4493 const { |
4507 const { |
4498 |
4512 |
4499 if (event.defaultPrevented) { |
4513 if (event.defaultPrevented) { |
4500 return; |
4514 return; |
4501 } |
4515 } |
4502 |
4516 |
4503 if (keyCode !== external_wp_keycodes_["DELETE"] && keyCode !== external_wp_keycodes_["BACKSPACE"]) { |
4517 if (keyCode !== external_wp_keycodes_namespaceObject.DELETE && keyCode !== external_wp_keycodes_namespaceObject.BACKSPACE) { |
4504 return; |
4518 return; |
4505 } |
4519 } |
4506 |
4520 |
4507 const currentValue = createRecord(); |
4521 const currentValue = createRecord(); |
4508 const { |
4522 const { |
4509 start, |
4523 start, |
4510 end, |
4524 end, |
4511 text |
4525 text |
4512 } = currentValue; |
4526 } = currentValue; |
4513 const isReverse = keyCode === external_wp_keycodes_["BACKSPACE"]; // Always handle full content deletion ourselves. |
4527 const isReverse = keyCode === external_wp_keycodes_namespaceObject.BACKSPACE; // Always handle full content deletion ourselves. |
4514 |
4528 |
4515 if (start === 0 && end !== 0 && end === text.length) { |
4529 if (start === 0 && end !== 0 && end === text.length) { |
4516 handleChange(remove_remove(currentValue)); |
4530 handleChange(remove(currentValue)); |
4517 event.preventDefault(); |
4531 event.preventDefault(); |
4518 return; |
4532 return; |
4519 } |
4533 } |
4520 |
4534 |
4521 if (multilineTag) { |
4535 if (multilineTag) { |
4539 element.removeEventListener('keydown', onKeyDown); |
4553 element.removeEventListener('keydown', onKeyDown); |
4540 }; |
4554 }; |
4541 }, []); |
4555 }, []); |
4542 } |
4556 } |
4543 |
4557 |
4544 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/index.js |
4558 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-space.js |
4545 /** |
4559 /** |
4546 * WordPress dependencies |
4560 * WordPress dependencies |
4547 */ |
4561 */ |
4548 |
4562 |
4549 |
4563 |
4550 /** |
4564 /** |
4565 * For some elements like BUTTON and SUMMARY, the space key doesn't insert a |
|
4566 * space character in some browsers even though the element is editable. We have |
|
4567 * to manually insert a space and prevent default behaviour. |
|
4568 * |
|
4569 * DO NOT limit this behaviour to specific tag names! It would mean that this |
|
4570 * behaviour is not widely tested. If there's ever any problems, we should find |
|
4571 * a different solution entirely or remove it entirely. |
|
4572 */ |
|
4573 |
|
4574 function useSpace() { |
|
4575 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { |
|
4576 function onKeyDown(event) { |
|
4577 // Don't insert a space if default behaviour is prevented. |
|
4578 if (event.defaultPrevented) { |
|
4579 return; |
|
4580 } |
|
4581 |
|
4582 const { |
|
4583 keyCode, |
|
4584 altKey, |
|
4585 metaKey, |
|
4586 ctrlKey, |
|
4587 key |
|
4588 } = event; // Only consider the space key without modifiers pressed. |
|
4589 |
|
4590 if (keyCode !== external_wp_keycodes_namespaceObject.SPACE || altKey || metaKey || ctrlKey) { |
|
4591 return; |
|
4592 } // Disregard character composition that involves the Space key. |
|
4593 // |
|
4594 // @see https://github.com/WordPress/gutenberg/issues/35086 |
|
4595 // |
|
4596 // For example, to input a standalone diacritic (like ´ or `) using a |
|
4597 // keyboard with dead keys, one must first press the dead key and then |
|
4598 // press the Space key. |
|
4599 // |
|
4600 // Many operating systems handle this in such a way that the second |
|
4601 // KeyboardEvent contains the property `keyCode: 229`. According to the |
|
4602 // spec, 229 allows the system to indicate that an Input Method Editor |
|
4603 // (IDE) is processing some key input. |
|
4604 // |
|
4605 // However, Windows doesn't use `keyCode: 229` for dead key composition, |
|
4606 // instead emitting an event with values `keyCode: SPACE` and `key: '´'`. |
|
4607 // That is why checking the `key` property for values other than `SPACE` |
|
4608 // is important. |
|
4609 // |
|
4610 // This should serve as a reminder that the `KeyboardEvent.keyCode` |
|
4611 // attribute is officially deprecated and that we should consider more |
|
4612 // consistent interfaces. |
|
4613 |
|
4614 |
|
4615 if (key !== ' ') { |
|
4616 return; |
|
4617 } |
|
4618 |
|
4619 event.target.ownerDocument.execCommand('insertText', false, ' '); |
|
4620 event.preventDefault(); |
|
4621 } |
|
4622 |
|
4623 element.addEventListener('keydown', onKeyDown); |
|
4624 return () => { |
|
4625 element.removeEventListener('keydown', onKeyDown); |
|
4626 }; |
|
4627 }, []); |
|
4628 } |
|
4629 |
|
4630 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/index.js |
|
4631 /** |
|
4632 * WordPress dependencies |
|
4633 */ |
|
4634 |
|
4635 |
|
4636 |
|
4637 /** |
|
4551 * Internal dependencies |
4638 * Internal dependencies |
4552 */ |
4639 */ |
4553 |
4640 |
4554 |
4641 |
4555 |
4642 |
4561 |
4648 |
4562 |
4649 |
4563 |
4650 |
4564 |
4651 |
4565 |
4652 |
4566 function useRichText({ |
4653 function useRichText(_ref) { |
4567 value = '', |
4654 let { |
4568 selectionStart, |
4655 value = '', |
4569 selectionEnd, |
4656 selectionStart, |
4570 placeholder, |
4657 selectionEnd, |
4571 preserveWhiteSpace, |
4658 placeholder, |
4572 onSelectionChange, |
4659 preserveWhiteSpace, |
4573 onChange, |
4660 onSelectionChange, |
4574 __unstableMultilineTag: multilineTag, |
4661 onChange, |
4575 __unstableDisableFormats: disableFormats, |
4662 __unstableMultilineTag: multilineTag, |
4576 __unstableIsSelected: isSelected, |
4663 __unstableDisableFormats: disableFormats, |
4577 __unstableDependencies, |
4664 __unstableIsSelected: isSelected, |
4578 __unstableAfterParse, |
4665 __unstableDependencies = [], |
4579 __unstableBeforeSerialize, |
4666 __unstableAfterParse, |
4580 __unstableAddInvisibleFormats |
4667 __unstableBeforeSerialize, |
4581 }) { |
4668 __unstableAddInvisibleFormats |
4582 const [, forceRender] = Object(external_wp_element_["useReducer"])(() => ({})); |
4669 } = _ref; |
4583 const ref = Object(external_wp_element_["useRef"])(); |
4670 const registry = (0,external_wp_data_namespaceObject.useRegistry)(); |
4671 const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(() => ({})); |
|
4672 const ref = (0,external_wp_element_namespaceObject.useRef)(); |
|
4584 |
4673 |
4585 function createRecord() { |
4674 function createRecord() { |
4586 const { |
4675 const { |
4587 ownerDocument: { |
4676 ownerDocument: { |
4588 defaultView |
4677 defaultView |
4598 __unstableIsEditableTree: true, |
4687 __unstableIsEditableTree: true, |
4599 preserveWhiteSpace |
4688 preserveWhiteSpace |
4600 }); |
4689 }); |
4601 } |
4690 } |
4602 |
4691 |
4603 function applyRecord(newRecord, { |
4692 function applyRecord(newRecord) { |
4604 domOnly |
4693 let { |
4605 } = {}) { |
4694 domOnly |
4695 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
4606 apply({ |
4696 apply({ |
4607 value: newRecord, |
4697 value: newRecord, |
4608 current: ref.current, |
4698 current: ref.current, |
4609 multilineTag, |
4699 multilineTag, |
4610 multilineWrapperTags: multilineTag === 'li' ? ['ul', 'ol'] : undefined, |
4700 multilineWrapperTags: multilineTag === 'li' ? ['ul', 'ol'] : undefined, |
4613 placeholder |
4703 placeholder |
4614 }); |
4704 }); |
4615 } // Internal values are updated synchronously, unlike props and state. |
4705 } // Internal values are updated synchronously, unlike props and state. |
4616 |
4706 |
4617 |
4707 |
4618 const _value = Object(external_wp_element_["useRef"])(value); |
4708 const _value = (0,external_wp_element_namespaceObject.useRef)(value); |
4619 |
4709 |
4620 const record = Object(external_wp_element_["useRef"])(); |
4710 const record = (0,external_wp_element_namespaceObject.useRef)(); |
4621 |
4711 |
4622 function setRecordFromProps() { |
4712 function setRecordFromProps() { |
4623 _value.current = value; |
4713 _value.current = value; |
4624 record.current = create({ |
4714 record.current = create({ |
4625 html: value, |
4715 html: value, |
4631 if (disableFormats) { |
4721 if (disableFormats) { |
4632 record.current.formats = Array(value.length); |
4722 record.current.formats = Array(value.length); |
4633 record.current.replacements = Array(value.length); |
4723 record.current.replacements = Array(value.length); |
4634 } |
4724 } |
4635 |
4725 |
4636 record.current.formats = __unstableAfterParse(record.current); |
4726 if (__unstableAfterParse) { |
4727 record.current.formats = __unstableAfterParse(record.current); |
|
4728 } |
|
4729 |
|
4637 record.current.start = selectionStart; |
4730 record.current.start = selectionStart; |
4638 record.current.end = selectionEnd; |
4731 record.current.end = selectionEnd; |
4639 } |
4732 } |
4640 |
4733 |
4641 const hadSelectionUpdate = Object(external_wp_element_["useRef"])(false); |
4734 const hadSelectionUpdate = (0,external_wp_element_namespaceObject.useRef)(false); |
4642 |
4735 |
4643 if (!record.current) { |
4736 if (!record.current) { |
4644 setRecordFromProps(); |
4737 var _record$current, _record$current$forma, _record$current$forma2; |
4738 |
|
4739 setRecordFromProps(); // Sometimes formats are added programmatically and we need to make |
|
4740 // sure it's persisted to the block store / markup. If these formats |
|
4741 // are not applied, they could cause inconsistencies between the data |
|
4742 // in the visual editor and the frontend. Right now, it's only relevant |
|
4743 // to the `core/text-color` format, which is applied at runtime in |
|
4744 // certain circunstances. See the `__unstableFilterAttributeValue` |
|
4745 // function in `packages/format-library/src/text-color/index.js`. |
|
4746 // @todo find a less-hacky way of solving this. |
|
4747 |
|
4748 const hasRelevantInitFormat = ((_record$current = record.current) === null || _record$current === void 0 ? void 0 : (_record$current$forma = _record$current.formats[0]) === null || _record$current$forma === void 0 ? void 0 : (_record$current$forma2 = _record$current$forma[0]) === null || _record$current$forma2 === void 0 ? void 0 : _record$current$forma2.type) === 'core/text-color'; |
|
4749 |
|
4750 if (hasRelevantInitFormat) { |
|
4751 handleChangesUponInit(record.current); |
|
4752 } |
|
4645 } else if (selectionStart !== record.current.start || selectionEnd !== record.current.end) { |
4753 } else if (selectionStart !== record.current.start || selectionEnd !== record.current.end) { |
4646 hadSelectionUpdate.current = isSelected; |
4754 hadSelectionUpdate.current = isSelected; |
4647 record.current = { ...record.current, |
4755 record.current = { ...record.current, |
4648 start: selectionStart, |
4756 start: selectionStart, |
4649 end: selectionEnd |
4757 end: selectionEnd |
4656 * @param {Object} newRecord The record to sync and apply. |
4764 * @param {Object} newRecord The record to sync and apply. |
4657 */ |
4765 */ |
4658 |
4766 |
4659 |
4767 |
4660 function handleChange(newRecord) { |
4768 function handleChange(newRecord) { |
4769 record.current = newRecord; |
|
4661 applyRecord(newRecord); |
4770 applyRecord(newRecord); |
4662 |
4771 |
4663 if (disableFormats) { |
4772 if (disableFormats) { |
4664 _value.current = newRecord.text; |
4773 _value.current = newRecord.text; |
4665 } else { |
4774 } else { |
4666 _value.current = toHTMLString({ |
4775 _value.current = toHTMLString({ |
4667 value: { ...newRecord, |
4776 value: __unstableBeforeSerialize ? { ...newRecord, |
4668 formats: __unstableBeforeSerialize(newRecord) |
4777 formats: __unstableBeforeSerialize(newRecord) |
4669 }, |
4778 } : newRecord, |
4670 multilineTag, |
4779 multilineTag, |
4671 preserveWhiteSpace |
4780 preserveWhiteSpace |
4672 }); |
4781 }); |
4673 } |
4782 } |
4674 |
4783 |
4675 record.current = newRecord; |
|
4676 const { |
4784 const { |
4677 start, |
4785 start, |
4678 end, |
4786 end, |
4679 formats, |
4787 formats, |
4680 text |
4788 text |
4681 } = newRecord; // Selection must be updated first, so it is recorded in history when |
4789 } = newRecord; // Selection must be updated first, so it is recorded in history when |
4682 // the content change happens. |
4790 // the content change happens. |
4683 |
4791 // We batch both calls to only attempt to rerender once. |
4684 onSelectionChange(start, end); |
4792 |
4685 onChange(_value.current, { |
4793 registry.batch(() => { |
4686 __unstableFormats: formats, |
4794 onSelectionChange(start, end); |
4687 __unstableText: text |
4795 onChange(_value.current, { |
4796 __unstableFormats: formats, |
|
4797 __unstableText: text |
|
4798 }); |
|
4799 }); |
|
4800 forceRender(); |
|
4801 } |
|
4802 |
|
4803 function handleChangesUponInit(newRecord) { |
|
4804 record.current = newRecord; |
|
4805 _value.current = toHTMLString({ |
|
4806 value: __unstableBeforeSerialize ? { ...newRecord, |
|
4807 formats: __unstableBeforeSerialize(newRecord) |
|
4808 } : newRecord, |
|
4809 multilineTag, |
|
4810 preserveWhiteSpace |
|
4811 }); |
|
4812 const { |
|
4813 formats, |
|
4814 text |
|
4815 } = newRecord; |
|
4816 registry.batch(() => { |
|
4817 onChange(_value.current, { |
|
4818 __unstableFormats: formats, |
|
4819 __unstableText: text |
|
4820 }); |
|
4688 }); |
4821 }); |
4689 forceRender(); |
4822 forceRender(); |
4690 } |
4823 } |
4691 |
4824 |
4692 function applyFromProps() { |
4825 function applyFromProps() { |
4693 setRecordFromProps(); |
4826 setRecordFromProps(); |
4694 applyRecord(record.current); |
4827 applyRecord(record.current); |
4695 } |
4828 } |
4696 |
4829 |
4697 const didMount = Object(external_wp_element_["useRef"])(false); // Value updates must happen synchonously to avoid overwriting newer values. |
4830 const didMount = (0,external_wp_element_namespaceObject.useRef)(false); // Value updates must happen synchonously to avoid overwriting newer values. |
4698 |
4831 |
4699 Object(external_wp_element_["useLayoutEffect"])(() => { |
4832 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { |
4700 if (didMount.current && value !== _value.current) { |
4833 if (didMount.current && value !== _value.current) { |
4701 applyFromProps(); |
4834 applyFromProps(); |
4835 forceRender(); |
|
4702 } |
4836 } |
4703 }, [value]); // Value updates must happen synchonously to avoid overwriting newer values. |
4837 }, [value]); // Value updates must happen synchonously to avoid overwriting newer values. |
4704 |
4838 |
4705 Object(external_wp_element_["useLayoutEffect"])(() => { |
4839 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { |
4706 if (!hadSelectionUpdate.current) { |
4840 if (!hadSelectionUpdate.current) { |
4707 return; |
4841 return; |
4842 } |
|
4843 |
|
4844 if (ref.current.ownerDocument.activeElement !== ref.current) { |
|
4845 ref.current.focus(); |
|
4708 } |
4846 } |
4709 |
4847 |
4710 applyFromProps(); |
4848 applyFromProps(); |
4711 hadSelectionUpdate.current = false; |
4849 hadSelectionUpdate.current = false; |
4712 }, [hadSelectionUpdate.current]); |
4850 }, [hadSelectionUpdate.current]); |
4713 |
4851 const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, useDefaultStyle(), useBoundaryStyle({ |
4714 function focus() { |
|
4715 ref.current.focus(); |
|
4716 applyRecord(record.current); |
|
4717 } |
|
4718 |
|
4719 const mergedRefs = Object(external_wp_compose_["useMergeRefs"])([ref, useDefaultStyle(), useBoundaryStyle({ |
|
4720 record |
4852 record |
4721 }), useInlineWarning(), useCopyHandler({ |
4853 }), useCopyHandler({ |
4722 record, |
4854 record, |
4723 multilineTag, |
4855 multilineTag, |
4724 preserveWhiteSpace |
4856 preserveWhiteSpace |
4725 }), useSelectObject(), useFormatBoundaries({ |
4857 }), useSelectObject(), useFormatBoundaries({ |
4726 record, |
4858 record, |
4738 applyRecord, |
4870 applyRecord, |
4739 createRecord, |
4871 createRecord, |
4740 handleChange, |
4872 handleChange, |
4741 isSelected, |
4873 isSelected, |
4742 onSelectionChange |
4874 onSelectionChange |
4743 }), Object(external_wp_compose_["useRefEffect"])(() => { |
4875 }), useSpace(), (0,external_wp_compose_namespaceObject.useRefEffect)(() => { |
4744 applyFromProps(); |
4876 applyFromProps(); |
4745 didMount.current = true; |
4877 didMount.current = true; |
4746 }, [placeholder, ...__unstableDependencies])]); |
4878 }, [placeholder, ...__unstableDependencies])]); |
4747 return { |
4879 return { |
4748 value: record.current, |
4880 value: record.current, |
4749 onChange: handleChange, |
4881 onChange: handleChange, |
4750 onFocus: focus, |
|
4751 ref: mergedRefs |
4882 ref: mergedRefs |
4752 }; |
4883 }; |
4753 } |
4884 } |
4754 function __experimentalRichText() {} |
4885 function __experimentalRichText() {} |
4755 |
4886 |
4756 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/format-edit.js |
4887 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/format-edit.js |
4757 |
4888 |
4758 |
4889 |
4759 /** |
4890 /** |
4760 * Internal dependencies |
4891 * Internal dependencies |
4761 */ |
4892 */ |
4762 |
4893 |
4763 |
4894 |
4764 function FormatEdit({ |
4895 function FormatEdit(_ref) { |
4765 formatTypes, |
4896 let { |
4766 onChange, |
4897 formatTypes, |
4767 onFocus, |
4898 onChange, |
4768 value, |
4899 onFocus, |
4769 forwardedRef |
4900 value, |
4770 }) { |
4901 forwardedRef |
4902 } = _ref; |
|
4771 return formatTypes.map(settings => { |
4903 return formatTypes.map(settings => { |
4772 const { |
4904 const { |
4773 name, |
4905 name, |
4774 edit: Edit |
4906 edit: Edit |
4775 } = settings; |
4907 } = settings; |
4780 |
4912 |
4781 const activeFormat = getActiveFormat(value, name); |
4913 const activeFormat = getActiveFormat(value, name); |
4782 const isActive = activeFormat !== undefined; |
4914 const isActive = activeFormat !== undefined; |
4783 const activeObject = getActiveObject(value); |
4915 const activeObject = getActiveObject(value); |
4784 const isObjectActive = activeObject !== undefined && activeObject.type === name; |
4916 const isObjectActive = activeObject !== undefined && activeObject.type === name; |
4785 return Object(external_wp_element_["createElement"])(Edit, { |
4917 return (0,external_wp_element_namespaceObject.createElement)(Edit, { |
4786 key: name, |
4918 key: name, |
4787 isActive: isActive, |
4919 isActive: isActive, |
4788 activeAttributes: isActive ? activeFormat.attributes || {} : {}, |
4920 activeAttributes: isActive ? activeFormat.attributes || {} : {}, |
4789 isObjectActive: isObjectActive, |
4921 isObjectActive: isObjectActive, |
4790 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {}, |
4922 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {}, |
4794 contentRef: forwardedRef |
4926 contentRef: forwardedRef |
4795 }); |
4927 }); |
4796 }); |
4928 }); |
4797 } |
4929 } |
4798 |
4930 |
4799 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/index.js |
4931 ;// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/index.js |
4800 |
4932 |
4801 |
4933 |
4802 |
4934 |
4803 |
4935 |
4804 |
4936 |
4805 |
4937 |
4806 |
4938 |
4807 |
4939 |
4808 |
4940 |
4809 |
4941 |
4810 |
4942 |
4811 |
4943 |
4812 |
4944 |
4813 |
4945 |
4814 |
4946 |
4815 |
4947 |
4816 |
4948 |
4817 |
4949 |
4818 |
4950 |
4819 |
4951 |
4820 |
4952 |
4821 |
4953 |
4822 |
4954 |
4823 |
4955 |
4824 |
4956 |
4825 |
4957 |
4826 |
4958 |
4827 |
4959 |
4828 |
4960 |
4829 |
4961 |
4830 |
4962 |
4831 |
4963 |
4832 |
4964 |
4833 |
4965 |
4834 |
4966 |
4835 |
4967 |
4836 |
4968 |
4837 |
4969 (window.wp = window.wp || {}).richText = __webpack_exports__; |
4838 /***/ }) |
4970 /******/ })() |
4839 |
4971 ; |
4840 /******/ }); |