fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

View File

@@ -0,0 +1,92 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.applyFormat = applyFormat;
var _normaliseFormats = require("./normalise-formats");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/** @typedef {import('./types').RichTextFormat} RichTextFormat */
function replace(array, index, value) {
array = array.slice();
array[index] = value;
return array;
}
/**
* Apply a format object to a Rich Text value from the given `startIndex` to the
* given `endIndex`. Indices are retrieved from the selection if none are
* provided.
*
* @param {RichTextValue} value Value to modify.
* @param {RichTextFormat} format Format to apply.
* @param {number} [startIndex] Start index.
* @param {number} [endIndex] End index.
*
* @return {RichTextValue} A new value with the format applied.
*/
function applyFormat(value, format, startIndex = value.start, endIndex = value.end) {
const {
formats,
activeFormats
} = value;
const newFormats = formats.slice();
// The selection is collapsed.
if (startIndex === endIndex) {
const startFormat = newFormats[startIndex]?.find(({
type
}) => type === format.type);
// If the caret is at a format of the same type, expand start and end to
// the edges of the format. This is useful to apply new attributes.
if (startFormat) {
const index = newFormats[startIndex].indexOf(startFormat);
while (newFormats[startIndex] && newFormats[startIndex][index] === startFormat) {
newFormats[startIndex] = replace(newFormats[startIndex], index, format);
startIndex--;
}
endIndex++;
while (newFormats[endIndex] && newFormats[endIndex][index] === startFormat) {
newFormats[endIndex] = replace(newFormats[endIndex], index, format);
endIndex++;
}
}
} else {
// Determine the highest position the new format can be inserted at.
let position = +Infinity;
for (let index = startIndex; index < endIndex; index++) {
if (newFormats[index]) {
newFormats[index] = newFormats[index].filter(({
type
}) => type !== format.type);
const length = newFormats[index].length;
if (length < position) {
position = length;
}
} else {
newFormats[index] = [];
position = 0;
}
}
for (let index = startIndex; index < endIndex; index++) {
newFormats[index].splice(position, 0, format);
}
}
return (0, _normaliseFormats.normaliseFormats)({
...value,
formats: newFormats,
// Always revise active formats. This serves as a placeholder for new
// inputs with the format so new input appears with the format applied,
// and ensures a format of the same type uses the latest values.
activeFormats: [...(activeFormats?.filter(({
type
}) => type !== format.type) || []), format]
});
}
//# sourceMappingURL=apply-format.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _toHtmlString = require("../../to-html-string");
var _isCollapsed = require("../../is-collapsed");
var _slice = require("../../slice");
var _getTextContent = require("../../get-text-content");
/**
* Internal dependencies
*/
var _default = props => element => {
function onCopy(event) {
const {
record
} = props.current;
const {
ownerDocument
} = element;
if ((0, _isCollapsed.isCollapsed)(record.current) || !element.contains(ownerDocument.activeElement)) {
return;
}
const selectedRecord = (0, _slice.slice)(record.current);
const plainText = (0, _getTextContent.getTextContent)(selectedRecord);
const html = (0, _toHtmlString.toHTMLString)({
value: selectedRecord
});
event.clipboardData.setData('text/plain', plainText);
event.clipboardData.setData('text/html', html);
event.clipboardData.setData('rich-text', 'true');
event.preventDefault();
if (event.type === 'cut') {
ownerDocument.execCommand('delete');
}
}
const {
defaultView
} = element.ownerDocument;
defaultView.addEventListener('copy', onCopy);
defaultView.addEventListener('cut', onCopy);
return () => {
defaultView.removeEventListener('copy', onCopy);
defaultView.removeEventListener('cut', onCopy);
};
};
exports.default = _default;
//# sourceMappingURL=copy-handler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_toHtmlString","require","_isCollapsed","_slice","_getTextContent","_default","props","element","onCopy","event","record","current","ownerDocument","isCollapsed","contains","activeElement","selectedRecord","slice","plainText","getTextContent","html","toHTMLString","value","clipboardData","setData","preventDefault","type","execCommand","defaultView","addEventListener","removeEventListener","exports","default"],"sources":["@wordpress/rich-text/src/component/event-listeners/copy-handler.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { toHTMLString } from '../../to-html-string';\nimport { isCollapsed } from '../../is-collapsed';\nimport { slice } from '../../slice';\nimport { getTextContent } from '../../get-text-content';\n\nexport default ( props ) => ( element ) => {\n\tfunction onCopy( event ) {\n\t\tconst { record } = props.current;\n\t\tconst { ownerDocument } = element;\n\t\tif (\n\t\t\tisCollapsed( record.current ) ||\n\t\t\t! element.contains( ownerDocument.activeElement )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst selectedRecord = slice( record.current );\n\t\tconst plainText = getTextContent( selectedRecord );\n\t\tconst html = toHTMLString( { value: selectedRecord } );\n\t\tevent.clipboardData.setData( 'text/plain', plainText );\n\t\tevent.clipboardData.setData( 'text/html', html );\n\t\tevent.clipboardData.setData( 'rich-text', 'true' );\n\t\tevent.preventDefault();\n\n\t\tif ( event.type === 'cut' ) {\n\t\t\townerDocument.execCommand( 'delete' );\n\t\t}\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\tdefaultView.addEventListener( 'copy', onCopy );\n\tdefaultView.addEventListener( 'cut', onCopy );\n\treturn () => {\n\t\tdefaultView.removeEventListener( 'copy', onCopy );\n\t\tdefaultView.removeEventListener( 'cut', onCopy );\n\t};\n};\n"],"mappings":";;;;;;AAGA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AANA;AACA;AACA;AAFA,IAAAI,QAAA,GAQiBC,KAAK,IAAQC,OAAO,IAAM;EAC1C,SAASC,MAAMA,CAAEC,KAAK,EAAG;IACxB,MAAM;MAAEC;IAAO,CAAC,GAAGJ,KAAK,CAACK,OAAO;IAChC,MAAM;MAAEC;IAAc,CAAC,GAAGL,OAAO;IACjC,IACC,IAAAM,wBAAW,EAAEH,MAAM,CAACC,OAAQ,CAAC,IAC7B,CAAEJ,OAAO,CAACO,QAAQ,CAAEF,aAAa,CAACG,aAAc,CAAC,EAChD;MACD;IACD;IAEA,MAAMC,cAAc,GAAG,IAAAC,YAAK,EAAEP,MAAM,CAACC,OAAQ,CAAC;IAC9C,MAAMO,SAAS,GAAG,IAAAC,8BAAc,EAAEH,cAAe,CAAC;IAClD,MAAMI,IAAI,GAAG,IAAAC,0BAAY,EAAE;MAAEC,KAAK,EAAEN;IAAe,CAAE,CAAC;IACtDP,KAAK,CAACc,aAAa,CAACC,OAAO,CAAE,YAAY,EAAEN,SAAU,CAAC;IACtDT,KAAK,CAACc,aAAa,CAACC,OAAO,CAAE,WAAW,EAAEJ,IAAK,CAAC;IAChDX,KAAK,CAACc,aAAa,CAACC,OAAO,CAAE,WAAW,EAAE,MAAO,CAAC;IAClDf,KAAK,CAACgB,cAAc,CAAC,CAAC;IAEtB,IAAKhB,KAAK,CAACiB,IAAI,KAAK,KAAK,EAAG;MAC3Bd,aAAa,CAACe,WAAW,CAAE,QAAS,CAAC;IACtC;EACD;EAEA,MAAM;IAAEC;EAAY,CAAC,GAAGrB,OAAO,CAACK,aAAa;EAE7CgB,WAAW,CAACC,gBAAgB,CAAE,MAAM,EAAErB,MAAO,CAAC;EAC9CoB,WAAW,CAACC,gBAAgB,CAAE,KAAK,EAAErB,MAAO,CAAC;EAC7C,OAAO,MAAM;IACZoB,WAAW,CAACE,mBAAmB,CAAE,MAAM,EAAEtB,MAAO,CAAC;IACjDoB,WAAW,CAACE,mBAAmB,CAAE,KAAK,EAAEtB,MAAO,CAAC;EACjD,CAAC;AACF,CAAC;AAAAuB,OAAA,CAAAC,OAAA,GAAA3B,QAAA","ignoreList":[]}

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _keycodes = require("@wordpress/keycodes");
var _remove = require("../../remove");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var _default = props => element => {
function onKeyDown(event) {
const {
keyCode
} = event;
const {
createRecord,
handleChange
} = props.current;
if (event.defaultPrevented) {
return;
}
if (keyCode !== _keycodes.DELETE && keyCode !== _keycodes.BACKSPACE) {
return;
}
const currentValue = createRecord();
const {
start,
end,
text
} = currentValue;
// Always handle full content deletion ourselves.
if (start === 0 && end !== 0 && end === text.length) {
handleChange((0, _remove.remove)(currentValue));
event.preventDefault();
}
}
element.addEventListener('keydown', onKeyDown);
return () => {
element.removeEventListener('keydown', onKeyDown);
};
};
exports.default = _default;
//# sourceMappingURL=delete.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_keycodes","require","_remove","_default","props","element","onKeyDown","event","keyCode","createRecord","handleChange","current","defaultPrevented","DELETE","BACKSPACE","currentValue","start","end","text","length","remove","preventDefault","addEventListener","removeEventListener","exports","default"],"sources":["@wordpress/rich-text/src/component/event-listeners/delete.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BACKSPACE, DELETE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { remove } from '../../remove';\n\nexport default ( props ) => ( element ) => {\n\tfunction onKeyDown( event ) {\n\t\tconst { keyCode } = event;\n\t\tconst { createRecord, handleChange } = props.current;\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( keyCode !== DELETE && keyCode !== BACKSPACE ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst currentValue = createRecord();\n\t\tconst { start, end, text } = currentValue;\n\n\t\t// Always handle full content deletion ourselves.\n\t\tif ( start === 0 && end !== 0 && end === text.length ) {\n\t\t\thandleChange( remove( currentValue ) );\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\telement.addEventListener( 'keydown', onKeyDown );\n\treturn () => {\n\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t};\n};\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AARA;AACA;AACA;AAGA;AACA;AACA;AAFA,IAAAE,QAAA,GAKiBC,KAAK,IAAQC,OAAO,IAAM;EAC1C,SAASC,SAASA,CAAEC,KAAK,EAAG;IAC3B,MAAM;MAAEC;IAAQ,CAAC,GAAGD,KAAK;IACzB,MAAM;MAAEE,YAAY;MAAEC;IAAa,CAAC,GAAGN,KAAK,CAACO,OAAO;IAEpD,IAAKJ,KAAK,CAACK,gBAAgB,EAAG;MAC7B;IACD;IAEA,IAAKJ,OAAO,KAAKK,gBAAM,IAAIL,OAAO,KAAKM,mBAAS,EAAG;MAClD;IACD;IAEA,MAAMC,YAAY,GAAGN,YAAY,CAAC,CAAC;IACnC,MAAM;MAAEO,KAAK;MAAEC,GAAG;MAAEC;IAAK,CAAC,GAAGH,YAAY;;IAEzC;IACA,IAAKC,KAAK,KAAK,CAAC,IAAIC,GAAG,KAAK,CAAC,IAAIA,GAAG,KAAKC,IAAI,CAACC,MAAM,EAAG;MACtDT,YAAY,CAAE,IAAAU,cAAM,EAAEL,YAAa,CAAE,CAAC;MACtCR,KAAK,CAACc,cAAc,CAAC,CAAC;IACvB;EACD;EAEAhB,OAAO,CAACiB,gBAAgB,CAAE,SAAS,EAAEhB,SAAU,CAAC;EAChD,OAAO,MAAM;IACZD,OAAO,CAACkB,mBAAmB,CAAE,SAAS,EAAEjB,SAAU,CAAC;EACpD,CAAC;AACF,CAAC;AAAAkB,OAAA,CAAAC,OAAA,GAAAtB,QAAA","ignoreList":[]}

View File

@@ -0,0 +1,109 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _keycodes = require("@wordpress/keycodes");
var _isCollapsed = require("../../is-collapsed");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const EMPTY_ACTIVE_FORMATS = [];
var _default = props => element => {
function onKeyDown(event) {
const {
keyCode,
shiftKey,
altKey,
metaKey,
ctrlKey
} = event;
if (
// Only override left and right keys without modifiers pressed.
shiftKey || altKey || metaKey || ctrlKey || keyCode !== _keycodes.LEFT && keyCode !== _keycodes.RIGHT) {
return;
}
const {
record,
applyRecord,
forceRender
} = props.current;
const {
text,
formats,
start,
end,
activeFormats: currentActiveFormats = []
} = record.current;
const collapsed = (0, _isCollapsed.isCollapsed)(record.current);
const {
ownerDocument
} = element;
const {
defaultView
} = ownerDocument;
// To do: ideally, we should look at visual position instead.
const {
direction
} = defaultView.getComputedStyle(element);
const reverseKey = direction === 'rtl' ? _keycodes.RIGHT : _keycodes.LEFT;
const isReverse = event.keyCode === reverseKey;
// If the selection is collapsed and at the very start, do nothing if
// navigating backward.
// If the selection is collapsed and at the very end, do nothing if
// navigating forward.
if (collapsed && currentActiveFormats.length === 0) {
if (start === 0 && isReverse) {
return;
}
if (end === text.length && !isReverse) {
return;
}
}
// If the selection is not collapsed, let the browser handle collapsing
// the selection for now. Later we could expand this logic to set
// boundary positions if needed.
if (!collapsed) {
return;
}
const formatsBefore = formats[start - 1] || EMPTY_ACTIVE_FORMATS;
const formatsAfter = formats[start] || EMPTY_ACTIVE_FORMATS;
const destination = isReverse ? formatsBefore : formatsAfter;
const isIncreasing = currentActiveFormats.every((format, index) => format === destination[index]);
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
};
record.current = newValue;
applyRecord(newValue);
forceRender();
}
element.addEventListener('keydown', onKeyDown);
return () => {
element.removeEventListener('keydown', onKeyDown);
};
};
exports.default = _default;
//# sourceMappingURL=format-boundaries.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,36 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useEventListeners = useEventListeners;
var _element = require("@wordpress/element");
var _compose = require("@wordpress/compose");
var _copyHandler = _interopRequireDefault(require("./copy-handler"));
var _selectObject = _interopRequireDefault(require("./select-object"));
var _formatBoundaries = _interopRequireDefault(require("./format-boundaries"));
var _delete = _interopRequireDefault(require("./delete"));
var _inputAndSelection = _interopRequireDefault(require("./input-and-selection"));
var _selectionChangeCompat = _interopRequireDefault(require("./selection-change-compat"));
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const allEventListeners = [_copyHandler.default, _selectObject.default, _formatBoundaries.default, _delete.default, _inputAndSelection.default, _selectionChangeCompat.default];
function useEventListeners(props) {
const propsRef = (0, _element.useRef)(props);
propsRef.current = props;
const refEffects = (0, _element.useMemo)(() => allEventListeners.map(refEffect => refEffect(propsRef)), [propsRef]);
return (0, _compose.useRefEffect)(element => {
const cleanups = refEffects.map(effect => effect(element));
return () => {
cleanups.forEach(cleanup => cleanup());
};
}, [refEffects]);
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","_compose","_copyHandler","_interopRequireDefault","_selectObject","_formatBoundaries","_delete","_inputAndSelection","_selectionChangeCompat","allEventListeners","copyHandler","selectObject","formatBoundaries","deleteHandler","inputAndSelection","selectionChangeCompat","useEventListeners","props","propsRef","useRef","current","refEffects","useMemo","map","refEffect","useRefEffect","element","cleanups","effect","forEach","cleanup"],"sources":["@wordpress/rich-text/src/component/event-listeners/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport copyHandler from './copy-handler';\nimport selectObject from './select-object';\nimport formatBoundaries from './format-boundaries';\nimport deleteHandler from './delete';\nimport inputAndSelection from './input-and-selection';\nimport selectionChangeCompat from './selection-change-compat';\n\nconst allEventListeners = [\n\tcopyHandler,\n\tselectObject,\n\tformatBoundaries,\n\tdeleteHandler,\n\tinputAndSelection,\n\tselectionChangeCompat,\n];\n\nexport function useEventListeners( props ) {\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\tconst refEffects = useMemo(\n\t\t() => allEventListeners.map( ( refEffect ) => refEffect( propsRef ) ),\n\t\t[ propsRef ]\n\t);\n\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tconst cleanups = refEffects.map( ( effect ) => effect( element ) );\n\t\t\treturn () => {\n\t\t\t\tcleanups.forEach( ( cleanup ) => cleanup() );\n\t\t\t};\n\t\t},\n\t\t[ refEffects ]\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,iBAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,OAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,kBAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,sBAAA,GAAAL,sBAAA,CAAAH,OAAA;AAdA;AACA;AACA;;AAIA;AACA;AACA;;AAQA,MAAMS,iBAAiB,GAAG,CACzBC,oBAAW,EACXC,qBAAY,EACZC,yBAAgB,EAChBC,eAAa,EACbC,0BAAiB,EACjBC,8BAAqB,CACrB;AAEM,SAASC,iBAAiBA,CAAEC,KAAK,EAAG;EAC1C,MAAMC,QAAQ,GAAG,IAAAC,eAAM,EAAEF,KAAM,CAAC;EAChCC,QAAQ,CAACE,OAAO,GAAGH,KAAK;EACxB,MAAMI,UAAU,GAAG,IAAAC,gBAAO,EACzB,MAAMb,iBAAiB,CAACc,GAAG,CAAIC,SAAS,IAAMA,SAAS,CAAEN,QAAS,CAAE,CAAC,EACrE,CAAEA,QAAQ,CACX,CAAC;EAED,OAAO,IAAAO,qBAAY,EAChBC,OAAO,IAAM;IACd,MAAMC,QAAQ,GAAGN,UAAU,CAACE,GAAG,CAAIK,MAAM,IAAMA,MAAM,CAAEF,OAAQ,CAAE,CAAC;IAClE,OAAO,MAAM;MACZC,QAAQ,CAACE,OAAO,CAAIC,OAAO,IAAMA,OAAO,CAAC,CAAE,CAAC;IAC7C,CAAC;EACF,CAAC,EACD,CAAET,UAAU,CACb,CAAC;AACF","ignoreList":[]}

View File

@@ -0,0 +1,242 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _getActiveFormats = require("../../get-active-formats");
var _updateFormats = require("../../update-formats");
/**
* Internal dependencies
*/
/**
* All inserting input types that would insert HTML into the DOM.
*
* @see https://www.w3.org/TR/input-events-2/#interface-InputEvent-Attributes
*
* @type {Set}
*/
const INSERTION_INPUT_TYPES_TO_IGNORE = new Set(['insertParagraph', 'insertOrderedList', 'insertUnorderedList', 'insertHorizontalRule', 'insertLink']);
const EMPTY_ACTIVE_FORMATS = [];
const PLACEHOLDER_ATTR_NAME = 'data-rich-text-placeholder';
/**
* If the selection is set on the placeholder element, collapse the selection to
* the start (before the placeholder).
*
* @param {Window} defaultView
*/
function fixPlaceholderSelection(defaultView) {
const selection = defaultView.getSelection();
const {
anchorNode,
anchorOffset
} = selection;
if (anchorNode.nodeType !== anchorNode.ELEMENT_NODE) {
return;
}
const targetNode = anchorNode.childNodes[anchorOffset];
if (!targetNode || targetNode.nodeType !== targetNode.ELEMENT_NODE || !targetNode.hasAttribute(PLACEHOLDER_ATTR_NAME)) {
return;
}
selection.collapseToStart();
}
var _default = props => element => {
const {
ownerDocument
} = element;
const {
defaultView
} = ownerDocument;
let isComposing = false;
function onInput(event) {
// Do not trigger a change if characters are being composed. Browsers
// will usually emit a final `input` event when the characters are
// composed. As of December 2019, Safari doesn't support
// nativeEvent.isComposing.
if (isComposing) {
return;
}
let inputType;
if (event) {
inputType = event.inputType;
}
const {
record,
applyRecord,
createRecord,
handleChange
} = props.current;
// The browser formatted something or tried to insert HTML. Overwrite
// it. It will be handled later by the format library if needed.
if (inputType && (inputType.indexOf('format') === 0 || INSERTION_INPUT_TYPES_TO_IGNORE.has(inputType))) {
applyRecord(record.current);
return;
}
const currentValue = createRecord();
const {
start,
activeFormats: oldActiveFormats = []
} = record.current;
// Update the formats between the last and new caret position.
const change = (0, _updateFormats.updateFormats)({
value: currentValue,
start,
end: currentValue.start,
formats: oldActiveFormats
});
handleChange(change);
}
/**
* Syncs the selection to local state. A callback for the `selectionchange`
* event.
*/
function handleSelectionChange() {
const {
record,
applyRecord,
createRecord,
onSelectionChange
} = props.current;
// Check if the implementor disabled editing. `contentEditable` does
// disable input, but not text selection, so we must ignore selection
// changes.
if (element.contentEditable !== 'true') {
return;
}
// Ensure the active element is the rich text element.
if (ownerDocument.activeElement !== element) {
// If it is not, we can stop listening for selection changes. We
// resume listening when the element is focused.
ownerDocument.removeEventListener('selectionchange', handleSelectionChange);
return;
}
// In case of a keyboard event, ignore selection changes during
// composition.
if (isComposing) {
return;
}
const {
start,
end,
text
} = createRecord();
const oldRecord = record.current;
// Fallback mechanism for IE11, which doesn't support the input event.
// Any input results in a selection change.
if (text !== oldRecord.text) {
onInput();
return;
}
if (start === oldRecord.start && end === oldRecord.end) {
// Sometimes the browser may set the selection on the placeholder
// element, in which case the caret is not visible. We need to set
// the caret before the placeholder if that's the case.
if (oldRecord.text.length === 0 && start === 0) {
fixPlaceholderSelection(defaultView);
}
return;
}
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,
_newActiveFormats: undefined
};
const newActiveFormats = (0, _getActiveFormats.getActiveFormats)(newValue, EMPTY_ACTIVE_FORMATS);
// Update the value with the new active formats.
newValue.activeFormats = newActiveFormats;
// It is important that the internal value is updated first,
// otherwise the value will be wrong on render!
record.current = newValue;
applyRecord(newValue, {
domOnly: true
});
onSelectionChange(start, end);
}
function onCompositionStart() {
isComposing = true;
// Do not update the selection when characters are being composed as
// this rerenders the component and might destroy internal browser
// editing state.
ownerDocument.removeEventListener('selectionchange', handleSelectionChange);
// Remove the placeholder. Since the rich text value doesn't update
// during composition, the placeholder doesn't get removed. There's no
// need to re-add it, when the value is updated on compositionend it
// will be re-added when the value is empty.
element.querySelector(`[${PLACEHOLDER_ATTR_NAME}]`)?.remove();
}
function onCompositionEnd() {
isComposing = false;
// Ensure the value is up-to-date for browsers that don't emit a final
// input event after composition.
onInput({
inputType: 'insertText'
});
// Tracking selection changes can be resumed.
ownerDocument.addEventListener('selectionchange', handleSelectionChange);
}
function onFocus() {
const {
record,
isSelected,
onSelectionChange,
applyRecord
} = props.current;
// When the whole editor is editable, let writing flow handle
// selection.
if (element.parentElement.closest('[contenteditable="true"]')) {
return;
}
if (!isSelected) {
// We know for certain that on focus, the old selection is invalid.
// It will be recalculated on the next mouseup, keyup, or touchend
// event.
const index = undefined;
record.current = {
...record.current,
start: index,
end: index,
activeFormats: EMPTY_ACTIVE_FORMATS
};
} else {
applyRecord(record.current, {
domOnly: true
});
}
onSelectionChange(record.current.start, record.current.end);
// There is no selection change event when the element is focused, so
// we need to manually trigger it. The selection is also not available
// yet in this call stack.
window.queueMicrotask(handleSelectionChange);
ownerDocument.addEventListener('selectionchange', handleSelectionChange);
}
element.addEventListener('input', onInput);
element.addEventListener('compositionstart', onCompositionStart);
element.addEventListener('compositionend', onCompositionEnd);
element.addEventListener('focus', onFocus);
return () => {
element.removeEventListener('input', onInput);
element.removeEventListener('compositionstart', onCompositionStart);
element.removeEventListener('compositionend', onCompositionEnd);
element.removeEventListener('focus', onFocus);
};
};
exports.default = _default;
//# sourceMappingURL=input-and-selection.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = () => element => {
function onClick(event) {
const {
target
} = event;
// If the child element has no text content, it must be an object.
if (target === element || target.textContent && target.isContentEditable) {
return;
}
const {
ownerDocument
} = target;
const {
defaultView
} = ownerDocument;
const selection = defaultView.getSelection();
// If it's already selected, do nothing and let default behavior happen.
// This means it's "click-through".
if (selection.containsNode(target)) {
return;
}
const range = ownerDocument.createRange();
// If the target is within a non editable element, select the non
// editable element.
const nodeToSelect = target.isContentEditable ? target : target.closest('[contenteditable]');
range.selectNode(nodeToSelect);
selection.removeAllRanges();
selection.addRange(range);
event.preventDefault();
}
function onFocusIn(event) {
// When there is incoming focus from a link, select the object.
if (event.relatedTarget && !element.contains(event.relatedTarget) && event.relatedTarget.tagName === 'A') {
onClick(event);
}
}
element.addEventListener('click', onClick);
element.addEventListener('focusin', onFocusIn);
return () => {
element.removeEventListener('click', onClick);
element.removeEventListener('focusin', onFocusIn);
};
};
exports.default = _default;
//# sourceMappingURL=select-object.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_default","element","onClick","event","target","textContent","isContentEditable","ownerDocument","defaultView","selection","getSelection","containsNode","range","createRange","nodeToSelect","closest","selectNode","removeAllRanges","addRange","preventDefault","onFocusIn","relatedTarget","contains","tagName","addEventListener","removeEventListener","exports","default"],"sources":["@wordpress/rich-text/src/component/event-listeners/select-object.js"],"sourcesContent":["export default () => ( element ) => {\n\tfunction onClick( event ) {\n\t\tconst { target } = event;\n\n\t\t// If the child element has no text content, it must be an object.\n\t\tif (\n\t\t\ttarget === element ||\n\t\t\t( target.textContent && target.isContentEditable )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = target;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\n\t\t// If it's already selected, do nothing and let default behavior happen.\n\t\t// This means it's \"click-through\".\n\t\tif ( selection.containsNode( target ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst range = ownerDocument.createRange();\n\t\t// If the target is within a non editable element, select the non\n\t\t// editable element.\n\t\tconst nodeToSelect = target.isContentEditable\n\t\t\t? target\n\t\t\t: target.closest( '[contenteditable]' );\n\n\t\trange.selectNode( nodeToSelect );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\n\t\tevent.preventDefault();\n\t}\n\n\tfunction onFocusIn( event ) {\n\t\t// When there is incoming focus from a link, select the object.\n\t\tif (\n\t\t\tevent.relatedTarget &&\n\t\t\t! element.contains( event.relatedTarget ) &&\n\t\t\tevent.relatedTarget.tagName === 'A'\n\t\t) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\telement.addEventListener( 'click', onClick );\n\telement.addEventListener( 'focusin', onFocusIn );\n\treturn () => {\n\t\telement.removeEventListener( 'click', onClick );\n\t\telement.removeEventListener( 'focusin', onFocusIn );\n\t};\n};\n"],"mappings":";;;;;;eAAeA,CAAA,KAAQC,OAAO,IAAM;EACnC,SAASC,OAAOA,CAAEC,KAAK,EAAG;IACzB,MAAM;MAAEC;IAAO,CAAC,GAAGD,KAAK;;IAExB;IACA,IACCC,MAAM,KAAKH,OAAO,IAChBG,MAAM,CAACC,WAAW,IAAID,MAAM,CAACE,iBAAmB,EACjD;MACD;IACD;IAEA,MAAM;MAAEC;IAAc,CAAC,GAAGH,MAAM;IAChC,MAAM;MAAEI;IAAY,CAAC,GAAGD,aAAa;IACrC,MAAME,SAAS,GAAGD,WAAW,CAACE,YAAY,CAAC,CAAC;;IAE5C;IACA;IACA,IAAKD,SAAS,CAACE,YAAY,CAAEP,MAAO,CAAC,EAAG;MACvC;IACD;IAEA,MAAMQ,KAAK,GAAGL,aAAa,CAACM,WAAW,CAAC,CAAC;IACzC;IACA;IACA,MAAMC,YAAY,GAAGV,MAAM,CAACE,iBAAiB,GAC1CF,MAAM,GACNA,MAAM,CAACW,OAAO,CAAE,mBAAoB,CAAC;IAExCH,KAAK,CAACI,UAAU,CAAEF,YAAa,CAAC;IAChCL,SAAS,CAACQ,eAAe,CAAC,CAAC;IAC3BR,SAAS,CAACS,QAAQ,CAAEN,KAAM,CAAC;IAE3BT,KAAK,CAACgB,cAAc,CAAC,CAAC;EACvB;EAEA,SAASC,SAASA,CAAEjB,KAAK,EAAG;IAC3B;IACA,IACCA,KAAK,CAACkB,aAAa,IACnB,CAAEpB,OAAO,CAACqB,QAAQ,CAAEnB,KAAK,CAACkB,aAAc,CAAC,IACzClB,KAAK,CAACkB,aAAa,CAACE,OAAO,KAAK,GAAG,EAClC;MACDrB,OAAO,CAAEC,KAAM,CAAC;IACjB;EACD;EAEAF,OAAO,CAACuB,gBAAgB,CAAE,OAAO,EAAEtB,OAAQ,CAAC;EAC5CD,OAAO,CAACuB,gBAAgB,CAAE,SAAS,EAAEJ,SAAU,CAAC;EAChD,OAAO,MAAM;IACZnB,OAAO,CAACwB,mBAAmB,CAAE,OAAO,EAAEvB,OAAQ,CAAC;IAC/CD,OAAO,CAACwB,mBAAmB,CAAE,SAAS,EAAEL,SAAU,CAAC;EACpD,CAAC;AACF,CAAC;AAAAM,OAAA,CAAAC,OAAA,GAAA3B,QAAA","ignoreList":[]}

