@wordpress/annotations 3.31.1-next.f56bd8138.0 → 3.32.1-next.47f435fc9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/block/index.js +17 -30
- package/build/block/index.js.map +7 -1
- package/build/format/annotation.js +85 -116
- package/build/format/annotation.js.map +7 -1
- package/build/format/index.js +5 -18
- package/build/format/index.js.map +7 -1
- package/build/index.js +28 -13
- package/build/index.js.map +7 -1
- package/build/store/actions.js +41 -75
- package/build/store/actions.js.map +7 -1
- package/build/store/constants.js +27 -12
- package/build/store/constants.js.map +7 -1
- package/build/store/index.js +44 -36
- package/build/store/index.js.map +7 -1
- package/build/store/reducer.js +75 -76
- package/build/store/reducer.js.map +7 -1
- package/build/store/selectors.js +56 -80
- package/build/store/selectors.js.map +7 -1
- package/build-module/block/index.js +17 -27
- package/build-module/block/index.js.map +7 -1
- package/build-module/format/annotation.js +61 -108
- package/build-module/format/annotation.js.map +7 -1
- package/build-module/format/index.js +4 -14
- package/build-module/format/index.js.map +7 -1
- package/build-module/index.js +7 -7
- package/build-module/index.js.map +7 -1
- package/build-module/store/actions.js +19 -70
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/constants.js +5 -7
- package/build-module/store/constants.js.map +7 -1
- package/build-module/store/index.js +10 -26
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/reducer.js +54 -71
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/selectors.js +33 -75
- package/build-module/store/selectors.js.map +7 -1
- package/package.json +13 -7
|
@@ -1,52 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Filters an array based on the predicate, but keeps the reference the same if
|
|
3
|
-
* the array hasn't changed.
|
|
4
|
-
*
|
|
5
|
-
* @param {Array} collection The collection to filter.
|
|
6
|
-
* @param {Function} predicate Function that determines if the item should stay
|
|
7
|
-
* in the array.
|
|
8
|
-
* @return {Array} Filtered array.
|
|
9
|
-
*/
|
|
10
1
|
function filterWithReference(collection, predicate) {
|
|
11
2
|
const filteredCollection = collection.filter(predicate);
|
|
12
3
|
return collection.length === filteredCollection.length ? collection : filteredCollection;
|
|
13
4
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* @return {Array} Transformed object.
|
|
22
|
-
*/
|
|
23
|
-
const mapValues = (obj, callback) => Object.entries(obj).reduce((acc, [key, value]) => ({
|
|
24
|
-
...acc,
|
|
25
|
-
[key]: callback(value)
|
|
26
|
-
}), {});
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Verifies whether the given annotations is a valid annotation.
|
|
30
|
-
*
|
|
31
|
-
* @param {Object} annotation The annotation to verify.
|
|
32
|
-
* @return {boolean} Whether the given annotation is valid.
|
|
33
|
-
*/
|
|
5
|
+
const mapValues = (obj, callback) => Object.entries(obj).reduce(
|
|
6
|
+
(acc, [key, value]) => ({
|
|
7
|
+
...acc,
|
|
8
|
+
[key]: callback(value)
|
|
9
|
+
}),
|
|
10
|
+
{}
|
|
11
|
+
);
|
|
34
12
|
function isValidAnnotationRange(annotation) {
|
|
35
|
-
return typeof annotation.start ===
|
|
13
|
+
return typeof annotation.start === "number" && typeof annotation.end === "number" && annotation.start <= annotation.end;
|
|
36
14
|
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Reducer managing annotations.
|
|
40
|
-
*
|
|
41
|
-
* @param {Object} state The annotations currently shown in the editor.
|
|
42
|
-
* @param {Object} action Dispatched action.
|
|
43
|
-
*
|
|
44
|
-
* @return {Array} Updated state.
|
|
45
|
-
*/
|
|
46
|
-
export function annotations(state = {}, action) {
|
|
47
|
-
var _state$blockClientId;
|
|
15
|
+
function annotations(state = {}, action) {
|
|
48
16
|
switch (action.type) {
|
|
49
|
-
case
|
|
17
|
+
case "ANNOTATION_ADD":
|
|
50
18
|
const blockClientId = action.blockClientId;
|
|
51
19
|
const newAnnotation = {
|
|
52
20
|
id: action.id,
|
|
@@ -56,46 +24,61 @@ export function annotations(state = {}, action) {
|
|
|
56
24
|
selector: action.selector,
|
|
57
25
|
range: action.range
|
|
58
26
|
};
|
|
59
|
-
if (newAnnotation.selector ===
|
|
27
|
+
if (newAnnotation.selector === "range" && !isValidAnnotationRange(newAnnotation.range)) {
|
|
60
28
|
return state;
|
|
61
29
|
}
|
|
62
|
-
const previousAnnotationsForBlock =
|
|
30
|
+
const previousAnnotationsForBlock = state?.[blockClientId] ?? [];
|
|
63
31
|
return {
|
|
64
32
|
...state,
|
|
65
|
-
[blockClientId]: [
|
|
33
|
+
[blockClientId]: [
|
|
34
|
+
...previousAnnotationsForBlock,
|
|
35
|
+
newAnnotation
|
|
36
|
+
]
|
|
66
37
|
};
|
|
67
|
-
case
|
|
68
|
-
return mapValues(state, annotationsForBlock => {
|
|
69
|
-
return filterWithReference(
|
|
70
|
-
|
|
71
|
-
|
|
38
|
+
case "ANNOTATION_REMOVE":
|
|
39
|
+
return mapValues(state, (annotationsForBlock) => {
|
|
40
|
+
return filterWithReference(
|
|
41
|
+
annotationsForBlock,
|
|
42
|
+
(annotation) => {
|
|
43
|
+
return annotation.id !== action.annotationId;
|
|
44
|
+
}
|
|
45
|
+
);
|
|
72
46
|
});
|
|
73
|
-
case
|
|
74
|
-
return mapValues(state, annotationsForBlock => {
|
|
47
|
+
case "ANNOTATION_UPDATE_RANGE":
|
|
48
|
+
return mapValues(state, (annotationsForBlock) => {
|
|
75
49
|
let hasChangedRange = false;
|
|
76
|
-
const newAnnotations = annotationsForBlock.map(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
50
|
+
const newAnnotations = annotationsForBlock.map(
|
|
51
|
+
(annotation) => {
|
|
52
|
+
if (annotation.id === action.annotationId) {
|
|
53
|
+
hasChangedRange = true;
|
|
54
|
+
return {
|
|
55
|
+
...annotation,
|
|
56
|
+
range: {
|
|
57
|
+
start: action.start,
|
|
58
|
+
end: action.end
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return annotation;
|
|
86
63
|
}
|
|
87
|
-
|
|
88
|
-
});
|
|
64
|
+
);
|
|
89
65
|
return hasChangedRange ? newAnnotations : annotationsForBlock;
|
|
90
66
|
});
|
|
91
|
-
case
|
|
92
|
-
return mapValues(state, annotationsForBlock => {
|
|
93
|
-
return filterWithReference(
|
|
94
|
-
|
|
95
|
-
|
|
67
|
+
case "ANNOTATION_REMOVE_SOURCE":
|
|
68
|
+
return mapValues(state, (annotationsForBlock) => {
|
|
69
|
+
return filterWithReference(
|
|
70
|
+
annotationsForBlock,
|
|
71
|
+
(annotation) => {
|
|
72
|
+
return annotation.source !== action.source;
|
|
73
|
+
}
|
|
74
|
+
);
|
|
96
75
|
});
|
|
97
76
|
}
|
|
98
77
|
return state;
|
|
99
78
|
}
|
|
100
|
-
|
|
101
|
-
|
|
79
|
+
var reducer_default = annotations;
|
|
80
|
+
export {
|
|
81
|
+
annotations,
|
|
82
|
+
reducer_default as default
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=reducer.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/reducer.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Filters an array based on the predicate, but keeps the reference the same if\n * the array hasn't changed.\n *\n * @param {Array} collection The collection to filter.\n * @param {Function} predicate Function that determines if the item should stay\n * in the array.\n * @return {Array} Filtered array.\n */\nfunction filterWithReference( collection, predicate ) {\n\tconst filteredCollection = collection.filter( predicate );\n\n\treturn collection.length === filteredCollection.length\n\t\t? collection\n\t\t: filteredCollection;\n}\n\n/**\n * Creates a new object with the same keys, but with `callback()` called as\n * a transformer function on each of the values.\n *\n * @param {Object} obj The object to transform.\n * @param {Function} callback The function to transform each object value.\n * @return {Array} Transformed object.\n */\nconst mapValues = ( obj, callback ) =>\n\tObject.entries( obj ).reduce(\n\t\t( acc, [ key, value ] ) => ( {\n\t\t\t...acc,\n\t\t\t[ key ]: callback( value ),\n\t\t} ),\n\t\t{}\n\t);\n\n/**\n * Verifies whether the given annotations is a valid annotation.\n *\n * @param {Object} annotation The annotation to verify.\n * @return {boolean} Whether the given annotation is valid.\n */\nfunction isValidAnnotationRange( annotation ) {\n\treturn (\n\t\ttypeof annotation.start === 'number' &&\n\t\ttypeof annotation.end === 'number' &&\n\t\tannotation.start <= annotation.end\n\t);\n}\n\n/**\n * Reducer managing annotations.\n *\n * @param {Object} state The annotations currently shown in the editor.\n * @param {Object} action Dispatched action.\n *\n * @return {Array} Updated state.\n */\nexport function annotations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ANNOTATION_ADD':\n\t\t\tconst blockClientId = action.blockClientId;\n\t\t\tconst newAnnotation = {\n\t\t\t\tid: action.id,\n\t\t\t\tblockClientId,\n\t\t\t\trichTextIdentifier: action.richTextIdentifier,\n\t\t\t\tsource: action.source,\n\t\t\t\tselector: action.selector,\n\t\t\t\trange: action.range,\n\t\t\t};\n\n\t\t\tif (\n\t\t\t\tnewAnnotation.selector === 'range' &&\n\t\t\t\t! isValidAnnotationRange( newAnnotation.range )\n\t\t\t) {\n\t\t\t\treturn state;\n\t\t\t}\n\n\t\t\tconst previousAnnotationsForBlock = state?.[ blockClientId ] ?? [];\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ blockClientId ]: [\n\t\t\t\t\t...previousAnnotationsForBlock,\n\t\t\t\t\tnewAnnotation,\n\t\t\t\t],\n\t\t\t};\n\n\t\tcase 'ANNOTATION_REMOVE':\n\t\t\treturn mapValues( state, ( annotationsForBlock ) => {\n\t\t\t\treturn filterWithReference(\n\t\t\t\t\tannotationsForBlock,\n\t\t\t\t\t( annotation ) => {\n\t\t\t\t\t\treturn annotation.id !== action.annotationId;\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} );\n\n\t\tcase 'ANNOTATION_UPDATE_RANGE':\n\t\t\treturn mapValues( state, ( annotationsForBlock ) => {\n\t\t\t\tlet hasChangedRange = false;\n\n\t\t\t\tconst newAnnotations = annotationsForBlock.map(\n\t\t\t\t\t( annotation ) => {\n\t\t\t\t\t\tif ( annotation.id === action.annotationId ) {\n\t\t\t\t\t\t\thasChangedRange = true;\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t...annotation,\n\t\t\t\t\t\t\t\trange: {\n\t\t\t\t\t\t\t\t\tstart: action.start,\n\t\t\t\t\t\t\t\t\tend: action.end,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn annotation;\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\treturn hasChangedRange ? newAnnotations : annotationsForBlock;\n\t\t\t} );\n\n\t\tcase 'ANNOTATION_REMOVE_SOURCE':\n\t\t\treturn mapValues( state, ( annotationsForBlock ) => {\n\t\t\t\treturn filterWithReference(\n\t\t\t\t\tannotationsForBlock,\n\t\t\t\t\t( annotation ) => {\n\t\t\t\t\t\treturn annotation.source !== action.source;\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} );\n\t}\n\n\treturn state;\n}\n\nexport default annotations;\n"],
|
|
5
|
+
"mappings": "AASA,SAAS,oBAAqB,YAAY,WAAY;AACrD,QAAM,qBAAqB,WAAW,OAAQ,SAAU;AAExD,SAAO,WAAW,WAAW,mBAAmB,SAC7C,aACA;AACJ;AAUA,MAAM,YAAY,CAAE,KAAK,aACxB,OAAO,QAAS,GAAI,EAAE;AAAA,EACrB,CAAE,KAAK,CAAE,KAAK,KAAM,OAAS;AAAA,IAC5B,GAAG;AAAA,IACH,CAAE,GAAI,GAAG,SAAU,KAAM;AAAA,EAC1B;AAAA,EACA,CAAC;AACF;AAQD,SAAS,uBAAwB,YAAa;AAC7C,SACC,OAAO,WAAW,UAAU,YAC5B,OAAO,WAAW,QAAQ,YAC1B,WAAW,SAAS,WAAW;AAEjC;AAUO,SAAS,YAAa,QAAQ,CAAC,GAAG,QAAS;AACjD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,YAAM,gBAAgB,OAAO;AAC7B,YAAM,gBAAgB;AAAA,QACrB,IAAI,OAAO;AAAA,QACX;AAAA,QACA,oBAAoB,OAAO;AAAA,QAC3B,QAAQ,OAAO;AAAA,QACf,UAAU,OAAO;AAAA,QACjB,OAAO,OAAO;AAAA,MACf;AAEA,UACC,cAAc,aAAa,WAC3B,CAAE,uBAAwB,cAAc,KAAM,GAC7C;AACD,eAAO;AAAA,MACR;AAEA,YAAM,8BAA8B,QAAS,aAAc,KAAK,CAAC;AAEjE,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,aAAc,GAAG;AAAA,UAClB,GAAG;AAAA,UACH;AAAA,QACD;AAAA,MACD;AAAA,IAED,KAAK;AACJ,aAAO,UAAW,OAAO,CAAE,wBAAyB;AACnD,eAAO;AAAA,UACN;AAAA,UACA,CAAE,eAAgB;AACjB,mBAAO,WAAW,OAAO,OAAO;AAAA,UACjC;AAAA,QACD;AAAA,MACD,CAAE;AAAA,IAEH,KAAK;AACJ,aAAO,UAAW,OAAO,CAAE,wBAAyB;AACnD,YAAI,kBAAkB;AAEtB,cAAM,iBAAiB,oBAAoB;AAAA,UAC1C,CAAE,eAAgB;AACjB,gBAAK,WAAW,OAAO,OAAO,cAAe;AAC5C,gCAAkB;AAClB,qBAAO;AAAA,gBACN,GAAG;AAAA,gBACH,OAAO;AAAA,kBACN,OAAO,OAAO;AAAA,kBACd,KAAK,OAAO;AAAA,gBACb;AAAA,cACD;AAAA,YACD;AAEA,mBAAO;AAAA,UACR;AAAA,QACD;AAEA,eAAO,kBAAkB,iBAAiB;AAAA,MAC3C,CAAE;AAAA,IAEH,KAAK;AACJ,aAAO,UAAW,OAAO,CAAE,wBAAyB;AACnD,eAAO;AAAA,UACN;AAAA,UACA,CAAE,eAAgB;AACjB,mBAAO,WAAW,WAAW,OAAO;AAAA,UACrC;AAAA,QACD;AAAA,MACD,CAAE;AAAA,EACJ;AAEA,SAAO;AACR;AAEA,IAAO,kBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,79 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createSelector } from '@wordpress/data';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Shared reference to an empty array for cases where it is important to avoid
|
|
8
|
-
* returning a new array reference on every invocation, as in a connected or
|
|
9
|
-
* other pure component which performs `shouldComponentUpdate` check on props.
|
|
10
|
-
* This should be used as a last resort, since the normalized data should be
|
|
11
|
-
* maintained by the reducer result in state.
|
|
12
|
-
*
|
|
13
|
-
* @type {Array}
|
|
14
|
-
*/
|
|
1
|
+
import { createSelector } from "@wordpress/data";
|
|
15
2
|
const EMPTY_ARRAY = [];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var _state$blockClientId;
|
|
27
|
-
return ((_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => {
|
|
28
|
-
return annotation.selector === 'block';
|
|
29
|
-
});
|
|
30
|
-
}, (state, blockClientId) => {
|
|
31
|
-
var _state$blockClientId2;
|
|
32
|
-
return [(_state$blockClientId2 = state?.[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY];
|
|
33
|
-
});
|
|
34
|
-
export function __experimentalGetAllAnnotationsForBlock(state, blockClientId) {
|
|
35
|
-
var _state$blockClientId3;
|
|
36
|
-
return (_state$blockClientId3 = state?.[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY;
|
|
3
|
+
const __experimentalGetAnnotationsForBlock = createSelector(
|
|
4
|
+
(state, blockClientId) => {
|
|
5
|
+
return (state?.[blockClientId] ?? []).filter((annotation) => {
|
|
6
|
+
return annotation.selector === "block";
|
|
7
|
+
});
|
|
8
|
+
},
|
|
9
|
+
(state, blockClientId) => [state?.[blockClientId] ?? EMPTY_ARRAY]
|
|
10
|
+
);
|
|
11
|
+
function __experimentalGetAllAnnotationsForBlock(state, blockClientId) {
|
|
12
|
+
return state?.[blockClientId] ?? EMPTY_ARRAY;
|
|
37
13
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return ((_state$blockClientId4 = state?.[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => {
|
|
54
|
-
return annotation.selector === 'range' && richTextIdentifier === annotation.richTextIdentifier;
|
|
55
|
-
}).map(annotation => {
|
|
56
|
-
const {
|
|
57
|
-
range,
|
|
58
|
-
...other
|
|
59
|
-
} = annotation;
|
|
60
|
-
return {
|
|
61
|
-
...range,
|
|
62
|
-
...other
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
}, (state, blockClientId) => {
|
|
66
|
-
var _state$blockClientId5;
|
|
67
|
-
return [(_state$blockClientId5 = state?.[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY];
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Returns all annotations in the editor state.
|
|
72
|
-
*
|
|
73
|
-
* @param {Object} state Editor state.
|
|
74
|
-
* @return {Array} All annotations currently applied.
|
|
75
|
-
*/
|
|
76
|
-
export function __experimentalGetAnnotations(state) {
|
|
14
|
+
const __experimentalGetAnnotationsForRichText = createSelector(
|
|
15
|
+
(state, blockClientId, richTextIdentifier) => {
|
|
16
|
+
return (state?.[blockClientId] ?? []).filter((annotation) => {
|
|
17
|
+
return annotation.selector === "range" && richTextIdentifier === annotation.richTextIdentifier;
|
|
18
|
+
}).map((annotation) => {
|
|
19
|
+
const { range, ...other } = annotation;
|
|
20
|
+
return {
|
|
21
|
+
...range,
|
|
22
|
+
...other
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
(state, blockClientId) => [state?.[blockClientId] ?? EMPTY_ARRAY]
|
|
27
|
+
);
|
|
28
|
+
function __experimentalGetAnnotations(state) {
|
|
77
29
|
return Object.values(state).flat();
|
|
78
30
|
}
|
|
79
|
-
|
|
31
|
+
export {
|
|
32
|
+
__experimentalGetAllAnnotationsForBlock,
|
|
33
|
+
__experimentalGetAnnotations,
|
|
34
|
+
__experimentalGetAnnotationsForBlock,
|
|
35
|
+
__experimentalGetAnnotationsForRichText
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/selectors.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector } from '@wordpress/data';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation, as in a connected or\n * other pure component which performs `shouldComponentUpdate` check on props.\n * This should be used as a last resort, since the normalized data should be\n * maintained by the reducer result in state.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Returns the annotations for a specific client ID.\n *\n * @param {Object} state Editor state.\n * @param {string} clientId The ID of the block to get the annotations for.\n *\n * @return {Array} The annotations applicable to this block.\n */\nexport const __experimentalGetAnnotationsForBlock = createSelector(\n\t( state, blockClientId ) => {\n\t\treturn ( state?.[ blockClientId ] ?? [] ).filter( ( annotation ) => {\n\t\t\treturn annotation.selector === 'block';\n\t\t} );\n\t},\n\t( state, blockClientId ) => [ state?.[ blockClientId ] ?? EMPTY_ARRAY ]\n);\n\nexport function __experimentalGetAllAnnotationsForBlock(\n\tstate,\n\tblockClientId\n) {\n\treturn state?.[ blockClientId ] ?? EMPTY_ARRAY;\n}\n\n/**\n * Returns the annotations that apply to the given RichText instance.\n *\n * Both a blockClientId and a richTextIdentifier are required. This is because\n * a block might have multiple `RichText` components. This does mean that every\n * block needs to implement annotations itself.\n *\n * @param {Object} state Editor state.\n * @param {string} blockClientId The client ID for the block.\n * @param {string} richTextIdentifier Unique identifier that identifies the given RichText.\n * @return {Array} All the annotations relevant for the `RichText`.\n */\nexport const __experimentalGetAnnotationsForRichText = createSelector(\n\t( state, blockClientId, richTextIdentifier ) => {\n\t\treturn ( state?.[ blockClientId ] ?? [] )\n\t\t\t.filter( ( annotation ) => {\n\t\t\t\treturn (\n\t\t\t\t\tannotation.selector === 'range' &&\n\t\t\t\t\trichTextIdentifier === annotation.richTextIdentifier\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.map( ( annotation ) => {\n\t\t\t\tconst { range, ...other } = annotation;\n\n\t\t\t\treturn {\n\t\t\t\t\t...range,\n\t\t\t\t\t...other,\n\t\t\t\t};\n\t\t\t} );\n\t},\n\t( state, blockClientId ) => [ state?.[ blockClientId ] ?? EMPTY_ARRAY ]\n);\n\n/**\n * Returns all annotations in the editor state.\n *\n * @param {Object} state Editor state.\n * @return {Array} All annotations currently applied.\n */\nexport function __experimentalGetAnnotations( state ) {\n\treturn Object.values( state ).flat();\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,sBAAsB;AAW/B,MAAM,cAAc,CAAC;AAUd,MAAM,uCAAuC;AAAA,EACnD,CAAE,OAAO,kBAAmB;AAC3B,YAAS,QAAS,aAAc,KAAK,CAAC,GAAI,OAAQ,CAAE,eAAgB;AACnE,aAAO,WAAW,aAAa;AAAA,IAChC,CAAE;AAAA,EACH;AAAA,EACA,CAAE,OAAO,kBAAmB,CAAE,QAAS,aAAc,KAAK,WAAY;AACvE;AAEO,SAAS,wCACf,OACA,eACC;AACD,SAAO,QAAS,aAAc,KAAK;AACpC;AAcO,MAAM,0CAA0C;AAAA,EACtD,CAAE,OAAO,eAAe,uBAAwB;AAC/C,YAAS,QAAS,aAAc,KAAK,CAAC,GACpC,OAAQ,CAAE,eAAgB;AAC1B,aACC,WAAW,aAAa,WACxB,uBAAuB,WAAW;AAAA,IAEpC,CAAE,EACD,IAAK,CAAE,eAAgB;AACvB,YAAM,EAAE,OAAO,GAAG,MAAM,IAAI;AAE5B,aAAO;AAAA,QACN,GAAG;AAAA,QACH,GAAG;AAAA,MACJ;AAAA,IACD,CAAE;AAAA,EACJ;AAAA,EACA,CAAE,OAAO,kBAAmB,CAAE,QAAS,aAAc,KAAK,WAAY;AACvE;AAQO,SAAS,6BAA8B,OAAQ;AACrD,SAAO,OAAO,OAAQ,KAAM,EAAE,KAAK;AACpC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/annotations",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.32.1-next.47f435fc9.0",
|
|
4
4
|
"description": "Annotate content in the Gutenberg editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -24,14 +24,20 @@
|
|
|
24
24
|
},
|
|
25
25
|
"main": "build/index.js",
|
|
26
26
|
"module": "build-module/index.js",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./build-module/index.js",
|
|
30
|
+
"require": "./build/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
27
34
|
"react-native": "src/index",
|
|
28
35
|
"wpScript": true,
|
|
29
36
|
"dependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@wordpress/
|
|
32
|
-
"@wordpress/
|
|
33
|
-
"@wordpress/
|
|
34
|
-
"@wordpress/rich-text": "^7.31.1-next.f56bd8138.0",
|
|
37
|
+
"@wordpress/data": "^10.32.1-next.47f435fc9.0",
|
|
38
|
+
"@wordpress/hooks": "^4.32.1-next.47f435fc9.0",
|
|
39
|
+
"@wordpress/i18n": "^6.5.1-next.47f435fc9.0",
|
|
40
|
+
"@wordpress/rich-text": "^7.32.1-next.47f435fc9.0",
|
|
35
41
|
"uuid": "^9.0.1"
|
|
36
42
|
},
|
|
37
43
|
"peerDependencies": {
|
|
@@ -40,5 +46,5 @@
|
|
|
40
46
|
"publishConfig": {
|
|
41
47
|
"access": "public"
|
|
42
48
|
},
|
|
43
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "9720f22c138771d2ed1a0522725c3cdf1c242953"
|
|
44
50
|
}
|