2018-12-13 23:41:57 -05:00
this [ "wp" ] = this [ "wp" ] || { } ; this [ "wp" ] [ "richText" ] =
/******/ ( function ( modules ) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = { } ;
/******/
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/
/******/ // Check if module is in cache
/******/ if ( installedModules [ moduleId ] ) {
/******/ return installedModules [ moduleId ] . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules [ moduleId ] = {
/******/ i : moduleId ,
/******/ l : false ,
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
/******/ modules [ moduleId ] . call ( module . exports , module , module . exports , _ _webpack _require _ _ ) ;
/******/
/******/ // Flag the module as loaded
/******/ module . l = true ;
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ _ _webpack _require _ _ . m = modules ;
/******/
/******/ // expose the module cache
/******/ _ _webpack _require _ _ . c = installedModules ;
/******/
/******/ // define getter function for harmony exports
/******/ _ _webpack _require _ _ . d = function ( exports , name , getter ) {
/******/ if ( ! _ _webpack _require _ _ . o ( exports , name ) ) {
/******/ Object . defineProperty ( exports , name , { enumerable : true , get : getter } ) ;
/******/ }
/******/ } ;
/******/
/******/ // define __esModule on exports
/******/ _ _webpack _require _ _ . r = function ( exports ) {
/******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
/******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
/******/ }
/******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
/******/ } ;
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ _ _webpack _require _ _ . t = function ( value , mode ) {
/******/ if ( mode & 1 ) value = _ _webpack _require _ _ ( value ) ;
/******/ if ( mode & 8 ) return value ;
/******/ if ( ( mode & 4 ) && typeof value === 'object' && value && value . _ _esModule ) return value ;
/******/ var ns = Object . create ( null ) ;
/******/ _ _webpack _require _ _ . r ( ns ) ;
/******/ Object . defineProperty ( ns , 'default' , { enumerable : true , value : value } ) ;
/******/ if ( mode & 2 && typeof value != 'string' ) for ( var key in value ) _ _webpack _require _ _ . d ( ns , key , function ( key ) { return value [ key ] ; } . bind ( null , key ) ) ;
/******/ return ns ;
/******/ } ;
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ _ _webpack _require _ _ . n = function ( module ) {
/******/ var getter = module && module . _ _esModule ?
/******/ function getDefault ( ) { return module [ 'default' ] ; } :
/******/ function getModuleExports ( ) { return module ; } ;
/******/ _ _webpack _require _ _ . d ( getter , 'a' , getter ) ;
/******/ return getter ;
/******/ } ;
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ _ _webpack _require _ _ . o = function ( object , property ) { return Object . prototype . hasOwnProperty . call ( object , property ) ; } ;
/******/
/******/ // __webpack_public_path__
/******/ _ _webpack _require _ _ . p = "" ;
/******/
/******/
/******/ // Load entry module and return exports
2020-03-23 19:40:19 -04:00
/******/ return _ _webpack _require _ _ ( _ _webpack _require _ _ . s = 424 ) ;
2018-12-13 23:41:57 -05:00
/******/ } )
/************************************************************************/
/******/ ( {
2018-12-17 22:14:52 -05:00
/***/ 0 :
/***/ ( function ( module , exports ) {
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
( function ( ) { module . exports = this [ "wp" ] [ "element" ] ; } ( ) ) ;
2018-12-13 23:41:57 -05:00
/***/ } ) ,
2020-02-10 17:33:27 -05:00
/***/ 11 :
2020-01-08 06:57:23 -05:00
/***/ ( function ( module , exports , _ _webpack _require _ _ ) {
2018-12-13 23:41:57 -05:00
2020-01-08 06:57:23 -05:00
var _ _WEBPACK _AMD _DEFINE _ARRAY _ _ , _ _WEBPACK _AMD _DEFINE _RESULT _ _ ; / * !
Copyright ( c ) 2017 Jed Watson .
Licensed under the MIT License ( MIT ) , see
http : //jedwatson.github.io/classnames
* /
/* global define */
( function ( ) {
'use strict' ;
var hasOwn = { } . hasOwnProperty ;
function classNames ( ) {
var classes = [ ] ;
for ( var i = 0 ; i < arguments . length ; i ++ ) {
var arg = arguments [ i ] ;
if ( ! arg ) continue ;
var argType = typeof arg ;
if ( argType === 'string' || argType === 'number' ) {
classes . push ( arg ) ;
} else if ( Array . isArray ( arg ) && arg . length ) {
var inner = classNames . apply ( null , arg ) ;
if ( inner ) {
classes . push ( inner ) ;
}
} else if ( argType === 'object' ) {
for ( var key in arg ) {
if ( hasOwn . call ( arg , key ) && arg [ key ] ) {
classes . push ( key ) ;
}
}
}
}
return classes . join ( ' ' ) ;
}
if ( true && module . exports ) {
classNames . default = classNames ;
module . exports = classNames ;
} else if ( true ) {
// register as 'classnames', consistent with npm package name
! ( _ _WEBPACK _AMD _DEFINE _ARRAY _ _ = [ ] , _ _WEBPACK _AMD _DEFINE _RESULT _ _ = ( function ( ) {
return classNames ;
} ) . apply ( exports , _ _WEBPACK _AMD _DEFINE _ARRAY _ _ ) ,
_ _WEBPACK _AMD _DEFINE _RESULT _ _ !== undefined && ( module . exports = _ _WEBPACK _AMD _DEFINE _RESULT _ _ ) ) ;
} else { }
} ( ) ) ;
2018-12-13 23:41:57 -05:00
2019-09-19 11:19:18 -04:00
/***/ } ) ,
2020-02-10 17:33:27 -05:00
/***/ 12 :
2019-09-19 11:19:18 -04:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
2020-01-22 17:06:21 -05:00
"use strict" ;
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _extends ; } ) ;
function _extends ( ) {
_extends = Object . assign || function ( target ) {
for ( var i = 1 ; i < arguments . length ; i ++ ) {
var source = arguments [ i ] ;
for ( var key in source ) {
if ( Object . prototype . hasOwnProperty . call ( source , key ) ) {
target [ key ] = source [ key ] ;
}
}
}
return target ;
} ;
return _extends . apply ( this , arguments ) ;
}
/***/ } ) ,
2020-02-10 17:33:27 -05:00
/***/ 13 :
2020-01-22 17:06:21 -05:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
2019-09-19 11:19:18 -04:00
"use strict" ;
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _createClass ; } ) ;
function _defineProperties ( target , props ) {
for ( var i = 0 ; i < props . length ; i ++ ) {
var descriptor = props [ i ] ;
descriptor . enumerable = descriptor . enumerable || false ;
descriptor . configurable = true ;
if ( "value" in descriptor ) descriptor . writable = true ;
Object . defineProperty ( target , descriptor . key , descriptor ) ;
}
}
function _createClass ( Constructor , protoProps , staticProps ) {
if ( protoProps ) _defineProperties ( Constructor . prototype , protoProps ) ;
if ( staticProps ) _defineProperties ( Constructor , staticProps ) ;
return Constructor ;
}
/***/ } ) ,
2020-02-10 17:33:27 -05:00
/***/ 14 :
2019-09-19 11:19:18 -04:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _classCallCheck ; } ) ;
function _classCallCheck ( instance , Constructor ) {
if ( ! ( instance instanceof Constructor ) ) {
throw new TypeError ( "Cannot call a class as a function" ) ;
}
}
/***/ } ) ,
2020-02-10 17:33:27 -05:00
/***/ 15 :
2019-09-19 11:19:18 -04:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _possibleConstructorReturn ; } ) ;
2020-03-23 19:40:19 -04:00
/* harmony import */ var _helpers _esm _typeof _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( 34 ) ;
2020-01-22 17:06:21 -05:00
/* harmony import */ var _assertThisInitialized _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _ ( 7 ) ;
2019-09-19 11:19:18 -04:00
function _possibleConstructorReturn ( self , call ) {
if ( call && ( Object ( _helpers _esm _typeof _ _WEBPACK _IMPORTED _MODULE _0 _ _ [ /* default */ "a" ] ) ( call ) === "object" || typeof call === "function" ) ) {
return call ;
}
return Object ( _assertThisInitialized _ _WEBPACK _IMPORTED _MODULE _1 _ _ [ /* default */ "a" ] ) ( self ) ;
}
/***/ } ) ,
2020-02-10 17:33:27 -05:00
/***/ 16 :
2019-09-19 11:19:18 -04:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _getPrototypeOf ; } ) ;
function _getPrototypeOf ( o ) {
_getPrototypeOf = Object . setPrototypeOf ? Object . getPrototypeOf : function _getPrototypeOf ( o ) {
return o . _ _proto _ _ || Object . getPrototypeOf ( o ) ;
} ;
return _getPrototypeOf ( o ) ;
}
/***/ } ) ,
2020-02-10 17:33:27 -05:00
/***/ 17 :
2019-09-19 11:19:18 -04:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
function _setPrototypeOf ( o , p ) {
_setPrototypeOf = Object . setPrototypeOf || function _setPrototypeOf ( o , p ) {
o . _ _proto _ _ = p ;
return o ;
} ;
return _setPrototypeOf ( o , p ) ;
}
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _inherits ; } ) ;
function _inherits ( subClass , superClass ) {
if ( typeof superClass !== "function" && superClass !== null ) {
throw new TypeError ( "Super expression must either be null or a function" ) ;
}
subClass . prototype = Object . create ( superClass && superClass . prototype , {
constructor : {
value : subClass ,
writable : true ,
configurable : true
}
} ) ;
if ( superClass ) _setPrototypeOf ( subClass , superClass ) ;
}
/***/ } ) ,
2020-02-10 17:33:27 -05:00
/***/ 18 :
2018-12-16 23:52:00 -05:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
2018-12-13 23:41:57 -05:00
"use strict" ;
2020-03-23 19:40:19 -04:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
var arrayLikeToArray = _ _webpack _require _ _ ( 25 ) ;
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
2018-12-13 23:41:57 -05:00
2020-03-23 19:40:19 -04:00
function _arrayWithoutHoles ( arr ) {
if ( Array . isArray ( arr ) ) return Object ( arrayLikeToArray [ "a" /* default */ ] ) ( arr ) ;
2018-12-17 22:14:52 -05:00
}
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
2020-03-23 19:40:19 -04:00
var iterableToArray = _ _webpack _require _ _ ( 35 ) ;
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
var unsupportedIterableToArray = _ _webpack _require _ _ ( 27 ) ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
2018-12-13 23:41:57 -05:00
function _nonIterableSpread ( ) {
2020-03-23 19:40:19 -04:00
throw new TypeError ( "Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ) ;
2018-12-13 23:41:57 -05:00
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _toConsumableArray ; } ) ;
2018-12-13 23:41:57 -05:00
2020-03-23 19:40:19 -04:00
2018-12-17 22:14:52 -05:00
function _toConsumableArray ( arr ) {
2020-03-23 19:40:19 -04:00
return _arrayWithoutHoles ( arr ) || Object ( iterableToArray [ "a" /* default */ ] ) ( arr ) || Object ( unsupportedIterableToArray [ "a" /* default */ ] ) ( arr ) || _nonIterableSpread ( ) ;
2018-12-13 23:41:57 -05:00
}
/***/ } ) ,
2018-12-17 22:14:52 -05:00
/***/ 2 :
/***/ ( function ( module , exports ) {
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
( function ( ) { module . exports = this [ "lodash" ] ; } ( ) ) ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
/***/ } ) ,
2018-12-13 23:41:57 -05:00
2020-03-16 18:07:16 -04:00
/***/ 22 :
2020-02-06 16:03:31 -05:00
/***/ ( function ( module , exports ) {
2018-12-13 23:41:57 -05:00
2020-02-06 16:03:31 -05:00
( function ( ) { module . exports = this [ "wp" ] [ "keycodes" ] ; } ( ) ) ;
2018-12-13 23:41:57 -05:00
/***/ } ) ,
2020-03-23 19:40:19 -04:00
/***/ 25 :
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _arrayLikeToArray ; } ) ;
function _arrayLikeToArray ( arr , len ) {
if ( len == null || len > arr . length ) len = arr . length ;
for ( var i = 0 , arr2 = new Array ( len ) ; i < len ; i ++ ) {
arr2 [ i ] = arr [ i ] ;
}
return arr2 ;
}
/***/ } ) ,
/***/ 27 :
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _unsupportedIterableToArray ; } ) ;
/* harmony import */ var _arrayLikeToArray _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( 25 ) ;
function _unsupportedIterableToArray ( o , minLen ) {
if ( ! o ) return ;
if ( typeof o === "string" ) return Object ( _arrayLikeToArray _ _WEBPACK _IMPORTED _MODULE _0 _ _ [ /* default */ "a" ] ) ( o , minLen ) ;
var n = Object . prototype . toString . call ( o ) . slice ( 8 , - 1 ) ;
if ( n === "Object" && o . constructor ) n = o . constructor . name ;
if ( n === "Map" || n === "Set" ) return Array . from ( n ) ;
if ( n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/ . test ( n ) ) return Object ( _arrayLikeToArray _ _WEBPACK _IMPORTED _MODULE _0 _ _ [ /* default */ "a" ] ) ( o , minLen ) ;
}
/***/ } ) ,
/***/ 34 :
2019-09-19 11:19:18 -04:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _typeof ; } ) ;
function _typeof ( obj ) {
2020-02-06 16:03:31 -05:00
"@babel/helpers - typeof" ;
2020-01-08 06:57:23 -05:00
if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) {
2019-09-19 11:19:18 -04:00
_typeof = function _typeof ( obj ) {
2020-01-08 06:57:23 -05:00
return typeof obj ;
2019-09-19 11:19:18 -04:00
} ;
} else {
_typeof = function _typeof ( obj ) {
2020-01-08 06:57:23 -05:00
return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ;
2019-09-19 11:19:18 -04:00
} ;
}
return _typeof ( obj ) ;
}
/***/ } ) ,
2020-03-23 19:40:19 -04:00
/***/ 35 :
2020-03-16 18:07:16 -04:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _iterableToArray ; } ) ;
function _iterableToArray ( iter ) {
2020-03-23 19:40:19 -04:00
if ( typeof Symbol !== "undefined" && Symbol . iterator in Object ( iter ) ) return Array . from ( iter ) ;
2020-03-16 18:07:16 -04:00
}
/***/ } ) ,
2020-03-23 19:40:19 -04:00
/***/ 37 :
2020-01-08 06:57:23 -05:00
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = this [ "wp" ] [ "deprecated" ] ; } ( ) ) ;
/***/ } ) ,
2020-03-23 19:40:19 -04:00
/***/ 4 :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = this [ "wp" ] [ "data" ] ; } ( ) ) ;
/***/ } ) ,
/***/ 40 :
2019-03-07 04:09:59 -05:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
2020-01-22 17:06:21 -05:00
var LEAF _KEY , hasWeakMap ;
2019-03-07 04:09:59 -05:00
/ * *
2020-01-22 17:06:21 -05:00
* Arbitrary value used as key for referencing cache object in WeakMap tree .
*
* @ type { Object }
2019-03-07 04:09:59 -05:00
* /
2020-01-22 17:06:21 -05:00
LEAF _KEY = { } ;
2019-03-07 04:09:59 -05:00
/ * *
2020-01-22 17:06:21 -05:00
* Whether environment supports WeakMap .
*
* @ type { boolean }
2019-03-07 04:09:59 -05:00
* /
2020-01-22 17:06:21 -05:00
hasWeakMap = typeof WeakMap !== 'undefined' ;
2019-03-07 04:09:59 -05:00
/ * *
2020-01-22 17:06:21 -05:00
* Returns the first argument as the sole entry in an array .
2019-03-07 04:09:59 -05:00
*
2020-01-22 17:06:21 -05:00
* @ param { * } value Value to return .
2019-03-07 04:09:59 -05:00
*
2020-01-22 17:06:21 -05:00
* @ return { Array } Value returned as entry in array .
2019-03-07 04:09:59 -05:00
* /
2020-01-22 17:06:21 -05:00
function arrayOf ( value ) {
return [ value ] ;
2019-03-07 04:09:59 -05:00
}
/ * *
2020-01-22 17:06:21 -05:00
* Returns true if the value passed is object - like , or false otherwise . A value
* is object - like if it can support property assignment , e . g . object or array .
2019-03-07 04:09:59 -05:00
*
2020-01-22 17:06:21 -05:00
* @ param { * } value Value to test .
2019-03-07 04:09:59 -05:00
*
2020-01-22 17:06:21 -05:00
* @ return { boolean } Whether value is object - like .
2019-03-07 04:09:59 -05:00
* /
2020-01-22 17:06:21 -05:00
function isObjectLike ( value ) {
return ! ! value && 'object' === typeof value ;
}
2019-03-07 04:09:59 -05:00
/ * *
2020-01-22 17:06:21 -05:00
* Creates and returns a new cache object .
2019-03-07 04:09:59 -05:00
*
2020-01-22 17:06:21 -05:00
* @ return { Object } Cache object .
2019-03-07 04:09:59 -05:00
* /
2020-01-22 17:06:21 -05:00
function createCache ( ) {
var cache = {
clear : function ( ) {
cache . head = null ;
} ,
} ;
2019-03-07 04:09:59 -05:00
2020-01-22 17:06:21 -05:00
return cache ;
2019-03-07 04:09:59 -05:00
}
/ * *
2020-01-22 17:06:21 -05:00
* Returns true if entries within the two arrays are strictly equal by
* reference from a starting index .
2019-03-07 04:09:59 -05:00
*
2020-01-22 17:06:21 -05:00
* @ param { Array } a First array .
* @ param { Array } b Second array .
* @ param { number } fromIndex Index from which to start comparison .
*
* @ return { boolean } Whether arrays are shallowly equal .
2019-03-07 04:09:59 -05:00
* /
2020-01-22 17:06:21 -05:00
function isShallowEqual ( a , b , fromIndex ) {
var i ;
2019-03-07 04:09:59 -05:00
2020-01-22 17:06:21 -05:00
if ( a . length !== b . length ) {
return false ;
}
2019-03-07 04:09:59 -05:00
2020-01-22 17:06:21 -05:00
for ( i = fromIndex ; i < a . length ; i ++ ) {
if ( a [ i ] !== b [ i ] ) {
return false ;
}
}
2019-03-07 04:09:59 -05:00
2020-01-22 17:06:21 -05:00
return true ;
2019-03-07 04:09:59 -05:00
}
/ * *
2020-01-22 17:06:21 -05:00
* Returns a memoized selector function . The getDependants function argument is
* called before the memoized selector and is expected to return an immutable
* reference or array of references on which the selector depends for computing
* its own return value . The memoize cache is preserved only as long as those
* dependant references remain the same . If getDependants returns a different
* reference ( s ) , the cache is cleared and the selector value regenerated .
2019-03-07 04:09:59 -05:00
*
2020-01-22 17:06:21 -05:00
* @ param { Function } selector Selector function .
* @ param { Function } getDependants Dependant getter returning an immutable
* reference or array of reference used in
* cache bust consideration .
2019-03-07 04:09:59 -05:00
*
2020-01-22 17:06:21 -05:00
* @ return { Function } Memoized selector .
2019-03-07 04:09:59 -05:00
* /
2020-01-22 17:06:21 -05:00
/* harmony default export */ _ _webpack _exports _ _ [ "a" ] = ( function ( selector , getDependants ) {
var rootCache , getCache ;
2019-03-07 04:09:59 -05:00
2020-01-22 17:06:21 -05:00
// Use object source as dependant if getter not provided
if ( ! getDependants ) {
getDependants = arrayOf ;
}
/ * *
* Returns the root cache . If WeakMap is supported , this is assigned to the
* root WeakMap cache set , otherwise it is a shared instance of the default
* cache object .
*
* @ return { ( WeakMap | Object ) } Root cache object .
* /
function getRootCache ( ) {
return rootCache ;
}
/ * *
* Returns the cache for a given dependants array . When possible , a WeakMap
* will be used to create a unique cache for each set of dependants . This
* is feasible due to the nature of WeakMap in allowing garbage collection
* to occur on entries where the key object is no longer referenced . Since
* WeakMap requires the key to be an object , this is only possible when the
* dependant is object - like . The root cache is created as a hierarchy where
* each top - level key is the first entry in a dependants set , the value a
* WeakMap where each key is the next dependant , and so on . This continues
* so long as the dependants are object - like . If no dependants are object -
* like , then the cache is shared across all invocations .
*
* @ see isObjectLike
*
* @ param { Array } dependants Selector dependants .
*
* @ return { Object } Cache object .
* /
function getWeakMapCache ( dependants ) {
var caches = rootCache ,
isUniqueByDependants = true ,
i , dependant , map , cache ;
for ( i = 0 ; i < dependants . length ; i ++ ) {
dependant = dependants [ i ] ;
// Can only compose WeakMap from object-like key.
if ( ! isObjectLike ( dependant ) ) {
isUniqueByDependants = false ;
break ;
}
// Does current segment of cache already have a WeakMap?
if ( caches . has ( dependant ) ) {
// Traverse into nested WeakMap.
caches = caches . get ( dependant ) ;
} else {
// Create, set, and traverse into a new one.
map = new WeakMap ( ) ;
caches . set ( dependant , map ) ;
caches = map ;
}
}
// We use an arbitrary (but consistent) object as key for the last item
// in the WeakMap to serve as our running cache.
if ( ! caches . has ( LEAF _KEY ) ) {
cache = createCache ( ) ;
cache . isUniqueByDependants = isUniqueByDependants ;
caches . set ( LEAF _KEY , cache ) ;
}
return caches . get ( LEAF _KEY ) ;
}
// Assign cache handler by availability of WeakMap
getCache = hasWeakMap ? getWeakMapCache : getRootCache ;
/ * *
* Resets root memoization cache .
* /
function clear ( ) {
rootCache = hasWeakMap ? new WeakMap ( ) : createCache ( ) ;
}
// eslint-disable-next-line jsdoc/check-param-names
/ * *
* The augmented selector call , considering first whether dependants have
* changed before passing it to underlying memoize function .
*
* @ param { Object } source Source object for derivation .
* @ param { ... * } extraArgs Additional arguments to pass to selector .
*
* @ return { * } Selector result .
* /
function callSelector ( /* source, ...extraArgs */ ) {
var len = arguments . length ,
cache , node , i , args , dependants ;
// Create copy of arguments (avoid leaking deoptimization).
args = new Array ( len ) ;
for ( i = 0 ; i < len ; i ++ ) {
args [ i ] = arguments [ i ] ;
}
dependants = getDependants . apply ( null , args ) ;
cache = getCache ( dependants ) ;
// If not guaranteed uniqueness by dependants (primitive type or lack
// of WeakMap support), shallow compare against last dependants and, if
// references have changed, destroy cache to recalculate result.
if ( ! cache . isUniqueByDependants ) {
if ( cache . lastDependants && ! isShallowEqual ( dependants , cache . lastDependants , 0 ) ) {
cache . clear ( ) ;
}
cache . lastDependants = dependants ;
}
node = cache . head ;
while ( node ) {
// Check whether node arguments match arguments
if ( ! isShallowEqual ( node . args , args , 1 ) ) {
node = node . next ;
continue ;
}
// At this point we can assume we've found a match
// Surface matched node to head if not already
if ( node !== cache . head ) {
// Adjust siblings to point to each other.
node . prev . next = node . next ;
if ( node . next ) {
node . next . prev = node . prev ;
}
node . next = cache . head ;
node . prev = null ;
cache . head . prev = node ;
cache . head = node ;
}
// Return immediately
return node . val ;
}
// No cached value found. Continue to insertion phase:
node = {
// Generate the result from original function
val : selector . apply ( null , args ) ,
} ;
// Avoid including the source object in the cache.
args [ 0 ] = null ;
node . args = args ;
// Don't need to check whether node is already head, since it would
// have been returned above already if it was
// Shift existing head down list
if ( cache . head ) {
cache . head . prev = node ;
node . next = cache . head ;
}
cache . head = node ;
return node . val ;
}
callSelector . getDependants = getDependants ;
callSelector . clear = clear ;
clear ( ) ;
return callSelector ;
} ) ;
/***/ } ) ,
2020-03-23 19:40:19 -04:00
/***/ 424 :
2020-01-22 17:06:21 -05:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
var selectors _namespaceObject = { } ;
_ _webpack _require _ _ . r ( selectors _namespaceObject ) ;
_ _webpack _require _ _ . d ( selectors _namespaceObject , "getFormatTypes" , function ( ) { return getFormatTypes ; } ) ;
_ _webpack _require _ _ . d ( selectors _namespaceObject , "getFormatType" , function ( ) { return getFormatType ; } ) ;
_ _webpack _require _ _ . d ( selectors _namespaceObject , "getFormatTypeForBareElement" , function ( ) { return getFormatTypeForBareElement ; } ) ;
_ _webpack _require _ _ . d ( selectors _namespaceObject , "getFormatTypeForClassName" , function ( ) { return getFormatTypeForClassName ; } ) ;
var actions _namespaceObject = { } ;
_ _webpack _require _ _ . r ( actions _namespaceObject ) ;
_ _webpack _require _ _ . d ( actions _namespaceObject , "addFormatTypes" , function ( ) { return addFormatTypes ; } ) ;
_ _webpack _require _ _ . d ( actions _namespaceObject , "removeFormatTypes" , function ( ) { return removeFormatTypes ; } ) ;
// EXTERNAL MODULE: external {"this":["wp","data"]}
var external _this _wp _data _ = _ _webpack _require _ _ ( 4 ) ;
2020-02-06 16:03:31 -05:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
var defineProperty = _ _webpack _require _ _ ( 5 ) ;
2020-01-22 17:06:21 -05:00
// EXTERNAL MODULE: external {"this":"lodash"}
var external _this _lodash _ = _ _webpack _require _ _ ( 2 ) ;
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/reducer.js
2020-02-06 16:03:31 -05:00
function ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2020-01-22 17:06:21 -05:00
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
/ * *
* Reducer managing the format types
*
* @ param { Object } state Current state .
* @ param { Object } action Dispatched action .
*
* @ return { Object } Updated state .
* /
function reducer _formatTypes ( ) {
var state = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
var action = arguments . length > 1 ? arguments [ 1 ] : undefined ;
switch ( action . type ) {
case 'ADD_FORMAT_TYPES' :
2020-02-06 16:03:31 -05:00
return _objectSpread ( { } , state , { } , Object ( external _this _lodash _ [ "keyBy" ] ) ( action . formatTypes , 'name' ) ) ;
2020-01-22 17:06:21 -05:00
case 'REMOVE_FORMAT_TYPES' :
return Object ( external _this _lodash _ [ "omit" ] ) ( state , action . names ) ;
}
return state ;
}
/* harmony default export */ var reducer = ( Object ( external _this _wp _data _ [ "combineReducers" ] ) ( {
formatTypes : reducer _formatTypes
} ) ) ;
// EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js
2020-03-23 19:40:19 -04:00
var rememo = _ _webpack _require _ _ ( 40 ) ;
2020-01-22 17:06:21 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js
/ * *
* External dependencies
* /
/ * *
* Returns all the available format types .
*
* @ param { Object } state Data state .
*
* @ return { Array } Format types .
* /
var getFormatTypes = Object ( rememo [ "a" /* default */ ] ) ( function ( state ) {
return Object . values ( state . formatTypes ) ;
} , function ( state ) {
return [ state . formatTypes ] ;
} ) ;
/ * *
* Returns a format type by name .
*
* @ param { Object } state Data state .
* @ param { string } name Format type name .
*
* @ return { Object ? } Format type .
* /
function getFormatType ( state , name ) {
return state . formatTypes [ name ] ;
}
/ * *
* Gets the format type , if any , that can handle a bare element ( without a
* data - format - type attribute ) , given the tag name of this element .
*
* @ param { Object } state Data state .
* @ param { string } bareElementTagName The tag name of the element to find a
* format type for .
* @ return { ? Object } Format type .
* /
function getFormatTypeForBareElement ( state , bareElementTagName ) {
return Object ( external _this _lodash _ [ "find" ] ) ( getFormatTypes ( state ) , function ( _ref ) {
var className = _ref . className ,
tagName = _ref . tagName ;
return className === null && bareElementTagName === tagName ;
} ) ;
}
/ * *
* Gets the format type , if any , that can handle an element , given its classes .
*
* @ param { Object } state Data state .
* @ param { string } elementClassName The classes of the element to find a format
* type for .
* @ return { ? Object } Format type .
* /
function getFormatTypeForClassName ( state , elementClassName ) {
return Object ( external _this _lodash _ [ "find" ] ) ( getFormatTypes ( state ) , function ( _ref2 ) {
var className = _ref2 . className ;
if ( className === null ) {
return false ;
}
return " " . concat ( elementClassName , " " ) . indexOf ( " " . concat ( className , " " ) ) >= 0 ;
} ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/actions.js
/ * *
* External dependencies
* /
/ * *
* Returns an action object used in signalling that format types have been
* added .
*
* @ param { Array | Object } formatTypes Format types received .
*
* @ return { Object } Action object .
* /
function addFormatTypes ( formatTypes ) {
return {
type : 'ADD_FORMAT_TYPES' ,
formatTypes : Object ( external _this _lodash _ [ "castArray" ] ) ( formatTypes )
} ;
}
/ * *
* Returns an action object used to remove a registered format type .
*
* @ param { string | Array } names Format name .
*
* @ return { Object } Action object .
* /
2019-03-07 04:09:59 -05:00
function removeFormatTypes ( names ) {
2018-12-17 22:14:52 -05:00
return {
type : 'REMOVE_FORMAT_TYPES' ,
2020-01-03 08:17:24 -05:00
names : Object ( external _this _lodash _ [ "castArray" ] ) ( names )
2018-12-17 22:14:52 -05:00
} ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/index.js
2018-12-14 06:02:53 -05:00
/ * *
2018-12-16 23:52:00 -05:00
* WordPress dependencies
2018-12-14 06:02:53 -05:00
* /
2018-12-13 23:41:57 -05:00
/ * *
* Internal dependencies
* /
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
Object ( external _this _wp _data _ [ "registerStore" ] ) ( 'core/rich-text' , {
reducer : reducer ,
selectors : selectors _namespaceObject ,
actions : actions _namespaceObject
} ) ;
2018-12-14 06:02:53 -05:00
2019-03-21 08:48:00 -04:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
2020-02-10 17:33:27 -05:00
var toConsumableArray = _ _webpack _require _ _ ( 18 ) ;
2019-03-21 08:48:00 -04:00
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-format-equal.js
2018-12-13 23:41:57 -05:00
/ * *
2018-12-17 22:14:52 -05:00
* Optimised equality check for format objects .
*
* @ param { ? Object } format1 Format to compare .
* @ param { ? Object } format2 Format to compare .
*
* @ return { boolean } True if formats are equal , false if not .
2018-12-13 23:41:57 -05:00
* /
2018-12-17 22:14:52 -05:00
function isFormatEqual ( format1 , format2 ) {
// Both not defined.
if ( format1 === format2 ) {
return true ;
} // Either not defined.
2018-12-13 23:41:57 -05:00
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( ! format1 || ! format2 ) {
return false ;
2018-12-14 06:02:53 -05:00
}
2018-12-17 22:14:52 -05:00
if ( format1 . type !== format2 . type ) {
return false ;
}
2018-12-16 23:52:00 -05:00
2018-12-17 22:14:52 -05:00
var attributes1 = format1 . attributes ;
var attributes2 = format2 . attributes ; // Both not defined.
2018-12-16 23:52:00 -05:00
2018-12-17 22:14:52 -05:00
if ( attributes1 === attributes2 ) {
return true ;
} // Either not defined.
2018-12-16 23:52:00 -05:00
2018-12-17 22:14:52 -05:00
if ( ! attributes1 || ! attributes2 ) {
return false ;
2018-12-16 23:52:00 -05:00
}
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
var keys1 = Object . keys ( attributes1 ) ;
var keys2 = Object . keys ( attributes2 ) ;
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( keys1 . length !== keys2 . length ) {
return false ;
2018-12-14 06:02:53 -05:00
}
2018-12-17 22:14:52 -05:00
var length = keys1 . length ; // Optimise for speed.
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
for ( var i = 0 ; i < length ; i ++ ) {
var name = keys1 [ i ] ;
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( attributes1 [ name ] !== attributes2 [ name ] ) {
return false ;
2018-12-14 06:02:53 -05:00
}
}
2018-12-17 22:14:52 -05:00
return true ;
2018-12-14 06:02:53 -05:00
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/normalise-formats.js
2019-03-21 08:48:00 -04:00
2020-02-06 16:03:31 -05:00
function normalise _formats _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function normalise _formats _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { normalise _formats _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { normalise _formats _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2018-12-13 23:41:57 -05:00
/ * *
2018-12-17 22:14:52 -05:00
* Internal dependencies
* /
/ * *
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
* Normalises formats : ensures subsequent adjacent equal formats have the same
* reference .
2018-12-13 23:41:57 -05:00
*
2019-03-21 08:48:00 -04:00
* @ param { Object } value Value to normalise formats of .
2018-12-13 23:41:57 -05:00
*
2018-12-17 22:14:52 -05:00
* @ return { Object } New value with normalised formats .
2018-12-13 23:41:57 -05:00
* /
2019-03-21 08:48:00 -04:00
function normaliseFormats ( value ) {
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
var newFormats = value . formats . slice ( ) ;
newFormats . forEach ( function ( formatsAtIndex , index ) {
var formatsAtPreviousIndex = newFormats [ index - 1 ] ;
2018-12-13 23:41:57 -05:00
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
if ( formatsAtPreviousIndex ) {
var newFormatsAtIndex = formatsAtIndex . slice ( ) ;
newFormatsAtIndex . forEach ( function ( format , formatIndex ) {
var previousFormat = formatsAtPreviousIndex [ formatIndex ] ;
2018-12-13 23:41:57 -05:00
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
if ( isFormatEqual ( format , previousFormat ) ) {
newFormatsAtIndex [ formatIndex ] = previousFormat ;
}
} ) ;
newFormats [ index ] = newFormatsAtIndex ;
}
2018-12-17 22:14:52 -05:00
} ) ;
2020-02-06 16:03:31 -05:00
return normalise _formats _objectSpread ( { } , value , {
2019-03-21 08:48:00 -04:00
formats : newFormats
} ) ;
2018-12-17 22:14:52 -05:00
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/apply-format.js
2019-03-21 08:48:00 -04:00
2020-02-06 16:03:31 -05:00
function apply _format _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function apply _format _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { apply _format _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { apply _format _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2018-12-17 22:14:52 -05:00
/ * *
* External dependencies
* /
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
/ * *
* Internal dependencies
* /
2018-12-13 23:41:57 -05:00
2019-09-19 11:19:18 -04:00
function replace ( array , index , value ) {
array = array . slice ( ) ;
array [ index ] = value ;
return array ;
}
2018-12-13 23:41:57 -05:00
/ * *
2018-12-17 22:14:52 -05:00
* Apply a format object to a Rich Text value from the given ` startIndex ` to the
* given ` endIndex ` . Indices are retrieved from the selection if none are
* provided .
2018-12-13 23:41:57 -05:00
*
2019-03-21 08:48:00 -04:00
* @ param { Object } value Value to modify .
* @ param { Object } format Format to apply .
* @ param { number } [ startIndex ] Start index .
* @ param { number } [ endIndex ] End index .
2018-12-17 22:14:52 -05:00
*
* @ return { Object } A new value with the format applied .
2018-12-13 23:41:57 -05:00
* /
2019-09-19 11:19:18 -04:00
2019-03-21 08:48:00 -04:00
function applyFormat ( value , format ) {
var startIndex = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : value . start ;
var endIndex = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : value . end ;
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
var formats = value . formats ,
2019-05-16 14:08:00 -04:00
activeFormats = value . activeFormats ;
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
var newFormats = formats . slice ( ) ; // The selection is collapsed.
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( startIndex === endIndex ) {
2020-01-03 08:17:24 -05:00
var startFormat = Object ( external _this _lodash _ [ "find" ] ) ( newFormats [ startIndex ] , {
2018-12-17 22:14:52 -05:00
type : format . type
} ) ; // If the caret is at a format of the same type, expand start and end to
// the edges of the format. This is useful to apply new attributes.
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( startFormat ) {
2019-09-19 11:19:18 -04:00
var index = newFormats [ startIndex ] . indexOf ( startFormat ) ;
while ( newFormats [ startIndex ] && newFormats [ startIndex ] [ index ] === startFormat ) {
newFormats [ startIndex ] = replace ( newFormats [ startIndex ] , index , format ) ;
2018-12-17 22:14:52 -05:00
startIndex -- ;
2018-12-13 23:41:57 -05:00
}
2018-12-17 22:14:52 -05:00
endIndex ++ ;
2018-12-13 23:41:57 -05:00
2019-09-19 11:19:18 -04:00
while ( newFormats [ endIndex ] && newFormats [ endIndex ] [ index ] === startFormat ) {
newFormats [ endIndex ] = replace ( newFormats [ endIndex ] , index , format ) ;
2018-12-17 22:14:52 -05:00
endIndex ++ ;
2019-05-16 14:08:00 -04:00
}
2018-12-17 22:14:52 -05:00
}
} else {
2019-09-19 11:19:18 -04:00
// Determine the highest position the new format can be inserted at.
var position = + Infinity ;
for ( var _index = startIndex ; _index < endIndex ; _index ++ ) {
if ( newFormats [ _index ] ) {
newFormats [ _index ] = newFormats [ _index ] . filter ( function ( _ref ) {
var type = _ref . type ;
return type !== format . type ;
} ) ;
var length = newFormats [ _index ] . length ;
if ( length < position ) {
position = length ;
}
} else {
newFormats [ _index ] = [ ] ;
position = 0 ;
}
}
for ( var _index2 = startIndex ; _index2 < endIndex ; _index2 ++ ) {
newFormats [ _index2 ] . splice ( position , 0 , format ) ;
2018-12-13 23:41:57 -05:00
}
}
2020-02-06 16:03:31 -05:00
return normaliseFormats ( apply _format _objectSpread ( { } , value , {
2019-05-16 14:08:00 -04:00
formats : newFormats ,
// Always revise active formats. This serves as a placeholder for new
// inputs with the format so new input appears with the format applied,
// and ensures a format of the same type uses the latest values.
2020-01-03 08:17:24 -05:00
activeFormats : [ ] . concat ( Object ( toConsumableArray [ "a" /* default */ ] ) ( Object ( external _this _lodash _ [ "reject" ] ) ( activeFormats , {
2019-05-16 14:08:00 -04:00
type : format . type
} ) ) , [ format ] )
2019-03-21 08:48:00 -04:00
} ) ) ;
2018-12-13 23:41:57 -05:00
}
2018-12-17 22:14:52 -05:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
2020-03-23 19:40:19 -04:00
var esm _typeof = _ _webpack _require _ _ ( 34 ) ;
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create-element.js
2018-12-15 06:00:40 -05:00
/ * *
2018-12-17 22:14:52 -05:00
* Parse the given HTML into a body element .
2018-12-15 06:00:40 -05:00
*
2018-12-18 22:16:48 -05:00
* Note : The current implementation will return a shared reference , reset on
* each call to ` createElement ` . Therefore , you should not hold a reference to
* the value to operate upon asynchronously , as it may have unexpected results .
*
2018-12-17 22:14:52 -05:00
* @ param { HTMLDocument } document The HTML document to use to parse .
* @ param { string } html The HTML to parse .
2018-12-15 06:00:40 -05:00
*
2018-12-17 22:14:52 -05:00
* @ return { HTMLBodyElement } Body element with parsed HTML .
2018-12-15 06:00:40 -05:00
* /
2018-12-17 22:14:52 -05:00
function createElement ( _ref , html ) {
var implementation = _ref . implementation ;
2018-12-18 22:16:48 -05:00
// Because `createHTMLDocument` is an expensive operation, and with this
// function being internal to `rich-text` (full control in avoiding a risk
// of asynchronous operations on the shared reference), a single document
// is reused and reset for each call to the function.
if ( ! createElement . body ) {
createElement . body = implementation . createHTMLDocument ( '' ) . body ;
}
2018-12-17 22:14:52 -05:00
2018-12-18 22:16:48 -05:00
createElement . body . innerHTML = html ;
return createElement . body ;
2018-12-15 06:00:40 -05:00
}
2019-03-21 08:48:00 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/special-characters.js
/ * *
2019-09-19 11:19:18 -04:00
* Line separator character , used for multiline text .
2019-03-21 08:48:00 -04:00
* /
var LINE _SEPARATOR = "\u2028" ;
2019-09-19 11:19:18 -04:00
/ * *
* Object replacement character , used as a placeholder for objects .
* /
2019-03-21 08:48:00 -04:00
var OBJECT _REPLACEMENT _CHARACTER = "\uFFFC" ;
2019-09-19 11:19:18 -04:00
/ * *
* Zero width non - breaking space , used as padding in the editable DOM tree when
* it is empty otherwise .
* /
var ZWNBSP = "\uFEFF" ;
2019-03-21 08:48:00 -04:00
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create.js
2018-12-15 06:00:40 -05:00
2019-03-21 08:48:00 -04:00
2020-02-06 16:03:31 -05:00
function create _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function create _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { create _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { create _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2018-12-15 06:00:40 -05:00
/ * *
2018-12-17 22:14:52 -05:00
* WordPress dependencies
2018-12-15 06:00:40 -05:00
* /
2018-12-13 23:41:57 -05:00
/ * *
2018-12-17 22:14:52 -05:00
* Internal dependencies
2018-12-13 23:41:57 -05:00
* /
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
/ * *
* Browser dependencies
* /
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
var _window$Node = window . Node ,
TEXT _NODE = _window$Node . TEXT _NODE ,
ELEMENT _NODE = _window$Node . ELEMENT _NODE ;
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
function createEmptyValue ( ) {
return {
formats : [ ] ,
2019-03-21 08:48:00 -04:00
replacements : [ ] ,
2018-12-17 22:14:52 -05:00
text : ''
} ;
}
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
function simpleFindKey ( object , value ) {
for ( var key in object ) {
if ( object [ key ] === value ) {
return key ;
}
}
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
function toFormat ( _ref ) {
var type = _ref . type ,
attributes = _ref . attributes ;
var formatType ;
2018-12-15 06:00:40 -05:00
2018-12-17 22:14:52 -05:00
if ( attributes && attributes . class ) {
formatType = Object ( external _this _wp _data _ [ "select" ] ) ( 'core/rich-text' ) . getFormatTypeForClassName ( attributes . class ) ;
2018-12-15 06:00:40 -05:00
2018-12-17 22:14:52 -05:00
if ( formatType ) {
// Preserve any additional classes.
attributes . class = " " . concat ( attributes . class , " " ) . replace ( " " . concat ( formatType . className , " " ) , ' ' ) . trim ( ) ;
2018-12-15 06:00:40 -05:00
2018-12-17 22:14:52 -05:00
if ( ! attributes . class ) {
delete attributes . class ;
}
}
}
2018-12-15 06:00:40 -05:00
2018-12-17 22:14:52 -05:00
if ( ! formatType ) {
formatType = Object ( external _this _wp _data _ [ "select" ] ) ( 'core/rich-text' ) . getFormatTypeForBareElement ( type ) ;
}
2018-12-15 06:00:40 -05:00
2018-12-17 22:14:52 -05:00
if ( ! formatType ) {
return attributes ? {
type : type ,
attributes : attributes
} : {
type : type
} ;
}
2018-12-15 06:00:40 -05:00
2019-03-21 08:48:00 -04:00
if ( formatType . _ _experimentalCreatePrepareEditableTree && ! formatType . _ _experimentalCreateOnChangeEditableValue ) {
return null ;
}
2018-12-17 22:14:52 -05:00
if ( ! attributes ) {
return {
type : formatType . name
} ;
}
2018-12-15 06:00:40 -05:00
2018-12-17 22:14:52 -05:00
var registeredAttributes = { } ;
var unregisteredAttributes = { } ;
2018-12-15 06:00:40 -05:00
2018-12-17 22:14:52 -05:00
for ( var name in attributes ) {
var key = simpleFindKey ( formatType . attributes , name ) ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( key ) {
registeredAttributes [ key ] = attributes [ name ] ;
} else {
unregisteredAttributes [ name ] = attributes [ name ] ;
}
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
return {
type : formatType . name ,
attributes : registeredAttributes ,
unregisteredAttributes : unregisteredAttributes
} ;
}
/ * *
* Create a RichText value from an ` Element ` tree ( DOM ) , an HTML string or a
* plain text string , with optionally a ` Range ` object to set the selection . If
* called without any input , an empty value will be created . If
* ` multilineTag ` is provided , any content of direct children whose type matches
* ` multilineTag ` will be separated by two newlines . The optional functions can
* be used to filter out content .
*
2019-03-21 08:48:00 -04:00
* A value will have the following shape , which you are strongly encouraged not
* to modify without the use of helper functions :
*
* ` ` ` js
* {
* text : string ,
* formats : Array ,
* replacements : Array ,
* ? start : number ,
* ? end : number ,
* }
* ` ` `
*
* As you can see , text and formatting are separated . ` text ` holds the text ,
* including any replacement characters for objects and lines . ` formats ` ,
* ` objects ` and ` lines ` are all sparse arrays of the same length as ` text ` . It
* holds information about the formatting at the relevant text indices . Finally
* ` start ` and ` end ` state which text indices are selected . They are only
* provided if a ` Range ` was given .
*
* @ param { Object } [ $1 ] Optional named arguments .
* @ param { Element } [ $1 . element ] Element to create value from .
* @ param { string } [ $1 . text ] Text to create value from .
* @ param { string } [ $1 . html ] HTML to create value from .
* @ param { Range } [ $1 . range ] Range to create value from .
* @ param { string } [ $1 . multilineTag ] Multiline tag if the structure is
2018-12-17 22:14:52 -05:00
* multiline .
2019-03-21 08:48:00 -04:00
* @ param { Array } [ $1 . multilineWrapperTags ] Tags where lines can be found if
2018-12-17 22:14:52 -05:00
* nesting is possible .
2020-01-08 06:57:23 -05:00
* @ param { ? boolean } [ $1 . preserveWhiteSpace ] Whether or not to collapse white
* space characters .
2018-12-17 22:14:52 -05:00
*
* @ return { Object } A rich text value .
* /
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
function create ( ) {
var _ref2 = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ,
element = _ref2 . element ,
text = _ref2 . text ,
html = _ref2 . html ,
range = _ref2 . range ,
multilineTag = _ref2 . multilineTag ,
2019-03-21 08:48:00 -04:00
multilineWrapperTags = _ref2 . multilineWrapperTags ,
2020-01-08 06:57:23 -05:00
isEditableTree = _ref2 . _ _unstableIsEditableTree ,
preserveWhiteSpace = _ref2 . preserveWhiteSpace ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( typeof text === 'string' && text . length > 0 ) {
return {
formats : Array ( text . length ) ,
2019-03-21 08:48:00 -04:00
replacements : Array ( text . length ) ,
2018-12-17 22:14:52 -05:00
text : text
} ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( typeof html === 'string' && html . length > 0 ) {
element = createElement ( document , html ) ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( Object ( esm _typeof [ "a" /* default */ ] ) ( element ) !== 'object' ) {
return createEmptyValue ( ) ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( ! multilineTag ) {
return createFromElement ( {
element : element ,
2019-03-21 08:48:00 -04:00
range : range ,
2020-01-08 06:57:23 -05:00
isEditableTree : isEditableTree ,
preserveWhiteSpace : preserveWhiteSpace
2018-12-17 22:14:52 -05:00
} ) ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
return createFromMultilineElement ( {
element : element ,
range : range ,
multilineTag : multilineTag ,
2019-03-21 08:48:00 -04:00
multilineWrapperTags : multilineWrapperTags ,
2020-01-08 06:57:23 -05:00
isEditableTree : isEditableTree ,
preserveWhiteSpace : preserveWhiteSpace
2018-12-17 22:14:52 -05:00
} ) ;
}
/ * *
* Helper to accumulate the value ' s selection start and end from the current
* node and range .
*
* @ param { Object } accumulator Object to accumulate into .
* @ param { Node } node Node to create value with .
* @ param { Range } range Range to create value with .
* @ param { Object } value Value that is being accumulated .
* /
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
function accumulateSelection ( accumulator , node , range , value ) {
if ( ! range ) {
return ;
}
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
var parentNode = node . parentNode ;
var startContainer = range . startContainer ,
startOffset = range . startOffset ,
endContainer = range . endContainer ,
endOffset = range . endOffset ;
var currentLength = accumulator . text . length ; // Selection can be extracted from value.
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( value . start !== undefined ) {
accumulator . start = currentLength + value . start ; // Range indicates that the current node has selection.
} else if ( node === startContainer && node . nodeType === TEXT _NODE ) {
accumulator . start = currentLength + startOffset ; // Range indicates that the current node is selected.
} else if ( parentNode === startContainer && node === startContainer . childNodes [ startOffset ] ) {
accumulator . start = currentLength ; // Range indicates that the selection is after the current node.
} else if ( parentNode === startContainer && node === startContainer . childNodes [ startOffset - 1 ] ) {
accumulator . start = currentLength + value . text . length ; // Fallback if no child inside handled the selection.
} else if ( node === startContainer ) {
accumulator . start = currentLength ;
} // Selection can be extracted from value.
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( value . end !== undefined ) {
accumulator . end = currentLength + value . end ; // Range indicates that the current node has selection.
} else if ( node === endContainer && node . nodeType === TEXT _NODE ) {
accumulator . end = currentLength + endOffset ; // Range indicates that the current node is selected.
} else if ( parentNode === endContainer && node === endContainer . childNodes [ endOffset - 1 ] ) {
accumulator . end = currentLength + value . text . length ; // Range indicates that the selection is before the current node.
} else if ( parentNode === endContainer && node === endContainer . childNodes [ endOffset ] ) {
accumulator . end = currentLength ; // Fallback if no child inside handled the selection.
} else if ( node === endContainer ) {
accumulator . end = currentLength + endOffset ;
}
}
/ * *
* Adjusts the start and end offsets from a range based on a text filter .
*
* @ param { Node } node Node of which the text should be filtered .
* @ param { Range } range The range to filter .
* @ param { Function } filter Function to use to filter the text .
*
* @ return { ? Object } Object containing range properties .
* /
2018-12-14 06:02:53 -05:00
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
function filterRange ( node , range , filter ) {
if ( ! range ) {
return ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
var startContainer = range . startContainer ,
endContainer = range . endContainer ;
var startOffset = range . startOffset ,
endOffset = range . endOffset ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( node === startContainer ) {
startOffset = filter ( node . nodeValue . slice ( 0 , startOffset ) ) . length ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( node === endContainer ) {
endOffset = filter ( node . nodeValue . slice ( 0 , endOffset ) ) . length ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
return {
startContainer : startContainer ,
startOffset : startOffset ,
endContainer : endContainer ,
endOffset : endOffset
} ;
}
2020-01-08 06:57:23 -05:00
/ * *
* Collapse any whitespace used for HTML formatting to one space character ,
* because it will also be displayed as such by the browser .
*
* @ param { string } string
* /
function collapseWhiteSpace ( string ) {
return string . replace ( /[\n\r\t]+/g , ' ' ) ;
}
2019-03-07 04:09:59 -05:00
2019-09-19 11:19:18 -04:00
var ZWNBSPRegExp = new RegExp ( ZWNBSP , 'g' ) ;
2020-01-08 06:57:23 -05:00
/ * *
* Removes padding ( zero width non breaking spaces ) added by ` toTree ` .
*
* @ param { string } string
* /
2019-09-19 11:19:18 -04:00
2020-01-08 06:57:23 -05:00
function removePadding ( string ) {
return string . replace ( ZWNBSPRegExp , '' ) ;
2019-03-07 04:09:59 -05:00
}
2018-12-17 22:14:52 -05:00
/ * *
* Creates a Rich Text value from a DOM element and range .
*
* @ param { Object } $1 Named argements .
* @ param { ? Element } $1 . element Element to create value from .
* @ param { ? Range } $1 . range Range to create value from .
* @ param { ? string } $1 . multilineTag Multiline tag if the structure is
* multiline .
* @ param { ? Array } $1 . multilineWrapperTags Tags where lines can be found if
* nesting is possible .
2020-01-08 06:57:23 -05:00
* @ param { ? boolean } $1 . preserveWhiteSpace Whether or not to collapse white
* space characters .
2018-12-17 22:14:52 -05:00
*
* @ return { Object } A rich text value .
* /
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
function createFromElement ( _ref3 ) {
var element = _ref3 . element ,
range = _ref3 . range ,
multilineTag = _ref3 . multilineTag ,
multilineWrapperTags = _ref3 . multilineWrapperTags ,
_ref3$currentWrapperT = _ref3 . currentWrapperTags ,
2019-03-21 08:48:00 -04:00
currentWrapperTags = _ref3$currentWrapperT === void 0 ? [ ] : _ref3$currentWrapperT ,
2020-01-08 06:57:23 -05:00
isEditableTree = _ref3 . isEditableTree ,
preserveWhiteSpace = _ref3 . preserveWhiteSpace ;
2018-12-17 22:14:52 -05:00
var accumulator = createEmptyValue ( ) ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( ! element ) {
return accumulator ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( ! element . hasChildNodes ( ) ) {
accumulateSelection ( accumulator , element , range , createEmptyValue ( ) ) ;
return accumulator ;
}
2018-12-13 23:41:57 -05:00
2019-03-07 04:09:59 -05:00
var length = element . childNodes . length ; // Optimise for speed.
2018-12-13 23:41:57 -05:00
2019-03-21 08:48:00 -04:00
var _loop = function _loop ( index ) {
2018-12-17 22:14:52 -05:00
var node = element . childNodes [ index ] ;
var type = node . nodeName . toLowerCase ( ) ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( node . nodeType === TEXT _NODE ) {
2020-01-08 06:57:23 -05:00
var filter = removePadding ;
if ( ! preserveWhiteSpace ) {
filter = function filter ( string ) {
return removePadding ( collapseWhiteSpace ( string ) ) ;
} ;
}
var text = filter ( node . nodeValue ) ;
range = filterRange ( node , range , filter ) ;
2018-12-17 22:14:52 -05:00
accumulateSelection ( accumulator , node , range , {
2019-03-21 08:48:00 -04:00
text : text
} ) ; // Create a sparse array of the same length as `text`, in which
2018-12-17 22:14:52 -05:00
// formats can be added.
2018-12-13 23:41:57 -05:00
2019-03-21 08:48:00 -04:00
accumulator . formats . length += text . length ;
accumulator . replacements . length += text . length ;
accumulator . text += text ;
return "continue" ;
2018-12-17 22:14:52 -05:00
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( node . nodeType !== ELEMENT _NODE ) {
2019-03-21 08:48:00 -04:00
return "continue" ;
2018-12-17 22:14:52 -05:00
}
2018-12-13 23:41:57 -05:00
2019-09-19 11:19:18 -04:00
if ( isEditableTree && ( // Ignore any placeholders.
node . getAttribute ( 'data-rich-text-placeholder' ) || // Ignore any line breaks that are not inserted by us.
type === 'br' && ! node . getAttribute ( 'data-rich-text-line-break' ) ) ) {
2018-12-17 22:14:52 -05:00
accumulateSelection ( accumulator , node , range , createEmptyValue ( ) ) ;
2019-03-21 08:48:00 -04:00
return "continue" ;
2018-12-17 22:14:52 -05:00
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( type === 'br' ) {
accumulateSelection ( accumulator , node , range , createEmptyValue ( ) ) ;
2019-03-21 08:48:00 -04:00
mergePair ( accumulator , create ( {
text : '\n'
} ) ) ;
return "continue" ;
2018-12-17 22:14:52 -05:00
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
var lastFormats = accumulator . formats [ accumulator . formats . length - 1 ] ;
var lastFormat = lastFormats && lastFormats [ lastFormats . length - 1 ] ;
2019-03-07 04:09:59 -05:00
var newFormat = toFormat ( {
type : type ,
attributes : getAttributes ( {
element : node
} )
} ) ;
2019-03-21 08:48:00 -04:00
var format = isFormatEqual ( newFormat , lastFormat ) ? lastFormat : newFormat ;
2019-03-07 04:09:59 -05:00
2018-12-17 22:14:52 -05:00
if ( multilineWrapperTags && multilineWrapperTags . indexOf ( type ) !== - 1 ) {
2019-03-21 08:48:00 -04:00
var _value = createFromMultilineElement ( {
2018-12-17 22:14:52 -05:00
element : node ,
range : range ,
multilineTag : multilineTag ,
multilineWrapperTags : multilineWrapperTags ,
2019-03-21 08:48:00 -04:00
currentWrapperTags : [ ] . concat ( Object ( toConsumableArray [ "a" /* default */ ] ) ( currentWrapperTags ) , [ format ] ) ,
2020-01-08 06:57:23 -05:00
isEditableTree : isEditableTree ,
preserveWhiteSpace : preserveWhiteSpace
2018-12-17 22:14:52 -05:00
} ) ;
2018-12-15 06:00:40 -05:00
2019-03-21 08:48:00 -04:00
accumulateSelection ( accumulator , node , range , _value ) ;
mergePair ( accumulator , _value ) ;
return "continue" ;
2018-12-17 22:14:52 -05:00
}
2018-12-15 06:00:40 -05:00
2019-03-21 08:48:00 -04:00
var value = createFromElement ( {
element : node ,
range : range ,
multilineTag : multilineTag ,
multilineWrapperTags : multilineWrapperTags ,
2020-01-08 06:57:23 -05:00
isEditableTree : isEditableTree ,
preserveWhiteSpace : preserveWhiteSpace
2019-03-21 08:48:00 -04:00
} ) ;
accumulateSelection ( accumulator , node , range , value ) ;
2018-12-15 06:00:40 -05:00
2019-03-21 08:48:00 -04:00
if ( ! format ) {
mergePair ( accumulator , value ) ;
} else if ( value . text . length === 0 ) {
if ( format . attributes ) {
mergePair ( accumulator , {
formats : [ , ] ,
replacements : [ format ] ,
text : OBJECT _REPLACEMENT _CHARACTER
} ) ;
2018-12-17 22:14:52 -05:00
}
} else {
2020-01-22 17:06:21 -05:00
// Indices should share a reference to the same formats array.
// Only create a new reference if `formats` changes.
2020-02-06 16:03:31 -05:00
function mergeFormats ( formats ) {
2020-01-22 17:06:21 -05:00
if ( mergeFormats . formats === formats ) {
return mergeFormats . newFormats ;
}
var newFormats = formats ? [ format ] . concat ( Object ( toConsumableArray [ "a" /* default */ ] ) ( formats ) ) : [ format ] ;
mergeFormats . formats = formats ;
mergeFormats . newFormats = newFormats ;
return newFormats ;
2020-02-06 16:03:31 -05:00
} // Since the formats parameter can be `undefined`, preset
2020-01-22 17:06:21 -05:00
// `mergeFormats` with a new reference.
mergeFormats . newFormats = [ format ] ;
2020-02-06 16:03:31 -05:00
mergePair ( accumulator , create _objectSpread ( { } , value , {
2020-01-22 17:06:21 -05:00
formats : Array . from ( value . formats , mergeFormats )
2019-03-21 08:48:00 -04:00
} ) ) ;
}
} ;
2018-12-15 06:00:40 -05:00
2019-03-21 08:48:00 -04:00
for ( var index = 0 ; index < length ; index ++ ) {
var _ret = _loop ( index ) ;
2018-12-15 06:00:40 -05:00
2019-03-21 08:48:00 -04:00
if ( _ret === "continue" ) continue ;
2018-12-15 06:00:40 -05:00
}
2018-12-17 22:14:52 -05:00
return accumulator ;
2018-12-15 06:00:40 -05:00
}
2018-12-14 06:02:53 -05:00
/ * *
2018-12-17 22:14:52 -05:00
* Creates a rich text value from a DOM element and range that should be
* multiline .
2018-12-14 06:02:53 -05:00
*
2020-01-08 06:57:23 -05:00
* @ param { Object } $1 Named argements .
* @ param { ? Element } $1 . element Element to create value from .
* @ param { ? Range } $1 . range Range to create value from .
* @ param { ? string } $1 . multilineTag Multiline tag if the structure is
* multiline .
* @ param { ? Array } $1 . multilineWrapperTags Tags where lines can be found if
* nesting is possible .
* @ param { boolean } $1 . currentWrapperTags Whether to prepend a line
* separator .
* @ param { ? boolean } $1 . preserveWhiteSpace Whether or not to collapse white
* space characters .
2018-12-14 06:02:53 -05:00
*
2018-12-17 22:14:52 -05:00
* @ return { Object } A rich text value .
2018-12-14 06:02:53 -05:00
* /
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
function createFromMultilineElement ( _ref4 ) {
var element = _ref4 . element ,
range = _ref4 . range ,
multilineTag = _ref4 . multilineTag ,
multilineWrapperTags = _ref4 . multilineWrapperTags ,
_ref4$currentWrapperT = _ref4 . currentWrapperTags ,
2019-03-21 08:48:00 -04:00
currentWrapperTags = _ref4$currentWrapperT === void 0 ? [ ] : _ref4$currentWrapperT ,
2020-01-08 06:57:23 -05:00
isEditableTree = _ref4 . isEditableTree ,
preserveWhiteSpace = _ref4 . preserveWhiteSpace ;
2018-12-17 22:14:52 -05:00
var accumulator = createEmptyValue ( ) ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( ! element || ! element . hasChildNodes ( ) ) {
return accumulator ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
var length = element . children . length ; // Optimise for speed.
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
for ( var index = 0 ; index < length ; index ++ ) {
var node = element . children [ index ] ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( node . nodeName . toLowerCase ( ) !== multilineTag ) {
continue ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
var value = createFromElement ( {
element : node ,
range : range ,
multilineTag : multilineTag ,
multilineWrapperTags : multilineWrapperTags ,
2019-03-21 08:48:00 -04:00
currentWrapperTags : currentWrapperTags ,
2020-01-08 06:57:23 -05:00
isEditableTree : isEditableTree ,
preserveWhiteSpace : preserveWhiteSpace
2019-03-21 08:48:00 -04:00
} ) ; // Multiline value text should be separated by a line separator.
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( index !== 0 || currentWrapperTags . length > 0 ) {
2019-03-21 08:48:00 -04:00
mergePair ( accumulator , {
formats : [ , ] ,
replacements : currentWrapperTags . length > 0 ? [ currentWrapperTags ] : [ , ] ,
text : LINE _SEPARATOR
} ) ;
2018-12-17 22:14:52 -05:00
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
accumulateSelection ( accumulator , node , range , value ) ;
2019-03-21 08:48:00 -04:00
mergePair ( accumulator , value ) ;
2018-12-17 22:14:52 -05:00
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
return accumulator ;
}
2018-12-13 23:41:57 -05:00
/ * *
2018-12-17 22:14:52 -05:00
* Gets the attributes of an element in object shape .
2018-12-13 23:41:57 -05:00
*
2018-12-17 22:14:52 -05:00
* @ param { Object } $1 Named argements .
* @ param { Element } $1 . element Element to get attributes from .
2018-12-13 23:41:57 -05:00
*
2018-12-17 22:14:52 -05:00
* @ return { ? Object } Attribute object or ` undefined ` if the element has no
* attributes .
2018-12-13 23:41:57 -05:00
* /
2018-12-17 22:14:52 -05:00
function getAttributes ( _ref5 ) {
2019-03-07 04:09:59 -05:00
var element = _ref5 . element ;
2018-12-17 22:14:52 -05:00
if ( ! element . hasAttributes ( ) ) {
2018-12-13 23:41:57 -05:00
return ;
}
2018-12-17 22:14:52 -05:00
var length = element . attributes . length ;
var accumulator ; // Optimise for speed.
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
for ( var i = 0 ; i < length ; i ++ ) {
var _element$attributes$i = element . attributes [ i ] ,
name = _element$attributes$i . name ,
value = _element$attributes$i . value ;
2018-12-13 23:41:57 -05:00
2019-03-21 08:48:00 -04:00
if ( name . indexOf ( 'data-rich-text-' ) === 0 ) {
2018-12-17 22:14:52 -05:00
continue ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
accumulator = accumulator || { } ;
accumulator [ name ] = value ;
}
2018-12-13 23:41:57 -05:00
2019-03-07 04:09:59 -05:00
return accumulator ;
}
2019-03-21 08:48:00 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/concat.js
/ * *
* Internal dependencies
* /
/ * *
* Concats a pair of rich text values . Not that this mutates ` a ` and does NOT
* normalise formats !
*
* @ param { Object } a Value to mutate .
* @ param { Object } b Value to add read from .
*
* @ return { Object } ` a ` , mutated .
* /
function mergePair ( a , b ) {
a . formats = a . formats . concat ( b . formats ) ;
a . replacements = a . replacements . concat ( b . replacements ) ;
a . text += b . text ;
return a ;
}
/ * *
* Combine all Rich Text values into one . This is similar to
* ` String.prototype.concat ` .
*
* @ param { ... Object } values Objects to combine .
*
* @ return { Object } A new value combining all given records .
* /
function concat ( ) {
for ( var _len = arguments . length , values = new Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) {
values [ _key ] = arguments [ _key ] ;
}
return normaliseFormats ( values . reduce ( mergePair , create ( ) ) ) ;
}
2019-03-07 04:09:59 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-formats.js
/ * *
* Gets the all format objects at the start of the selection .
*
2020-01-22 17:06:21 -05:00
* @ param { Object } value Value to inspect .
* @ param { Array } EMPTY _ACTIVE _FORMATS Array to return if there are no active
* formats .
2019-03-07 04:09:59 -05:00
*
* @ return { ? Object } Active format objects .
* /
function getActiveFormats ( _ref ) {
var formats = _ref . formats ,
start = _ref . start ,
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
end = _ref . end ,
activeFormats = _ref . activeFormats ;
2020-01-22 17:06:21 -05:00
var EMPTY _ACTIVE _FORMATS = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : [ ] ;
2019-03-07 04:09:59 -05:00
if ( start === undefined ) {
2020-01-22 17:06:21 -05:00
return EMPTY _ACTIVE _FORMATS ;
2019-03-07 04:09:59 -05:00
}
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
if ( start === end ) {
// For a collapsed caret, it is possible to override the active formats.
if ( activeFormats ) {
return activeFormats ;
}
2020-01-22 17:06:21 -05:00
var formatsBefore = formats [ start - 1 ] || EMPTY _ACTIVE _FORMATS ;
var formatsAfter = formats [ start ] || EMPTY _ACTIVE _FORMATS ; // By default, select the lowest amount of formats possible (which means
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
// the caret is positioned outside the format boundary). The user can
// then use arrow keys to define `activeFormats`.
if ( formatsBefore . length < formatsAfter . length ) {
return formatsBefore ;
}
2019-03-07 04:09:59 -05:00
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
return formatsAfter ;
2019-03-07 04:09:59 -05:00
}
2020-01-22 17:06:21 -05:00
return formats [ start ] || EMPTY _ACTIVE _FORMATS ;
2018-12-17 22:14:52 -05:00
}
2018-12-15 06:00:40 -05:00
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-format.js
2018-12-13 23:41:57 -05:00
/ * *
2018-12-17 22:14:52 -05:00
* External dependencies
2018-12-13 23:41:57 -05:00
* /
2018-12-15 06:00:40 -05:00
2019-03-07 04:09:59 -05:00
/ * *
* Internal dependencies
* /
2018-12-13 23:41:57 -05:00
/ * *
2018-12-17 22:14:52 -05:00
* Gets the format object by type at the start of the selection . This can be
* used to get e . g . the URL of a link format at the current selection , but also
* to check if a format is active at the selection . Returns undefined if there
* is no format at the selection .
2018-12-13 23:41:57 -05:00
*
2018-12-17 22:14:52 -05:00
* @ param { Object } value Value to inspect .
* @ param { string } formatType Format type to look for .
2018-12-13 23:41:57 -05:00
*
2019-03-21 08:48:00 -04:00
* @ return { Object | undefined } Active format object of the specified type , or undefined .
2018-12-13 23:41:57 -05:00
* /
2019-03-07 04:09:59 -05:00
function getActiveFormat ( value , formatType ) {
2020-01-03 08:17:24 -05:00
return Object ( external _this _lodash _ [ "find" ] ) ( getActiveFormats ( value ) , {
2018-12-17 22:14:52 -05:00
type : formatType
} ) ;
2018-12-13 23:41:57 -05:00
}
2019-03-21 08:48:00 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-object.js
/ * *
* Internal dependencies
* /
/ * *
* Gets the active object , if there is any .
*
* @ param { Object } value Value to inspect .
*
* @ return { ? Object } Active object , or undefined .
* /
function getActiveObject ( _ref ) {
var start = _ref . start ,
end = _ref . end ,
replacements = _ref . replacements ,
text = _ref . text ;
if ( start + 1 !== end || text [ start ] !== OBJECT _REPLACEMENT _CHARACTER ) {
return ;
}
return replacements [ start ] ;
}
2019-09-19 11:19:18 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-text-content.js
/ * *
* Get the textual content of a Rich Text value . This is similar to
* ` Element.textContent ` .
*
* @ param { Object } value Value to use .
*
* @ return { string } The text content .
* /
function getTextContent ( _ref ) {
var text = _ref . text ;
return text ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-line-index.js
/ * *
* Internal dependencies
* /
2018-12-13 23:41:57 -05:00
/ * *
2019-09-19 11:19:18 -04:00
* Gets the currently selected line index , or the first line index if the
* selection spans over multiple items .
2018-12-13 23:41:57 -05:00
*
2019-09-19 11:19:18 -04:00
* @ param { Object } value Value to get the line index from .
* @ param { boolean } startIndex Optional index that should be contained by the
* line . Defaults to the selection start of the
* value .
2018-12-13 23:41:57 -05:00
*
2019-09-19 11:19:18 -04:00
* @ return { ? boolean } The line index . Undefined if not found .
2018-12-13 23:41:57 -05:00
* /
2019-09-19 11:19:18 -04:00
function getLineIndex ( _ref ) {
var start = _ref . start ,
text = _ref . text ;
var startIndex = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : start ;
var index = startIndex ;
while ( index -- ) {
if ( text [ index ] === LINE _SEPARATOR ) {
return index ;
}
}
2018-12-17 22:14:52 -05:00
}
2018-12-13 23:41:57 -05:00
2019-09-19 11:19:18 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-list-root-selected.js
/ * *
* Internal dependencies
* /
2018-12-17 22:14:52 -05:00
/ * *
2019-09-19 11:19:18 -04:00
* Whether or not the root list is selected .
2018-12-17 22:14:52 -05:00
*
2019-09-19 11:19:18 -04:00
* @ param { Object } value The value to check .
2018-12-17 22:14:52 -05:00
*
2019-09-19 11:19:18 -04:00
* @ return { boolean } True if the root list or nothing is selected , false if an
* inner list is selected .
2018-12-17 22:14:52 -05:00
* /
2019-09-19 11:19:18 -04:00
function isListRootSelected ( value ) {
var replacements = value . replacements ,
start = value . start ;
var lineIndex = getLineIndex ( value , start ) ;
var replacement = replacements [ lineIndex ] ;
return ! replacement || replacement . length < 1 ;
2018-12-17 22:14:52 -05:00
}
2018-12-13 23:41:57 -05:00
2019-09-19 11:19:18 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-active-list-type.js
2018-12-17 22:14:52 -05:00
/ * *
2019-09-19 11:19:18 -04:00
* Internal dependencies
* /
/ * *
* Wether or not the selected list has the given tag name .
2018-12-17 22:14:52 -05:00
*
2019-09-19 11:19:18 -04:00
* @ param { Object } value The value to check .
* @ param { string } type The tag name the list should have .
* @ param { string } rootType The current root tag name , to compare with in case
* nothing is selected .
2018-12-17 22:14:52 -05:00
*
2019-09-19 11:19:18 -04:00
* @ return { boolean } True if the current list type matches ` type ` , false if not .
2018-12-17 22:14:52 -05:00
* /
2019-09-19 11:19:18 -04:00
function isActiveListType ( value , type , rootType ) {
var replacements = value . replacements ,
start = value . start ;
var lineIndex = getLineIndex ( value , start ) ;
var replacement = replacements [ lineIndex ] ;
if ( ! replacement || replacement . length === 0 ) {
return type === rootType ;
}
var lastFormat = replacement [ replacement . length - 1 ] ;
return lastFormat . type === type ;
2018-12-17 22:14:52 -05:00
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-collapsed.js
/ * *
* Check if the selection of a Rich Text value is collapsed or not . Collapsed
* means that no characters are selected , but there is a caret present . If there
* is no selection , ` undefined ` will be returned . This is similar to
* ` window.getSelection().isCollapsed() ` .
*
* @ param { Object } value The rich text value to check .
*
2019-03-21 08:48:00 -04:00
* @ return { boolean | undefined } True if the selection is collapsed , false if not ,
* undefined if there is no selection .
2018-12-17 22:14:52 -05:00
* /
function isCollapsed ( _ref ) {
var start = _ref . start ,
end = _ref . end ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
if ( start === undefined || end === undefined ) {
return ;
2018-12-13 23:41:57 -05:00
}
2018-12-17 22:14:52 -05:00
return start === end ;
2018-12-13 23:41:57 -05:00
}
2019-03-21 08:48:00 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-empty.js
/ * *
* Internal dependencies
* /
/ * *
* Check if a Rich Text value is Empty , meaning it contains no text or any
* objects ( such as images ) .
*
* @ param { Object } value Value to use .
*
* @ return { boolean } True if the value is empty , false if not .
* /
function isEmpty ( _ref ) {
var text = _ref . text ;
return text . length === 0 ;
}
/ * *
* Check if the current collapsed selection is on an empty line in case of a
* multiline value .
*
* @ param { Object } value Value te check .
*
* @ return { boolean } True if the line is empty , false if not .
* /
function isEmptyLine ( _ref2 ) {
var text = _ref2 . text ,
start = _ref2 . start ,
end = _ref2 . end ;
if ( start !== end ) {
return false ;
}
if ( text . length === 0 ) {
return true ;
}
if ( start === 0 && text . slice ( 0 , 1 ) === LINE _SEPARATOR ) {
return true ;
}
if ( start === text . length && text . slice ( - 1 ) === LINE _SEPARATOR ) {
return true ;
}
return text . slice ( start - 1 , end + 1 ) === "" . concat ( LINE _SEPARATOR ) . concat ( LINE _SEPARATOR ) ;
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/join.js
2018-12-13 23:41:57 -05:00
/ * *
* Internal dependencies
* /
/ * *
* Combine an array of Rich Text values into one , optionally separated by
* ` separator ` , which can be a Rich Text value , HTML string , or plain text
* string . This is similar to ` Array.prototype.join ` .
*
2019-03-21 08:48:00 -04:00
* @ param { Array < Object > } values An array of values to join .
* @ param { string | Object } [ separator ] Separator string or value .
2018-12-13 23:41:57 -05:00
*
* @ return { Object } A new combined value .
* /
function join ( values ) {
var separator = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : '' ;
if ( typeof separator === 'string' ) {
2018-12-17 22:14:52 -05:00
separator = create ( {
2018-12-13 23:41:57 -05:00
text : separator
} ) ;
}
2018-12-17 22:14:52 -05:00
return normaliseFormats ( values . reduce ( function ( accumlator , _ref ) {
2018-12-13 23:41:57 -05:00
var formats = _ref . formats ,
2019-03-21 08:48:00 -04:00
replacements = _ref . replacements ,
2018-12-13 23:41:57 -05:00
text = _ref . text ;
return {
2019-03-21 08:48:00 -04:00
formats : accumlator . formats . concat ( separator . formats , formats ) ,
replacements : accumlator . replacements . concat ( separator . replacements , replacements ) ,
text : accumlator . text + separator . text + text
2018-12-13 23:41:57 -05:00
} ;
} ) ) ;
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/register-format-type.js
Block Editor: Update `@wordpress` dependencies to match Gutenberg 4.5.1.
- Update the annotations, api-fetch, block-library, blocks, components, compose, core-data, data, date, dom, edit-post, editor, element, format-library, html-entities, i18n, jest-console, jest-preset-default, keycodes, list-reusable-blocks, notices, nux, plugins, rich-text, scripts, token-lists, url, viewport packages.
- Upgrades React from 16.5.2 to 16.6.3.
- Adds a missing `wp-date` dependency to the editor script.
- Updates changed dependencies in `script-loader.php`.
- Fixes undefined notices in some blocks.
- Removes incorrect `gutenberg` textdomain.
Merges [43891], [43903], and [43919] to trunk.
Props atimmer, aduth, youknowriad, danielbachhuber.
See #45145.
Built from https://develop.svn.wordpress.org/trunk@44262
git-svn-id: http://core.svn.wordpress.org/trunk@44092 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-17 10:37:00 -05:00
2018-12-16 23:52:00 -05:00
2020-02-06 16:03:31 -05:00
function register _format _type _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function register _format _type _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { register _format _type _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { register _format _type _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2018-12-14 06:02:53 -05:00
/ * *
* WordPress dependencies
* /
2020-01-08 06:57:23 -05:00
/ * *
* @ typedef { Object } WPFormat
*
* @ property { string } name A string identifying the format . Must be
* unique across all registered formats .
* @ property { string } tagName The HTML tag this format will wrap the
* selection with .
* @ property { string } [ className ] A class to match the format .
* @ property { string } title Name of the format .
* @ property { Function } edit Should return a component for the user to
* interact with the new registered format .
* /
2018-12-14 06:02:53 -05:00
/ * *
* Registers a new format provided a unique name and an object defining its
* behavior .
*
2019-03-21 08:48:00 -04:00
* @ param { string } name Format name .
2020-01-08 06:57:23 -05:00
* @ param { WPFormat } settings Format settings .
2018-12-14 06:02:53 -05:00
*
2019-03-21 08:48:00 -04:00
* @ return { WPFormat | undefined } The format , if it has been successfully registered ;
* otherwise ` undefined ` .
2018-12-14 06:02:53 -05:00
* /
function registerFormatType ( name , settings ) {
2020-02-06 16:03:31 -05:00
settings = register _format _type _objectSpread ( {
2018-12-14 06:02:53 -05:00
name : name
} , settings ) ;
if ( typeof settings . name !== 'string' ) {
window . console . error ( 'Format names must be strings.' ) ;
return ;
}
if ( ! /^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/ . test ( settings . name ) ) {
window . console . error ( 'Format names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-format' ) ;
return ;
}
2018-12-17 22:14:52 -05:00
if ( Object ( external _this _wp _data _ [ "select" ] ) ( 'core/rich-text' ) . getFormatType ( settings . name ) ) {
2018-12-14 06:02:53 -05:00
window . console . error ( 'Format "' + settings . name + '" is already registered.' ) ;
return ;
}
2018-12-16 23:52:00 -05:00
if ( typeof settings . tagName !== 'string' || settings . tagName === '' ) {
window . console . error ( 'Format tag names must be a string.' ) ;
return ;
}
if ( ( typeof settings . className !== 'string' || settings . className === '' ) && settings . className !== null ) {
window . console . error ( 'Format class names must be a string, or null to handle bare elements.' ) ;
return ;
}
if ( ! /^[_a-zA-Z]+[a-zA-Z0-9-]*$/ . test ( settings . className ) ) {
window . console . error ( 'A class name must begin with a letter, followed by any number of hyphens, letters, or numbers.' ) ;
2018-12-14 06:02:53 -05:00
return ;
}
2018-12-16 23:52:00 -05:00
if ( settings . className === null ) {
2018-12-17 22:14:52 -05:00
var formatTypeForBareElement = Object ( external _this _wp _data _ [ "select" ] ) ( 'core/rich-text' ) . getFormatTypeForBareElement ( settings . tagName ) ;
2018-12-16 23:52:00 -05:00
if ( formatTypeForBareElement ) {
window . console . error ( "Format \"" . concat ( formatTypeForBareElement . name , "\" is already registered to handle bare tag name \"" ) . concat ( settings . tagName , "\"." ) ) ;
return ;
}
} else {
2018-12-17 22:14:52 -05:00
var formatTypeForClassName = Object ( external _this _wp _data _ [ "select" ] ) ( 'core/rich-text' ) . getFormatTypeForClassName ( settings . className ) ;
2018-12-16 23:52:00 -05:00
if ( formatTypeForClassName ) {
window . console . error ( "Format \"" . concat ( formatTypeForClassName . name , "\" is already registered to handle class name \"" ) . concat ( settings . className , "\"." ) ) ;
return ;
}
}
2018-12-14 06:02:53 -05:00
if ( ! ( 'title' in settings ) || settings . title === '' ) {
window . console . error ( 'The format "' + settings . name + '" must have a title.' ) ;
return ;
}
if ( 'keywords' in settings && settings . keywords . length > 3 ) {
window . console . error ( 'The format "' + settings . name + '" can have a maximum of 3 keywords.' ) ;
2020-01-22 17:06:21 -05:00
return ;
}
Block Editor: Update `@wordpress` dependencies to match Gutenberg 4.5.1.
- Update the annotations, api-fetch, block-library, blocks, components, compose, core-data, data, date, dom, edit-post, editor, element, format-library, html-entities, i18n, jest-console, jest-preset-default, keycodes, list-reusable-blocks, notices, nux, plugins, rich-text, scripts, token-lists, url, viewport packages.
- Upgrades React from 16.5.2 to 16.6.3.
- Adds a missing `wp-date` dependency to the editor script.
- Updates changed dependencies in `script-loader.php`.
- Fixes undefined notices in some blocks.
- Removes incorrect `gutenberg` textdomain.
Merges [43891], [43903], and [43919] to trunk.
Props atimmer, aduth, youknowriad, danielbachhuber.
See #45145.
Built from https://develop.svn.wordpress.org/trunk@44262
git-svn-id: http://core.svn.wordpress.org/trunk@44092 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-17 10:37:00 -05:00
2020-01-22 17:06:21 -05:00
if ( typeof settings . title !== 'string' ) {
window . console . error ( 'Format titles must be strings.' ) ;
return ;
2018-12-16 23:52:00 -05:00
}
2020-01-22 17:06:21 -05:00
Object ( external _this _wp _data _ [ "dispatch" ] ) ( 'core/rich-text' ) . addFormatTypes ( settings ) ;
2018-12-14 06:02:53 -05:00
return settings ;
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove-format.js
2019-03-21 08:48:00 -04:00
2020-02-06 16:03:31 -05:00
function remove _format _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function remove _format _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { remove _format _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { remove _format _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2018-12-13 23:41:57 -05:00
/ * *
* External dependencies
* /
/ * *
* Internal dependencies
* /
/ * *
* Remove any format object from a Rich Text value by type from the given
* ` startIndex ` to the given ` endIndex ` . Indices are retrieved from the
* selection if none are provided .
*
2019-03-21 08:48:00 -04:00
* @ param { Object } value Value to modify .
* @ param { string } formatType Format type to remove .
* @ param { number } [ startIndex ] Start index .
* @ param { number } [ endIndex ] End index .
2018-12-13 23:41:57 -05:00
*
* @ return { Object } A new value with the format applied .
* /
2019-03-21 08:48:00 -04:00
function removeFormat ( value , formatType ) {
var startIndex = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : value . start ;
var endIndex = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : value . end ;
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
var formats = value . formats ,
activeFormats = value . activeFormats ;
var newFormats = formats . slice ( ) ; // If the selection is collapsed, expand start and end to the edges of the
2018-12-13 23:41:57 -05:00
// format.
if ( startIndex === endIndex ) {
2020-01-03 08:17:24 -05:00
var format = Object ( external _this _lodash _ [ "find" ] ) ( newFormats [ startIndex ] , {
2018-12-13 23:41:57 -05:00
type : formatType
} ) ;
2019-03-21 08:48:00 -04:00
if ( format ) {
2020-01-03 08:17:24 -05:00
while ( Object ( external _this _lodash _ [ "find" ] ) ( newFormats [ startIndex ] , format ) ) {
2019-03-21 08:48:00 -04:00
filterFormats ( newFormats , startIndex , formatType ) ;
startIndex -- ;
}
2018-12-13 23:41:57 -05:00
endIndex ++ ;
2019-03-21 08:48:00 -04:00
2020-01-03 08:17:24 -05:00
while ( Object ( external _this _lodash _ [ "find" ] ) ( newFormats [ endIndex ] , format ) ) {
2019-03-21 08:48:00 -04:00
filterFormats ( newFormats , endIndex , formatType ) ;
endIndex ++ ;
}
2018-12-13 23:41:57 -05:00
}
} else {
for ( var i = startIndex ; i < endIndex ; i ++ ) {
if ( newFormats [ i ] ) {
filterFormats ( newFormats , i , formatType ) ;
}
}
}
2020-02-06 16:03:31 -05:00
return normaliseFormats ( remove _format _objectSpread ( { } , value , {
2019-05-16 14:08:00 -04:00
formats : newFormats ,
2020-01-03 08:17:24 -05:00
activeFormats : Object ( external _this _lodash _ [ "reject" ] ) ( activeFormats , {
2019-05-16 14:08:00 -04:00
type : formatType
} )
2019-03-21 08:48:00 -04:00
} ) ) ;
2018-12-13 23:41:57 -05:00
}
function filterFormats ( formats , index , formatType ) {
2019-03-21 08:48:00 -04:00
var newFormats = formats [ index ] . filter ( function ( _ref ) {
var type = _ref . type ;
2018-12-13 23:41:57 -05:00
return type !== formatType ;
} ) ;
if ( newFormats . length ) {
formats [ index ] = newFormats ;
} else {
delete formats [ index ] ;
}
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert.js
/ * *
* Internal dependencies
* /
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
/ * *
* Insert a Rich Text value , an HTML string , or a plain text string , into a
* Rich Text value at the given ` startIndex ` . Any content between ` startIndex `
* and ` endIndex ` will be removed . Indices are retrieved from the selection if
* none are provided .
*
2019-03-21 08:48:00 -04:00
* @ param { Object } value Value to modify .
* @ param { Object | string } valueToInsert Value to insert .
* @ param { number } [ startIndex ] Start index .
* @ param { number } [ endIndex ] End index .
2018-12-17 22:14:52 -05:00
*
* @ return { Object } A new value with the value inserted .
* /
2018-12-13 23:41:57 -05:00
2019-03-21 08:48:00 -04:00
function insert ( value , valueToInsert ) {
var startIndex = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : value . start ;
var endIndex = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : value . end ;
var formats = value . formats ,
replacements = value . replacements ,
text = value . text ;
2018-12-17 22:14:52 -05:00
if ( typeof valueToInsert === 'string' ) {
valueToInsert = create ( {
text : valueToInsert
} ) ;
}
var index = startIndex + valueToInsert . text . length ;
return normaliseFormats ( {
formats : formats . slice ( 0 , startIndex ) . concat ( valueToInsert . formats , formats . slice ( endIndex ) ) ,
2019-03-21 08:48:00 -04:00
replacements : replacements . slice ( 0 , startIndex ) . concat ( valueToInsert . replacements , replacements . slice ( endIndex ) ) ,
2018-12-17 22:14:52 -05:00
text : text . slice ( 0 , startIndex ) + valueToInsert . text + text . slice ( endIndex ) ,
start : index ,
end : index
} ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove.js
2018-12-13 23:41:57 -05:00
/ * *
* Internal dependencies
* /
/ * *
* Remove content from a Rich Text value between the given ` startIndex ` and
* ` endIndex ` . Indices are retrieved from the selection if none are provided .
*
2019-03-21 08:48:00 -04:00
* @ param { Object } value Value to modify .
* @ param { number } [ startIndex ] Start index .
* @ param { number } [ endIndex ] End index .
2018-12-13 23:41:57 -05:00
*
* @ return { Object } A new value with the content removed .
* /
2018-12-17 22:14:52 -05:00
function remove _remove ( value , startIndex , endIndex ) {
return insert ( value , create ( ) , startIndex , endIndex ) ;
2018-12-13 23:41:57 -05:00
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/replace.js
2018-12-13 23:41:57 -05:00
/ * *
* Internal dependencies
* /
/ * *
* Search a Rich Text value and replace the match ( es ) with ` replacement ` . This
* is similar to ` String.prototype.replace ` .
*
* @ param { Object } value The value to modify .
* @ param { RegExp | string } pattern A RegExp object or literal . Can also be
* a string . It is treated as a verbatim
* string and is not interpreted as a
* regular expression . Only the first
* occurrence will be replaced .
* @ param { Function | string } replacement The match or matches are replaced with
* the specified or the value returned by
* the specified function .
*
* @ return { Object } A new value with replacements applied .
* /
2019-09-19 11:19:18 -04:00
function replace _replace ( _ref , pattern , replacement ) {
2018-12-13 23:41:57 -05:00
var formats = _ref . formats ,
2019-03-21 08:48:00 -04:00
replacements = _ref . replacements ,
2018-12-13 23:41:57 -05:00
text = _ref . text ,
start = _ref . start ,
end = _ref . end ;
text = text . replace ( pattern , function ( match ) {
for ( var _len = arguments . length , rest = new Array ( _len > 1 ? _len - 1 : 0 ) , _key = 1 ; _key < _len ; _key ++ ) {
rest [ _key - 1 ] = arguments [ _key ] ;
}
var offset = rest [ rest . length - 2 ] ;
var newText = replacement ;
var newFormats ;
2019-03-21 08:48:00 -04:00
var newReplacements ;
2018-12-13 23:41:57 -05:00
if ( typeof newText === 'function' ) {
newText = replacement . apply ( void 0 , [ match ] . concat ( rest ) ) ;
}
2018-12-17 22:14:52 -05:00
if ( Object ( esm _typeof [ "a" /* default */ ] ) ( newText ) === 'object' ) {
2018-12-13 23:41:57 -05:00
newFormats = newText . formats ;
2019-03-21 08:48:00 -04:00
newReplacements = newText . replacements ;
2018-12-13 23:41:57 -05:00
newText = newText . text ;
} else {
newFormats = Array ( newText . length ) ;
2019-03-21 08:48:00 -04:00
newReplacements = Array ( newText . length ) ;
2018-12-13 23:41:57 -05:00
if ( formats [ offset ] ) {
newFormats = newFormats . fill ( formats [ offset ] ) ;
}
}
formats = formats . slice ( 0 , offset ) . concat ( newFormats , formats . slice ( offset + match . length ) ) ;
2019-03-21 08:48:00 -04:00
replacements = replacements . slice ( 0 , offset ) . concat ( newReplacements , replacements . slice ( offset + match . length ) ) ;
2018-12-13 23:41:57 -05:00
if ( start ) {
start = end = offset + newText . length ;
}
return newText ;
} ) ;
2018-12-17 22:14:52 -05:00
return normaliseFormats ( {
2018-12-13 23:41:57 -05:00
formats : formats ,
2019-03-21 08:48:00 -04:00
replacements : replacements ,
2018-12-13 23:41:57 -05:00
text : text ,
start : start ,
end : end
} ) ;
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-line-separator.js
/ * *
* Internal dependencies
* /
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
/ * *
* Insert a line break character into a Rich Text value at the given
* ` startIndex ` . Any content between ` startIndex ` and ` endIndex ` will be
* removed . Indices are retrieved from the selection if none are provided .
*
2019-03-21 08:48:00 -04:00
* @ param { Object } value Value to modify .
* @ param { number } [ startIndex ] Start index .
* @ param { number } [ endIndex ] End index .
2018-12-17 22:14:52 -05:00
*
* @ return { Object } A new value with the value inserted .
* /
function insertLineSeparator ( value ) {
var startIndex = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : value . start ;
var endIndex = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : value . end ;
var beforeText = getTextContent ( value ) . slice ( 0 , startIndex ) ;
var previousLineSeparatorIndex = beforeText . lastIndexOf ( LINE _SEPARATOR ) ;
2019-03-21 08:48:00 -04:00
var previousLineSeparatorFormats = value . replacements [ previousLineSeparatorIndex ] ;
var replacements = [ , ] ;
2018-12-17 22:14:52 -05:00
if ( previousLineSeparatorFormats ) {
2019-03-21 08:48:00 -04:00
replacements = [ previousLineSeparatorFormats ] ;
2018-12-17 22:14:52 -05:00
}
var valueToInsert = {
2019-03-21 08:48:00 -04:00
formats : [ , ] ,
replacements : replacements ,
2018-12-17 22:14:52 -05:00
text : LINE _SEPARATOR
} ;
return insert ( value , valueToInsert , startIndex , endIndex ) ;
}
2019-09-19 11:19:18 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove-line-separator.js
2020-02-06 16:03:31 -05:00
function remove _line _separator _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function remove _line _separator _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { remove _line _separator _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { remove _line _separator _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2019-09-19 11:19:18 -04:00
/ * *
* Internal dependencies
* /
/ * *
* Removes a line separator character , if existing , from a Rich Text value at the current
* indices . If no line separator exists on the indices it will return undefined .
*
* @ param { Object } value Value to modify .
* @ param { boolean } backward indicates if are removing from the start index or the end index .
*
* @ return { Object | undefined } A new value with the line separator removed . Or undefined if no line separator is found on the position .
* /
function removeLineSeparator ( value ) {
var backward = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : true ;
var replacements = value . replacements ,
text = value . text ,
start = value . start ,
end = value . end ;
var collapsed = isCollapsed ( value ) ;
var index = start - 1 ;
var removeStart = collapsed ? start - 1 : start ;
var removeEnd = end ;
if ( ! backward ) {
index = end ;
removeStart = start ;
removeEnd = collapsed ? end + 1 : end ;
}
if ( text [ index ] !== LINE _SEPARATOR ) {
return ;
}
var newValue ; // If the line separator that is about te be removed
// contains wrappers, remove the wrappers first.
if ( collapsed && replacements [ index ] && replacements [ index ] . length ) {
var newReplacements = replacements . slice ( ) ;
newReplacements [ index ] = replacements [ index ] . slice ( 0 , - 1 ) ;
2020-02-06 16:03:31 -05:00
newValue = remove _line _separator _objectSpread ( { } , value , {
2019-09-19 11:19:18 -04:00
replacements : newReplacements
} ) ;
} else {
newValue = remove _remove ( value , removeStart , removeEnd ) ;
}
return newValue ;
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-object.js
/ * *
* Internal dependencies
* /
var insert _object _OBJECT _REPLACEMENT _CHARACTER = "\uFFFC" ;
/ * *
* Insert a format as an object into a Rich Text value at the given
* ` startIndex ` . Any content between ` startIndex ` and ` endIndex ` will be
* removed . Indices are retrieved from the selection if none are provided .
*
* @ param { Object } value Value to modify .
* @ param { Object } formatToInsert Format to insert as object .
2019-03-21 08:48:00 -04:00
* @ param { number } [ startIndex ] Start index .
* @ param { number } [ endIndex ] End index .
2018-12-17 22:14:52 -05:00
*
* @ return { Object } A new value with the object inserted .
* /
function insertObject ( value , formatToInsert , startIndex , endIndex ) {
var valueToInsert = {
2019-03-21 08:48:00 -04:00
formats : [ , ] ,
replacements : [ formatToInsert ] ,
text : insert _object _OBJECT _REPLACEMENT _CHARACTER
2018-12-17 22:14:52 -05:00
} ;
return insert ( value , valueToInsert , startIndex , endIndex ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/slice.js
2019-03-21 08:48:00 -04:00
2020-02-06 16:03:31 -05:00
function slice _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function slice _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { slice _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { slice _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2018-12-13 23:41:57 -05:00
/ * *
* Slice a Rich Text value from ` startIndex ` to ` endIndex ` . Indices are
* retrieved from the selection if none are provided . This is similar to
* ` String.prototype.slice ` .
*
2019-03-21 08:48:00 -04:00
* @ param { Object } value Value to modify .
* @ param { number } [ startIndex ] Start index .
* @ param { number } [ endIndex ] End index .
2018-12-13 23:41:57 -05:00
*
* @ return { Object } A new extracted value .
* /
2019-03-21 08:48:00 -04:00
function slice ( value ) {
var startIndex = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : value . start ;
var endIndex = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : value . end ;
var formats = value . formats ,
replacements = value . replacements ,
text = value . text ;
2018-12-13 23:41:57 -05:00
if ( startIndex === undefined || endIndex === undefined ) {
2020-02-06 16:03:31 -05:00
return slice _objectSpread ( { } , value ) ;
2018-12-13 23:41:57 -05:00
}
return {
formats : formats . slice ( startIndex , endIndex ) ,
2019-03-21 08:48:00 -04:00
replacements : replacements . slice ( startIndex , endIndex ) ,
2018-12-13 23:41:57 -05:00
text : text . slice ( startIndex , endIndex )
} ;
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/split.js
2018-12-13 23:41:57 -05:00
/ * *
* Internal dependencies
* /
/ * *
* Split a Rich Text value in two at the given ` startIndex ` and ` endIndex ` , or
* split at the given separator . This is similar to ` String.prototype.split ` .
* Indices are retrieved from the selection if none are provided .
*
2019-09-19 11:19:18 -04:00
* @ param { Object } value
* @ param { Object [ ] } value . formats
* @ param { Object [ ] } value . replacements
* @ param { string } value . text
* @ param { number } value . start
* @ param { number } value . end
2019-03-21 08:48:00 -04:00
* @ param { number | string } [ string ] Start index , or string at which to split .
2018-12-13 23:41:57 -05:00
*
* @ return { Array } An array of new values .
* /
function split ( _ref , string ) {
var formats = _ref . formats ,
2019-03-21 08:48:00 -04:00
replacements = _ref . replacements ,
2018-12-13 23:41:57 -05:00
text = _ref . text ,
start = _ref . start ,
end = _ref . end ;
if ( typeof string !== 'string' ) {
return splitAtSelection . apply ( void 0 , arguments ) ;
}
var nextStart = 0 ;
return text . split ( string ) . map ( function ( substring ) {
var startIndex = nextStart ;
var value = {
formats : formats . slice ( startIndex , startIndex + substring . length ) ,
2019-03-21 08:48:00 -04:00
replacements : replacements . slice ( startIndex , startIndex + substring . length ) ,
2018-12-13 23:41:57 -05:00
text : substring
} ;
nextStart += string . length + substring . length ;
if ( start !== undefined && end !== undefined ) {
if ( start >= startIndex && start < nextStart ) {
value . start = start - startIndex ;
} else if ( start < startIndex && end > startIndex ) {
value . start = 0 ;
}
if ( end >= startIndex && end < nextStart ) {
value . end = end - startIndex ;
} else if ( start < nextStart && end > nextStart ) {
value . end = substring . length ;
}
}
return value ;
} ) ;
}
function splitAtSelection ( _ref2 ) {
var formats = _ref2 . formats ,
2019-03-21 08:48:00 -04:00
replacements = _ref2 . replacements ,
2018-12-13 23:41:57 -05:00
text = _ref2 . text ,
start = _ref2 . start ,
end = _ref2 . end ;
var startIndex = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : start ;
var endIndex = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : end ;
var before = {
formats : formats . slice ( 0 , startIndex ) ,
2019-03-21 08:48:00 -04:00
replacements : replacements . slice ( 0 , startIndex ) ,
2018-12-13 23:41:57 -05:00
text : text . slice ( 0 , startIndex )
} ;
var after = {
formats : formats . slice ( endIndex ) ,
2019-03-21 08:48:00 -04:00
replacements : replacements . slice ( endIndex ) ,
2018-12-13 23:41:57 -05:00
text : text . slice ( endIndex ) ,
start : 0 ,
end : 0
} ;
return [ // Ensure newlines are trimmed.
2019-09-19 11:19:18 -04:00
replace _replace ( before , /\u2028+$/ , '' ) , replace _replace ( after , /^\u2028+/ , '' ) ] ;
2018-12-13 23:41:57 -05:00
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-format-type.js
2018-12-14 06:02:53 -05:00
/ * *
2018-12-17 22:14:52 -05:00
* WordPress dependencies
2018-12-14 06:02:53 -05:00
* /
/ * *
2018-12-17 22:14:52 -05:00
* Returns a registered format type .
2018-12-14 06:02:53 -05:00
*
2018-12-17 22:14:52 -05:00
* @ param { string } name Format name .
2018-12-14 06:02:53 -05:00
*
2018-12-17 22:14:52 -05:00
* @ return { ? Object } Format type .
2018-12-14 06:02:53 -05:00
* /
2018-12-17 22:14:52 -05:00
function get _format _type _getFormatType ( name ) {
return Object ( external _this _wp _data _ [ "select" ] ) ( 'core/rich-text' ) . getFormatType ( name ) ;
2018-12-14 06:02:53 -05:00
}
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-tree.js
2018-12-14 06:02:53 -05:00
2020-02-06 16:03:31 -05:00
function to _tree _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function to _tree _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { to _tree _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { to _tree _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2018-12-14 06:02:53 -05:00
/ * *
* Internal dependencies
* /
2019-03-07 04:09:59 -05:00
/ * *
* Converts a format object to information that can be used to create an element
* from ( type , attributes and object ) .
*
* @ param { Object } $1 Named parameters .
* @ param { string } $1 . type The format type .
* @ param { Object } $1 . attributes The format attributes .
* @ param { Object } $1 . unregisteredAttributes The unregistered format
* attributes .
* @ param { boolean } $1 . object Wether or not it is an object
* format .
* @ param { boolean } $1 . boundaryClass Wether or not to apply a boundary
* class .
* @ return { Object } Information to be used for
* element creation .
* /
2018-12-17 22:14:52 -05:00
function fromFormat ( _ref ) {
var type = _ref . type ,
attributes = _ref . attributes ,
unregisteredAttributes = _ref . unregisteredAttributes ,
2019-03-07 04:09:59 -05:00
object = _ref . object ,
boundaryClass = _ref . boundaryClass ;
2018-12-17 22:14:52 -05:00
var formatType = get _format _type _getFormatType ( type ) ;
2019-03-07 04:09:59 -05:00
var elementAttributes = { } ;
if ( boundaryClass ) {
elementAttributes [ 'data-rich-text-format-boundary' ] = 'true' ;
}
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( ! formatType ) {
2019-03-07 04:09:59 -05:00
if ( attributes ) {
2020-02-06 16:03:31 -05:00
elementAttributes = to _tree _objectSpread ( { } , attributes , { } , elementAttributes ) ;
2019-03-07 04:09:59 -05:00
}
2018-12-17 22:14:52 -05:00
return {
type : type ,
2019-03-07 04:09:59 -05:00
attributes : elementAttributes ,
2018-12-17 22:14:52 -05:00
object : object
} ;
}
2018-12-14 06:02:53 -05:00
2020-02-06 16:03:31 -05:00
elementAttributes = to _tree _objectSpread ( { } , unregisteredAttributes , { } , elementAttributes ) ;
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
for ( var name in attributes ) {
2019-03-07 04:09:59 -05:00
var key = formatType . attributes ? formatType . attributes [ name ] : false ;
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( key ) {
elementAttributes [ key ] = attributes [ name ] ;
} else {
elementAttributes [ name ] = attributes [ name ] ;
}
}
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( formatType . className ) {
if ( elementAttributes . class ) {
elementAttributes . class = "" . concat ( formatType . className , " " ) . concat ( elementAttributes . class ) ;
} else {
elementAttributes . class = formatType . className ;
}
}
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
return {
type : formatType . tagName ,
object : formatType . object ,
attributes : elementAttributes
} ;
}
2020-01-22 17:06:21 -05:00
/ * *
* Checks if both arrays of formats up until a certain index are equal .
*
* @ param { Array } a Array of formats to compare .
* @ param { Array } b Array of formats to compare .
* @ param { number } index Index to check until .
* /
function isEqualUntil ( a , b , index ) {
do {
if ( a [ index ] !== b [ index ] ) {
return false ;
}
} while ( index -- ) ;
return true ;
}
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
function toTree ( _ref2 ) {
var value = _ref2 . value ,
multilineTag = _ref2 . multilineTag ,
2020-01-08 06:57:23 -05:00
preserveWhiteSpace = _ref2 . preserveWhiteSpace ,
2018-12-17 22:14:52 -05:00
createEmpty = _ref2 . createEmpty ,
append = _ref2 . append ,
getLastChild = _ref2 . getLastChild ,
getParent = _ref2 . getParent ,
isText = _ref2 . isText ,
getText = _ref2 . getText ,
remove = _ref2 . remove ,
appendText = _ref2 . appendText ,
onStartIndex = _ref2 . onStartIndex ,
onEndIndex = _ref2 . onEndIndex ,
2019-09-19 11:19:18 -04:00
isEditableTree = _ref2 . isEditableTree ,
placeholder = _ref2 . placeholder ;
2018-12-17 22:14:52 -05:00
var formats = value . formats ,
2019-03-21 08:48:00 -04:00
replacements = value . replacements ,
2018-12-17 22:14:52 -05:00
text = value . text ,
start = value . start ,
2019-03-07 04:09:59 -05:00
end = value . end ;
2018-12-17 22:14:52 -05:00
var formatsLength = formats . length + 1 ;
var tree = createEmpty ( ) ;
var multilineFormat = {
type : multilineTag
} ;
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
var activeFormats = getActiveFormats ( value ) ;
var deepestActiveFormat = activeFormats [ activeFormats . length - 1 ] ;
2018-12-17 22:14:52 -05:00
var lastSeparatorFormats ;
var lastCharacterFormats ;
var lastCharacter ; // If we're building a multiline tree, start off with a multiline element.
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( multilineTag ) {
append ( append ( tree , {
type : multilineTag
} ) , '' ) ;
lastCharacterFormats = lastSeparatorFormats = [ multilineFormat ] ;
} else {
append ( tree , '' ) ;
}
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
var _loop = function _loop ( i ) {
var character = text . charAt ( i ) ;
2019-03-21 08:48:00 -04:00
var shouldInsertPadding = isEditableTree && ( // Pad the line if the line is empty.
! lastCharacter || lastCharacter === LINE _SEPARATOR || // Pad the line if the previous character is a line break, otherwise
// the line break won't be visible.
lastCharacter === '\n' ) ;
2018-12-17 22:14:52 -05:00
var characterFormats = formats [ i ] ; // Set multiline tags in queue for building the tree.
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( multilineTag ) {
if ( character === LINE _SEPARATOR ) {
2019-03-21 08:48:00 -04:00
characterFormats = lastSeparatorFormats = ( replacements [ i ] || [ ] ) . reduce ( function ( accumulator , format ) {
accumulator . push ( format , multilineFormat ) ;
2018-12-17 22:14:52 -05:00
return accumulator ;
} , [ multilineFormat ] ) ;
} else {
2019-03-07 04:09:59 -05:00
characterFormats = [ ] . concat ( Object ( toConsumableArray [ "a" /* default */ ] ) ( lastSeparatorFormats ) , Object ( toConsumableArray [ "a" /* default */ ] ) ( characterFormats || [ ] ) ) ;
2018-12-17 22:14:52 -05:00
}
}
2018-12-14 06:02:53 -05:00
2019-03-21 08:48:00 -04:00
var pointer = getLastChild ( tree ) ;
2018-12-14 06:02:53 -05:00
2019-03-21 08:48:00 -04:00
if ( shouldInsertPadding && character === LINE _SEPARATOR ) {
2018-12-17 22:14:52 -05:00
var node = pointer ;
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
while ( ! isText ( node ) ) {
node = getLastChild ( node ) ;
}
2018-12-16 23:52:00 -05:00
2019-09-19 11:19:18 -04:00
append ( getParent ( node ) , ZWNBSP ) ;
2019-03-21 08:48:00 -04:00
} // Set selection for the start of line.
if ( lastCharacter === LINE _SEPARATOR ) {
var _node = pointer ;
while ( ! isText ( _node ) ) {
_node = getLastChild ( _node ) ;
}
2018-12-17 22:14:52 -05:00
if ( onStartIndex && start === i ) {
2019-03-21 08:48:00 -04:00
onStartIndex ( tree , _node ) ;
2018-12-17 22:14:52 -05:00
}
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( onEndIndex && end === i ) {
2019-03-21 08:48:00 -04:00
onEndIndex ( tree , _node ) ;
2018-12-17 22:14:52 -05:00
}
}
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( characterFormats ) {
characterFormats . forEach ( function ( format , formatIndex ) {
2020-01-22 17:06:21 -05:00
if ( pointer && lastCharacterFormats && // Reuse the last element if all formats remain the same.
isEqualUntil ( characterFormats , lastCharacterFormats , formatIndex ) && ( // Do not reuse the last element if the character is a
2018-12-17 22:14:52 -05:00
// line separator.
character !== LINE _SEPARATOR || characterFormats . length - 1 !== formatIndex ) ) {
pointer = getLastChild ( pointer ) ;
return ;
}
2018-12-16 23:52:00 -05:00
2019-03-07 04:09:59 -05:00
var type = format . type ,
attributes = format . attributes ,
2019-03-21 08:48:00 -04:00
unregisteredAttributes = format . unregisteredAttributes ;
var boundaryClass = isEditableTree && character !== LINE _SEPARATOR && format === deepestActiveFormat ;
2018-12-17 22:14:52 -05:00
var parent = getParent ( pointer ) ;
2019-03-07 04:09:59 -05:00
var newNode = append ( parent , fromFormat ( {
type : type ,
attributes : attributes ,
unregisteredAttributes : unregisteredAttributes ,
boundaryClass : boundaryClass
} ) ) ;
2018-12-16 23:52:00 -05:00
2018-12-17 22:14:52 -05:00
if ( isText ( pointer ) && getText ( pointer ) . length === 0 ) {
remove ( pointer ) ;
}
2019-03-21 08:48:00 -04:00
pointer = append ( newNode , '' ) ;
2018-12-17 22:14:52 -05:00
} ) ;
} // No need for further processing if the character is a line separator.
if ( character === LINE _SEPARATOR ) {
lastCharacterFormats = characterFormats ;
lastCharacter = character ;
return "continue" ;
2019-03-07 04:09:59 -05:00
} // If there is selection at 0, handle it before characters are inserted.
2018-12-17 22:14:52 -05:00
if ( i === 0 ) {
if ( onStartIndex && start === 0 ) {
onStartIndex ( tree , pointer ) ;
}
if ( onEndIndex && end === 0 ) {
onEndIndex ( tree , pointer ) ;
}
}
2019-03-21 08:48:00 -04:00
if ( character === OBJECT _REPLACEMENT _CHARACTER ) {
2020-02-06 16:03:31 -05:00
pointer = append ( getParent ( pointer ) , fromFormat ( to _tree _objectSpread ( { } , replacements [ i ] , {
2019-03-21 08:48:00 -04:00
object : true
} ) ) ) ; // Ensure pointer is text node.
pointer = append ( getParent ( pointer ) , '' ) ;
2020-01-08 06:57:23 -05:00
} else if ( ! preserveWhiteSpace && character === '\n' ) {
2019-03-21 08:48:00 -04:00
pointer = append ( getParent ( pointer ) , {
type : 'br' ,
attributes : isEditableTree ? {
'data-rich-text-line-break' : 'true'
} : undefined ,
object : true
} ) ; // Ensure pointer is text node.
pointer = append ( getParent ( pointer ) , '' ) ;
} else if ( ! isText ( pointer ) ) {
pointer = append ( getParent ( pointer ) , character ) ;
} else {
appendText ( pointer , character ) ;
2018-12-17 22:14:52 -05:00
}
if ( onStartIndex && start === i + 1 ) {
onStartIndex ( tree , pointer ) ;
}
2018-12-16 23:52:00 -05:00
2018-12-17 22:14:52 -05:00
if ( onEndIndex && end === i + 1 ) {
onEndIndex ( tree , pointer ) ;
2018-12-16 23:52:00 -05:00
}
2019-03-21 08:48:00 -04:00
if ( shouldInsertPadding && i === text . length ) {
2019-09-19 11:19:18 -04:00
append ( getParent ( pointer ) , ZWNBSP ) ;
if ( placeholder && text . length === 0 ) {
append ( getParent ( pointer ) , {
type : 'span' ,
attributes : {
'data-rich-text-placeholder' : placeholder ,
// Necessary to prevent the placeholder from catching
// selection. The placeholder is also not editable after
// all.
contenteditable : 'false'
}
} ) ;
}
2019-03-21 08:48:00 -04:00
}
2018-12-17 22:14:52 -05:00
lastCharacterFormats = characterFormats ;
lastCharacter = character ;
} ;
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
for ( var i = 0 ; i < formatsLength ; i ++ ) {
var _ret = _loop ( i ) ;
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
if ( _ret === "continue" ) continue ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
return tree ;
}
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-dom.js
2018-12-16 23:52:00 -05:00
2018-12-13 23:41:57 -05:00
2020-02-06 16:03:31 -05:00
function to _dom _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function to _dom _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { to _dom _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { to _dom _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2018-12-13 23:41:57 -05:00
/ * *
* Internal dependencies
* /
2018-12-18 22:16:48 -05:00
2018-12-13 23:41:57 -05:00
/ * *
* Browser dependencies
* /
2019-03-07 04:09:59 -05:00
var to _dom _TEXT _NODE = window . Node . TEXT _NODE ;
2018-12-13 23:41:57 -05:00
/ * *
* Creates a path as an array of indices from the given root node to the given
* node .
*
* @ param { Node } node Node to find the path of .
* @ param { HTMLElement } rootNode Root node to find the path from .
* @ param { Array } path Initial path to build on .
*
* @ return { Array } The path from the root node to the node .
* /
function createPathToNode ( node , rootNode , path ) {
var parentNode = node . parentNode ;
var i = 0 ;
while ( node = node . previousSibling ) {
i ++ ;
}
2018-12-17 22:14:52 -05:00
path = [ i ] . concat ( Object ( toConsumableArray [ "a" /* default */ ] ) ( path ) ) ;
2018-12-13 23:41:57 -05:00
if ( parentNode !== rootNode ) {
path = createPathToNode ( parentNode , rootNode , path ) ;
}
return path ;
}
/ * *
* Gets a node given a path ( array of indices ) from the given node .
*
* @ param { HTMLElement } node Root node to find the wanted node in .
* @ param { Array } path Path ( indices ) to the wanted node .
*
* @ return { Object } Object with the found node and the remaining offset ( if any ) .
* /
function getNodeByPath ( node , path ) {
2018-12-17 22:14:52 -05:00
path = Object ( toConsumableArray [ "a" /* default */ ] ) ( path ) ;
2018-12-13 23:41:57 -05:00
while ( node && path . length > 1 ) {
node = node . childNodes [ path . shift ( ) ] ;
}
return {
node : node ,
offset : path [ 0 ]
} ;
}
2018-12-18 22:16:48 -05:00
/ * *
* Returns a new instance of a DOM tree upon which RichText operations can be
* applied .
*
* Note : The current implementation will return a shared reference , reset on
* each call to ` createEmpty ` . Therefore , you should not hold a reference to
* the value to operate upon asynchronously , as it may have unexpected results .
*
2020-01-08 06:57:23 -05:00
* @ return { Object } RichText tree .
2018-12-18 22:16:48 -05:00
* /
2018-12-13 23:41:57 -05:00
2018-12-18 22:16:48 -05:00
var to _dom _createEmpty = function createEmpty ( ) {
return createElement ( document , '' ) ;
} ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
function to _dom _append ( element , child ) {
2018-12-13 23:41:57 -05:00
if ( typeof child === 'string' ) {
child = element . ownerDocument . createTextNode ( child ) ;
}
var _child = child ,
type = _child . type ,
attributes = _child . attributes ;
if ( type ) {
child = element . ownerDocument . createElement ( type ) ;
for ( var key in attributes ) {
child . setAttribute ( key , attributes [ key ] ) ;
}
}
return element . appendChild ( child ) ;
}
2018-12-17 22:14:52 -05:00
function to _dom _appendText ( node , text ) {
2018-12-13 23:41:57 -05:00
node . appendData ( text ) ;
}
2018-12-17 22:14:52 -05:00
function to _dom _getLastChild ( _ref ) {
2018-12-13 23:41:57 -05:00
var lastChild = _ref . lastChild ;
return lastChild ;
}
2018-12-17 22:14:52 -05:00
function to _dom _getParent ( _ref2 ) {
2018-12-13 23:41:57 -05:00
var parentNode = _ref2 . parentNode ;
return parentNode ;
}
2018-12-17 22:14:52 -05:00
function to _dom _isText ( _ref3 ) {
2018-12-13 23:41:57 -05:00
var nodeType = _ref3 . nodeType ;
2018-12-17 22:14:52 -05:00
return nodeType === to _dom _TEXT _NODE ;
2018-12-13 23:41:57 -05:00
}
2018-12-17 22:14:52 -05:00
function to _dom _getText ( _ref4 ) {
2018-12-13 23:41:57 -05:00
var nodeValue = _ref4 . nodeValue ;
return nodeValue ;
}
2018-12-17 22:14:52 -05:00
function to _dom _remove ( node ) {
2018-12-13 23:41:57 -05:00
return node . parentNode . removeChild ( node ) ;
}
2019-03-21 08:48:00 -04:00
function toDom ( _ref5 ) {
var value = _ref5 . value ,
multilineTag = _ref5 . multilineTag ,
prepareEditableTree = _ref5 . prepareEditableTree ,
_ref5$isEditableTree = _ref5 . isEditableTree ,
2019-09-19 11:19:18 -04:00
isEditableTree = _ref5$isEditableTree === void 0 ? true : _ref5$isEditableTree ,
placeholder = _ref5 . placeholder ;
2018-12-13 23:41:57 -05:00
var startPath = [ ] ;
var endPath = [ ] ;
2019-09-19 11:19:18 -04:00
if ( prepareEditableTree ) {
2020-02-06 16:03:31 -05:00
value = to _dom _objectSpread ( { } , value , {
2019-09-19 11:19:18 -04:00
formats : prepareEditableTree ( value )
} ) ;
}
2018-12-17 22:14:52 -05:00
var tree = toTree ( {
2019-09-19 11:19:18 -04:00
value : value ,
2018-12-15 06:00:40 -05:00
multilineTag : multilineTag ,
2018-12-17 22:14:52 -05:00
createEmpty : to _dom _createEmpty ,
append : to _dom _append ,
getLastChild : to _dom _getLastChild ,
getParent : to _dom _getParent ,
isText : to _dom _isText ,
getText : to _dom _getText ,
remove : to _dom _remove ,
appendText : to _dom _appendText ,
2018-12-15 06:00:40 -05:00
onStartIndex : function onStartIndex ( body , pointer ) {
2018-12-13 23:41:57 -05:00
startPath = createPathToNode ( pointer , body , [ pointer . nodeValue . length ] ) ;
} ,
2018-12-15 06:00:40 -05:00
onEndIndex : function onEndIndex ( body , pointer ) {
2018-12-13 23:41:57 -05:00
endPath = createPathToNode ( pointer , body , [ pointer . nodeValue . length ] ) ;
} ,
2019-09-19 11:19:18 -04:00
isEditableTree : isEditableTree ,
placeholder : placeholder
2018-12-13 23:41:57 -05:00
} ) ;
return {
body : tree ,
selection : {
startPath : startPath ,
endPath : endPath
}
} ;
}
/ * *
* Create an ` Element ` tree from a Rich Text value and applies the difference to
* the ` Element ` tree contained by ` current ` . If a ` multilineTag ` is provided ,
* text separated by two new lines will be wrapped in an ` Element ` of that type .
*
2019-03-21 08:48:00 -04:00
* @ param { Object } $1 Named arguments .
* @ param { Object } $1 . value Value to apply .
* @ param { HTMLElement } $1 . current The live root node to apply the element tree to .
* @ param { string } [ $1 . multilineTag ] Multiline tag .
* @ param { Array } [ $1 . multilineWrapperTags ] Tags where lines can be found if nesting is possible .
2018-12-13 23:41:57 -05:00
* /
2019-03-21 08:48:00 -04:00
function apply ( _ref6 ) {
var value = _ref6 . value ,
current = _ref6 . current ,
multilineTag = _ref6 . multilineTag ,
prepareEditableTree = _ref6 . prepareEditableTree ,
2019-09-19 11:19:18 -04:00
_ _unstableDomOnly = _ref6 . _ _unstableDomOnly ,
placeholder = _ref6 . placeholder ;
2018-12-15 06:00:40 -05:00
2018-12-13 23:41:57 -05:00
// Construct a new element tree in memory.
2018-12-15 06:00:40 -05:00
var _toDom = toDom ( {
value : value ,
multilineTag : multilineTag ,
2019-09-19 11:19:18 -04:00
prepareEditableTree : prepareEditableTree ,
placeholder : placeholder
2018-12-15 06:00:40 -05:00
} ) ,
2018-12-13 23:41:57 -05:00
body = _toDom . body ,
selection = _toDom . selection ;
applyValue ( body , current ) ;
2019-03-07 04:09:59 -05:00
if ( value . start !== undefined && ! _ _unstableDomOnly ) {
2018-12-13 23:41:57 -05:00
applySelection ( selection , current ) ;
}
}
function applyValue ( future , current ) {
var i = 0 ;
2018-12-18 22:16:48 -05:00
var futureChild ;
2018-12-13 23:41:57 -05:00
2018-12-18 22:16:48 -05:00
while ( futureChild = future . firstChild ) {
2018-12-13 23:41:57 -05:00
var currentChild = current . childNodes [ i ] ;
if ( ! currentChild ) {
2018-12-18 22:16:48 -05:00
current . appendChild ( futureChild ) ;
} else if ( ! currentChild . isEqualNode ( futureChild ) ) {
2019-03-07 04:09:59 -05:00
if ( currentChild . nodeName !== futureChild . nodeName || currentChild . nodeType === to _dom _TEXT _NODE && currentChild . data !== futureChild . data ) {
current . replaceChild ( futureChild , currentChild ) ;
} else {
var currentAttributes = currentChild . attributes ;
var futureAttributes = futureChild . attributes ;
if ( currentAttributes ) {
2019-09-19 11:19:18 -04:00
var ii = currentAttributes . length ; // Reverse loop because `removeAttribute` on `currentChild`
// changes `currentAttributes`.
while ( ii -- ) {
2019-03-07 04:09:59 -05:00
var name = currentAttributes [ ii ] . name ;
if ( ! futureChild . getAttribute ( name ) ) {
currentChild . removeAttribute ( name ) ;
}
}
}
if ( futureAttributes ) {
for ( var _ii = 0 ; _ii < futureAttributes . length ; _ii ++ ) {
var _futureAttributes$ _ii = futureAttributes [ _ii ] ,
2020-02-06 16:03:31 -05:00
_name = _futureAttributes$ _ii . name ,
2019-03-07 04:09:59 -05:00
value = _futureAttributes$ _ii . value ;
2020-02-06 16:03:31 -05:00
if ( currentChild . getAttribute ( _name ) !== value ) {
currentChild . setAttribute ( _name , value ) ;
2019-03-07 04:09:59 -05:00
}
}
}
applyValue ( futureChild , currentChild ) ;
future . removeChild ( futureChild ) ;
}
2018-12-13 23:41:57 -05:00
} else {
2018-12-18 22:16:48 -05:00
future . removeChild ( futureChild ) ;
2018-12-13 23:41:57 -05:00
}
i ++ ;
}
while ( current . childNodes [ i ] ) {
current . removeChild ( current . childNodes [ i ] ) ;
}
}
2018-12-18 22:16:48 -05:00
/ * *
* Returns true if two ranges are equal , or false otherwise . Ranges are
* considered equal if their start and end occur in the same container and
* offset .
*
* @ param { Range } a First range object to test .
* @ param { Range } b First range object to test .
*
* @ return { boolean } Whether the two ranges are equal .
* /
function isRangeEqual ( a , b ) {
return a . startContainer === b . startContainer && a . startOffset === b . startOffset && a . endContainer === b . endContainer && a . endOffset === b . endOffset ;
}
2019-03-21 08:48:00 -04:00
function applySelection ( _ref7 , current ) {
var startPath = _ref7 . startPath ,
endPath = _ref7 . endPath ;
2019-03-07 04:09:59 -05:00
var _getNodeByPath = getNodeByPath ( current , startPath ) ,
2018-12-13 23:41:57 -05:00
startContainer = _getNodeByPath . node ,
startOffset = _getNodeByPath . offset ;
2019-03-07 04:09:59 -05:00
var _getNodeByPath2 = getNodeByPath ( current , endPath ) ,
2018-12-13 23:41:57 -05:00
endContainer = _getNodeByPath2 . node ,
endOffset = _getNodeByPath2 . offset ;
2019-03-07 04:09:59 -05:00
var selection = window . getSelection ( ) ;
var ownerDocument = current . ownerDocument ;
var range = ownerDocument . createRange ( ) ;
range . setStart ( startContainer , startOffset ) ;
2020-02-06 16:03:31 -05:00
range . setEnd ( endContainer , endOffset ) ;
var activeElement = ownerDocument . activeElement ;
2018-12-13 23:41:57 -05:00
2019-03-07 04:09:59 -05:00
if ( selection . rangeCount > 0 ) {
2018-12-18 22:16:48 -05:00
// If the to be added range and the live range are the same, there's no
// need to remove the live range and add the equivalent range.
2019-03-07 04:09:59 -05:00
if ( isRangeEqual ( range , selection . getRangeAt ( 0 ) ) ) {
2018-12-18 22:16:48 -05:00
return ;
}
2019-03-07 04:09:59 -05:00
selection . removeAllRanges ( ) ;
2018-12-18 22:16:48 -05:00
}
2020-03-02 18:21:15 -05:00
selection . addRange ( range ) ; // This function is not intended to cause a shift in focus. Since the above
// selection manipulations may shift focus, ensure that focus is restored to
2020-03-23 19:40:19 -04:00
// its previous state.
2020-03-02 18:21:15 -05:00
if ( activeElement !== document . activeElement ) {
// The `instanceof` checks protect against edge cases where the focused
// element is not of the interface HTMLElement (does not have a `focus`
// or `blur` property).
//
// See: https://github.com/Microsoft/TypeScript/issues/5901#issuecomment-431649653
2020-03-23 19:40:19 -04:00
if ( activeElement instanceof window . HTMLElement ) {
activeElement . focus ( ) ;
2020-03-02 18:21:15 -05:00
}
}
2018-12-13 23:41:57 -05:00
}
2018-12-17 22:14:52 -05:00
// EXTERNAL MODULE: external {"this":["wp","escapeHtml"]}
2020-03-23 19:40:19 -04:00
var external _this _wp _escapeHtml _ = _ _webpack _require _ _ ( 68 ) ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-html-string.js
2018-12-13 23:41:57 -05:00
/ * *
2019-03-07 04:09:59 -05:00
* WordPress dependencies
2018-12-13 23:41:57 -05:00
* /
/ * *
* Internal dependencies
* /
/ * *
* Create an HTML string from a Rich Text value . If a ` multilineTag ` is
2018-12-15 06:00:40 -05:00
* provided , text separated by a line separator will be wrapped in it .
2018-12-13 23:41:57 -05:00
*
2020-01-08 06:57:23 -05:00
* @ param { Object } $1 Named argements .
* @ param { Object } $1 . value Rich text value .
* @ param { string } [ $1 . multilineTag ] Multiline tag .
* @ param { ? boolean } [ $1 . preserveWhiteSpace ] Whether or not to use newline
* characters for line breaks .
2018-12-13 23:41:57 -05:00
*
* @ return { string } HTML string .
* /
2018-12-15 06:00:40 -05:00
function toHTMLString ( _ref ) {
var value = _ref . value ,
2020-01-08 06:57:23 -05:00
multilineTag = _ref . multilineTag ,
preserveWhiteSpace = _ref . preserveWhiteSpace ;
2018-12-17 22:14:52 -05:00
var tree = toTree ( {
2018-12-15 06:00:40 -05:00
value : value ,
multilineTag : multilineTag ,
2020-01-08 06:57:23 -05:00
preserveWhiteSpace : preserveWhiteSpace ,
2018-12-17 22:14:52 -05:00
createEmpty : to _html _string _createEmpty ,
append : to _html _string _append ,
getLastChild : to _html _string _getLastChild ,
getParent : to _html _string _getParent ,
isText : to _html _string _isText ,
getText : to _html _string _getText ,
remove : to _html _string _remove ,
appendText : to _html _string _appendText
2018-12-13 23:41:57 -05:00
} ) ;
return createChildrenHTML ( tree . children ) ;
}
2018-12-17 22:14:52 -05:00
function to _html _string _createEmpty ( ) {
2018-12-15 06:00:40 -05:00
return { } ;
2018-12-13 23:41:57 -05:00
}
2018-12-17 22:14:52 -05:00
function to _html _string _getLastChild ( _ref2 ) {
2018-12-15 06:00:40 -05:00
var children = _ref2 . children ;
2018-12-13 23:41:57 -05:00
return children && children [ children . length - 1 ] ;
}
2018-12-17 22:14:52 -05:00
function to _html _string _append ( parent , object ) {
2018-12-13 23:41:57 -05:00
if ( typeof object === 'string' ) {
object = {
text : object
} ;
}
object . parent = parent ;
parent . children = parent . children || [ ] ;
parent . children . push ( object ) ;
return object ;
}
2018-12-17 22:14:52 -05:00
function to _html _string _appendText ( object , text ) {
2018-12-13 23:41:57 -05:00
object . text += text ;
}
2018-12-17 22:14:52 -05:00
function to _html _string _getParent ( _ref3 ) {
2018-12-15 06:00:40 -05:00
var parent = _ref3 . parent ;
2018-12-13 23:41:57 -05:00
return parent ;
}
2018-12-17 22:14:52 -05:00
function to _html _string _isText ( _ref4 ) {
2018-12-15 06:00:40 -05:00
var text = _ref4 . text ;
2018-12-13 23:41:57 -05:00
return typeof text === 'string' ;
}
2018-12-17 22:14:52 -05:00
function to _html _string _getText ( _ref5 ) {
2018-12-15 06:00:40 -05:00
var text = _ref5 . text ;
2018-12-13 23:41:57 -05:00
return text ;
}
2018-12-17 22:14:52 -05:00
function to _html _string _remove ( object ) {
2018-12-13 23:41:57 -05:00
var index = object . parent . children . indexOf ( object ) ;
if ( index !== - 1 ) {
object . parent . children . splice ( index , 1 ) ;
}
return object ;
}
2018-12-15 06:00:40 -05:00
function createElementHTML ( _ref6 ) {
var type = _ref6 . type ,
attributes = _ref6 . attributes ,
object = _ref6 . object ,
children = _ref6 . children ;
2018-12-13 23:41:57 -05:00
var attributeString = '' ;
for ( var key in attributes ) {
2018-12-17 22:14:52 -05:00
if ( ! Object ( external _this _wp _escapeHtml _ [ "isValidAttributeName" ] ) ( key ) ) {
2018-12-13 23:53:54 -05:00
continue ;
}
2018-12-17 22:14:52 -05:00
attributeString += " " . concat ( key , "=\"" ) . concat ( Object ( external _this _wp _escapeHtml _ [ "escapeAttribute" ] ) ( attributes [ key ] ) , "\"" ) ;
2018-12-13 23:41:57 -05:00
}
if ( object ) {
return "<" . concat ( type ) . concat ( attributeString , ">" ) ;
}
return "<" . concat ( type ) . concat ( attributeString , ">" ) . concat ( createChildrenHTML ( children ) , "</" ) . concat ( type , ">" ) ;
}
2018-12-17 22:14:52 -05:00
function createChildrenHTML ( ) {
var children = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : [ ] ;
return children . map ( function ( child ) {
2020-01-08 06:57:23 -05:00
return child . text === undefined ? createElementHTML ( child ) : Object ( external _this _wp _escapeHtml _ [ "escapeEditableHTML" ] ) ( child . text ) ;
2018-12-17 22:14:52 -05:00
} ) . join ( '' ) ;
}
2018-12-14 06:02:53 -05:00
2018-12-17 22:14:52 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/toggle-format.js
2018-12-14 06:02:53 -05:00
/ * *
* Internal dependencies
* /
/ * *
* Toggles a format object to a Rich Text value at the current selection .
*
2019-03-21 08:48:00 -04:00
* @ param { Object } value Value to modify .
* @ param { Object } format Format to apply or remove .
2018-12-14 06:02:53 -05:00
*
* @ return { Object } A new value with the format applied or removed .
* /
function toggleFormat ( value , format ) {
2018-12-17 22:14:52 -05:00
if ( getActiveFormat ( value , format . type ) ) {
return removeFormat ( value , format . type ) ;
2018-12-14 06:02:53 -05:00
}
2020-01-08 06:57:23 -05:00
return applyFormat ( value , format ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/unregister-format-type.js
/ * *
* WordPress dependencies
* /
/** @typedef {import('./register-format-type').WPFormat} WPFormat */
/ * *
* Unregisters a format .
*
* @ param { string } name Format name .
*
* @ return { WPFormat | undefined } The previous format value , if it has been successfully
* unregistered ; otherwise ` undefined ` .
* /
function unregisterFormatType ( name ) {
var oldFormat = Object ( external _this _wp _data _ [ "select" ] ) ( 'core/rich-text' ) . getFormatType ( name ) ;
if ( ! oldFormat ) {
window . console . error ( "Format " . concat ( name , " is not registered." ) ) ;
return ;
}
Object ( external _this _wp _data _ [ "dispatch" ] ) ( 'core/rich-text' ) . removeFormatTypes ( name ) ;
return oldFormat ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/can-indent-list-items.js
/ * *
* Internal dependencies
* /
/ * *
* Checks if the selected list item can be indented .
*
* @ param { Object } value Value to check .
*
* @ return { boolean } Whether or not the selected list item can be indented .
* /
function canIndentListItems ( value ) {
var lineIndex = getLineIndex ( value ) ; // There is only one line, so the line cannot be indented.
if ( lineIndex === undefined ) {
return false ;
}
var replacements = value . replacements ;
var previousLineIndex = getLineIndex ( value , lineIndex ) ;
var formatsAtLineIndex = replacements [ lineIndex ] || [ ] ;
var formatsAtPreviousLineIndex = replacements [ previousLineIndex ] || [ ] ; // If the indentation of the current line is greater than previous line,
// then the line cannot be furter indented.
return formatsAtLineIndex . length <= formatsAtPreviousLineIndex . length ;
2018-12-14 06:02:53 -05:00
}
2020-01-08 06:57:23 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/can-outdent-list-items.js
2018-12-14 06:02:53 -05:00
/ * *
2020-01-08 06:57:23 -05:00
* Internal dependencies
2018-12-14 06:02:53 -05:00
* /
/ * *
2020-01-08 06:57:23 -05:00
* Checks if the selected list item can be outdented .
2018-12-14 06:02:53 -05:00
*
2020-01-08 06:57:23 -05:00
* @ param { Object } value Value to check .
2018-12-14 06:02:53 -05:00
*
2020-01-08 06:57:23 -05:00
* @ return { boolean } Whether or not the selected list item can be outdented .
2018-12-14 06:02:53 -05:00
* /
2020-01-08 06:57:23 -05:00
function canOutdentListItems ( value ) {
var replacements = value . replacements ,
start = value . start ;
var startingLineIndex = getLineIndex ( value , start ) ;
return replacements [ startingLineIndex ] !== undefined ;
2018-12-14 06:02:53 -05:00
}
2019-01-29 13:23:55 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/indent-list-items.js
2019-03-21 08:48:00 -04:00
2020-02-06 16:03:31 -05:00
function indent _list _items _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function indent _list _items _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { indent _list _items _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { indent _list _items _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2019-01-29 13:23:55 -05:00
/ * *
* Internal dependencies
* /
2020-01-08 06:57:23 -05:00
2019-01-29 13:23:55 -05:00
/ * *
* Gets the line index of the first previous list item with higher indentation .
*
* @ param { Object } value Value to search .
* @ param { number } lineIndex Line index of the list item to compare with .
*
* @ return { boolean } The line index .
* /
function getTargetLevelLineIndex ( _ref , lineIndex ) {
var text = _ref . text ,
2019-03-21 08:48:00 -04:00
replacements = _ref . replacements ;
var startFormats = replacements [ lineIndex ] || [ ] ;
2019-01-29 13:23:55 -05:00
var index = lineIndex ;
while ( index -- >= 0 ) {
if ( text [ index ] !== LINE _SEPARATOR ) {
continue ;
}
2019-03-21 08:48:00 -04:00
var formatsAtIndex = replacements [ index ] || [ ] ; // Return the first line index that is one level higher. If the level is
2019-01-29 13:23:55 -05:00
// lower or equal, there is no result.
if ( formatsAtIndex . length === startFormats . length + 1 ) {
return index ;
} else if ( formatsAtIndex . length <= startFormats . length ) {
return ;
}
}
}
/ * *
* Indents any selected list items if possible .
*
* @ param { Object } value Value to change .
2019-03-21 08:48:00 -04:00
* @ param { Object } rootFormat Root format .
2019-01-29 13:23:55 -05:00
*
* @ return { Object } The changed value .
* /
function indentListItems ( value , rootFormat ) {
2020-01-08 06:57:23 -05:00
if ( ! canIndentListItems ( value ) ) {
2019-01-29 13:23:55 -05:00
return value ;
}
2020-01-08 06:57:23 -05:00
var lineIndex = getLineIndex ( value ) ;
var previousLineIndex = getLineIndex ( value , lineIndex ) ;
2019-01-29 13:23:55 -05:00
var text = value . text ,
2019-03-21 08:48:00 -04:00
replacements = value . replacements ,
2019-01-29 13:23:55 -05:00
end = value . end ;
2019-03-21 08:48:00 -04:00
var newFormats = replacements . slice ( ) ;
2019-01-29 13:23:55 -05:00
var targetLevelLineIndex = getTargetLevelLineIndex ( value , lineIndex ) ;
for ( var index = lineIndex ; index < end ; index ++ ) {
if ( text [ index ] !== LINE _SEPARATOR ) {
continue ;
} // Get the previous list, and if there's a child list, take over the
// formats. If not, duplicate the last level and create a new level.
if ( targetLevelLineIndex ) {
2019-03-21 08:48:00 -04:00
var targetFormats = replacements [ targetLevelLineIndex ] || [ ] ;
2019-01-29 13:23:55 -05:00
newFormats [ index ] = targetFormats . concat ( ( newFormats [ index ] || [ ] ) . slice ( targetFormats . length - 1 ) ) ;
} else {
2019-03-21 08:48:00 -04:00
var _targetFormats = replacements [ previousLineIndex ] || [ ] ;
2019-01-29 13:23:55 -05:00
var lastformat = _targetFormats [ _targetFormats . length - 1 ] || rootFormat ;
newFormats [ index ] = _targetFormats . concat ( [ lastformat ] , ( newFormats [ index ] || [ ] ) . slice ( _targetFormats . length ) ) ;
}
}
2020-02-06 16:03:31 -05:00
return indent _list _items _objectSpread ( { } , value , {
2019-03-21 08:48:00 -04:00
replacements : newFormats
2019-01-29 13:23:55 -05:00
} ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-parent-line-index.js
/ * *
* Internal dependencies
* /
/ * *
* Gets the index of the first parent list . To get the parent list formats , we
* go through every list item until we find one with exactly one format type
* less .
*
* @ param { Object } value Value to search .
* @ param { number } lineIndex Line index of a child list item .
*
* @ return { Array } The parent list line index .
* /
function getParentLineIndex ( _ref , lineIndex ) {
var text = _ref . text ,
2019-03-21 08:48:00 -04:00
replacements = _ref . replacements ;
var startFormats = replacements [ lineIndex ] || [ ] ;
2019-01-29 13:23:55 -05:00
var index = lineIndex ;
while ( index -- >= 0 ) {
if ( text [ index ] !== LINE _SEPARATOR ) {
continue ;
}
2019-03-21 08:48:00 -04:00
var formatsAtIndex = replacements [ index ] || [ ] ;
2019-01-29 13:23:55 -05:00
if ( formatsAtIndex . length === startFormats . length - 1 ) {
return index ;
}
}
}
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-last-child-index.js
/ * *
* Internal dependencies
* /
/ * *
* Gets the line index of the last child in the list .
*
* @ param { Object } value Value to search .
* @ param { number } lineIndex Line index of a list item in the list .
*
* @ return { Array } The index of the last child .
* /
function getLastChildIndex ( _ref , lineIndex ) {
var text = _ref . text ,
2019-03-21 08:48:00 -04:00
replacements = _ref . replacements ;
var lineFormats = replacements [ lineIndex ] || [ ] ; // Use the given line index in case there are no next children.
2019-01-29 13:23:55 -05:00
var childIndex = lineIndex ; // `lineIndex` could be `undefined` if it's the first line.
for ( var index = lineIndex || 0 ; index < text . length ; index ++ ) {
// We're only interested in line indices.
if ( text [ index ] !== LINE _SEPARATOR ) {
continue ;
}
2019-03-21 08:48:00 -04:00
var formatsAtIndex = replacements [ index ] || [ ] ; // If the amout of formats is equal or more, store it, then return the
2019-01-29 13:23:55 -05:00
// last one if the amount of formats is less.
if ( formatsAtIndex . length >= lineFormats . length ) {
childIndex = index ;
} else {
return childIndex ;
}
} // If the end of the text is reached, return the last child index.
return childIndex ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/outdent-list-items.js
2019-03-21 08:48:00 -04:00
2020-02-06 16:03:31 -05:00
function outdent _list _items _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function outdent _list _items _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { outdent _list _items _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { outdent _list _items _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2019-01-29 13:23:55 -05:00
/ * *
* Internal dependencies
* /
2020-01-08 06:57:23 -05:00
2019-01-29 13:23:55 -05:00
/ * *
* Outdents any selected list items if possible .
*
* @ param { Object } value Value to change .
*
* @ return { Object } The changed value .
* /
function outdentListItems ( value ) {
2020-01-08 06:57:23 -05:00
if ( ! canOutdentListItems ( value ) ) {
return value ;
}
2019-01-29 13:23:55 -05:00
var text = value . text ,
2019-03-21 08:48:00 -04:00
replacements = value . replacements ,
2019-01-29 13:23:55 -05:00
start = value . start ,
end = value . end ;
2020-01-08 06:57:23 -05:00
var startingLineIndex = getLineIndex ( value , start ) ;
2019-03-21 08:48:00 -04:00
var newFormats = replacements . slice ( 0 ) ;
var parentFormats = replacements [ getParentLineIndex ( value , startingLineIndex ) ] || [ ] ;
2019-01-29 13:23:55 -05:00
var endingLineIndex = getLineIndex ( value , end ) ;
var lastChildIndex = getLastChildIndex ( value , endingLineIndex ) ; // Outdent all list items from the starting line index until the last child
// index of the ending list. All children of the ending list need to be
// outdented, otherwise they'll be orphaned.
for ( var index = startingLineIndex ; index <= lastChildIndex ; index ++ ) {
// Skip indices that are not line separators.
if ( text [ index ] !== LINE _SEPARATOR ) {
continue ;
} // In the case of level 0, the formats at the index are undefined.
var currentFormats = newFormats [ index ] || [ ] ; // Omit the indentation level where the selection starts.
newFormats [ index ] = parentFormats . concat ( currentFormats . slice ( parentFormats . length + 1 ) ) ;
if ( newFormats [ index ] . length === 0 ) {
delete newFormats [ index ] ;
}
}
2020-02-06 16:03:31 -05:00
return outdent _list _items _objectSpread ( { } , value , {
2019-03-21 08:48:00 -04:00
replacements : newFormats
2019-01-29 13:23:55 -05:00
} ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/change-list-type.js
2019-03-21 08:48:00 -04:00
2020-02-06 16:03:31 -05:00
function change _list _type _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function change _list _type _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { change _list _type _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { change _list _type _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2019-01-29 13:23:55 -05:00
/ * *
* Internal dependencies
* /
/ * *
* Changes the list type of the selected indented list , if any . Looks at the
* currently selected list item and takes the parent list , then changes the list
2019-03-07 04:09:59 -05:00
* type of this list . When multiple lines are selected , the parent lists are
* takes and changed .
2018-12-14 06:02:53 -05:00
*
2019-03-07 04:09:59 -05:00
* @ param { Object } value Value to change .
* @ param { Object } newFormat The new list format object . Choose between
* ` { type: 'ol' } ` and ` { type: 'ul' } ` .
2018-12-14 06:02:53 -05:00
*
2019-03-07 04:09:59 -05:00
* @ return { Object } The changed value .
2018-12-14 06:02:53 -05:00
* /
2019-03-07 04:09:59 -05:00
function changeListType ( value , newFormat ) {
var text = value . text ,
2019-03-21 08:48:00 -04:00
replacements = value . replacements ,
2019-03-07 04:09:59 -05:00
start = value . start ,
end = value . end ;
var startingLineIndex = getLineIndex ( value , start ) ;
2019-03-21 08:48:00 -04:00
var startLineFormats = replacements [ startingLineIndex ] || [ ] ;
var endLineFormats = replacements [ getLineIndex ( value , end ) ] || [ ] ;
2019-03-07 04:09:59 -05:00
var startIndex = getParentLineIndex ( value , startingLineIndex ) ;
2019-03-21 08:48:00 -04:00
var newReplacements = replacements . slice ( ) ;
2019-03-07 04:09:59 -05:00
var startCount = startLineFormats . length - 1 ;
var endCount = endLineFormats . length - 1 ;
var changed ;
2018-12-14 06:02:53 -05:00
2019-03-07 04:09:59 -05:00
for ( var index = startIndex + 1 || 0 ; index < text . length ; index ++ ) {
if ( text [ index ] !== LINE _SEPARATOR ) {
continue ;
}
2018-12-14 06:02:53 -05:00
2019-03-21 08:48:00 -04:00
if ( ( newReplacements [ index ] || [ ] ) . length <= startCount ) {
2019-03-07 04:09:59 -05:00
break ;
}
2019-03-21 08:48:00 -04:00
if ( ! newReplacements [ index ] ) {
2019-03-07 04:09:59 -05:00
continue ;
}
changed = true ;
2019-03-21 08:48:00 -04:00
newReplacements [ index ] = newReplacements [ index ] . map ( function ( format , i ) {
2019-03-07 04:09:59 -05:00
return i < startCount || i > endCount ? format : newFormat ;
} ) ;
}
if ( ! changed ) {
return value ;
}
2020-02-06 16:03:31 -05:00
return change _list _type _objectSpread ( { } , value , {
2019-03-21 08:48:00 -04:00
replacements : newReplacements
2019-03-07 04:09:59 -05:00
} ) ;
2018-12-14 06:02:53 -05:00
}
2019-09-19 11:19:18 -04:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
2020-02-10 17:33:27 -05:00
var esm _extends = _ _webpack _require _ _ ( 12 ) ;
2019-09-19 11:19:18 -04:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
2020-02-10 17:33:27 -05:00
var classCallCheck = _ _webpack _require _ _ ( 14 ) ;
2019-09-19 11:19:18 -04:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
2020-02-10 17:33:27 -05:00
var createClass = _ _webpack _require _ _ ( 13 ) ;
2019-09-19 11:19:18 -04:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
2020-02-10 17:33:27 -05:00
var possibleConstructorReturn = _ _webpack _require _ _ ( 15 ) ;
2019-09-19 11:19:18 -04:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
2020-02-10 17:33:27 -05:00
var getPrototypeOf = _ _webpack _require _ _ ( 16 ) ;
2019-09-19 11:19:18 -04:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
2020-01-22 17:06:21 -05:00
var assertThisInitialized = _ _webpack _require _ _ ( 7 ) ;
2019-09-19 11:19:18 -04:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules
2020-02-10 17:33:27 -05:00
var inherits = _ _webpack _require _ _ ( 17 ) ;
2019-09-19 11:19:18 -04:00
2020-01-22 17:06:21 -05:00
// EXTERNAL MODULE: external {"this":["wp","element"]}
var external _this _wp _element _ = _ _webpack _require _ _ ( 0 ) ;
2019-09-19 11:19:18 -04:00
// EXTERNAL MODULE: ./node_modules/classnames/index.js
2020-02-10 17:33:27 -05:00
var classnames = _ _webpack _require _ _ ( 11 ) ;
2019-09-19 11:19:18 -04:00
var classnames _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( classnames ) ;
// EXTERNAL MODULE: external {"this":["wp","keycodes"]}
2020-03-16 18:07:16 -04:00
var external _this _wp _keycodes _ = _ _webpack _require _ _ ( 22 ) ;
2019-09-19 11:19:18 -04:00
2020-01-22 17:06:21 -05:00
// EXTERNAL MODULE: external {"this":["wp","compose"]}
var external _this _wp _compose _ = _ _webpack _require _ _ ( 8 ) ;
2019-09-19 11:19:18 -04:00
// EXTERNAL MODULE: external {"this":["wp","isShallowEqual"]}
2020-03-23 19:40:19 -04:00
var external _this _wp _isShallowEqual _ = _ _webpack _require _ _ ( 51 ) ;
2019-09-19 11:19:18 -04:00
var external _this _wp _isShallowEqual _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _this _wp _isShallowEqual _ ) ;
// EXTERNAL MODULE: external {"this":["wp","deprecated"]}
2020-03-23 19:40:19 -04:00
var external _this _wp _deprecated _ = _ _webpack _require _ _ ( 37 ) ;
2019-09-19 11:19:18 -04:00
var external _this _wp _deprecated _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _this _wp _deprecated _ ) ;
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/format-edit.js
/ * *
* Internal dependencies
* /
/ * *
* Set of all interactive content tags .
*
* @ see https : //html.spec.whatwg.org/multipage/dom.html#interactive-content
* /
var interactiveContentTags = new Set ( [ 'a' , 'audio' , 'button' , 'details' , 'embed' , 'iframe' , 'input' , 'label' , 'select' , 'textarea' , 'video' ] ) ;
2020-01-22 17:06:21 -05:00
function FormatEdit ( _ref ) {
2019-09-19 11:19:18 -04:00
var formatTypes = _ref . formatTypes ,
onChange = _ref . onChange ,
2020-02-06 16:03:31 -05:00
onFocus = _ref . onFocus ,
2019-09-19 11:19:18 -04:00
value = _ref . value ,
allowedFormats = _ref . allowedFormats ,
withoutInteractiveFormatting = _ref . withoutInteractiveFormatting ;
return formatTypes . map ( function ( _ref2 ) {
var name = _ref2 . name ,
Edit = _ref2 . edit ,
tagName = _ref2 . tagName ;
if ( ! Edit ) {
return null ;
}
if ( allowedFormats && allowedFormats . indexOf ( name ) === - 1 ) {
return null ;
}
if ( withoutInteractiveFormatting && interactiveContentTags . has ( tagName ) ) {
return null ;
}
var activeFormat = getActiveFormat ( value , name ) ;
var isActive = activeFormat !== undefined ;
var activeObject = getActiveObject ( value ) ;
2019-10-15 12:17:12 -04:00
var isObjectActive = activeObject !== undefined && activeObject . type === name ;
2019-09-19 11:19:18 -04:00
return Object ( external _this _wp _element _ [ "createElement" ] ) ( Edit , {
key : name ,
isActive : isActive ,
activeAttributes : isActive ? activeFormat . attributes || { } : { } ,
isObjectActive : isObjectActive ,
activeObjectAttributes : isObjectActive ? activeObject . attributes || { } : { } ,
value : value ,
2020-02-06 16:03:31 -05:00
onChange : onChange ,
onFocus : onFocus
2019-09-19 11:19:18 -04:00
} ) ;
} ) ;
2020-01-22 17:06:21 -05:00
}
2019-09-19 11:19:18 -04:00
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/update-formats.js
/ * *
* Internal dependencies
* /
/ * *
* Efficiently updates all the formats from ` start ` ( including ) until ` end `
* ( excluding ) with the active formats . Mutates ` value ` .
*
* @ param { Object } $1 Named paramentes .
* @ param { Object } $1 . value Value te update .
* @ param { number } $1 . start Index to update from .
* @ param { number } $1 . end Index to update until .
* @ param { Array } $1 . formats Replacement formats .
*
* @ return { Object } Mutated value .
* /
function updateFormats ( _ref ) {
var value = _ref . value ,
start = _ref . start ,
end = _ref . end ,
formats = _ref . formats ;
var formatsBefore = value . formats [ start - 1 ] || [ ] ;
var formatsAfter = value . formats [ end ] || [ ] ; // First, fix the references. If any format right before or after are
// equal, the replacement format should use the same reference.
value . activeFormats = formats . map ( function ( format , index ) {
if ( formatsBefore [ index ] ) {
if ( isFormatEqual ( format , formatsBefore [ index ] ) ) {
return formatsBefore [ index ] ;
}
} else if ( formatsAfter [ index ] ) {
if ( isFormatEqual ( format , formatsAfter [ index ] ) ) {
return formatsAfter [ index ] ;
}
}
return format ;
} ) ;
while ( -- end >= start ) {
if ( value . activeFormats . length > 0 ) {
value . formats [ end ] = value . activeFormats ;
} else {
delete value . formats [ end ] ;
}
}
return value ;
}
2020-01-22 17:06:21 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/with-format-types.js
2020-02-06 16:03:31 -05:00
function with _format _types _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function with _format _types _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { with _format _types _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { with _format _types _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2020-01-22 17:06:21 -05:00
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
function formatTypesSelector ( select ) {
return select ( 'core/rich-text' ) . getFormatTypes ( ) ;
}
/ * *
* This higher - order component provides RichText with the ` formatTypes ` prop
* and its derived props from experimental format type settings .
*
* @ param { WPComponent } RichText The rich text component to add props for .
*
* @ return { WPComponent } New enhanced component .
* /
function withFormatTypes ( RichText ) {
return function WithFormatTypes ( props ) {
var clientId = props . clientId ,
identifier = props . identifier ;
var formatTypes = Object ( external _this _wp _data _ [ "useSelect" ] ) ( formatTypesSelector , [ ] ) ;
var selectProps = Object ( external _this _wp _data _ [ "useSelect" ] ) ( function ( select ) {
return formatTypes . reduce ( function ( acc , settings ) {
if ( ! settings . _ _experimentalGetPropsForEditableTreePreparation ) {
return acc ;
}
var selectPrefix = "format_prepare_props_(" . concat ( settings . name , ")_" ) ;
2020-02-06 16:03:31 -05:00
return with _format _types _objectSpread ( { } , acc , { } , Object ( external _this _lodash _ [ "mapKeys" ] ) ( settings . _ _experimentalGetPropsForEditableTreePreparation ( select , {
2020-01-22 17:06:21 -05:00
richTextIdentifier : identifier ,
blockClientId : clientId
} ) , function ( value , key ) {
return selectPrefix + key ;
} ) ) ;
} , { } ) ;
} , [ formatTypes , clientId , identifier ] ) ;
var dispatchProps = Object ( external _this _wp _data _ [ "__unstableUseDispatchWithMap" ] ) ( function ( dispatch ) {
return formatTypes . reduce ( function ( acc , settings ) {
if ( ! settings . _ _experimentalGetPropsForEditableTreeChangeHandler ) {
return acc ;
}
var dispatchPrefix = "format_on_change_props_(" . concat ( settings . name , ")_" ) ;
2020-02-06 16:03:31 -05:00
return with _format _types _objectSpread ( { } , acc , { } , Object ( external _this _lodash _ [ "mapKeys" ] ) ( settings . _ _experimentalGetPropsForEditableTreeChangeHandler ( dispatch , {
2020-01-22 17:06:21 -05:00
richTextIdentifier : identifier ,
blockClientId : clientId
} ) , function ( value , key ) {
return dispatchPrefix + key ;
} ) ) ;
} , { } ) ;
} , [ formatTypes , clientId , identifier ] ) ;
var newProps = Object ( external _this _wp _element _ [ "useMemo" ] ) ( function ( ) {
return formatTypes . reduce ( function ( acc , settings ) {
if ( ! settings . _ _experimentalCreatePrepareEditableTree ) {
return acc ;
}
var args = {
richTextIdentifier : identifier ,
blockClientId : clientId
} ;
2020-02-06 16:03:31 -05:00
var combined = with _format _types _objectSpread ( { } , selectProps , { } , dispatchProps ) ;
2020-01-22 17:06:21 -05:00
var name = settings . name ;
var selectPrefix = "format_prepare_props_(" . concat ( name , ")_" ) ;
var dispatchPrefix = "format_on_change_props_(" . concat ( name , ")_" ) ;
var propsByPrefix = Object . keys ( combined ) . reduce ( function ( accumulator , key ) {
if ( key . startsWith ( selectPrefix ) ) {
accumulator [ key . slice ( selectPrefix . length ) ] = combined [ key ] ;
}
if ( key . startsWith ( dispatchPrefix ) ) {
accumulator [ key . slice ( dispatchPrefix . length ) ] = combined [ key ] ;
}
return accumulator ;
} , { } ) ;
if ( settings . _ _experimentalCreateOnChangeEditableValue ) {
var _objectSpread2 ;
2020-02-06 16:03:31 -05:00
return with _format _types _objectSpread ( { } , acc , ( _objectSpread2 = { } , Object ( defineProperty [ "a" /* default */ ] ) ( _objectSpread2 , "format_value_functions_(" . concat ( name , ")" ) , settings . _ _experimentalCreatePrepareEditableTree ( propsByPrefix , args ) ) , Object ( defineProperty [ "a" /* default */ ] ) ( _objectSpread2 , "format_on_change_functions_(" . concat ( name , ")" ) , settings . _ _experimentalCreateOnChangeEditableValue ( propsByPrefix , args ) ) , _objectSpread2 ) ) ;
2020-01-22 17:06:21 -05:00
}
2020-02-06 16:03:31 -05:00
return with _format _types _objectSpread ( { } , acc , Object ( defineProperty [ "a" /* default */ ] ) ( { } , "format_prepare_functions_(" . concat ( name , ")" ) , settings . _ _experimentalCreatePrepareEditableTree ( propsByPrefix , args ) ) ) ;
2020-01-22 17:06:21 -05:00
} , { } ) ;
} , [ formatTypes , clientId , identifier , selectProps , dispatchProps ] ) ;
return Object ( external _this _wp _element _ [ "createElement" ] ) ( RichText , Object ( esm _extends [ "a" /* default */ ] ) ( { } , props , selectProps , newProps , {
formatTypes : formatTypes
} ) ) ;
} ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/boundary-style.js
/ * *
* WordPress dependencies
* /
/ * *
* Global stylesheet shared by all RichText instances .
* /
var globalStyle = document . createElement ( 'style' ) ;
var boundarySelector = '*[data-rich-text-format-boundary]' ;
document . head . appendChild ( globalStyle ) ;
/ * *
* Calculates and renders the format boundary style when the active formats
* change .
* /
function BoundaryStyle ( _ref ) {
var activeFormats = _ref . activeFormats ,
forwardedRef = _ref . forwardedRef ;
Object ( external _this _wp _element _ [ "useEffect" ] ) ( function ( ) {
// There's no need to recalculate the boundary styles if no formats are
// active, because no boundary styles will be visible.
if ( ! activeFormats || ! activeFormats . length ) {
return ;
}
var element = forwardedRef . current . querySelector ( boundarySelector ) ;
if ( ! element ) {
return ;
}
var computedStyle = window . getComputedStyle ( element ) ;
var newColor = computedStyle . color . replace ( ')' , ', 0.2)' ) . replace ( 'rgb' , 'rgba' ) ;
var selector = ".rich-text:focus " . concat ( boundarySelector ) ;
var rule = "background-color: " . concat ( newColor ) ;
var style = "" . concat ( selector , " {" ) . concat ( rule , "}" ) ;
if ( globalStyle . innerHTML !== style ) {
globalStyle . innerHTML = style ;
}
} , [ activeFormats ] ) ;
return null ;
}
2020-02-06 16:03:31 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/inline-warning.js
/ * *
* WordPress dependencies
* /
function InlineWarning ( _ref ) {
var forwardedRef = _ref . forwardedRef ;
Object ( external _this _wp _element _ [ "useEffect" ] ) ( function ( ) {
if ( false ) { var computedStyle ; }
} , [ ] ) ;
return null ;
}
2019-09-19 11:19:18 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/index.js
2018-12-14 06:02:53 -05:00
2020-02-06 16:03:31 -05:00
function component _ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function component _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { component _ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { Object ( defineProperty [ "a" /* default */ ] ) ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { component _ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
2019-09-19 11:19:18 -04:00
/ * *
* External dependencies
* /
2018-12-14 06:02:53 -05:00
2019-09-19 11:19:18 -04:00
/ * *
* WordPress dependencies
* /
2018-12-14 06:02:53 -05:00
2019-09-19 11:19:18 -04:00
/ * *
* Internal dependencies
* /
2018-12-14 06:02:53 -05:00
2019-03-07 04:09:59 -05:00
Block Editor: Update packages to bring a selection of bugfixes in.
Props iseulde, kjellr, aduth, 0mirka00, mcsf, nosolosw, gziolo, jasmussen, talldanwp, notnownikki, swissspidy, jorgefilipecosta, noisysocks.
See https://github.com/WordPress/gutenberg/pull/14796.
Fixes #46801.
Built from https://develop.svn.wordpress.org/trunk@45138
git-svn-id: http://core.svn.wordpress.org/trunk@44947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 02:37:57 -04:00
2018-12-14 06:02:53 -05:00
2020-01-22 17:06:21 -05:00
2020-02-06 16:03:31 -05:00
2019-09-19 11:19:18 -04:00
/ * *
* Browser dependencies
* /
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
var _window = window ,
getSelection = _window . getSelection ,
getComputedStyle = _window . getComputedStyle ;
2020-01-08 06:57:23 -05:00
/** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */
2019-09-19 11:19:18 -04:00
/ * *
* All inserting input types that would insert HTML into the DOM .
*
* @ see https : //www.w3.org/TR/input-events-2/#interface-InputEvent-Attributes
*
* @ type { Set }
* /
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
var INSERTION _INPUT _TYPES _TO _IGNORE = new Set ( [ 'insertParagraph' , 'insertOrderedList' , 'insertUnorderedList' , 'insertHorizontalRule' , 'insertLink' ] ) ;
2020-01-08 06:57:23 -05:00
/ * *
* In HTML , leading and trailing spaces are not visible , and multiple spaces
* elsewhere are visually reduced to one space . This rule prevents spaces from
* collapsing so all space is visible in the editor and can be removed . It also
* prevents some browsers from inserting non - breaking spaces at the end of a
* line to prevent the space from visually disappearing . Sometimes these non
* breaking spaces can linger in the editor causing unwanted non breaking spaces
* in between words . If also prevent Firefox from inserting a trailing ` br ` node
* to visualise any trailing space , causing the element to be saved .
*
* > Authors are encouraged to set the 'white-space' property on editing hosts
* > and on markup that was originally created through these editing mechanisms
* > to the value 'pre-wrap' . Default HTML whitespace handling is not well
* > suited to WYSIWYG editing , and line wrapping will not work correctly in
* > some corner cases if 'white-space' is left at its default value .
*
* https : //html.spec.whatwg.org/multipage/interaction.html#best-practices-for-in-page-editors
*
* @ type { string }
* /
var whiteSpace = 'pre-wrap' ;
/ * *
* Default style object for the editable element .
*
* @ type { Object < string , string > }
* /
var defaultStyle = {
whiteSpace : whiteSpace
} ;
2020-01-22 17:06:21 -05:00
var EMPTY _ACTIVE _FORMATS = [ ] ;
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
function createPrepareEditableTree ( props , prefix ) {
var fns = Object . keys ( props ) . reduce ( function ( accumulator , key ) {
if ( key . startsWith ( prefix ) ) {
accumulator . push ( props [ key ] ) ;
}
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
return accumulator ;
} , [ ] ) ;
return function ( value ) {
return fns . reduce ( function ( accumulator , fn ) {
return fn ( accumulator , value . text ) ;
} , value . formats ) ;
} ;
}
2019-10-15 12:17:12 -04:00
/ * *
* If the selection is set on the placeholder element , collapse the selection to
* the start ( before the placeholder ) .
* /
function fixPlaceholderSelection ( ) {
var selection = window . getSelection ( ) ;
var anchorNode = selection . anchorNode ,
anchorOffset = selection . anchorOffset ;
if ( anchorNode . nodeType !== anchorNode . ELEMENT _NODE ) {
return ;
}
var targetNode = anchorNode . childNodes [ anchorOffset ] ;
if ( ! targetNode || targetNode . nodeType !== targetNode . ELEMENT _NODE || ! targetNode . getAttribute ( 'data-rich-text-placeholder' ) ) {
return ;
}
selection . collapseToStart ( ) ;
}
2019-09-19 11:19:18 -04:00
/ * *
* See export statement below .
* /
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
var component _RichText =
/*#__PURE__*/
function ( _Component ) {
Object ( inherits [ "a" /* default */ ] ) ( RichText , _Component ) ;
function RichText ( _ref ) {
var _this ;
var value = _ref . value ,
selectionStart = _ref . selectionStart ,
selectionEnd = _ref . selectionEnd ;
Object ( classCallCheck [ "a" /* default */ ] ) ( this , RichText ) ;
_this = Object ( possibleConstructorReturn [ "a" /* default */ ] ) ( this , Object ( getPrototypeOf [ "a" /* default */ ] ) ( RichText ) . apply ( this , arguments ) ) ;
_this . onFocus = _this . onFocus . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . onBlur = _this . onBlur . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . onChange = _this . onChange . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . handleDelete = _this . handleDelete . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . handleEnter = _this . handleEnter . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . handleSpace = _this . handleSpace . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . handleHorizontalNavigation = _this . handleHorizontalNavigation . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . onPaste = _this . onPaste . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . onCreateUndoLevel = _this . onCreateUndoLevel . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . onInput = _this . onInput . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
2020-01-22 17:06:21 -05:00
_this . onCompositionStart = _this . onCompositionStart . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
2019-09-19 11:19:18 -04:00
_this . onCompositionEnd = _this . onCompositionEnd . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . onSelectionChange = _this . onSelectionChange . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . createRecord = _this . createRecord . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . applyRecord = _this . applyRecord . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . valueToFormat = _this . valueToFormat . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . onPointerDown = _this . onPointerDown . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . formatToValue = _this . formatToValue . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . Editable = _this . Editable . bind ( Object ( assertThisInitialized [ "a" /* default */ ] ) ( _this ) ) ;
_this . onKeyDown = function ( event ) {
Block Editor: Update WordPress packages to include the latest bug fixes.
Updated packages:
@wordpress/annotations@1.7.1
@wordpress/api-fetch@3.6.1
@wordpress/babel-plugin-makepot@3.2.1
@wordpress/babel-preset-default@4.6.1
@wordpress/block-directory@1.0.1
@wordpress/block-editor@3.2.1
@wordpress/block-library@2.9.1
@wordpress/blocks@6.7.1
@wordpress/components@8.3.1
@wordpress/compose@3.7.1
@wordpress/core-data@2.7.1
@wordpress/data-controls@1.3.1
@wordpress/data@4.9.1
@wordpress/docgen@1.4.1
@wordpress/dom@2.5.1
@wordpress/e2e-test-utils@2.4.1
@wordpress/e2e-tests@1.7.1
@wordpress/edit-post@3.8.1
@wordpress/editor@9.7.1
@wordpress/element@2.8.1
@wordpress/format-library@1.9.1
@wordpress/i18n@3.6.1
@wordpress/jest-console@3.3.1
@wordpress/jest-preset-default@5.1.1
@wordpress/keycodes@2.6.1
@wordpress/library-export-default-webpack-plugin@1.4.1
@wordpress/list-reusable-blocks@1.8.1
@wordpress/media-utils@1.2.1
@wordpress/notices@1.8.1
@wordpress/nux@3.7.1
@wordpress/plugins@2.7.1
@wordpress/redux-routine@3.6.1
@wordpress/rich-text@3.7.1
@wordpress/scripts@5.0.1
@wordpress/server-side-render@1.3.1
@wordpress/shortcode@2.4.1
@wordpress/token-list@1.6.1
@wordpress/viewport@2.8.1
@wordpress/wordcount@2.6.1
Props epiqueras, youknowriad, donmhico, jorgefilipecosta, soean, mcsf, noisysocks, andraganescu, gziolo, talldanwp, iseulde, nrqsnchz, mapk, karmatosed, joen, afercia, kjellr, desrosj.
Fixes #48186.
Built from https://develop.svn.wordpress.org/trunk@46364
git-svn-id: http://core.svn.wordpress.org/trunk@46163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-30 16:07:06 -04:00
if ( event . defaultPrevented ) {
return ;
}
2019-09-19 11:19:18 -04:00
_this . handleDelete ( event ) ;
_this . handleEnter ( event ) ;
_this . handleSpace ( event ) ;
_this . handleHorizontalNavigation ( event ) ;
} ;
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
_this . state = { } ;
_this . lastHistoryValue = value ; // Internal values are updated synchronously, unlike props and state.
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
_this . value = value ;
_this . record = _this . formatToValue ( value ) ;
_this . record . start = selectionStart ;
_this . record . end = selectionEnd ;
return _this ;
}
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
Object ( createClass [ "a" /* default */ ] ) ( RichText , [ {
key : "componentWillUnmount" ,
value : function componentWillUnmount ( ) {
document . removeEventListener ( 'selectionchange' , this . onSelectionChange ) ;
window . cancelAnimationFrame ( this . rafId ) ;
}
} , {
2020-01-08 06:57:23 -05:00
key : "componentDidMount" ,
value : function componentDidMount ( ) {
this . applyRecord ( this . record , {
domOnly : true
} ) ;
2019-09-19 11:19:18 -04:00
}
} , {
key : "createRecord" ,
value : function createRecord ( ) {
2020-01-08 06:57:23 -05:00
var _this$props = this . props ,
multilineTag = _this$props . _ _unstableMultilineTag ,
forwardedRef = _this$props . forwardedRef ,
preserveWhiteSpace = _this$props . preserveWhiteSpace ;
2019-09-19 11:19:18 -04:00
var selection = getSelection ( ) ;
var range = selection . rangeCount > 0 ? selection . getRangeAt ( 0 ) : null ;
return create ( {
2020-01-08 06:57:23 -05:00
element : forwardedRef . current ,
2019-09-19 11:19:18 -04:00
range : range ,
multilineTag : multilineTag ,
multilineWrapperTags : multilineTag === 'li' ? [ 'ul' , 'ol' ] : undefined ,
2020-01-08 06:57:23 -05:00
_ _unstableIsEditableTree : true ,
preserveWhiteSpace : preserveWhiteSpace
2019-09-19 11:19:18 -04:00
} ) ;
}
} , {
key : "applyRecord" ,
value : function applyRecord ( record ) {
var _ref2 = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ,
domOnly = _ref2 . domOnly ;
2020-01-08 06:57:23 -05:00
var _this$props2 = this . props ,
multilineTag = _this$props2 . _ _unstableMultilineTag ,
forwardedRef = _this$props2 . forwardedRef ;
2019-09-19 11:19:18 -04:00
apply ( {
value : record ,
2020-01-08 06:57:23 -05:00
current : forwardedRef . current ,
2019-09-19 11:19:18 -04:00
multilineTag : multilineTag ,
multilineWrapperTags : multilineTag === 'li' ? [ 'ul' , 'ol' ] : undefined ,
prepareEditableTree : createPrepareEditableTree ( this . props , 'format_prepare_functions' ) ,
_ _unstableDomOnly : domOnly ,
placeholder : this . props . placeholder
} ) ;
}
/ * *
* Handles a paste event .
*
* Saves the pasted data as plain text in ` pastedPlainText ` .
*
2020-01-08 06:57:23 -05:00
* @ param { ClipboardEvent } event The paste event .
2019-09-19 11:19:18 -04:00
* /
} , {
key : "onPaste" ,
value : function onPaste ( event ) {
2020-01-08 06:57:23 -05:00
var _this$props3 = this . props ,
formatTypes = _this$props3 . formatTypes ,
onPaste = _this$props3 . onPaste ,
isSelected = _this$props3 . _ _unstableIsSelected ;
2020-01-22 17:06:21 -05:00
var _this$state$activeFor = this . state . activeFormats ,
activeFormats = _this$state$activeFor === void 0 ? [ ] : _this$state$activeFor ;
2020-01-08 06:57:23 -05:00
if ( ! isSelected ) {
event . preventDefault ( ) ;
return ;
}
2019-09-19 11:19:18 -04:00
var clipboardData = event . clipboardData ;
var items = clipboardData . items ,
files = clipboardData . files ; // In Edge these properties can be null instead of undefined, so a more
// rigorous test is required over using default values.
2020-01-03 08:17:24 -05:00
items = Object ( external _this _lodash _ [ "isNil" ] ) ( items ) ? [ ] : items ;
files = Object ( external _this _lodash _ [ "isNil" ] ) ( files ) ? [ ] : files ;
2019-09-19 11:19:18 -04:00
var plainText = '' ;
var html = '' ; // IE11 only supports `Text` as an argument for `getData` and will
// otherwise throw an invalid argument error, so we try the standard
// arguments first, then fallback to `Text` if they fail.
try {
plainText = clipboardData . getData ( 'text/plain' ) ;
html = clipboardData . getData ( 'text/html' ) ;
} catch ( error1 ) {
try {
html = clipboardData . getData ( 'Text' ) ;
} catch ( error2 ) {
// Some browsers like UC Browser paste plain text by default and
// don't support clipboardData at all, so allow default
// behaviour.
return ;
}
}
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
event . preventDefault ( ) ; // Allows us to ask for this information when we get a report.
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
window . console . log ( 'Received HTML:\n\n' , html ) ;
window . console . log ( 'Received plain text:\n\n' , plainText ) ;
var record = this . record ;
var transformed = formatTypes . reduce ( function ( accumlator , _ref3 ) {
var _ _unstablePasteRule = _ref3 . _ _unstablePasteRule ;
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
// Only allow one transform.
if ( _ _unstablePasteRule && accumlator === record ) {
accumlator = _ _unstablePasteRule ( record , {
html : html ,
plainText : plainText
} ) ;
}
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
return accumlator ;
} , record ) ;
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
if ( transformed !== record ) {
this . onChange ( transformed ) ;
return ;
}
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
if ( onPaste ) {
2020-01-08 06:57:23 -05:00
files = Array . from ( files ) ;
Array . from ( items ) . forEach ( function ( item ) {
if ( ! item . getAsFile ) {
return ;
}
var file = item . getAsFile ( ) ;
if ( ! file ) {
return ;
}
var name = file . name ,
type = file . type ,
size = file . size ;
if ( ! Object ( external _this _lodash _ [ "find" ] ) ( files , {
name : name ,
type : type ,
size : size
} ) ) {
files . push ( file ) ;
}
2019-09-19 11:19:18 -04:00
} ) ;
onPaste ( {
value : this . removeEditorOnlyFormats ( record ) ,
onChange : this . onChange ,
html : html ,
plainText : plainText ,
2020-01-22 17:06:21 -05:00
files : files ,
activeFormats : activeFormats
2019-09-19 11:19:18 -04:00
} ) ;
}
}
/ * *
* Handles a focus event on the contenteditable field , calling the
* ` unstableOnFocus ` prop callback if one is defined . The callback does not
* receive any arguments .
*
* This is marked as a private API and the ` unstableOnFocus ` prop is not
* documented , as the current requirements where it is used are subject to
* future refactoring following ` isSelected ` handling .
*
* In contrast with ` setFocusedElement ` , this is only triggered in response
* to focus within the contenteditable field , whereas ` setFocusedElement `
* is triggered on focus within any ` RichText ` descendent element .
*
* @ see setFocusedElement
*
* @ private
* /
} , {
key : "onFocus" ,
value : function onFocus ( ) {
var unstableOnFocus = this . props . unstableOnFocus ;
if ( unstableOnFocus ) {
unstableOnFocus ( ) ;
2020-02-06 16:03:31 -05:00
}
2020-01-22 17:06:21 -05:00
2020-02-06 16:03:31 -05:00
if ( ! this . props . _ _unstableIsSelected ) {
// We know for certain that on focus, the old selection is invalid. It
// will be recalculated on the next mouseup, keyup, or touchend event.
var index = undefined ;
var activeFormats = EMPTY _ACTIVE _FORMATS ;
this . record = component _objectSpread ( { } , this . record , {
start : index ,
end : index ,
activeFormats : activeFormats
} ) ;
this . props . onSelectionChange ( index , index ) ;
this . setState ( {
activeFormats : activeFormats
} ) ;
} else {
this . props . onSelectionChange ( this . record . start , this . record . end ) ;
this . setState ( {
activeFormats : getActiveFormats ( component _objectSpread ( { } , this . record , {
activeFormats : undefined
} ) , EMPTY _ACTIVE _FORMATS )
} ) ;
} // Update selection as soon as possible, which is at the next animation
2019-09-19 11:19:18 -04:00
// frame. The event listener for selection changes may be added too late
// at this point, but this focus event is still too early to calculate
// the selection.
2020-02-06 16:03:31 -05:00
2019-09-19 11:19:18 -04:00
this . rafId = window . requestAnimationFrame ( this . onSelectionChange ) ;
document . addEventListener ( 'selectionchange' , this . onSelectionChange ) ;
if ( this . props . setFocusedElement ) {
external _this _wp _deprecated _default ( ) ( 'wp.blockEditor.RichText setFocusedElement prop' , {
alternative : 'selection state from the block editor store.'
} ) ;
this . props . setFocusedElement ( this . props . instanceId ) ;
}
}
} , {
key : "onBlur" ,
value : function onBlur ( ) {
document . removeEventListener ( 'selectionchange' , this . onSelectionChange ) ;
}
/ * *
* Handle input on the next selection change event .
*
2020-01-08 06:57:23 -05:00
* @ param { WPSyntheticEvent } event Synthetic input event .
2019-09-19 11:19:18 -04:00
* /
} , {
key : "onInput" ,
value : function onInput ( event ) {
2020-01-22 17:06:21 -05:00
// Do not trigger a change if characters are being composed. Browsers
// will usually emit a final `input` event when the characters are
// composed.
// As of December 2019, Safari doesn't support nativeEvent.isComposing.
if ( this . isComposing ) {
2019-09-19 11:19:18 -04:00
return ;
}
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
var inputType ;
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
if ( event ) {
Block Editor: Update WordPress packages to include the latest bug fixes.
Updated packages:
@wordpress/annotations@1.7.1
@wordpress/api-fetch@3.6.1
@wordpress/babel-plugin-makepot@3.2.1
@wordpress/babel-preset-default@4.6.1
@wordpress/block-directory@1.0.1
@wordpress/block-editor@3.2.1
@wordpress/block-library@2.9.1
@wordpress/blocks@6.7.1
@wordpress/components@8.3.1
@wordpress/compose@3.7.1
@wordpress/core-data@2.7.1
@wordpress/data-controls@1.3.1
@wordpress/data@4.9.1
@wordpress/docgen@1.4.1
@wordpress/dom@2.5.1
@wordpress/e2e-test-utils@2.4.1
@wordpress/e2e-tests@1.7.1
@wordpress/edit-post@3.8.1
@wordpress/editor@9.7.1
@wordpress/element@2.8.1
@wordpress/format-library@1.9.1
@wordpress/i18n@3.6.1
@wordpress/jest-console@3.3.1
@wordpress/jest-preset-default@5.1.1
@wordpress/keycodes@2.6.1
@wordpress/library-export-default-webpack-plugin@1.4.1
@wordpress/list-reusable-blocks@1.8.1
@wordpress/media-utils@1.2.1
@wordpress/notices@1.8.1
@wordpress/nux@3.7.1
@wordpress/plugins@2.7.1
@wordpress/redux-routine@3.6.1
@wordpress/rich-text@3.7.1
@wordpress/scripts@5.0.1
@wordpress/server-side-render@1.3.1
@wordpress/shortcode@2.4.1
@wordpress/token-list@1.6.1
@wordpress/viewport@2.8.1
@wordpress/wordcount@2.6.1
Props epiqueras, youknowriad, donmhico, jorgefilipecosta, soean, mcsf, noisysocks, andraganescu, gziolo, talldanwp, iseulde, nrqsnchz, mapk, karmatosed, joen, afercia, kjellr, desrosj.
Fixes #48186.
Built from https://develop.svn.wordpress.org/trunk@46364
git-svn-id: http://core.svn.wordpress.org/trunk@46163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-30 16:07:06 -04:00
inputType = event . inputType ;
}
2020-01-22 17:06:21 -05:00
if ( ! inputType && event && event . nativeEvent ) {
2019-09-19 11:19:18 -04:00
inputType = event . nativeEvent . inputType ;
} // The browser formatted something or tried to insert HTML.
// Overwrite it. It will be handled later by the format library if
// needed.
if ( inputType && ( inputType . indexOf ( 'format' ) === 0 || INSERTION _INPUT _TYPES _TO _IGNORE . has ( inputType ) ) ) {
this . applyRecord ( this . record ) ;
return ;
}
var value = this . createRecord ( ) ;
var _this$record = this . record ,
start = _this$record . start ,
_this$record$activeFo = _this$record . activeFormats ,
activeFormats = _this$record$activeFo === void 0 ? [ ] : _this$record$activeFo ; // Update the formats between the last and new caret position.
var change = updateFormats ( {
value : value ,
start : start ,
end : value . start ,
formats : activeFormats
} ) ;
this . onChange ( change , {
withoutHistory : true
} ) ;
2020-01-08 06:57:23 -05:00
var _this$props4 = this . props ,
inputRule = _this$props4 . _ _unstableInputRule ,
markAutomaticChange = _this$props4 . _ _unstableMarkAutomaticChange ,
2020-02-06 16:03:31 -05:00
allowPrefixTransformations = _this$props4 . _ _unstableAllowPrefixTransformations ,
2020-01-08 06:57:23 -05:00
formatTypes = _this$props4 . formatTypes ,
setTimeout = _this$props4 . setTimeout ,
clearTimeout = _this$props4 . clearTimeout ; // Create an undo level when input stops for over a second.
2019-09-19 11:19:18 -04:00
clearTimeout ( this . onInput . timeout ) ;
2020-03-23 19:40:19 -04:00
this . onInput . timeout = setTimeout ( this . onCreateUndoLevel , 1000 ) ; // Only run input rules when inserting text.
2019-09-19 11:19:18 -04:00
if ( inputType !== 'insertText' ) {
return ;
}
2018-12-17 22:14:52 -05:00
2020-03-23 19:40:19 -04:00
if ( allowPrefixTransformations && inputRule ) {
2019-09-19 11:19:18 -04:00
inputRule ( change , this . valueToFormat ) ;
}
2020-01-08 06:57:23 -05:00
var transformed = formatTypes . reduce ( function ( accumlator , _ref4 ) {
var _ _unstableInputRule = _ref4 . _ _unstableInputRule ;
2019-09-19 11:19:18 -04:00
if ( _ _unstableInputRule ) {
accumlator = _ _unstableInputRule ( accumlator ) ;
}
return accumlator ;
} , change ) ;
if ( transformed !== change ) {
this . onCreateUndoLevel ( ) ;
2020-02-06 16:03:31 -05:00
this . onChange ( component _objectSpread ( { } , transformed , {
2019-09-19 11:19:18 -04:00
activeFormats : activeFormats
} ) ) ;
markAutomaticChange ( ) ;
}
}
2020-01-22 17:06:21 -05:00
} , {
key : "onCompositionStart" ,
value : function onCompositionStart ( ) {
this . isComposing = true ; // Do not update the selection when characters are being composed as
// this rerenders the component and might distroy internal browser
// editing state.
document . removeEventListener ( 'selectionchange' , this . onSelectionChange ) ;
}
2019-09-19 11:19:18 -04:00
} , {
key : "onCompositionEnd" ,
value : function onCompositionEnd ( ) {
2020-01-22 17:06:21 -05:00
this . isComposing = false ; // Ensure the value is up-to-date for browsers that don't emit a final
2019-09-19 11:19:18 -04:00
// input event after composition.
2020-01-22 17:06:21 -05:00
Block Editor: Update WordPress packages to include the latest bug fixes.
Updated packages:
@wordpress/annotations@1.7.1
@wordpress/api-fetch@3.6.1
@wordpress/babel-plugin-makepot@3.2.1
@wordpress/babel-preset-default@4.6.1
@wordpress/block-directory@1.0.1
@wordpress/block-editor@3.2.1
@wordpress/block-library@2.9.1
@wordpress/blocks@6.7.1
@wordpress/components@8.3.1
@wordpress/compose@3.7.1
@wordpress/core-data@2.7.1
@wordpress/data-controls@1.3.1
@wordpress/data@4.9.1
@wordpress/docgen@1.4.1
@wordpress/dom@2.5.1
@wordpress/e2e-test-utils@2.4.1
@wordpress/e2e-tests@1.7.1
@wordpress/edit-post@3.8.1
@wordpress/editor@9.7.1
@wordpress/element@2.8.1
@wordpress/format-library@1.9.1
@wordpress/i18n@3.6.1
@wordpress/jest-console@3.3.1
@wordpress/jest-preset-default@5.1.1
@wordpress/keycodes@2.6.1
@wordpress/library-export-default-webpack-plugin@1.4.1
@wordpress/list-reusable-blocks@1.8.1
@wordpress/media-utils@1.2.1
@wordpress/notices@1.8.1
@wordpress/nux@3.7.1
@wordpress/plugins@2.7.1
@wordpress/redux-routine@3.6.1
@wordpress/rich-text@3.7.1
@wordpress/scripts@5.0.1
@wordpress/server-side-render@1.3.1
@wordpress/shortcode@2.4.1
@wordpress/token-list@1.6.1
@wordpress/viewport@2.8.1
@wordpress/wordcount@2.6.1
Props epiqueras, youknowriad, donmhico, jorgefilipecosta, soean, mcsf, noisysocks, andraganescu, gziolo, talldanwp, iseulde, nrqsnchz, mapk, karmatosed, joen, afercia, kjellr, desrosj.
Fixes #48186.
Built from https://develop.svn.wordpress.org/trunk@46364
git-svn-id: http://core.svn.wordpress.org/trunk@46163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-30 16:07:06 -04:00
this . onInput ( {
inputType : 'insertText'
} ) ; // Tracking selection changes can be resumed.
2019-09-19 11:19:18 -04:00
document . addEventListener ( 'selectionchange' , this . onSelectionChange ) ;
}
/ * *
* Syncs the selection to local state . A callback for the ` selectionchange `
* native events , ` keyup ` , ` mouseup ` and ` touchend ` synthetic events , and
* animation frames after the ` focus ` event .
*
2020-01-08 06:57:23 -05:00
* @ param { Event | WPSyntheticEvent | DOMHighResTimeStamp } event
2019-09-19 11:19:18 -04:00
* /
} , {
key : "onSelectionChange" ,
value : function onSelectionChange ( event ) {
if ( event . type !== 'selectionchange' && ! this . props . _ _unstableIsSelected ) {
return ;
2020-01-08 06:57:23 -05:00
}
if ( this . props . disabled ) {
return ;
2019-09-19 11:19:18 -04:00
} // In case of a keyboard event, ignore selection changes during
// composition.
2020-01-22 17:06:21 -05:00
if ( this . isComposing ) {
2019-09-19 11:19:18 -04:00
return ;
}
var _this$createRecord = this . createRecord ( ) ,
start = _this$createRecord . start ,
end = _this$createRecord . end ,
text = _this$createRecord . text ;
var value = this . record ; // Fallback mechanism for IE11, which doesn't support the input event.
// Any input results in a selection change.
if ( text !== value . text ) {
this . onInput ( ) ;
return ;
}
if ( start === value . start && end === value . end ) {
2019-10-15 12:17:12 -04:00
// Sometimes the browser may set the selection on the placeholder
// element, in which case the caret is not visible. We need to set
// the caret before the placeholder if that's the case.
2019-09-19 11:19:18 -04:00
if ( value . text . length === 0 && start === 0 ) {
2019-10-15 12:17:12 -04:00
fixPlaceholderSelection ( ) ;
2019-09-19 11:19:18 -04:00
}
return ;
}
2020-01-08 06:57:23 -05:00
var _this$props5 = this . props ,
isCaretWithinFormattedText = _this$props5 . _ _unstableIsCaretWithinFormattedText ,
onEnterFormattedText = _this$props5 . _ _unstableOnEnterFormattedText ,
onExitFormattedText = _this$props5 . _ _unstableOnExitFormattedText ;
2019-09-19 11:19:18 -04:00
2020-02-06 16:03:31 -05:00
var newValue = component _objectSpread ( { } , value , {
2019-09-19 11:19:18 -04:00
start : start ,
end : end ,
// Allow `getActiveFormats` to get new `activeFormats`.
activeFormats : undefined
} ) ;
2020-01-22 17:06:21 -05:00
var activeFormats = getActiveFormats ( newValue , EMPTY _ACTIVE _FORMATS ) ; // Update the value with the new active formats.
2019-09-19 11:19:18 -04:00
newValue . activeFormats = activeFormats ;
if ( ! isCaretWithinFormattedText && activeFormats . length ) {
onEnterFormattedText ( ) ;
} else if ( isCaretWithinFormattedText && ! activeFormats . length ) {
onExitFormattedText ( ) ;
} // It is important that the internal value is updated first,
// otherwise the value will be wrong on render!
this . record = newValue ;
this . applyRecord ( newValue , {
domOnly : true
} ) ;
this . props . onSelectionChange ( start , end ) ;
this . setState ( {
activeFormats : activeFormats
} ) ;
}
/ * *
* Sync the value to global state . The node tree and selection will also be
* updated if differences are found .
*
* @ param { Object } record The record to sync and apply .
* @ param { Object } $2 Named options .
* @ param { boolean } $2 . withoutHistory If true , no undo level will be
* created .
* /
} , {
key : "onChange" ,
value : function onChange ( record ) {
2020-01-08 06:57:23 -05:00
var _ref5 = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ,
withoutHistory = _ref5 . withoutHistory ;
2019-09-19 11:19:18 -04:00
this . applyRecord ( record ) ;
var start = record . start ,
end = record . end ,
_record$activeFormats = record . activeFormats ,
activeFormats = _record$activeFormats === void 0 ? [ ] : _record$activeFormats ;
2020-01-03 08:17:24 -05:00
var changeHandlers = Object ( external _this _lodash _ [ "pickBy" ] ) ( this . props , function ( v , key ) {
2019-09-19 11:19:18 -04:00
return key . startsWith ( 'format_on_change_functions_' ) ;
} ) ;
Object . values ( changeHandlers ) . forEach ( function ( changeHandler ) {
changeHandler ( record . formats , record . text ) ;
} ) ;
this . value = this . valueToFormat ( record ) ;
2020-01-08 06:57:23 -05:00
this . record = record ; // Selection must be updated first, so it is recorded in history when
// the content change happens.
2019-09-19 11:19:18 -04:00
this . props . onSelectionChange ( start , end ) ;
2020-01-08 06:57:23 -05:00
this . props . onChange ( this . value ) ;
2019-09-19 11:19:18 -04:00
this . setState ( {
activeFormats : activeFormats
} ) ;
2018-12-17 22:14:52 -05:00
2019-09-19 11:19:18 -04:00
if ( ! withoutHistory ) {
this . onCreateUndoLevel ( ) ;
}
}
} , {
key : "onCreateUndoLevel" ,
value : function onCreateUndoLevel ( ) {
// If the content is the same, no level needs to be created.
if ( this . lastHistoryValue === this . value ) {
return ;
}
this . props . _ _unstableOnCreateUndoLevel ( ) ;
this . lastHistoryValue = this . value ;
}
/ * *
* Handles delete on keydown :
* - outdent list items ,
* - delete content if everything is selected ,
* - trigger the onDelete prop when selection is uncollapsed and at an edge .
*
2020-01-08 06:57:23 -05:00
* @ param { WPSyntheticEvent } event A synthetic keyboard event .
2019-09-19 11:19:18 -04:00
* /
} , {
key : "handleDelete" ,
value : function handleDelete ( event ) {
var keyCode = event . keyCode ;
if ( keyCode !== external _this _wp _keycodes _ [ "DELETE" ] && keyCode !== external _this _wp _keycodes _ [ "BACKSPACE" ] && keyCode !== external _this _wp _keycodes _ [ "ESCAPE" ] ) {
return ;
}
if ( this . props . _ _unstableDidAutomaticChange ) {
event . preventDefault ( ) ;
this . props . _ _unstableUndo ( ) ;
return ;
}
if ( keyCode === external _this _wp _keycodes _ [ "ESCAPE" ] ) {
return ;
}
2020-01-08 06:57:23 -05:00
var _this$props6 = this . props ,
onDelete = _this$props6 . onDelete ,
multilineTag = _this$props6 . _ _unstableMultilineTag ;
2020-01-22 17:06:21 -05:00
var _this$state$activeFor2 = this . state . activeFormats ,
activeFormats = _this$state$activeFor2 === void 0 ? [ ] : _this$state$activeFor2 ;
2019-09-19 11:19:18 -04:00
var value = this . createRecord ( ) ;
var start = value . start ,
end = value . end ,
text = value . text ;
2020-01-08 06:57:23 -05:00
var isReverse = keyCode === external _this _wp _keycodes _ [ "BACKSPACE" ] ; // Always handle full content deletion ourselves.
if ( start === 0 && end !== 0 && end === text . length ) {
this . onChange ( remove _remove ( value ) ) ;
event . preventDefault ( ) ;
return ;
}
2019-09-19 11:19:18 -04:00
if ( multilineTag ) {
2020-01-08 06:57:23 -05:00
var newValue ; // Check to see if we should remove the first item if empty.
if ( isReverse && value . start === 0 && value . end === 0 && isEmptyLine ( value ) ) {
newValue = removeLineSeparator ( value , ! isReverse ) ;
} else {
newValue = removeLineSeparator ( value , isReverse ) ;
}
2019-09-19 11:19:18 -04:00
if ( newValue ) {
this . onChange ( newValue ) ;
event . preventDefault ( ) ;
2020-01-08 06:57:23 -05:00
return ;
2019-09-19 11:19:18 -04:00
}
} // Only process delete if the key press occurs at an uncollapsed edge.
if ( ! onDelete || ! isCollapsed ( value ) || activeFormats . length || isReverse && start !== 0 || ! isReverse && end !== text . length ) {
return ;
}
onDelete ( {
isReverse : isReverse ,
value : value
} ) ;
event . preventDefault ( ) ;
}
/ * *
* Triggers the ` onEnter ` prop on keydown .
*
2020-01-08 06:57:23 -05:00
* @ param { WPSyntheticEvent } event A synthetic keyboard event .
2019-09-19 11:19:18 -04:00
* /
} , {
key : "handleEnter" ,
value : function handleEnter ( event ) {
if ( event . keyCode !== external _this _wp _keycodes _ [ "ENTER" ] ) {
return ;
}
event . preventDefault ( ) ;
var onEnter = this . props . onEnter ;
if ( ! onEnter ) {
return ;
}
onEnter ( {
value : this . removeEditorOnlyFormats ( this . createRecord ( ) ) ,
onChange : this . onChange ,
shiftKey : event . shiftKey
} ) ;
}
/ * *
* Indents list items on space keydown .
*
2020-01-08 06:57:23 -05:00
* @ param { WPSyntheticEvent } event A synthetic keyboard event .
2019-09-19 11:19:18 -04:00
* /
} , {
key : "handleSpace" ,
value : function handleSpace ( event ) {
Block Editor: Update WordPress packages to include the latest bug fixes.
Updated packages:
@wordpress/annotations@1.7.1
@wordpress/api-fetch@3.6.1
@wordpress/babel-plugin-makepot@3.2.1
@wordpress/babel-preset-default@4.6.1
@wordpress/block-directory@1.0.1
@wordpress/block-editor@3.2.1
@wordpress/block-library@2.9.1
@wordpress/blocks@6.7.1
@wordpress/components@8.3.1
@wordpress/compose@3.7.1
@wordpress/core-data@2.7.1
@wordpress/data-controls@1.3.1
@wordpress/data@4.9.1
@wordpress/docgen@1.4.1
@wordpress/dom@2.5.1
@wordpress/e2e-test-utils@2.4.1
@wordpress/e2e-tests@1.7.1
@wordpress/edit-post@3.8.1
@wordpress/editor@9.7.1
@wordpress/element@2.8.1
@wordpress/format-library@1.9.1
@wordpress/i18n@3.6.1
@wordpress/jest-console@3.3.1
@wordpress/jest-preset-default@5.1.1
@wordpress/keycodes@2.6.1
@wordpress/library-export-default-webpack-plugin@1.4.1
@wordpress/list-reusable-blocks@1.8.1
@wordpress/media-utils@1.2.1
@wordpress/notices@1.8.1
@wordpress/nux@3.7.1
@wordpress/plugins@2.7.1
@wordpress/redux-routine@3.6.1
@wordpress/rich-text@3.7.1
@wordpress/scripts@5.0.1
@wordpress/server-side-render@1.3.1
@wordpress/shortcode@2.4.1
@wordpress/token-list@1.6.1
@wordpress/viewport@2.8.1
@wordpress/wordcount@2.6.1
Props epiqueras, youknowriad, donmhico, jorgefilipecosta, soean, mcsf, noisysocks, andraganescu, gziolo, talldanwp, iseulde, nrqsnchz, mapk, karmatosed, joen, afercia, kjellr, desrosj.
Fixes #48186.
Built from https://develop.svn.wordpress.org/trunk@46364
git-svn-id: http://core.svn.wordpress.org/trunk@46163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-30 16:07:06 -04:00
var keyCode = event . keyCode ,
shiftKey = event . shiftKey ,
altKey = event . altKey ,
metaKey = event . metaKey ,
ctrlKey = event . ctrlKey ;
2020-01-08 06:57:23 -05:00
var _this$props7 = this . props ,
tagName = _this$props7 . tagName ,
multilineTag = _this$props7 . _ _unstableMultilineTag ;
2019-09-19 11:19:18 -04:00
Block Editor: Update WordPress packages to include the latest bug fixes.
Updated packages:
@wordpress/annotations@1.7.1
@wordpress/api-fetch@3.6.1
@wordpress/babel-plugin-makepot@3.2.1
@wordpress/babel-preset-default@4.6.1
@wordpress/block-directory@1.0.1
@wordpress/block-editor@3.2.1
@wordpress/block-library@2.9.1
@wordpress/blocks@6.7.1
@wordpress/components@8.3.1
@wordpress/compose@3.7.1
@wordpress/core-data@2.7.1
@wordpress/data-controls@1.3.1
@wordpress/data@4.9.1
@wordpress/docgen@1.4.1
@wordpress/dom@2.5.1
@wordpress/e2e-test-utils@2.4.1
@wordpress/e2e-tests@1.7.1
@wordpress/edit-post@3.8.1
@wordpress/editor@9.7.1
@wordpress/element@2.8.1
@wordpress/format-library@1.9.1
@wordpress/i18n@3.6.1
@wordpress/jest-console@3.3.1
@wordpress/jest-preset-default@5.1.1
@wordpress/keycodes@2.6.1
@wordpress/library-export-default-webpack-plugin@1.4.1
@wordpress/list-reusable-blocks@1.8.1
@wordpress/media-utils@1.2.1
@wordpress/notices@1.8.1
@wordpress/nux@3.7.1
@wordpress/plugins@2.7.1
@wordpress/redux-routine@3.6.1
@wordpress/rich-text@3.7.1
@wordpress/scripts@5.0.1
@wordpress/server-side-render@1.3.1
@wordpress/shortcode@2.4.1
@wordpress/token-list@1.6.1
@wordpress/viewport@2.8.1
@wordpress/wordcount@2.6.1
Props epiqueras, youknowriad, donmhico, jorgefilipecosta, soean, mcsf, noisysocks, andraganescu, gziolo, talldanwp, iseulde, nrqsnchz, mapk, karmatosed, joen, afercia, kjellr, desrosj.
Fixes #48186.
Built from https://develop.svn.wordpress.org/trunk@46364
git-svn-id: http://core.svn.wordpress.org/trunk@46163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-30 16:07:06 -04:00
if ( // Only override when no modifiers are pressed.
shiftKey || altKey || metaKey || ctrlKey || keyCode !== external _this _wp _keycodes _ [ "SPACE" ] || multilineTag !== 'li' ) {
2019-09-19 11:19:18 -04:00
return ;
}
var value = this . createRecord ( ) ;
if ( ! isCollapsed ( value ) ) {
return ;
}
var text = value . text ,
start = value . start ;
var characterBefore = text [ start - 1 ] ; // The caret must be at the start of a line.
if ( characterBefore && characterBefore !== LINE _SEPARATOR ) {
return ;
}
this . onChange ( indentListItems ( value , {
type : tagName
} ) ) ;
event . preventDefault ( ) ;
}
/ * *
* Handles horizontal keyboard navigation when no modifiers are pressed . The
* navigation is handled separately to move correctly around format
* boundaries .
*
2020-01-08 06:57:23 -05:00
* @ param { WPSyntheticEvent } event A synthetic keyboard event .
2019-09-19 11:19:18 -04:00
* /
} , {
key : "handleHorizontalNavigation" ,
value : function handleHorizontalNavigation ( event ) {
var keyCode = event . keyCode ,
shiftKey = event . shiftKey ,
altKey = event . altKey ,
metaKey = event . metaKey ,
ctrlKey = event . ctrlKey ;
if ( // Only override left and right keys without modifiers pressed.
shiftKey || altKey || metaKey || ctrlKey || keyCode !== external _this _wp _keycodes _ [ "LEFT" ] && keyCode !== external _this _wp _keycodes _ [ "RIGHT" ] ) {
return ;
}
var value = this . record ;
var text = value . text ,
formats = value . formats ,
start = value . start ,
end = value . end ,
_value$activeFormats = value . activeFormats ,
activeFormats = _value$activeFormats === void 0 ? [ ] : _value$activeFormats ;
var collapsed = isCollapsed ( value ) ; // To do: ideally, we should look at visual position instead.
2020-01-08 06:57:23 -05:00
var _getComputedStyle = getComputedStyle ( this . props . forwardedRef . current ) ,
2019-09-19 11:19:18 -04:00
direction = _getComputedStyle . direction ;
var reverseKey = direction === 'rtl' ? external _this _wp _keycodes _ [ "RIGHT" ] : external _this _wp _keycodes _ [ "LEFT" ] ;
var isReverse = event . keyCode === reverseKey ; // If the selection is collapsed and at the very start, do nothing if
// navigating backward.
// If the selection is collapsed and at the very end, do nothing if
// navigating forward.
if ( collapsed && activeFormats . length === 0 ) {
if ( start === 0 && isReverse ) {
return ;
}
if ( end === text . length && ! isReverse ) {
return ;
}
} // If the selection is not collapsed, let the browser handle collapsing
// the selection for now. Later we could expand this logic to set
// boundary positions if needed.
if ( ! collapsed ) {
return ;
} // In all other cases, prevent default behaviour.
event . preventDefault ( ) ;
2020-01-22 17:06:21 -05:00
var formatsBefore = formats [ start - 1 ] || EMPTY _ACTIVE _FORMATS ;
var formatsAfter = formats [ start ] || EMPTY _ACTIVE _FORMATS ;
2019-09-19 11:19:18 -04:00
var newActiveFormatsLength = activeFormats . length ;
var source = formatsAfter ;
if ( formatsBefore . length > formatsAfter . length ) {
source = formatsBefore ;
} // If the amount of formats before the caret and after the caret is
// different, the caret is at a format boundary.
if ( formatsBefore . length < formatsAfter . length ) {
if ( ! isReverse && activeFormats . length < formatsAfter . length ) {
newActiveFormatsLength ++ ;
}
if ( isReverse && activeFormats . length > formatsBefore . length ) {
newActiveFormatsLength -- ;
}
} else if ( formatsBefore . length > formatsAfter . length ) {
if ( ! isReverse && activeFormats . length > formatsAfter . length ) {
newActiveFormatsLength -- ;
}
if ( isReverse && activeFormats . length < formatsBefore . length ) {
newActiveFormatsLength ++ ;
}
2020-01-22 17:06:21 -05:00
}
2019-09-19 11:19:18 -04:00
if ( newActiveFormatsLength !== activeFormats . length ) {
var _newActiveFormats = source . slice ( 0 , newActiveFormatsLength ) ;
2020-02-06 16:03:31 -05:00
var _newValue = component _objectSpread ( { } , value , {
2019-09-19 11:19:18 -04:00
activeFormats : _newActiveFormats
} ) ;
this . record = _newValue ;
this . applyRecord ( _newValue ) ;
this . setState ( {
activeFormats : _newActiveFormats
} ) ;
return ;
}
var newPos = start + ( isReverse ? - 1 : 1 ) ;
var newActiveFormats = isReverse ? formatsBefore : formatsAfter ;
2020-02-06 16:03:31 -05:00
var newValue = component _objectSpread ( { } , value , {
2019-09-19 11:19:18 -04:00
start : newPos ,
end : newPos ,
activeFormats : newActiveFormats
} ) ;
this . record = newValue ;
this . applyRecord ( newValue ) ;
this . props . onSelectionChange ( newPos , newPos ) ;
this . setState ( {
activeFormats : newActiveFormats
} ) ;
}
/ * *
* Select object when they are clicked . The browser will not set any
* selection when clicking e . g . an image .
*
2020-01-08 06:57:23 -05:00
* @ param { WPSyntheticEvent } event Synthetic mousedown or touchstart event .
2019-09-19 11:19:18 -04:00
* /
} , {
key : "onPointerDown" ,
value : function onPointerDown ( event ) {
var target = event . target ; // If the child element has no text content, it must be an object.
2020-01-08 06:57:23 -05:00
if ( target === this . props . forwardedRef . current || target . textContent ) {
2019-09-19 11:19:18 -04:00
return ;
}
var parentNode = target . parentNode ;
var index = Array . from ( parentNode . childNodes ) . indexOf ( target ) ;
var range = target . ownerDocument . createRange ( ) ;
var selection = getSelection ( ) ;
range . setStart ( target . parentNode , index ) ;
range . setEnd ( target . parentNode , index + 1 ) ;
selection . removeAllRanges ( ) ;
selection . addRange ( range ) ;
}
} , {
key : "componentDidUpdate" ,
value : function componentDidUpdate ( prevProps ) {
2020-01-08 06:57:23 -05:00
var _this$props8 = this . props ,
tagName = _this$props8 . tagName ,
value = _this$props8 . value ,
selectionStart = _this$props8 . selectionStart ,
selectionEnd = _this$props8 . selectionEnd ,
placeholder = _this$props8 . placeholder ,
isSelected = _this$props8 . _ _unstableIsSelected ; // Check if tag name changed.
2019-09-19 11:19:18 -04:00
2020-01-08 06:57:23 -05:00
var shouldReapply = tagName !== prevProps . tagName ; // Check if the content changed.
2020-01-22 17:06:21 -05:00
shouldReapply = shouldReapply || value !== prevProps . value && value !== this . value ;
var selectionChanged = selectionStart !== prevProps . selectionStart && selectionStart !== this . record . start || selectionEnd !== prevProps . selectionEnd && selectionEnd !== this . record . end ; // Check if the selection changed.
2019-09-19 11:19:18 -04:00
2020-01-22 17:06:21 -05:00
shouldReapply = shouldReapply || isSelected && ! prevProps . isSelected && selectionChanged ;
2019-09-19 11:19:18 -04:00
var prefix = 'format_prepare_props_' ;
var predicate = function predicate ( v , key ) {
return key . startsWith ( prefix ) ;
} ;
2020-01-03 08:17:24 -05:00
var prepareProps = Object ( external _this _lodash _ [ "pickBy" ] ) ( this . props , predicate ) ;
var prevPrepareProps = Object ( external _this _lodash _ [ "pickBy" ] ) ( prevProps , predicate ) ; // Check if any format props changed.
2019-09-19 11:19:18 -04:00
shouldReapply = shouldReapply || ! external _this _wp _isShallowEqual _default ( ) ( prepareProps , prevPrepareProps ) ; // Rerender if the placeholder changed.
shouldReapply = shouldReapply || placeholder !== prevProps . placeholder ;
if ( shouldReapply ) {
this . value = value ;
this . record = this . formatToValue ( value ) ;
this . record . start = selectionStart ;
this . record . end = selectionEnd ;
this . applyRecord ( this . record ) ;
2020-01-22 17:06:21 -05:00
} else if ( selectionChanged ) {
2020-02-06 16:03:31 -05:00
this . record = component _objectSpread ( { } , this . record , {
2019-09-19 11:19:18 -04:00
start : selectionStart ,
end : selectionEnd
} ) ;
}
}
/ * *
* Converts the outside data structure to our internal representation .
*
* @ param { * } value The outside value , data type depends on props .
* @ return { Object } An internal rich - text value .
* /
} , {
key : "formatToValue" ,
value : function formatToValue ( value ) {
2020-01-08 06:57:23 -05:00
var _this$props9 = this . props ,
format = _this$props9 . format ,
multilineTag = _this$props9 . _ _unstableMultilineTag ,
preserveWhiteSpace = _this$props9 . preserveWhiteSpace ;
2019-09-19 11:19:18 -04:00
if ( format !== 'string' ) {
return value ;
}
var prepare = createPrepareEditableTree ( this . props , 'format_value_functions' ) ;
value = create ( {
html : value ,
multilineTag : multilineTag ,
2020-01-08 06:57:23 -05:00
multilineWrapperTags : multilineTag === 'li' ? [ 'ul' , 'ol' ] : undefined ,
preserveWhiteSpace : preserveWhiteSpace
2019-09-19 11:19:18 -04:00
} ) ;
value . formats = prepare ( value ) ;
return value ;
}
/ * *
* Removes editor only formats from the value .
*
* Editor only formats are applied using ` prepareEditableTree ` , so we need to
* remove them before converting the internal state
*
* @ param { Object } value The internal rich - text value .
* @ return { Object } A new rich - text value .
* /
} , {
key : "removeEditorOnlyFormats" ,
value : function removeEditorOnlyFormats ( value ) {
this . props . formatTypes . forEach ( function ( formatType ) {
// Remove formats created by prepareEditableTree, because they are editor only.
if ( formatType . _ _experimentalCreatePrepareEditableTree ) {
value = removeFormat ( value , formatType . name , 0 , value . text . length ) ;
}
} ) ;
return value ;
}
/ * *
* Converts the internal value to the external data format .
*
* @ param { Object } value The internal rich - text value .
* @ return { * } The external data format , data type depends on props .
* /
} , {
key : "valueToFormat" ,
value : function valueToFormat ( value ) {
2020-01-08 06:57:23 -05:00
var _this$props10 = this . props ,
format = _this$props10 . format ,
multilineTag = _this$props10 . _ _unstableMultilineTag ,
preserveWhiteSpace = _this$props10 . preserveWhiteSpace ;
2019-09-19 11:19:18 -04:00
value = this . removeEditorOnlyFormats ( value ) ;
if ( format !== 'string' ) {
return ;
}
return toHTMLString ( {
value : value ,
2020-01-08 06:57:23 -05:00
multilineTag : multilineTag ,
preserveWhiteSpace : preserveWhiteSpace
2019-09-19 11:19:18 -04:00
} ) ;
}
} , {
key : "Editable" ,
value : function Editable ( props ) {
2020-01-22 17:06:21 -05:00
var _this2 = this ;
Block Editor: Update WordPress packages to include the latest bug fixes.
Updated packages:
@wordpress/annotations@1.7.1
@wordpress/api-fetch@3.6.1
@wordpress/babel-plugin-makepot@3.2.1
@wordpress/babel-preset-default@4.6.1
@wordpress/block-directory@1.0.1
@wordpress/block-editor@3.2.1
@wordpress/block-library@2.9.1
@wordpress/blocks@6.7.1
@wordpress/components@8.3.1
@wordpress/compose@3.7.1
@wordpress/core-data@2.7.1
@wordpress/data-controls@1.3.1
@wordpress/data@4.9.1
@wordpress/docgen@1.4.1
@wordpress/dom@2.5.1
@wordpress/e2e-test-utils@2.4.1
@wordpress/e2e-tests@1.7.1
@wordpress/edit-post@3.8.1
@wordpress/editor@9.7.1
@wordpress/element@2.8.1
@wordpress/format-library@1.9.1
@wordpress/i18n@3.6.1
@wordpress/jest-console@3.3.1
@wordpress/jest-preset-default@5.1.1
@wordpress/keycodes@2.6.1
@wordpress/library-export-default-webpack-plugin@1.4.1
@wordpress/list-reusable-blocks@1.8.1
@wordpress/media-utils@1.2.1
@wordpress/notices@1.8.1
@wordpress/nux@3.7.1
@wordpress/plugins@2.7.1
@wordpress/redux-routine@3.6.1
@wordpress/rich-text@3.7.1
@wordpress/scripts@5.0.1
@wordpress/server-side-render@1.3.1
@wordpress/shortcode@2.4.1
@wordpress/token-list@1.6.1
@wordpress/viewport@2.8.1
@wordpress/wordcount@2.6.1
Props epiqueras, youknowriad, donmhico, jorgefilipecosta, soean, mcsf, noisysocks, andraganescu, gziolo, talldanwp, iseulde, nrqsnchz, mapk, karmatosed, joen, afercia, kjellr, desrosj.
Fixes #48186.
Built from https://develop.svn.wordpress.org/trunk@46364
git-svn-id: http://core.svn.wordpress.org/trunk@46163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-30 16:07:06 -04:00
2020-01-08 06:57:23 -05:00
var _this$props11 = this . props ,
_this$props11$tagName = _this$props11 . tagName ,
TagName = _this$props11$tagName === void 0 ? 'div' : _this$props11$tagName ,
style = _this$props11 . style ,
className = _this$props11 . className ,
placeholder = _this$props11 . placeholder ,
forwardedRef = _this$props11 . forwardedRef ,
disabled = _this$props11 . disabled ;
var ariaProps = Object ( external _this _lodash _ [ "pickBy" ] ) ( this . props , function ( value , key ) {
return Object ( external _this _lodash _ [ "startsWith" ] ) ( key , 'aria-' ) ;
} ) ;
return Object ( external _this _wp _element _ [ "createElement" ] ) ( TagName // Overridable props.
, Object ( esm _extends [ "a" /* default */ ] ) ( {
role : "textbox" ,
"aria-multiline" : true ,
2019-09-19 11:19:18 -04:00
"aria-label" : placeholder
2020-01-08 06:57:23 -05:00
} , props , ariaProps , {
ref : forwardedRef ,
2020-02-06 16:03:31 -05:00
style : style ? component _objectSpread ( { } , style , {
2020-01-08 06:57:23 -05:00
whiteSpace : whiteSpace
} ) : defaultStyle ,
2019-09-19 11:19:18 -04:00
className : classnames _default ( ) ( 'rich-text' , className ) ,
onPaste : this . onPaste ,
onInput : this . onInput ,
2020-01-22 17:06:21 -05:00
onCompositionStart : this . onCompositionStart ,
2019-09-19 11:19:18 -04:00
onCompositionEnd : this . onCompositionEnd ,
Block Editor: Update WordPress packages to include the latest bug fixes.
Updated packages:
@wordpress/annotations@1.7.1
@wordpress/api-fetch@3.6.1
@wordpress/babel-plugin-makepot@3.2.1
@wordpress/babel-preset-default@4.6.1
@wordpress/block-directory@1.0.1
@wordpress/block-editor@3.2.1
@wordpress/block-library@2.9.1
@wordpress/blocks@6.7.1
@wordpress/components@8.3.1
@wordpress/compose@3.7.1
@wordpress/core-data@2.7.1
@wordpress/data-controls@1.3.1
@wordpress/data@4.9.1
@wordpress/docgen@1.4.1
@wordpress/dom@2.5.1
@wordpress/e2e-test-utils@2.4.1
@wordpress/e2e-tests@1.7.1
@wordpress/edit-post@3.8.1
@wordpress/editor@9.7.1
@wordpress/element@2.8.1
@wordpress/format-library@1.9.1
@wordpress/i18n@3.6.1
@wordpress/jest-console@3.3.1
@wordpress/jest-preset-default@5.1.1
@wordpress/keycodes@2.6.1
@wordpress/library-export-default-webpack-plugin@1.4.1
@wordpress/list-reusable-blocks@1.8.1
@wordpress/media-utils@1.2.1
@wordpress/notices@1.8.1
@wordpress/nux@3.7.1
@wordpress/plugins@2.7.1
@wordpress/redux-routine@3.6.1
@wordpress/rich-text@3.7.1
@wordpress/scripts@5.0.1
@wordpress/server-side-render@1.3.1
@wordpress/shortcode@2.4.1
@wordpress/token-list@1.6.1
@wordpress/viewport@2.8.1
@wordpress/wordcount@2.6.1
Props epiqueras, youknowriad, donmhico, jorgefilipecosta, soean, mcsf, noisysocks, andraganescu, gziolo, talldanwp, iseulde, nrqsnchz, mapk, karmatosed, joen, afercia, kjellr, desrosj.
Fixes #48186.
Built from https://develop.svn.wordpress.org/trunk@46364
git-svn-id: http://core.svn.wordpress.org/trunk@46163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-30 16:07:06 -04:00
onKeyDown : props . onKeyDown ? function ( event ) {
props . onKeyDown ( event ) ;
2020-01-22 17:06:21 -05:00
_this2 . onKeyDown ( event ) ;
Block Editor: Update WordPress packages to include the latest bug fixes.
Updated packages:
@wordpress/annotations@1.7.1
@wordpress/api-fetch@3.6.1
@wordpress/babel-plugin-makepot@3.2.1
@wordpress/babel-preset-default@4.6.1
@wordpress/block-directory@1.0.1
@wordpress/block-editor@3.2.1
@wordpress/block-library@2.9.1
@wordpress/blocks@6.7.1
@wordpress/components@8.3.1
@wordpress/compose@3.7.1
@wordpress/core-data@2.7.1
@wordpress/data-controls@1.3.1
@wordpress/data@4.9.1
@wordpress/docgen@1.4.1
@wordpress/dom@2.5.1
@wordpress/e2e-test-utils@2.4.1
@wordpress/e2e-tests@1.7.1
@wordpress/edit-post@3.8.1
@wordpress/editor@9.7.1
@wordpress/element@2.8.1
@wordpress/format-library@1.9.1
@wordpress/i18n@3.6.1
@wordpress/jest-console@3.3.1
@wordpress/jest-preset-default@5.1.1
@wordpress/keycodes@2.6.1
@wordpress/library-export-default-webpack-plugin@1.4.1
@wordpress/list-reusable-blocks@1.8.1
@wordpress/media-utils@1.2.1
@wordpress/notices@1.8.1
@wordpress/nux@3.7.1
@wordpress/plugins@2.7.1
@wordpress/redux-routine@3.6.1
@wordpress/rich-text@3.7.1
@wordpress/scripts@5.0.1
@wordpress/server-side-render@1.3.1
@wordpress/shortcode@2.4.1
@wordpress/token-list@1.6.1
@wordpress/viewport@2.8.1
@wordpress/wordcount@2.6.1
Props epiqueras, youknowriad, donmhico, jorgefilipecosta, soean, mcsf, noisysocks, andraganescu, gziolo, talldanwp, iseulde, nrqsnchz, mapk, karmatosed, joen, afercia, kjellr, desrosj.
Fixes #48186.
Built from https://develop.svn.wordpress.org/trunk@46364
git-svn-id: http://core.svn.wordpress.org/trunk@46163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-30 16:07:06 -04:00
} : this . onKeyDown ,
2019-09-19 11:19:18 -04:00
onFocus : this . onFocus ,
onBlur : this . onBlur ,
onMouseDown : this . onPointerDown ,
2020-01-08 06:57:23 -05:00
onTouchStart : this . onPointerDown // Selection updates must be done at these events as they
2019-09-19 11:19:18 -04:00
// happen before the `selectionchange` event. In some cases,
// the `selectionchange` event may not even fire, for
// example when the window receives focus again on click.
,
onKeyUp : this . onSelectionChange ,
onMouseUp : this . onSelectionChange ,
2020-01-08 06:57:23 -05:00
onTouchEnd : this . onSelectionChange // Do not set the attribute if disabled.
,
contentEditable : disabled ? undefined : true ,
suppressContentEditableWarning : ! disabled
2019-09-19 11:19:18 -04:00
} ) ) ;
}
} , {
key : "render" ,
value : function render ( ) {
2020-02-06 16:03:31 -05:00
var _this3 = this ;
2020-01-08 06:57:23 -05:00
var _this$props12 = this . props ,
isSelected = _this$props12 . _ _unstableIsSelected ,
children = _this$props12 . children ,
allowedFormats = _this$props12 . allowedFormats ,
2020-01-22 17:06:21 -05:00
withoutInteractiveFormatting = _this$props12 . withoutInteractiveFormatting ,
formatTypes = _this$props12 . formatTypes ,
forwardedRef = _this$props12 . forwardedRef ;
var activeFormats = this . state . activeFormats ;
2020-02-06 16:03:31 -05:00
var onFocus = function onFocus ( ) {
forwardedRef . current . focus ( ) ;
_this3 . applyRecord ( _this3 . record ) ;
} ;
2020-01-22 17:06:21 -05:00
return Object ( external _this _wp _element _ [ "createElement" ] ) ( external _this _wp _element _ [ "Fragment" ] , null , Object ( external _this _wp _element _ [ "createElement" ] ) ( BoundaryStyle , {
activeFormats : activeFormats ,
forwardedRef : forwardedRef
2020-02-06 16:03:31 -05:00
} ) , Object ( external _this _wp _element _ [ "createElement" ] ) ( InlineWarning , {
forwardedRef : forwardedRef
2020-01-22 17:06:21 -05:00
} ) , isSelected && Object ( external _this _wp _element _ [ "createElement" ] ) ( FormatEdit , {
2019-09-19 11:19:18 -04:00
allowedFormats : allowedFormats ,
withoutInteractiveFormatting : withoutInteractiveFormatting ,
value : this . record ,
2020-01-22 17:06:21 -05:00
onChange : this . onChange ,
2020-02-06 16:03:31 -05:00
onFocus : onFocus ,
2020-01-22 17:06:21 -05:00
formatTypes : formatTypes
2019-09-19 11:19:18 -04:00
} ) , children && children ( {
isSelected : isSelected ,
value : this . record ,
onChange : this . onChange ,
2020-02-06 16:03:31 -05:00
onFocus : onFocus ,
2019-09-19 11:19:18 -04:00
Editable : this . Editable
} ) , ! children && Object ( external _this _wp _element _ [ "createElement" ] ) ( this . Editable , null ) ) ;
}
} ] ) ;
2019-10-15 11:37:08 -04:00
return RichText ;
} ( external _this _wp _element _ [ "Component" ] ) ;
component _RichText . defaultProps = {
format : 'string' ,
value : ''
} ;
2020-01-22 17:06:21 -05:00
var RichTextWrapper = Object ( external _this _wp _compose _ [ "compose" ] ) ( [ external _this _wp _compose _ [ "withSafeTimeout" ] , withFormatTypes ] ) ( component _RichText ) ;
2019-10-15 11:37:08 -04:00
/ * *
* Renders a rich content input , providing users with the option to format the
* content .
* /
2020-01-08 06:57:23 -05:00
/* harmony default export */ var component = ( Object ( external _this _wp _element _ [ "forwardRef" ] ) ( function ( props , ref ) {
return Object ( external _this _wp _element _ [ "createElement" ] ) ( RichTextWrapper , Object ( esm _extends [ "a" /* default */ ] ) ( { } , props , {
forwardedRef : ref
} ) ) ;
} ) ) ;
2019-10-15 11:37:08 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/index.js
/* concated harmony reexport applyFormat */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "applyFormat" , function ( ) { return applyFormat ; } ) ;
/* concated harmony reexport concat */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "concat" , function ( ) { return concat ; } ) ;
/* concated harmony reexport create */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "create" , function ( ) { return create ; } ) ;
/* concated harmony reexport getActiveFormat */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "getActiveFormat" , function ( ) { return getActiveFormat ; } ) ;
/* concated harmony reexport getActiveObject */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "getActiveObject" , function ( ) { return getActiveObject ; } ) ;
/* concated harmony reexport getTextContent */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "getTextContent" , function ( ) { return getTextContent ; } ) ;
/* concated harmony reexport __unstableIsListRootSelected */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableIsListRootSelected" , function ( ) { return isListRootSelected ; } ) ;
/* concated harmony reexport __unstableIsActiveListType */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableIsActiveListType" , function ( ) { return isActiveListType ; } ) ;
/* concated harmony reexport isCollapsed */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "isCollapsed" , function ( ) { return isCollapsed ; } ) ;
/* concated harmony reexport isEmpty */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "isEmpty" , function ( ) { return isEmpty ; } ) ;
/* concated harmony reexport __unstableIsEmptyLine */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableIsEmptyLine" , function ( ) { return isEmptyLine ; } ) ;
/* concated harmony reexport join */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "join" , function ( ) { return join ; } ) ;
/* concated harmony reexport registerFormatType */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "registerFormatType" , function ( ) { return registerFormatType ; } ) ;
/* concated harmony reexport removeFormat */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "removeFormat" , function ( ) { return removeFormat ; } ) ;
/* concated harmony reexport remove */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "remove" , function ( ) { return remove _remove ; } ) ;
/* concated harmony reexport replace */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "replace" , function ( ) { return replace _replace ; } ) ;
/* concated harmony reexport insert */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "insert" , function ( ) { return insert ; } ) ;
2020-01-22 17:06:21 -05:00
/* concated harmony reexport __unstableInsertLineSeparator */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableInsertLineSeparator" , function ( ) { return insertLineSeparator ; } ) ;
/* concated harmony reexport __unstableRemoveLineSeparator */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableRemoveLineSeparator" , function ( ) { return removeLineSeparator ; } ) ;
/* concated harmony reexport insertObject */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "insertObject" , function ( ) { return insertObject ; } ) ;
/* concated harmony reexport slice */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "slice" , function ( ) { return slice ; } ) ;
/* concated harmony reexport split */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "split" , function ( ) { return split ; } ) ;
/* concated harmony reexport __unstableToDom */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableToDom" , function ( ) { return toDom ; } ) ;
/* concated harmony reexport toHTMLString */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "toHTMLString" , function ( ) { return toHTMLString ; } ) ;
/* concated harmony reexport toggleFormat */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "toggleFormat" , function ( ) { return toggleFormat ; } ) ;
/* concated harmony reexport __UNSTABLE_LINE_SEPARATOR */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__UNSTABLE_LINE_SEPARATOR" , function ( ) { return LINE _SEPARATOR ; } ) ;
/* concated harmony reexport unregisterFormatType */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "unregisterFormatType" , function ( ) { return unregisterFormatType ; } ) ;
/* concated harmony reexport __unstableCanIndentListItems */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableCanIndentListItems" , function ( ) { return canIndentListItems ; } ) ;
/* concated harmony reexport __unstableCanOutdentListItems */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableCanOutdentListItems" , function ( ) { return canOutdentListItems ; } ) ;
/* concated harmony reexport __unstableIndentListItems */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableIndentListItems" , function ( ) { return indentListItems ; } ) ;
/* concated harmony reexport __unstableOutdentListItems */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableOutdentListItems" , function ( ) { return outdentListItems ; } ) ;
/* concated harmony reexport __unstableChangeListType */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableChangeListType" , function ( ) { return changeListType ; } ) ;
/* concated harmony reexport __unstableCreateElement */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableCreateElement" , function ( ) { return createElement ; } ) ;
/* concated harmony reexport __experimentalRichText */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__experimentalRichText" , function ( ) { return component ; } ) ;
/* concated harmony reexport __unstableFormatEdit */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__unstableFormatEdit" , function ( ) { return FormatEdit ; } ) ;
2019-10-15 11:37:08 -04:00
/ * *
2020-01-22 17:06:21 -05:00
* Internal dependencies
2019-10-15 11:37:08 -04:00
* /
2019-09-19 11:19:18 -04:00
2019-10-15 11:37:08 -04:00
2019-09-19 11:19:18 -04:00
2019-10-15 11:37:08 -04:00
/***/ } ) ,
2019-09-19 11:19:18 -04:00
2020-02-06 16:03:31 -05:00
/***/ 5 :
2019-09-19 11:19:18 -04:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
2018-12-16 23:52:00 -05:00
2018-12-17 22:14:52 -05:00
"use strict" ;
2020-02-06 16:03:31 -05:00
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _defineProperty ; } ) ;
function _defineProperty ( obj , key , value ) {
if ( key in obj ) {
Object . defineProperty ( obj , key , {
value : value ,
enumerable : true ,
configurable : true ,
writable : true
2018-12-17 22:14:52 -05:00
} ) ;
2020-02-06 16:03:31 -05:00
} else {
obj [ key ] = value ;
2018-12-17 22:14:52 -05:00
}
2020-02-06 16:03:31 -05:00
return obj ;
2018-12-17 22:14:52 -05:00
}
2018-12-13 23:41:57 -05:00
2019-09-19 11:19:18 -04:00
/***/ } ) ,
2020-03-23 19:40:19 -04:00
/***/ 51 :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = this [ "wp" ] [ "isShallowEqual" ] ; } ( ) ) ;
/***/ } ) ,
/***/ 68 :
2020-01-22 17:06:21 -05:00
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = this [ "wp" ] [ "escapeHtml" ] ; } ( ) ) ;
/***/ } ) ,
/***/ 7 :
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _assertThisInitialized ; } ) ;
function _assertThisInitialized ( self ) {
if ( self === void 0 ) {
throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ;
}
return self ;
}
/***/ } ) ,
2020-01-08 06:57:23 -05:00
/***/ 8 :
2019-10-15 12:17:12 -04:00
/***/ ( function ( module , exports ) {
2020-01-08 06:57:23 -05:00
( function ( ) { module . exports = this [ "wp" ] [ "compose" ] ; } ( ) ) ;
2019-10-15 12:17:12 -04:00
2018-12-13 23:41:57 -05:00
/***/ } )
2018-12-17 22:14:52 -05:00
/******/ } ) ;