View File

@@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _isRangeEqual = require("../../is-range-equal");
/**
* Internal dependencies
*/
/**
* Sometimes some browsers are not firing a `selectionchange` event when
* changing the selection by mouse or keyboard. This hook makes sure that, if we
* detect no `selectionchange` or `input` event between the up and down events,
* we fire a `selectionchange` event.
*/
var _default = () => element => {
const {
ownerDocument
} = element;
const {
defaultView
} = ownerDocument;
const selection = defaultView?.getSelection();
let range;
function getRange() {
return selection.rangeCount ? selection.getRangeAt(0) : null;
}
function onDown(event) {
const type = event.type === 'keydown' ? 'keyup' : 'pointerup';
function onCancel() {
ownerDocument.removeEventListener(type, onUp);
ownerDocument.removeEventListener('selectionchange', onCancel);
ownerDocument.removeEventListener('input', onCancel);
}
function onUp() {
onCancel();
if ((0, _isRangeEqual.isRangeEqual)(range, getRange())) {
return;
}
ownerDocument.dispatchEvent(new Event('selectionchange'));
}
ownerDocument.addEventListener(type, onUp);
ownerDocument.addEventListener('selectionchange', onCancel);
ownerDocument.addEventListener('input', onCancel);
range = getRange();
}
element.addEventListener('pointerdown', onDown);
element.addEventListener('keydown', onDown);
return () => {
element.removeEventListener('pointerdown', onDown);
element.removeEventListener('keydown', onDown);
};
};
exports.default = _default;
//# sourceMappingURL=selection-change-compat.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_isRangeEqual","require","_default","element","ownerDocument","defaultView","selection","getSelection","range","getRange","rangeCount","getRangeAt","onDown","event","type","onCancel","removeEventListener","onUp","isRangeEqual","dispatchEvent","Event","addEventListener","exports","default"],"sources":["@wordpress/rich-text/src/component/event-listeners/selection-change-compat.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { isRangeEqual } from '../../is-range-equal';\n\n/**\n * Sometimes some browsers are not firing a `selectionchange` event when\n * changing the selection by mouse or keyboard. This hook makes sure that, if we\n * detect no `selectionchange` or `input` event between the up and down events,\n * we fire a `selectionchange` event.\n */\nexport default () => ( element ) => {\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst selection = defaultView?.getSelection();\n\n\tlet range;\n\n\tfunction getRange() {\n\t\treturn selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\t}\n\n\tfunction onDown( event ) {\n\t\tconst type = event.type === 'keydown' ? 'keyup' : 'pointerup';\n\n\t\tfunction onCancel() {\n\t\t\townerDocument.removeEventListener( type, onUp );\n\t\t\townerDocument.removeEventListener( 'selectionchange', onCancel );\n\t\t\townerDocument.removeEventListener( 'input', onCancel );\n\t\t}\n\n\t\tfunction onUp() {\n\t\t\tonCancel();\n\t\t\tif ( isRangeEqual( range, getRange() ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\townerDocument.dispatchEvent( new Event( 'selectionchange' ) );\n\t\t}\n\n\t\townerDocument.addEventListener( type, onUp );\n\t\townerDocument.addEventListener( 'selectionchange', onCancel );\n\t\townerDocument.addEventListener( 'input', onCancel );\n\n\t\trange = getRange();\n\t}\n\n\telement.addEventListener( 'pointerdown', onDown );\n\telement.addEventListener( 'keydown', onDown );\n\treturn () => {\n\t\telement.removeEventListener( 'pointerdown', onDown );\n\t\telement.removeEventListener( 'keydown', onDown );\n\t};\n};\n"],"mappings":";;;;;;AAGA,IAAAA,aAAA,GAAAC,OAAA;AAHA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AALA,IAAAC,QAAA,GAMeA,CAAA,KAAQC,OAAO,IAAM;EACnC,MAAM;IAAEC;EAAc,CAAC,GAAGD,OAAO;EACjC,MAAM;IAAEE;EAAY,CAAC,GAAGD,aAAa;EACrC,MAAME,SAAS,GAAGD,WAAW,EAAEE,YAAY,CAAC,CAAC;EAE7C,IAAIC,KAAK;EAET,SAASC,QAAQA,CAAA,EAAG;IACnB,OAAOH,SAAS,CAACI,UAAU,GAAGJ,SAAS,CAACK,UAAU,CAAE,CAAE,CAAC,GAAG,IAAI;EAC/D;EAEA,SAASC,MAAMA,CAAEC,KAAK,EAAG;IACxB,MAAMC,IAAI,GAAGD,KAAK,CAACC,IAAI,KAAK,SAAS,GAAG,OAAO,GAAG,WAAW;IAE7D,SAASC,QAAQA,CAAA,EAAG;MACnBX,aAAa,CAACY,mBAAmB,CAAEF,IAAI,EAAEG,IAAK,CAAC;MAC/Cb,aAAa,CAACY,mBAAmB,CAAE,iBAAiB,EAAED,QAAS,CAAC;MAChEX,aAAa,CAACY,mBAAmB,CAAE,OAAO,EAAED,QAAS,CAAC;IACvD;IAEA,SAASE,IAAIA,CAAA,EAAG;MACfF,QAAQ,CAAC,CAAC;MACV,IAAK,IAAAG,0BAAY,EAAEV,KAAK,EAAEC,QAAQ,CAAC,CAAE,CAAC,EAAG;QACxC;MACD;MACAL,aAAa,CAACe,aAAa,CAAE,IAAIC,KAAK,CAAE,iBAAkB,CAAE,CAAC;IAC9D;IAEAhB,aAAa,CAACiB,gBAAgB,CAAEP,IAAI,EAAEG,IAAK,CAAC;IAC5Cb,aAAa,CAACiB,gBAAgB,CAAE,iBAAiB,EAAEN,QAAS,CAAC;IAC7DX,aAAa,CAACiB,gBAAgB,CAAE,OAAO,EAAEN,QAAS,CAAC;IAEnDP,KAAK,GAAGC,QAAQ,CAAC,CAAC;EACnB;EAEAN,OAAO,CAACkB,gBAAgB,CAAE,aAAa,EAAET,MAAO,CAAC;EACjDT,OAAO,CAACkB,gBAAgB,CAAE,SAAS,EAAET,MAAO,CAAC;EAC7C,OAAO,MAAM;IACZT,OAAO,CAACa,mBAAmB,CAAE,aAAa,EAAEJ,MAAO,CAAC;IACpDT,OAAO,CAACa,mBAAmB,CAAE,SAAS,EAAEJ,MAAO,CAAC;EACjD,CAAC;AACF,CAAC;AAAAU,OAAA,CAAAC,OAAA,GAAArB,QAAA","ignoreList":[]}

View File

@@ -0,0 +1,207 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = __experimentalRichText;
exports.useRichText = useRichText;
var _element = require("@wordpress/element");
var _compose = require("@wordpress/compose");
var _data = require("@wordpress/data");
var _create = require("../create");
var _toDom = require("../to-dom");
var _toHtmlString = require("../to-html-string");
var _useDefaultStyle = require("./use-default-style");
var _useBoundaryStyle = require("./use-boundary-style");
var _eventListeners = require("./event-listeners");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function useRichText({
value = '',
selectionStart,
selectionEnd,
placeholder,
onSelectionChange,
preserveWhiteSpace,
onChange,
__unstableDisableFormats: disableFormats,
__unstableIsSelected: isSelected,
__unstableDependencies = [],
__unstableAfterParse,
__unstableBeforeSerialize,
__unstableAddInvisibleFormats
}) {
const registry = (0, _data.useRegistry)();
const [, forceRender] = (0, _element.useReducer)(() => ({}));
const ref = (0, _element.useRef)();
function createRecord() {
const {
ownerDocument: {
defaultView
}
} = ref.current;
const selection = defaultView.getSelection();
const range = selection.rangeCount > 0 ? selection.getRangeAt(0) : null;
return (0, _create.create)({
element: ref.current,
range,
__unstableIsEditableTree: true
});
}
function applyRecord(newRecord, {
domOnly
} = {}) {
(0, _toDom.apply)({
value: newRecord,
current: ref.current,
prepareEditableTree: __unstableAddInvisibleFormats,
__unstableDomOnly: domOnly,
placeholder
});
}
// Internal values are updated synchronously, unlike props and state.
const _value = (0, _element.useRef)(value);
const record = (0, _element.useRef)();
function setRecordFromProps() {
_value.current = value;
record.current = value;
if (!(value instanceof _create.RichTextData)) {
record.current = value ? _create.RichTextData.fromHTMLString(value, {
preserveWhiteSpace
}) : _create.RichTextData.empty();
}
// To do: make rich text internally work with RichTextData.
record.current = {
text: record.current.text,
formats: record.current.formats,
replacements: record.current.replacements
};
if (disableFormats) {
record.current.formats = Array(value.length);
record.current.replacements = Array(value.length);
}
if (__unstableAfterParse) {
record.current.formats = __unstableAfterParse(record.current);
}
record.current.start = selectionStart;
record.current.end = selectionEnd;
}
const hadSelectionUpdate = (0, _element.useRef)(false);
if (!record.current) {
hadSelectionUpdate.current = isSelected;
setRecordFromProps();
} else if (selectionStart !== record.current.start || selectionEnd !== record.current.end) {
hadSelectionUpdate.current = isSelected;
record.current = {
...record.current,
start: selectionStart,
end: selectionEnd,
activeFormats: undefined
};
}
/**
* Sync the value to global state. The node tree and selection will also be
* updated if differences are found.
*
* @param {Object} newRecord The record to sync and apply.
*/
function handleChange(newRecord) {
record.current = newRecord;
applyRecord(newRecord);
if (disableFormats) {
_value.current = newRecord.text;
} else {
const newFormats = __unstableBeforeSerialize ? __unstableBeforeSerialize(newRecord) : newRecord.formats;
newRecord = {
...newRecord,
formats: newFormats
};
if (typeof value === 'string') {
_value.current = (0, _toHtmlString.toHTMLString)({
value: newRecord,
preserveWhiteSpace
});
} else {
_value.current = new _create.RichTextData(newRecord);
}
}
const {
start,
end,
formats,
text
} = record.current;
// Selection must be updated first, so it is recorded in history when
// the content change happens.
// We batch both calls to only attempt to rerender once.
registry.batch(() => {
onSelectionChange(start, end);
onChange(_value.current, {
__unstableFormats: formats,
__unstableText: text
});
});
forceRender();
}
function applyFromProps() {
setRecordFromProps();
applyRecord(record.current);
}
const didMount = (0, _element.useRef)(false);
// Value updates must happen synchonously to avoid overwriting newer values.
(0, _element.useLayoutEffect)(() => {
if (didMount.current && value !== _value.current) {
applyFromProps();
forceRender();
}
}, [value]);
// Value updates must happen synchonously to avoid overwriting newer values.
(0, _element.useLayoutEffect)(() => {
if (!hadSelectionUpdate.current) {
return;
}
if (ref.current.ownerDocument.activeElement !== ref.current) {
ref.current.focus();
}
applyRecord(record.current);
hadSelectionUpdate.current = false;
}, [hadSelectionUpdate.current]);
const mergedRefs = (0, _compose.useMergeRefs)([ref, (0, _useDefaultStyle.useDefaultStyle)(), (0, _useBoundaryStyle.useBoundaryStyle)({
record
}), (0, _eventListeners.useEventListeners)({
record,
handleChange,
applyRecord,
createRecord,
isSelected,
onSelectionChange,
forceRender
}), (0, _compose.useRefEffect)(() => {
applyFromProps();
didMount.current = true;
}, [placeholder, ...__unstableDependencies])]);
return {
value: record.current,
// 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.
getValue: () => record.current,
onChange: handleChange,
ref: mergedRefs
};
}
function __experimentalRichText() {}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,82 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useAnchorRef = useAnchorRef;
var _element = require("@wordpress/element");
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
var _getActiveFormat = require("../get-active-format");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* @template T
* @typedef {import('@wordpress/element').RefObject<T>} RefObject<T>
*/
/** @typedef {import('../register-format-type').WPFormat} WPFormat */
/** @typedef {import('../types').RichTextValue} RichTextValue */
/**
* This hook, to be used in a format type's Edit component, returns the active
* element that is formatted, or the selection range if no format is active.
* The returned value is meant to be used for positioning UI, e.g. by passing it
* to the `Popover` component.
*
* @param {Object} $1 Named parameters.
* @param {RefObject<HTMLElement>} $1.ref React ref of the element
* containing the editable content.
* @param {RichTextValue} $1.value Value to check for selection.
* @param {WPFormat} $1.settings The format type's settings.
*
* @return {Element|Range} The active element or selection range.
*/
function useAnchorRef({
ref,
value,
settings = {}
}) {
(0, _deprecated.default)('`useAnchorRef` hook', {
since: '6.1',
alternative: '`useAnchor` hook'
});
const {
tagName,
className,
name
} = settings;
const activeFormat = name ? (0, _getActiveFormat.getActiveFormat)(value, name) : undefined;
return (0, _element.useMemo)(() => {
if (!ref.current) {
return;
}
const {
ownerDocument: {
defaultView
}
} = ref.current;
const selection = defaultView.getSelection();
if (!selection.rangeCount) {
return;
}
const range = selection.getRangeAt(0);
if (!activeFormat) {
return range;
}
let element = range.startContainer;
// If the caret is right before the element, select the next element.
element = element.nextElementSibling || element;
while (element.nodeType !== element.ELEMENT_NODE) {
element = element.parentNode;
}
return element.closest(tagName + (className ? '.' + className : ''));
}, [activeFormat, value.start, value.end, tagName, className]);
}
//# sourceMappingURL=use-anchor-ref.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","_deprecated","_interopRequireDefault","_getActiveFormat","useAnchorRef","ref","value","settings","deprecated","since","alternative","tagName","className","name","activeFormat","getActiveFormat","undefined","useMemo","current","ownerDocument","defaultView","selection","getSelection","rangeCount","range","getRangeAt","element","startContainer","nextElementSibling","nodeType","ELEMENT_NODE","parentNode","closest","start","end"],"sources":["@wordpress/rich-text/src/component/use-anchor-ref.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { getActiveFormat } from '../get-active-format';\n\n/**\n * @template T\n * @typedef {import('@wordpress/element').RefObject<T>} RefObject<T>\n */\n/** @typedef {import('../register-format-type').WPFormat} WPFormat */\n/** @typedef {import('../types').RichTextValue} RichTextValue */\n\n/**\n * This hook, to be used in a format type's Edit component, returns the active\n * element that is formatted, or the selection range if no format is active.\n * The returned value is meant to be used for positioning UI, e.g. by passing it\n * to the `Popover` component.\n *\n * @param {Object} $1 Named parameters.\n * @param {RefObject<HTMLElement>} $1.ref React ref of the element\n * containing the editable content.\n * @param {RichTextValue} $1.value Value to check for selection.\n * @param {WPFormat} $1.settings The format type's settings.\n *\n * @return {Element|Range} The active element or selection range.\n */\nexport function useAnchorRef( { ref, value, settings = {} } ) {\n\tdeprecated( '`useAnchorRef` hook', {\n\t\tsince: '6.1',\n\t\talternative: '`useAnchor` hook',\n\t} );\n\n\tconst { tagName, className, name } = settings;\n\tconst activeFormat = name ? getActiveFormat( value, name ) : undefined;\n\n\treturn useMemo( () => {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst {\n\t\t\townerDocument: { defaultView },\n\t\t} = ref.current;\n\t\tconst selection = defaultView.getSelection();\n\n\t\tif ( ! selection.rangeCount ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst range = selection.getRangeAt( 0 );\n\n\t\tif ( ! activeFormat ) {\n\t\t\treturn range;\n\t\t}\n\n\t\tlet element = range.startContainer;\n\n\t\t// If the caret is right before the element, select the next element.\n\t\telement = element.nextElementSibling || element;\n\n\t\twhile ( element.nodeType !== element.ELEMENT_NODE ) {\n\t\t\telement = element.parentNode;\n\t\t}\n\n\t\treturn element.closest(\n\t\t\ttagName + ( className ? '.' + className : '' )\n\t\t);\n\t}, [ activeFormat, value.start, value.end, tagName, className ] );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,gBAAA,GAAAH,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,YAAYA,CAAE;EAAEC,GAAG;EAAEC,KAAK;EAAEC,QAAQ,GAAG,CAAC;AAAE,CAAC,EAAG;EAC7D,IAAAC,mBAAU,EAAE,qBAAqB,EAAE;IAClCC,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE;EACd,CAAE,CAAC;EAEH,MAAM;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EAAK,CAAC,GAAGN,QAAQ;EAC7C,MAAMO,YAAY,GAAGD,IAAI,GAAG,IAAAE,gCAAe,EAAET,KAAK,EAAEO,IAAK,CAAC,GAAGG,SAAS;EAEtE,OAAO,IAAAC,gBAAO,EAAE,MAAM;IACrB,IAAK,CAAEZ,GAAG,CAACa,OAAO,EAAG;MACpB;IACD;IACA,MAAM;MACLC,aAAa,EAAE;QAAEC;MAAY;IAC9B,CAAC,GAAGf,GAAG,CAACa,OAAO;IACf,MAAMG,SAAS,GAAGD,WAAW,CAACE,YAAY,CAAC,CAAC;IAE5C,IAAK,CAAED,SAAS,CAACE,UAAU,EAAG;MAC7B;IACD;IAEA,MAAMC,KAAK,GAAGH,SAAS,CAACI,UAAU,CAAE,CAAE,CAAC;IAEvC,IAAK,CAAEX,YAAY,EAAG;MACrB,OAAOU,KAAK;IACb;IAEA,IAAIE,OAAO,GAAGF,KAAK,CAACG,cAAc;;IAElC;IACAD,OAAO,GAAGA,OAAO,CAACE,kBAAkB,IAAIF,OAAO;IAE/C,OAAQA,OAAO,CAACG,QAAQ,KAAKH,OAAO,CAACI,YAAY,EAAG;MACnDJ,OAAO,GAAGA,OAAO,CAACK,UAAU;IAC7B;IAEA,OAAOL,OAAO,CAACM,OAAO,CACrBrB,OAAO,IAAKC,SAAS,GAAG,GAAG,GAAGA,SAAS,GAAG,EAAE,CAC7C,CAAC;EACF,CAAC,EAAE,CAAEE,YAAY,EAAER,KAAK,CAAC2B,KAAK,EAAE3B,KAAK,CAAC4B,GAAG,EAAEvB,OAAO,EAAEC,SAAS,CAAG,CAAC;AAClE","ignoreList":[]}

View File

