@wordpress/annotations 2.39.0 → 2.40.1

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/block/index.js +0 -5
  3. package/build/block/index.js.map +1 -1
  4. package/build/format/annotation.js +9 -29
  5. package/build/format/annotation.js.map +1 -1
  6. package/build/format/index.js +1 -2
  7. package/build/format/index.js.map +1 -1
  8. package/build/index.js +0 -3
  9. package/build/index.js.map +1 -1
  10. package/build/store/actions.js +3 -10
  11. package/build/store/actions.js.map +1 -1
  12. package/build/store/constants.js +0 -1
  13. package/build/store/constants.js.map +1 -1
  14. package/build/store/index.js +0 -9
  15. package/build/store/index.js.map +1 -1
  16. package/build/store/reducer.js +9 -19
  17. package/build/store/reducer.js.map +1 -1
  18. package/build/store/selectors.js +5 -17
  19. package/build/store/selectors.js.map +1 -1
  20. package/build-module/block/index.js +1 -4
  21. package/build-module/block/index.js.map +1 -1
  22. package/build-module/format/annotation.js +9 -25
  23. package/build-module/format/annotation.js.map +1 -1
  24. package/build-module/format/index.js +1 -1
  25. package/build-module/format/index.js.map +1 -1
  26. package/build-module/index.js.map +1 -1
  27. package/build-module/store/actions.js +4 -6
  28. package/build-module/store/actions.js.map +1 -1
  29. package/build-module/store/constants.js.map +1 -1
  30. package/build-module/store/index.js +3 -3
  31. package/build-module/store/index.js.map +1 -1
  32. package/build-module/store/reducer.js +9 -17
  33. package/build-module/store/reducer.js.map +1 -1
  34. package/build-module/store/selectors.js +6 -10
  35. package/build-module/store/selectors.js.map +1 -1
  36. package/package.json +9 -6
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/annotations/src/store/reducer.js"],"names":["filterWithReference","collection","predicate","filteredCollection","filter","length","mapValues","obj","callback","Object","entries","reduce","acc","key","value","isValidAnnotationRange","annotation","start","end","annotations","state","action","type","blockClientId","newAnnotation","id","richTextIdentifier","source","selector","range","previousAnnotationsForBlock","annotationsForBlock","annotationId","hasChangedRange","newAnnotations","map"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,mBAAT,CAA8BC,UAA9B,EAA0CC,SAA1C,EAAsD;AACrD,QAAMC,kBAAkB,GAAGF,UAAU,CAACG,MAAX,CAAmBF,SAAnB,CAA3B;AAEA,SAAOD,UAAU,CAACI,MAAX,KAAsBF,kBAAkB,CAACE,MAAzC,GACJJ,UADI,GAEJE,kBAFH;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMG,SAAS,GAAG,CAAEC,GAAF,EAAOC,QAAP,KACjBC,MAAM,CAACC,OAAP,CAAgBH,GAAhB,EAAsBI,MAAtB,CACC,CAAEC,GAAF,EAAO,CAAEC,GAAF,EAAOC,KAAP,CAAP,MAA6B,EAC5B,GAAGF,GADyB;AAE5B,GAAEC,GAAF,GAASL,QAAQ,CAAEM,KAAF;AAFW,CAA7B,CADD,EAKC,EALD,CADD;AASA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,sBAAT,CAAiCC,UAAjC,EAA8C;AAC7C,SACC,OAAOA,UAAU,CAACC,KAAlB,KAA4B,QAA5B,IACA,OAAOD,UAAU,CAACE,GAAlB,KAA0B,QAD1B,IAEAF,UAAU,CAACC,KAAX,IAAoBD,UAAU,CAACE,GAHhC;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,WAAT,CAAsBC,KAAK,GAAG,EAA9B,EAAkCC,MAAlC,EAA2C;AAAA;;AACjD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,gBAAL;AACC,YAAMC,aAAa,GAAGF,MAAM,CAACE,aAA7B;AACA,YAAMC,aAAa,GAAG;AACrBC,QAAAA,EAAE,EAAEJ,MAAM,CAACI,EADU;AAErBF,QAAAA,aAFqB;AAGrBG,QAAAA,kBAAkB,EAAEL,MAAM,CAACK,kBAHN;AAIrBC,QAAAA,MAAM,EAA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C,aAAOzB,SAAS,CAAEc,KAAF,EAAWW,mBAAF,IAA2B;AACnD,eAAO/B,mBAAmB,CACzB+B,mBADyB,EAEvBf,UAAF,IAAkB;AACjB,iBAAOA,UAAU,CAACW,MAAX,KAAsBN,MAAM,CAACM,MAApC;AACA,SAJwB,CAA1B;AAMA,OAPe,CAAhB;AAhEF;;AA0EA,SAAOP,KAAP;AACA;AAED,eAAeD,WAAf","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"]}
1
+ {"version":3,"names":["filterWithReference","collection","predicate","filteredCollection","filter","length","mapValues","obj","callback","Object","entries","reduce","acc","key","value","isValidAnnotationRange","annotation","start","end","annotations","state","action","_state$blockClientId","type","blockClientId","newAnnotation","id","richTextIdentifier","source","selector","range","previousAnnotationsForBlock","annotationsForBlock","annotationId","hasChangedRange","newAnnotations","map"],"sources":["@wordpress/annotations/src/store/reducer.js"],"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"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,mBAAmBA,CAAEC,UAAU,EAAEC,SAAS,EAAG;EACrD,MAAMC,kBAAkB,GAAGF,UAAU,CAACG,MAAM,CAAEF,SAAU,CAAC;EAEzD,OAAOD,UAAU,CAACI,MAAM,KAAKF,kBAAkB,CAACE,MAAM,GACnDJ,UAAU,GACVE,kBAAkB;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,SAAS,GAAGA,CAAEC,GAAG,EAAEC,QAAQ,KAChCC,MAAM,CAACC,OAAO,CAAEH,GAAI,CAAC,CAACI,MAAM,CAC3B,CAAEC,GAAG,EAAE,CAAEC,GAAG,EAAEC,KAAK,CAAE,MAAQ;EAC5B,GAAGF,GAAG;EACN,CAAEC,GAAG,GAAIL,QAAQ,CAAEM,KAAM;AAC1B,CAAC,CAAE,EACH,CAAC,CACF,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,sBAAsBA,CAAEC,UAAU,EAAG;EAC7C,OACC,OAAOA,UAAU,CAACC,KAAK,KAAK,QAAQ,IACpC,OAAOD,UAAU,CAACE,GAAG,KAAK,QAAQ,IAClCF,UAAU,CAACC,KAAK,IAAID,UAAU,CAACE,GAAG;A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A,UAAU,CAACU,EAAE,KAAKL,MAAM,CAACY,YAAY,EAAG;YAC5CC,eAAe,GAAG,IAAI;YACtB,OAAO;cACN,GAAGlB,UAAU;cACbc,KAAK,EAAE;gBACNb,KAAK,EAAEI,MAAM,CAACJ,KAAK;gBACnBC,GAAG,EAAEG,MAAM,CAACH;cACb;YACD,CAAC;UACF;UAEA,OAAOF,UAAU;QAClB,CACD,CAAC;QAED,OAAOkB,eAAe,GAAGC,cAAc,GAAGH,mBAAmB;MAC9D,CAAE,CAAC;IAEJ,KAAK,0BAA0B;MAC9B,OAAO1B,SAAS,CAAEc,KAAK,EAAIY,mBAAmB,IAAM;QACnD,OAAOhC,mBAAmB,CACzBgC,mBAAmB,EACjBhB,UAAU,IAAM;UACjB,OAAOA,UAAU,CAACY,MAAM,KAAKP,MAAM,CAACO,MAAM;QAC3C,CACD,CAAC;MACF,CAAE,CAAC;EACL;EAEA,OAAOR,KAAK;AACb;AAEA,eAAeD,WAAW"}
@@ -2,6 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import createSelector from 'rememo';
5
+
5
6
  /**
6
7
  * Shared reference to an empty array for cases where it is important to avoid
7
8
  * returning a new array reference on every invocation, as in a connected or
@@ -11,8 +12,8 @@ import createSelector from 'rememo';
11
12
  *
12
13
  * @type {Array}
13
14
  */
14
-
15
15
  const EMPTY_ARRAY = [];
16
+
16
17
  /**
17
18
  * Returns the annotations for a specific client ID.
18
19
  *
@@ -21,23 +22,20 @@ const EMPTY_ARRAY = [];
21
22
  *
22
23
  * @return {Array} The annotations applicable to this block.
23
24
  */
24
-
25
25
  export const __experimentalGetAnnotationsForBlock = createSelector((state, blockClientId) => {
26
26
  var _state$blockClientId;
27
-
28
27
  return ((_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => {
29
28
  return annotation.selector === 'block';
30
29
  });
31
30
  }, (state, blockClientId) => {
32
31
  var _state$blockClientId2;
33
-
34
32
  return [(_state$blockClientId2 = state?.[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY];
35
33
  });
36
34
  export function __experimentalGetAllAnnotationsForBlock(state, blockClientId) {
37
35
  var _state$blockClientId3;
38
-
39
36
  return (_state$blockClientId3 = state?.[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY;
40
37
  }
38
+
41
39
  /**
42
40
  * Returns the annotations that apply to the given RichText instance.
43
41
  *
@@ -50,10 +48,8 @@ export function __experimentalGetAllAnnotationsForBlock(state, blockClientId) {
50
48
  * @param {string} richTextIdentifier Unique identifier that identifies the given RichText.
51
49
  * @return {Array} All the annotations relevant for the `RichText`.
52
50
  */
53
-
54
51
  export const __experimentalGetAnnotationsForRichText = createSelector((state, blockClientId, richTextIdentifier) => {
55
52
  var _state$blockClientId4;
56
-
57
53
  return ((_state$blockClientId4 = state?.[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => {
58
54
  return annotation.selector === 'range' && richTextIdentifier === annotation.richTextIdentifier;
59
55
  }).map(annotation => {
@@ -61,22 +57,22 @@ export const __experimentalGetAnnotationsForRichText = createSelector((state, bl
61
57
  range,
62
58
  ...other
63
59
  } = annotation;
64
- return { ...range,
60
+ return {
61
+ ...range,
65
62
  ...other
66
63
  };
67
64
  });
68
65
  }, (state, blockClientId) => {
69
66
  var _state$blockClientId5;
70
-
71
67
  return [(_state$blockClientId5 = state?.[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY];
72
68
  });
69
+
73
70
  /**
74
71
  * Returns all annotations in the editor state.
75
72
  *
76
73
  * @param {Object} state Editor state.
77
74
  * @return {Array} All annotations currently applied.
78
75
  */
79
-
80
76
  export function __experimentalGetAnnotations(state) {
81
77
  return Object.values(state).flat();
82
78
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/annotations/src/store/selectors.js"],"names":["createSelector","EMPTY_ARRAY","__experimentalGetAnnotationsForBlock","state","blockClientId","filter","annotation","selector","__experimentalGetAllAnnotationsForBlock","__experimentalGetAnnotationsForRichText","richTextIdentifier","map","range","other","__experimentalGetAnnotations","Object","values","flat"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,oCAAoC,GAAGF,cAAc,CACjE,CAAEG,KAAF,EAASC,aAAT,KAA4B;AAAA;;AAC3B,SAAO,yBAAED,KAAK,GAAIC,aAAJ,CAAP,uEAA8B,EAA9B,EAAmCC,MAAnC,CAA6CC,UAAF,IAAkB;AACnE,WAAOA,UAAU,CAACC,QAAX,KAAwB,OAA/B;AACA,GAFM,CAAP;AAGA,CALgE,EAMjE,CAAEJ,KAAF,EAASC,aAAT;AAAA;;AAAA,SAA4B,0BAAED,KAAK,GAAIC,aAAJ,CAAP,yEAA8BH,WAA9B,CAA5B;AAAA,CANiE,CAA3D;AASP,OAAO,SAASO,uCAAT,CACNL,KADM,EAENC,aAFM,EAGL;AAAA;;AACD,kCAAOD,KAAK,GAAIC,aAAJ,CAAZ,yEAAmCH,WAAnC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMQ,uCAAuC,GAAGT,cAAc,CACpE,CAAEG,KAAF,EAASC,aAAT,EAAwBM,kBAAxB,KAAgD;AAAA;;AAC/C,SAAO,0BAAEP,KAAK,GAAIC,aAAJ,CAAP,yEAA8B,EAA9B,EACLC,MADK,CACKC,UAAF,IAAkB;AAC1B,WACCA,UAAU,CAACC,QAAX,KAAwB,OAAxB,IACAG,kBAAkB,KAAKJ,UAAU,CAACI,kBAFnC;AAIA,GANK,EAOLC,GAPK,CAOEL,UAAF,IAAkB;AACvB,UAAM;AAAEM,MAAAA,KAAF;AAAS,SAAGC;AAAZ,QAAsBP,UAA5B;AAEA,WAAO,EACN,GAAGM,KADG;AAEN,SAAGC;AAFG,KAAP;AAIA,GAdK,CAAP;AAeA,CAjBmE,EAkBpE,CAAEV,KAAF,EAASC,aAAT;AAAA;;AAAA,SAA4B,0BAAED,KAAK,GAAIC,aAAJ,CAAP,yEAA8BH,WAA9B,CAA5B;AAAA,CAlBoE,CAA9D;AAqBP;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASa,4BAAT,CAAuCX,KAAvC,EAA+C;AACrD,SAAOY,MAAM,CAACC,MAAP,CAAeb,KAAf,EAAuBc,IAAvB,EAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\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"]}
1
+ {"version":3,"names":["createSelector","EMPTY_ARRAY","__experimentalGetAnnotationsForBlock","state","blockClientId","_state$blockClientId","filter","annotation","selector","_state$blockClientId2","__experimentalGetAllAnnotationsForBlock","_state$blockClientId3","__experimentalGetAnnotationsForRichText","richTextIdentifier","_state$blockClientId4","map","range","other","_state$blockClientId5","__experimentalGetAnnotations","Object","values","flat"],"sources":["@wordpress/annotations/src/store/selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\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"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAc,MAAM,QAAQ;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;A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GAAGC;IACJ,CAAC;EACF,CAAE,CAAC;AACL,CAAC,EACD,CAAEd,KAAK,EAAEC,aAAa;EAAA,IAAAc,qBAAA;EAAA,OAAM,EAAAA,qBAAA,GAAEf,KAAK,GAAIC,aAAa,CAAE,cAAAc,qBAAA,cAAAA,qBAAA,GAAIjB,WAAW,CAAE;AAAA,CACxE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASkB,4BAA4BA,CAAEhB,KAAK,EAAG;EACrD,OAAOiB,MAAM,CAACC,MAAM,CAAElB,KAAM,CAAC,CAACmB,IAAI,CAAC,CAAC;AACrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/annotations",
3
- "version": "2.39.0",
3
+ "version": "2.40.1",
4
4
  "description": "Annotate content in the Gutenberg editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,15 +26,18 @@
26
26
  "react-native": "src/index",
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.16.0",
29
- "@wordpress/data": "^9.9.0",
30
- "@wordpress/hooks": "^3.39.0",
31
- "@wordpress/i18n": "^4.39.0",
32
- "@wordpress/rich-text": "^6.16.0",
29
+ "@wordpress/data": "^9.10.1",
30
+ "@wordpress/hooks": "^3.40.1",
31
+ "@wordpress/i18n": "^4.40.1",
32
+ "@wordpress/rich-text": "^6.17.1",
33
33
  "rememo": "^4.0.2",
34
34
  "uuid": "^8.3.0"
35
35
  },
36
+ "peerDependencies": {
37
+ "react": "^18.0.0"
38
+ },
36
39
  "publishConfig": {
37
40
  "access": "public"
38
41
  },
39
- "gitHead": "b898cf1dc8e70841d1647ea0994ac6278acc18a7"
42
+ "gitHead": "bb1fbf87bb0f451744530fc6a85de2dff1263bed"
40
43
  }