2024-04-17 11:32:24 +02:00
/******/ ( ( ) => { // webpackBootstrap
2022-06-16 14:03:35 +02:00
/******/ "use strict" ;
/******/ // The require scope
/******/ var _ _webpack _require _ _ = { } ;
/******/
/************************************************************************/
2022-12-15 17:47:31 +01:00
/******/ /* webpack/runtime/compat get default export */
2024-04-17 11:32:24 +02:00
/******/ ( ( ) => {
2022-12-15 17:47:31 +01:00
/******/ // getDefaultExport function for compatibility with non-harmony modules
2024-04-17 11:32:24 +02:00
/******/ _ _webpack _require _ _ . n = ( module ) => {
2022-12-15 17:47:31 +01:00
/******/ var getter = module && module . _ _esModule ?
2024-04-17 11:32:24 +02:00
/******/ ( ) => ( module [ 'default' ] ) :
/******/ ( ) => ( module ) ;
2022-12-15 17:47:31 +01:00
/******/ _ _webpack _require _ _ . d ( getter , { a : getter } ) ;
/******/ return getter ;
/******/ } ;
2024-04-17 11:32:24 +02:00
/******/ } ) ( ) ;
2022-12-15 17:47:31 +01:00
/******/
2022-06-16 14:03:35 +02:00
/******/ /* webpack/runtime/define property getters */
2024-04-17 11:32:24 +02:00
/******/ ( ( ) => {
2022-06-16 14:03:35 +02:00
/******/ // define getter functions for harmony exports
2024-04-17 11:32:24 +02:00
/******/ _ _webpack _require _ _ . d = ( exports , definition ) => {
2022-06-16 14:03:35 +02:00
/******/ for ( var key in definition ) {
/******/ if ( _ _webpack _require _ _ . o ( definition , key ) && ! _ _webpack _require _ _ . o ( exports , key ) ) {
/******/ Object . defineProperty ( exports , key , { enumerable : true , get : definition [ key ] } ) ;
/******/ }
/******/ }
/******/ } ;
2024-04-17 11:32:24 +02:00
/******/ } ) ( ) ;
2022-06-16 14:03:35 +02:00
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
2024-04-17 11:32:24 +02:00
/******/ ( ( ) => {
/******/ _ _webpack _require _ _ . o = ( obj , prop ) => ( Object . prototype . hasOwnProperty . call ( obj , prop ) )
/******/ } ) ( ) ;
2022-06-16 14:03:35 +02:00
/******/
/******/ /* webpack/runtime/make namespace object */
2024-04-17 11:32:24 +02:00
/******/ ( ( ) => {
2022-06-16 14:03:35 +02:00
/******/ // define __esModule on exports
2024-04-17 11:32:24 +02:00
/******/ _ _webpack _require _ _ . r = ( exports ) => {
2022-06-16 14:03:35 +02:00
/******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
/******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
/******/ }
/******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
2019-11-02 10:38:58 +01:00
/******/ } ;
2024-04-17 11:32:24 +02:00
/******/ } ) ( ) ;
2022-06-16 14:03:35 +02:00
/******/
2019-11-02 10:38:58 +01:00
/************************************************************************/
2022-06-16 14:03:35 +02:00
var _ _webpack _exports _ _ = { } ;
// ESM COMPAT FLAG
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
2020-09-15 14:29:22 +02:00
2022-06-16 14:03:35 +02:00
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
2024-04-17 11:32:24 +02:00
RichTextData : ( ) => ( /* reexport */ RichTextData ) ,
_ _experimentalRichText : ( ) => ( /* reexport */ _ _experimentalRichText ) ,
_ _unstableCreateElement : ( ) => ( /* reexport */ createElement ) ,
_ _unstableToDom : ( ) => ( /* reexport */ toDom ) ,
_ _unstableUseRichText : ( ) => ( /* reexport */ useRichText ) ,
applyFormat : ( ) => ( /* reexport */ applyFormat ) ,
concat : ( ) => ( /* reexport */ concat ) ,
create : ( ) => ( /* reexport */ create ) ,
getActiveFormat : ( ) => ( /* reexport */ getActiveFormat ) ,
getActiveFormats : ( ) => ( /* reexport */ getActiveFormats ) ,
getActiveObject : ( ) => ( /* reexport */ getActiveObject ) ,
getTextContent : ( ) => ( /* reexport */ getTextContent ) ,
insert : ( ) => ( /* reexport */ insert ) ,
insertObject : ( ) => ( /* reexport */ insertObject ) ,
isCollapsed : ( ) => ( /* reexport */ isCollapsed ) ,
isEmpty : ( ) => ( /* reexport */ isEmpty ) ,
join : ( ) => ( /* reexport */ join ) ,
registerFormatType : ( ) => ( /* reexport */ registerFormatType ) ,
remove : ( ) => ( /* reexport */ remove _remove ) ,
removeFormat : ( ) => ( /* reexport */ removeFormat ) ,
replace : ( ) => ( /* reexport */ replace _replace ) ,
slice : ( ) => ( /* reexport */ slice ) ,
split : ( ) => ( /* reexport */ split ) ,
store : ( ) => ( /* reexport */ store ) ,
toHTMLString : ( ) => ( /* reexport */ toHTMLString ) ,
toggleFormat : ( ) => ( /* reexport */ toggleFormat ) ,
unregisterFormatType : ( ) => ( /* reexport */ unregisterFormatType ) ,
useAnchor : ( ) => ( /* reexport */ useAnchor ) ,
useAnchorRef : ( ) => ( /* reexport */ useAnchorRef )
2022-06-16 14:03:35 +02:00
} ) ;
2020-09-15 14:29:22 +02:00
2022-06-16 14:03:35 +02:00
// NAMESPACE OBJECT: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js
var selectors _namespaceObject = { } ;
_ _webpack _require _ _ . r ( selectors _namespaceObject ) ;
_ _webpack _require _ _ . d ( selectors _namespaceObject , {
2024-04-17 11:32:24 +02:00
getFormatType : ( ) => ( getFormatType ) ,
getFormatTypeForBareElement : ( ) => ( getFormatTypeForBareElement ) ,
getFormatTypeForClassName : ( ) => ( getFormatTypeForClassName ) ,
getFormatTypes : ( ) => ( getFormatTypes )
2022-06-16 14:03:35 +02:00
} ) ;
2020-09-15 14:29:22 +02:00
2022-06-16 14:03:35 +02:00
// NAMESPACE OBJECT: ./node_modules/@wordpress/rich-text/build-module/store/actions.js
var actions _namespaceObject = { } ;
_ _webpack _require _ _ . r ( actions _namespaceObject ) ;
_ _webpack _require _ _ . d ( actions _namespaceObject , {
2024-04-17 11:32:24 +02:00
addFormatTypes : ( ) => ( addFormatTypes ) ,
removeFormatTypes : ( ) => ( removeFormatTypes )
2022-06-16 14:03:35 +02:00
} ) ;
2019-11-15 22:59:44 +01:00
2025-04-25 12:30:07 +02:00
; // external ["wp","data"]
2024-04-17 11:32:24 +02:00
const external _wp _data _namespaceObject = window [ "wp" ] [ "data" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/store/reducer.js
2025-12-12 13:15:55 +01:00
2023-09-26 10:33:34 +02:00
function formatTypes ( state = { } , action ) {
2022-06-16 14:03:35 +02:00
switch ( action . type ) {
2025-12-12 13:15:55 +01:00
case "ADD_FORMAT_TYPES" :
2023-12-07 09:44:11 +01:00
return {
... state ,
2022-12-15 17:47:31 +01:00
// Key format types by their name.
2025-12-12 13:15:55 +01:00
... action . formatTypes . reduce (
( newFormatTypes , type ) => ( {
... newFormatTypes ,
[ type . name ] : type
} ) ,
{ }
)
2022-06-16 14:03:35 +02:00
} ;
2025-12-12 13:15:55 +01:00
case "REMOVE_FORMAT_TYPES" :
return Object . fromEntries (
Object . entries ( state ) . filter (
( [ key ] ) => ! action . names . includes ( key )
)
) ;
2022-06-16 14:03:35 +02:00
}
return state ;
}
2025-12-12 13:15:55 +01:00
var reducer _default = ( 0 , external _wp _data _namespaceObject . combineReducers ) ( { formatTypes } ) ;
2020-05-06 17:23:38 +02:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/store/selectors.js
2025-12-12 13:15:55 +01:00
const getFormatTypes = ( 0 , external _wp _data _namespaceObject . createSelector ) (
( state ) => Object . values ( state . formatTypes ) ,
( state ) => [ state . formatTypes ]
) ;
2019-11-15 22:59:44 +01:00
function getFormatType ( state , name ) {
return state . formatTypes [ name ] ;
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
function getFormatTypeForBareElement ( state , bareElementTagName ) {
2023-04-26 17:39:43 +02:00
const formatTypes = getFormatTypes ( state ) ;
2025-12-12 13:15:55 +01:00
return formatTypes . find ( ( { className , tagName } ) => {
2019-11-15 22:59:44 +01:00
return className === null && bareElementTagName === tagName ;
2025-12-12 13:15:55 +01:00
} ) || formatTypes . find ( ( { className , tagName } ) => {
return className === null && "*" === tagName ;
2019-11-15 22:59:44 +01:00
} ) ;
}
function getFormatTypeForClassName ( state , elementClassName ) {
2025-12-12 13:15:55 +01:00
return getFormatTypes ( state ) . find ( ( { className } ) => {
2019-11-15 22:59:44 +01:00
if ( className === null ) {
return false ;
}
2021-07-23 11:58:50 +02:00
return ` ${ elementClassName } ` . indexOf ( ` ${ className } ` ) >= 0 ;
2019-11-15 22:59:44 +01:00
} ) ;
}
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/store/actions.js
2019-11-15 22:59:44 +01:00
function addFormatTypes ( formatTypes ) {
return {
2025-12-12 13:15:55 +01:00
type : "ADD_FORMAT_TYPES" ,
2023-04-26 17:39:43 +02:00
formatTypes : Array . isArray ( formatTypes ) ? formatTypes : [ formatTypes ]
2019-11-15 22:59:44 +01:00
} ;
}
function removeFormatTypes ( names ) {
return {
2025-12-12 13:15:55 +01:00
type : "REMOVE_FORMAT_TYPES" ,
2023-04-26 17:39:43 +02:00
names : Array . isArray ( names ) ? names : [ names ]
2019-11-15 22:59:44 +01:00
} ;
}
2019-11-02 10:38:58 +01:00
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/store/index.js
2019-11-02 10:38:58 +01:00
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
const STORE _NAME = "core/rich-text" ;
2022-06-16 14:03:35 +02:00
const store = ( 0 , external _wp _data _namespaceObject . createReduxStore ) ( STORE _NAME , {
2025-12-12 13:15:55 +01:00
reducer : reducer _default ,
2019-11-15 22:59:44 +01:00
selectors : selectors _namespaceObject ,
actions : actions _namespaceObject
} ) ;
2022-06-16 14:03:35 +02:00
( 0 , external _wp _data _namespaceObject . register ) ( store ) ;
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/is-format-equal.js
2019-11-15 22:59:44 +01:00
function isFormatEqual ( format1 , format2 ) {
if ( format1 === format2 ) {
return true ;
2023-12-07 09:44:11 +01:00
}
2019-11-15 22:59:44 +01:00
if ( ! format1 || ! format2 ) {
return false ;
}
if ( format1 . type !== format2 . type ) {
return false ;
}
2021-07-23 11:58:50 +02:00
const attributes1 = format1 . attributes ;
2023-12-07 09:44:11 +01:00
const attributes2 = format2 . attributes ;
2019-11-15 22:59:44 +01:00
if ( attributes1 === attributes2 ) {
return true ;
2023-12-07 09:44:11 +01:00
}
2019-11-15 22:59:44 +01:00
if ( ! attributes1 || ! attributes2 ) {
return false ;
}
2021-07-23 11:58:50 +02:00
const keys1 = Object . keys ( attributes1 ) ;
const keys2 = Object . keys ( attributes2 ) ;
2019-11-15 22:59:44 +01:00
if ( keys1 . length !== keys2 . length ) {
return false ;
}
2023-12-07 09:44:11 +01:00
const length = keys1 . length ;
2021-07-23 11:58:50 +02:00
for ( let i = 0 ; i < length ; i ++ ) {
const name = keys1 [ i ] ;
2019-11-15 22:59:44 +01:00
if ( attributes1 [ name ] !== attributes2 [ name ] ) {
return false ;
}
}
return true ;
}
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/normalise-formats.js
2023-12-07 09:44:11 +01:00
2019-11-15 22:59:44 +01:00
function normaliseFormats ( value ) {
2021-07-23 11:58:50 +02:00
const newFormats = value . formats . slice ( ) ;
newFormats . forEach ( ( formatsAtIndex , index ) => {
const formatsAtPreviousIndex = newFormats [ index - 1 ] ;
2019-11-15 22:59:44 +01:00
if ( formatsAtPreviousIndex ) {
2021-07-23 11:58:50 +02:00
const newFormatsAtIndex = formatsAtIndex . slice ( ) ;
newFormatsAtIndex . forEach ( ( format , formatIndex ) => {
const previousFormat = formatsAtPreviousIndex [ formatIndex ] ;
2019-11-15 22:59:44 +01:00
if ( isFormatEqual ( format , previousFormat ) ) {
newFormatsAtIndex [ formatIndex ] = previousFormat ;
}
} ) ;
newFormats [ index ] = newFormatsAtIndex ;
}
} ) ;
2023-12-07 09:44:11 +01:00
return {
... value ,
2019-11-15 22:59:44 +01:00
formats : newFormats
2021-07-23 11:58:50 +02:00
} ;
2019-11-15 22:59:44 +01:00
}
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/apply-format.js
2019-11-15 22:59:44 +01:00
function replace ( array , index , value ) {
array = array . slice ( ) ;
array [ index ] = value ;
return array ;
}
2023-09-26 10:33:34 +02:00
function applyFormat ( value , format , startIndex = value . start , endIndex = value . end ) {
2025-12-12 13:15:55 +01:00
const { formats , activeFormats } = value ;
2023-12-07 09:44:11 +01:00
const newFormats = formats . slice ( ) ;
2019-11-15 22:59:44 +01:00
if ( startIndex === endIndex ) {
2025-12-12 13:15:55 +01:00
const startFormat = newFormats [ startIndex ] ? . find (
( { type } ) => type === format . type
) ;
2019-11-15 22:59:44 +01:00
if ( startFormat ) {
2021-07-23 11:58:50 +02:00
const index = newFormats [ startIndex ] . indexOf ( startFormat ) ;
2019-11-15 22:59:44 +01:00
while ( newFormats [ startIndex ] && newFormats [ startIndex ] [ index ] === startFormat ) {
2025-12-12 13:15:55 +01:00
newFormats [ startIndex ] = replace (
newFormats [ startIndex ] ,
index ,
format
) ;
2019-11-15 22:59:44 +01:00
startIndex -- ;
}
endIndex ++ ;
while ( newFormats [ endIndex ] && newFormats [ endIndex ] [ index ] === startFormat ) {
2025-12-12 13:15:55 +01:00
newFormats [ endIndex ] = replace (
newFormats [ endIndex ] ,
index ,
format
) ;
2019-11-15 22:59:44 +01:00
endIndex ++ ;
}
}
} else {
2025-12-12 13:15:55 +01:00
let position = Infinity ;
2021-07-23 11:58:50 +02:00
for ( let index = startIndex ; index < endIndex ; index ++ ) {
if ( newFormats [ index ] ) {
2025-12-12 13:15:55 +01:00
newFormats [ index ] = newFormats [ index ] . filter (
( { type } ) => type !== format . type
) ;
2021-07-23 11:58:50 +02:00
const length = newFormats [ index ] . length ;
2019-11-15 22:59:44 +01:00
if ( length < position ) {
position = length ;
}
} else {
2021-07-23 11:58:50 +02:00
newFormats [ index ] = [ ] ;
2019-11-15 22:59:44 +01:00
position = 0 ;
}
}
2021-07-23 11:58:50 +02:00
for ( let index = startIndex ; index < endIndex ; index ++ ) {
newFormats [ index ] . splice ( position , 0 , format ) ;
2019-11-15 22:59:44 +01:00
}
}
2023-12-07 09:44:11 +01:00
return normaliseFormats ( {
... value ,
2019-11-15 22:59:44 +01: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.
2025-12-12 13:15:55 +01:00
activeFormats : [
... activeFormats ? . filter (
( { type } ) => type !== format . type
) || [ ] ,
format
]
2021-07-23 11:58:50 +02:00
} ) ;
2019-11-15 22:59:44 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/create-element.js
2025-12-12 13:15:55 +01:00
function createElement ( { implementation } , html ) {
2019-11-15 22:59:44 +01:00
if ( ! createElement . body ) {
2025-12-12 13:15:55 +01:00
createElement . body = implementation . createHTMLDocument ( "" ) . body ;
2019-11-15 22:59:44 +01:00
}
createElement . body . innerHTML = html ;
return createElement . body ;
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/special-characters.js
2025-12-12 13:15:55 +01:00
const OBJECT _REPLACEMENT _CHARACTER = "\uFFFC" ;
const ZWNBSP = "\uFEFF" ;
2023-12-07 09:44:11 +01:00
2019-11-15 22:59:44 +01:00
2025-04-25 12:30:07 +02:00
; // external ["wp","escapeHtml"]
2024-04-17 11:32:24 +02:00
const external _wp _escapeHtml _namespaceObject = window [ "wp" ] [ "escapeHtml" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/get-active-formats.js
2025-12-12 13:15:55 +01:00
2024-04-17 11:32:24 +02:00
function getActiveFormats ( value , EMPTY _ACTIVE _FORMATS = [ ] ) {
2025-12-12 13:15:55 +01:00
const { formats , start , end , activeFormats } = value ;
if ( start === void 0 ) {
2024-04-17 11:32:24 +02:00
return EMPTY _ACTIVE _FORMATS ;
}
if ( start === end ) {
if ( activeFormats ) {
return activeFormats ;
}
const formatsBefore = formats [ start - 1 ] || EMPTY _ACTIVE _FORMATS ;
const formatsAfter = formats [ start ] || EMPTY _ACTIVE _FORMATS ;
if ( formatsBefore . length < formatsAfter . length ) {
return formatsBefore ;
}
return formatsAfter ;
}
if ( ! formats [ start ] ) {
return EMPTY _ACTIVE _FORMATS ;
}
const selectedFormats = formats . slice ( start , end ) ;
const _activeFormats = [ ... selectedFormats [ 0 ] ] ;
let i = selectedFormats . length ;
while ( i -- ) {
const formatsAtIndex = selectedFormats [ i ] ;
if ( ! formatsAtIndex ) {
return EMPTY _ACTIVE _FORMATS ;
}
let ii = _activeFormats . length ;
while ( ii -- ) {
const format = _activeFormats [ ii ] ;
2025-12-12 13:15:55 +01:00
if ( ! formatsAtIndex . find (
( _format ) => isFormatEqual ( format , _format )
) ) {
2024-04-17 11:32:24 +02:00
_activeFormats . splice ( ii , 1 ) ;
2019-11-15 22:59:44 +01:00
}
}
2024-04-17 11:32:24 +02:00
if ( _activeFormats . length === 0 ) {
return EMPTY _ACTIVE _FORMATS ;
}
2019-11-15 22:59:44 +01:00
}
2024-04-17 11:32:24 +02:00
return _activeFormats || EMPTY _ACTIVE _FORMATS ;
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/get-format-type.js
2024-04-17 11:32:24 +02:00
function get _format _type _getFormatType ( name ) {
return ( 0 , external _wp _data _namespaceObject . select ) ( store ) . getFormatType ( name ) ;
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/to-tree.js
2024-04-17 11:32:24 +02:00
function restoreOnAttributes ( attributes , isEditableTree ) {
if ( isEditableTree ) {
return attributes ;
2019-11-15 22:59:44 +01:00
}
2024-04-17 11:32:24 +02:00
const newAttributes = { } ;
for ( const key in attributes ) {
let newKey = key ;
2025-12-12 13:15:55 +01:00
if ( key . startsWith ( "data-disable-rich-text-" ) ) {
newKey = key . slice ( "data-disable-rich-text-" . length ) ;
2024-04-17 11:32:24 +02:00
}
newAttributes [ newKey ] = attributes [ key ] ;
2019-11-15 22:59:44 +01:00
}
2024-04-17 11:32:24 +02:00
return newAttributes ;
}
function fromFormat ( {
type ,
tagName ,
attributes ,
unregisteredAttributes ,
object ,
boundaryClass ,
isEditableTree
} ) {
const formatType = get _format _type _getFormatType ( type ) ;
let elementAttributes = { } ;
if ( boundaryClass && isEditableTree ) {
2025-12-12 13:15:55 +01:00
elementAttributes [ "data-rich-text-format-boundary" ] = "true" ;
2019-11-15 22:59:44 +01:00
}
2024-04-17 11:32:24 +02:00
if ( ! formatType ) {
if ( attributes ) {
2025-12-12 13:15:55 +01:00
elementAttributes = { ... attributes , ... elementAttributes } ;
2024-04-17 11:32:24 +02:00
}
2019-11-15 22:59:44 +01:00
return {
2024-04-17 11:32:24 +02:00
type ,
2025-12-12 13:15:55 +01:00
attributes : restoreOnAttributes (
elementAttributes ,
isEditableTree
) ,
2024-04-17 11:32:24 +02:00
object
2019-11-15 22:59:44 +01:00
} ;
}
2025-12-12 13:15:55 +01:00
elementAttributes = { ... unregisteredAttributes , ... elementAttributes } ;
2024-04-17 11:32:24 +02:00
for ( const name in attributes ) {
const key = formatType . attributes ? formatType . attributes [ name ] : false ;
if ( key ) {
elementAttributes [ key ] = attributes [ name ] ;
} else {
elementAttributes [ name ] = attributes [ name ] ;
2019-11-15 22:59:44 +01:00
}
}
2024-04-17 11:32:24 +02:00
if ( formatType . className ) {
if ( elementAttributes . class ) {
elementAttributes . class = ` ${ formatType . className } ${ elementAttributes . class } ` ;
} else {
elementAttributes . class = formatType . className ;
}
2022-04-02 10:26:41 +02:00
}
2019-11-15 22:59:44 +01:00
return {
2024-04-17 11:32:24 +02:00
type : tagName || formatType . tagName ,
object : formatType . object ,
attributes : restoreOnAttributes ( elementAttributes , isEditableTree )
2019-11-15 22:59:44 +01:00
} ;
}
2024-04-17 11:32:24 +02:00
function isEqualUntil ( a , b , index ) {
do {
if ( a [ index ] !== b [ index ] ) {
return false ;
}
} while ( index -- ) ;
return true ;
}
function toTree ( {
value ,
preserveWhiteSpace ,
createEmpty ,
append ,
getLastChild ,
getParent ,
isText ,
getText ,
remove ,
appendText ,
onStartIndex ,
onEndIndex ,
isEditableTree ,
placeholder
} ) {
2025-12-12 13:15:55 +01:00
const { formats , replacements , text , start , end } = value ;
2024-04-17 11:32:24 +02:00
const formatsLength = formats . length + 1 ;
const tree = createEmpty ( ) ;
const activeFormats = getActiveFormats ( value ) ;
const deepestActiveFormat = activeFormats [ activeFormats . length - 1 ] ;
let lastCharacterFormats ;
let lastCharacter ;
2025-12-12 13:15:55 +01:00
append ( tree , "" ) ;
2024-04-17 11:32:24 +02:00
for ( let i = 0 ; i < formatsLength ; i ++ ) {
const character = text . charAt ( i ) ;
2025-12-12 13:15:55 +01:00
const shouldInsertPadding = isEditableTree && // Pad the line if the line is empty.
( ! lastCharacter || // Pad the line if the previous character is a line break, otherwise
2024-04-17 11:32:24 +02:00
// the line break won't be visible.
2025-12-12 13:15:55 +01:00
lastCharacter === "\n" ) ;
2024-04-17 11:32:24 +02:00
const characterFormats = formats [ i ] ;
let pointer = getLastChild ( tree ) ;
if ( characterFormats ) {
characterFormats . forEach ( ( format , formatIndex ) => {
2025-12-12 13:15:55 +01:00
if ( pointer && lastCharacterFormats && // Reuse the last element if all formats remain the same.
isEqualUntil (
characterFormats ,
lastCharacterFormats ,
formatIndex
) ) {
2024-04-17 11:32:24 +02:00
pointer = getLastChild ( pointer ) ;
return ;
}
2025-12-12 13:15:55 +01:00
const { type , tagName , attributes , unregisteredAttributes } = format ;
2024-04-17 11:32:24 +02:00
const boundaryClass = isEditableTree && format === deepestActiveFormat ;
const parent = getParent ( pointer ) ;
2025-12-12 13:15:55 +01:00
const newNode = append (
parent ,
fromFormat ( {
type ,
tagName ,
attributes ,
unregisteredAttributes ,
boundaryClass ,
isEditableTree
} )
) ;
2024-04-17 11:32:24 +02:00
if ( isText ( pointer ) && getText ( pointer ) . length === 0 ) {
remove ( pointer ) ;
}
2025-12-12 13:15:55 +01:00
pointer = append ( newNode , "" ) ;
2024-04-17 11:32:24 +02:00
} ) ;
}
if ( i === 0 ) {
if ( onStartIndex && start === 0 ) {
onStartIndex ( tree , pointer ) ;
}
if ( onEndIndex && end === 0 ) {
onEndIndex ( tree , pointer ) ;
}
}
if ( character === OBJECT _REPLACEMENT _CHARACTER ) {
const replacement = replacements [ i ] ;
2025-02-28 08:42:11 +01:00
if ( ! replacement ) {
continue ;
}
2025-12-12 13:15:55 +01:00
const { type , attributes , innerHTML } = replacement ;
2024-04-17 11:32:24 +02:00
const formatType = get _format _type _getFormatType ( type ) ;
2025-12-12 13:15:55 +01:00
if ( isEditableTree && type === "#comment" ) {
2025-04-25 12:30:07 +02:00
pointer = append ( getParent ( pointer ) , {
2025-12-12 13:15:55 +01:00
type : "span" ,
2025-04-25 12:30:07 +02:00
attributes : {
2025-12-12 13:15:55 +01:00
contenteditable : "false" ,
"data-rich-text-comment" : attributes [ "data-rich-text-comment" ]
2025-04-25 12:30:07 +02:00
}
} ) ;
2025-12-12 13:15:55 +01:00
append (
append ( pointer , { type : "span" } ) ,
attributes [ "data-rich-text-comment" ] . trim ( )
) ;
} else if ( ! isEditableTree && type === "script" ) {
pointer = append (
getParent ( pointer ) ,
fromFormat ( {
type : "script" ,
isEditableTree
} )
) ;
2024-04-17 11:32:24 +02:00
append ( pointer , {
2025-12-12 13:15:55 +01:00
html : decodeURIComponent (
attributes [ "data-rich-text-script" ]
)
2024-04-17 11:32:24 +02:00
} ) ;
} else if ( formatType ? . contentEditable === false ) {
2025-12-12 13:15:55 +01:00
if ( innerHTML || isEditableTree ) {
pointer = getParent ( pointer ) ;
if ( isEditableTree ) {
const attrs = {
contenteditable : "false" ,
"data-rich-text-bogus" : true
} ;
if ( start === i && end === i + 1 ) {
attrs [ "data-rich-text-format-boundary" ] = true ;
}
pointer = append ( pointer , {
type : "span" ,
attributes : attrs
} ) ;
if ( isEditableTree && i + 1 === text . length ) {
append ( getParent ( pointer ) , ZWNBSP ) ;
}
}
pointer = append (
pointer ,
fromFormat ( {
... replacement ,
isEditableTree
} )
) ;
if ( innerHTML ) {
append ( pointer , {
html : innerHTML
} ) ;
}
2024-04-17 11:32:24 +02:00
}
} else {
2025-12-12 13:15:55 +01:00
pointer = append (
getParent ( pointer ) ,
fromFormat ( {
... replacement ,
object : true ,
isEditableTree
} )
) ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
pointer = append ( getParent ( pointer ) , "" ) ;
} else if ( ! preserveWhiteSpace && character === "\n" ) {
2024-04-17 11:32:24 +02:00
pointer = append ( getParent ( pointer ) , {
2025-12-12 13:15:55 +01:00
type : "br" ,
2024-04-17 11:32:24 +02:00
attributes : isEditableTree ? {
2025-12-12 13:15:55 +01:00
"data-rich-text-line-break" : "true"
} : void 0 ,
2024-04-17 11:32:24 +02:00
object : true
} ) ;
2025-12-12 13:15:55 +01:00
pointer = append ( getParent ( pointer ) , "" ) ;
2024-04-17 11:32:24 +02:00
} else if ( ! isText ( pointer ) ) {
pointer = append ( getParent ( pointer ) , character ) ;
} else {
appendText ( pointer , character ) ;
}
if ( onStartIndex && start === i + 1 ) {
onStartIndex ( tree , pointer ) ;
}
if ( onEndIndex && end === i + 1 ) {
onEndIndex ( tree , pointer ) ;
}
if ( shouldInsertPadding && i === text . length ) {
append ( getParent ( pointer ) , ZWNBSP ) ;
if ( placeholder && text . length === 0 ) {
append ( getParent ( pointer ) , {
2025-12-12 13:15:55 +01:00
type : "span" ,
2024-04-17 11:32:24 +02:00
attributes : {
2025-12-12 13:15:55 +01:00
"data-rich-text-placeholder" : placeholder ,
2024-04-17 11:32:24 +02:00
// Necessary to prevent the placeholder from catching
// selection and being editable.
2025-12-12 13:15:55 +01:00
style : "pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;"
2024-04-17 11:32:24 +02:00
}
} ) ;
}
}
lastCharacterFormats = characterFormats ;
lastCharacter = character ;
}
return tree ;
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/to-html-string.js
2024-04-17 11:32:24 +02:00
2025-12-12 13:15:55 +01:00
function toHTMLString ( { value , preserveWhiteSpace } ) {
2024-04-17 11:32:24 +02:00
const tree = toTree ( {
value ,
preserveWhiteSpace ,
createEmpty ,
append ,
getLastChild ,
getParent ,
isText ,
getText ,
remove ,
appendText
} ) ;
return createChildrenHTML ( tree . children ) ;
}
function createEmpty ( ) {
return { } ;
}
2025-12-12 13:15:55 +01:00
function getLastChild ( { children } ) {
2024-04-17 11:32:24 +02:00
return children && children [ children . length - 1 ] ;
}
function append ( parent , object ) {
2025-12-12 13:15:55 +01:00
if ( typeof object === "string" ) {
object = { text : object } ;
2024-04-17 11:32:24 +02:00
}
object . parent = parent ;
parent . children = parent . children || [ ] ;
parent . children . push ( object ) ;
return object ;
}
function appendText ( object , text ) {
object . text += text ;
}
2025-12-12 13:15:55 +01:00
function getParent ( { parent } ) {
2024-04-17 11:32:24 +02:00
return parent ;
}
2025-12-12 13:15:55 +01:00
function isText ( { text } ) {
return typeof text === "string" ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
function getText ( { text } ) {
2024-04-17 11:32:24 +02:00
return text ;
}
function remove ( object ) {
const index = object . parent . children . indexOf ( object ) ;
if ( index !== - 1 ) {
object . parent . children . splice ( index , 1 ) ;
}
return object ;
}
2025-12-12 13:15:55 +01:00
function createElementHTML ( { type , attributes , object , children } ) {
if ( type === "#comment" ) {
return ` <!-- ${ attributes [ "data-rich-text-comment" ] } --> ` ;
}
let attributeString = "" ;
2024-04-17 11:32:24 +02:00
for ( const key in attributes ) {
if ( ! ( 0 , external _wp _escapeHtml _namespaceObject . isValidAttributeName ) ( key ) ) {
continue ;
}
2025-12-12 13:15:55 +01:00
attributeString += ` ${ key } =" ${ ( 0 , external _wp _escapeHtml _namespaceObject . escapeAttribute ) (
attributes [ key ]
) } " ` ;
2024-04-17 11:32:24 +02:00
}
if ( object ) {
return ` < ${ type } ${ attributeString } > ` ;
}
2025-12-12 13:15:55 +01:00
return ` < ${ type } ${ attributeString } > ${ createChildrenHTML (
children
) } < / $ { t y p e } > ` ;
2024-04-17 11:32:24 +02:00
}
function createChildrenHTML ( children = [ ] ) {
2025-12-12 13:15:55 +01:00
return children . map ( ( child ) => {
if ( child . html !== void 0 ) {
2024-04-17 11:32:24 +02:00
return child . html ;
}
2025-12-12 13:15:55 +01:00
return child . text === void 0 ? createElementHTML ( child ) : ( 0 , external _wp _escapeHtml _namespaceObject . escapeEditableHTML ) ( child . text ) ;
} ) . join ( "" ) ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/get-text-content.js
2024-04-17 11:32:24 +02:00
2025-12-12 13:15:55 +01:00
function getTextContent ( { text } ) {
return text . replace ( OBJECT _REPLACEMENT _CHARACTER , "" ) ;
}
2024-04-17 11:32:24 +02:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/create.js
2024-04-17 11:32:24 +02:00
function createEmptyValue ( ) {
return {
formats : [ ] ,
replacements : [ ] ,
2025-12-12 13:15:55 +01:00
text : ""
2024-04-17 11:32:24 +02:00
} ;
}
2025-12-12 13:15:55 +01:00
function toFormat ( { tagName , attributes } ) {
2024-04-17 11:32:24 +02:00
let formatType ;
if ( attributes && attributes . class ) {
2025-12-12 13:15:55 +01:00
formatType = ( 0 , external _wp _data _namespaceObject . select ) ( store ) . getFormatTypeForClassName (
attributes . class
) ;
2024-04-17 11:32:24 +02:00
if ( formatType ) {
2025-12-12 13:15:55 +01:00
attributes . class = ` ${ attributes . class } ` . replace ( ` ${ formatType . className } ` , " " ) . trim ( ) ;
2024-04-17 11:32:24 +02:00
if ( ! attributes . class ) {
delete attributes . class ;
}
}
}
if ( ! formatType ) {
formatType = ( 0 , external _wp _data _namespaceObject . select ) ( store ) . getFormatTypeForBareElement ( tagName ) ;
}
if ( ! formatType ) {
2025-12-12 13:15:55 +01:00
return attributes ? { type : tagName , attributes } : { type : tagName } ;
2024-04-17 11:32:24 +02:00
}
if ( formatType . _ _experimentalCreatePrepareEditableTree && ! formatType . _ _experimentalCreateOnChangeEditableValue ) {
return null ;
}
if ( ! attributes ) {
2025-12-12 13:15:55 +01:00
return { formatType , type : formatType . name , tagName } ;
2024-04-17 11:32:24 +02:00
}
const registeredAttributes = { } ;
const unregisteredAttributes = { } ;
2025-12-12 13:15:55 +01:00
const _attributes = { ... attributes } ;
2024-04-17 11:32:24 +02:00
for ( const key in formatType . attributes ) {
const name = formatType . attributes [ key ] ;
registeredAttributes [ key ] = _attributes [ name ] ;
delete _attributes [ name ] ;
2025-12-12 13:15:55 +01:00
if ( typeof registeredAttributes [ key ] === "undefined" ) {
2024-04-17 11:32:24 +02:00
delete registeredAttributes [ key ] ;
}
}
for ( const name in _attributes ) {
unregisteredAttributes [ name ] = attributes [ name ] ;
}
if ( formatType . contentEditable === false ) {
delete unregisteredAttributes . contenteditable ;
}
return {
formatType ,
type : formatType . name ,
tagName ,
attributes : registeredAttributes ,
unregisteredAttributes
} ;
}
class RichTextData {
# value ;
static empty ( ) {
return new RichTextData ( ) ;
}
static fromPlainText ( text ) {
2025-12-12 13:15:55 +01:00
return new RichTextData ( create ( { text } ) ) ;
2024-04-17 11:32:24 +02:00
}
static fromHTMLString ( html ) {
2025-12-12 13:15:55 +01:00
return new RichTextData ( create ( { html } ) ) ;
2024-04-17 11:32:24 +02:00
}
2025-04-25 12:30:07 +02:00
/ * *
* Create a RichTextData instance from an HTML element .
*
* @ param { HTMLElement } htmlElement The HTML element to create the instance from .
* @ param { { preserveWhiteSpace ? : boolean } } options Options .
* @ return { RichTextData } The RichTextData instance .
* /
2024-04-17 11:32:24 +02:00
static fromHTMLElement ( htmlElement , options = { } ) {
2025-12-12 13:15:55 +01:00
const { preserveWhiteSpace = false } = options ;
2024-04-17 11:32:24 +02:00
const element = preserveWhiteSpace ? htmlElement : collapseWhiteSpace ( htmlElement ) ;
2025-12-12 13:15:55 +01:00
const richTextData = new RichTextData ( create ( { element } ) ) ;
Object . defineProperty ( richTextData , "originalHTML" , {
2024-04-17 11:32:24 +02:00
value : htmlElement . innerHTML
} ) ;
return richTextData ;
}
constructor ( init = createEmptyValue ( ) ) {
this . # value = init ;
}
toPlainText ( ) {
return getTextContent ( this . # value ) ;
}
// We could expose `toHTMLElement` at some point as well, but we'd only use
// it internally.
2025-04-25 12:30:07 +02:00
/ * *
* Convert the rich text value to an HTML string .
*
* @ param { { preserveWhiteSpace ? : boolean } } options Options .
* @ return { string } The HTML string .
* /
2025-12-12 13:15:55 +01:00
toHTMLString ( { preserveWhiteSpace } = { } ) {
return this . originalHTML || toHTMLString ( { value : this . # value , preserveWhiteSpace } ) ;
2024-04-17 11:32:24 +02:00
}
valueOf ( ) {
return this . toHTMLString ( ) ;
}
toString ( ) {
return this . toHTMLString ( ) ;
}
toJSON ( ) {
return this . toHTMLString ( ) ;
}
get length ( ) {
return this . text . length ;
}
get formats ( ) {
return this . # value . formats ;
}
get replacements ( ) {
return this . # value . replacements ;
}
get text ( ) {
return this . # value . text ;
}
}
for ( const name of Object . getOwnPropertyNames ( String . prototype ) ) {
if ( RichTextData . prototype . hasOwnProperty ( name ) ) {
continue ;
}
Object . defineProperty ( RichTextData . prototype , name , {
value ( ... args ) {
return this . toHTMLString ( ) [ name ] ( ... args ) ;
}
} ) ;
}
2023-09-26 10:33:34 +02:00
function create ( {
element ,
text ,
html ,
range ,
2024-04-17 11:32:24 +02:00
_ _unstableIsEditableTree : isEditableTree
2023-09-26 10:33:34 +02:00
} = { } ) {
2024-04-17 11:32:24 +02:00
if ( html instanceof RichTextData ) {
return {
text : html . text ,
formats : html . formats ,
replacements : html . replacements
} ;
}
2025-12-12 13:15:55 +01:00
if ( typeof text === "string" && text . length > 0 ) {
2019-11-15 22:59:44 +01:00
return {
formats : Array ( text . length ) ,
replacements : Array ( text . length ) ,
2021-07-23 11:58:50 +02:00
text
2019-11-15 22:59:44 +01:00
} ;
}
2025-12-12 13:15:55 +01:00
if ( typeof html === "string" && html . length > 0 ) {
2019-11-15 22:59:44 +01:00
element = createElement ( document , html ) ;
}
2025-12-12 13:15:55 +01:00
if ( typeof element !== "object" ) {
2019-11-15 22:59:44 +01:00
return createEmptyValue ( ) ;
}
2023-12-07 09:44:11 +01:00
return createFromElement ( {
2021-07-23 11:58:50 +02:00
element ,
range ,
2024-04-17 11:32:24 +02:00
isEditableTree
2019-11-15 22:59:44 +01:00
} ) ;
}
function accumulateSelection ( accumulator , node , range , value ) {
if ( ! range ) {
return ;
}
2025-12-12 13:15:55 +01:00
const { parentNode } = node ;
const { startContainer , startOffset , endContainer , endOffset } = range ;
2023-12-07 09:44:11 +01:00
const currentLength = accumulator . text . length ;
2025-12-12 13:15:55 +01:00
if ( value . start !== void 0 ) {
2023-12-07 09:44:11 +01:00
accumulator . start = currentLength + value . start ;
2020-09-15 14:29:22 +02:00
} else if ( node === startContainer && node . nodeType === node . TEXT _NODE ) {
2023-12-07 09:44:11 +01:00
accumulator . start = currentLength + startOffset ;
2019-11-15 22:59:44 +01:00
} else if ( parentNode === startContainer && node === startContainer . childNodes [ startOffset ] ) {
2023-12-07 09:44:11 +01:00
accumulator . start = currentLength ;
2019-11-15 22:59:44 +01:00
} else if ( parentNode === startContainer && node === startContainer . childNodes [ startOffset - 1 ] ) {
2023-12-07 09:44:11 +01:00
accumulator . start = currentLength + value . text . length ;
2019-11-15 22:59:44 +01:00
} else if ( node === startContainer ) {
accumulator . start = currentLength ;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
if ( value . end !== void 0 ) {
2023-12-07 09:44:11 +01:00
accumulator . end = currentLength + value . end ;
2020-09-15 14:29:22 +02:00
} else if ( node === endContainer && node . nodeType === node . TEXT _NODE ) {
2023-12-07 09:44:11 +01:00
accumulator . end = currentLength + endOffset ;
2019-11-15 22:59:44 +01:00
} else if ( parentNode === endContainer && node === endContainer . childNodes [ endOffset - 1 ] ) {
2023-12-07 09:44:11 +01:00
accumulator . end = currentLength + value . text . length ;
2019-11-15 22:59:44 +01:00
} else if ( parentNode === endContainer && node === endContainer . childNodes [ endOffset ] ) {
2023-12-07 09:44:11 +01:00
accumulator . end = currentLength ;
2019-11-15 22:59:44 +01:00
} else if ( node === endContainer ) {
accumulator . end = currentLength + endOffset ;
}
}
function filterRange ( node , range , filter ) {
if ( ! range ) {
return ;
}
2025-12-12 13:15:55 +01:00
const { startContainer , endContainer } = range ;
let { startOffset , endOffset } = range ;
2019-11-15 22:59:44 +01:00
if ( node === startContainer ) {
startOffset = filter ( node . nodeValue . slice ( 0 , startOffset ) ) . length ;
}
if ( node === endContainer ) {
endOffset = filter ( node . nodeValue . slice ( 0 , endOffset ) ) . length ;
}
2025-12-12 13:15:55 +01:00
return { startContainer , startOffset , endContainer , endOffset } ;
2019-11-15 22:59:44 +01:00
}
2024-04-17 11:32:24 +02:00
function collapseWhiteSpace ( element , isRoot = true ) {
const clone = element . cloneNode ( true ) ;
clone . normalize ( ) ;
Array . from ( clone . childNodes ) . forEach ( ( node , i , nodes ) => {
if ( node . nodeType === node . TEXT _NODE ) {
let newNodeValue = node . nodeValue ;
if ( /[\n\t\r\f]/ . test ( newNodeValue ) ) {
2025-12-12 13:15:55 +01:00
newNodeValue = newNodeValue . replace ( /[\n\t\r\f]+/g , " " ) ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
if ( newNodeValue . indexOf ( " " ) !== - 1 ) {
newNodeValue = newNodeValue . replace ( / {2,}/g , " " ) ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
if ( i === 0 && newNodeValue . startsWith ( " " ) ) {
2024-04-17 11:32:24 +02:00
newNodeValue = newNodeValue . slice ( 1 ) ;
2025-12-12 13:15:55 +01:00
} else if ( isRoot && i === nodes . length - 1 && newNodeValue . endsWith ( " " ) ) {
2024-04-17 11:32:24 +02:00
newNodeValue = newNodeValue . slice ( 0 , - 1 ) ;
}
node . nodeValue = newNodeValue ;
} else if ( node . nodeType === node . ELEMENT _NODE ) {
2025-12-12 13:15:55 +01:00
node . replaceWith ( collapseWhiteSpace ( node , false ) ) ;
2024-04-17 11:32:24 +02:00
}
} ) ;
return clone ;
2020-05-06 17:23:38 +02:00
}
2025-12-12 13:15:55 +01:00
const CARRIAGE _RETURN = "\r" ;
2022-04-02 10:26:41 +02:00
function removeReservedCharacters ( string ) {
2025-12-12 13:15:55 +01:00
return string . replace (
new RegExp (
` [ ${ ZWNBSP } ${ OBJECT _REPLACEMENT _CHARACTER } ${ CARRIAGE _RETURN } ] ` ,
"gu"
) ,
""
) ;
}
function createFromElement ( { element , range , isEditableTree } ) {
2021-07-23 11:58:50 +02:00
const accumulator = createEmptyValue ( ) ;
2019-11-15 22:59:44 +01:00
if ( ! element ) {
return accumulator ;
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
if ( ! element . hasChildNodes ( ) ) {
accumulateSelection ( accumulator , element , range , createEmptyValue ( ) ) ;
return accumulator ;
}
2023-12-07 09:44:11 +01:00
const length = element . childNodes . length ;
2021-07-23 11:58:50 +02:00
for ( let index = 0 ; index < length ; index ++ ) {
const node = element . childNodes [ index ] ;
2023-04-26 17:39:43 +02:00
const tagName = node . nodeName . toLowerCase ( ) ;
2020-09-15 14:29:22 +02:00
if ( node . nodeType === node . TEXT _NODE ) {
2024-04-17 11:32:24 +02:00
const text = removeReservedCharacters ( node . nodeValue ) ;
range = filterRange ( node , range , removeReservedCharacters ) ;
2025-12-12 13:15:55 +01:00
accumulateSelection ( accumulator , node , range , { text } ) ;
2019-11-15 22:59:44 +01:00
accumulator . formats . length += text . length ;
accumulator . replacements . length += text . length ;
accumulator . text += text ;
2021-07-23 11:58:50 +02:00
continue ;
2019-11-15 22:59:44 +01:00
}
2025-12-12 13:15:55 +01:00
if ( node . nodeType === node . COMMENT _NODE || node . nodeType === node . ELEMENT _NODE && node . tagName === "SPAN" && node . hasAttribute ( "data-rich-text-comment" ) ) {
const value2 = {
2025-04-25 12:30:07 +02:00
formats : [ , ] ,
2025-12-12 13:15:55 +01:00
replacements : [
{
type : "#comment" ,
attributes : {
"data-rich-text-comment" : node . nodeType === node . COMMENT _NODE ? node . nodeValue : node . getAttribute (
"data-rich-text-comment"
)
}
2025-04-25 12:30:07 +02:00
}
2025-12-12 13:15:55 +01:00
] ,
2025-04-25 12:30:07 +02:00
text : OBJECT _REPLACEMENT _CHARACTER
} ;
2025-12-12 13:15:55 +01:00
accumulateSelection ( accumulator , node , range , value2 ) ;
mergePair ( accumulator , value2 ) ;
2025-04-25 12:30:07 +02:00
continue ;
}
2020-09-15 14:29:22 +02:00
if ( node . nodeType !== node . ELEMENT _NODE ) {
2021-07-23 11:58:50 +02:00
continue ;
2019-11-15 22:59:44 +01:00
}
2025-12-12 13:15:55 +01:00
if ( isEditableTree && // Ignore any line breaks that are not inserted by us.
tagName === "br" && ! node . getAttribute ( "data-rich-text-line-break" ) ) {
2019-11-15 22:59:44 +01:00
accumulateSelection ( accumulator , node , range , createEmptyValue ( ) ) ;
2021-07-23 11:58:50 +02:00
continue ;
}
2025-12-12 13:15:55 +01:00
if ( tagName === "script" ) {
const value2 = {
2021-07-23 11:58:50 +02:00
formats : [ , ] ,
2025-12-12 13:15:55 +01:00
replacements : [
{
type : tagName ,
attributes : {
"data-rich-text-script" : node . getAttribute ( "data-rich-text-script" ) || encodeURIComponent ( node . innerHTML )
}
2021-07-23 11:58:50 +02:00
}
2025-12-12 13:15:55 +01:00
] ,
2021-07-23 11:58:50 +02:00
text : OBJECT _REPLACEMENT _CHARACTER
} ;
2025-12-12 13:15:55 +01:00
accumulateSelection ( accumulator , node , range , value2 ) ;
mergePair ( accumulator , value2 ) ;
2021-07-23 11:58:50 +02:00
continue ;
2019-11-15 22:59:44 +01:00
}
2025-12-12 13:15:55 +01:00
if ( tagName === "br" ) {
2019-11-15 22:59:44 +01:00
accumulateSelection ( accumulator , node , range , createEmptyValue ( ) ) ;
2025-12-12 13:15:55 +01:00
mergePair ( accumulator , create ( { text : "\n" } ) ) ;
2021-07-23 11:58:50 +02:00
continue ;
2019-11-15 22:59:44 +01:00
}
2022-04-02 10:26:41 +02:00
const format = toFormat ( {
2023-04-26 17:39:43 +02:00
tagName ,
2025-12-12 13:15:55 +01:00
attributes : getAttributes ( { element : node } )
2023-12-07 09:44:11 +01:00
} ) ;
2023-09-26 10:33:34 +02:00
if ( format ? . formatType ? . contentEditable === false ) {
delete format . formatType ;
accumulateSelection ( accumulator , node , range , createEmptyValue ( ) ) ;
mergePair ( accumulator , {
formats : [ , ] ,
2025-12-12 13:15:55 +01:00
replacements : [
{
... format ,
innerHTML : node . innerHTML
}
] ,
2023-09-26 10:33:34 +02:00
text : OBJECT _REPLACEMENT _CHARACTER
} ) ;
continue ;
}
2025-02-28 08:42:11 +01:00
if ( format ) {
delete format . formatType ;
}
2021-07-23 11:58:50 +02:00
const value = createFromElement ( {
2019-11-15 22:59:44 +01:00
element : node ,
2021-07-23 11:58:50 +02:00
range ,
2024-04-17 11:32:24 +02:00
isEditableTree
2019-11-15 22:59:44 +01:00
} ) ;
accumulateSelection ( accumulator , node , range , value ) ;
2025-12-12 13:15:55 +01:00
if ( ! format || node . getAttribute ( "data-rich-text-placeholder" ) || node . getAttribute ( "data-rich-text-bogus" ) ) {
2019-11-15 22:59:44 +01:00
mergePair ( accumulator , value ) ;
} else if ( value . text . length === 0 ) {
if ( format . attributes ) {
mergePair ( accumulator , {
formats : [ , ] ,
replacements : [ format ] ,
text : OBJECT _REPLACEMENT _CHARACTER
} ) ;
}
} else {
2025-12-12 13:15:55 +01:00
let mergeFormats2 = function ( formats ) {
if ( mergeFormats2 . formats === formats ) {
return mergeFormats2 . newFormats ;
2020-05-06 17:23:38 +02:00
}
2021-07-23 11:58:50 +02:00
const newFormats = formats ? [ format , ... formats ] : [ format ] ;
2025-12-12 13:15:55 +01:00
mergeFormats2 . formats = formats ;
mergeFormats2 . newFormats = newFormats ;
2020-05-06 17:23:38 +02:00
return newFormats ;
2025-12-12 13:15:55 +01:00
} ;
var mergeFormats = mergeFormats2 ;
mergeFormats2 . newFormats = [ format ] ;
2023-12-07 09:44:11 +01:00
mergePair ( accumulator , {
... value ,
2025-12-12 13:15:55 +01:00
formats : Array . from ( value . formats , mergeFormats2 )
2021-07-23 11:58:50 +02:00
} ) ;
2019-11-15 22:59:44 +01:00
}
}
return accumulator ;
}
2025-12-12 13:15:55 +01:00
function getAttributes ( { element } ) {
2019-11-15 22:59:44 +01:00
if ( ! element . hasAttributes ( ) ) {
return ;
}
2021-07-23 11:58:50 +02:00
const length = element . attributes . length ;
2023-12-07 09:44:11 +01:00
let accumulator ;
2021-07-23 11:58:50 +02:00
for ( let i = 0 ; i < length ; i ++ ) {
2025-12-12 13:15:55 +01:00
const { name , value } = element . attributes [ i ] ;
if ( name . indexOf ( "data-rich-text-" ) === 0 ) {
2024-04-17 11:32:24 +02:00
continue ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
const safeName = /^on/i . test ( name ) ? "data-disable-rich-text-" + name : name ;
2024-04-17 11:32:24 +02:00
accumulator = accumulator || { } ;
accumulator [ safeName ] = value ;
2023-12-07 09:44:11 +01:00
}
2024-04-17 11:32:24 +02:00
return accumulator ;
}
2023-09-26 10:33:34 +02:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/concat.js
2023-09-26 10:33:34 +02:00
2024-04-17 11:32:24 +02:00
function mergePair ( a , b ) {
a . formats = a . formats . concat ( b . formats ) ;
a . replacements = a . replacements . concat ( b . replacements ) ;
a . text += b . text ;
return a ;
}
function concat ( ... values ) {
return normaliseFormats ( values . reduce ( mergePair , create ( ) ) ) ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/get-active-format.js
2025-12-12 13:15:55 +01:00
2019-11-15 22:59:44 +01:00
function getActiveFormat ( value , formatType ) {
2025-12-12 13:15:55 +01:00
return getActiveFormats ( value ) . find (
( { type } ) => type === formatType
) ;
2019-11-02 10:38:58 +01:00
}
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/get-active-object.js
2020-12-10 14:06:04 +01:00
2025-12-12 13:15:55 +01:00
function getActiveObject ( { start , end , replacements , text } ) {
2019-11-15 22:59:44 +01:00
if ( start + 1 !== end || text [ start ] !== OBJECT _REPLACEMENT _CHARACTER ) {
return ;
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
return replacements [ start ] ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/is-collapsed.js
2023-09-26 10:33:34 +02:00
function isCollapsed ( {
start ,
end
} ) {
2025-12-12 13:15:55 +01:00
if ( start === void 0 || end === void 0 ) {
2019-11-15 22:59:44 +01:00
return ;
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
return start === end ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/is-empty.js
2025-12-12 13:15:55 +01:00
function isEmpty ( { text } ) {
2019-11-15 22:59:44 +01:00
return text . length === 0 ;
}
2019-11-02 10:38:58 +01:00
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/join.js
2023-12-07 09:44:11 +01:00
2020-12-10 14:06:04 +01:00
2025-12-12 13:15:55 +01:00
function join ( values , separator = "" ) {
if ( typeof separator === "string" ) {
separator = create ( { text : separator } ) ;
2019-11-15 22:59:44 +01:00
}
2025-12-12 13:15:55 +01:00
return normaliseFormats (
values . reduce ( ( accumulator , { formats , replacements , text } ) => ( {
formats : accumulator . formats . concat ( separator . formats , formats ) ,
replacements : accumulator . replacements . concat (
separator . replacements ,
replacements
) ,
text : accumulator . text + separator . text + text
} ) )
) ;
2019-11-15 22:59:44 +01:00
}
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/register-format-type.js
2025-12-12 13:15:55 +01:00
2019-11-15 22:59:44 +01:00
function registerFormatType ( name , settings ) {
2021-07-23 11:58:50 +02:00
settings = {
name ,
... settings
} ;
2025-12-12 13:15:55 +01:00
if ( typeof settings . name !== "string" ) {
window . console . error ( "Format names must be strings." ) ;
2019-11-02 10:38:58 +01:00
return ;
}
2019-11-15 22:59:44 +01:00
if ( ! /^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/ . test ( settings . name ) ) {
2025-12-12 13:15:55 +01:00
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"
) ;
2019-11-15 22:59:44 +01:00
return ;
}
2022-06-16 14:03:35 +02:00
if ( ( 0 , external _wp _data _namespaceObject . select ) ( store ) . getFormatType ( settings . name ) ) {
2025-12-12 13:15:55 +01:00
window . console . error (
'Format "' + settings . name + '" is already registered.'
) ;
2019-11-15 22:59:44 +01:00
return ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
if ( typeof settings . tagName !== "string" || settings . tagName === "" ) {
window . console . error ( "Format tag names must be a string." ) ;
2019-11-15 22:59:44 +01:00
return ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
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."
) ;
2019-11-15 22:59:44 +01:00
return ;
}
2024-04-17 11:32:24 +02:00
if ( ! /^[_a-zA-Z]+[a-zA-Z0-9_-]*$/ . test ( settings . className ) ) {
2025-12-12 13:15:55 +01:00
window . console . error (
"A class name must begin with a letter, followed by any number of hyphens, underscores, letters, or numbers."
) ;
2019-11-15 22:59:44 +01:00
return ;
}
if ( settings . className === null ) {
2025-12-12 13:15:55 +01:00
const formatTypeForBareElement = ( 0 , external _wp _data _namespaceObject . select ) (
store
) . getFormatTypeForBareElement ( settings . tagName ) ;
if ( formatTypeForBareElement && formatTypeForBareElement . name !== "core/unknown" ) {
window . console . error (
` Format " ${ formatTypeForBareElement . name } " is already registered to handle bare tag name " ${ settings . tagName } ". `
) ;
2019-11-15 22:59:44 +01:00
return ;
}
} else {
2025-12-12 13:15:55 +01:00
const formatTypeForClassName = ( 0 , external _wp _data _namespaceObject . select ) (
store
) . getFormatTypeForClassName ( settings . className ) ;
2019-11-15 22:59:44 +01:00
if ( formatTypeForClassName ) {
2025-12-12 13:15:55 +01:00
window . console . error (
` Format " ${ formatTypeForClassName . name } " is already registered to handle class name " ${ settings . className } ". `
) ;
2019-11-15 22:59:44 +01:00
return ;
}
2020-05-06 17:23:38 +02:00
}
2025-12-12 13:15:55 +01:00
if ( ! ( "title" in settings ) || settings . title === "" ) {
window . console . error (
'The format "' + settings . name + '" must have a title.'
) ;
2020-05-06 17:23:38 +02:00
return ;
}
2025-12-12 13:15:55 +01:00
if ( "keywords" in settings && settings . keywords . length > 3 ) {
window . console . error (
'The format "' + settings . name + '" can have a maximum of 3 keywords.'
) ;
2020-05-06 17:23:38 +02:00
return ;
}
2025-12-12 13:15:55 +01:00
if ( typeof settings . title !== "string" ) {
window . console . error ( "Format titles must be strings." ) ;
2020-05-06 17:23:38 +02:00
return ;
2019-11-02 10:38:58 +01:00
}
2022-06-16 14:03:35 +02:00
( 0 , external _wp _data _namespaceObject . dispatch ) ( store ) . addFormatTypes ( settings ) ;
2019-11-15 22:59:44 +01:00
return settings ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/remove-format.js
2025-12-12 13:15:55 +01:00
2023-09-26 10:33:34 +02:00
function removeFormat ( value , formatType , startIndex = value . start , endIndex = value . end ) {
2025-12-12 13:15:55 +01:00
const { formats , activeFormats } = value ;
2023-12-07 09:44:11 +01:00
const newFormats = formats . slice ( ) ;
2019-11-15 22:59:44 +01:00
if ( startIndex === endIndex ) {
2025-12-12 13:15:55 +01:00
const format = newFormats [ startIndex ] ? . find (
( { type } ) => type === formatType
) ;
2019-11-15 22:59:44 +01:00
if ( format ) {
2025-12-12 13:15:55 +01:00
while ( newFormats [ startIndex ] ? . find (
( newFormat ) => newFormat === format
) ) {
2019-11-15 22:59:44 +01:00
filterFormats ( newFormats , startIndex , formatType ) ;
startIndex -- ;
}
endIndex ++ ;
2025-12-12 13:15:55 +01:00
while ( newFormats [ endIndex ] ? . find (
( newFormat ) => newFormat === format
) ) {
2019-11-15 22:59:44 +01:00
filterFormats ( newFormats , endIndex , formatType ) ;
endIndex ++ ;
}
}
} else {
2021-07-23 11:58:50 +02:00
for ( let i = startIndex ; i < endIndex ; i ++ ) {
2019-11-15 22:59:44 +01:00
if ( newFormats [ i ] ) {
filterFormats ( newFormats , i , formatType ) ;
}
2019-11-02 10:38:58 +01:00
}
}
2023-12-07 09:44:11 +01:00
return normaliseFormats ( {
... value ,
2019-11-15 22:59:44 +01:00
formats : newFormats ,
2025-12-12 13:15:55 +01:00
activeFormats : activeFormats ? . filter ( ( { type } ) => type !== formatType ) || [ ]
2021-07-23 11:58:50 +02:00
} ) ;
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
function filterFormats ( formats , index , formatType ) {
2025-12-12 13:15:55 +01:00
const newFormats = formats [ index ] . filter (
( { type } ) => type !== formatType
) ;
2019-11-15 22:59:44 +01:00
if ( newFormats . length ) {
formats [ index ] = newFormats ;
} else {
delete formats [ index ] ;
}
}
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/insert.js
2023-12-07 09:44:11 +01:00
2020-12-10 14:06:04 +01:00
2023-09-26 10:33:34 +02:00
function insert ( value , valueToInsert , startIndex = value . start , endIndex = value . end ) {
2025-12-12 13:15:55 +01:00
const { formats , replacements , text } = value ;
if ( typeof valueToInsert === "string" ) {
valueToInsert = create ( { text : valueToInsert } ) ;
2019-11-15 22:59:44 +01:00
}
2021-07-23 11:58:50 +02:00
const index = startIndex + valueToInsert . text . length ;
2019-11-15 22:59:44 +01:00
return normaliseFormats ( {
formats : formats . slice ( 0 , startIndex ) . concat ( valueToInsert . formats , formats . slice ( endIndex ) ) ,
2025-12-12 13:15:55 +01:00
replacements : replacements . slice ( 0 , startIndex ) . concat (
valueToInsert . replacements ,
replacements . slice ( endIndex )
) ,
2019-11-15 22:59:44 +01:00
text : text . slice ( 0 , startIndex ) + valueToInsert . text + text . slice ( endIndex ) ,
start : index ,
end : index
} ) ;
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/remove.js
2023-12-07 09:44:11 +01:00
2020-12-10 14:06:04 +01:00
2024-04-17 11:32:24 +02:00
function remove _remove ( value , startIndex , endIndex ) {
2019-11-15 22:59:44 +01:00
return insert ( value , create ( ) , startIndex , endIndex ) ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/replace.js
2025-12-12 13:15:55 +01:00
function replace _replace ( { formats , replacements , text , start , end } , pattern , replacement ) {
2023-09-26 10:33:34 +02:00
text = text . replace ( pattern , ( match , ... rest ) => {
2021-07-23 11:58:50 +02:00
const offset = rest [ rest . length - 2 ] ;
let newText = replacement ;
let newFormats ;
let newReplacements ;
2025-12-12 13:15:55 +01:00
if ( typeof newText === "function" ) {
2021-07-23 11:58:50 +02:00
newText = replacement ( match , ... rest ) ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
if ( typeof newText === "object" ) {
2019-11-15 22:59:44 +01:00
newFormats = newText . formats ;
newReplacements = newText . replacements ;
newText = newText . text ;
} else {
newFormats = Array ( newText . length ) ;
newReplacements = Array ( newText . length ) ;
if ( formats [ offset ] ) {
newFormats = newFormats . fill ( formats [ offset ] ) ;
}
}
formats = formats . slice ( 0 , offset ) . concat ( newFormats , formats . slice ( offset + match . length ) ) ;
2025-12-12 13:15:55 +01:00
replacements = replacements . slice ( 0 , offset ) . concat (
newReplacements ,
replacements . slice ( offset + match . length )
) ;
2019-11-15 22:59:44 +01:00
if ( start ) {
start = end = offset + newText . length ;
}
return newText ;
} ) ;
2025-12-12 13:15:55 +01:00
return normaliseFormats ( { formats , replacements , text , start , end } ) ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/insert-object.js
2020-12-10 14:06:04 +01:00
2019-11-15 22:59:44 +01:00
function insertObject ( value , formatToInsert , startIndex , endIndex ) {
2024-04-17 11:32:24 +02:00
const valueToInsert = {
formats : [ , ] ,
replacements : [ formatToInsert ] ,
text : OBJECT _REPLACEMENT _CHARACTER
} ;
return insert ( value , valueToInsert , startIndex , endIndex ) ;
2021-07-23 11:58:50 +02:00
}
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/slice.js
2024-04-17 11:32:24 +02:00
function slice ( value , startIndex = value . start , endIndex = value . end ) {
2025-12-12 13:15:55 +01:00
const { formats , replacements , text } = value ;
if ( startIndex === void 0 || endIndex === void 0 ) {
return { ... value } ;
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
return {
2024-04-17 11:32:24 +02:00
formats : formats . slice ( startIndex , endIndex ) ,
replacements : replacements . slice ( startIndex , endIndex ) ,
text : text . slice ( startIndex , endIndex )
2019-11-15 22:59:44 +01:00
} ;
}
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/split.js
2025-12-12 13:15:55 +01:00
function split ( { formats , replacements , text , start , end } , string ) {
if ( typeof string !== "string" ) {
2024-04-17 11:32:24 +02:00
return splitAtSelection ( ... arguments ) ;
}
let nextStart = 0 ;
2025-12-12 13:15:55 +01:00
return text . split ( string ) . map ( ( substring ) => {
2024-04-17 11:32:24 +02:00
const startIndex = nextStart ;
const value = {
formats : formats . slice ( startIndex , startIndex + substring . length ) ,
2025-12-12 13:15:55 +01:00
replacements : replacements . slice (
startIndex ,
startIndex + substring . length
) ,
2024-04-17 11:32:24 +02:00
text : substring
} ;
nextStart += string . length + substring . length ;
2025-12-12 13:15:55 +01:00
if ( start !== void 0 && end !== void 0 ) {
2024-04-17 11:32:24 +02:00
if ( start >= startIndex && start < nextStart ) {
value . start = start - startIndex ;
} else if ( start < startIndex && end > startIndex ) {
value . start = 0 ;
2023-12-07 09:44:11 +01:00
}
2024-04-17 11:32:24 +02:00
if ( end >= startIndex && end < nextStart ) {
value . end = end - startIndex ;
} else if ( start < nextStart && end > nextStart ) {
value . end = substring . length ;
2019-11-02 10:38:58 +01:00
}
}
2024-04-17 11:32:24 +02:00
return value ;
} ) ;
}
2025-12-12 13:15:55 +01:00
function splitAtSelection ( { formats , replacements , text , start , end } , startIndex = start , endIndex = end ) {
if ( start === void 0 || end === void 0 ) {
2024-04-17 11:32:24 +02:00
return ;
2019-11-02 10:38:58 +01:00
}
2024-04-17 11:32:24 +02:00
const before = {
formats : formats . slice ( 0 , startIndex ) ,
replacements : replacements . slice ( 0 , startIndex ) ,
text : text . slice ( 0 , startIndex )
} ;
const after = {
formats : formats . slice ( endIndex ) ,
replacements : replacements . slice ( endIndex ) ,
text : text . slice ( endIndex ) ,
start : 0 ,
end : 0
} ;
return [ before , after ] ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/is-range-equal.js
2023-09-26 10:33:34 +02:00
function isRangeEqual ( a , b ) {
return a === b || a && b && a . startContainer === b . startContainer && a . startOffset === b . startOffset && a . endContainer === b . endContainer && a . endOffset === b . endOffset ;
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/to-dom.js
2023-12-07 09:44:11 +01:00
2020-12-10 14:06:04 +01:00
2025-12-12 13:15:55 +01:00
const MATHML _NAMESPACE = "http://www.w3.org/1998/Math/MathML" ;
2019-11-15 22:59:44 +01:00
function createPathToNode ( node , rootNode , path ) {
2021-07-23 11:58:50 +02:00
const parentNode = node . parentNode ;
let i = 0 ;
2019-11-15 22:59:44 +01:00
while ( node = node . previousSibling ) {
i ++ ;
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
path = [ i , ... path ] ;
2019-11-15 22:59:44 +01:00
if ( parentNode !== rootNode ) {
path = createPathToNode ( parentNode , rootNode , path ) ;
}
return path ;
}
function getNodeByPath ( node , path ) {
2021-07-23 11:58:50 +02:00
path = [ ... path ] ;
2019-11-15 22:59:44 +01:00
while ( node && path . length > 1 ) {
node = node . childNodes [ path . shift ( ) ] ;
}
return {
2021-07-23 11:58:50 +02:00
node ,
2019-11-15 22:59:44 +01:00
offset : path [ 0 ]
} ;
}
2024-04-17 11:32:24 +02:00
function to _dom _append ( element , child ) {
2025-12-12 13:15:55 +01:00
if ( child . html !== void 0 ) {
2023-09-26 10:33:34 +02:00
return element . innerHTML += child . html ;
}
2025-12-12 13:15:55 +01:00
if ( typeof child === "string" ) {
2019-11-15 22:59:44 +01:00
child = element . ownerDocument . createTextNode ( child ) ;
}
2025-12-12 13:15:55 +01:00
const { type , attributes } = child ;
2019-11-15 22:59:44 +01:00
if ( type ) {
2025-12-12 13:15:55 +01:00
if ( type === "#comment" ) {
child = element . ownerDocument . createComment (
attributes [ "data-rich-text-comment" ]
) ;
2025-04-25 12:30:07 +02:00
} else {
2025-12-12 13:15:55 +01:00
const parentNamespace = element . namespaceURI ;
if ( type === "math" ) {
child = element . ownerDocument . createElementNS (
MATHML _NAMESPACE ,
type
) ;
} else if ( parentNamespace === MATHML _NAMESPACE ) {
if ( element . tagName === "MTEXT" ) {
child = element . ownerDocument . createElement ( type ) ;
} else {
child = element . ownerDocument . createElementNS (
MATHML _NAMESPACE ,
type
) ;
}
} else {
child = element . ownerDocument . createElement ( type ) ;
}
2025-04-25 12:30:07 +02:00
for ( const key in attributes ) {
child . setAttribute ( key , attributes [ key ] ) ;
}
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
}
return element . appendChild ( child ) ;
}
2024-04-17 11:32:24 +02:00
function to _dom _appendText ( node , text ) {
2019-11-15 22:59:44 +01:00
node . appendData ( text ) ;
}
2025-12-12 13:15:55 +01:00
function to _dom _getLastChild ( { lastChild } ) {
2019-11-15 22:59:44 +01:00
return lastChild ;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
function to _dom _getParent ( { parentNode } ) {
2019-11-15 22:59:44 +01:00
return parentNode ;
}
2024-04-17 11:32:24 +02:00
function to _dom _isText ( node ) {
2020-09-15 14:29:22 +02:00
return node . nodeType === node . TEXT _NODE ;
2019-11-15 22:59:44 +01:00
}
2025-12-12 13:15:55 +01:00
function to _dom _getText ( { nodeValue } ) {
2019-11-15 22:59:44 +01:00
return nodeValue ;
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
function to _dom _remove ( node ) {
return node . parentNode . removeChild ( node ) ;
}
2023-09-26 10:33:34 +02:00
function toDom ( {
value ,
prepareEditableTree ,
isEditableTree = true ,
placeholder ,
doc = document
} ) {
2021-07-23 11:58:50 +02:00
let startPath = [ ] ;
let endPath = [ ] ;
2019-11-15 22:59:44 +01:00
if ( prepareEditableTree ) {
2023-12-07 09:44:11 +01:00
value = {
... value ,
2019-11-15 22:59:44 +01:00
formats : prepareEditableTree ( value )
2021-07-23 11:58:50 +02:00
} ;
2019-11-15 22:59:44 +01:00
}
2025-12-12 13:15:55 +01:00
const createEmpty = ( ) => createElement ( doc , "" ) ;
2021-07-23 11:58:50 +02:00
const tree = toTree ( {
value ,
createEmpty ,
2024-04-17 11:32:24 +02:00
append : to _dom _append ,
getLastChild : to _dom _getLastChild ,
getParent : to _dom _getParent ,
isText : to _dom _isText ,
getText : to _dom _getText ,
2019-11-15 22:59:44 +01:00
remove : to _dom _remove ,
2024-04-17 11:32:24 +02:00
appendText : to _dom _appendText ,
2021-07-23 11:58:50 +02:00
onStartIndex ( body , pointer ) {
2025-12-12 13:15:55 +01:00
startPath = createPathToNode ( pointer , body , [
pointer . nodeValue . length
] ) ;
2019-11-15 22:59:44 +01:00
} ,
2021-07-23 11:58:50 +02:00
onEndIndex ( body , pointer ) {
2025-12-12 13:15:55 +01:00
endPath = createPathToNode ( pointer , body , [
pointer . nodeValue . length
] ) ;
2019-11-15 22:59:44 +01:00
} ,
2021-07-23 11:58:50 +02:00
isEditableTree ,
placeholder
2019-11-15 22:59:44 +01:00
} ) ;
return {
body : tree ,
2025-12-12 13:15:55 +01:00
selection : { startPath , endPath }
2019-11-15 22:59:44 +01:00
} ;
}
2023-09-26 10:33:34 +02:00
function apply ( {
value ,
current ,
prepareEditableTree ,
_ _unstableDomOnly ,
placeholder
} ) {
2025-12-12 13:15:55 +01:00
const { body , selection } = toDom ( {
2021-07-23 11:58:50 +02:00
value ,
prepareEditableTree ,
placeholder ,
2020-09-15 14:29:22 +02:00
doc : current . ownerDocument
2021-07-23 11:58:50 +02:00
} ) ;
2019-11-15 22:59:44 +01:00
applyValue ( body , current ) ;
2025-12-12 13:15:55 +01:00
if ( value . start !== void 0 && ! _ _unstableDomOnly ) {
2019-11-15 22:59:44 +01:00
applySelection ( selection , current ) ;
}
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
function applyValue ( future , current ) {
2021-07-23 11:58:50 +02:00
let i = 0 ;
let futureChild ;
2019-11-15 22:59:44 +01:00
while ( futureChild = future . firstChild ) {
2021-07-23 11:58:50 +02:00
const currentChild = current . childNodes [ i ] ;
2019-11-15 22:59:44 +01:00
if ( ! currentChild ) {
current . appendChild ( futureChild ) ;
} else if ( ! currentChild . isEqualNode ( futureChild ) ) {
2020-09-15 14:29:22 +02:00
if ( currentChild . nodeName !== futureChild . nodeName || currentChild . nodeType === currentChild . TEXT _NODE && currentChild . data !== futureChild . data ) {
2019-11-15 22:59:44 +01:00
current . replaceChild ( futureChild , currentChild ) ;
} else {
2021-07-23 11:58:50 +02:00
const currentAttributes = currentChild . attributes ;
const futureAttributes = futureChild . attributes ;
2019-11-15 22:59:44 +01:00
if ( currentAttributes ) {
2023-12-07 09:44:11 +01:00
let ii = currentAttributes . length ;
2019-11-15 22:59:44 +01:00
while ( ii -- ) {
2025-12-12 13:15:55 +01:00
const { name } = currentAttributes [ ii ] ;
2019-11-15 22:59:44 +01:00
if ( ! futureChild . getAttribute ( name ) ) {
currentChild . removeAttribute ( name ) ;
}
}
}
if ( futureAttributes ) {
2021-07-23 11:58:50 +02:00
for ( let ii = 0 ; ii < futureAttributes . length ; ii ++ ) {
2025-12-12 13:15:55 +01:00
const { name , value } = futureAttributes [ ii ] ;
2021-07-23 11:58:50 +02:00
if ( currentChild . getAttribute ( name ) !== value ) {
currentChild . setAttribute ( name , value ) ;
2019-11-15 22:59:44 +01:00
}
}
}
applyValue ( futureChild , currentChild ) ;
future . removeChild ( futureChild ) ;
}
} else {
future . removeChild ( futureChild ) ;
}
i ++ ;
}
while ( current . childNodes [ i ] ) {
current . removeChild ( current . childNodes [ i ] ) ;
}
}
2025-12-12 13:15:55 +01:00
function applySelection ( { startPath , endPath } , current ) {
const { node : startContainer , offset : startOffset } = getNodeByPath (
current ,
startPath
) ;
const { node : endContainer , offset : endOffset } = getNodeByPath (
current ,
endPath
) ;
const { ownerDocument } = current ;
const { defaultView } = ownerDocument ;
2021-07-23 11:58:50 +02:00
const selection = defaultView . getSelection ( ) ;
const range = ownerDocument . createRange ( ) ;
2019-11-15 22:59:44 +01:00
range . setStart ( startContainer , startOffset ) ;
2020-05-06 17:23:38 +02:00
range . setEnd ( endContainer , endOffset ) ;
2025-12-12 13:15:55 +01:00
const { activeElement } = ownerDocument ;
2019-11-15 22:59:44 +01:00
if ( selection . rangeCount > 0 ) {
if ( isRangeEqual ( range , selection . getRangeAt ( 0 ) ) ) {
return ;
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
selection . removeAllRanges ( ) ;
}
2023-12-07 09:44:11 +01:00
selection . addRange ( range ) ;
2020-09-15 14:29:22 +02:00
if ( activeElement !== ownerDocument . activeElement ) {
if ( activeElement instanceof defaultView . HTMLElement ) {
2020-05-06 17:23:38 +02:00
activeElement . focus ( ) ;
}
}
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // external ["wp","a11y"]
2024-04-17 11:32:24 +02:00
const external _wp _a11y _namespaceObject = window [ "wp" ] [ "a11y" ] ;
2025-04-25 12:30:07 +02:00
; // external ["wp","i18n"]
2024-04-17 11:32:24 +02:00
const external _wp _i18n _namespaceObject = window [ "wp" ] [ "i18n" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/toggle-format.js
2019-11-15 22:59:44 +01:00
2022-04-02 10:26:41 +02:00
2020-12-10 14:06:04 +01:00
2019-11-15 22:59:44 +01:00
function toggleFormat ( value , format ) {
if ( getActiveFormat ( value , format . type ) ) {
2022-04-02 10:26:41 +02:00
if ( format . title ) {
2025-12-12 13:15:55 +01:00
( 0 , external _wp _a11y _namespaceObject . speak ) ( ( 0 , external _wp _i18n _namespaceObject . sprintf ) ( ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "%s removed." ) , format . title ) , "assertive" ) ;
2022-04-02 10:26:41 +02:00
}
2019-11-15 22:59:44 +01:00
return removeFormat ( value , format . type ) ;
2023-12-07 09:44:11 +01:00
}
2022-04-02 10:26:41 +02:00
if ( format . title ) {
2025-12-12 13:15:55 +01:00
( 0 , external _wp _a11y _namespaceObject . speak ) ( ( 0 , external _wp _i18n _namespaceObject . sprintf ) ( ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "%s applied." ) , format . title ) , "assertive" ) ;
2019-11-02 10:38:58 +01:00
}
2019-11-15 22:59:44 +01:00
return applyFormat ( value , format ) ;
}
2019-11-02 10:38:58 +01:00
2021-04-27 08:32:47 +02:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/unregister-format-type.js
2021-04-27 08:32:47 +02:00
2019-11-02 10:38:58 +01:00
2019-11-15 22:59:44 +01:00
function unregisterFormatType ( name ) {
2022-06-16 14:03:35 +02:00
const oldFormat = ( 0 , external _wp _data _namespaceObject . select ) ( store ) . getFormatType ( name ) ;
2019-11-15 22:59:44 +01:00
if ( ! oldFormat ) {
2021-07-23 11:58:50 +02:00
window . console . error ( ` Format ${ name } is not registered. ` ) ;
2019-11-15 22:59:44 +01:00
return ;
}
2022-06-16 14:03:35 +02:00
( 0 , external _wp _data _namespaceObject . dispatch ) ( store ) . removeFormatTypes ( name ) ;
2019-11-15 22:59:44 +01:00
return oldFormat ;
}
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // external ["wp","element"]
2024-04-17 11:32:24 +02:00
const external _wp _element _namespaceObject = window [ "wp" ] [ "element" ] ;
2025-04-25 12:30:07 +02:00
; // external ["wp","deprecated"]
2024-04-17 11:32:24 +02:00
const external _wp _deprecated _namespaceObject = window [ "wp" ] [ "deprecated" ] ;
2022-12-15 17:47:31 +01:00
var external _wp _deprecated _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _deprecated _namespaceObject ) ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/component/use-anchor-ref.js
2025-12-12 13:15:55 +01:00
function useAnchorRef ( { ref , value , settings = { } } ) {
external _wp _deprecated _default ( ) ( "`useAnchorRef` hook" , {
since : "6.1" ,
alternative : "`useAnchor` hook"
2022-12-15 17:47:31 +01:00
} ) ;
2025-12-12 13:15:55 +01:00
const { tagName , className , name } = settings ;
const activeFormat = name ? getActiveFormat ( value , name ) : void 0 ;
2022-12-15 17:47:31 +01:00
return ( 0 , external _wp _element _namespaceObject . useMemo ) ( ( ) => {
2025-02-28 08:42:11 +01:00
if ( ! ref . current ) {
return ;
}
2022-12-15 17:47:31 +01:00
const {
2025-12-12 13:15:55 +01:00
ownerDocument : { defaultView }
2022-12-15 17:47:31 +01:00
} = ref . current ;
const selection = defaultView . getSelection ( ) ;
if ( ! selection . rangeCount ) {
return ;
}
const range = selection . getRangeAt ( 0 ) ;
if ( ! activeFormat ) {
return range ;
}
2023-12-07 09:44:11 +01:00
let element = range . startContainer ;
2022-12-15 17:47:31 +01:00
element = element . nextElementSibling || element ;
while ( element . nodeType !== element . ELEMENT _NODE ) {
element = element . parentNode ;
}
2025-12-12 13:15:55 +01:00
return element . closest (
tagName + ( className ? "." + className : "" )
) ;
2022-12-15 17:47:31 +01:00
} , [ activeFormat , value . start , value . end , tagName , className ] ) ;
2020-05-06 17:23:38 +02:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // external ["wp","compose"]
2024-04-17 11:32:24 +02:00
const external _wp _compose _namespaceObject = window [ "wp" ] [ "compose" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/component/use-anchor.js
2025-12-12 13:15:55 +01:00
2023-09-26 10:33:34 +02:00
function getFormatElement ( range , editableContentElement , tagName , className ) {
2023-12-07 09:44:11 +01:00
let element = range . startContainer ;
if ( element . nodeType === element . TEXT _NODE && range . startOffset === element . length && element . nextSibling ) {
element = element . nextSibling ;
while ( element . firstChild ) {
element = element . firstChild ;
}
}
2023-09-26 10:33:34 +02:00
if ( element . nodeType !== element . ELEMENT _NODE ) {
element = element . parentElement ;
}
2025-02-28 08:42:11 +01:00
if ( ! element ) {
return ;
}
if ( element === editableContentElement ) {
return ;
}
if ( ! editableContentElement . contains ( element ) ) {
return ;
}
2025-12-12 13:15:55 +01:00
const selector = tagName + ( className ? "." + className : "" ) ;
2023-09-26 10:33:34 +02:00
while ( element !== editableContentElement ) {
if ( element . matches ( selector ) ) {
return element ;
}
element = element . parentElement ;
}
}
function createVirtualAnchorElement ( range , editableContentElement ) {
return {
2023-12-07 09:44:11 +01:00
contextElement : editableContentElement ,
2023-09-26 10:33:34 +02:00
getBoundingClientRect ( ) {
return editableContentElement . contains ( range . startContainer ) ? range . getBoundingClientRect ( ) : editableContentElement . getBoundingClientRect ( ) ;
}
} ;
}
function getAnchor ( editableContentElement , tagName , className ) {
2025-02-28 08:42:11 +01:00
if ( ! editableContentElement ) {
return ;
}
2025-12-12 13:15:55 +01:00
const { ownerDocument } = editableContentElement ;
const { defaultView } = ownerDocument ;
2023-09-26 10:33:34 +02:00
const selection = defaultView . getSelection ( ) ;
2025-02-28 08:42:11 +01:00
if ( ! selection ) {
return ;
}
if ( ! selection . rangeCount ) {
return ;
}
2023-09-26 10:33:34 +02:00
const range = selection . getRangeAt ( 0 ) ;
2025-02-28 08:42:11 +01:00
if ( ! range || ! range . startContainer ) {
return ;
}
2025-12-12 13:15:55 +01:00
const formatElement = getFormatElement (
range ,
editableContentElement ,
tagName ,
className
) ;
2025-02-28 08:42:11 +01:00
if ( formatElement ) {
return formatElement ;
}
2023-09-26 10:33:34 +02:00
return createVirtualAnchorElement ( range , editableContentElement ) ;
}
2025-12-12 13:15:55 +01:00
function useAnchor ( { editableContentElement , settings = { } } ) {
const { tagName , className , isActive } = settings ;
const [ anchor , setAnchor ] = ( 0 , external _wp _element _namespaceObject . useState ) (
( ) => getAnchor ( editableContentElement , tagName , className )
) ;
2024-04-17 11:32:24 +02:00
const wasActive = ( 0 , external _wp _compose _namespaceObject . usePrevious ) ( isActive ) ;
2023-09-26 10:33:34 +02:00
( 0 , external _wp _element _namespaceObject . useLayoutEffect ) ( ( ) => {
2025-02-28 08:42:11 +01:00
if ( ! editableContentElement ) {
return ;
}
2023-09-26 10:33:34 +02:00
function callback ( ) {
2025-12-12 13:15:55 +01:00
setAnchor (
getAnchor ( editableContentElement , tagName , className )
) ;
2021-04-27 08:32:47 +02:00
}
2023-09-26 10:33:34 +02:00
function attach ( ) {
2025-12-12 13:15:55 +01:00
ownerDocument . addEventListener ( "selectionchange" , callback ) ;
2021-04-27 08:32:47 +02:00
}
2023-09-26 10:33:34 +02:00
function detach ( ) {
2025-12-12 13:15:55 +01:00
ownerDocument . removeEventListener ( "selectionchange" , callback ) ;
2023-09-26 10:33:34 +02:00
}
2025-12-12 13:15:55 +01:00
const { ownerDocument } = editableContentElement ;
if ( editableContentElement === ownerDocument . activeElement || // When a link is created, we need to attach the popover to the newly created anchor.
! wasActive && isActive || // Sometimes we're _removing_ an active anchor, such as the inline color popover.
2024-04-17 11:32:24 +02:00
// When we add the color, it switches from a virtual anchor to a `<mark>` element.
// When we _remove_ the color, it switches from a `<mark>` element to a virtual anchor.
wasActive && ! isActive ) {
2025-12-12 13:15:55 +01:00
setAnchor (
getAnchor ( editableContentElement , tagName , className )
) ;
2023-09-26 10:33:34 +02:00
attach ( ) ;
2021-04-27 08:32:47 +02:00
}
2025-12-12 13:15:55 +01:00
editableContentElement . addEventListener ( "focusin" , attach ) ;
editableContentElement . addEventListener ( "focusout" , detach ) ;
2024-04-17 11:32:24 +02:00
return ( ) => {
detach ( ) ;
2025-12-12 13:15:55 +01:00
editableContentElement . removeEventListener ( "focusin" , attach ) ;
editableContentElement . removeEventListener ( "focusout" , detach ) ;
2024-04-17 11:32:24 +02:00
} ;
} , [ editableContentElement , tagName , className , isActive , wasActive ] ) ;
2023-09-26 10:33:34 +02:00
return anchor ;
2021-04-27 08:32:47 +02:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/component/use-default-style.js
2025-12-12 13:15:55 +01:00
const whiteSpace = "pre-wrap" ;
const minWidth = "1px" ;
2021-07-23 11:58:50 +02:00
function useDefaultStyle ( ) {
2025-12-12 13:15:55 +01:00
return ( 0 , external _wp _element _namespaceObject . useCallback ) ( ( element ) => {
2025-02-28 08:42:11 +01:00
if ( ! element ) {
return ;
}
2021-07-23 11:58:50 +02:00
element . style . whiteSpace = whiteSpace ;
element . style . minWidth = minWidth ;
} , [ ] ) ;
2020-05-06 17:23:38 +02:00
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/colord/index.mjs
var r = { grad : . 9 , turn : 360 , rad : 360 / ( 2 * Math . PI ) } , t = function ( r ) { return "string" == typeof r ? r . length > 0 : "number" == typeof r } , n = function ( r , t , n ) { return void 0 === t && ( t = 0 ) , void 0 === n && ( n = Math . pow ( 10 , t ) ) , Math . round ( n * r ) / n + 0 } , e = function ( r , t , n ) { return void 0 === t && ( t = 0 ) , void 0 === n && ( n = 1 ) , r > n ? n : r > t ? r : t } , u = function ( r ) { return ( r = isFinite ( r ) ? r % 360 : 0 ) > 0 ? r : r + 360 } , a = function ( r ) { return { r : e ( r . r , 0 , 255 ) , g : e ( r . g , 0 , 255 ) , b : e ( r . b , 0 , 255 ) , a : e ( r . a ) } } , o = function ( r ) { return { r : n ( r . r ) , g : n ( r . g ) , b : n ( r . b ) , a : n ( r . a , 3 ) } } , i = /^#([0-9a-f]{3,8})$/i , s = function ( r ) { var t = r . toString ( 16 ) ; return t . length < 2 ? "0" + t : t } , h = function ( r ) { var t = r . r , n = r . g , e = r . b , u = r . a , a = Math . max ( t , n , e ) , o = a - Math . min ( t , n , e ) , i = o ? a === t ? ( n - e ) / o : a === n ? 2 + ( e - t ) / o : 4 + ( t - n ) / o : 0 ; return { h : 60 * ( i < 0 ? i + 6 : i ) , s : a ? o / a * 100 : 0 , v : a / 255 * 100 , a : u } } , b = function ( r ) { var t = r . h , n = r . s , e = r . v , u = r . a ; t = t / 360 * 6 , n /= 100 , e /= 100 ; var a = Math . floor ( t ) , o = e * ( 1 - n ) , i = e * ( 1 - ( t - a ) * n ) , s = e * ( 1 - ( 1 - t + a ) * n ) , h = a % 6 ; return { r : 255 * [ e , i , o , o , s , e ] [ h ] , g : 255 * [ s , e , e , i , o , o ] [ h ] , b : 255 * [ o , o , s , e , e , i ] [ h ] , a : u } } , g = function ( r ) { return { h : u ( r . h ) , s : e ( r . s , 0 , 100 ) , l : e ( r . l , 0 , 100 ) , a : e ( r . a ) } } , d = function ( r ) { return { h : n ( r . h ) , s : n ( r . s ) , l : n ( r . l ) , a : n ( r . a , 3 ) } } , f = function ( r ) { return b ( ( n = ( t = r ) . s , { h : t . h , s : ( n *= ( ( e = t . l ) < 50 ? e : 100 - e ) / 100 ) > 0 ? 2 * n / ( e + n ) * 100 : 0 , v : e + n , a : t . a } ) ) ; var t , n , e } , c = function ( r ) { return { h : ( t = h ( r ) ) . h , s : ( u = ( 200 - ( n = t . s ) ) * ( e = t . v ) / 100 ) > 0 && u < 200 ? n * e / 100 / ( u <= 100 ? u : 200 - u ) * 100 : 0 , l : u / 2 , a : t . a } ; var t , n , e , u } , l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i , p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i , v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i , m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i , y = { string : [ [ function ( r ) { var t = i . exec ( r ) ; return t ? ( r = t [ 1 ] ) . length <= 4 ? { r : parseInt ( r [ 0 ] + r [ 0 ] , 16 ) , g : parseInt ( r [ 1 ] + r [ 1 ] , 16 ) , b : parseInt ( r [ 2 ] + r [ 2 ] , 16 ) , a : 4 === r . length ? n ( parseInt ( r [ 3 ] + r [ 3 ] , 16 ) / 255 , 2 ) : 1 } : 6 === r . length || 8 === r . length ? { r : parseInt ( r . substr ( 0 , 2 ) , 16 ) , g : parseInt ( r . substr ( 2 , 2 ) , 16 ) , b : parseInt ( r . substr ( 4 , 2 ) , 16 ) , a : 8 === r . length ? n ( parseInt ( r . substr ( 6 , 2 ) , 16 ) / 255 , 2 ) : 1 } : null : null } , "hex" ] , [ function ( r ) { var t = v . exec ( r ) || m . exec ( r ) ; return t ? t [ 2 ] !== t [ 4 ] || t [ 4 ] !== t [ 6 ] ? null : a ( { r : Number ( t [ 1 ] ) / ( t [ 2 ] ? 100 / 255 : 1 ) , g : Number ( t [ 3 ] ) / ( t [ 4 ] ? 100 / 255 : 1 ) , b : Number ( t [ 5 ] ) / ( t [ 6 ] ? 100 / 255 : 1 ) , a : void 0 === t [ 7 ] ? 1 : Number ( t [ 7 ] ) / ( t [ 8 ] ? 100 : 1 ) } ) : null } , "rgb" ] , [ function ( t ) { var n = l . exec ( t ) || p . exec ( t ) ; if ( ! n ) return null ; var e , u , a = g ( { h : ( e = n [ 1 ] , u = n [ 2 ] , void 0 === u && ( u = "deg" ) , Number ( e ) * ( r [ u ] || 1 ) ) , s : Number ( n [ 3 ] ) , l : Number ( n [ 4 ] ) , a : void 0 === n [ 5 ] ? 1 : Number ( n [ 5 ] ) / ( n [ 6 ] ? 100 : 1 ) } ) ; return f ( a ) } , "hsl" ] ] , object : [ [ function ( r ) { var n = r . r , e = r . g , u = r . b , o = r . a , i = void 0 === o ? 1 : o ; return t ( n ) && t ( e ) && t ( u ) ? a ( { r : Number ( n ) , g : Number ( e ) , b : Number ( u ) , a : Number ( i ) } ) : null } , "rgb" ] , [ function ( r ) { var n = r . h , e = r . s , u = r . l , a = r . a , o = void 0 === a ? 1 : a ; if ( ! t ( n ) || ! t ( e ) || ! t ( u ) ) return null ; var i = g ( { h : Number ( n ) , s : Number ( e ) , l : Number ( u ) , a : Number ( o ) } ) ; return f ( i ) } , "hsl" ] , [ function ( r ) { var n = r . h , a = r . s , o = r . v , i = r . a , s = void 0 === i ? 1 : i ; if ( ! t ( n ) || ! t ( a ) || ! t ( o ) ) return null ; var h = function ( r ) { return { h : u ( r . h ) , s : e ( r . s , 0 , 100 ) , v : e ( r . v , 0 , 100 ) , a : e ( r . a ) } } ( { h : Number ( n ) , s : Number ( a ) , v : Number ( o ) , a : Number ( s ) } ) ; return b ( h ) } , "hsv" ] ] } , N = function ( r , t ) { for ( var n = 0 ; n < t . length ; n ++ ) { var e = t [ n ] [ 0 ] ( r ) ; if ( e ) return [ e , t [ n ] [ 1 ] ] } return [ null , void 0 ] } , x = function ( r ) { return "string" == typeof r ? N ( r . trim ( ) , y . string ) : "object" == typeof r && null !== r ? N ( r , y . object ) : [ null , void 0 ] } , I = function ( r ) { return x ( r ) [ 1 ] } , M = function ( r , t ) { var n = c ( r ) ; return { h : n . h , s : e ( n . s + 100 * t , 0 , 100 ) , l : n . l , a : n . a } } , H = function ( r ) { return ( 299 * r . r + 587 * r . g + 114 * r . b ) / 1e3 / 255 } , $ = function ( r , t ) { var n = c ( r ) ; return { h : n . h , s : n . s , l : e ( n . l + 100 * t , 0 , 100 ) , a : n . a } } , j = function ( ) { function r ( r ) { this . parsed = x ( r ) [ 0 ] , this . rgba = this . parsed || { r : 0 , g : 0 , b : 0 , a : 1 } } return r . prototype . isValid = function ( ) { return null !== this . parsed } , r . prototype . brightness = function ( ) { return n ( H ( this . rgba ) , 2 ) } , r . prototype . isDark = function ( ) { return H ( this . rgba ) < . 5 } , r . prototype . isLight = function ( ) { return H ( this . rgba ) >= . 5 } , r . prototype . toHex = function ( ) { re
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/component/use-boundary-style.js
2019-11-15 22:59:44 +01:00
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
function useBoundaryStyle ( { record } ) {
2022-06-16 14:03:35 +02:00
const ref = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
2025-12-12 13:15:55 +01:00
const { activeFormats = [ ] , replacements , start } = record . current ;
2023-09-26 10:33:34 +02:00
const activeReplacement = replacements [ start ] ;
2022-06-16 14:03:35 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
2023-09-26 10:33:34 +02:00
if ( ( ! activeFormats || ! activeFormats . length ) && ! activeReplacement ) {
2020-05-06 17:23:38 +02:00
return ;
2019-11-15 22:59:44 +01:00
}
2025-12-12 13:15:55 +01:00
const boundarySelector = "*[data-rich-text-format-boundary]" ;
2021-07-23 11:58:50 +02:00
const element = ref . current . querySelector ( boundarySelector ) ;
2020-05-06 17:23:38 +02:00
if ( ! element ) {
return ;
2019-11-15 22:59:44 +01:00
}
2025-12-12 13:15:55 +01:00
const { ownerDocument } = element ;
const { defaultView } = ownerDocument ;
2021-07-23 11:58:50 +02:00
const computedStyle = defaultView . getComputedStyle ( element ) ;
2025-12-12 13:15:55 +01:00
const newColor = w ( computedStyle . color ) . alpha ( 0.2 ) . toRgbString ( ) ;
2021-07-23 11:58:50 +02:00
const selector = ` .rich-text:focus ${ boundarySelector } ` ;
const rule = ` background-color: ${ newColor } ` ;
const style = ` ${ selector } { ${ rule } } ` ;
2025-12-12 13:15:55 +01:00
const globalStyleId = "rich-text-boundary-style" ;
2021-07-23 11:58:50 +02:00
let globalStyle = ownerDocument . getElementById ( globalStyleId ) ;
2020-09-15 14:29:22 +02:00
if ( ! globalStyle ) {
2025-12-12 13:15:55 +01:00
globalStyle = ownerDocument . createElement ( "style" ) ;
2020-09-15 14:29:22 +02:00
globalStyle . id = globalStyleId ;
ownerDocument . head . appendChild ( globalStyle ) ;
}
2020-05-06 17:23:38 +02:00
if ( globalStyle . innerHTML !== style ) {
globalStyle . innerHTML = style ;
}
2023-09-26 10:33:34 +02:00
} , [ activeFormats , activeReplacement ] ) ;
2021-07-23 11:58:50 +02:00
return ref ;
2020-05-06 17:23:38 +02:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/copy-handler.js
2019-11-15 22:59:44 +01:00
2019-11-02 10:38:58 +01:00
2023-12-07 09:44:11 +01:00
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
var copy _handler _default = ( props ) => ( element ) => {
2025-02-28 08:42:11 +01:00
function onCopy ( event ) {
2025-12-12 13:15:55 +01:00
const { record } = props . current ;
const { ownerDocument } = element ;
2025-02-28 08:42:11 +01:00
if ( isCollapsed ( record . current ) || ! element . contains ( ownerDocument . activeElement ) ) {
return ;
}
const selectedRecord = slice ( record . current ) ;
const plainText = getTextContent ( selectedRecord ) ;
2025-12-12 13:15:55 +01:00
const html = toHTMLString ( { value : selectedRecord } ) ;
event . clipboardData . setData ( "text/plain" , plainText ) ;
event . clipboardData . setData ( "text/html" , html ) ;
event . clipboardData . setData ( "rich-text" , "true" ) ;
2025-02-28 08:42:11 +01:00
event . preventDefault ( ) ;
2025-12-12 13:15:55 +01:00
if ( event . type === "cut" ) {
ownerDocument . execCommand ( "delete" ) ;
2025-02-28 08:42:11 +01:00
}
}
2025-12-12 13:15:55 +01:00
const { defaultView } = element . ownerDocument ;
defaultView . addEventListener ( "copy" , onCopy ) ;
defaultView . addEventListener ( "cut" , onCopy ) ;
2025-02-28 08:42:11 +01:00
return ( ) => {
2025-12-12 13:15:55 +01:00
defaultView . removeEventListener ( "copy" , onCopy ) ;
defaultView . removeEventListener ( "cut" , onCopy ) ;
2025-02-28 08:42:11 +01:00
} ;
2025-12-12 13:15:55 +01:00
} ;
2021-07-23 11:58:50 +02:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/select-object.js
2025-12-12 13:15:55 +01:00
var select _object _default = ( ) => ( element ) => {
2025-02-28 08:42:11 +01:00
function onClick ( event ) {
2025-12-12 13:15:55 +01:00
const { target } = event ;
2025-02-28 08:42:11 +01:00
if ( target === element || target . textContent && target . isContentEditable ) {
return ;
}
2025-12-12 13:15:55 +01:00
const { ownerDocument } = target ;
const { defaultView } = ownerDocument ;
2025-02-28 08:42:11 +01:00
const selection = defaultView . getSelection ( ) ;
if ( selection . containsNode ( target ) ) {
return ;
2021-07-23 11:58:50 +02:00
}
2025-02-28 08:42:11 +01:00
const range = ownerDocument . createRange ( ) ;
2025-12-12 13:15:55 +01:00
const nodeToSelect = target . isContentEditable ? target : target . closest ( "[contenteditable]" ) ;
2025-02-28 08:42:11 +01:00
range . selectNode ( nodeToSelect ) ;
selection . removeAllRanges ( ) ;
selection . addRange ( range ) ;
event . preventDefault ( ) ;
}
function onFocusIn ( event ) {
2025-12-12 13:15:55 +01:00
if ( event . relatedTarget && ! element . contains ( event . relatedTarget ) && event . relatedTarget . tagName === "A" ) {
2025-02-28 08:42:11 +01:00
onClick ( event ) ;
}
}
2025-12-12 13:15:55 +01:00
element . addEventListener ( "click" , onClick ) ;
element . addEventListener ( "focusin" , onFocusIn ) ;
2025-02-28 08:42:11 +01:00
return ( ) => {
2025-12-12 13:15:55 +01:00
element . removeEventListener ( "click" , onClick ) ;
element . removeEventListener ( "focusin" , onFocusIn ) ;
2025-02-28 08:42:11 +01:00
} ;
2025-12-12 13:15:55 +01:00
} ;
2020-05-06 17:23:38 +02:00
2025-04-25 12:30:07 +02:00
; // external ["wp","keycodes"]
2024-04-17 11:32:24 +02:00
const external _wp _keycodes _namespaceObject = window [ "wp" ] [ "keycodes" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/format-boundaries.js
2019-11-02 10:38:58 +01:00
2021-07-23 11:58:50 +02:00
const EMPTY _ACTIVE _FORMATS = [ ] ;
2025-12-12 13:15:55 +01:00
var format _boundaries _default = ( props ) => ( element ) => {
2025-02-28 08:42:11 +01:00
function onKeyDown ( event ) {
2025-12-12 13:15:55 +01:00
const { keyCode , shiftKey , altKey , metaKey , ctrlKey } = event ;
2025-02-28 08:42:11 +01:00
if (
2025-12-12 13:15:55 +01:00
// Only override left and right keys without modifiers pressed.
shiftKey || altKey || metaKey || ctrlKey || keyCode !== external _wp _keycodes _namespaceObject . LEFT && keyCode !== external _wp _keycodes _namespaceObject . RIGHT
) {
2025-02-28 08:42:11 +01:00
return ;
}
2025-12-12 13:15:55 +01:00
const { record , applyRecord , forceRender } = props . current ;
2025-02-28 08:42:11 +01:00
const {
text ,
formats ,
start ,
end ,
activeFormats : currentActiveFormats = [ ]
} = record . current ;
const collapsed = isCollapsed ( record . current ) ;
2025-12-12 13:15:55 +01:00
const { ownerDocument } = element ;
const { defaultView } = ownerDocument ;
const { direction } = defaultView . getComputedStyle ( element ) ;
const reverseKey = direction === "rtl" ? external _wp _keycodes _namespaceObject . RIGHT : external _wp _keycodes _namespaceObject . LEFT ;
2025-02-28 08:42:11 +01:00
const isReverse = event . keyCode === reverseKey ;
if ( collapsed && currentActiveFormats . length === 0 ) {
if ( start === 0 && isReverse ) {
2021-07-23 11:58:50 +02:00
return ;
}
2025-02-28 08:42:11 +01:00
if ( end === text . length && ! isReverse ) {
2021-07-23 11:58:50 +02:00
return ;
}
}
2025-02-28 08:42:11 +01:00
if ( ! collapsed ) {
return ;
}
const formatsBefore = formats [ start - 1 ] || EMPTY _ACTIVE _FORMATS ;
const formatsAfter = formats [ start ] || EMPTY _ACTIVE _FORMATS ;
const destination = isReverse ? formatsBefore : formatsAfter ;
2025-12-12 13:15:55 +01:00
const isIncreasing = currentActiveFormats . every (
( format , index ) => format === destination [ index ]
) ;
2025-02-28 08:42:11 +01:00
let newActiveFormatsLength = currentActiveFormats . length ;
if ( ! isIncreasing ) {
newActiveFormatsLength -- ;
} else if ( newActiveFormatsLength < destination . length ) {
newActiveFormatsLength ++ ;
}
if ( newActiveFormatsLength === currentActiveFormats . length ) {
record . current . _newActiveFormats = destination ;
return ;
}
event . preventDefault ( ) ;
const origin = isReverse ? formatsAfter : formatsBefore ;
const source = isIncreasing ? destination : origin ;
const newActiveFormats = source . slice ( 0 , newActiveFormatsLength ) ;
const newValue = {
... record . current ,
activeFormats : newActiveFormats
2021-07-23 11:58:50 +02:00
} ;
2025-02-28 08:42:11 +01:00
record . current = newValue ;
applyRecord ( newValue ) ;
forceRender ( ) ;
}
2025-12-12 13:15:55 +01:00
element . addEventListener ( "keydown" , onKeyDown ) ;
2025-02-28 08:42:11 +01:00
return ( ) => {
2025-12-12 13:15:55 +01:00
element . removeEventListener ( "keydown" , onKeyDown ) ;
2025-02-28 08:42:11 +01:00
} ;
2025-12-12 13:15:55 +01:00
} ;
2019-11-02 10:38:58 +01:00
2020-05-06 17:23:38 +02:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/delete.js
2020-05-06 17:23:38 +02:00
2025-02-28 08:42:11 +01:00
2025-12-12 13:15:55 +01:00
var delete _default = ( props ) => ( element ) => {
2025-02-28 08:42:11 +01:00
function onKeyDown ( event ) {
2025-12-12 13:15:55 +01:00
const { keyCode } = event ;
const { createRecord , handleChange } = props . current ;
2025-02-28 08:42:11 +01:00
if ( event . defaultPrevented ) {
return ;
2023-09-26 10:33:34 +02:00
}
2025-02-28 08:42:11 +01:00
if ( keyCode !== external _wp _keycodes _namespaceObject . DELETE && keyCode !== external _wp _keycodes _namespaceObject . BACKSPACE ) {
return ;
2021-07-23 11:58:50 +02:00
}
2025-02-28 08:42:11 +01:00
const currentValue = createRecord ( ) ;
2025-12-12 13:15:55 +01:00
const { start , end , text } = currentValue ;
2025-02-28 08:42:11 +01:00
if ( start === 0 && end !== 0 && end === text . length ) {
handleChange ( remove _remove ( currentValue ) ) ;
event . preventDefault ( ) ;
}
}
2025-12-12 13:15:55 +01:00
element . addEventListener ( "keydown" , onKeyDown ) ;
2025-02-28 08:42:11 +01:00
return ( ) => {
2025-12-12 13:15:55 +01:00
element . removeEventListener ( "keydown" , onKeyDown ) ;
2025-02-28 08:42:11 +01:00
} ;
2025-12-12 13:15:55 +01:00
} ;
2019-11-02 10:38:58 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/update-formats.js
2025-12-12 13:15:55 +01:00
function updateFormats ( { value , start , end , formats } ) {
2022-04-02 10:26:41 +02:00
const min = Math . min ( start , end ) ;
const max = Math . max ( start , end ) ;
const formatsBefore = value . formats [ min - 1 ] || [ ] ;
2023-12-07 09:44:11 +01:00
const formatsAfter = value . formats [ max ] || [ ] ;
2021-07-23 11:58:50 +02:00
value . activeFormats = formats . map ( ( 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 ] ;
}
2019-11-15 22:59:44 +01:00
}
2021-07-23 11:58:50 +02:00
return format ;
} ) ;
while ( -- end >= start ) {
if ( value . activeFormats . length > 0 ) {
value . formats [ end ] = value . activeFormats ;
} else {
delete value . formats [ end ] ;
2019-11-15 22:59:44 +01:00
}
2021-07-23 11:58:50 +02:00
}
return value ;
}
2019-11-15 22:59:44 +01:00
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/input-and-selection.js
2020-09-15 14:29:22 +02:00
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
const INSERTION _INPUT _TYPES _TO _IGNORE = /* @__PURE__ */ new Set ( [
"insertParagraph" ,
"insertOrderedList" ,
"insertUnorderedList" ,
"insertHorizontalRule" ,
"insertLink"
] ) ;
2025-02-28 08:42:11 +01:00
const input _and _selection _EMPTY _ACTIVE _FORMATS = [ ] ;
2025-12-12 13:15:55 +01:00
const PLACEHOLDER _ATTR _NAME = "data-rich-text-placeholder" ;
2021-07-23 11:58:50 +02:00
function fixPlaceholderSelection ( defaultView ) {
const selection = defaultView . getSelection ( ) ;
2025-12-12 13:15:55 +01:00
const { anchorNode , anchorOffset } = selection ;
2021-07-23 11:58:50 +02:00
if ( anchorNode . nodeType !== anchorNode . ELEMENT _NODE ) {
return ;
}
const targetNode = anchorNode . childNodes [ anchorOffset ] ;
2022-12-15 17:47:31 +01:00
if ( ! targetNode || targetNode . nodeType !== targetNode . ELEMENT _NODE || ! targetNode . hasAttribute ( PLACEHOLDER _ATTR _NAME ) ) {
2021-07-23 11:58:50 +02:00
return ;
}
selection . collapseToStart ( ) ;
}
2025-12-12 13:15:55 +01:00
var input _and _selection _default = ( props ) => ( element ) => {
const { ownerDocument } = element ;
const { defaultView } = ownerDocument ;
2025-02-28 08:42:11 +01:00
let isComposing = false ;
function onInput ( event ) {
if ( isComposing ) {
return ;
}
let inputType ;
if ( event ) {
inputType = event . inputType ;
}
2025-12-12 13:15:55 +01:00
const { record , applyRecord , createRecord , handleChange } = props . current ;
if ( inputType && ( inputType . indexOf ( "format" ) === 0 || INSERTION _INPUT _TYPES _TO _IGNORE . has ( inputType ) ) ) {
2025-02-28 08:42:11 +01:00
applyRecord ( record . current ) ;
return ;
2019-11-02 10:38:58 +01:00
}
2025-02-28 08:42:11 +01:00
const currentValue = createRecord ( ) ;
2025-12-12 13:15:55 +01:00
const { start , activeFormats : oldActiveFormats = [ ] } = record . current ;
2025-02-28 08:42:11 +01:00
const change = updateFormats ( {
value : currentValue ,
start ,
end : currentValue . start ,
formats : oldActiveFormats
} ) ;
handleChange ( change ) ;
}
function handleSelectionChange ( ) {
2025-12-12 13:15:55 +01:00
const { record , applyRecord , createRecord , onSelectionChange } = props . current ;
if ( element . contentEditable !== "true" ) {
2025-02-28 08:42:11 +01:00
return ;
2020-05-06 17:23:38 +02:00
}
2025-02-28 08:42:11 +01:00
if ( ownerDocument . activeElement !== element ) {
2025-12-12 13:15:55 +01:00
ownerDocument . removeEventListener (
"selectionchange" ,
handleSelectionChange
) ;
2025-02-28 08:42:11 +01:00
return ;
2019-11-15 22:59:44 +01:00
}
2025-02-28 08:42:11 +01:00
if ( isComposing ) {
return ;
2020-09-15 14:29:22 +02:00
}
2025-12-12 13:15:55 +01:00
const { start , end , text } = createRecord ( ) ;
2025-02-28 08:42:11 +01:00
const oldRecord = record . current ;
if ( text !== oldRecord . text ) {
onInput ( ) ;
return ;
}
if ( start === oldRecord . start && end === oldRecord . end ) {
if ( oldRecord . text . length === 0 && start === 0 ) {
fixPlaceholderSelection ( defaultView ) ;
2023-09-26 10:33:34 +02:00
}
2025-02-28 08:42:11 +01:00
return ;
2021-07-23 11:58:50 +02:00
}
2025-02-28 08:42:11 +01:00
const newValue = {
... oldRecord ,
start ,
end ,
// _newActiveFormats may be set on arrow key navigation to control
// the right boundary position. If undefined, getActiveFormats will
// give the active formats according to the browser.
activeFormats : oldRecord . _newActiveFormats ,
2025-12-12 13:15:55 +01:00
_newActiveFormats : void 0
2023-09-26 10:33:34 +02:00
} ;
2025-12-12 13:15:55 +01:00
const newActiveFormats = getActiveFormats (
newValue ,
input _and _selection _EMPTY _ACTIVE _FORMATS
) ;
2025-02-28 08:42:11 +01:00
newValue . activeFormats = newActiveFormats ;
record . current = newValue ;
2025-12-12 13:15:55 +01:00
applyRecord ( newValue , { domOnly : true } ) ;
2025-02-28 08:42:11 +01:00
onSelectionChange ( start , end ) ;
}
function onCompositionStart ( ) {
isComposing = true ;
2025-12-12 13:15:55 +01:00
ownerDocument . removeEventListener (
"selectionchange" ,
handleSelectionChange
) ;
2025-02-28 08:42:11 +01:00
element . querySelector ( ` [ ${ PLACEHOLDER _ATTR _NAME } ] ` ) ? . remove ( ) ;
}
function onCompositionEnd ( ) {
isComposing = false ;
2025-12-12 13:15:55 +01:00
onInput ( { inputType : "insertText" } ) ;
ownerDocument . addEventListener (
"selectionchange" ,
handleSelectionChange
) ;
2025-02-28 08:42:11 +01:00
}
function onFocus ( ) {
2025-12-12 13:15:55 +01:00
const { record , isSelected , onSelectionChange , applyRecord } = props . current ;
2025-02-28 08:42:11 +01:00
if ( element . parentElement . closest ( '[contenteditable="true"]' ) ) {
return ;
}
if ( ! isSelected ) {
2025-12-12 13:15:55 +01:00
const index = void 0 ;
2025-02-28 08:42:11 +01:00
record . current = {
... record . current ,
start : index ,
end : index ,
activeFormats : input _and _selection _EMPTY _ACTIVE _FORMATS
} ;
} else {
2025-12-12 13:15:55 +01:00
applyRecord ( record . current , { domOnly : true } ) ;
2025-02-28 08:42:11 +01:00
}
onSelectionChange ( record . current . start , record . current . end ) ;
window . queueMicrotask ( handleSelectionChange ) ;
2025-12-12 13:15:55 +01:00
ownerDocument . addEventListener (
"selectionchange" ,
handleSelectionChange
) ;
}
element . addEventListener ( "input" , onInput ) ;
element . addEventListener ( "compositionstart" , onCompositionStart ) ;
element . addEventListener ( "compositionend" , onCompositionEnd ) ;
element . addEventListener ( "focus" , onFocus ) ;
2025-02-28 08:42:11 +01:00
return ( ) => {
2025-12-12 13:15:55 +01:00
element . removeEventListener ( "input" , onInput ) ;
element . removeEventListener ( "compositionstart" , onCompositionStart ) ;
element . removeEventListener ( "compositionend" , onCompositionEnd ) ;
element . removeEventListener ( "focus" , onFocus ) ;
2025-02-28 08:42:11 +01:00
} ;
2025-12-12 13:15:55 +01:00
} ;
2023-12-07 09:44:11 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/selection-change-compat.js
2025-12-12 13:15:55 +01:00
var selection _change _compat _default = ( ) => ( element ) => {
const { ownerDocument } = element ;
const { defaultView } = ownerDocument ;
2025-02-28 08:42:11 +01:00
const selection = defaultView ? . getSelection ( ) ;
let range ;
function getRange ( ) {
return selection . rangeCount ? selection . getRangeAt ( 0 ) : null ;
}
function onDown ( event ) {
2025-12-12 13:15:55 +01:00
const type = event . type === "keydown" ? "keyup" : "pointerup" ;
2025-02-28 08:42:11 +01:00
function onCancel ( ) {
ownerDocument . removeEventListener ( type , onUp ) ;
2025-12-12 13:15:55 +01:00
ownerDocument . removeEventListener ( "selectionchange" , onCancel ) ;
ownerDocument . removeEventListener ( "input" , onCancel ) ;
2025-02-28 08:42:11 +01:00
}
function onUp ( ) {
onCancel ( ) ;
if ( isRangeEqual ( range , getRange ( ) ) ) {
return ;
2023-09-26 10:33:34 +02:00
}
2025-12-12 13:15:55 +01:00
ownerDocument . dispatchEvent ( new Event ( "selectionchange" ) ) ;
2025-02-28 08:42:11 +01:00
}
ownerDocument . addEventListener ( type , onUp ) ;
2025-12-12 13:15:55 +01:00
ownerDocument . addEventListener ( "selectionchange" , onCancel ) ;
ownerDocument . addEventListener ( "input" , onCancel ) ;
2025-02-28 08:42:11 +01:00
range = getRange ( ) ;
}
2025-12-12 13:15:55 +01:00
element . addEventListener ( "pointerdown" , onDown ) ;
element . addEventListener ( "keydown" , onDown ) ;
2025-02-28 08:42:11 +01:00
return ( ) => {
2025-12-12 13:15:55 +01:00
element . removeEventListener ( "pointerdown" , onDown ) ;
element . removeEventListener ( "keydown" , onDown ) ;
2025-02-28 08:42:11 +01:00
} ;
2025-12-12 13:15:55 +01:00
} ;
2020-09-15 14:29:22 +02:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/prevent-focus-capture.js
function preventFocusCapture ( ) {
2025-12-12 13:15:55 +01:00
return ( element ) => {
const { ownerDocument } = element ;
const { defaultView } = ownerDocument ;
2025-04-25 12:30:07 +02:00
let value = null ;
function onPointerDown ( event ) {
if ( event . defaultPrevented ) {
return ;
}
if ( event . target === element ) {
return ;
}
if ( ! event . target . contains ( element ) ) {
return ;
}
2025-12-12 13:15:55 +01:00
value = element . getAttribute ( "contenteditable" ) ;
element . setAttribute ( "contenteditable" , "false" ) ;
2025-04-25 12:30:07 +02:00
defaultView . getSelection ( ) . removeAllRanges ( ) ;
}
function onPointerUp ( ) {
if ( value !== null ) {
2025-12-12 13:15:55 +01:00
element . setAttribute ( "contenteditable" , value ) ;
2025-04-25 12:30:07 +02:00
value = null ;
}
}
2025-12-12 13:15:55 +01:00
defaultView . addEventListener ( "pointerdown" , onPointerDown ) ;
defaultView . addEventListener ( "pointerup" , onPointerUp ) ;
2025-04-25 12:30:07 +02:00
return ( ) => {
2025-12-12 13:15:55 +01:00
defaultView . removeEventListener ( "pointerdown" , onPointerDown ) ;
defaultView . removeEventListener ( "pointerup" , onPointerUp ) ;
2025-04-25 12:30:07 +02:00
} ;
} ;
}
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/index.js
2019-11-02 10:38:58 +01:00
2025-02-28 08:42:11 +01:00
2025-04-25 12:30:07 +02:00
2025-12-12 13:15:55 +01:00
const allEventListeners = [
copy _handler _default ,
select _object _default ,
format _boundaries _default ,
delete _default ,
input _and _selection _default ,
selection _change _compat _default ,
preventFocusCapture
] ;
2025-02-28 08:42:11 +01:00
function useEventListeners ( props ) {
2022-06-16 14:03:35 +02:00
const propsRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( props ) ;
2025-04-25 12:30:07 +02:00
( 0 , external _wp _element _namespaceObject . useInsertionEffect ) ( ( ) => {
propsRef . current = props ;
} ) ;
2025-12-12 13:15:55 +01:00
const refEffects = ( 0 , external _wp _element _namespaceObject . useMemo ) (
( ) => allEventListeners . map ( ( refEffect ) => refEffect ( propsRef ) ) ,
[ propsRef ]
) ;
return ( 0 , external _wp _compose _namespaceObject . useRefEffect ) (
( element ) => {
const cleanups = refEffects . map ( ( effect ) => effect ( element ) ) ;
return ( ) => {
cleanups . forEach ( ( cleanup ) => cleanup ( ) ) ;
} ;
} ,
[ refEffects ]
) ;
2021-07-23 11:58:50 +02:00
}
2019-11-02 10:38:58 +01:00
2019-11-15 22:59:44 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/rich-text/build-module/component/index.js
2020-05-06 17:23:38 +02:00
2022-04-02 10:26:41 +02:00
2023-12-07 09:44:11 +01:00
2019-11-15 22:59:44 +01:00
2019-11-02 10:38:58 +01:00
2020-09-15 14:29:22 +02:00
2019-11-02 10:38:58 +01:00
2023-09-26 10:33:34 +02:00
function useRichText ( {
2025-12-12 13:15:55 +01:00
value = "" ,
2023-09-26 10:33:34 +02:00
selectionStart ,
selectionEnd ,
placeholder ,
onSelectionChange ,
2024-04-17 11:32:24 +02:00
preserveWhiteSpace ,
2023-09-26 10:33:34 +02:00
onChange ,
_ _unstableDisableFormats : disableFormats ,
_ _unstableIsSelected : isSelected ,
_ _unstableDependencies = [ ] ,
_ _unstableAfterParse ,
_ _unstableBeforeSerialize ,
_ _unstableAddInvisibleFormats
} ) {
2022-06-16 14:03:35 +02:00
const registry = ( 0 , external _wp _data _namespaceObject . useRegistry ) ( ) ;
const [ , forceRender ] = ( 0 , external _wp _element _namespaceObject . useReducer ) ( ( ) => ( { } ) ) ;
const ref = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
2021-07-23 11:58:50 +02:00
function createRecord ( ) {
const {
2025-12-12 13:15:55 +01:00
ownerDocument : { defaultView }
2021-07-23 11:58:50 +02:00
} = ref . current ;
const selection = defaultView . getSelection ( ) ;
const range = selection . rangeCount > 0 ? selection . getRangeAt ( 0 ) : null ;
return create ( {
element : ref . current ,
range ,
2024-04-17 11:32:24 +02:00
_ _unstableIsEditableTree : true
2021-07-23 11:58:50 +02:00
} ) ;
2020-09-15 14:29:22 +02:00
}
2025-12-12 13:15:55 +01:00
function applyRecord ( newRecord , { domOnly } = { } ) {
2021-07-23 11:58:50 +02:00
apply ( {
value : newRecord ,
current : ref . current ,
prepareEditableTree : _ _unstableAddInvisibleFormats ,
_ _unstableDomOnly : domOnly ,
placeholder
} ) ;
2023-12-07 09:44:11 +01:00
}
2025-02-28 08:42:11 +01:00
const _valueRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( value ) ;
const recordRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
2021-07-23 11:58:50 +02:00
function setRecordFromProps ( ) {
2025-02-28 08:42:11 +01:00
_valueRef . current = value ;
recordRef . current = value ;
2024-04-17 11:32:24 +02:00
if ( ! ( value instanceof RichTextData ) ) {
2025-12-12 13:15:55 +01:00
recordRef . current = value ? RichTextData . fromHTMLString ( value , { preserveWhiteSpace } ) : RichTextData . empty ( ) ;
2024-04-17 11:32:24 +02:00
}
2025-02-28 08:42:11 +01:00
recordRef . current = {
text : recordRef . current . text ,
formats : recordRef . current . formats ,
replacements : recordRef . current . replacements
2024-04-17 11:32:24 +02:00
} ;
2021-07-23 11:58:50 +02:00
if ( disableFormats ) {
2025-02-28 08:42:11 +01:00
recordRef . current . formats = Array ( value . length ) ;
recordRef . current . replacements = Array ( value . length ) ;
2021-07-23 11:58:50 +02:00
}
2022-04-02 10:26:41 +02:00
if ( _ _unstableAfterParse ) {
2025-12-12 13:15:55 +01:00
recordRef . current . formats = _ _unstableAfterParse (
recordRef . current
) ;
2022-04-02 10:26:41 +02:00
}
2025-02-28 08:42:11 +01:00
recordRef . current . start = selectionStart ;
recordRef . current . end = selectionEnd ;
2021-07-23 11:58:50 +02:00
}
2025-02-28 08:42:11 +01:00
const hadSelectionUpdateRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( false ) ;
if ( ! recordRef . current ) {
hadSelectionUpdateRef . current = isSelected ;
2023-12-07 09:44:11 +01:00
setRecordFromProps ( ) ;
2025-02-28 08:42:11 +01:00
} else if ( selectionStart !== recordRef . current . start || selectionEnd !== recordRef . current . end ) {
hadSelectionUpdateRef . current = isSelected ;
recordRef . current = {
... recordRef . current ,
2021-07-23 11:58:50 +02:00
start : selectionStart ,
2023-12-07 09:44:11 +01:00
end : selectionEnd ,
2025-12-12 13:15:55 +01:00
activeFormats : void 0
2021-07-23 11:58:50 +02:00
} ;
2020-09-15 14:29:22 +02:00
}
function handleChange ( newRecord ) {
2025-02-28 08:42:11 +01:00
recordRef . current = newRecord ;
2021-07-23 11:58:50 +02:00
applyRecord ( newRecord ) ;
2020-09-15 14:29:22 +02:00
if ( disableFormats ) {
2025-02-28 08:42:11 +01:00
_valueRef . current = newRecord . text ;
2021-07-23 11:58:50 +02:00
} else {
2024-04-17 11:32:24 +02:00
const newFormats = _ _unstableBeforeSerialize ? _ _unstableBeforeSerialize ( newRecord ) : newRecord . formats ;
2025-12-12 13:15:55 +01:00
newRecord = { ... newRecord , formats : newFormats } ;
if ( typeof value === "string" ) {
2025-02-28 08:42:11 +01:00
_valueRef . current = toHTMLString ( {
2024-04-17 11:32:24 +02:00
value : newRecord ,
preserveWhiteSpace
} ) ;
} else {
2025-02-28 08:42:11 +01:00
_valueRef . current = new RichTextData ( newRecord ) ;
2024-04-17 11:32:24 +02:00
}
2019-11-15 22:59:44 +01:00
}
2025-12-12 13:15:55 +01:00
const { start , end , formats , text } = recordRef . current ;
2022-04-02 10:26:41 +02:00
registry . batch ( ( ) => {
onSelectionChange ( start , end ) ;
2025-02-28 08:42:11 +01:00
onChange ( _valueRef . current , {
2022-04-02 10:26:41 +02:00
_ _unstableFormats : formats ,
_ _unstableText : text
} ) ;
} ) ;
forceRender ( ) ;
}
2020-09-15 14:29:22 +02:00
function applyFromProps ( ) {
2025-12-12 13:15:55 +01:00
const previousValue = _valueRef . current ;
2021-07-23 11:58:50 +02:00
setRecordFromProps ( ) ;
2025-12-12 13:15:55 +01:00
const contentLengthChanged = previousValue && typeof previousValue === "string" && typeof value === "string" && previousValue . length !== value . length ;
const hasFocus = ref . current ? . contains (
ref . current . ownerDocument . activeElement
) ;
const skipSelection = contentLengthChanged && ! hasFocus ;
applyRecord ( recordRef . current , { domOnly : skipSelection } ) ;
2020-09-15 14:29:22 +02:00
}
2025-02-28 08:42:11 +01:00
const didMountRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( false ) ;
2022-06-16 14:03:35 +02:00
( 0 , external _wp _element _namespaceObject . useLayoutEffect ) ( ( ) => {
2025-02-28 08:42:11 +01:00
if ( didMountRef . current && value !== _valueRef . current ) {
2020-09-15 14:29:22 +02:00
applyFromProps ( ) ;
2022-06-16 14:03:35 +02:00
forceRender ( ) ;
2020-09-15 14:29:22 +02:00
}
2023-12-07 09:44:11 +01:00
} , [ value ] ) ;
2022-06-16 14:03:35 +02:00
( 0 , external _wp _element _namespaceObject . useLayoutEffect ) ( ( ) => {
2025-02-28 08:42:11 +01:00
if ( ! hadSelectionUpdateRef . current ) {
2020-09-15 14:29:22 +02:00
return ;
2019-11-02 10:38:58 +01:00
}
2022-06-16 14:03:35 +02:00
if ( ref . current . ownerDocument . activeElement !== ref . current ) {
ref . current . focus ( ) ;
}
2025-02-28 08:42:11 +01:00
applyRecord ( recordRef . current ) ;
hadSelectionUpdateRef . current = false ;
} , [ hadSelectionUpdateRef . current ] ) ;
2025-12-12 13:15:55 +01:00
const mergedRefs = ( 0 , external _wp _compose _namespaceObject . useMergeRefs ) ( [
ref ,
useDefaultStyle ( ) ,
useBoundaryStyle ( { record : recordRef } ) ,
useEventListeners ( {
record : recordRef ,
handleChange ,
applyRecord ,
createRecord ,
isSelected ,
onSelectionChange ,
forceRender
} ) ,
( 0 , external _wp _compose _namespaceObject . useRefEffect ) ( ( ) => {
applyFromProps ( ) ;
didMountRef . current = true ;
} , [ placeholder , ... _ _unstableDependencies ] )
] ) ;
2021-07-23 11:58:50 +02:00
return {
2025-02-28 08:42:11 +01:00
value : recordRef . current ,
2023-05-23 23:18:12 +02:00
// A function to get the most recent value so event handlers in
// useRichText implementations have access to it. For example when
// listening to input events, we internally update the state, but this
// state is not yet available to the input event handler because React
// may re-render asynchronously.
2025-02-28 08:42:11 +01:00
getValue : ( ) => recordRef . current ,
2020-09-15 14:29:22 +02:00
onChange : handleChange ,
2021-07-23 11:58:50 +02:00
ref : mergedRefs
} ;
2020-09-15 14:29:22 +02:00
}
2025-12-12 13:15:55 +01:00
function _ _experimentalRichText ( ) {
}
2019-11-15 22:59:44 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/rich-text/build-module/index.js
2019-11-15 22:59:44 +01:00
2019-11-02 10:38:58 +01:00
2020-05-06 17:23:38 +02:00
2019-11-02 10:38:58 +01:00
2022-06-16 14:03:35 +02:00
( window . wp = window . wp || { } ) . richText = _ _webpack _exports _ _ ;
/******/ } ) ( )
;