@@ -0,0 +1,190 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useAnchor = useAnchor;
var _compose = require("@wordpress/compose");
var _element = require("@wordpress/element");
/**
* WordPress dependencies
*/
/** @typedef {import('../register-format-type').WPFormat} WPFormat */
/** @typedef {import('../types').RichTextValue} RichTextValue */
/**
* Given a range and a format tag name and class name, returns the closest
* format element.
*
* @param {Range} range The Range to check.
* @param {HTMLElement} editableContentElement The editable wrapper.
* @param {string} tagName The tag name of the format element.
* @param {string} className The class name of the format element.
*
* @return {HTMLElement|undefined} The format element, if found.
*/
function getFormatElement(range, editableContentElement, tagName, className) {
let element = range.startContainer;
// Even if the active format is defined, the actualy DOM range's start
// container may be outside of the format's DOM element:
// `a‸<strong>b</strong>` (DOM) while visually it's `a<strong>‸b</strong>`.
// So at a given selection index, start with the deepest format DOM element.
if (element.nodeType === element.TEXT_NODE && range.startOffset === element.length && element.nextSibling) {
element = element.nextSibling;
while (element.firstChild) {
element = element.firstChild;
}
}
if (element.nodeType !== element.ELEMENT_NODE) {
element = element.parentElement;
}
if (!element) {
return;
}
if (element === editableContentElement) {
return;
}
if (!editableContentElement.contains(element)) {
return;
}
const selector = tagName + (className ? '.' + className : '');
// .closest( selector ), but with a boundary. Check if the element matches
// the selector. If it doesn't match, try the parent element if it's not the
// editable wrapper. We don't want to try to match ancestors of the editable
// wrapper, which is what .closest( selector ) would do. When the element is
// the editable wrapper (which is most likely the case because most text is
// unformatted), this never runs.
while (element !== editableContentElement) {
if (element.matches(selector)) {
return element;
}
element = element.parentElement;
}
}
/**
* @typedef {Object} VirtualAnchorElement
* @property {() => DOMRect} getBoundingClientRect A function returning a DOMRect
* @property {HTMLElement} contextElement The actual DOM element
*/
/**
* Creates a virtual anchor element for a range.
*
* @param {Range} range The range to create a virtual anchor element for.
* @param {HTMLElement} editableContentElement The editable wrapper.
*
* @return {VirtualAnchorElement} The virtual anchor element.
*/
function createVirtualAnchorElement(range, editableContentElement) {
return {
contextElement: editableContentElement,
getBoundingClientRect() {
return editableContentElement.contains(range.startContainer) ? range.getBoundingClientRect() : editableContentElement.getBoundingClientRect();
}
};
}
/**
* Get the anchor: a format element if there is a matching one based on the
* tagName and className or a range otherwise.
*
* @param {HTMLElement} editableContentElement The editable wrapper.
* @param {string} tagName The tag name of the format
* element.
* @param {string} className The class name of the format
* element.
*
* @return {HTMLElement|VirtualAnchorElement|undefined} The anchor.
*/
function getAnchor(editableContentElement, tagName, className) {
if (!editableContentElement) {
return;
}
const {
ownerDocument
} = editableContentElement;
const {
defaultView
} = ownerDocument;
const selection = defaultView.getSelection();
if (!selection) {
return;
}
if (!selection.rangeCount) {
return;
}
const range = selection.getRangeAt(0);
if (!range || !range.startContainer) {
return;
}
const formatElement = getFormatElement(range, editableContentElement, tagName, className);
if (formatElement) {
return formatElement;
}
return createVirtualAnchorElement(range, editableContentElement);
}
/**
* This hook, to be used in a format type's Edit component, returns the active
* element that is formatted, or a virtual element for the selection range if
* no format is active. The returned value is meant to be used for positioning
* UI, e.g. by passing it to the `Popover` component via the `anchor` prop.
*
* @param {Object} $1 Named parameters.
* @param {HTMLElement|null} $1.editableContentElement The element containing
* the editable content.
* @param {WPFormat=} $1.settings The format type's settings.
* @return {Element|VirtualAnchorElement|undefined|null} The active element or selection range.
*/
function useAnchor({
editableContentElement,
settings = {}
}) {
const {
tagName,
className,
isActive
} = settings;
const [anchor, setAnchor] = (0, _element.useState)(() => getAnchor(editableContentElement, tagName, className));
const wasActive = (0, _compose.usePrevious)(isActive);
(0, _element.useLayoutEffect)(() => {
if (!editableContentElement) {
return;
}
function callback() {
setAnchor(getAnchor(editableContentElement, tagName, className));
}
function attach() {
ownerDocument.addEventListener('selectionchange', callback);
}
function detach() {
ownerDocument.removeEventListener('selectionchange', callback);
}
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.
// 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) {
setAnchor(getAnchor(editableContentElement, tagName, className));
attach();
}
editableContentElement.addEventListener('focusin', attach);
editableContentElement.addEventListener('focusout', detach);
return () => {
detach();
editableContentElement.removeEventListener('focusin', attach);
editableContentElement.removeEventListener('focusout', detach);
};
}, [editableContentElement, tagName, className, isActive, wasActive]);
return anchor;
}
//# sourceMappingURL=use-anchor.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,61 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useBoundaryStyle = useBoundaryStyle;
var _element = require("@wordpress/element");
/**
* WordPress dependencies
*/
/*
* Calculates and renders the format boundary style when the active formats
* change.
*/
function useBoundaryStyle({
record
}) {
const ref = (0, _element.useRef)();
const {
activeFormats = [],
replacements,
start
} = record.current;
const activeReplacement = replacements[start];
(0, _element.useEffect)(() => {
// There's no need to recalculate the boundary styles if no formats are
// active, because no boundary styles will be visible.
if ((!activeFormats || !activeFormats.length) && !activeReplacement) {
return;
}
const boundarySelector = '*[data-rich-text-format-boundary]';
const element = ref.current.querySelector(boundarySelector);
if (!element) {
return;
}
const {
ownerDocument
} = element;
const {
defaultView
} = ownerDocument;
const computedStyle = defaultView.getComputedStyle(element);
const newColor = computedStyle.color.replace(')', ', 0.2)').replace('rgb', 'rgba');
const selector = `.rich-text:focus ${boundarySelector}`;
const rule = `background-color: ${newColor}`;
const style = `${selector} {${rule}}`;
const globalStyleId = 'rich-text-boundary-style';
let globalStyle = ownerDocument.getElementById(globalStyleId);
if (!globalStyle) {
globalStyle = ownerDocument.createElement('style');
globalStyle.id = globalStyleId;
ownerDocument.head.appendChild(globalStyle);
}
if (globalStyle.innerHTML !== style) {
globalStyle.innerHTML = style;
}
}, [activeFormats, activeReplacement]);
return ref;
}
//# sourceMappingURL=use-boundary-style.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","useBoundaryStyle","record","ref","useRef","activeFormats","replacements","start","current","activeReplacement","useEffect","length","boundarySelector","element","querySelector","ownerDocument","defaultView","computedStyle","getComputedStyle","newColor","color","replace","selector","rule","style","globalStyleId","globalStyle","getElementById","createElement","id","head","appendChild","innerHTML"],"sources":["@wordpress/rich-text/src/component/use-boundary-style.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\n\n/*\n * Calculates and renders the format boundary style when the active formats\n * change.\n */\nexport function useBoundaryStyle( { record } ) {\n\tconst ref = useRef();\n\tconst { activeFormats = [], replacements, start } = record.current;\n\tconst activeReplacement = replacements[ start ];\n\tuseEffect( () => {\n\t\t// There's no need to recalculate the boundary styles if no formats are\n\t\t// active, because no boundary styles will be visible.\n\t\tif (\n\t\t\t( ! activeFormats || ! activeFormats.length ) &&\n\t\t\t! activeReplacement\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst boundarySelector = '*[data-rich-text-format-boundary]';\n\t\tconst element = ref.current.querySelector( boundarySelector );\n\n\t\tif ( ! element ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst computedStyle = defaultView.getComputedStyle( element );\n\t\tconst newColor = computedStyle.color\n\t\t\t.replace( ')', ', 0.2)' )\n\t\t\t.replace( 'rgb', 'rgba' );\n\t\tconst selector = `.rich-text:focus ${ boundarySelector }`;\n\t\tconst rule = `background-color: ${ newColor }`;\n\t\tconst style = `${ selector } {${ rule }}`;\n\t\tconst globalStyleId = 'rich-text-boundary-style';\n\n\t\tlet globalStyle = ownerDocument.getElementById( globalStyleId );\n\n\t\tif ( ! globalStyle ) {\n\t\t\tglobalStyle = ownerDocument.createElement( 'style' );\n\t\t\tglobalStyle.id = globalStyleId;\n\t\t\townerDocument.head.appendChild( globalStyle );\n\t\t}\n\n\t\tif ( globalStyle.innerHTML !== style ) {\n\t\t\tglobalStyle.innerHTML = style;\n\t\t}\n\t}, [ activeFormats, activeReplacement ] );\n\treturn ref;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAE;EAAEC;AAAO,CAAC,EAAG;EAC9C,MAAMC,GAAG,GAAG,IAAAC,eAAM,EAAC,CAAC;EACpB,MAAM;IAAEC,aAAa,GAAG,EAAE;IAAEC,YAAY;IAAEC;EAAM,CAAC,GAAGL,MAAM,CAACM,OAAO;EAClE,MAAMC,iBAAiB,GAAGH,YAAY,CAAEC,KAAK,CAAE;EAC/C,IAAAG,kBAAS,EAAE,MAAM;IAChB;IACA;IACA,IACC,CAAE,CAAEL,aAAa,IAAI,CAAEA,aAAa,CAACM,MAAM,KAC3C,CAAEF,iBAAiB,EAClB;MACD;IACD;IAEA,MAAMG,gBAAgB,GAAG,mCAAmC;IAC5D,MAAMC,OAAO,GAAGV,GAAG,CAACK,OAAO,CAACM,aAAa,CAAEF,gBAAiB,CAAC;IAE7D,IAAK,CAAEC,OAAO,EAAG;MAChB;IACD;IAEA,MAAM;MAAEE;IAAc,CAAC,GAAGF,OAAO;IACjC,MAAM;MAAEG;IAAY,CAAC,GAAGD,aAAa;IACrC,MAAME,aAAa,GAAGD,WAAW,CAACE,gBAAgB,CAAEL,OAAQ,CAAC;IAC7D,MAAMM,QAAQ,GAAGF,aAAa,CAACG,KAAK,CAClCC,OAAO,CAAE,GAAG,EAAE,QAAS,CAAC,CACxBA,OAAO,CAAE,KAAK,EAAE,MAAO,CAAC;IAC1B,MAAMC,QAAQ,GAAI,oBAAoBV,gBAAkB,EAAC;IACzD,MAAMW,IAAI,GAAI,qBAAqBJ,QAAU,EAAC;IAC9C,MAAMK,KAAK,GAAI,GAAGF,QAAU,KAAKC,IAAM,GAAE;IACzC,MAAME,aAAa,GAAG,0BAA0B;IAEhD,IAAIC,WAAW,GAAGX,aAAa,CAACY,cAAc,CAAEF,aAAc,CAAC;IAE/D,IAAK,CAAEC,WAAW,EAAG;MACpBA,WAAW,GAAGX,aAAa,CAACa,aAAa,CAAE,OAAQ,CAAC;MACpDF,WAAW,CAACG,EAAE,GAAGJ,aAAa;MAC9BV,aAAa,CAACe,IAAI,CAACC,WAAW,CAAEL,WAAY,CAAC;IAC9C;IAEA,IAAKA,WAAW,CAACM,SAAS,KAAKR,KAAK,EAAG;MACtCE,WAAW,CAACM,SAAS,GAAGR,KAAK;IAC9B;EACD,CAAC,EAAE,CAAEnB,aAAa,EAAEI,iBAAiB,CAAG,CAAC;EACzC,OAAON,GAAG;AACX","ignoreList":[]}

View File

@@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useDefaultStyle = useDefaultStyle;
var _element = require("@wordpress/element");
/**
* WordPress dependencies
*/
/**
* In HTML, leading and trailing spaces are not visible, and multiple spaces
* elsewhere are visually reduced to one space. This rule prevents spaces from
* collapsing so all space is visible in the editor and can be removed. It also
* prevents some browsers from inserting non-breaking spaces at the end of a
* line to prevent the space from visually disappearing. Sometimes these non
* breaking spaces can linger in the editor causing unwanted non breaking spaces
* in between words. If also prevent Firefox from inserting a trailing `br` node
* to visualise any trailing space, causing the element to be saved.
*
* > Authors are encouraged to set the 'white-space' property on editing hosts
* > and on markup that was originally created through these editing mechanisms
* > to the value 'pre-wrap'. Default HTML whitespace handling is not well
* > suited to WYSIWYG editing, and line wrapping will not work correctly in
* > some corner cases if 'white-space' is left at its default value.
*
* https://html.spec.whatwg.org/multipage/interaction.html#best-practices-for-in-page-editors
*
* @type {string}
*/
const whiteSpace = 'pre-wrap';
/**
* A minimum width of 1px will prevent the rich text container from collapsing
* to 0 width and hiding the caret. This is useful for inline containers.
*/
const minWidth = '1px';
function useDefaultStyle() {
return (0, _element.useCallback)(element => {
if (!element) {
return;
}
element.style.whiteSpace = whiteSpace;
element.style.minWidth = minWidth;
}, []);
}
//# sourceMappingURL=use-default-style.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","whiteSpace","minWidth","useDefaultStyle","useCallback","element","style"],"sources":["@wordpress/rich-text/src/component/use-default-style.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\n/**\n * In HTML, leading and trailing spaces are not visible, and multiple spaces\n * elsewhere are visually reduced to one space. This rule prevents spaces from\n * collapsing so all space is visible in the editor and can be removed. It also\n * prevents some browsers from inserting non-breaking spaces at the end of a\n * line to prevent the space from visually disappearing. Sometimes these non\n * breaking spaces can linger in the editor causing unwanted non breaking spaces\n * in between words. If also prevent Firefox from inserting a trailing `br` node\n * to visualise any trailing space, causing the element to be saved.\n *\n * > Authors are encouraged to set the 'white-space' property on editing hosts\n * > and on markup that was originally created through these editing mechanisms\n * > to the value 'pre-wrap'. Default HTML whitespace handling is not well\n * > suited to WYSIWYG editing, and line wrapping will not work correctly in\n * > some corner cases if 'white-space' is left at its default value.\n *\n * https://html.spec.whatwg.org/multipage/interaction.html#best-practices-for-in-page-editors\n *\n * @type {string}\n */\nconst whiteSpace = 'pre-wrap';\n\n/**\n * A minimum width of 1px will prevent the rich text container from collapsing\n * to 0 width and hiding the caret. This is useful for inline containers.\n */\nconst minWidth = '1px';\n\nexport function useDefaultStyle() {\n\treturn useCallback( ( element ) => {\n\t\tif ( ! element ) {\n\t\t\treturn;\n\t\t}\n\t\telement.style.whiteSpace = whiteSpace;\n\t\telement.style.minWidth = minWidth;\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAG,UAAU;;AAE7B;AACA;AACA;AACA;AACA,MAAMC,QAAQ,GAAG,KAAK;AAEf,SAASC,eAAeA,CAAA,EAAG;EACjC,OAAO,IAAAC,oBAAW,EAAIC,OAAO,IAAM;IAClC,IAAK,CAAEA,OAAO,EAAG;MAChB;IACD;IACAA,OAAO,CAACC,KAAK,CAACL,UAAU,GAAGA,UAAU;IACrCI,OAAO,CAACC,KAAK,CAACJ,QAAQ,GAAGA,QAAQ;EAClC,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}

43
node_modules/@wordpress/rich-text/build/concat.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.concat = concat;
exports.mergePair = mergePair;
var _normaliseFormats = require("./normalise-formats");
var _create = require("./create");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Concats a pair of rich text values. Not that this mutates `a` and does NOT
* normalise formats!
*
* @param {Object} a Value to mutate.
* @param {Object} b Value to add read from.
*
* @return {Object} `a`, mutated.
*/
function mergePair(a, b) {
a.formats = a.formats.concat(b.formats);
a.replacements = a.replacements.concat(b.replacements);
a.text += b.text;
return a;
}
/**
* Combine all Rich Text values into one. This is similar to
* `String.prototype.concat`.
*
* @param {...RichTextValue} values Objects to combine.
*
* @return {RichTextValue} A new value combining all given records.
*/
function concat(...values) {
return (0, _normaliseFormats.normaliseFormats)(values.reduce(mergePair, (0, _create.create)()));
}
//# sourceMappingURL=concat.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_normaliseFormats","require","_create","mergePair","a","b","formats","concat","replacements","text","values","normaliseFormats","reduce","create"],"sources":["@wordpress/rich-text/src/concat.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nimport { normaliseFormats } from './normalise-formats';\nimport { create } from './create';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Concats a pair of rich text values. Not that this mutates `a` and does NOT\n * normalise formats!\n *\n * @param {Object} a Value to mutate.\n * @param {Object} b Value to add read from.\n *\n * @return {Object} `a`, mutated.\n */\nexport function mergePair( a, b ) {\n\ta.formats = a.formats.concat( b.formats );\n\ta.replacements = a.replacements.concat( b.replacements );\n\ta.text += b.text;\n\n\treturn a;\n}\n\n/**\n * Combine all Rich Text values into one. This is similar to\n * `String.prototype.concat`.\n *\n * @param {...RichTextValue} values Objects to combine.\n *\n * @return {RichTextValue} A new value combining all given records.\n */\nexport function concat( ...values ) {\n\treturn normaliseFormats( values.reduce( mergePair, create() ) );\n}\n"],"mappings":";;;;;;;AAIA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,SAASA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACjCD,CAAC,CAACE,OAAO,GAAGF,CAAC,CAACE,OAAO,CAACC,MAAM,CAAEF,CAAC,CAACC,OAAQ,CAAC;EACzCF,CAAC,CAACI,YAAY,GAAGJ,CAAC,CAACI,YAAY,CAACD,MAAM,CAAEF,CAAC,CAACG,YAAa,CAAC;EACxDJ,CAAC,CAACK,IAAI,IAAIJ,CAAC,CAACI,IAAI;EAEhB,OAAOL,CAAC;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,MAAMA,CAAE,GAAGG,MAAM,EAAG;EACnC,OAAO,IAAAC,kCAAgB,EAAED,MAAM,CAACE,MAAM,CAAET,SAAS,EAAE,IAAAU,cAAM,EAAC,CAAE,CAAE,CAAC;AAChE","ignoreList":[]}

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createElement = createElement;
/**
* Parse the given HTML into a body element.
*
* Note: The current implementation will return a shared reference, reset on
* each call to `createElement`. Therefore, you should not hold a reference to
* the value to operate upon asynchronously, as it may have unexpected results.
*
* @param {HTMLDocument} document The HTML document to use to parse.
* @param {string} html The HTML to parse.
*
* @return {HTMLBodyElement} Body element with parsed HTML.
*/
function createElement({
implementation
}, html) {
// Because `createHTMLDocument` is an expensive operation, and with this
// function being internal to `rich-text` (full control in avoiding a risk
// of asynchronous operations on the shared reference), a single document
// is reused and reset for each call to the function.
if (!createElement.body) {
createElement.body = implementation.createHTMLDocument('').body;
}
createElement.body.innerHTML = html;
return createElement.body;
}
//# sourceMappingURL=create-element.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createElement","implementation","html","body","createHTMLDocument","innerHTML"],"sources":["@wordpress/rich-text/src/create-element.js"],"sourcesContent":["/**\n * Parse the given HTML into a body element.\n *\n * Note: The current implementation will return a shared reference, reset on\n * each call to `createElement`. Therefore, you should not hold a reference to\n * the value to operate upon asynchronously, as it may have unexpected results.\n *\n * @param {HTMLDocument} document The HTML document to use to parse.\n * @param {string} html The HTML to parse.\n *\n * @return {HTMLBodyElement} Body element with parsed HTML.\n */\nexport function createElement( { implementation }, html ) {\n\t// Because `createHTMLDocument` is an expensive operation, and with this\n\t// function being internal to `rich-text` (full control in avoiding a risk\n\t// of asynchronous operations on the shared reference), a single document\n\t// is reused and reset for each call to the function.\n\tif ( ! createElement.body ) {\n\t\tcreateElement.body = implementation.createHTMLDocument( '' ).body;\n\t}\n\n\tcreateElement.body.innerHTML = html;\n\n\treturn createElement.body;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAAE;EAAEC;AAAe,CAAC,EAAEC,IAAI,EAAG;EACzD;EACA;EACA;EACA;EACA,IAAK,CAAEF,aAAa,CAACG,IAAI,EAAG;IAC3BH,aAAa,CAACG,IAAI,GAAGF,cAAc,CAACG,kBAAkB,CAAE,EAAG,CAAC,CAACD,IAAI;EAClE;EAEAH,aAAa,CAACG,IAAI,CAACE,SAAS,GAAGH,IAAI;EAEnC,OAAOF,aAAa,CAACG,IAAI;AAC1B","ignoreList":[]}

594
node_modules/@wordpress/rich-text/build/create.js generated vendored Normal file
View File

