@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.
Files changed (38) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/block/index.js +17 -30
  3. package/build/block/index.js.map +7 -1
  4. package/build/format/annotation.js +85 -116
  5. package/build/format/annotation.js.map +7 -1
  6. package/build/format/index.js +5 -18
  7. package/build/format/index.js.map +7 -1
  8. package/build/index.js +28 -13
  9. package/build/index.js.map +7 -1
  10. package/build/store/actions.js +41 -75
  11. package/build/store/actions.js.map +7 -1
  12. package/build/store/constants.js +27 -12
  13. package/build/store/constants.js.map +7 -1
  14. package/build/store/index.js +44 -36
  15. package/build/store/index.js.map +7 -1
  16. package/build/store/reducer.js +75 -76
  17. package/build/store/reducer.js.map +7 -1
  18. package/build/store/selectors.js +56 -80
  19. package/build/store/selectors.js.map +7 -1
  20. package/build-module/block/index.js +17 -27
  21. package/build-module/block/index.js.map +7 -1
  22. package/build-module/format/annotation.js +61 -108
  23. package/build-module/format/annotation.js.map +7 -1
  24. package/build-module/format/index.js +4 -14
  25. package/build-module/format/index.js.map +7 -1
  26. package/build-module/index.js +7 -7
  27. package/build-module/index.js.map +7 -1
  28. package/build-module/store/actions.js +19 -70
  29. package/build-module/store/actions.js.map +7 -1
  30. package/build-module/store/constants.js +5 -7
  31. package/build-module/store/constants.js.map +7 -1
  32. package/build-module/store/index.js +10 -26
  33. package/build-module/store/index.js.map +7 -1
  34. package/build-module/store/reducer.js +54 -71
  35. package/build-module/store/reducer.js.map +7 -1
  36. package/build-module/store/selectors.js +33 -75
  37. package/build-module/store/selectors.js.map +7 -1
  38. package/package.json +13 -7
