rebase on oct-10-2023
This commit is contained in:
81
wp/wp-includes/js/dist/annotations.js
vendored
81
wp/wp-includes/js/dist/annotations.js
vendored
@@ -95,8 +95,7 @@ const ANNOTATION_ATTRIBUTE_PREFIX = 'annotation-text-';
|
||||
* @return {Object} A record with the annotations applied.
|
||||
*/
|
||||
|
||||
function applyAnnotations(record) {
|
||||
let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
function applyAnnotations(record, annotations = []) {
|
||||
annotations.forEach(annotation => {
|
||||
let {
|
||||
start,
|
||||
@@ -176,11 +175,10 @@ function retrieveAnnotationPositions(formats) {
|
||||
*/
|
||||
|
||||
|
||||
function updateAnnotationsWithPositions(annotations, positions, _ref) {
|
||||
let {
|
||||
removeAnnotation,
|
||||
updateAnnotationRange
|
||||
} = _ref;
|
||||
function updateAnnotationsWithPositions(annotations, positions, {
|
||||
removeAnnotation,
|
||||
updateAnnotationRange
|
||||
}) {
|
||||
annotations.forEach(currentAnnotation => {
|
||||
const position = positions[currentAnnotation.id]; // If we cannot find an annotation, delete it.
|
||||
|
||||
@@ -216,20 +214,18 @@ const annotation = {
|
||||
return null;
|
||||
},
|
||||
|
||||
__experimentalGetPropsForEditableTreePreparation(select, _ref2) {
|
||||
let {
|
||||
richTextIdentifier,
|
||||
blockClientId
|
||||
} = _ref2;
|
||||
__experimentalGetPropsForEditableTreePreparation(select, {
|
||||
richTextIdentifier,
|
||||
blockClientId
|
||||
}) {
|
||||
return {
|
||||
annotations: select(STORE_NAME).__experimentalGetAnnotationsForRichText(blockClientId, richTextIdentifier)
|
||||
};
|
||||
},
|
||||
|
||||
__experimentalCreatePrepareEditableTree(_ref3) {
|
||||
let {
|
||||
annotations
|
||||
} = _ref3;
|
||||
__experimentalCreatePrepareEditableTree({
|
||||
annotations
|
||||
}) {
|
||||
return (formats, text) => {
|
||||
if (annotations.length === 0) {
|
||||
return formats;
|
||||
@@ -307,12 +303,10 @@ var external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
*/
|
||||
|
||||
const addAnnotationClassName = OriginalComponent => {
|
||||
return (0,external_wp_data_namespaceObject.withSelect)((select, _ref) => {
|
||||
let {
|
||||
clientId,
|
||||
className
|
||||
} = _ref;
|
||||
|
||||
return (0,external_wp_data_namespaceObject.withSelect)((select, {
|
||||
clientId,
|
||||
className
|
||||
}) => {
|
||||
const annotations = select(STORE_NAME).__experimentalGetAnnotationsForBlock(clientId);
|
||||
|
||||
return {
|
||||
@@ -349,12 +343,9 @@ function filterWithReference(collection, predicate) {
|
||||
*/
|
||||
|
||||
|
||||
const mapValues = (obj, callback) => Object.entries(obj).reduce((acc, _ref) => {
|
||||
let [key, value] = _ref;
|
||||
return { ...acc,
|
||||
[key]: callback(value)
|
||||
};
|
||||
}, {});
|
||||
const mapValues = (obj, callback) => Object.entries(obj).reduce((acc, [key, value]) => ({ ...acc,
|
||||
[key]: callback(value)
|
||||
}), {});
|
||||
/**
|
||||
* Verifies whether the given annotations is a valid annotation.
|
||||
*
|
||||
@@ -376,12 +367,9 @@ function isValidAnnotationRange(annotation) {
|
||||
*/
|
||||
|
||||
|
||||
function annotations() {
|
||||
function annotations(state = {}, action) {
|
||||
var _state$blockClientId;
|
||||
|
||||
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
let action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
switch (action.type) {
|
||||
case 'ANNOTATION_ADD':
|
||||
const blockClientId = action.blockClientId;
|
||||
@@ -398,7 +386,7 @@ function annotations() {
|
||||
return state;
|
||||
}
|
||||
|
||||
const previousAnnotationsForBlock = (_state$blockClientId = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : [];
|
||||
const previousAnnotationsForBlock = (_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : [];
|
||||
return { ...state,
|
||||
[blockClientId]: [...previousAnnotationsForBlock, newAnnotation]
|
||||
};
|
||||
@@ -767,18 +755,18 @@ const EMPTY_ARRAY = [];
|
||||
const __experimentalGetAnnotationsForBlock = rememo((state, blockClientId) => {
|
||||
var _state$blockClientId;
|
||||
|
||||
return ((_state$blockClientId = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => {
|
||||
return ((_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => {
|
||||
return annotation.selector === 'block';
|
||||
});
|
||||
}, (state, blockClientId) => {
|
||||
var _state$blockClientId2;
|
||||
|
||||
return [(_state$blockClientId2 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY];
|
||||
return [(_state$blockClientId2 = state?.[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY];
|
||||
});
|
||||
function __experimentalGetAllAnnotationsForBlock(state, blockClientId) {
|
||||
var _state$blockClientId3;
|
||||
|
||||
return (_state$blockClientId3 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY;
|
||||
return (_state$blockClientId3 = state?.[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY;
|
||||
}
|
||||
/**
|
||||
* Returns the annotations that apply to the given RichText instance.
|
||||
@@ -796,7 +784,7 @@ function __experimentalGetAllAnnotationsForBlock(state, blockClientId) {
|
||||
const __experimentalGetAnnotationsForRichText = rememo((state, blockClientId, richTextIdentifier) => {
|
||||
var _state$blockClientId4;
|
||||
|
||||
return ((_state$blockClientId4 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => {
|
||||
return ((_state$blockClientId4 = state?.[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => {
|
||||
return annotation.selector === 'range' && richTextIdentifier === annotation.richTextIdentifier;
|
||||
}).map(annotation => {
|
||||
const {
|
||||
@@ -810,7 +798,7 @@ const __experimentalGetAnnotationsForRichText = rememo((state, blockClientId, ri
|
||||
}, (state, blockClientId) => {
|
||||
var _state$blockClientId5;
|
||||
|
||||
return [(_state$blockClientId5 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY];
|
||||
return [(_state$blockClientId5 = state?.[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY];
|
||||
});
|
||||
/**
|
||||
* Returns all annotations in the editor state.
|
||||
@@ -942,15 +930,14 @@ function v4(options, buf, offset) {
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
|
||||
function __experimentalAddAnnotation(_ref) {
|
||||
let {
|
||||
blockClientId,
|
||||
richTextIdentifier = null,
|
||||
range = null,
|
||||
selector = 'range',
|
||||
source = 'default',
|
||||
id = esm_browser_v4()
|
||||
} = _ref;
|
||||
function __experimentalAddAnnotation({
|
||||
blockClientId,
|
||||
richTextIdentifier = null,
|
||||
range = null,
|
||||
selector = 'range',
|
||||
source = 'default',
|
||||
id = esm_browser_v4()
|
||||
}) {
|
||||
const action = {
|
||||
type: 'ANNOTATION_ADD',
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user