@@ -0,0 +1,594 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RichTextData = void 0;
exports.create = create;
exports.removeReservedCharacters = removeReservedCharacters;
var _data = require("@wordpress/data");
var _store = require("./store");
var _createElement = require("./create-element");
var _concat = require("./concat");
var _specialCharacters = require("./special-characters");
var _toHtmlString = require("./to-html-string");
var _getTextContent = require("./get-text-content");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
function createEmptyValue() {
return {
formats: [],
replacements: [],
text: ''
};
}
function toFormat({
tagName,
attributes
}) {
let formatType;
if (attributes && attributes.class) {
formatType = (0, _data.select)(_store.store).getFormatTypeForClassName(attributes.class);
if (formatType) {
// Preserve any additional classes.
attributes.class = ` ${attributes.class} `.replace(` ${formatType.className} `, ' ').trim();
if (!attributes.class) {
delete attributes.class;
}
}
}
if (!formatType) {
formatType = (0, _data.select)(_store.store).getFormatTypeForBareElement(tagName);
}
if (!formatType) {
return attributes ? {
type: tagName,
attributes
} : {
type: tagName
};
}
if (formatType.__experimentalCreatePrepareEditableTree && !formatType.__experimentalCreateOnChangeEditableValue) {
return null;
}
if (!attributes) {
return {
formatType,
type: formatType.name,
tagName
};
}
const registeredAttributes = {};
const unregisteredAttributes = {};
const _attributes = {
...attributes
};
for (const key in formatType.attributes) {
const name = formatType.attributes[key];
registeredAttributes[key] = _attributes[name];
// delete the attribute and what's left is considered
// to be unregistered.
delete _attributes[name];
if (typeof registeredAttributes[key] === 'undefined') {
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
};
}
/**
* The RichTextData class is used to instantiate a wrapper around rich text
* values, with methods that can be used to transform or manipulate the data.
*
* - Create an empty instance: `new RichTextData()`.
* - Create one from an HTML string: `RichTextData.fromHTMLString(
* '<em>hello</em>' )`.
* - Create one from a wrapper HTMLElement: `RichTextData.fromHTMLElement(
* document.querySelector( 'p' ) )`.
* - Create one from plain text: `RichTextData.fromPlainText( '1\n2' )`.
* - Create one from a rich text value: `new RichTextData( { text: '...',
* formats: [ ... ] } )`.
*
* @todo Add methods to manipulate the data, such as applyFormat, slice etc.
*/
class RichTextData {
#value;
static empty() {
return new RichTextData();
}
static fromPlainText(text) {
return new RichTextData(create({
text
}));
}
static fromHTMLString(html) {
return new RichTextData(create({
html
}));
}
static fromHTMLElement(htmlElement, options = {}) {
const {
preserveWhiteSpace = false
} = options;
const element = preserveWhiteSpace ? htmlElement : collapseWhiteSpace(htmlElement);
const richTextData = new RichTextData(create({
element
}));
Object.defineProperty(richTextData, 'originalHTML', {
value: htmlElement.innerHTML
});
return richTextData;
}
constructor(init = createEmptyValue()) {
this.#value = init;
}
toPlainText() {
return (0, _getTextContent.getTextContent)(this.#value);
}
// We could expose `toHTMLElement` at some point as well, but we'd only use
// it internally.
toHTMLString({
preserveWhiteSpace
} = {}) {
return this.originalHTML || (0, _toHtmlString.toHTMLString)({
value: this.#value,
preserveWhiteSpace
});
}
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;
}
}
exports.RichTextData = RichTextData;
for (const name of Object.getOwnPropertyNames(String.prototype)) {
if (RichTextData.prototype.hasOwnProperty(name)) {
continue;
}
Object.defineProperty(RichTextData.prototype, name, {
value(...args) {
// Should we convert back to RichTextData?
return this.toHTMLString()[name](...args);
}
});
}
/**
* Create a RichText value from an `Element` tree (DOM), an HTML string or a
* plain text string, with optionally a `Range` object to set the selection. If
* called without any input, an empty value will be created. The optional
* functions can be used to filter out content.
*
* A value will have the following shape, which you are strongly encouraged not
* to modify without the use of helper functions:
*
* ```js
* {
* text: string,
* formats: Array,
* replacements: Array,
* ?start: number,
* ?end: number,
* }
* ```
*
* As you can see, text and formatting are separated. `text` holds the text,
* including any replacement characters for objects and lines. `formats`,
* `objects` and `lines` are all sparse arrays of the same length as `text`. It
* holds information about the formatting at the relevant text indices. Finally
* `start` and `end` state which text indices are selected. They are only
* provided if a `Range` was given.
*
* @param {Object} [$1] Optional named arguments.
* @param {Element} [$1.element] Element to create value from.
* @param {string} [$1.text] Text to create value from.
* @param {string} [$1.html] HTML to create value from.
* @param {Range} [$1.range] Range to create value from.
* @param {boolean} [$1.__unstableIsEditableTree]
* @return {RichTextValue} A rich text value.
*/
function create({
element,
text,
html,
range,
__unstableIsEditableTree: isEditableTree
} = {}) {
if (html instanceof RichTextData) {
return {
text: html.text,
formats: html.formats,
replacements: html.replacements
};
}
if (typeof text === 'string' && text.length > 0) {
return {
formats: Array(text.length),
replacements: Array(text.length),
text
};
}
if (typeof html === 'string' && html.length > 0) {
// It does not matter which document this is, we're just using it to
// parse.
element = (0, _createElement.createElement)(document, html);
}
if (typeof element !== 'object') {
return createEmptyValue();
}
return createFromElement({
element,
range,
isEditableTree
});
}
/**
* Helper to accumulate the value's selection start and end from the current
* node and range.
*
* @param {Object} accumulator Object to accumulate into.
* @param {Node} node Node to create value with.
* @param {Range} range Range to create value with.
* @param {Object} value Value that is being accumulated.
*/
function accumulateSelection(accumulator, node, range, value) {
if (!range) {
return;
}
const {
parentNode
} = node;
const {
startContainer,
startOffset,
endContainer,
endOffset
} = range;
const currentLength = accumulator.text.length;
// Selection can be extracted from value.
if (value.start !== undefined) {
accumulator.start = currentLength + value.start;
// Range indicates that the current node has selection.
} else if (node === startContainer && node.nodeType === node.TEXT_NODE) {
accumulator.start = currentLength + startOffset;
// Range indicates that the current node is selected.
} else if (parentNode === startContainer && node === startContainer.childNodes[startOffset]) {
accumulator.start = currentLength;
// Range indicates that the selection is after the current node.
} else if (parentNode === startContainer && node === startContainer.childNodes[startOffset - 1]) {
accumulator.start = currentLength + value.text.length;
// Fallback if no child inside handled the selection.
} else if (node === startContainer) {
accumulator.start = currentLength;
}
// Selection can be extracted from value.
if (value.end !== undefined) {
accumulator.end = currentLength + value.end;
// Range indicates that the current node has selection.
} else if (node === endContainer && node.nodeType === node.TEXT_NODE) {
accumulator.end = currentLength + endOffset;
// Range indicates that the current node is selected.
} else if (parentNode === endContainer && node === endContainer.childNodes[endOffset - 1]) {
accumulator.end = currentLength + value.text.length;
// Range indicates that the selection is before the current node.
} else if (parentNode === endContainer && node === endContainer.childNodes[endOffset]) {
accumulator.end = currentLength;
// Fallback if no child inside handled the selection.
} else if (node === endContainer) {
accumulator.end = currentLength + endOffset;
}
}
/**
* Adjusts the start and end offsets from a range based on a text filter.
*
* @param {Node} node Node of which the text should be filtered.
* @param {Range} range The range to filter.
* @param {Function} filter Function to use to filter the text.
*
* @return {Object|void} Object containing range properties.
*/
function filterRange(node, range, filter) {
if (!range) {
return;
}
const {
startContainer,
endContainer
} = range;
let {
startOffset,
endOffset
} = range;
if (node === startContainer) {
startOffset = filter(node.nodeValue.slice(0, startOffset)).length;
}
if (node === endContainer) {
endOffset = filter(node.nodeValue.slice(0, endOffset)).length;
}
return {
startContainer,
startOffset,
endContainer,
endOffset
};
}
/**
* Collapse any whitespace used for HTML formatting to one space character,
* because it will also be displayed as such by the browser.
*
* We need to strip it from the content because we use white-space: pre-wrap for
* displaying editable rich text. Without using white-space: pre-wrap, the
* browser will litter the content with non breaking spaces, among other issues.
* See packages/rich-text/src/component/use-default-style.js.
*
* @see
* https://developer.mozilla.org/en-US/docs/Web/CSS/white-space-collapse#collapsing_of_white_space
*
* @param {HTMLElement} element
* @param {boolean} isRoot
*
* @return {HTMLElement} New element with collapsed whitespace.
*/
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)) {
newNodeValue = newNodeValue.replace(/[\n\t\r\f]+/g, ' ');
}
if (newNodeValue.indexOf(' ') !== -1) {
newNodeValue = newNodeValue.replace(/ {2,}/g, ' ');
}
if (i === 0 && newNodeValue.startsWith(' ')) {
newNodeValue = newNodeValue.slice(1);
} else if (isRoot && i === nodes.length - 1 && newNodeValue.endsWith(' ')) {
newNodeValue = newNodeValue.slice(0, -1);
}
node.nodeValue = newNodeValue;
} else if (node.nodeType === node.ELEMENT_NODE) {
collapseWhiteSpace(node, false);
}
});
return clone;
}
/**
* We need to normalise line breaks to `\n` so they are consistent across
* platforms and serialised properly. Not removing \r would cause it to
* linger and result in double line breaks when whitespace is preserved.
*/
const CARRIAGE_RETURN = '\r';
/**
* Removes reserved characters used by rich-text (zero width non breaking spaces
* added by `toTree` and object replacement characters).
*
* @param {string} string
*/
function removeReservedCharacters(string) {
// with the global flag, note that we should create a new regex each time OR
// reset lastIndex state.
return string.replace(new RegExp(`[${_specialCharacters.ZWNBSP}${_specialCharacters.OBJECT_REPLACEMENT_CHARACTER}${CARRIAGE_RETURN}]`, 'gu'), '');
}
/**
* Creates a Rich Text value from a DOM element and range.
*
* @param {Object} $1 Named argements.
* @param {Element} [$1.element] Element to create value from.
* @param {Range} [$1.range] Range to create value from.
* @param {boolean} [$1.isEditableTree]
*
* @return {RichTextValue} A rich text value.
*/
function createFromElement({
element,
range,
isEditableTree
}) {
const accumulator = createEmptyValue();
if (!element) {
return accumulator;
}
if (!element.hasChildNodes()) {
accumulateSelection(accumulator, element, range, createEmptyValue());
return accumulator;
}
const length = element.childNodes.length;
// Optimise for speed.
for (let index = 0; index < length; index++) {
const node = element.childNodes[index];
const tagName = node.nodeName.toLowerCase();
if (node.nodeType === node.TEXT_NODE) {
const text = removeReservedCharacters(node.nodeValue);
range = filterRange(node, range, removeReservedCharacters);
accumulateSelection(accumulator, node, range, {
text
});
// Create a sparse array of the same length as `text`, in which
// formats can be added.
accumulator.formats.length += text.length;
accumulator.replacements.length += text.length;
accumulator.text += text;
continue;
}
if (node.nodeType !== node.ELEMENT_NODE) {
continue;
}
if (isEditableTree &&
// Ignore any line breaks that are not inserted by us.
tagName === 'br' && !node.getAttribute('data-rich-text-line-break')) {
accumulateSelection(accumulator, node, range, createEmptyValue());
continue;
}
if (tagName === 'script') {
const value = {
formats: [,],
replacements: [{
type: tagName,
attributes: {
'data-rich-text-script': node.getAttribute('data-rich-text-script') || encodeURIComponent(node.innerHTML)
}
}],
text: _specialCharacters.OBJECT_REPLACEMENT_CHARACTER
};
accumulateSelection(accumulator, node, range, value);
(0, _concat.mergePair)(accumulator, value);
continue;
}
if (tagName === 'br') {
accumulateSelection(accumulator, node, range, createEmptyValue());
(0, _concat.mergePair)(accumulator, create({
text: '\n'
}));
continue;
}
const format = toFormat({
tagName,
attributes: getAttributes({
element: node
})
});
// When a format type is declared as not editable, replace it with an
// object replacement character and preserve the inner HTML.
if (format?.formatType?.contentEditable === false) {
delete format.formatType;
accumulateSelection(accumulator, node, range, createEmptyValue());
(0, _concat.mergePair)(accumulator, {
formats: [,],
replacements: [{
...format,
innerHTML: node.innerHTML
}],
text: _specialCharacters.OBJECT_REPLACEMENT_CHARACTER
});
continue;
}
if (format) {
delete format.formatType;
}
const value = createFromElement({
element: node,
range,
isEditableTree
});
accumulateSelection(accumulator, node, range, value);
// Ignore any placeholders, but keep their content since the browser
// might insert text inside them when the editable element is flex.
if (!format || node.getAttribute('data-rich-text-placeholder')) {
(0, _concat.mergePair)(accumulator, value);
} else if (value.text.length === 0) {
if (format.attributes) {
(0, _concat.mergePair)(accumulator, {
formats: [,],
replacements: [format],
text: _specialCharacters.OBJECT_REPLACEMENT_CHARACTER
});
}
} else {
// Indices should share a reference to the same formats array.
// Only create a new reference if `formats` changes.
function mergeFormats(formats) {
if (mergeFormats.formats === formats) {
return mergeFormats.newFormats;
}
const newFormats = formats ? [format, ...formats] : [format];
mergeFormats.formats = formats;
mergeFormats.newFormats = newFormats;
return newFormats;
}
// Since the formats parameter can be `undefined`, preset
// `mergeFormats` with a new reference.
mergeFormats.newFormats = [format];
(0, _concat.mergePair)(accumulator, {
...value,
formats: Array.from(value.formats, mergeFormats)
});
}
}
return accumulator;
}
/**
* Gets the attributes of an element in object shape.
*
* @param {Object} $1 Named argements.
* @param {Element} $1.element Element to get attributes from.
*
* @return {Object|void} Attribute object or `undefined` if the element has no
* attributes.
*/
function getAttributes({
element
}) {
if (!element.hasAttributes()) {
return;
}
const length = element.attributes.length;
let accumulator;
// Optimise for speed.
for (let i = 0; i < length; i++) {
const {
name,
value
} = element.attributes[i];
if (name.indexOf('data-rich-text-') === 0) {
continue;
}
const safeName = /^on/i.test(name) ? 'data-disable-rich-text-' + name : name;
accumulator = accumulator || {};
accumulator[safeName] = value;
}
return accumulator;
}
//# sourceMappingURL=create.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getActiveFormat = getActiveFormat;
var _getActiveFormats = require("./get-active-formats");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/** @typedef {import('./types').RichTextFormat} RichTextFormat */
/**
* Gets the format object by type at the start of the selection. This can be
* used to get e.g. the URL of a link format at the current selection, but also
* to check if a format is active at the selection. Returns undefined if there
* is no format at the selection.
*
* @param {RichTextValue} value Value to inspect.
* @param {string} formatType Format type to look for.
*
* @return {RichTextFormat|undefined} Active format object of the specified
* type, or undefined.
*/
function getActiveFormat(value, formatType) {
return (0, _getActiveFormats.getActiveFormats)(value).find(({
type
}) => type === formatType);
}
//# sourceMappingURL=get-active-format.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_getActiveFormats","require","getActiveFormat","value","formatType","getActiveFormats","find","type"],"sources":["@wordpress/rich-text/src/get-active-format.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { getActiveFormats } from './get-active-formats';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n/** @typedef {import('./types').RichTextFormat} RichTextFormat */\n\n/**\n * Gets the format object by type at the start of the selection. This can be\n * used to get e.g. the URL of a link format at the current selection, but also\n * to check if a format is active at the selection. Returns undefined if there\n * is no format at the selection.\n *\n * @param {RichTextValue} value Value to inspect.\n * @param {string} formatType Format type to look for.\n *\n * @return {RichTextFormat|undefined} Active format object of the specified\n * type, or undefined.\n */\nexport function getActiveFormat( value, formatType ) {\n\treturn getActiveFormats( value ).find(\n\t\t( { type } ) => type === formatType\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,iBAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAAEC,KAAK,EAAEC,UAAU,EAAG;EACpD,OAAO,IAAAC,kCAAgB,EAAEF,KAAM,CAAC,CAACG,IAAI,CACpC,CAAE;IAAEC;EAAK,CAAC,KAAMA,IAAI,KAAKH,UAC1B,CAAC;AACF","ignoreList":[]}

View File

@@ -0,0 +1,89 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getActiveFormats = getActiveFormats;
var _isFormatEqual = require("./is-format-equal");
/** @typedef {import('./types').RichTextValue} RichTextValue */
/** @typedef {import('./types').RichTextFormatList} RichTextFormatList */
/**
* Internal dependencies
*/
/**
* Gets the all format objects at the start of the selection.
*
* @param {RichTextValue} value Value to inspect.
* @param {Array} EMPTY_ACTIVE_FORMATS Array to return if there are no
* active formats.
*
* @return {RichTextFormatList} Active format objects.
*/
function getActiveFormats(value, EMPTY_ACTIVE_FORMATS = []) {
const {
formats,
start,
end,
activeFormats
} = value;
if (start === undefined) {
return EMPTY_ACTIVE_FORMATS;
}
if (start === end) {
// For a collapsed caret, it is possible to override the active formats.
if (activeFormats) {
return activeFormats;
}
const formatsBefore = formats[start - 1] || EMPTY_ACTIVE_FORMATS;
const formatsAfter = formats[start] || EMPTY_ACTIVE_FORMATS;
// By default, select the lowest amount of formats possible (which means
// the caret is positioned outside the format boundary). The user can
// then use arrow keys to define `activeFormats`.
if (formatsBefore.length < formatsAfter.length) {
return formatsBefore;
}
return formatsAfter;
}
// If there's no formats at the start index, there are not active formats.
if (!formats[start]) {
return EMPTY_ACTIVE_FORMATS;
}
const selectedFormats = formats.slice(start, end);
// Clone the formats so we're not mutating the live value.
const _activeFormats = [...selectedFormats[0]];
let i = selectedFormats.length;
// For performance reasons, start from the end where it's much quicker to
// realise that there are no active formats.
while (i--) {
const formatsAtIndex = selectedFormats[i];
// If we run into any index without formats, we're sure that there's no
// active formats.
if (!formatsAtIndex) {
return EMPTY_ACTIVE_FORMATS;
}
let ii = _activeFormats.length;
// Loop over the active formats and remove any that are not present at
// the current index.
while (ii--) {
const format = _activeFormats[ii];
if (!formatsAtIndex.find(_format => (0, _isFormatEqual.isFormatEqual)(format, _format))) {
_activeFormats.splice(ii, 1);
}
}
// If there are no active formats, we can stop.
if (_activeFormats.length === 0) {
return EMPTY_ACTIVE_FORMATS;
}
}
return _activeFormats || EMPTY_ACTIVE_FORMATS;
}
//# sourceMappingURL=get-active-formats.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_isFormatEqual","require","getActiveFormats","value","EMPTY_ACTIVE_FORMATS","formats","start","end","activeFormats","undefined","formatsBefore","formatsAfter","length","selectedFormats","slice","_activeFormats","i","formatsAtIndex","ii","format","find","_format","isFormatEqual","splice"],"sources":["@wordpress/rich-text/src/get-active-formats.js"],"sourcesContent":["/** @typedef {import('./types').RichTextValue} RichTextValue */\n/** @typedef {import('./types').RichTextFormatList} RichTextFormatList */\n\n/**\n * Internal dependencies\n */\nimport { isFormatEqual } from './is-format-equal';\n\n/**\n * Gets the all format objects at the start of the selection.\n *\n * @param {RichTextValue} value Value to inspect.\n * @param {Array} EMPTY_ACTIVE_FORMATS Array to return if there are no\n * active formats.\n *\n * @return {RichTextFormatList} Active format objects.\n */\nexport function getActiveFormats( value, EMPTY_ACTIVE_FORMATS = [] ) {\n\tconst { formats, start, end, activeFormats } = value;\n\tif ( start === undefined ) {\n\t\treturn EMPTY_ACTIVE_FORMATS;\n\t}\n\n\tif ( start === end ) {\n\t\t// For a collapsed caret, it is possible to override the active formats.\n\t\tif ( activeFormats ) {\n\t\t\treturn activeFormats;\n\t\t}\n\n\t\tconst formatsBefore = formats[ start - 1 ] || EMPTY_ACTIVE_FORMATS;\n\t\tconst formatsAfter = formats[ start ] || EMPTY_ACTIVE_FORMATS;\n\n\t\t// By default, select the lowest amount of formats possible (which means\n\t\t// the caret is positioned outside the format boundary). The user can\n\t\t// then use arrow keys to define `activeFormats`.\n\t\tif ( formatsBefore.length < formatsAfter.length ) {\n\t\t\treturn formatsBefore;\n\t\t}\n\n\t\treturn formatsAfter;\n\t}\n\n\t// If there's no formats at the start index, there are not active formats.\n\tif ( ! formats[ start ] ) {\n\t\treturn EMPTY_ACTIVE_FORMATS;\n\t}\n\n\tconst selectedFormats = formats.slice( start, end );\n\n\t// Clone the formats so we're not mutating the live value.\n\tconst _activeFormats = [ ...selectedFormats[ 0 ] ];\n\tlet i = selectedFormats.length;\n\n\t// For performance reasons, start from the end where it's much quicker to\n\t// realise that there are no active formats.\n\twhile ( i-- ) {\n\t\tconst formatsAtIndex = selectedFormats[ i ];\n\n\t\t// If we run into any index without formats, we're sure that there's no\n\t\t// active formats.\n\t\tif ( ! formatsAtIndex ) {\n\t\t\treturn EMPTY_ACTIVE_FORMATS;\n\t\t}\n\n\t\tlet ii = _activeFormats.length;\n\n\t\t// Loop over the active formats and remove any that are not present at\n\t\t// the current index.\n\t\twhile ( ii-- ) {\n\t\t\tconst format = _activeFormats[ ii ];\n\n\t\t\tif (\n\t\t\t\t! formatsAtIndex.find( ( _format ) =>\n\t\t\t\t\tisFormatEqual( format, _format )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t_activeFormats.splice( ii, 1 );\n\t\t\t}\n\t\t}\n\n\t\t// If there are no active formats, we can stop.\n\t\tif ( _activeFormats.length === 0 ) {\n\t\t\treturn EMPTY_ACTIVE_FORMATS;\n\t\t}\n\t}\n\n\treturn _activeFormats || EMPTY_ACTIVE_FORMATS;\n}\n"],"mappings":";;;;;;AAMA,IAAAA,cAAA,GAAAC,OAAA;AANA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAEC,KAAK,EAAEC,oBAAoB,GAAG,EAAE,EAAG;EACpE,MAAM;IAAEC,OAAO;IAAEC,KAAK;IAAEC,GAAG;IAAEC;EAAc,CAAC,GAAGL,KAAK;EACpD,IAAKG,KAAK,KAAKG,SAAS,EAAG;IAC1B,OAAOL,oBAAoB;EAC5B;EAEA,IAAKE,KAAK,KAAKC,GAAG,EAAG;IACpB;IACA,IAAKC,aAAa,EAAG;MACpB,OAAOA,aAAa;IACrB;IAEA,MAAME,aAAa,GAAGL,OAAO,CAAEC,KAAK,GAAG,CAAC,CAAE,IAAIF,oBAAoB;IAClE,MAAMO,YAAY,GAAGN,OAAO,CAAEC,KAAK,CAAE,IAAIF,oBAAoB;;IAE7D;IACA;IACA;IACA,IAAKM,aAAa,CAACE,MAAM,GAAGD,YAAY,CAACC,MAAM,EAAG;MACjD,OAAOF,aAAa;IACrB;IAEA,OAAOC,YAAY;EACpB;;EAEA;EACA,IAAK,CAAEN,OAAO,CAAEC,KAAK,CAAE,EAAG;IACzB,OAAOF,oBAAoB;EAC5B;EAEA,MAAMS,eAAe,GAAGR,OAAO,CAACS,KAAK,CAAER,KAAK,EAAEC,GAAI,CAAC;;EAEnD;EACA,MAAMQ,cAAc,GAAG,CAAE,GAAGF,eAAe,CAAE,CAAC,CAAE,CAAE;EAClD,IAAIG,CAAC,GAAGH,eAAe,CAACD,MAAM;;EAE9B;EACA;EACA,OAAQI,CAAC,EAAE,EAAG;IACb,MAAMC,cAAc,GAAGJ,eAAe,CAAEG,CAAC,CAAE;;IAE3C;IACA;IACA,IAAK,CAAEC,cAAc,EAAG;MACvB,OAAOb,oBAAoB;IAC5B;IAEA,IAAIc,EAAE,GAAGH,cAAc,CAACH,MAAM;;IAE9B;IACA;IACA,OAAQM,EAAE,EAAE,EAAG;MACd,MAAMC,MAAM,GAAGJ,cAAc,CAAEG,EAAE,CAAE;MAEnC,IACC,CAAED,cAAc,CAACG,IAAI,CAAIC,OAAO,IAC/B,IAAAC,4BAAa,EAAEH,MAAM,EAAEE,OAAQ,CAChC,CAAC,EACA;QACDN,cAAc,CAACQ,MAAM,CAAEL,EAAE,EAAE,CAAE,CAAC;MAC/B;IACD;;IAEA;IACA,IAAKH,cAAc,CAACH,MAAM,KAAK,CAAC,EAAG;MAClC,OAAOR,oBAAoB;IAC5B;EACD;EAEA,OAAOW,cAAc,IAAIX,oBAAoB;AAC9C","ignoreList":[]}

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getActiveObject = getActiveObject;
var _specialCharacters = require("./special-characters");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/** @typedef {import('./types').RichTextFormat} RichTextFormat */
/**
* Gets the active object, if there is any.
*
* @param {RichTextValue} value Value to inspect.
*
* @return {RichTextFormat|void} Active object, or undefined.
*/
function getActiveObject({
start,
end,
replacements,
text
}) {
if (start + 1 !== end || text[start] !== _specialCharacters.OBJECT_REPLACEMENT_CHARACTER) {
return;
}
return replacements[start];
}
//# sourceMappingURL=get-active-object.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_specialCharacters","require","getActiveObject","start","end","replacements","text","OBJECT_REPLACEMENT_CHARACTER"],"sources":["@wordpress/rich-text/src/get-active-object.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nimport { OBJECT_REPLACEMENT_CHARACTER } from './special-characters';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n/** @typedef {import('./types').RichTextFormat} RichTextFormat */\n\n/**\n * Gets the active object, if there is any.\n *\n * @param {RichTextValue} value Value to inspect.\n *\n * @return {RichTextFormat|void} Active object, or undefined.\n */\nexport function getActiveObject( { start, end, replacements, text } ) {\n\tif ( start + 1 !== end || text[ start ] !== OBJECT_REPLACEMENT_CHARACTER ) {\n\t\treturn;\n\t}\n\n\treturn replacements[ start ];\n}\n"],"mappings":";;;;;;AAIA,IAAAA,kBAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAAE;EAAEC,KAAK;EAAEC,GAAG;EAAEC,YAAY;EAAEC;AAAK,CAAC,EAAG;EACrE,IAAKH,KAAK,GAAG,CAAC,KAAKC,GAAG,IAAIE,IAAI,CAAEH,KAAK,CAAE,KAAKI,+CAA4B,EAAG;IAC1E;EACD;EAEA,OAAOF,YAAY,CAAEF,KAAK,CAAE;AAC7B","ignoreList":[]}

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getFormatType = getFormatType;
var _data = require("@wordpress/data");
var _store = require("./store");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('./register-format-type').RichTextFormatType} RichTextFormatType */
/**
* Returns a registered format type.
*
* @param {string} name Format name.
*
* @return {RichTextFormatType|undefined} Format type.
*/
function getFormatType(name) {
return (0, _data.select)(_store.store).getFormatType(name);
}
//# sourceMappingURL=get-format-type.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_data","require","_store","getFormatType","name","select","richTextStore"],"sources":["@wordpress/rich-text/src/get-format-type.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { select } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { store as richTextStore } from './store';\n\n/** @typedef {import('./register-format-type').RichTextFormatType} RichTextFormatType */\n\n/**\n * Returns a registered format type.\n *\n * @param {string} name Format name.\n *\n * @return {RichTextFormatType|undefined} Format type.\n */\nexport function getFormatType( name ) {\n\treturn select( richTextStore ).getFormatType( name );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAPA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,aAAaA,CAAEC,IAAI,EAAG;EACrC,OAAO,IAAAC,YAAM,EAAEC,YAAc,CAAC,CAACH,aAAa,CAAEC,IAAK,CAAC;AACrD","ignoreList":[]}

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getFormatTypes = getFormatTypes;
var _data = require("@wordpress/data");
var _store = require("./store");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('./register-format-type').RichTextFormatType} RichTextFormatType */
/**
* Returns all registered formats.
*
* @return {Array<RichTextFormatType>} Format settings.
*/
function getFormatTypes() {
return (0, _data.select)(_store.store).getFormatTypes();
}
//# sourceMappingURL=get-format-types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_data","require","_store","getFormatTypes","select","richTextStore"],"sources":["@wordpress/rich-text/src/get-format-types.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { select } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { store as richTextStore } from './store';\n\n/** @typedef {import('./register-format-type').RichTextFormatType} RichTextFormatType */\n\n/**\n * Returns all registered formats.\n *\n * @return {Array<RichTextFormatType>} Format settings.\n */\nexport function getFormatTypes() {\n\treturn select( richTextStore ).getFormatTypes();\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAPA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASE,cAAcA,CAAA,EAAG;EAChC,OAAO,IAAAC,YAAM,EAAEC,YAAc,CAAC,CAACF,cAAc,CAAC,CAAC;AAChD","ignoreList":[]}

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getTextContent = getTextContent;
var _specialCharacters = require("./special-characters");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Get the textual content of a Rich Text value. This is similar to
* `Element.textContent`.
*
* @param {RichTextValue} value Value to use.
*
* @return {string} The text content.
*/
function getTextContent({
text
}) {
return text.replace(_specialCharacters.OBJECT_REPLACEMENT_CHARACTER, '');
}
//# sourceMappingURL=get-text-content.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_specialCharacters","require","getTextContent","text","replace","OBJECT_REPLACEMENT_CHARACTER"],"sources":["@wordpress/rich-text/src/get-text-content.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { OBJECT_REPLACEMENT_CHARACTER } from './special-characters';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Get the textual content of a Rich Text value. This is similar to\n * `Element.textContent`.\n *\n * @param {RichTextValue} value Value to use.\n *\n * @return {string} The text content.\n */\nexport function getTextContent( { text } ) {\n\treturn text.replace( OBJECT_REPLACEMENT_CHARACTER, '' );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,kBAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAE;EAAEC;AAAK,CAAC,EAAG;EAC1C,OAAOA,IAAI,CAACC,OAAO,CAAEC,+CAA4B,EAAE,EAAG,CAAC;AACxD","ignoreList":[]}