@@ -1,150 +1,102 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import { applyFormat, removeFormat } from '@wordpress/rich-text';
6
- const FORMAT_NAME = 'core/annotation';
7
- const ANNOTATION_ATTRIBUTE_PREFIX = 'annotation-text-';
8
- /**
9
- * Internal dependencies
10
- */
11
- import { STORE_NAME } from '../store/constants';
12
-
13
- /**
14
- * Applies given annotations to the given record.
15
- *
16
- * @param {Object} record The record to apply annotations to.
17
- * @param {Array} annotations The annotation to apply.
18
- * @return {Object} A record with the annotations applied.
19
- */
20
- export function applyAnnotations(record, annotations = []) {
21
- annotations.forEach(annotation => {
22
- let {
23
- start,
24
- end
25
- } = annotation;
1
+ import { __ } from "@wordpress/i18n";
2
+ import { applyFormat, removeFormat } from "@wordpress/rich-text";
3
+ const FORMAT_NAME = "core/annotation";
4
+ const ANNOTATION_ATTRIBUTE_PREFIX = "annotation-text-";
5
+ import { STORE_NAME } from "../store/constants";
6
+ function applyAnnotations(record, annotations = []) {
7
+ annotations.forEach((annotation2) => {
8
+ let { start, end } = annotation2;
26
9
  if (start > record.text.length) {
27
10
  start = record.text.length;
28
11
  }
29
12
  if (end > record.text.length) {
30
13
  end = record.text.length;
31
14
  }
32
- const className = ANNOTATION_ATTRIBUTE_PREFIX + annotation.source;
33
- const id = ANNOTATION_ATTRIBUTE_PREFIX + annotation.id;
34
- record = applyFormat(record, {
35
- type: FORMAT_NAME,
36
- attributes: {
37
- className,
38
- id
39
- }
40
- }, start, end);
15
+ const className = ANNOTATION_ATTRIBUTE_PREFIX + annotation2.source;
16
+ const id = ANNOTATION_ATTRIBUTE_PREFIX + annotation2.id;
17
+ record = applyFormat(
18
+ record,
19
+ {
20
+ type: FORMAT_NAME,
21
+ attributes: {
22
+ className,
23
+ id
24
+ }
25
+ },
26
+ start,
27
+ end
28
+ );
41
29
  });
42
30
  return record;
43
31
  }
44
-
45
- /**
46
- * Removes annotations from the given record.
47
- *
48
- * @param {Object} record Record to remove annotations from.
49
- * @return {Object} The cleaned record.
50
- */
51
- export function removeAnnotations(record) {
52
- return removeFormat(record, 'core/annotation', 0, record.text.length);
32
+ function removeAnnotations(record) {
33
+ return removeFormat(record, "core/annotation", 0, record.text.length);
53
34
  }
54
-
55
- /**
56
- * Retrieves the positions of annotations inside an array of formats.
57
- *
58
- * @param {Array} formats Formats with annotations in there.
59
- * @return {Object} ID keyed positions of annotations.
60
- */
61
35
  function retrieveAnnotationPositions(formats) {
62
36
  const positions = {};
63
37
  formats.forEach((characterFormats, i) => {
64
38
  characterFormats = characterFormats || [];
65
- characterFormats = characterFormats.filter(format => format.type === FORMAT_NAME);
66
- characterFormats.forEach(format => {
67
- let {
68
- id
69
- } = format.attributes;
70
- id = id.replace(ANNOTATION_ATTRIBUTE_PREFIX, '');
39
+ characterFormats = characterFormats.filter(
40
+ (format) => format.type === FORMAT_NAME
41
+ );
42
+ characterFormats.forEach((format) => {
43
+ let { id } = format.attributes;
44
+ id = id.replace(ANNOTATION_ATTRIBUTE_PREFIX, "");
71
45
  if (!positions.hasOwnProperty(id)) {
72
46
  positions[id] = {
73
47
  start: i
74
48
  };
75
49
  }
76
-
77
- // Annotations refer to positions between characters.
78
- // Formats refer to the character themselves.
79
- // So we need to adjust for that here.
80
50
  positions[id].end = i + 1;
81
51
  });
82
52
  });
83
53
  return positions;
84
54
  }
85
-
86
- /**
87
- * Updates annotations in the state based on positions retrieved from RichText.
88
- *
89
- * @param {Array} annotations The annotations that are currently applied.
90
- * @param {Array} positions The current positions of the given annotations.
91
- * @param {Object} actions
92
- * @param {Function} actions.removeAnnotation Function to remove an annotation from the state.
93
- * @param {Function} actions.updateAnnotationRange Function to update an annotation range in the state.
94
- */
95
- function updateAnnotationsWithPositions(annotations, positions, {
96
- removeAnnotation,
97
- updateAnnotationRange
98
- }) {
99
- annotations.forEach(currentAnnotation => {
55
+ function updateAnnotationsWithPositions(annotations, positions, { removeAnnotation, updateAnnotationRange }) {
56
+ annotations.forEach((currentAnnotation) => {
100
57
  const position = positions[currentAnnotation.id];
101
- // If we cannot find an annotation, delete it.
102
58
  if (!position) {
103
- // Apparently the annotation has been removed, so remove it from the state:
104
- // Remove...
105
59
  removeAnnotation(currentAnnotation.id);
106
60
  return;
107
61
  }
108
- const {
109
- start,
110
- end
111
- } = currentAnnotation;
62
+ const { start, end } = currentAnnotation;
112
63
  if (start !== position.start || end !== position.end) {
113
- updateAnnotationRange(currentAnnotation.id, position.start, position.end);
64
+ updateAnnotationRange(
65
+ currentAnnotation.id,
66
+ position.start,
67
+ position.end
68
+ );
114
69
  }
115
70
  });
116
71
  }
117
- export const annotation = {
72
+ const annotation = {
118
73
  name: FORMAT_NAME,
119
- title: __('Annotation'),
120
- tagName: 'mark',
121
- className: 'annotation-text',
74
+ title: __("Annotation"),
75
+ tagName: "mark",
76
+ className: "annotation-text",
122
77
  attributes: {
123
- className: 'class',
124
- id: 'id'
78
+ className: "class",
79
+ id: "id"
125
80
  },
126
81
  edit() {
127
82
  return null;
128
83
  },
129
- __experimentalGetPropsForEditableTreePreparation(select, {
130
- richTextIdentifier,
131
- blockClientId
132
- }) {
84
+ __experimentalGetPropsForEditableTreePreparation(select, { richTextIdentifier, blockClientId }) {
133
85
  return {
134
- annotations: select(STORE_NAME).__experimentalGetAnnotationsForRichText(blockClientId, richTextIdentifier)
86
+ annotations: select(
87
+ STORE_NAME
88
+ ).__experimentalGetAnnotationsForRichText(
89
+ blockClientId,
90
+ richTextIdentifier
91
+ )
135
92
  };
136
93
  },
137
- __experimentalCreatePrepareEditableTree({
138
- annotations
139
- }) {
94
+ __experimentalCreatePrepareEditableTree({ annotations }) {
140
95
  return (formats, text) => {
141
96
  if (annotations.length === 0) {
142
97
  return formats;
143
98
  }
144
- let record = {
145
- formats,
146
- text
147
- };
99
+ let record = { formats, text };
148
100
  record = applyAnnotations(record, annotations);
149
101
  return record.formats;
150
102
  };
@@ -156,13 +108,9 @@ export const annotation = {
156
108
  };
157
109
  },
158
110
  __experimentalCreateOnChangeEditableValue(props) {
159
- return formats => {
111
+ return (formats) => {
160
112
  const positions = retrieveAnnotationPositions(formats);
161
- const {
162
- removeAnnotation,
163
- updateAnnotationRange,
164
- annotations
165
- } = props;
113
+ const { removeAnnotation, updateAnnotationRange, annotations } = props;
166
114
  updateAnnotationsWithPositions(annotations, positions, {
167
115
  removeAnnotation,
168
116
  updateAnnotationRange
@@ -170,4 +118,9 @@ export const annotation = {
170
118
  };
171
119
  }
172
120
  };
173
- //# sourceMappingURL=annotation.js.map
121
+ export {
122
+ annotation,
123
+ applyAnnotations,
124
+ removeAnnotations
125
+ };
126
+ //# sourceMappingURL=annotation.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["__","applyFormat","removeFormat","FORMAT_NAME","ANNOTATION_ATTRIBUTE_PREFIX","STORE_NAME","applyAnnotations","record","annotations","forEach","annotation","start","end","text","length","className","source","id","type","attributes","removeAnnotations","retrieveAnnotationPositions","formats","positions","characterFormats","i","filter","format","replace","hasOwnProperty","updateAnnotationsWithPositions","removeAnnotation","updateAnnotationRange","currentAnnotation","position","name","title","tagName","edit","__experimentalGetPropsForEditableTreePreparation","select","richTextIdentifier","blockClientId","__experimentalGetAnnotationsForRichText","__experimentalCreatePrepareEditableTree","__experimentalGetPropsForEditableTreeChangeHandler","dispatch","__experimentalRemoveAnnotation","__experimentalUpdateAnnotationRange","__experimentalCreateOnChangeEditableValue","props"],"sources":["@wordpress/annotations/src/format/annotation.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { applyFormat, removeFormat } from '@wordpress/rich-text';\n\nconst FORMAT_NAME = 'core/annotation';\n\nconst ANNOTATION_ATTRIBUTE_PREFIX = 'annotation-text-';\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from '../store/constants';\n\n/**\n * Applies given annotations to the given record.\n *\n * @param {Object} record The record to apply annotations to.\n * @param {Array} annotations The annotation to apply.\n * @return {Object} A record with the annotations applied.\n */\nexport function applyAnnotations( record, annotations = [] ) {\n\tannotations.forEach( ( annotation ) => {\n\t\tlet { start, end } = annotation;\n\n\t\tif ( start > record.text.length ) {\n\t\t\tstart = record.text.length;\n\t\t}\n\n\t\tif ( end > record.text.length ) {\n\t\t\tend = record.text.length;\n\t\t}\n\n\t\tconst className = ANNOTATION_ATTRIBUTE_PREFIX + annotation.source;\n\t\tconst id = ANNOTATION_ATTRIBUTE_PREFIX + annotation.id;\n\n\t\trecord = applyFormat(\n\t\t\trecord,\n\t\t\t{\n\t\t\t\ttype: FORMAT_NAME,\n\t\t\t\tattributes: {\n\t\t\t\t\tclassName,\n\t\t\t\t\tid,\n\t\t\t\t},\n\t\t\t},\n\t\t\tstart,\n\t\t\tend\n\t\t);\n\t} );\n\n\treturn record;\n}\n\n/**\n * Removes annotations from the given record.\n *\n * @param {Object} record Record to remove annotations from.\n * @return {Object} The cleaned record.\n */\nexport function removeAnnotations( record ) {\n\treturn removeFormat( record, 'core/annotation', 0, record.text.length );\n}\n\n/**\n * Retrieves the positions of annotations inside an array of formats.\n *\n * @param {Array} formats Formats with annotations in there.\n * @return {Object} ID keyed positions of annotations.\n */\nfunction retrieveAnnotationPositions( formats ) {\n\tconst positions = {};\n\n\tformats.forEach( ( characterFormats, i ) => {\n\t\tcharacterFormats = characterFormats || [];\n\t\tcharacterFormats = characterFormats.filter(\n\t\t\t( format ) => format.type === FORMAT_NAME\n\t\t);\n\t\tcharacterFormats.forEach( ( format ) => {\n\t\t\tlet { id } = format.attributes;\n\t\t\tid = id.replace( ANNOTATION_ATTRIBUTE_PREFIX, '' );\n\n\t\t\tif ( ! positions.hasOwnProperty( id ) ) {\n\t\t\t\tpositions[ id ] = {\n\t\t\t\t\tstart: i,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Annotations refer to positions between characters.\n\t\t\t// Formats refer to the character themselves.\n\t\t\t// So we need to adjust for that here.\n\t\t\tpositions[ id ].end = i + 1;\n\t\t} );\n\t} );\n\n\treturn positions;\n}\n\n/**\n * Updates annotations in the state based on positions retrieved from RichText.\n *\n * @param {Array} annotations The annotations that are currently applied.\n * @param {Array} positions The current positions of the given annotations.\n * @param {Object} actions\n * @param {Function} actions.removeAnnotation Function to remove an annotation from the state.\n * @param {Function} actions.updateAnnotationRange Function to update an annotation range in the state.\n */\nfunction updateAnnotationsWithPositions(\n\tannotations,\n\tpositions,\n\t{ removeAnnotation, updateAnnotationRange }\n) {\n\tannotations.forEach( ( currentAnnotation ) => {\n\t\tconst position = positions[ currentAnnotation.id ];\n\t\t// If we cannot find an annotation, delete it.\n\t\tif ( ! position ) {\n\t\t\t// Apparently the annotation has been removed, so remove it from the state:\n\t\t\t// Remove...\n\t\t\tremoveAnnotation( currentAnnotation.id );\n\t\t\treturn;\n\t\t}\n\n\t\tconst { start, end } = currentAnnotation;\n\t\tif ( start !== position.start || end !== position.end ) {\n\t\t\tupdateAnnotationRange(\n\t\t\t\tcurrentAnnotation.id,\n\t\t\t\tposition.start,\n\t\t\t\tposition.end\n\t\t\t);\n\t\t}\n\t} );\n}\n\nexport const annotation = {\n\tname: FORMAT_NAME,\n\ttitle: __( 'Annotation' ),\n\ttagName: 'mark',\n\tclassName: 'annotation-text',\n\tattributes: {\n\t\tclassName: 'class',\n\t\tid: 'id',\n\t},\n\tedit() {\n\t\treturn null;\n\t},\n\t__experimentalGetPropsForEditableTreePreparation(\n\t\tselect,\n\t\t{ richTextIdentifier, blockClientId }\n\t) {\n\t\treturn {\n\t\t\tannotations: select(\n\t\t\t\tSTORE_NAME\n\t\t\t).__experimentalGetAnnotationsForRichText(\n\t\t\t\tblockClientId,\n\t\t\t\trichTextIdentifier\n\t\t\t),\n\t\t};\n\t},\n\t__experimentalCreatePrepareEditableTree( { annotations } ) {\n\t\treturn ( formats, text ) => {\n\t\t\tif ( annotations.length === 0 ) {\n\t\t\t\treturn formats;\n\t\t\t}\n\n\t\t\tlet record = { formats, text };\n\t\t\trecord = applyAnnotations( record, annotations );\n\t\t\treturn record.formats;\n\t\t};\n\t},\n\t__experimentalGetPropsForEditableTreeChangeHandler( dispatch ) {\n\t\treturn {\n\t\t\tremoveAnnotation:\n\t\t\t\tdispatch( STORE_NAME ).__experimentalRemoveAnnotation,\n\t\t\tupdateAnnotationRange:\n\t\t\t\tdispatch( STORE_NAME ).__experimentalUpdateAnnotationRange,\n\t\t};\n\t},\n\t__experimentalCreateOnChangeEditableValue( props ) {\n\t\treturn ( formats ) => {\n\t\t\tconst positions = retrieveAnnotationPositions( formats );\n\t\t\tconst { removeAnnotation, updateAnnotationRange, annotations } =\n\t\t\t\tprops;\n\n\t\t\tupdateAnnotationsWithPositions( annotations, positions, {\n\t\t\t\tremoveAnnotation,\n\t\t\t\tupdateAnnotationRange,\n\t\t\t} );\n\t\t};\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,EAAEC,YAAY,QAAQ,sBAAsB;AAEhE,MAAMC,WAAW,GAAG,iBAAiB;AAErC,MAAMC,2BAA2B,GAAG,kBAAkB;AACtD;AACA;AACA;AACA,SAASC,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAEC,MAAM,EAAEC,WAAW,GAAG,EAAE,EAAG;EAC5DA,WAAW,CAACC,OAAO,CAAIC,UAAU,IAAM;IACtC,IAAI;MAAEC,KAAK;MAAEC;IAAI,CAAC,GAAGF,UAAU;IAE/B,IAAKC,KAAK,GAAGJ,MAAM,CAACM,IAAI,CAACC,MAAM,EAAG;MACjCH,KAAK,GAAGJ,MAAM,CAACM,IAAI,CAACC,MAAM;IAC3B;IAEA,IAAKF,GAAG,GAAGL,MAAM,CAACM,IAAI,CAACC,MAAM,EAAG;MAC/BF,GAAG,GAAGL,MAAM,CAACM,IAAI,CAACC,MAAM;IACzB;IAEA,MAAMC,SAAS,GAAGX,2BAA2B,GAAGM,UAAU,CAACM,MAAM;IACjE,MAAMC,EAAE,GAAGb,2BAA2B,GAAGM,UAAU,CAACO,EAAE;IAEtDV,MAAM,GAAGN,WAAW,CACnBM,MAAM,EACN;MACCW,IAAI,EAAEf,WAAW;MACjBgB,UAAU,EAAE;QACXJ,SAAS;QACTE;M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CAAEC,MAAM,EAAEC,WAAY,CAAC;MAChD,OAAOD,MAAM,CAACe,OAAO;IACtB,CAAC;EACF,CAAC;EACDuB,kDAAkDA,CAAEC,QAAQ,EAAG;IAC9D,OAAO;MACNf,gBAAgB,EACfe,QAAQ,CAAEzC,UAAW,CAAC,CAAC0C,8BAA8B;MACtDf,qBAAqB,EACpBc,QAAQ,CAAEzC,UAAW,CAAC,CAAC2C;IACzB,CAAC;EACF,CAAC;EACDC,yCAAyCA,CAAEC,KAAK,EAAG;IAClD,OAAS5B,OAAO,IAAM;MACrB,MAAMC,SAAS,GAAGF,2BAA2B,CAAEC,OAAQ,CAAC;MACxD,MAAM;QAAES,gBAAgB;QAAEC,qBAAqB;QAAExB;MAAY,CAAC,GAC7D0C,KAAK;MAENpB,8BAA8B,CAAEtB,WAAW,EAAEe,SAAS,EAAE;QACvDQ,gBAAgB;QAChBC;MACD,CAAE,CAAC;IACJ,CAAC;EACF;AACD,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/format/annotation.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { applyFormat, removeFormat } from '@wordpress/rich-text';\n\nconst FORMAT_NAME = 'core/annotation';\n\nconst ANNOTATION_ATTRIBUTE_PREFIX = 'annotation-text-';\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from '../store/constants';\n\n/**\n * Applies given annotations to the given record.\n *\n * @param {Object} record The record to apply annotations to.\n * @param {Array} annotations The annotation to apply.\n * @return {Object} A record with the annotations applied.\n */\nexport function applyAnnotations( record, annotations = [] ) {\n\tannotations.forEach( ( annotation ) => {\n\t\tlet { start, end } = annotation;\n\n\t\tif ( start > record.text.length ) {\n\t\t\tstart = record.text.length;\n\t\t}\n\n\t\tif ( end > record.text.length ) {\n\t\t\tend = record.text.length;\n\t\t}\n\n\t\tconst className = ANNOTATION_ATTRIBUTE_PREFIX + annotation.source;\n\t\tconst id = ANNOTATION_ATTRIBUTE_PREFIX + annotation.id;\n\n\t\trecord = applyFormat(\n\t\t\trecord,\n\t\t\t{\n\t\t\t\ttype: FORMAT_NAME,\n\t\t\t\tattributes: {\n\t\t\t\t\tclassName,\n\t\t\t\t\tid,\n\t\t\t\t},\n\t\t\t},\n\t\t\tstart,\n\t\t\tend\n\t\t);\n\t} );\n\n\treturn record;\n}\n\n/**\n * Removes annotations from the given record.\n *\n * @param {Object} record Record to remove annotations from.\n * @return {Object} The cleaned record.\n */\nexport function removeAnnotations( record ) {\n\treturn removeFormat( record, 'core/annotation', 0, record.text.length );\n}\n\n/**\n * Retrieves the positions of annotations inside an array of formats.\n *\n * @param {Array} formats Formats with annotations in there.\n * @return {Object} ID keyed positions of annotations.\n */\nfunction retrieveAnnotationPositions( formats ) {\n\tconst positions = {};\n\n\tformats.forEach( ( characterFormats, i ) => {\n\t\tcharacterFormats = characterFormats || [];\n\t\tcharacterFormats = characterFormats.filter(\n\t\t\t( format ) => format.type === FORMAT_NAME\n\t\t);\n\t\tcharacterFormats.forEach( ( format ) => {\n\t\t\tlet { id } = format.attributes;\n\t\t\tid = id.replace( ANNOTATION_ATTRIBUTE_PREFIX, '' );\n\n\t\t\tif ( ! positions.hasOwnProperty( id ) ) {\n\t\t\t\tpositions[ id ] = {\n\t\t\t\t\tstart: i,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Annotations refer to positions between characters.\n\t\t\t// Formats refer to the character themselves.\n\t\t\t// So we need to adjust for that here.\n\t\t\tpositions[ id ].end = i + 1;\n\t\t} );\n\t} );\n\n\treturn positions;\n}\n\n/**\n * Updates annotations in the state based on positions retrieved from RichText.\n *\n * @param {Array} annotations The annotations that are currently applied.\n * @param {Array} positions The current positions of the given annotations.\n * @param {Object} actions\n * @param {Function} actions.removeAnnotation Function to remove an annotation from the state.\n * @param {Function} actions.updateAnnotationRange Function to update an annotation range in the state.\n */\nfunction updateAnnotationsWithPositions(\n\tannotations,\n\tpositions,\n\t{ removeAnnotation, updateAnnotationRange }\n) {\n\tannotations.forEach( ( currentAnnotation ) => {\n\t\tconst position = positions[ currentAnnotation.id ];\n\t\t// If we cannot find an annotation, delete it.\n\t\tif ( ! position ) {\n\t\t\t// Apparently the annotation has been removed, so remove it from the state:\n\t\t\t// Remove...\n\t\t\tremoveAnnotation( currentAnnotation.id );\n\t\t\treturn;\n\t\t}\n\n\t\tconst { start, end } = currentAnnotation;\n\t\tif ( start !== position.start || end !== position.end ) {\n\t\t\tupdateAnnotationRange(\n\t\t\t\tcurrentAnnotation.id,\n\t\t\t\tposition.start,\n\t\t\t\tposition.end\n\t\t\t);\n\t\t}\n\t} );\n}\n\nexport const annotation = {\n\tname: FORMAT_NAME,\n\ttitle: __( 'Annotation' ),\n\ttagName: 'mark',\n\tclassName: 'annotation-text',\n\tattributes: {\n\t\tclassName: 'class',\n\t\tid: 'id',\n\t},\n\tedit() {\n\t\treturn null;\n\t},\n\t__experimentalGetPropsForEditableTreePreparation(\n\t\tselect,\n\t\t{ richTextIdentifier, blockClientId }\n\t) {\n\t\treturn {\n\t\t\tannotations: select(\n\t\t\t\tSTORE_NAME\n\t\t\t).__experimentalGetAnnotationsForRichText(\n\t\t\t\tblockClientId,\n\t\t\t\trichTextIdentifier\n\t\t\t),\n\t\t};\n\t},\n\t__experimentalCreatePrepareEditableTree( { annotations } ) {\n\t\treturn ( formats, text ) => {\n\t\t\tif ( annotations.length === 0 ) {\n\t\t\t\treturn formats;\n\t\t\t}\n\n\t\t\tlet record = { formats, text };\n\t\t\trecord = applyAnnotations( record, annotations );\n\t\t\treturn record.formats;\n\t\t};\n\t},\n\t__experimentalGetPropsForEditableTreeChangeHandler( dispatch ) {\n\t\treturn {\n\t\t\tremoveAnnotation:\n\t\t\t\tdispatch( STORE_NAME ).__experimentalRemoveAnnotation,\n\t\t\tupdateAnnotationRange:\n\t\t\t\tdispatch( STORE_NAME ).__experimentalUpdateAnnotationRange,\n\t\t};\n\t},\n\t__experimentalCreateOnChangeEditableValue( props ) {\n\t\treturn ( formats ) => {\n\t\t\tconst positions = retrieveAnnotationPositions( formats );\n\t\t\tconst { removeAnnotation, updateAnnotationRange, annotations } =\n\t\t\t\tprops;\n\n\t\t\tupdateAnnotationsWithPositions( annotations, positions, {\n\t\t\t\tremoveAnnotation,\n\t\t\t\tupdateAnnotationRange,\n\t\t\t} );\n\t\t};\n\t},\n};\n"],
5
+ "mappings": "AAGA,SAAS,UAAU;AACnB,SAAS,aAAa,oBAAoB;AAE1C,MAAM,cAAc;AAEpB,MAAM,8BAA8B;AAIpC,SAAS,kBAAkB;AASpB,SAAS,iBAAkB,QAAQ,cAAc,CAAC,GAAI;AAC5D,cAAY,QAAS,CAAEA,gBAAgB;AACtC,QAAI,EAAE,OAAO,IAAI,IAAIA;AAErB,QAAK,QAAQ,OAAO,KAAK,QAAS;AACjC,cAAQ,OAAO,KAAK;AAAA,IACrB;AAEA,QAAK,MAAM,OAAO,KAAK,QAAS;AAC/B,YAAM,OAAO,KAAK;AAAA,IACnB;AAEA,UAAM,YAAY,8BAA8BA,YAAW;AAC3D,UAAM,KAAK,8BAA8BA,YAAW;AAEpD,aAAS;AAAA,MACR;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,YAAY;AAAA,UACX;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD,CAAE;AAEF,SAAO;AACR;AAQO,SAAS,kBAAmB,QAAS;AAC3C,SAAO,aAAc,QAAQ,mBAAmB,GAAG,OAAO,KAAK,MAAO;AACvE;AAQA,SAAS,4BAA6B,SAAU;AAC/C,QAAM,YAAY,CAAC;AAEnB,UAAQ,QAAS,CAAE,kBAAkB,MAAO;AAC3C,uBAAmB,oBAAoB,CAAC;AACxC,uBAAmB,iBAAiB;AAAA,MACnC,CAAE,WAAY,OAAO,SAAS;AAAA,IAC/B;AACA,qBAAiB,QAAS,CAAE,WAAY;AACvC,UAAI,EAAE,GAAG,IAAI,OAAO;AACpB,WAAK,G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;AAC9D,WAAO;AAAA,MACN,kBACC,SAAU,UAAW,EAAE;AAAA,MACxB,uBACC,SAAU,UAAW,EAAE;AAAA,IACzB;AAAA,EACD;AAAA,EACA,0CAA2C,OAAQ;AAClD,WAAO,CAAE,YAAa;AACrB,YAAM,YAAY,4BAA6B,OAAQ;AACvD,YAAM,EAAE,kBAAkB,uBAAuB,YAAY,IAC5D;AAED,qCAAgC,aAAa,WAAW;AAAA,QACvD;AAAA,QACA;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AACD;",
6
+ "names": ["annotation"]
7
+ }
@@ -1,15 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { registerFormatType } from '@wordpress/rich-text';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { annotation } from './annotation';
10
- const {
11
- name,
12
- ...settings
13
- } = annotation;
1
+ import { registerFormatType } from "@wordpress/rich-text";
2
+ import { annotation } from "./annotation";
3
+ const { name, ...settings } = annotation;
14
4
  registerFormatType(name, settings);
15
- //# sourceMappingURL=index.js.map
5
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["registerFormatType","annotation","name","settings"],"sources":["@wordpress/annotations/src/format/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { registerFormatType } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { annotation } from './annotation';\n\nconst { name, ...settings } = annotation;\n\nregisterFormatType( name, settings );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,kBAAkB,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASC,UAAU,QAAQ,cAAc;AAEzC,MAAM;EAAEC,IAAI;EAAE,GAAGC;AAAS,CAAC,GAAGF,UAAU;AAExCD,kBAAkB,CAAEE,IAAI,EAAEC,QAAS,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/format/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { registerFormatType } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { annotation } from './annotation';\n\nconst { name, ...settings } = annotation;\n\nregisterFormatType( name, settings );\n"],
5
+ "mappings": "AAGA,SAAS,0BAA0B;AAKnC,SAAS,kBAAkB;AAE3B,MAAM,EAAE,MAAM,GAAG,SAAS,IAAI;AAE9B,mBAAoB,MAAM,QAAS;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import './format';
5
- import './block';
6
- export { store } from './store';
7
- //# sourceMappingURL=index.js.map
1
+ import "./format";
2
+ import "./block";
3
+ import { store } from "./store";
4
+ export {
5
+ store
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["store"],"sources":["@wordpress/annotations/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './format';\nimport './block';\n\nexport { store } from './store';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,UAAU;AACjB,OAAO,SAAS;AAEhB,SAASA,KAAK,QAAQ,SAAS","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport './format';\nimport './block';\n\nexport { store } from './store';\n"],
5
+ "mappings": "AAGA,OAAO;AACP,OAAO;AAEP,SAAS,aAAa;",
6
+ "names": []
7
+ }
@@ -1,100 +1,49 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { v4 as uuid } from 'uuid';
5
-
6
- /**
7
- * @typedef WPAnnotationRange
8
- *
9
- * @property {number} start The offset where the annotation should start.
10
- * @property {number} end The offset where the annotation should end.
11
- */
12
-
13
- /**
14
- * Adds an annotation to a block.
15
- *
16
- * The `block` attribute refers to a block ID that needs to be annotated.
17
- * `isBlockAnnotation` controls whether or not the annotation is a block
18
- * annotation. The `source` is the source of the annotation, this will be used
19
- * to identity groups of annotations.
20
- *
21
- * The `range` property is only relevant if the selector is 'range'.
22
- *
23
- * @param {Object} annotation The annotation to add.
24
- * @param {string} annotation.blockClientId The blockClientId to add the annotation to.
25
- * @param {string} annotation.richTextIdentifier Identifier for the RichText instance the annotation applies to.
26
- * @param {WPAnnotationRange} annotation.range The range at which to apply this annotation.
27
- * @param {string} [annotation.selector="range"] The way to apply this annotation.
28
- * @param {string} [annotation.source="default"] The source that added the annotation.
29
- * @param {string} [annotation.id] The ID the annotation should have. Generates a UUID by default.
30
- *
31
- * @return {Object} Action object.
32
- */
33
- export function __experimentalAddAnnotation({
1
+ import { v4 as uuid } from "uuid";
2
+ function __experimentalAddAnnotation({
34
3
  blockClientId,
35
4
  richTextIdentifier = null,
36
5
  range = null,
37
- selector = 'range',
38
- source = 'default',
6
+ selector = "range",
7
+ source = "default",
39
8
  id = uuid()
40
9
  }) {
41
10
  const action = {
42
- type: 'ANNOTATION_ADD',
11
+ type: "ANNOTATION_ADD",
43
12
  id,
44
13
  blockClientId,
45
14
  richTextIdentifier,
46
15
  source,
47
16
  selector
48
17
  };
49
- if (selector === 'range') {
18
+ if (selector === "range") {
50
19
  action.range = range;
51
20
  }
52
21
  return action;
53
22
  }
54
-
55
- /**
56
- * Removes an annotation with a specific ID.
57
- *
58
- * @param {string} annotationId The annotation to remove.
59
- *
60
- * @return {Object} Action object.
61
- */
62
- export function __experimentalRemoveAnnotation(annotationId) {
23
+ function __experimentalRemoveAnnotation(annotationId) {
63
24
  return {
64
- type: 'ANNOTATION_REMOVE',
25
+ type: "ANNOTATION_REMOVE",
65
26
  annotationId
66
27
  };
67
28
  }
68
-
69
- /**
70
- * Updates the range of an annotation.
71
- *
72
- * @param {string} annotationId ID of the annotation to update.
73
- * @param {number} start The start of the new range.
74
- * @param {number} end The end of the new range.
75
- *
76
- * @return {Object} Action object.
77
- */
78
- export function __experimentalUpdateAnnotationRange(annotationId, start, end) {
29
+ function __experimentalUpdateAnnotationRange(annotationId, start, end) {
79
30
  return {
80
- type: 'ANNOTATION_UPDATE_RANGE',
31
+ type: "ANNOTATION_UPDATE_RANGE",
81
32
  annotationId,
82
33
  start,
83
34
  end
84
35
  };
85
36
  }
86
-
87
- /**
88
- * Removes all annotations of a specific source.
89
- *
90
- * @param {string} source The source to remove.
91
- *
92
- * @return {Object} Action object.
93
- */
94
- export function __experimentalRemoveAnnotationsBySource(source) {
37
+ function __experimentalRemoveAnnotationsBySource(source) {
95
38
  return {
96
- type: 'ANNOTATION_REMOVE_SOURCE',
39
+ type: "ANNOTATION_REMOVE_SOURCE",
97
40
  source
98
41
  };
99
42
  }
100
- //# sourceMappingURL=actions.js.map
43
+ export {
44
+ __experimentalAddAnnotation,
45
+ __experimentalRemoveAnnotation,
46
+ __experimentalRemoveAnnotationsBySource,
47
+ __experimentalUpdateAnnotationRange
48
+ };
49
+ //# sourceMappingURL=actions.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["v4","uuid","__experimentalAddAnnotation","blockClientId","richTextIdentifier","range","selector","source","id","action","type","__experimentalRemoveAnnotation","annotationId","__experimentalUpdateAnnotationRange","start","end","__experimentalRemoveAnnotationsBySource"],"sources":["@wordpress/annotations/src/store/actions.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { v4 as uuid } from 'uuid';\n\n/**\n * @typedef WPAnnotationRange\n *\n * @property {number} start The offset where the annotation should start.\n * @property {number} end The offset where the annotation should end.\n */\n\n/**\n * Adds an annotation to a block.\n *\n * The `block` attribute refers to a block ID that needs to be annotated.\n * `isBlockAnnotation` controls whether or not the annotation is a block\n * annotation. The `source` is the source of the annotation, this will be used\n * to identity groups of annotations.\n *\n * The `range` property is only relevant if the selector is 'range'.\n *\n * @param {Object} annotation The annotation to add.\n * @param {string} annotation.blockClientId The blockClientId to add the annotation to.\n * @param {string} annotation.richTextIdentifier Identifier for the RichText instance the annotation applies to.\n * @param {WPAnnotationRange} annotation.range The range at which to apply this annotation.\n * @param {string} [annotation.selector=\"range\"] The way to apply this annotation.\n * @param {string} [annotation.source=\"default\"] The source that added the annotation.\n * @param {string} [annotation.id] The ID the annotation should have. Generates a UUID by default.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalAddAnnotation( {\n\tblockClientId,\n\trichTextIdentifier = null,\n\trange = null,\n\tselector = 'range',\n\tsource = 'default',\n\tid = uuid(),\n} ) {\n\tconst action = {\n\t\ttype: 'ANNOTATION_ADD',\n\t\tid,\n\t\tblockClientId,\n\t\trichTextIdentifier,\n\t\tsource,\n\t\tselector,\n\t};\n\n\tif ( selector === 'range' ) {\n\t\taction.range = range;\n\t}\n\n\treturn action;\n}\n\n/**\n * Removes an annotation with a specific ID.\n *\n * @param {string} annotationId The annotation to remove.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalRemoveAnnotation( annotationId ) {\n\treturn {\n\t\ttype: 'ANNOTATION_REMOVE',\n\t\tannotationId,\n\t};\n}\n\n/**\n * Updates the range of an annotation.\n *\n * @param {string} annotationId ID of the annotation to update.\n * @param {number} start The start of the new range.\n * @param {number} end The end of the new range.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalUpdateAnnotationRange(\n\tannotationId,\n\tstart,\n\tend\n) {\n\treturn {\n\t\ttype: 'ANNOTATION_UPDATE_RANGE',\n\t\tannotationId,\n\t\tstart,\n\t\tend,\n\t};\n}\n\n/**\n * Removes all annotations of a specific source.\n *\n * @param {string} source The source to remove.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalRemoveAnnotationsBySource( source ) {\n\treturn {\n\t\ttype: 'ANNOTATION_REMOVE_SOURCE',\n\t\tsource,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,IAAIC,IAAI,QAAQ,MAAM;;AAEjC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,2BAA2BA,CAAE;EAC5CC,aAAa;EACbC,kBAAkB,GAAG,IAAI;EACzBC,KAAK,GAAG,IAAI;EACZC,QAAQ,GAAG,OAAO;EAClBC,MAAM,GAAG,SAAS;EAClBC,EAAE,GAAGP,IAAI,CAAC;AACX,CAAC,EAAG;EACH,MAAMQ,MAAM,GAAG;IACdC,IAAI,EAAE,gBAAgB;IACtBF,EAAE;IACFL,aAAa;IACbC,kBAAkB;IAClBG,MAAM;IACND;EACD,CAAC;EAED,IAAKA,QAAQ,KAAK,OAAO,EAAG;IAC3BG,MAAM,CAACJ,KAAK,GAAGA,KAAK;EACrB;EAEA,OAAOI,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,8BAA8BA,CAAEC,YAAY,EAAG;EAC9D,OAAO;IACNF,IAAI,EAAE,mBAAmB;IACzBE;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mCAAmCA,CAClDD,YAAY,EACZE,KAAK,EACLC,GAAG,EACF;EACD,OAAO;IACNL,IAAI,EAAE,yBAAyB;IAC/BE,YAAY;IACZE,KAAK;IACLC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uCAAuCA,CAAET,MAAM,EAAG;EACjE,OAAO;IACNG,IAAI,EAAE,0BAA0B;IAChCH;EACD,CAAC;AACF","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/actions.js"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { v4 as uuid } from 'uuid';\n\n/**\n * @typedef WPAnnotationRange\n *\n * @property {number} start The offset where the annotation should start.\n * @property {number} end The offset where the annotation should end.\n */\n\n/**\n * Adds an annotation to a block.\n *\n * The `block` attribute refers to a block ID that needs to be annotated.\n * `isBlockAnnotation` controls whether or not the annotation is a block\n * annotation. The `source` is the source of the annotation, this will be used\n * to identity groups of annotations.\n *\n * The `range` property is only relevant if the selector is 'range'.\n *\n * @param {Object} annotation The annotation to add.\n * @param {string} annotation.blockClientId The blockClientId to add the annotation to.\n * @param {string} annotation.richTextIdentifier Identifier for the RichText instance the annotation applies to.\n * @param {WPAnnotationRange} annotation.range The range at which to apply this annotation.\n * @param {string} [annotation.selector=\"range\"] The way to apply this annotation.\n * @param {string} [annotation.source=\"default\"] The source that added the annotation.\n * @param {string} [annotation.id] The ID the annotation should have. Generates a UUID by default.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalAddAnnotation( {\n\tblockClientId,\n\trichTextIdentifier = null,\n\trange = null,\n\tselector = 'range',\n\tsource = 'default',\n\tid = uuid(),\n} ) {\n\tconst action = {\n\t\ttype: 'ANNOTATION_ADD',\n\t\tid,\n\t\tblockClientId,\n\t\trichTextIdentifier,\n\t\tsource,\n\t\tselector,\n\t};\n\n\tif ( selector === 'range' ) {\n\t\taction.range = range;\n\t}\n\n\treturn action;\n}\n\n/**\n * Removes an annotation with a specific ID.\n *\n * @param {string} annotationId The annotation to remove.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalRemoveAnnotation( annotationId ) {\n\treturn {\n\t\ttype: 'ANNOTATION_REMOVE',\n\t\tannotationId,\n\t};\n}\n\n/**\n * Updates the range of an annotation.\n *\n * @param {string} annotationId ID of the annotation to update.\n * @param {number} start The start of the new range.\n * @param {number} end The end of the new range.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalUpdateAnnotationRange(\n\tannotationId,\n\tstart,\n\tend\n) {\n\treturn {\n\t\ttype: 'ANNOTATION_UPDATE_RANGE',\n\t\tannotationId,\n\t\tstart,\n\t\tend,\n\t};\n}\n\n/**\n * Removes all annotations of a specific source.\n *\n * @param {string} source The source to remove.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalRemoveAnnotationsBySource( source ) {\n\treturn {\n\t\ttype: 'ANNOTATION_REMOVE_SOURCE',\n\t\tsource,\n\t};\n}\n"],
5
+ "mappings": "AAGA,SAAS,MAAM,YAAY;AA6BpB,SAAS,4BAA6B;AAAA,EAC5C;AAAA,EACA,qBAAqB;AAAA,EACrB,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,SAAS;AAAA,EACT,KAAK,KAAK;AACX,GAAI;AACH,QAAM,SAAS;AAAA,IACd,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,MAAK,aAAa,SAAU;AAC3B,WAAO,QAAQ;AAAA,EAChB;AAEA,SAAO;AACR;AASO,SAAS,+BAAgC,cAAe;AAC9D,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;AAWO,SAAS,oCACf,cACA,OACA,KACC;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AASO,SAAS,wCAAyC,QAAS;AACjE,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -1,7 +1,5 @@
1
- /**
2
- * The identifier for the data store.
3
- *
4
- * @type {string}
5
- */
6
- export const STORE_NAME = 'core/annotations';
7
- //# sourceMappingURL=constants.js.map
1
+ const STORE_NAME = "core/annotations";
2
+ export {
3
+ STORE_NAME
4
+ };
5
+ //# sourceMappingURL=constants.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["STORE_NAME"],"sources":["@wordpress/annotations/src/store/constants.js"],"sourcesContent":["/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/annotations';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,GAAG,kBAAkB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/constants.js"],
4
+ "sourcesContent": ["/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/annotations';\n"],
5
+ "mappings": "AAKO,MAAM,aAAa;",
6
+ "names": []
7
+ }
@@ -1,31 +1,15 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { register, createReduxStore } from '@wordpress/data';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import reducer from './reducer';
10
- import * as selectors from './selectors';
11
- import * as actions from './actions';
12
-
13
- /**
14
- * Module Constants
15
- */
16
- import { STORE_NAME } from './constants';
17
-
18
- /**
19
- * Store definition for the annotations namespace.
20
- *
21
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
22
- *
23
- * @type {Object}
24
- */
25
- export const store = createReduxStore(STORE_NAME, {
1
+ import { register, createReduxStore } from "@wordpress/data";
2
+ import reducer from "./reducer";
3
+ import * as selectors from "./selectors";
4
+ import * as actions from "./actions";
5
+ import { STORE_NAME } from "./constants";
6
+ const store = createReduxStore(STORE_NAME, {
26
7
  reducer,
27
8
  selectors,
28
9
  actions
29
10
  });
30
11
  register(store);
31
- //# sourceMappingURL=index.js.map
12
+ export {
13
+ store
14
+ };
15
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["register","createReduxStore","reducer","selectors","actions","STORE_NAME","store"],"sources":["@wordpress/annotations/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { register, createReduxStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\n\n/**\n * Module Constants\n */\nimport { STORE_NAME } from './constants';\n\n/**\n * Store definition for the annotations 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":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,gBAAgB,QAAQ,iBAAiB;;AAE5D;AACA;AACA;AACA,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAO,KAAKC,SAAS,MAAM,aAAa;AACxC,OAAO,KAAKC,OAAO,MAAM,WAAW;;AAEpC;AACA;AACA;AACA,SAASC,UAAU,QAAQ,aAAa;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAGL,gBAAgB,CAAEI,UAAU,EAAE;EAClDH,OAAO;EACPC,SAAS;EACTC;AACD,CAAE,CAAC;AAEHJ,QAAQ,CAAEM,KAAM,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { register, createReduxStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\n\n/**\n * Module Constants\n */\nimport { STORE_NAME } from './constants';\n\n/**\n * Store definition for the annotations 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"],
5
+ "mappings": "AAGA,SAAS,UAAU,wBAAwB;AAK3C,OAAO,aAAa;AACpB,YAAY,eAAe;AAC3B,YAAY,aAAa;AAKzB,SAAS,kBAAkB;AASpB,MAAM,QAAQ,iBAAkB,YAAY;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,SAAU,KAAM;",
6
+ "names": []
7
+ }