209
node_modules/@wordpress/rich-text/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,209 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "RichTextData", {
enumerable: true,
get: function () {
return _create.RichTextData;
}
});
Object.defineProperty(exports, "__experimentalRichText", {
enumerable: true,
get: function () {
return _component.default;
}
});
Object.defineProperty(exports, "__unstableCreateElement", {
enumerable: true,
get: function () {
return _createElement.createElement;
}
});
Object.defineProperty(exports, "__unstableToDom", {
enumerable: true,
get: function () {
return _toDom.toDom;
}
});
Object.defineProperty(exports, "__unstableUseRichText", {
enumerable: true,
get: function () {
return _component.useRichText;
}
});
Object.defineProperty(exports, "applyFormat", {
enumerable: true,
get: function () {
return _applyFormat.applyFormat;
}
});
Object.defineProperty(exports, "concat", {
enumerable: true,
get: function () {
return _concat.concat;
}
});
Object.defineProperty(exports, "create", {
enumerable: true,
get: function () {
return _create.create;
}
});
Object.defineProperty(exports, "getActiveFormat", {
enumerable: true,
get: function () {
return _getActiveFormat.getActiveFormat;
}
});
Object.defineProperty(exports, "getActiveFormats", {
enumerable: true,
get: function () {
return _getActiveFormats.getActiveFormats;
}
});
Object.defineProperty(exports, "getActiveObject", {
enumerable: true,
get: function () {
return _getActiveObject.getActiveObject;
}
});
Object.defineProperty(exports, "getTextContent", {
enumerable: true,
get: function () {
return _getTextContent.getTextContent;
}
});
Object.defineProperty(exports, "insert", {
enumerable: true,
get: function () {
return _insert.insert;
}
});
Object.defineProperty(exports, "insertObject", {
enumerable: true,
get: function () {
return _insertObject.insertObject;
}
});
Object.defineProperty(exports, "isCollapsed", {
enumerable: true,
get: function () {
return _isCollapsed.isCollapsed;
}
});
Object.defineProperty(exports, "isEmpty", {
enumerable: true,
get: function () {
return _isEmpty.isEmpty;
}
});
Object.defineProperty(exports, "join", {
enumerable: true,
get: function () {
return _join.join;
}
});
Object.defineProperty(exports, "registerFormatType", {
enumerable: true,
get: function () {
return _registerFormatType.registerFormatType;
}
});
Object.defineProperty(exports, "remove", {
enumerable: true,
get: function () {
return _remove.remove;
}
});
Object.defineProperty(exports, "removeFormat", {
enumerable: true,
get: function () {
return _removeFormat.removeFormat;
}
});
Object.defineProperty(exports, "replace", {
enumerable: true,
get: function () {
return _replace.replace;
}
});
Object.defineProperty(exports, "slice", {
enumerable: true,
get: function () {
return _slice.slice;
}
});
Object.defineProperty(exports, "split", {
enumerable: true,
get: function () {
return _split.split;
}
});
Object.defineProperty(exports, "store", {
enumerable: true,
get: function () {
return _store.store;
}
});
Object.defineProperty(exports, "toHTMLString", {
enumerable: true,
get: function () {
return _toHtmlString.toHTMLString;
}
});
Object.defineProperty(exports, "toggleFormat", {
enumerable: true,
get: function () {
return _toggleFormat.toggleFormat;
}
});
Object.defineProperty(exports, "unregisterFormatType", {
enumerable: true,
get: function () {
return _unregisterFormatType.unregisterFormatType;
}
});
Object.defineProperty(exports, "useAnchor", {
enumerable: true,
get: function () {
return _useAnchor.useAnchor;
}
});
Object.defineProperty(exports, "useAnchorRef", {
enumerable: true,
get: function () {
return _useAnchorRef.useAnchorRef;
}
});
var _store = require("./store");
var _applyFormat = require("./apply-format");
var _concat = require("./concat");
var _create = require("./create");
var _getActiveFormat = require("./get-active-format");
var _getActiveFormats = require("./get-active-formats");
var _getActiveObject = require("./get-active-object");
var _getTextContent = require("./get-text-content");
var _isCollapsed = require("./is-collapsed");
var _isEmpty = require("./is-empty");
var _join = require("./join");
var _registerFormatType = require("./register-format-type");
var _removeFormat = require("./remove-format");
var _remove = require("./remove");
var _replace = require("./replace");
var _insert = require("./insert");
var _insertObject = require("./insert-object");
var _slice = require("./slice");
var _split = require("./split");
var _toDom = require("./to-dom");
var _toHtmlString = require("./to-html-string");
var _toggleFormat = require("./toggle-format");
var _unregisterFormatType = require("./unregister-format-type");
var _createElement = require("./create-element");
var _useAnchorRef = require("./component/use-anchor-ref");
var _useAnchor = require("./component/use-anchor");
var _component = _interopRequireWildcard(require("./component"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
//# sourceMappingURL=index.js.map

1
node_modules/@wordpress/rich-text/build/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"names":["_store","require","_applyFormat","_concat","_create","_getActiveFormat","_getActiveFormats","_getActiveObject","_getTextContent","_isCollapsed","_isEmpty","_join","_registerFormatType","_removeFormat","_remove","_replace","_insert","_insertObject","_slice","_split","_toDom","_toHtmlString","_toggleFormat","_unregisterFormatType","_createElement","_useAnchorRef","_useAnchor","_component","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set"],"sources":["@wordpress/rich-text/src/index.ts"],"sourcesContent":["export { store } from './store';\nexport { applyFormat } from './apply-format';\nexport { concat } from './concat';\nexport { RichTextData, create } from './create';\nexport { getActiveFormat } from './get-active-format';\nexport { getActiveFormats } from './get-active-formats';\nexport { getActiveObject } from './get-active-object';\nexport { getTextContent } from './get-text-content';\nexport { isCollapsed } from './is-collapsed';\nexport { isEmpty } from './is-empty';\nexport { join } from './join';\nexport { registerFormatType } from './register-format-type';\nexport { removeFormat } from './remove-format';\nexport { remove } from './remove';\nexport { replace } from './replace';\nexport { insert } from './insert';\nexport { insertObject } from './insert-object';\nexport { slice } from './slice';\nexport { split } from './split';\nexport { toDom as __unstableToDom } from './to-dom';\nexport { toHTMLString } from './to-html-string';\nexport { toggleFormat } from './toggle-format';\nexport { unregisterFormatType } from './unregister-format-type';\nexport { createElement as __unstableCreateElement } from './create-element';\n\nexport { useAnchorRef } from './component/use-anchor-ref';\nexport { useAnchor } from './component/use-anchor';\n\nexport {\n\tdefault as __experimentalRichText,\n\tuseRichText as __unstableUseRichText,\n} from './component';\n\n/**\n * An object which represents a formatted string. See main `@wordpress/rich-text`\n * documentation for more information.\n */\nexport type { RichTextValue } from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,KAAA,GAAAV,OAAA;AACA,IAAAW,mBAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AACA,IAAAa,OAAA,GAAAb,OAAA;AACA,IAAAc,QAAA,GAAAd,OAAA;AACA,IAAAe,OAAA,GAAAf,OAAA;AACA,IAAAgB,aAAA,GAAAhB,OAAA;AACA,IAAAiB,MAAA,GAAAjB,OAAA;AACA,IAAAkB,MAAA,GAAAlB,OAAA;AACA,IAAAmB,MAAA,GAAAnB,OAAA;AACA,IAAAoB,aAAA,GAAApB,OAAA;AACA,IAAAqB,aAAA,GAAArB,OAAA;AACA,IAAAsB,qBAAA,GAAAtB,OAAA;AACA,IAAAuB,cAAA,GAAAvB,OAAA;AAEA,IAAAwB,aAAA,GAAAxB,OAAA;AACA,IAAAyB,UAAA,GAAAzB,OAAA;AAEA,IAAA0B,UAAA,GAAAC,uBAAA,CAAA3B,OAAA;AAGqB,SAAA4B,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA","ignoreList":[]}

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.insertObject = insertObject;
var _insert = require("./insert");
var _specialCharacters = require("./special-characters");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/** @typedef {import('./types').RichTextFormat} RichTextFormat */
/**
* Insert a format as an object into a Rich Text value at the given
* `startIndex`. Any content between `startIndex` and `endIndex` will be
* removed. Indices are retrieved from the selection if none are provided.
*
* @param {RichTextValue} value Value to modify.
* @param {RichTextFormat} formatToInsert Format to insert as object.
* @param {number} [startIndex] Start index.
* @param {number} [endIndex] End index.
*
* @return {RichTextValue} A new value with the object inserted.
*/
function insertObject(value, formatToInsert, startIndex, endIndex) {
const valueToInsert = {
formats: [,],
replacements: [formatToInsert],
text: _specialCharacters.OBJECT_REPLACEMENT_CHARACTER
};
return (0, _insert.insert)(value, valueToInsert, startIndex, endIndex);
}
//# sourceMappingURL=insert-object.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_insert","require","_specialCharacters","insertObject","value","formatToInsert","startIndex","endIndex","valueToInsert","formats","replacements","text","OBJECT_REPLACEMENT_CHARACTER","insert"],"sources":["@wordpress/rich-text/src/insert-object.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nimport { insert } from './insert';\nimport { OBJECT_REPLACEMENT_CHARACTER } from './special-characters';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n/** @typedef {import('./types').RichTextFormat} RichTextFormat */\n\n/**\n * Insert a format as an object into a Rich Text value at the given\n * `startIndex`. Any content between `startIndex` and `endIndex` will be\n * removed. Indices are retrieved from the selection if none are provided.\n *\n * @param {RichTextValue} value Value to modify.\n * @param {RichTextFormat} formatToInsert Format to insert as object.\n * @param {number} [startIndex] Start index.\n * @param {number} [endIndex] End index.\n *\n * @return {RichTextValue} A new value with the object inserted.\n */\nexport function insertObject( value, formatToInsert, startIndex, endIndex ) {\n\tconst valueToInsert = {\n\t\tformats: [ , ],\n\t\treplacements: [ formatToInsert ],\n\t\ttext: OBJECT_REPLACEMENT_CHARACTER,\n\t};\n\n\treturn insert( value, valueToInsert, startIndex, endIndex );\n}\n"],"mappings":";;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAKA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAAEC,KAAK,EAAEC,cAAc,EAAEC,UAAU,EAAEC,QAAQ,EAAG;EAC3E,MAAMC,aAAa,GAAG;IACrBC,OAAO,EAAE,GAAK;IACdC,YAAY,EAAE,CAAEL,cAAc,CAAE;IAChCM,IAAI,EAAEC;EACP,CAAC;EAED,OAAO,IAAAC,cAAM,EAAET,KAAK,EAAEI,aAAa,EAAEF,UAAU,EAAEC,QAAS,CAAC;AAC5D","ignoreList":[]}

48
node_modules/@wordpress/rich-text/build/insert.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.insert = insert;
var _create = require("./create");
var _normaliseFormats = require("./normalise-formats");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Insert a Rich Text value, an HTML string, or a plain text string, into a
* Rich Text value at the given `startIndex`. Any content between `startIndex`
* and `endIndex` will be removed. Indices are retrieved from the selection if
* none are provided.
*
* @param {RichTextValue} value Value to modify.
* @param {RichTextValue|string} valueToInsert Value to insert.
* @param {number} [startIndex] Start index.
* @param {number} [endIndex] End index.
*
* @return {RichTextValue} A new value with the value inserted.
*/
function insert(value, valueToInsert, startIndex = value.start, endIndex = value.end) {
const {
formats,
replacements,
text
} = value;
if (typeof valueToInsert === 'string') {
valueToInsert = (0, _create.create)({
text: valueToInsert
});
}
const index = startIndex + valueToInsert.text.length;
return (0, _normaliseFormats.normaliseFormats)({
formats: formats.slice(0, startIndex).concat(valueToInsert.formats, formats.slice(endIndex)),
replacements: replacements.slice(0, startIndex).concat(valueToInsert.replacements, replacements.slice(endIndex)),
text: text.slice(0, startIndex) + valueToInsert.text + text.slice(endIndex),
start: index,
end: index
});
}
//# sourceMappingURL=insert.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_create","require","_normaliseFormats","insert","value","valueToInsert","startIndex","start","endIndex","end","formats","replacements","text","create","index","length","normaliseFormats","slice","concat"],"sources":["@wordpress/rich-text/src/insert.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nimport { create } from './create';\nimport { normaliseFormats } from './normalise-formats';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Insert a Rich Text value, an HTML string, or a plain text string, into a\n * Rich Text value at the given `startIndex`. Any content between `startIndex`\n * and `endIndex` will be removed. Indices are retrieved from the selection if\n * none are provided.\n *\n * @param {RichTextValue} value Value to modify.\n * @param {RichTextValue|string} valueToInsert Value to insert.\n * @param {number} [startIndex] Start index.\n * @param {number} [endIndex] End index.\n *\n * @return {RichTextValue} A new value with the value inserted.\n */\nexport function insert(\n\tvalue,\n\tvalueToInsert,\n\tstartIndex = value.start,\n\tendIndex = value.end\n) {\n\tconst { formats, replacements, text } = value;\n\n\tif ( typeof valueToInsert === 'string' ) {\n\t\tvalueToInsert = create( { text: valueToInsert } );\n\t}\n\n\tconst index = startIndex + valueToInsert.text.length;\n\n\treturn normaliseFormats( {\n\t\tformats: formats\n\t\t\t.slice( 0, startIndex )\n\t\t\t.concat( valueToInsert.formats, formats.slice( endIndex ) ),\n\t\treplacements: replacements\n\t\t\t.slice( 0, startIndex )\n\t\t\t.concat(\n\t\t\t\tvalueToInsert.replacements,\n\t\t\t\treplacements.slice( endIndex )\n\t\t\t),\n\t\ttext:\n\t\t\ttext.slice( 0, startIndex ) +\n\t\t\tvalueToInsert.text +\n\t\t\ttext.slice( endIndex ),\n\t\tstart: index,\n\t\tend: index,\n\t} );\n}\n"],"mappings":";;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,MAAMA,CACrBC,KAAK,EACLC,aAAa,EACbC,UAAU,GAAGF,KAAK,CAACG,KAAK,EACxBC,QAAQ,GAAGJ,KAAK,CAACK,GAAG,EACnB;EACD,MAAM;IAAEC,OAAO;IAAEC,YAAY;IAAEC;EAAK,CAAC,GAAGR,KAAK;EAE7C,IAAK,OAAOC,aAAa,KAAK,QAAQ,EAAG;IACxCA,aAAa,GAAG,IAAAQ,cAAM,EAAE;MAAED,IAAI,EAAEP;IAAc,CAAE,CAAC;EAClD;EAEA,MAAMS,KAAK,GAAGR,UAAU,GAAGD,aAAa,CAACO,IAAI,CAACG,MAAM;EAEpD,OAAO,IAAAC,kCAAgB,EAAE;IACxBN,OAAO,EAAEA,OAAO,CACdO,KAAK,CAAE,CAAC,EAAEX,UAAW,CAAC,CACtBY,MAAM,CAAEb,aAAa,CAACK,OAAO,EAAEA,OAAO,CAACO,KAAK,CAAET,QAAS,CAAE,CAAC;IAC5DG,YAAY,EAAEA,YAAY,CACxBM,KAAK,CAAE,CAAC,EAAEX,UAAW,CAAC,CACtBY,MAAM,CACNb,aAAa,CAACM,YAAY,EAC1BA,YAAY,CAACM,KAAK,CAAET,QAAS,CAC9B,CAAC;IACFI,IAAI,EACHA,IAAI,CAACK,KAAK,CAAE,CAAC,EAAEX,UAAW,CAAC,GAC3BD,aAAa,CAACO,IAAI,GAClBA,IAAI,CAACK,KAAK,CAAET,QAAS,CAAC;IACvBD,KAAK,EAAEO,KAAK;IACZL,GAAG,EAAEK;EACN,CAAE,CAAC;AACJ","ignoreList":[]}

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isCollapsed = isCollapsed;
/**
* Internal dependencies
*/
/**
* Check if the selection of a Rich Text value is collapsed or not. Collapsed
* means that no characters are selected, but there is a caret present. If there
* is no selection, `undefined` will be returned. This is similar to
* `window.getSelection().isCollapsed()`.
*
* @param props The rich text value to check.
* @param props.start
* @param props.end
* @return True if the selection is collapsed, false if not, undefined if there is no selection.
*/
function isCollapsed({
start,
end
}) {
if (start === undefined || end === undefined) {
return;
}
return start === end;
}
//# sourceMappingURL=is-collapsed.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["isCollapsed","start","end","undefined"],"sources":["@wordpress/rich-text/src/is-collapsed.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { RichTextValue } from './types';\n\n/**\n * Check if the selection of a Rich Text value is collapsed or not. Collapsed\n * means that no characters are selected, but there is a caret present. If there\n * is no selection, `undefined` will be returned. This is similar to\n * `window.getSelection().isCollapsed()`.\n *\n * @param props The rich text value to check.\n * @param props.start\n * @param props.end\n * @return True if the selection is collapsed, false if not, undefined if there is no selection.\n */\nexport function isCollapsed( {\n\tstart,\n\tend,\n}: RichTextValue ): boolean | undefined {\n\tif ( start === undefined || end === undefined ) {\n\t\treturn;\n\t}\n\n\treturn start === end;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAWA,CAAE;EAC5BC,KAAK;EACLC;AACc,CAAC,EAAwB;EACvC,IAAKD,KAAK,KAAKE,SAAS,IAAID,GAAG,KAAKC,SAAS,EAAG;IAC/C;EACD;EAEA,OAAOF,KAAK,KAAKC,GAAG;AACrB","ignoreList":[]}

22
node_modules/@wordpress/rich-text/build/is-empty.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isEmpty = isEmpty;
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Check if a Rich Text value is Empty, meaning it contains no text or any
* objects (such as images).
*
* @param {RichTextValue} value Value to use.
*
* @return {boolean} True if the value is empty, false if not.
*/
function isEmpty({
text
}) {
return text.length === 0;
}
//# sourceMappingURL=is-empty.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["isEmpty","text","length"],"sources":["@wordpress/rich-text/src/is-empty.js"],"sourcesContent":["/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Check if a Rich Text value is Empty, meaning it contains no text or any\n * objects (such as images).\n *\n * @param {RichTextValue} value Value to use.\n *\n * @return {boolean} True if the value is empty, false if not.\n */\nexport function isEmpty( { text } ) {\n\treturn text.length === 0;\n}\n"],"mappings":";;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,OAAOA,CAAE;EAAEC;AAAK,CAAC,EAAG;EACnC,OAAOA,IAAI,CAACC,MAAM,KAAK,CAAC;AACzB","ignoreList":[]}

View File

@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isFormatEqual = isFormatEqual;
/** @typedef {import('./types').RichTextFormat} RichTextFormat */
/**
* Optimised equality check for format objects.
*
* @param {?RichTextFormat} format1 Format to compare.
* @param {?RichTextFormat} format2 Format to compare.
*
* @return {boolean} True if formats are equal, false if not.
*/
function isFormatEqual(format1, format2) {
// Both not defined.
if (format1 === format2) {
return true;
}
// Either not defined.
if (!format1 || !format2) {
return false;
}
if (format1.type !== format2.type) {
return false;
}
const attributes1 = format1.attributes;
const attributes2 = format2.attributes;
// Both not defined.
if (attributes1 === attributes2) {
return true;
}
// Either not defined.
if (!attributes1 || !attributes2) {
return false;
}
const keys1 = Object.keys(attributes1);
const keys2 = Object.keys(attributes2);
if (keys1.length !== keys2.length) {
return false;
}
const length = keys1.length;
// Optimise for speed.
for (let i = 0; i < length; i++) {
const name = keys1[i];
if (attributes1[name] !== attributes2[name]) {
return false;
}
}
return true;
}
//# sourceMappingURL=is-format-equal.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["isFormatEqual","format1","format2","type","attributes1","attributes","attributes2","keys1","Object","keys","keys2","length","i","name"],"sources":["@wordpress/rich-text/src/is-format-equal.js"],"sourcesContent":["/** @typedef {import('./types').RichTextFormat} RichTextFormat */\n\n/**\n * Optimised equality check for format objects.\n *\n * @param {?RichTextFormat} format1 Format to compare.\n * @param {?RichTextFormat} format2 Format to compare.\n *\n * @return {boolean} True if formats are equal, false if not.\n */\nexport function isFormatEqual( format1, format2 ) {\n\t// Both not defined.\n\tif ( format1 === format2 ) {\n\t\treturn true;\n\t}\n\n\t// Either not defined.\n\tif ( ! format1 || ! format2 ) {\n\t\treturn false;\n\t}\n\n\tif ( format1.type !== format2.type ) {\n\t\treturn false;\n\t}\n\n\tconst attributes1 = format1.attributes;\n\tconst attributes2 = format2.attributes;\n\n\t// Both not defined.\n\tif ( attributes1 === attributes2 ) {\n\t\treturn true;\n\t}\n\n\t// Either not defined.\n\tif ( ! attributes1 || ! attributes2 ) {\n\t\treturn false;\n\t}\n\n\tconst keys1 = Object.keys( attributes1 );\n\tconst keys2 = Object.keys( attributes2 );\n\n\tif ( keys1.length !== keys2.length ) {\n\t\treturn false;\n\t}\n\n\tconst length = keys1.length;\n\n\t// Optimise for speed.\n\tfor ( let i = 0; i < length; i++ ) {\n\t\tconst name = keys1[ i ];\n\n\t\tif ( attributes1[ name ] !== attributes2[ name ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n"],"mappings":";;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAAEC,OAAO,EAAEC,OAAO,EAAG;EACjD;EACA,IAAKD,OAAO,KAAKC,OAAO,EAAG;IAC1B,OAAO,IAAI;EACZ;;EAEA;EACA,IAAK,CAAED,OAAO,IAAI,CAAEC,OAAO,EAAG;IAC7B,OAAO,KAAK;EACb;EAEA,IAAKD,OAAO,CAACE,IAAI,KAAKD,OAAO,CAACC,IAAI,EAAG;IACpC,OAAO,KAAK;EACb;EAEA,MAAMC,WAAW,GAAGH,OAAO,CAACI,UAAU;EACtC,MAAMC,WAAW,GAAGJ,OAAO,CAACG,UAAU;;EAEtC;EACA,IAAKD,WAAW,KAAKE,WAAW,EAAG;IAClC,OAAO,IAAI;EACZ;;EAEA;EACA,IAAK,CAAEF,WAAW,IAAI,CAAEE,WAAW,EAAG;IACrC,OAAO,KAAK;EACb;EAEA,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAEL,WAAY,CAAC;EACxC,MAAMM,KAAK,GAAGF,MAAM,CAACC,IAAI,CAAEH,WAAY,CAAC;EAExC,IAAKC,KAAK,CAACI,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAG;IACpC,OAAO,KAAK;EACb;EAEA,MAAMA,MAAM,GAAGJ,KAAK,CAACI,MAAM;;EAE3B;EACA,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,MAAM,EAAEC,CAAC,EAAE,EAAG;IAClC,MAAMC,IAAI,GAAGN,KAAK,CAAEK,CAAC,CAAE;IAEvB,IAAKR,WAAW,CAAES,IAAI,CAAE,KAAKP,WAAW,CAAEO,IAAI,CAAE,EAAG;MAClD,OAAO,KAAK;IACb;EACD;EAEA,OAAO,IAAI;AACZ","ignoreList":[]}

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isRangeEqual = isRangeEqual;
/**
* Returns true if two ranges are equal, or false otherwise. Ranges are
* considered equal if their start and end occur in the same container and
* offset.
*
* @param {Range|null} a First range object to test.
* @param {Range|null} b First range object to test.
*
* @return {boolean} Whether the two ranges are equal.
*/
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;
}
//# sourceMappingURL=is-range-equal.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["isRangeEqual","a","b","startContainer","startOffset","endContainer","endOffset"],"sources":["@wordpress/rich-text/src/is-range-equal.js"],"sourcesContent":["/**\n * Returns true if two ranges are equal, or false otherwise. Ranges are\n * considered equal if their start and end occur in the same container and\n * offset.\n *\n * @param {Range|null} a First range object to test.\n * @param {Range|null} b First range object to test.\n *\n * @return {boolean} Whether the two ranges are equal.\n */\nexport function isRangeEqual( a, b ) {\n\treturn (\n\t\ta === b ||\n\t\t( a &&\n\t\t\tb &&\n\t\t\ta.startContainer === b.startContainer &&\n\t\t\ta.startOffset === b.startOffset &&\n\t\t\ta.endContainer === b.endContainer &&\n\t\t\ta.endOffset === b.endOffset )\n\t);\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAYA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACpC,OACCD,CAAC,KAAKC,CAAC,IACLD,CAAC,IACFC,CAAC,IACDD,CAAC,CAACE,cAAc,KAAKD,CAAC,CAACC,cAAc,IACrCF,CAAC,CAACG,WAAW,KAAKF,CAAC,CAACE,WAAW,IAC/BH,CAAC,CAACI,YAAY,KAAKH,CAAC,CAACG,YAAY,IACjCJ,CAAC,CAACK,SAAS,KAAKJ,CAAC,CAACI,SAAW;AAEhC","ignoreList":[]}

41
node_modules/@wordpress/rich-text/build/join.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.join = join;
var _create = require("./create");
var _normaliseFormats = require("./normalise-formats");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Combine an array of Rich Text values into one, optionally separated by
* `separator`, which can be a Rich Text value, HTML string, or plain text
* string. This is similar to `Array.prototype.join`.
*
* @param {Array<RichTextValue>} values An array of values to join.
* @param {string|RichTextValue} [separator] Separator string or value.
*
* @return {RichTextValue} A new combined value.
*/
function join(values, separator = '') {
if (typeof separator === 'string') {
separator = (0, _create.create)({
text: separator
});
}
return (0, _normaliseFormats.normaliseFormats)(values.reduce((accumlator, {
formats,
replacements,
text
}) => ({
formats: accumlator.formats.concat(separator.formats, formats),
replacements: accumlator.replacements.concat(separator.replacements, replacements),
text: accumlator.text + separator.text + text
})));
}
//# sourceMappingURL=join.js.map

1
node_modules/@wordpress/rich-text/build/join.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"names":["_create","require","_normaliseFormats","join","values","separator","create","text","normaliseFormats","reduce","accumlator","formats","replacements","concat"],"sources":["@wordpress/rich-text/src/join.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nimport { create } from './create';\nimport { normaliseFormats } from './normalise-formats';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Combine an array of Rich Text values into one, optionally separated by\n * `separator`, which can be a Rich Text value, HTML string, or plain text\n * string. This is similar to `Array.prototype.join`.\n *\n * @param {Array<RichTextValue>} values An array of values to join.\n * @param {string|RichTextValue} [separator] Separator string or value.\n *\n * @return {RichTextValue} A new combined value.\n */\nexport function join( values, separator = '' ) {\n\tif ( typeof separator === 'string' ) {\n\t\tseparator = create( { text: separator } );\n\t}\n\n\treturn normaliseFormats(\n\t\tvalues.reduce( ( accumlator, { formats, replacements, text } ) => ( {\n\t\t\tformats: accumlator.formats.concat( separator.formats, formats ),\n\t\t\treplacements: accumlator.replacements.concat(\n\t\t\t\tseparator.replacements,\n\t\t\t\treplacements\n\t\t\t),\n\t\t\ttext: accumlator.text + separator.text + text,\n\t\t} ) )\n\t);\n}\n"],"mappings":";;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,IAAIA,CAAEC,MAAM,EAAEC,SAAS,GAAG,EAAE,EAAG;EAC9C,IAAK,OAAOA,SAAS,KAAK,QAAQ,EAAG;IACpCA,SAAS,GAAG,IAAAC,cAAM,EAAE;MAAEC,IAAI,EAAEF;IAAU,CAAE,CAAC;EAC1C;EAEA,OAAO,IAAAG,kCAAgB,EACtBJ,MAAM,CAACK,MAAM,CAAE,CAAEC,UAAU,EAAE;IAAEC,OAAO;IAAEC,YAAY;IAAEL;EAAK,CAAC,MAAQ;IACnEI,OAAO,EAAED,UAAU,CAACC,OAAO,CAACE,MAAM,CAAER,SAAS,CAACM,OAAO,EAAEA,OAAQ,CAAC;IAChEC,YAAY,EAAEF,UAAU,CAACE,YAAY,CAACC,MAAM,CAC3CR,SAAS,CAACO,YAAY,EACtBA,YACD,CAAC;IACDL,IAAI,EAAEG,UAAU,CAACH,IAAI,GAAGF,SAAS,CAACE,IAAI,GAAGA;EAC1C,CAAC,CAAG,CACL,CAAC;AACF","ignoreList":[]}

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.normaliseFormats = normaliseFormats;
var _isFormatEqual = require("./is-format-equal");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Normalises formats: ensures subsequent adjacent equal formats have the same
* reference.
*
* @param {RichTextValue} value Value to normalise formats of.
*
* @return {RichTextValue} New value with normalised formats.
*/
function normaliseFormats(value) {
const newFormats = value.formats.slice();
newFormats.forEach((formatsAtIndex, index) => {
const formatsAtPreviousIndex = newFormats[index - 1];
if (formatsAtPreviousIndex) {
const newFormatsAtIndex = formatsAtIndex.slice();
newFormatsAtIndex.forEach((format, formatIndex) => {
const previousFormat = formatsAtPreviousIndex[formatIndex];
if ((0, _isFormatEqual.isFormatEqual)(format, previousFormat)) {
newFormatsAtIndex[formatIndex] = previousFormat;
}
});
newFormats[index] = newFormatsAtIndex;
}
});
return {
...value,
formats: newFormats
};
}
//# sourceMappingURL=normalise-formats.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_isFormatEqual","require","normaliseFormats","value","newFormats","formats","slice","forEach","formatsAtIndex","index","formatsAtPreviousIndex","newFormatsAtIndex","format","formatIndex","previousFormat","isFormatEqual"],"sources":["@wordpress/rich-text/src/normalise-formats.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nimport { isFormatEqual } from './is-format-equal';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Normalises formats: ensures subsequent adjacent equal formats have the same\n * reference.\n *\n * @param {RichTextValue} value Value to normalise formats of.\n *\n * @return {RichTextValue} New value with normalised formats.\n */\nexport function normaliseFormats( value ) {\n\tconst newFormats = value.formats.slice();\n\n\tnewFormats.forEach( ( formatsAtIndex, index ) => {\n\t\tconst formatsAtPreviousIndex = newFormats[ index - 1 ];\n\n\t\tif ( formatsAtPreviousIndex ) {\n\t\t\tconst newFormatsAtIndex = formatsAtIndex.slice();\n\n\t\t\tnewFormatsAtIndex.forEach( ( format, formatIndex ) => {\n\t\t\t\tconst previousFormat = formatsAtPreviousIndex[ formatIndex ];\n\n\t\t\t\tif ( isFormatEqual( format, previousFormat ) ) {\n\t\t\t\t\tnewFormatsAtIndex[ formatIndex ] = previousFormat;\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tnewFormats[ index ] = newFormatsAtIndex;\n\t\t}\n\t} );\n\n\treturn {\n\t\t...value,\n\t\tformats: newFormats,\n\t};\n}\n"],"mappings":";;;;;;AAIA,IAAAA,cAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAEC,KAAK,EAAG;EACzC,MAAMC,UAAU,GAAGD,KAAK,CAACE,OAAO,CAACC,KAAK,CAAC,CAAC;EAExCF,UAAU,CAACG,OAAO,CAAE,CAAEC,cAAc,EAAEC,KAAK,KAAM;IAChD,MAAMC,sBAAsB,GAAGN,UAAU,CAAEK,KAAK,GAAG,CAAC,CAAE;IAEtD,IAAKC,sBAAsB,EAAG;MAC7B,MAAMC,iBAAiB,GAAGH,cAAc,CAACF,KAAK,CAAC,CAAC;MAEhDK,iBAAiB,CAACJ,OAAO,CAAE,CAAEK,MAAM,EAAEC,WAAW,KAAM;QACrD,MAAMC,cAAc,GAAGJ,sBAAsB,CAAEG,WAAW,CAAE;QAE5D,IAAK,IAAAE,4BAAa,EAAEH,MAAM,EAAEE,cAAe,CAAC,EAAG;UAC9CH,iBAAiB,CAAEE,WAAW,CAAE,GAAGC,cAAc;QAClD;MACD,CAAE,CAAC;MAEHV,UAAU,CAAEK,KAAK,CAAE,GAAGE,iBAAiB;IACxC;EACD,CAAE,CAAC;EAEH,OAAO;IACN,GAAGR,KAAK;IACRE,OAAO,EAAED;EACV,CAAC;AACF","ignoreList":[]}

View File

@@ -0,0 +1,98 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.registerFormatType = registerFormatType;
var _data = require("@wordpress/data");
var _store = require("./store");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* @typedef {Object} WPFormat
*
* @property {string} name A string identifying the format. Must be
* unique across all registered formats.
* @property {string} tagName The HTML tag this format will wrap the
* selection with.
* @property {boolean} interactive Whether format makes content interactive or not.
* @property {string | null} [className] A class to match the format.
* @property {string} title Name of the format.
* @property {Function} edit Should return a component for the user to
* interact with the new registered format.
*/
/**
* Registers a new format provided a unique name and an object defining its
* behavior.
*
* @param {string} name Format name.
* @param {WPFormat} settings Format settings.
*
* @return {WPFormat|undefined} The format, if it has been successfully
* registered; otherwise `undefined`.
*/
function registerFormatType(name, settings) {
settings = {
name,
...settings
};
if (typeof settings.name !== 'string') {
window.console.error('Format names must be strings.');
return;
}
if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(settings.name)) {
window.console.error('Format names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-format');
return;
}
if ((0, _data.select)(_store.store).getFormatType(settings.name)) {
window.console.error('Format "' + settings.name + '" is already registered.');
return;
}
if (typeof settings.tagName !== 'string' || settings.tagName === '') {
window.console.error('Format tag names must be a string.');
return;
}
if ((typeof settings.className !== 'string' || settings.className === '') && settings.className !== null) {
window.console.error('Format class names must be a string, or null to handle bare elements.');
return;
}
if (!/^[_a-zA-Z]+[a-zA-Z0-9_-]*$/.test(settings.className)) {
window.console.error('A class name must begin with a letter, followed by any number of hyphens, underscores, letters, or numbers.');
return;
}
if (settings.className === null) {
const formatTypeForBareElement = (0, _data.select)(_store.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}".`);
return;
}
} else {
const formatTypeForClassName = (0, _data.select)(_store.store).getFormatTypeForClassName(settings.className);
if (formatTypeForClassName) {
window.console.error(`Format "${formatTypeForClassName.name}" is already registered to handle class name "${settings.className}".`);
return;
}
}
if (!('title' in settings) || settings.title === '') {
window.console.error('The format "' + settings.name + '" must have a title.');
return;
}
if ('keywords' in settings && settings.keywords.length > 3) {
window.console.error('The format "' + settings.name + '" can have a maximum of 3 keywords.');
return;
}
if (typeof settings.title !== 'string') {
window.console.error('Format titles must be strings.');
return;
}
(0, _data.dispatch)(_store.store).addFormatTypes(settings);
return settings;
}
//# sourceMappingURL=register-format-type.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.removeFormat = removeFormat;
var _normaliseFormats = require("./normalise-formats");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Remove any format object from a Rich Text value by type from the given
* `startIndex` to the given `endIndex`. Indices are retrieved from the
* selection if none are provided.
*
* @param {RichTextValue} value Value to modify.
* @param {string} formatType Format type to remove.
* @param {number} [startIndex] Start index.
* @param {number} [endIndex] End index.
*
* @return {RichTextValue} A new value with the format applied.
*/
function removeFormat(value, formatType, startIndex = value.start, endIndex = value.end) {
const {
formats,
activeFormats
} = value;
const newFormats = formats.slice();
// If the selection is collapsed, expand start and end to the edges of the
// format.
if (startIndex === endIndex) {
const format = newFormats[startIndex]?.find(({
type
}) => type === formatType);
if (format) {
while (newFormats[startIndex]?.find(newFormat => newFormat === format)) {
filterFormats(newFormats, startIndex, formatType);
startIndex--;
}
endIndex++;
while (newFormats[endIndex]?.find(newFormat => newFormat === format)) {
filterFormats(newFormats, endIndex, formatType);
endIndex++;
}
}
} else {
for (let i = startIndex; i < endIndex; i++) {
if (newFormats[i]) {
filterFormats(newFormats, i, formatType);
}
}
}
return (0, _normaliseFormats.normaliseFormats)({
...value,
formats: newFormats,
activeFormats: activeFormats?.filter(({
type
}) => type !== formatType) || []
});
}
function filterFormats(formats, index, formatType) {
const newFormats = formats[index].filter(({
type
}) => type !== formatType);
if (newFormats.length) {
formats[index] = newFormats;
} else {
delete formats[index];
}
}
//# sourceMappingURL=remove-format.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_normaliseFormats","require","removeFormat","value","formatType","startIndex","start","endIndex","end","formats","activeFormats","newFormats","slice","format","find","type","newFormat","filterFormats","i","normaliseFormats","filter","index","length"],"sources":["@wordpress/rich-text/src/remove-format.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nimport { normaliseFormats } from './normalise-formats';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Remove any format object from a Rich Text value by type from the given\n * `startIndex` to the given `endIndex`. Indices are retrieved from the\n * selection if none are provided.\n *\n * @param {RichTextValue} value Value to modify.\n * @param {string} formatType Format type to remove.\n * @param {number} [startIndex] Start index.\n * @param {number} [endIndex] End index.\n *\n * @return {RichTextValue} A new value with the format applied.\n */\nexport function removeFormat(\n\tvalue,\n\tformatType,\n\tstartIndex = value.start,\n\tendIndex = value.end\n) {\n\tconst { formats, activeFormats } = value;\n\tconst newFormats = formats.slice();\n\n\t// If the selection is collapsed, expand start and end to the edges of the\n\t// format.\n\tif ( startIndex === endIndex ) {\n\t\tconst format = newFormats[ startIndex ]?.find(\n\t\t\t( { type } ) => type === formatType\n\t\t);\n\n\t\tif ( format ) {\n\t\t\twhile (\n\t\t\t\tnewFormats[ startIndex ]?.find(\n\t\t\t\t\t( newFormat ) => newFormat === format\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tfilterFormats( newFormats, startIndex, formatType );\n\t\t\t\tstartIndex--;\n\t\t\t}\n\n\t\t\tendIndex++;\n\n\t\t\twhile (\n\t\t\t\tnewFormats[ endIndex ]?.find(\n\t\t\t\t\t( newFormat ) => newFormat === format\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tfilterFormats( newFormats, endIndex, formatType );\n\t\t\t\tendIndex++;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ( let i = startIndex; i < endIndex; i++ ) {\n\t\t\tif ( newFormats[ i ] ) {\n\t\t\t\tfilterFormats( newFormats, i, formatType );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn normaliseFormats( {\n\t\t...value,\n\t\tformats: newFormats,\n\t\tactiveFormats:\n\t\t\tactiveFormats?.filter( ( { type } ) => type !== formatType ) || [],\n\t} );\n}\n\nfunction filterFormats( formats, index, formatType ) {\n\tconst newFormats = formats[ index ].filter(\n\t\t( { type } ) => type !== formatType\n\t);\n\n\tif ( newFormats.length ) {\n\t\tformats[ index ] = newFormats;\n\t} else {\n\t\tdelete formats[ index ];\n\t}\n}\n"],"mappings":";;;;;;AAIA,IAAAA,iBAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAC3BC,KAAK,EACLC,UAAU,EACVC,UAAU,GAAGF,KAAK,CAACG,KAAK,EACxBC,QAAQ,GAAGJ,KAAK,CAACK,GAAG,EACnB;EACD,MAAM;IAAEC,OAAO;IAAEC;EAAc,CAAC,GAAGP,KAAK;EACxC,MAAMQ,UAAU,GAAGF,OAAO,CAACG,KAAK,CAAC,CAAC;;EAElC;EACA;EACA,IAAKP,UAAU,KAAKE,QAAQ,EAAG;IAC9B,MAAMM,MAAM,GAAGF,UAAU,CAAEN,UAAU,CAAE,EAAES,IAAI,CAC5C,CAAE;MAAEC;IAAK,CAAC,KAAMA,IAAI,KAAKX,UAC1B,CAAC;IAED,IAAKS,MAAM,EAAG;MACb,OACCF,UAAU,CAAEN,UAAU,CAAE,EAAES,IAAI,CAC3BE,SAAS,IAAMA,SAAS,KAAKH,MAChC,CAAC,EACA;QACDI,aAAa,CAAEN,UAAU,EAAEN,UAAU,EAAED,UAAW,CAAC;QACnDC,UAAU,EAAE;MACb;MAEAE,QAAQ,EAAE;MAEV,OACCI,UAAU,CAAEJ,QAAQ,CAAE,EAAEO,IAAI,CACzBE,SAAS,IAAMA,SAAS,KAAKH,MAChC,CAAC,EACA;QACDI,aAAa,CAAEN,UAAU,EAAEJ,QAAQ,EAAEH,UAAW,CAAC;QACjDG,QAAQ,EAAE;MACX;IACD;EACD,CAAC,MAAM;IACN,KAAM,IAAIW,CAAC,GAAGb,UAAU,EAAEa,CAAC,GAAGX,QAAQ,EAAEW,CAAC,EAAE,EAAG;MAC7C,IAAKP,UAAU,CAAEO,CAAC,CAAE,EAAG;QACtBD,aAAa,CAAEN,UAAU,EAAEO,CAAC,EAAEd,UAAW,CAAC;MAC3C;IACD;EACD;EAEA,OAAO,IAAAe,kCAAgB,EAAE;IACxB,GAAGhB,KAAK;IACRM,OAAO,EAAEE,UAAU;IACnBD,aAAa,EACZA,aAAa,EAAEU,MAAM,CAAE,CAAE;MAAEL;IAAK,CAAC,KAAMA,IAAI,KAAKX,UAAW,CAAC,IAAI;EAClE,CAAE,CAAC;AACJ;AAEA,SAASa,aAAaA,CAAER,OAAO,EAAEY,KAAK,EAAEjB,UAAU,EAAG;EACpD,MAAMO,UAAU,GAAGF,OAAO,CAAEY,KAAK,CAAE,CAACD,MAAM,CACzC,CAAE;IAAEL;EAAK,CAAC,KAAMA,IAAI,KAAKX,UAC1B,CAAC;EAED,IAAKO,UAAU,CAACW,MAAM,EAAG;IACxBb,OAAO,CAAEY,KAAK,CAAE,GAAGV,UAAU;EAC9B,CAAC,MAAM;IACN,OAAOF,OAAO,CAAEY,KAAK,CAAE;EACxB;AACD","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=remove-unregistered-formatting.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/rich-text/src/remove-unregistered-formatting.js"],"sourcesContent":[""],"mappings":"","ignoreList":[]}

28
node_modules/@wordpress/rich-text/build/remove.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.remove = remove;
var _insert = require("./insert");
var _create = require("./create");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Remove content from a Rich Text value between the given `startIndex` and
* `endIndex`. Indices are retrieved from the selection if none are provided.
*
* @param {RichTextValue} value Value to modify.
* @param {number} [startIndex] Start index.
* @param {number} [endIndex] End index.
*
* @return {RichTextValue} A new value with the content removed.
*/
function remove(value, startIndex, endIndex) {
return (0, _insert.insert)(value, (0, _create.create)(), startIndex, endIndex);
}
//# sourceMappingURL=remove.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_insert","require","_create","remove","value","startIndex","endIndex","insert","create"],"sources":["@wordpress/rich-text/src/remove.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nimport { insert } from './insert';\nimport { create } from './create';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Remove content from a Rich Text value between the given `startIndex` and\n * `endIndex`. Indices are retrieved from the selection if none are provided.\n *\n * @param {RichTextValue} value Value to modify.\n * @param {number} [startIndex] Start index.\n * @param {number} [endIndex] End index.\n *\n * @return {RichTextValue} A new value with the content removed.\n */\nexport function remove( value, startIndex, endIndex ) {\n\treturn insert( value, create(), startIndex, endIndex );\n}\n"],"mappings":";;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,MAAMA,CAAEC,KAAK,EAAEC,UAAU,EAAEC,QAAQ,EAAG;EACrD,OAAO,IAAAC,cAAM,EAAEH,KAAK,EAAE,IAAAI,cAAM,EAAC,CAAC,EAAEH,UAAU,EAAEC,QAAS,CAAC;AACvD","ignoreList":[]}

71
node_modules/@wordpress/rich-text/build/replace.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.replace = replace;
var _normaliseFormats = require("./normalise-formats");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Search a Rich Text value and replace the match(es) with `replacement`. This
* is similar to `String.prototype.replace`.
*
* @param {RichTextValue} value The value to modify.
* @param {RegExp|string} pattern A RegExp object or literal. Can also be
* a string. It is treated as a verbatim
* string and is not interpreted as a
* regular expression. Only the first
* occurrence will be replaced.
* @param {Function|string} replacement The match or matches are replaced with
* the specified or the value returned by
* the specified function.
*
* @return {RichTextValue} A new value with replacements applied.
*/
function replace({
formats,
replacements,
text,
start,
end
}, pattern, replacement) {
text = text.replace(pattern, (match, ...rest) => {
const offset = rest[rest.length - 2];
let newText = replacement;
let newFormats;
let newReplacements;
if (typeof newText === 'function') {
newText = replacement(match, ...rest);
}
if (typeof newText === 'object') {
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));
replacements = replacements.slice(0, offset).concat(newReplacements, replacements.slice(offset + match.length));
if (start) {
start = end = offset + newText.length;
}
return newText;
});
return (0, _normaliseFormats.normaliseFormats)({
formats,
replacements,
text,
start,
end
});
}
//# sourceMappingURL=replace.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_normaliseFormats","require","replace","formats","replacements","text","start","end","pattern","replacement","match","rest","offset","length","newText","newFormats","newReplacements","Array","fill","slice","concat","normaliseFormats"],"sources":["@wordpress/rich-text/src/replace.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nimport { normaliseFormats } from './normalise-formats';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Search a Rich Text value and replace the match(es) with `replacement`. This\n * is similar to `String.prototype.replace`.\n *\n * @param {RichTextValue} value The value to modify.\n * @param {RegExp|string} pattern A RegExp object or literal. Can also be\n * a string. It is treated as a verbatim\n * string and is not interpreted as a\n * regular expression. Only the first\n * occurrence will be replaced.\n * @param {Function|string} replacement The match or matches are replaced with\n * the specified or the value returned by\n * the specified function.\n *\n * @return {RichTextValue} A new value with replacements applied.\n */\nexport function replace(\n\t{ formats, replacements, text, start, end },\n\tpattern,\n\treplacement\n) {\n\ttext = text.replace( pattern, ( match, ...rest ) => {\n\t\tconst offset = rest[ rest.length - 2 ];\n\t\tlet newText = replacement;\n\t\tlet newFormats;\n\t\tlet newReplacements;\n\n\t\tif ( typeof newText === 'function' ) {\n\t\t\tnewText = replacement( match, ...rest );\n\t\t}\n\n\t\tif ( typeof newText === 'object' ) {\n\t\t\tnewFormats = newText.formats;\n\t\t\tnewReplacements = newText.replacements;\n\t\t\tnewText = newText.text;\n\t\t} else {\n\t\t\tnewFormats = Array( newText.length );\n\t\t\tnewReplacements = Array( newText.length );\n\n\t\t\tif ( formats[ offset ] ) {\n\t\t\t\tnewFormats = newFormats.fill( formats[ offset ] );\n\t\t\t}\n\t\t}\n\n\t\tformats = formats\n\t\t\t.slice( 0, offset )\n\t\t\t.concat( newFormats, formats.slice( offset + match.length ) );\n\t\treplacements = replacements\n\t\t\t.slice( 0, offset )\n\t\t\t.concat(\n\t\t\t\tnewReplacements,\n\t\t\t\treplacements.slice( offset + match.length )\n\t\t\t);\n\n\t\tif ( start ) {\n\t\t\tstart = end = offset + newText.length;\n\t\t}\n\n\t\treturn newText;\n\t} );\n\n\treturn normaliseFormats( { formats, replacements, text, start, end } );\n}\n"],"mappings":";;;;;;AAIA,IAAAA,iBAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CACtB;EAAEC,OAAO;EAAEC,YAAY;EAAEC,IAAI;EAAEC,KAAK;EAAEC;AAAI,CAAC,EAC3CC,OAAO,EACPC,WAAW,EACV;EACDJ,IAAI,GAAGA,IAAI,CAACH,OAAO,CAAEM,OAAO,EAAE,CAAEE,KAAK,EAAE,GAAGC,IAAI,KAAM;IACnD,MAAMC,MAAM,GAAGD,IAAI,CAAEA,IAAI,CAACE,MAAM,GAAG,CAAC,CAAE;IACtC,IAAIC,OAAO,GAAGL,WAAW;IACzB,IAAIM,UAAU;IACd,IAAIC,eAAe;IAEnB,IAAK,OAAOF,OAAO,KAAK,UAAU,EAAG;MACpCA,OAAO,GAAGL,WAAW,CAAEC,KAAK,EAAE,GAAGC,IAAK,CAAC;IACxC;IAEA,IAAK,OAAOG,OAAO,KAAK,QAAQ,EAAG;MAClCC,UAAU,GAAGD,OAAO,CAACX,OAAO;MAC5Ba,eAAe,GAAGF,OAAO,CAACV,YAAY;MACtCU,OAAO,GAAGA,OAAO,CAACT,IAAI;IACvB,CAAC,MAAM;MACNU,UAAU,GAAGE,KAAK,CAAEH,OAAO,CAACD,MAAO,CAAC;MACpCG,eAAe,GAAGC,KAAK,CAAEH,OAAO,CAACD,MAAO,CAAC;MAEzC,IAAKV,OAAO,CAAES,MAAM,CAAE,EAAG;QACxBG,UAAU,GAAGA,UAAU,CAACG,IAAI,CAAEf,OAAO,CAAES,MAAM,CAAG,CAAC;MAClD;IACD;IAEAT,OAAO,GAAGA,OAAO,CACfgB,KAAK,CAAE,CAAC,EAAEP,MAAO,CAAC,CAClBQ,MAAM,CAAEL,UAAU,EAAEZ,OAAO,CAACgB,KAAK,CAAEP,MAAM,GAAGF,KAAK,CAACG,MAAO,CAAE,CAAC;IAC9DT,YAAY,GAAGA,YAAY,CACzBe,KAAK,CAAE,CAAC,EAAEP,MAAO,CAAC,CAClBQ,MAAM,CACNJ,eAAe,EACfZ,YAAY,CAACe,KAAK,CAAEP,MAAM,GAAGF,KAAK,CAACG,MAAO,CAC3C,CAAC;IAEF,IAAKP,KAAK,EAAG;MACZA,KAAK,GAAGC,GAAG,GAAGK,MAAM,GAAGE,OAAO,CAACD,MAAM;IACtC;IAEA,OAAOC,OAAO;EACf,CAAE,CAAC;EAEH,OAAO,IAAAO,kCAAgB,EAAE;IAAElB,OAAO;IAAEC,YAAY;IAAEC,IAAI;IAAEC,KAAK;IAAEC;EAAI,CAAE,CAAC;AACvE","ignoreList":[]}

37
node_modules/@wordpress/rich-text/build/slice.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.slice = slice;
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Slice a Rich Text value from `startIndex` to `endIndex`. Indices are
* retrieved from the selection if none are provided. This is similar to
* `String.prototype.slice`.
*
* @param {RichTextValue} value Value to modify.
* @param {number} [startIndex] Start index.
* @param {number} [endIndex] End index.
*
* @return {RichTextValue} A new extracted value.
*/
function slice(value, startIndex = value.start, endIndex = value.end) {
const {
formats,
replacements,
text
} = value;
if (startIndex === undefined || endIndex === undefined) {
return {
...value
};
}
return {
formats: formats.slice(startIndex, endIndex),
replacements: replacements.slice(startIndex, endIndex),
text: text.slice(startIndex, endIndex)
};
}
//# sourceMappingURL=slice.js.map

1
node_modules/@wordpress/rich-text/build/slice.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"names":["slice","value","startIndex","start","endIndex","end","formats","replacements","text","undefined"],"sources":["@wordpress/rich-text/src/slice.js"],"sourcesContent":["/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Slice a Rich Text value from `startIndex` to `endIndex`. Indices are\n * retrieved from the selection if none are provided. This is similar to\n * `String.prototype.slice`.\n *\n * @param {RichTextValue} value Value to modify.\n * @param {number} [startIndex] Start index.\n * @param {number} [endIndex] End index.\n *\n * @return {RichTextValue} A new extracted value.\n */\nexport function slice( value, startIndex = value.start, endIndex = value.end ) {\n\tconst { formats, replacements, text } = value;\n\n\tif ( startIndex === undefined || endIndex === undefined ) {\n\t\treturn { ...value };\n\t}\n\n\treturn {\n\t\tformats: formats.slice( startIndex, endIndex ),\n\t\treplacements: replacements.slice( startIndex, endIndex ),\n\t\ttext: text.slice( startIndex, endIndex ),\n\t};\n}\n"],"mappings":";;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,KAAKA,CAAEC,KAAK,EAAEC,UAAU,GAAGD,KAAK,CAACE,KAAK,EAAEC,QAAQ,GAAGH,KAAK,CAACI,GAAG,EAAG;EAC9E,MAAM;IAAEC,OAAO;IAAEC,YAAY;IAAEC;EAAK,CAAC,GAAGP,KAAK;EAE7C,IAAKC,UAAU,KAAKO,SAAS,IAAIL,QAAQ,KAAKK,SAAS,EAAG;IACzD,OAAO;MAAE,GAAGR;IAAM,CAAC;EACpB;EAEA,OAAO;IACNK,OAAO,EAAEA,OAAO,CAACN,KAAK,CAAEE,UAAU,EAAEE,QAAS,CAAC;IAC9CG,YAAY,EAAEA,YAAY,CAACP,KAAK,CAAEE,UAAU,EAAEE,QAAS,CAAC;IACxDI,IAAI,EAAEA,IAAI,CAACR,KAAK,CAAEE,UAAU,EAAEE,QAAS;EACxC,CAAC;AACF","ignoreList":[]}

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ZWNBSP = exports.OBJECT_REPLACEMENT_CHARACTER = void 0;
/**
* Object replacement character, used as a placeholder for objects.
*/
const OBJECT_REPLACEMENT_CHARACTER = exports.OBJECT_REPLACEMENT_CHARACTER = '\ufffc';
/**
* Zero width non-breaking space, used as padding in the editable DOM tree when
* it is empty otherwise.
*/
const ZWNBSP = exports.ZWNBSP = '\ufeff';
//# sourceMappingURL=special-characters.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["OBJECT_REPLACEMENT_CHARACTER","exports","ZWNBSP"],"sources":["@wordpress/rich-text/src/special-characters.js"],"sourcesContent":["/**\n * Object replacement character, used as a placeholder for objects.\n */\nexport const OBJECT_REPLACEMENT_CHARACTER = '\\ufffc';\n\n/**\n * Zero width non-breaking space, used as padding in the editable DOM tree when\n * it is empty otherwise.\n */\nexport const ZWNBSP = '\\ufeff';\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACO,MAAMA,4BAA4B,GAAAC,OAAA,CAAAD,4BAAA,GAAG,QAAQ;;AAEpD;AACA;AACA;AACA;AACO,MAAME,MAAM,GAAAD,OAAA,CAAAC,MAAA,GAAG,QAAQ","ignoreList":[]}

81
node_modules/@wordpress/rich-text/build/split.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.split = split;
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Split a Rich Text value in two at the given `startIndex` and `endIndex`, or
* split at the given separator. This is similar to `String.prototype.split`.
* Indices are retrieved from the selection if none are provided.
*
* @param {RichTextValue} value
* @param {number|string} [string] Start index, or string at which to split.
*
* @return {Array<RichTextValue>|undefined} An array of new values.
*/
function split({
formats,
replacements,
text,
start,
end
}, string) {
if (typeof string !== 'string') {
return splitAtSelection(...arguments);
}
let nextStart = 0;
return text.split(string).map(substring => {
const startIndex = nextStart;
const value = {
formats: formats.slice(startIndex, startIndex + substring.length),
replacements: replacements.slice(startIndex, startIndex + substring.length),
text: substring
};
nextStart += string.length + substring.length;
if (start !== undefined && end !== undefined) {
if (start >= startIndex && start < nextStart) {
value.start = start - startIndex;
} else if (start < startIndex && end > startIndex) {
value.start = 0;
}
if (end >= startIndex && end < nextStart) {
value.end = end - startIndex;
} else if (start < nextStart && end > nextStart) {
value.end = substring.length;
}
}
return value;
});
}
function splitAtSelection({
formats,
replacements,
text,
start,
end
}, startIndex = start, endIndex = end) {
if (start === undefined || end === undefined) {
return;
}
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];
}
//# sourceMappingURL=split.js.map

1
node_modules/@wordpress/rich-text/build/split.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"names":["split","formats","replacements","text","start","end","string","splitAtSelection","arguments","nextStart","map","substring","startIndex","value","slice","length","undefined","endIndex","before","after"],"sources":["@wordpress/rich-text/src/split.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Split a Rich Text value in two at the given `startIndex` and `endIndex`, or\n * split at the given separator. This is similar to `String.prototype.split`.\n * Indices are retrieved from the selection if none are provided.\n *\n * @param {RichTextValue} value\n * @param {number|string} [string] Start index, or string at which to split.\n *\n * @return {Array<RichTextValue>|undefined} An array of new values.\n */\nexport function split( { formats, replacements, text, start, end }, string ) {\n\tif ( typeof string !== 'string' ) {\n\t\treturn splitAtSelection( ...arguments );\n\t}\n\n\tlet nextStart = 0;\n\n\treturn text.split( string ).map( ( substring ) => {\n\t\tconst startIndex = nextStart;\n\t\tconst value = {\n\t\t\tformats: formats.slice( startIndex, startIndex + substring.length ),\n\t\t\treplacements: replacements.slice(\n\t\t\t\tstartIndex,\n\t\t\t\tstartIndex + substring.length\n\t\t\t),\n\t\t\ttext: substring,\n\t\t};\n\n\t\tnextStart += string.length + substring.length;\n\n\t\tif ( start !== undefined && end !== undefined ) {\n\t\t\tif ( start >= startIndex && start < nextStart ) {\n\t\t\t\tvalue.start = start - startIndex;\n\t\t\t} else if ( start < startIndex && end > startIndex ) {\n\t\t\t\tvalue.start = 0;\n\t\t\t}\n\n\t\t\tif ( end >= startIndex && end < nextStart ) {\n\t\t\t\tvalue.end = end - startIndex;\n\t\t\t} else if ( start < nextStart && end > nextStart ) {\n\t\t\t\tvalue.end = substring.length;\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t} );\n}\n\nfunction splitAtSelection(\n\t{ formats, replacements, text, start, end },\n\tstartIndex = start,\n\tendIndex = end\n) {\n\tif ( start === undefined || end === undefined ) {\n\t\treturn;\n\t}\n\n\tconst before = {\n\t\tformats: formats.slice( 0, startIndex ),\n\t\treplacements: replacements.slice( 0, startIndex ),\n\t\ttext: text.slice( 0, startIndex ),\n\t};\n\tconst after = {\n\t\tformats: formats.slice( endIndex ),\n\t\treplacements: replacements.slice( endIndex ),\n\t\ttext: text.slice( endIndex ),\n\t\tstart: 0,\n\t\tend: 0,\n\t};\n\n\treturn [ before, after ];\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,KAAKA,CAAE;EAAEC,OAAO;EAAEC,YAAY;EAAEC,IAAI;EAAEC,KAAK;EAAEC;AAAI,CAAC,EAAEC,MAAM,EAAG;EAC5E,IAAK,OAAOA,MAAM,KAAK,QAAQ,EAAG;IACjC,OAAOC,gBAAgB,CAAE,GAAGC,SAAU,CAAC;EACxC;EAEA,IAAIC,SAAS,GAAG,CAAC;EAEjB,OAAON,IAAI,CAACH,KAAK,CAAEM,MAAO,CAAC,CAACI,GAAG,CAAIC,SAAS,IAAM;IACjD,MAAMC,UAAU,GAAGH,SAAS;IAC5B,MAAMI,KAAK,GAAG;MACbZ,OAAO,EAAEA,OAAO,CAACa,KAAK,CAAEF,UAAU,EAAEA,UAAU,GAAGD,SAAS,CAACI,MAAO,CAAC;MACnEb,YAAY,EAAEA,YAAY,CAACY,KAAK,CAC/BF,UAAU,EACVA,UAAU,GAAGD,SAAS,CAACI,MACxB,CAAC;MACDZ,IAAI,EAAEQ;IACP,CAAC;IAEDF,SAAS,IAAIH,MAAM,CAACS,MAAM,GAAGJ,SAAS,CAACI,MAAM;IAE7C,IAAKX,KAAK,KAAKY,SAAS,IAAIX,GAAG,KAAKW,SAAS,EAAG;MAC/C,IAAKZ,KAAK,IAAIQ,UAAU,IAAIR,KAAK,GAAGK,SAAS,EAAG;QAC/CI,KAAK,CAACT,KAAK,GAAGA,KAAK,GAAGQ,UAAU;MACjC,CAAC,MAAM,IAAKR,KAAK,GAAGQ,UAAU,IAAIP,GAAG,GAAGO,UAAU,EAAG;QACpDC,KAAK,CAACT,KAAK,GAAG,CAAC;MAChB;MAEA,IAAKC,GAAG,IAAIO,UAAU,IAAIP,GAAG,GAAGI,SAAS,EAAG;QAC3CI,KAAK,CAACR,GAAG,GAAGA,GAAG,GAAGO,UAAU;MAC7B,CAAC,MAAM,IAAKR,KAAK,GAAGK,SAAS,IAAIJ,GAAG,GAAGI,SAAS,EAAG;QAClDI,KAAK,CAACR,GAAG,GAAGM,SAAS,CAACI,MAAM;MAC7B;IACD;IAEA,OAAOF,KAAK;EACb,CAAE,CAAC;AACJ;AAEA,SAASN,gBAAgBA,CACxB;EAAEN,OAAO;EAAEC,YAAY;EAAEC,IAAI;EAAEC,KAAK;EAAEC;AAAI,CAAC,EAC3CO,UAAU,GAAGR,KAAK,EAClBa,QAAQ,GAAGZ,GAAG,EACb;EACD,IAAKD,KAAK,KAAKY,SAAS,IAAIX,GAAG,KAAKW,SAAS,EAAG;IAC/C;EACD;EAEA,MAAME,MAAM,GAAG;IACdjB,OAAO,EAAEA,OAAO,CAACa,KAAK,CAAE,CAAC,EAAEF,UAAW,CAAC;IACvCV,YAAY,EAAEA,YAAY,CAACY,KAAK,CAAE,CAAC,EAAEF,UAAW,CAAC;IACjDT,IAAI,EAAEA,IAAI,CAACW,KAAK,CAAE,CAAC,EAAEF,UAAW;EACjC,CAAC;EACD,MAAMO,KAAK,GAAG;IACblB,OAAO,EAAEA,OAAO,CAACa,KAAK,CAAEG,QAAS,CAAC;IAClCf,YAAY,EAAEA,YAAY,CAACY,KAAK,CAAEG,QAAS,CAAC;IAC5Cd,IAAI,EAAEA,IAAI,CAACW,KAAK,CAAEG,QAAS,CAAC;IAC5Bb,KAAK,EAAE,CAAC;IACRC,GAAG,EAAE;EACN,CAAC;EAED,OAAO,CAAEa,MAAM,EAAEC,KAAK,CAAE;AACzB","ignoreList":[]}

View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addFormatTypes = addFormatTypes;
exports.removeFormatTypes = removeFormatTypes;
/**
* Returns an action object used in signalling that format types have been
* added.
* Ignored from documentation as registerFormatType should be used instead from @wordpress/rich-text
*
* @ignore
*
* @param {Array|Object} formatTypes Format types received.
*
* @return {Object} Action object.
*/
function addFormatTypes(formatTypes) {
return {
type: 'ADD_FORMAT_TYPES',
formatTypes: Array.isArray(formatTypes) ? formatTypes : [formatTypes]
};
}
/**
* Returns an action object used to remove a registered format type.
*
* Ignored from documentation as unregisterFormatType should be used instead from @wordpress/rich-text
*
* @ignore
*
* @param {string|Array} names Format name.
*
* @return {Object} Action object.
*/
function removeFormatTypes(names) {
return {
type: 'REMOVE_FORMAT_TYPES',
names: Array.isArray(names) ? names : [names]
};
}
//# sourceMappingURL=actions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["addFormatTypes","formatTypes","type","Array","isArray","removeFormatTypes","names"],"sources":["@wordpress/rich-text/src/store/actions.js"],"sourcesContent":["/**\n * Returns an action object used in signalling that format types have been\n * added.\n * Ignored from documentation as registerFormatType should be used instead from @wordpress/rich-text\n *\n * @ignore\n *\n * @param {Array|Object} formatTypes Format types received.\n *\n * @return {Object} Action object.\n */\nexport function addFormatTypes( formatTypes ) {\n\treturn {\n\t\ttype: 'ADD_FORMAT_TYPES',\n\t\tformatTypes: Array.isArray( formatTypes )\n\t\t\t? formatTypes\n\t\t\t: [ formatTypes ],\n\t};\n}\n\n/**\n * Returns an action object used to remove a registered format type.\n *\n * Ignored from documentation as unregisterFormatType should be used instead from @wordpress/rich-text\n *\n * @ignore\n *\n * @param {string|Array} names Format name.\n *\n * @return {Object} Action object.\n */\nexport function removeFormatTypes( names ) {\n\treturn {\n\t\ttype: 'REMOVE_FORMAT_TYPES',\n\t\tnames: Array.isArray( names ) ? names : [ names ],\n\t};\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAcA,CAAEC,WAAW,EAAG;EAC7C,OAAO;IACNC,IAAI,EAAE,kBAAkB;IACxBD,WAAW,EAAEE,KAAK,CAACC,OAAO,CAAEH,WAAY,CAAC,GACtCA,WAAW,GACX,CAAEA,WAAW;EACjB,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,iBAAiBA,CAAEC,KAAK,EAAG;EAC1C,OAAO;IACNJ,IAAI,EAAE,qBAAqB;IAC3BI,KAAK,EAAEH,KAAK,CAACC,OAAO,CAAEE,KAAM,CAAC,GAAGA,KAAK,GAAG,CAAEA,KAAK;EAChD,CAAC;AACF","ignoreList":[]}

37
node_modules/@wordpress/rich-text/build/store/index.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.store = void 0;
var _data = require("@wordpress/data");
var _reducer = _interopRequireDefault(require("./reducer"));
var selectors = _interopRequireWildcard(require("./selectors"));
var actions = _interopRequireWildcard(require("./actions"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const STORE_NAME = 'core/rich-text';
/**
* Store definition for the rich-text namespace.
*
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
*
* @type {Object}
*/
const store = exports.store = (0, _data.createReduxStore)(STORE_NAME, {
reducer: _reducer.default,
selectors,
actions
});
(0, _data.register)(store);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_data","require","_reducer","_interopRequireDefault","selectors","_interopRequireWildcard","actions","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","STORE_NAME","store","exports","createReduxStore","reducer","register"],"sources":["@wordpress/rich-text/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\n\nconst STORE_NAME = 'core/rich-text';\n\n/**\n * Store definition for the rich-text namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tselectors,\n\tactions,\n} );\n\nregister( store );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAD,uBAAA,CAAAJ,OAAA;AAAqC,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAVrC;AACA;AACA;;AAGA;AACA;AACA;;AAKA,MAAMW,UAAU,GAAG,gBAAgB;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG,IAAAE,sBAAgB,EAAEH,UAAU,EAAE;EAClDI,OAAO,EAAPA,gBAAO;EACP3B,SAAS;EACTE;AACD,CAAE,CAAC;AAEH,IAAA0B,cAAQ,EAAEJ,KAAM,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.formatTypes = formatTypes;
var _data = require("@wordpress/data");
/**
* WordPress dependencies
*/
/**
* Reducer managing the format types
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
function formatTypes(state = {}, action) {
switch (action.type) {
case 'ADD_FORMAT_TYPES':
return {
...state,
// Key format types by their name.
...action.formatTypes.reduce((newFormatTypes, type) => ({
...newFormatTypes,
[type.name]: type
}), {})
};
case 'REMOVE_FORMAT_TYPES':
return Object.fromEntries(Object.entries(state).filter(([key]) => !action.names.includes(key)));
}
return state;
}
var _default = exports.default = (0, _data.combineReducers)({
formatTypes
});
//# sourceMappingURL=reducer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_data","require","formatTypes","state","action","type","reduce","newFormatTypes","name","Object","fromEntries","entries","filter","key","names","includes","_default","exports","default","combineReducers"],"sources":["@wordpress/rich-text/src/store/reducer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer managing the format types\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function formatTypes( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_FORMAT_TYPES':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t// Key format types by their name.\n\t\t\t\t...action.formatTypes.reduce(\n\t\t\t\t\t( newFormatTypes, type ) => ( {\n\t\t\t\t\t\t...newFormatTypes,\n\t\t\t\t\t\t[ type.name ]: type,\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t\t),\n\t\t\t};\n\t\tcase 'REMOVE_FORMAT_TYPES':\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries( state ).filter(\n\t\t\t\t\t( [ key ] ) => ! action.names.includes( key )\n\t\t\t\t)\n\t\t\t);\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( { formatTypes } );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,WAAWA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EACjD,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,kBAAkB;MACtB,OAAO;QACN,GAAGF,KAAK;QACR;QACA,GAAGC,MAAM,CAACF,WAAW,CAACI,MAAM,CAC3B,CAAEC,cAAc,EAAEF,IAAI,MAAQ;UAC7B,GAAGE,cAAc;UACjB,CAAEF,IAAI,CAACG,IAAI,GAAIH;QAChB,CAAC,CAAE,EACH,CAAC,CACF;MACD,CAAC;IACF,KAAK,qBAAqB;MACzB,OAAOI,MAAM,CAACC,WAAW,CACxBD,MAAM,CAACE,OAAO,CAAER,KAAM,CAAC,CAACS,MAAM,CAC7B,CAAE,CAAEC,GAAG,CAAE,KAAM,CAAET,MAAM,CAACU,KAAK,CAACC,QAAQ,CAAEF,GAAI,CAC7C,CACD,CAAC;EACH;EAEA,OAAOV,KAAK;AACb;AAAC,IAAAa,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,qBAAe,EAAE;EAAEjB;AAAY,CAAE,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,170 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getFormatType = getFormatType;
exports.getFormatTypeForBareElement = getFormatTypeForBareElement;
exports.getFormatTypeForClassName = getFormatTypeForClassName;
exports.getFormatTypes = void 0;
var _data = require("@wordpress/data");
/**
* WordPress dependencies
*/
/**
* Returns all the available format types.
*
* @param {Object} state Data state.
*
* @example
* ```js
* import { __, sprintf } from '@wordpress/i18n';
* import { store as richTextStore } from '@wordpress/rich-text';
* import { useSelect } from '@wordpress/data';
*
* const ExampleComponent = () => {
* const { getFormatTypes } = useSelect(
* ( select ) => select( richTextStore ),
* []
* );
*
* const availableFormats = getFormatTypes();
*
* return availableFormats ? (
* <ul>
* { availableFormats?.map( ( format ) => (
* <li>{ format.name }</li>
* ) ) }
* </ul>
* ) : (
* __( 'No Formats available' )
* );
* };
* ```
*
* @return {Array} Format types.
*/
const getFormatTypes = exports.getFormatTypes = (0, _data.createSelector)(state => Object.values(state.formatTypes), state => [state.formatTypes]);
/**
* Returns a format type by name.
*
* @param {Object} state Data state.
* @param {string} name Format type name.
*
* @example
* ```js
* import { __, sprintf } from '@wordpress/i18n';
* import { store as richTextStore } from '@wordpress/rich-text';
* import { useSelect } from '@wordpress/data';
*
* const ExampleComponent = () => {
* const { getFormatType } = useSelect(
* ( select ) => select( richTextStore ),
* []
* );
*
* const boldFormat = getFormatType( 'core/bold' );
*
* return boldFormat ? (
* <ul>
* { Object.entries( boldFormat )?.map( ( [ key, value ] ) => (
* <li>
* { key } : { value }
* </li>
* ) ) }
* </ul>
* ) : (
* __( 'Not Found' )
* ;
* };
* ```
*
* @return {Object?} Format type.
*/
function getFormatType(state, name) {
return state.formatTypes[name];
}
/**
* Gets the format type, if any, that can handle a bare element (without a
* data-format-type attribute), given the tag name of this element.
*
* @param {Object} state Data state.
* @param {string} bareElementTagName The tag name of the element to find a
* format type for.
*
* @example
* ```js
* import { __, sprintf } from '@wordpress/i18n';
* import { store as richTextStore } from '@wordpress/rich-text';
* import { useSelect } from '@wordpress/data';
*
* const ExampleComponent = () => {
* const { getFormatTypeForBareElement } = useSelect(
* ( select ) => select( richTextStore ),
* []
* );
*
* const format = getFormatTypeForBareElement( 'strong' );
*
* return format && <p>{ sprintf( __( 'Format name: %s' ), format.name ) }</p>;
* }
* ```
*
* @return {?Object} Format type.
*/
function getFormatTypeForBareElement(state, bareElementTagName) {
const formatTypes = getFormatTypes(state);
return formatTypes.find(({
className,
tagName
}) => {
return className === null && bareElementTagName === tagName;
}) || formatTypes.find(({
className,
tagName
}) => {
return className === null && '*' === tagName;
});
}
/**
* Gets the format type, if any, that can handle an element, given its classes.
*
* @param {Object} state Data state.
* @param {string} elementClassName The classes of the element to find a format
* type for.
*
* @example
* ```js
* import { __, sprintf } from '@wordpress/i18n';
* import { store as richTextStore } from '@wordpress/rich-text';
* import { useSelect } from '@wordpress/data';
*
* const ExampleComponent = () => {
* const { getFormatTypeForClassName } = useSelect(
* ( select ) => select( richTextStore ),
* []
* );
*
* const format = getFormatTypeForClassName( 'has-inline-color' );
*
* return format && <p>{ sprintf( __( 'Format name: %s' ), format.name ) }</p>;
* };
* ```
*
* @return {?Object} Format type.
*/
function getFormatTypeForClassName(state, elementClassName) {
return getFormatTypes(state).find(({
className
}) => {
if (className === null) {
return false;
}
return ` ${elementClassName} `.indexOf(` ${className} `) >= 0;
});
}
//# sourceMappingURL=selectors.js.map

File diff suppressed because one or more lines are too long

290
node_modules/@wordpress/rich-text/build/to-dom.js generated vendored Normal file
View File

@@ -0,0 +1,290 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.apply = apply;
exports.applySelection = applySelection;
exports.applyValue = applyValue;
exports.toDom = toDom;
var _toTree = require("./to-tree");
var _createElement = require("./create-element");
var _isRangeEqual = require("./is-range-equal");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Creates a path as an array of indices from the given root node to the given
* node.
*
* @param {Node} node Node to find the path of.
* @param {HTMLElement} rootNode Root node to find the path from.
* @param {Array} path Initial path to build on.
*
* @return {Array} The path from the root node to the node.
*/
function createPathToNode(node, rootNode, path) {
const parentNode = node.parentNode;
let i = 0;
while (node = node.previousSibling) {
i++;
}
path = [i, ...path];
if (parentNode !== rootNode) {
path = createPathToNode(parentNode, rootNode, path);
}
return path;
}
/**
* Gets a node given a path (array of indices) from the given node.
*
* @param {HTMLElement} node Root node to find the wanted node in.
* @param {Array} path Path (indices) to the wanted node.
*
* @return {Object} Object with the found node and the remaining offset (if any).
*/
function getNodeByPath(node, path) {
path = [...path];
while (node && path.length > 1) {
node = node.childNodes[path.shift()];
}
return {
node,
offset: path[0]
};
}
function append(element, child) {
if (child.html !== undefined) {
return element.innerHTML += child.html;
}
if (typeof child === 'string') {
child = element.ownerDocument.createTextNode(child);
}
const {
type,
attributes
} = child;
if (type) {
child = element.ownerDocument.createElement(type);
for (const key in attributes) {
child.setAttribute(key, attributes[key]);
}
}
return element.appendChild(child);
}
function appendText(node, text) {
node.appendData(text);
}
function getLastChild({
lastChild
}) {
return lastChild;
}
function getParent({
parentNode
}) {
return parentNode;
}
function isText(node) {
return node.nodeType === node.TEXT_NODE;
}
function getText({
nodeValue
}) {
return nodeValue;
}
function remove(node) {
return node.parentNode.removeChild(node);
}
function toDom({
value,
prepareEditableTree,
isEditableTree = true,
placeholder,
doc = document
}) {
let startPath = [];
let endPath = [];
if (prepareEditableTree) {
value = {
...value,
formats: prepareEditableTree(value)
};
}
/**
* Returns a new instance of a DOM tree upon which RichText operations can be
* applied.
*
* Note: The current implementation will return a shared reference, reset on
* each call to `createEmpty`. Therefore, you should not hold a reference to
* the value to operate upon asynchronously, as it may have unexpected results.
*
* @return {Object} RichText tree.
*/
const createEmpty = () => (0, _createElement.createElement)(doc, '');
const tree = (0, _toTree.toTree)({
value,
createEmpty,
append,
getLastChild,
getParent,
isText,
getText,
remove,
appendText,
onStartIndex(body, pointer) {
startPath = createPathToNode(pointer, body, [pointer.nodeValue.length]);
},
onEndIndex(body, pointer) {
endPath = createPathToNode(pointer, body, [pointer.nodeValue.length]);
},
isEditableTree,
placeholder
});
return {
body: tree,
selection: {
startPath,
endPath
}
};
}
/**
* Create an `Element` tree from a Rich Text value and applies the difference to
* the `Element` tree contained by `current`.
*
* @param {Object} $1 Named arguments.
* @param {RichTextValue} $1.value Value to apply.
* @param {HTMLElement} $1.current The live root node to apply the element tree to.
* @param {Function} [$1.prepareEditableTree] Function to filter editorable formats.
* @param {boolean} [$1.__unstableDomOnly] Only apply elements, no selection.
* @param {string} [$1.placeholder] Placeholder text.
*/
function apply({
value,
current,
prepareEditableTree,
__unstableDomOnly,
placeholder
}) {
// Construct a new element tree in memory.
const {
body,
selection
} = toDom({
value,
prepareEditableTree,
placeholder,
doc: current.ownerDocument
});
applyValue(body, current);
if (value.start !== undefined && !__unstableDomOnly) {
applySelection(selection, current);
}
}
function applyValue(future, current) {
let i = 0;
let futureChild;
while (futureChild = future.firstChild) {
const currentChild = current.childNodes[i];
if (!currentChild) {
current.appendChild(futureChild);
} else if (!currentChild.isEqualNode(futureChild)) {
if (currentChild.nodeName !== futureChild.nodeName || currentChild.nodeType === currentChild.TEXT_NODE && currentChild.data !== futureChild.data) {
current.replaceChild(futureChild, currentChild);
} else {
const currentAttributes = currentChild.attributes;
const futureAttributes = futureChild.attributes;
if (currentAttributes) {
let ii = currentAttributes.length;
// Reverse loop because `removeAttribute` on `currentChild`
// changes `currentAttributes`.
while (ii--) {
const {
name
} = currentAttributes[ii];
if (!futureChild.getAttribute(name)) {
currentChild.removeAttribute(name);
}
}
}
if (futureAttributes) {
for (let ii = 0; ii < futureAttributes.length; ii++) {
const {
name,
value
} = futureAttributes[ii];
if (currentChild.getAttribute(name) !== value) {
currentChild.setAttribute(name, value);
}
}
}
applyValue(futureChild, currentChild);
future.removeChild(futureChild);
}
} else {
future.removeChild(futureChild);
}
i++;
}
while (current.childNodes[i]) {
current.removeChild(current.childNodes[i]);
}
}
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;
const selection = defaultView.getSelection();
const range = ownerDocument.createRange();
range.setStart(startContainer, startOffset);
range.setEnd(endContainer, endOffset);
const {
activeElement
} = ownerDocument;
if (selection.rangeCount > 0) {
// If the to be added range and the live range are the same, there's no
// need to remove the live range and add the equivalent range.
if ((0, _isRangeEqual.isRangeEqual)(range, selection.getRangeAt(0))) {
return;
}
selection.removeAllRanges();
}
selection.addRange(range);
// This function is not intended to cause a shift in focus. Since the above
// selection manipulations may shift focus, ensure that focus is restored to
// its previous state.
if (activeElement !== ownerDocument.activeElement) {
// The `instanceof` checks protect against edge cases where the focused
// element is not of the interface HTMLElement (does not have a `focus`
// or `blur` property).
//
// See: https://github.com/Microsoft/TypeScript/issues/5901#issuecomment-431649653
if (activeElement instanceof defaultView.HTMLElement) {
activeElement.focus();
}
}
}
//# sourceMappingURL=to-dom.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,116 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.toHTMLString = toHTMLString;
var _escapeHtml = require("@wordpress/escape-html");
var _toTree = require("./to-tree");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Create an HTML string from a Rich Text value.
*
* @param {Object} $1 Named argements.
* @param {RichTextValue} $1.value Rich text value.
* @param {boolean} [$1.preserveWhiteSpace] Preserves newlines if true.
*
* @return {string} HTML string.
*/
function toHTMLString({
value,
preserveWhiteSpace
}) {
const tree = (0, _toTree.toTree)({
value,
preserveWhiteSpace,
createEmpty,
append,
getLastChild,
getParent,
isText,
getText,
remove,
appendText
});
return createChildrenHTML(tree.children);
}
function createEmpty() {
return {};
}
function getLastChild({
children
}) {
return children && children[children.length - 1];
}
function append(parent, object) {
if (typeof object === 'string') {
object = {
text: object
};
}
object.parent = parent;
parent.children = parent.children || [];
parent.children.push(object);
return object;
}
function appendText(object, text) {
object.text += text;
}
function getParent({
parent
}) {
return parent;
}
function isText({
text
}) {
return typeof text === 'string';
}
function getText({
text
}) {
return text;
}
function remove(object) {
const index = object.parent.children.indexOf(object);
if (index !== -1) {
object.parent.children.splice(index, 1);
}
return object;
}
function createElementHTML({
type,
attributes,
object,
children
}) {
let attributeString = '';
for (const key in attributes) {
if (!(0, _escapeHtml.isValidAttributeName)(key)) {
continue;
}
attributeString += ` ${key}="${(0, _escapeHtml.escapeAttribute)(attributes[key])}"`;
}
if (object) {
return `<${type}${attributeString}>`;
}
return `<${type}${attributeString}>${createChildrenHTML(children)}</${type}>`;
}
function createChildrenHTML(children = []) {
return children.map(child => {
if (child.html !== undefined) {
return child.html;
}
return child.text === undefined ? createElementHTML(child) : (0, _escapeHtml.escapeEditableHTML)(child.text);
}).join('');
}
//# sourceMappingURL=to-html-string.js.map

File diff suppressed because one or more lines are too long

281
node_modules/@wordpress/rich-text/build/to-tree.js generated vendored Normal file
View File

@@ -0,0 +1,281 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.toTree = toTree;
var _getActiveFormats = require("./get-active-formats");
var _getFormatType = require("./get-format-type");
var _specialCharacters = require("./special-characters");
/**
* Internal dependencies
*/
function restoreOnAttributes(attributes, isEditableTree) {
if (isEditableTree) {
return attributes;
}
const newAttributes = {};
for (const key in attributes) {
let newKey = key;
if (key.startsWith('data-disable-rich-text-')) {
newKey = key.slice('data-disable-rich-text-'.length);
}
newAttributes[newKey] = attributes[key];
}
return newAttributes;
}
/**
* Converts a format object to information that can be used to create an element
* from (type, attributes and object).
*
* @param {Object} $1 Named parameters.
* @param {string} $1.type The format type.
* @param {string} $1.tagName The tag name.
* @param {Object} $1.attributes The format attributes.
* @param {Object} $1.unregisteredAttributes The unregistered format
* attributes.
* @param {boolean} $1.object Whether or not it is an object
* format.
* @param {boolean} $1.boundaryClass Whether or not to apply a boundary
* class.
* @param {boolean} $1.isEditableTree
*
* @return {Object} Information to be used for element creation.
*/
function fromFormat({
type,
tagName,
attributes,
unregisteredAttributes,
object,
boundaryClass,
isEditableTree
}) {
const formatType = (0, _getFormatType.getFormatType)(type);
let elementAttributes = {};
if (boundaryClass && isEditableTree) {
elementAttributes['data-rich-text-format-boundary'] = 'true';
}
if (!formatType) {
if (attributes) {
elementAttributes = {
...attributes,
...elementAttributes
};
}
return {
type,
attributes: restoreOnAttributes(elementAttributes, isEditableTree),
object
};
}
elementAttributes = {
...unregisteredAttributes,
...elementAttributes
};
for (const name in attributes) {
const key = formatType.attributes ? formatType.attributes[name] : false;
if (key) {
elementAttributes[key] = attributes[name];
} else {
elementAttributes[name] = attributes[name];
}
}
if (formatType.className) {
if (elementAttributes.class) {
elementAttributes.class = `${formatType.className} ${elementAttributes.class}`;
} else {
elementAttributes.class = formatType.className;
}
}
// When a format is declared as non editable, make it non editable in the
// editor.
if (isEditableTree && formatType.contentEditable === false) {
elementAttributes.contenteditable = 'false';
}
return {
type: tagName || formatType.tagName,
object: formatType.object,
attributes: restoreOnAttributes(elementAttributes, isEditableTree)
};
}
/**
* Checks if both arrays of formats up until a certain index are equal.
*
* @param {Array} a Array of formats to compare.
* @param {Array} b Array of formats to compare.
* @param {number} index Index to check until.
*/
function isEqualUntil(a, b, index) {
do {
if (a[index] !== b[index]) {
return false;
}
} while (index--);
return true;
}
function toTree({
value,
preserveWhiteSpace,
createEmpty,
append,
getLastChild,
getParent,
isText,
getText,
remove,
appendText,
onStartIndex,
onEndIndex,
isEditableTree,
placeholder
}) {
const {
formats,
replacements,
text,
start,
end
} = value;
const formatsLength = formats.length + 1;
const tree = createEmpty();
const activeFormats = (0, _getActiveFormats.getActiveFormats)(value);
const deepestActiveFormat = activeFormats[activeFormats.length - 1];
let lastCharacterFormats;
let lastCharacter;
append(tree, '');
for (let i = 0; i < formatsLength; i++) {
const character = text.charAt(i);
const shouldInsertPadding = isEditableTree && (
// Pad the line if the line is empty.
!lastCharacter ||
// Pad the line if the previous character is a line break, otherwise
// the line break won't be visible.
lastCharacter === '\n');
const characterFormats = formats[i];
let pointer = getLastChild(tree);
if (characterFormats) {
characterFormats.forEach((format, formatIndex) => {
if (pointer && lastCharacterFormats &&
// Reuse the last element if all formats remain the same.
isEqualUntil(characterFormats, lastCharacterFormats, formatIndex)) {
pointer = getLastChild(pointer);
return;
}
const {
type,
tagName,
attributes,
unregisteredAttributes
} = format;
const boundaryClass = isEditableTree && format === deepestActiveFormat;
const parent = getParent(pointer);
const newNode = append(parent, fromFormat({
type,
tagName,
attributes,
unregisteredAttributes,
boundaryClass,
isEditableTree
}));
if (isText(pointer) && getText(pointer).length === 0) {
remove(pointer);
}
pointer = append(newNode, '');
});
}
// If there is selection at 0, handle it before characters are inserted.
if (i === 0) {
if (onStartIndex && start === 0) {
onStartIndex(tree, pointer);
}
if (onEndIndex && end === 0) {
onEndIndex(tree, pointer);
}
}
if (character === _specialCharacters.OBJECT_REPLACEMENT_CHARACTER) {
const replacement = replacements[i];
if (!replacement) {
continue;
}
const {
type,
attributes,
innerHTML
} = replacement;
const formatType = (0, _getFormatType.getFormatType)(type);
if (!isEditableTree && type === 'script') {
pointer = append(getParent(pointer), fromFormat({
type: 'script',
isEditableTree
}));
append(pointer, {
html: decodeURIComponent(attributes['data-rich-text-script'])
});
} else if (formatType?.contentEditable === false) {
// For non editable formats, render the stored inner HTML.
pointer = append(getParent(pointer), fromFormat({
...replacement,
isEditableTree,
boundaryClass: start === i && end === i + 1
}));
if (innerHTML) {
append(pointer, {
html: innerHTML
});
}
} else {
pointer = append(getParent(pointer), fromFormat({
...replacement,
object: true,
isEditableTree
}));
}
// Ensure pointer is text node.
pointer = append(getParent(pointer), '');
} else if (!preserveWhiteSpace && character === '\n') {
pointer = append(getParent(pointer), {
type: 'br',
attributes: isEditableTree ? {
'data-rich-text-line-break': 'true'
} : undefined,
object: true
});
// Ensure pointer is text node.
pointer = append(getParent(pointer), '');
} else if (!isText(pointer)) {
pointer = append(getParent(pointer), character);
} else {
appendText(pointer, character);
}
if (onStartIndex && start === i + 1) {
onStartIndex(tree, pointer);
}
if (onEndIndex && end === i + 1) {
onEndIndex(tree, pointer);
}
if (shouldInsertPadding && i === text.length) {
append(getParent(pointer), _specialCharacters.ZWNBSP);
if (placeholder && text.length === 0) {
append(getParent(pointer), {
type: 'span',
attributes: {
'data-rich-text-placeholder': placeholder,
// Necessary to prevent the placeholder from catching
// selection and being editable.
style: 'pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;'
}
});
}
}
lastCharacterFormats = characterFormats;
lastCharacter = character;
}
return tree;
}
//# sourceMappingURL=to-tree.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.toggleFormat = toggleFormat;
var _a11y = require("@wordpress/a11y");
var _i18n = require("@wordpress/i18n");
var _getActiveFormat = require("./get-active-format");
var _removeFormat = require("./remove-format");
var _applyFormat = require("./apply-format");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/** @typedef {import('./types').RichTextFormat} RichTextFormat */
/**
* Toggles a format object to a Rich Text value at the current selection.
*
* @param {RichTextValue} value Value to modify.
* @param {RichTextFormat} format Format to apply or remove.
*
* @return {RichTextValue} A new value with the format applied or removed.
*/
function toggleFormat(value, format) {
if ((0, _getActiveFormat.getActiveFormat)(value, format.type)) {
// For screen readers, will announce if formatting control is disabled.
if (format.title) {
// translators: %s: title of the formatting control
(0, _a11y.speak)((0, _i18n.sprintf)((0, _i18n.__)('%s removed.'), format.title), 'assertive');
}
return (0, _removeFormat.removeFormat)(value, format.type);
}
// For screen readers, will announce if formatting control is enabled.
if (format.title) {
// translators: %s: title of the formatting control
(0, _a11y.speak)((0, _i18n.sprintf)((0, _i18n.__)('%s applied.'), format.title), 'assertive');
}
return (0, _applyFormat.applyFormat)(value, format);
}
//# sourceMappingURL=toggle-format.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_a11y","require","_i18n","_getActiveFormat","_removeFormat","_applyFormat","toggleFormat","value","format","getActiveFormat","type","title","speak","sprintf","__","removeFormat","applyFormat"],"sources":["@wordpress/rich-text/src/toggle-format.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nimport { getActiveFormat } from './get-active-format';\nimport { removeFormat } from './remove-format';\nimport { applyFormat } from './apply-format';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n/** @typedef {import('./types').RichTextFormat} RichTextFormat */\n\n/**\n * Toggles a format object to a Rich Text value at the current selection.\n *\n * @param {RichTextValue} value Value to modify.\n * @param {RichTextFormat} format Format to apply or remove.\n *\n * @return {RichTextValue} A new value with the format applied or removed.\n */\nexport function toggleFormat( value, format ) {\n\tif ( getActiveFormat( value, format.type ) ) {\n\t\t// For screen readers, will announce if formatting control is disabled.\n\t\tif ( format.title ) {\n\t\t\t// translators: %s: title of the formatting control\n\t\t\tspeak( sprintf( __( '%s removed.' ), format.title ), 'assertive' );\n\t\t}\n\t\treturn removeFormat( value, format.type );\n\t}\n\t// For screen readers, will announce if formatting control is enabled.\n\tif ( format.title ) {\n\t\t// translators: %s: title of the formatting control\n\t\tspeak( sprintf( __( '%s applied.' ), format.title ), 'assertive' );\n\t}\n\treturn applyFormat( value, format );\n}\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAMA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAbA;AACA;AACA;;AAKA;AACA;AACA;;AAMA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,YAAYA,CAAEC,KAAK,EAAEC,MAAM,EAAG;EAC7C,IAAK,IAAAC,gCAAe,EAAEF,KAAK,EAAEC,MAAM,CAACE,IAAK,CAAC,EAAG;IAC5C;IACA,IAAKF,MAAM,CAACG,KAAK,EAAG;MACnB;MACA,IAAAC,WAAK,EAAE,IAAAC,aAAO,EAAE,IAAAC,QAAE,EAAE,aAAc,CAAC,EAAEN,MAAM,CAACG,KAAM,CAAC,EAAE,WAAY,CAAC;IACnE;IACA,OAAO,IAAAI,0BAAY,EAAER,KAAK,EAAEC,MAAM,CAACE,IAAK,CAAC;EAC1C;EACA;EACA,IAAKF,MAAM,CAACG,KAAK,EAAG;IACnB;IACA,IAAAC,WAAK,EAAE,IAAAC,aAAO,EAAE,IAAAC,QAAE,EAAE,aAAc,CAAC,EAAEN,MAAM,CAACG,KAAM,CAAC,EAAE,WAAY,CAAC;EACnE;EACA,OAAO,IAAAK,wBAAW,EAAET,KAAK,EAAEC,MAAO,CAAC;AACpC","ignoreList":[]}

6
node_modules/@wordpress/rich-text/build/types.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map

1
node_modules/@wordpress/rich-text/build/types.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/rich-text/src/types.ts"],"sourcesContent":["/**\n * Stores the type of a rich text format, such as core/bold.\n */\nexport type RichTextFormat = {\n\ttype:\n\t\t| 'core/bold'\n\t\t| 'core/italic'\n\t\t| 'core/link '\n\t\t| 'core/strikethrough'\n\t\t| 'core/image'\n\t\t| string;\n};\n\n/**\n * A list of rich text format types.\n */\nexport type RichTextFormatList = Array< RichTextFormat >;\n\n/**\n * An object which represents a formatted string. The text property contains the\n * text to be formatted, and the formats property contains an array which indicates\n * the formats that are applied to each character in the text. See the main\n * `@wordpress/rich-text` documentation for more detail.\n */\nexport type RichTextValue = {\n\ttext: string;\n\tformats: Array< RichTextFormatList >;\n\treplacements: Array< RichTextFormat >;\n\tstart: number;\n\tend: number;\n};\n"],"mappings":"","ignoreList":[]}

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unregisterFormatType = unregisterFormatType;
var _data = require("@wordpress/data");
var _store = require("./store");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('./register-format-type').WPFormat} WPFormat */
/**
* Unregisters a format.
*
* @param {string} name Format name.
*
* @return {WPFormat|undefined} The previous format value, if it has
* been successfully unregistered;
* otherwise `undefined`.
*/
function unregisterFormatType(name) {
const oldFormat = (0, _data.select)(_store.store).getFormatType(name);
if (!oldFormat) {
window.console.error(`Format ${name} is not registered.`);
return;
}
(0, _data.dispatch)(_store.store).removeFormatTypes(name);
return oldFormat;
}
//# sourceMappingURL=unregister-format-type.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_data","require","_store","unregisterFormatType","name","oldFormat","select","richTextStore","getFormatType","window","console","error","dispatch","removeFormatTypes"],"sources":["@wordpress/rich-text/src/unregister-format-type.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { select, dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as richTextStore } from './store';\n\n/** @typedef {import('./register-format-type').WPFormat} WPFormat */\n\n/**\n * Unregisters a format.\n *\n * @param {string} name Format name.\n *\n * @return {WPFormat|undefined} The previous format value, if it has\n * been successfully unregistered;\n * otherwise `undefined`.\n */\nexport function unregisterFormatType( name ) {\n\tconst oldFormat = select( richTextStore ).getFormatType( name );\n\n\tif ( ! oldFormat ) {\n\t\twindow.console.error( `Format ${ name } is not registered.` );\n\t\treturn;\n\t}\n\n\tdispatch( richTextStore ).removeFormatTypes( name );\n\n\treturn oldFormat;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,oBAAoBA,CAAEC,IAAI,EAAG;EAC5C,MAAMC,SAAS,GAAG,IAAAC,YAAM,EAAEC,YAAc,CAAC,CAACC,aAAa,CAAEJ,IAAK,CAAC;EAE/D,IAAK,CAAEC,SAAS,EAAG;IAClBI,MAAM,CAACC,OAAO,CAACC,KAAK,CAAG,UAAUP,IAAM,qBAAqB,CAAC;IAC7D;EACD;EAEA,IAAAQ,cAAQ,EAAEL,YAAc,CAAC,CAACM,iBAAiB,CAAET,IAAK,CAAC;EAEnD,OAAOC,SAAS;AACjB","ignoreList":[]}

View File

@@ -0,0 +1,61 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.updateFormats = updateFormats;
var _isFormatEqual = require("./is-format-equal");
/**
* Internal dependencies
*/
/** @typedef {import('./types').RichTextValue} RichTextValue */
/**
* Efficiently updates all the formats from `start` (including) until `end`
* (excluding) with the active formats. Mutates `value`.
*
* @param {Object} $1 Named paramentes.
* @param {RichTextValue} $1.value Value te update.
* @param {number} $1.start Index to update from.
* @param {number} $1.end Index to update until.
* @param {Array} $1.formats Replacement formats.
*
* @return {RichTextValue} Mutated value.
*/
function updateFormats({
value,
start,
end,
formats
}) {
// Start and end may be switched in case of delete.
const min = Math.min(start, end);
const max = Math.max(start, end);
const formatsBefore = value.formats[min - 1] || [];
const formatsAfter = value.formats[max] || [];
// First, fix the references. If any format right before or after are
// equal, the replacement format should use the same reference.
value.activeFormats = formats.map((format, index) => {
if (formatsBefore[index]) {
if ((0, _isFormatEqual.isFormatEqual)(format, formatsBefore[index])) {
return formatsBefore[index];
}
} else if (formatsAfter[index]) {
if ((0, _isFormatEqual.isFormatEqual)(format, formatsAfter[index])) {
return formatsAfter[index];
}
}
return format;
});
while (--end >= start) {
if (value.activeFormats.length > 0) {
value.formats[end] = value.activeFormats;
} else {
delete value.formats[end];
}
}
return value;
}
//# sourceMappingURL=update-formats.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_isFormatEqual","require","updateFormats","value","start","end","formats","min","Math","max","formatsBefore","formatsAfter","activeFormats","map","format","index","isFormatEqual","length"],"sources":["@wordpress/rich-text/src/update-formats.js"],"sourcesContent":["/**\n * Internal dependencies\n */\n\nimport { isFormatEqual } from './is-format-equal';\n\n/** @typedef {import('./types').RichTextValue} RichTextValue */\n\n/**\n * Efficiently updates all the formats from `start` (including) until `end`\n * (excluding) with the active formats. Mutates `value`.\n *\n * @param {Object} $1 Named paramentes.\n * @param {RichTextValue} $1.value Value te update.\n * @param {number} $1.start Index to update from.\n * @param {number} $1.end Index to update until.\n * @param {Array} $1.formats Replacement formats.\n *\n * @return {RichTextValue} Mutated value.\n */\nexport function updateFormats( { value, start, end, formats } ) {\n\t// Start and end may be switched in case of delete.\n\tconst min = Math.min( start, end );\n\tconst max = Math.max( start, end );\n\tconst formatsBefore = value.formats[ min - 1 ] || [];\n\tconst formatsAfter = value.formats[ max ] || [];\n\n\t// First, fix the references. If any format right before or after are\n\t// equal, the replacement format should use the same reference.\n\tvalue.activeFormats = formats.map( ( format, index ) => {\n\t\tif ( formatsBefore[ index ] ) {\n\t\t\tif ( isFormatEqual( format, formatsBefore[ index ] ) ) {\n\t\t\t\treturn formatsBefore[ index ];\n\t\t\t}\n\t\t} else if ( formatsAfter[ index ] ) {\n\t\t\tif ( isFormatEqual( format, formatsAfter[ index ] ) ) {\n\t\t\t\treturn formatsAfter[ index ];\n\t\t\t}\n\t\t}\n\n\t\treturn format;\n\t} );\n\n\twhile ( --end >= start ) {\n\t\tif ( value.activeFormats.length > 0 ) {\n\t\t\tvalue.formats[ end ] = value.activeFormats;\n\t\t} else {\n\t\t\tdelete value.formats[ end ];\n\t\t}\n\t}\n\n\treturn value;\n}\n"],"mappings":";;;;;;AAIA,IAAAA,cAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAAE;EAAEC,KAAK;EAAEC,KAAK;EAAEC,GAAG;EAAEC;AAAQ,CAAC,EAAG;EAC/D;EACA,MAAMC,GAAG,GAAGC,IAAI,CAACD,GAAG,CAAEH,KAAK,EAAEC,GAAI,CAAC;EAClC,MAAMI,GAAG,GAAGD,IAAI,CAACC,GAAG,CAAEL,KAAK,EAAEC,GAAI,CAAC;EAClC,MAAMK,aAAa,GAAGP,KAAK,CAACG,OAAO,CAAEC,GAAG,GAAG,CAAC,CAAE,IAAI,EAAE;EACpD,MAAMI,YAAY,GAAGR,KAAK,CAACG,OAAO,CAAEG,GAAG,CAAE,IAAI,EAAE;;EAE/C;EACA;EACAN,KAAK,CAACS,aAAa,GAAGN,OAAO,CAACO,GAAG,CAAE,CAAEC,MAAM,EAAEC,KAAK,KAAM;IACvD,IAAKL,aAAa,CAAEK,KAAK,CAAE,EAAG;MAC7B,IAAK,IAAAC,4BAAa,EAAEF,MAAM,EAAEJ,aAAa,CAAEK,KAAK,CAAG,CAAC,EAAG;QACtD,OAAOL,aAAa,CAAEK,KAAK,CAAE;MAC9B;IACD,CAAC,MAAM,IAAKJ,YAAY,CAAEI,KAAK,CAAE,EAAG;MACnC,IAAK,IAAAC,4BAAa,EAAEF,MAAM,EAAEH,YAAY,CAAEI,KAAK,CAAG,CAAC,EAAG;QACrD,OAAOJ,YAAY,CAAEI,KAAK,CAAE;MAC7B;IACD;IAEA,OAAOD,MAAM;EACd,CAAE,CAAC;EAEH,OAAQ,EAAET,GAAG,IAAID,KAAK,EAAG;IACxB,IAAKD,KAAK,CAACS,aAAa,CAACK,MAAM,GAAG,CAAC,EAAG;MACrCd,KAAK,CAACG,OAAO,CAAED,GAAG,CAAE,GAAGF,KAAK,CAACS,aAAa;IAC3C,CAAC,MAAM;MACN,OAAOT,KAAK,CAACG,OAAO,CAAED,GAAG,CAAE;IAC5B;EACD;EAEA,OAAOF,KAAK;AACb","ignoreList":[]}