1 /******/ (function() { // webpackBootstrap |
1 /******/ (() => { // webpackBootstrap |
2 /******/ "use strict"; |
2 /******/ "use strict"; |
3 /******/ // The require scope |
3 /******/ // The require scope |
4 /******/ var __webpack_require__ = {}; |
4 /******/ var __webpack_require__ = {}; |
5 /******/ |
5 /******/ |
6 /************************************************************************/ |
6 /************************************************************************/ |
7 /******/ /* webpack/runtime/define property getters */ |
7 /******/ /* webpack/runtime/define property getters */ |
8 /******/ !function() { |
8 /******/ (() => { |
9 /******/ // define getter functions for harmony exports |
9 /******/ // define getter functions for harmony exports |
10 /******/ __webpack_require__.d = function(exports, definition) { |
10 /******/ __webpack_require__.d = (exports, definition) => { |
11 /******/ for(var key in definition) { |
11 /******/ for(var key in definition) { |
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
14 /******/ } |
14 /******/ } |
15 /******/ } |
15 /******/ } |
16 /******/ }; |
16 /******/ }; |
17 /******/ }(); |
17 /******/ })(); |
18 /******/ |
18 /******/ |
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
20 /******/ !function() { |
20 /******/ (() => { |
21 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
21 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
22 /******/ }(); |
22 /******/ })(); |
23 /******/ |
23 /******/ |
24 /******/ /* webpack/runtime/make namespace object */ |
24 /******/ /* webpack/runtime/make namespace object */ |
25 /******/ !function() { |
25 /******/ (() => { |
26 /******/ // define __esModule on exports |
26 /******/ // define __esModule on exports |
27 /******/ __webpack_require__.r = function(exports) { |
27 /******/ __webpack_require__.r = (exports) => { |
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
30 /******/ } |
30 /******/ } |
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
32 /******/ }; |
32 /******/ }; |
33 /******/ }(); |
33 /******/ })(); |
34 /******/ |
34 /******/ |
35 /************************************************************************/ |
35 /************************************************************************/ |
36 var __webpack_exports__ = {}; |
36 var __webpack_exports__ = {}; |
37 // ESM COMPAT FLAG |
37 // ESM COMPAT FLAG |
38 __webpack_require__.r(__webpack_exports__); |
38 __webpack_require__.r(__webpack_exports__); |
39 |
39 |
40 // EXPORTS |
40 // EXPORTS |
41 __webpack_require__.d(__webpack_exports__, { |
41 __webpack_require__.d(__webpack_exports__, { |
42 "store": function() { return /* reexport */ store; } |
42 store: () => (/* reexport */ store) |
43 }); |
43 }); |
44 |
44 |
45 // NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/selectors.js |
45 // NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/selectors.js |
46 var selectors_namespaceObject = {}; |
46 var selectors_namespaceObject = {}; |
47 __webpack_require__.r(selectors_namespaceObject); |
47 __webpack_require__.r(selectors_namespaceObject); |
48 __webpack_require__.d(selectors_namespaceObject, { |
48 __webpack_require__.d(selectors_namespaceObject, { |
49 "__experimentalGetAllAnnotationsForBlock": function() { return __experimentalGetAllAnnotationsForBlock; }, |
49 __experimentalGetAllAnnotationsForBlock: () => (__experimentalGetAllAnnotationsForBlock), |
50 "__experimentalGetAnnotations": function() { return __experimentalGetAnnotations; }, |
50 __experimentalGetAnnotations: () => (__experimentalGetAnnotations), |
51 "__experimentalGetAnnotationsForBlock": function() { return __experimentalGetAnnotationsForBlock; }, |
51 __experimentalGetAnnotationsForBlock: () => (__experimentalGetAnnotationsForBlock), |
52 "__experimentalGetAnnotationsForRichText": function() { return __experimentalGetAnnotationsForRichText; } |
52 __experimentalGetAnnotationsForRichText: () => (__experimentalGetAnnotationsForRichText) |
53 }); |
53 }); |
54 |
54 |
55 // NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/actions.js |
55 // NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/actions.js |
56 var actions_namespaceObject = {}; |
56 var actions_namespaceObject = {}; |
57 __webpack_require__.r(actions_namespaceObject); |
57 __webpack_require__.r(actions_namespaceObject); |
58 __webpack_require__.d(actions_namespaceObject, { |
58 __webpack_require__.d(actions_namespaceObject, { |
59 "__experimentalAddAnnotation": function() { return __experimentalAddAnnotation; }, |
59 __experimentalAddAnnotation: () => (__experimentalAddAnnotation), |
60 "__experimentalRemoveAnnotation": function() { return __experimentalRemoveAnnotation; }, |
60 __experimentalRemoveAnnotation: () => (__experimentalRemoveAnnotation), |
61 "__experimentalRemoveAnnotationsBySource": function() { return __experimentalRemoveAnnotationsBySource; }, |
61 __experimentalRemoveAnnotationsBySource: () => (__experimentalRemoveAnnotationsBySource), |
62 "__experimentalUpdateAnnotationRange": function() { return __experimentalUpdateAnnotationRange; } |
62 __experimentalUpdateAnnotationRange: () => (__experimentalUpdateAnnotationRange) |
63 }); |
63 }); |
64 |
64 |
65 ;// CONCATENATED MODULE: external ["wp","richText"] |
65 ;// CONCATENATED MODULE: external ["wp","richText"] |
66 var external_wp_richText_namespaceObject = window["wp"]["richText"]; |
66 const external_wp_richText_namespaceObject = window["wp"]["richText"]; |
67 ;// CONCATENATED MODULE: external ["wp","i18n"] |
67 ;// CONCATENATED MODULE: external ["wp","i18n"] |
68 var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
68 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
69 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/constants.js |
69 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/constants.js |
70 /** |
70 /** |
71 * The identifier for the data store. |
71 * The identifier for the data store. |
72 * |
72 * |
73 * @type {string} |
73 * @type {string} |
121 } |
116 } |
122 }, start, end); |
117 }, start, end); |
123 }); |
118 }); |
124 return record; |
119 return record; |
125 } |
120 } |
|
121 |
126 /** |
122 /** |
127 * Removes annotations from the given record. |
123 * Removes annotations from the given record. |
128 * |
124 * |
129 * @param {Object} record Record to remove annotations from. |
125 * @param {Object} record Record to remove annotations from. |
130 * @return {Object} The cleaned record. |
126 * @return {Object} The cleaned record. |
131 */ |
127 */ |
132 |
|
133 function removeAnnotations(record) { |
128 function removeAnnotations(record) { |
134 return removeFormat(record, 'core/annotation', 0, record.text.length); |
129 return removeFormat(record, 'core/annotation', 0, record.text.length); |
135 } |
130 } |
|
131 |
136 /** |
132 /** |
137 * Retrieves the positions of annotations inside an array of formats. |
133 * Retrieves the positions of annotations inside an array of formats. |
138 * |
134 * |
139 * @param {Array} formats Formats with annotations in there. |
135 * @param {Array} formats Formats with annotations in there. |
140 * @return {Object} ID keyed positions of annotations. |
136 * @return {Object} ID keyed positions of annotations. |
141 */ |
137 */ |
142 |
|
143 function retrieveAnnotationPositions(formats) { |
138 function retrieveAnnotationPositions(formats) { |
144 const positions = {}; |
139 const positions = {}; |
145 formats.forEach((characterFormats, i) => { |
140 formats.forEach((characterFormats, i) => { |
146 characterFormats = characterFormats || []; |
141 characterFormats = characterFormats || []; |
147 characterFormats = characterFormats.filter(format => format.type === FORMAT_NAME); |
142 characterFormats = characterFormats.filter(format => format.type === FORMAT_NAME); |
148 characterFormats.forEach(format => { |
143 characterFormats.forEach(format => { |
149 let { |
144 let { |
150 id |
145 id |
151 } = format.attributes; |
146 } = format.attributes; |
152 id = id.replace(ANNOTATION_ATTRIBUTE_PREFIX, ''); |
147 id = id.replace(ANNOTATION_ATTRIBUTE_PREFIX, ''); |
153 |
|
154 if (!positions.hasOwnProperty(id)) { |
148 if (!positions.hasOwnProperty(id)) { |
155 positions[id] = { |
149 positions[id] = { |
156 start: i |
150 start: i |
157 }; |
151 }; |
158 } // Annotations refer to positions between characters. |
152 } |
|
153 |
|
154 // Annotations refer to positions between characters. |
159 // Formats refer to the character themselves. |
155 // Formats refer to the character themselves. |
160 // So we need to adjust for that here. |
156 // So we need to adjust for that here. |
161 |
|
162 |
|
163 positions[id].end = i + 1; |
157 positions[id].end = i + 1; |
164 }); |
158 }); |
165 }); |
159 }); |
166 return positions; |
160 return positions; |
167 } |
161 } |
|
162 |
168 /** |
163 /** |
169 * Updates annotations in the state based on positions retrieved from RichText. |
164 * Updates annotations in the state based on positions retrieved from RichText. |
170 * |
165 * |
171 * @param {Array} annotations The annotations that are currently applied. |
166 * @param {Array} annotations The annotations that are currently applied. |
172 * @param {Array} positions The current positions of the given annotations. |
167 * @param {Array} positions The current positions of the given annotations. |
173 * @param {Object} actions |
168 * @param {Object} actions |
174 * @param {Function} actions.removeAnnotation Function to remove an annotation from the state. |
169 * @param {Function} actions.removeAnnotation Function to remove an annotation from the state. |
175 * @param {Function} actions.updateAnnotationRange Function to update an annotation range in the state. |
170 * @param {Function} actions.updateAnnotationRange Function to update an annotation range in the state. |
176 */ |
171 */ |
177 |
172 function updateAnnotationsWithPositions(annotations, positions, { |
178 |
173 removeAnnotation, |
179 function updateAnnotationsWithPositions(annotations, positions, _ref) { |
174 updateAnnotationRange |
180 let { |
175 }) { |
181 removeAnnotation, |
|
182 updateAnnotationRange |
|
183 } = _ref; |
|
184 annotations.forEach(currentAnnotation => { |
176 annotations.forEach(currentAnnotation => { |
185 const position = positions[currentAnnotation.id]; // If we cannot find an annotation, delete it. |
177 const position = positions[currentAnnotation.id]; |
186 |
178 // If we cannot find an annotation, delete it. |
187 if (!position) { |
179 if (!position) { |
188 // Apparently the annotation has been removed, so remove it from the state: |
180 // Apparently the annotation has been removed, so remove it from the state: |
189 // Remove... |
181 // Remove... |
190 removeAnnotation(currentAnnotation.id); |
182 removeAnnotation(currentAnnotation.id); |
191 return; |
183 return; |
192 } |
184 } |
193 |
|
194 const { |
185 const { |
195 start, |
186 start, |
196 end |
187 end |
197 } = currentAnnotation; |
188 } = currentAnnotation; |
198 |
|
199 if (start !== position.start || end !== position.end) { |
189 if (start !== position.start || end !== position.end) { |
200 updateAnnotationRange(currentAnnotation.id, position.start, position.end); |
190 updateAnnotationRange(currentAnnotation.id, position.start, position.end); |
201 } |
191 } |
202 }); |
192 }); |
203 } |
193 } |
204 |
|
205 const annotation = { |
194 const annotation = { |
206 name: FORMAT_NAME, |
195 name: FORMAT_NAME, |
207 title: (0,external_wp_i18n_namespaceObject.__)('Annotation'), |
196 title: (0,external_wp_i18n_namespaceObject.__)('Annotation'), |
208 tagName: 'mark', |
197 tagName: 'mark', |
209 className: 'annotation-text', |
198 className: 'annotation-text', |
210 attributes: { |
199 attributes: { |
211 className: 'class', |
200 className: 'class', |
212 id: 'id' |
201 id: 'id' |
213 }, |
202 }, |
214 |
|
215 edit() { |
203 edit() { |
216 return null; |
204 return null; |
217 }, |
205 }, |
218 |
206 __experimentalGetPropsForEditableTreePreparation(select, { |
219 __experimentalGetPropsForEditableTreePreparation(select, _ref2) { |
207 richTextIdentifier, |
220 let { |
208 blockClientId |
221 richTextIdentifier, |
209 }) { |
222 blockClientId |
|
223 } = _ref2; |
|
224 return { |
210 return { |
225 annotations: select(STORE_NAME).__experimentalGetAnnotationsForRichText(blockClientId, richTextIdentifier) |
211 annotations: select(STORE_NAME).__experimentalGetAnnotationsForRichText(blockClientId, richTextIdentifier) |
226 }; |
212 }; |
227 }, |
213 }, |
228 |
214 __experimentalCreatePrepareEditableTree({ |
229 __experimentalCreatePrepareEditableTree(_ref3) { |
215 annotations |
230 let { |
216 }) { |
231 annotations |
|
232 } = _ref3; |
|
233 return (formats, text) => { |
217 return (formats, text) => { |
234 if (annotations.length === 0) { |
218 if (annotations.length === 0) { |
235 return formats; |
219 return formats; |
236 } |
220 } |
237 |
|
238 let record = { |
221 let record = { |
239 formats, |
222 formats, |
240 text |
223 text |
241 }; |
224 }; |
242 record = applyAnnotations(record, annotations); |
225 record = applyAnnotations(record, annotations); |
243 return record.formats; |
226 return record.formats; |
244 }; |
227 }; |
245 }, |
228 }, |
246 |
|
247 __experimentalGetPropsForEditableTreeChangeHandler(dispatch) { |
229 __experimentalGetPropsForEditableTreeChangeHandler(dispatch) { |
248 return { |
230 return { |
249 removeAnnotation: dispatch(STORE_NAME).__experimentalRemoveAnnotation, |
231 removeAnnotation: dispatch(STORE_NAME).__experimentalRemoveAnnotation, |
250 updateAnnotationRange: dispatch(STORE_NAME).__experimentalUpdateAnnotationRange |
232 updateAnnotationRange: dispatch(STORE_NAME).__experimentalUpdateAnnotationRange |
251 }; |
233 }; |
252 }, |
234 }, |
253 |
|
254 __experimentalCreateOnChangeEditableValue(props) { |
235 __experimentalCreateOnChangeEditableValue(props) { |
255 return formats => { |
236 return formats => { |
256 const positions = retrieveAnnotationPositions(formats); |
237 const positions = retrieveAnnotationPositions(formats); |
257 const { |
238 const { |
258 removeAnnotation, |
239 removeAnnotation, |
263 removeAnnotation, |
244 removeAnnotation, |
264 updateAnnotationRange |
245 updateAnnotationRange |
265 }); |
246 }); |
266 }; |
247 }; |
267 } |
248 } |
268 |
|
269 }; |
249 }; |
270 |
250 |
271 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/format/index.js |
251 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/format/index.js |
272 /** |
252 /** |
273 * WordPress dependencies |
253 * WordPress dependencies |
274 */ |
254 */ |
275 |
255 |
|
256 |
276 /** |
257 /** |
277 * Internal dependencies |
258 * Internal dependencies |
278 */ |
259 */ |
279 |
|
280 |
260 |
281 const { |
261 const { |
282 name: format_name, |
262 name: format_name, |
283 ...settings |
263 ...settings |
284 } = annotation; |
264 } = annotation; |
285 (0,external_wp_richText_namespaceObject.registerFormatType)(format_name, settings); |
265 (0,external_wp_richText_namespaceObject.registerFormatType)(format_name, settings); |
286 |
266 |
287 ;// CONCATENATED MODULE: external ["wp","hooks"] |
267 ;// CONCATENATED MODULE: external ["wp","hooks"] |
288 var external_wp_hooks_namespaceObject = window["wp"]["hooks"]; |
268 const external_wp_hooks_namespaceObject = window["wp"]["hooks"]; |
289 ;// CONCATENATED MODULE: external ["wp","data"] |
269 ;// CONCATENATED MODULE: external ["wp","data"] |
290 var external_wp_data_namespaceObject = window["wp"]["data"]; |
270 const external_wp_data_namespaceObject = window["wp"]["data"]; |
291 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/block/index.js |
271 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/block/index.js |
292 /** |
272 /** |
293 * WordPress dependencies |
273 * WordPress dependencies |
294 */ |
274 */ |
295 |
275 |
296 |
276 |
|
277 |
297 /** |
278 /** |
298 * Internal dependencies |
279 * Internal dependencies |
299 */ |
280 */ |
300 |
|
301 |
281 |
302 /** |
282 /** |
303 * Adds annotation className to the block-list-block component. |
283 * Adds annotation className to the block-list-block component. |
304 * |
284 * |
305 * @param {Object} OriginalComponent The original BlockListBlock component. |
285 * @param {Object} OriginalComponent The original BlockListBlock component. |
306 * @return {Object} The enhanced component. |
286 * @return {Object} The enhanced component. |
307 */ |
287 */ |
308 |
|
309 const addAnnotationClassName = OriginalComponent => { |
288 const addAnnotationClassName = OriginalComponent => { |
310 return (0,external_wp_data_namespaceObject.withSelect)((select, _ref) => { |
289 return (0,external_wp_data_namespaceObject.withSelect)((select, { |
311 let { |
290 clientId, |
312 clientId, |
291 className |
313 className |
292 }) => { |
314 } = _ref; |
|
315 |
|
316 const annotations = select(STORE_NAME).__experimentalGetAnnotationsForBlock(clientId); |
293 const annotations = select(STORE_NAME).__experimentalGetAnnotationsForBlock(clientId); |
317 |
|
318 return { |
294 return { |
319 className: annotations.map(annotation => { |
295 className: annotations.map(annotation => { |
320 return 'is-annotated-by-' + annotation.source; |
296 return 'is-annotated-by-' + annotation.source; |
321 }).concat(className).filter(Boolean).join(' ') |
297 }).concat(className).filter(Boolean).join(' ') |
322 }; |
298 }; |
323 })(OriginalComponent); |
299 })(OriginalComponent); |
324 }; |
300 }; |
325 |
|
326 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/annotations', addAnnotationClassName); |
301 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/annotations', addAnnotationClassName); |
327 |
302 |
328 ;// CONCATENATED MODULE: external "lodash" |
|
329 var external_lodash_namespaceObject = window["lodash"]; |
|
330 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/reducer.js |
303 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/reducer.js |
331 /** |
|
332 * External dependencies |
|
333 */ |
|
334 |
|
335 /** |
304 /** |
336 * Filters an array based on the predicate, but keeps the reference the same if |
305 * Filters an array based on the predicate, but keeps the reference the same if |
337 * the array hasn't changed. |
306 * the array hasn't changed. |
338 * |
307 * |
339 * @param {Array} collection The collection to filter. |
308 * @param {Array} collection The collection to filter. |
340 * @param {Function} predicate Function that determines if the item should stay |
309 * @param {Function} predicate Function that determines if the item should stay |
341 * in the array. |
310 * in the array. |
342 * @return {Array} Filtered array. |
311 * @return {Array} Filtered array. |
343 */ |
312 */ |
344 |
|
345 function filterWithReference(collection, predicate) { |
313 function filterWithReference(collection, predicate) { |
346 const filteredCollection = collection.filter(predicate); |
314 const filteredCollection = collection.filter(predicate); |
347 return collection.length === filteredCollection.length ? collection : filteredCollection; |
315 return collection.length === filteredCollection.length ? collection : filteredCollection; |
348 } |
316 } |
|
317 |
|
318 /** |
|
319 * Creates a new object with the same keys, but with `callback()` called as |
|
320 * a transformer function on each of the values. |
|
321 * |
|
322 * @param {Object} obj The object to transform. |
|
323 * @param {Function} callback The function to transform each object value. |
|
324 * @return {Array} Transformed object. |
|
325 */ |
|
326 const mapValues = (obj, callback) => Object.entries(obj).reduce((acc, [key, value]) => ({ |
|
327 ...acc, |
|
328 [key]: callback(value) |
|
329 }), {}); |
|
330 |
349 /** |
331 /** |
350 * Verifies whether the given annotations is a valid annotation. |
332 * Verifies whether the given annotations is a valid annotation. |
351 * |
333 * |
352 * @param {Object} annotation The annotation to verify. |
334 * @param {Object} annotation The annotation to verify. |
353 * @return {boolean} Whether the given annotation is valid. |
335 * @return {boolean} Whether the given annotation is valid. |
354 */ |
336 */ |
355 |
|
356 |
|
357 function isValidAnnotationRange(annotation) { |
337 function isValidAnnotationRange(annotation) { |
358 return (0,external_lodash_namespaceObject.isNumber)(annotation.start) && (0,external_lodash_namespaceObject.isNumber)(annotation.end) && annotation.start <= annotation.end; |
338 return typeof annotation.start === 'number' && typeof annotation.end === 'number' && annotation.start <= annotation.end; |
359 } |
339 } |
|
340 |
360 /** |
341 /** |
361 * Reducer managing annotations. |
342 * Reducer managing annotations. |
362 * |
343 * |
363 * @param {Object} state The annotations currently shown in the editor. |
344 * @param {Object} state The annotations currently shown in the editor. |
364 * @param {Object} action Dispatched action. |
345 * @param {Object} action Dispatched action. |
365 * |
346 * |
366 * @return {Array} Updated state. |
347 * @return {Array} Updated state. |
367 */ |
348 */ |
368 |
349 function annotations(state = {}, action) { |
369 |
|
370 function annotations() { |
|
371 var _state$blockClientId; |
350 var _state$blockClientId; |
372 |
|
373 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
374 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
375 |
|
376 switch (action.type) { |
351 switch (action.type) { |
377 case 'ANNOTATION_ADD': |
352 case 'ANNOTATION_ADD': |
378 const blockClientId = action.blockClientId; |
353 const blockClientId = action.blockClientId; |
379 const newAnnotation = { |
354 const newAnnotation = { |
380 id: action.id, |
355 id: action.id, |
382 richTextIdentifier: action.richTextIdentifier, |
357 richTextIdentifier: action.richTextIdentifier, |
383 source: action.source, |
358 source: action.source, |
384 selector: action.selector, |
359 selector: action.selector, |
385 range: action.range |
360 range: action.range |
386 }; |
361 }; |
387 |
|
388 if (newAnnotation.selector === 'range' && !isValidAnnotationRange(newAnnotation.range)) { |
362 if (newAnnotation.selector === 'range' && !isValidAnnotationRange(newAnnotation.range)) { |
389 return state; |
363 return state; |
390 } |
364 } |
391 |
365 const previousAnnotationsForBlock = (_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []; |
392 const previousAnnotationsForBlock = (_state$blockClientId = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []; |
366 return { |
393 return { ...state, |
367 ...state, |
394 [blockClientId]: [...previousAnnotationsForBlock, newAnnotation] |
368 [blockClientId]: [...previousAnnotationsForBlock, newAnnotation] |
395 }; |
369 }; |
396 |
|
397 case 'ANNOTATION_REMOVE': |
370 case 'ANNOTATION_REMOVE': |
398 return (0,external_lodash_namespaceObject.mapValues)(state, annotationsForBlock => { |
371 return mapValues(state, annotationsForBlock => { |
399 return filterWithReference(annotationsForBlock, annotation => { |
372 return filterWithReference(annotationsForBlock, annotation => { |
400 return annotation.id !== action.annotationId; |
373 return annotation.id !== action.annotationId; |
401 }); |
374 }); |
402 }); |
375 }); |
403 |
|
404 case 'ANNOTATION_UPDATE_RANGE': |
376 case 'ANNOTATION_UPDATE_RANGE': |
405 return (0,external_lodash_namespaceObject.mapValues)(state, annotationsForBlock => { |
377 return mapValues(state, annotationsForBlock => { |
406 let hasChangedRange = false; |
378 let hasChangedRange = false; |
407 const newAnnotations = annotationsForBlock.map(annotation => { |
379 const newAnnotations = annotationsForBlock.map(annotation => { |
408 if (annotation.id === action.annotationId) { |
380 if (annotation.id === action.annotationId) { |
409 hasChangedRange = true; |
381 hasChangedRange = true; |
410 return { ...annotation, |
382 return { |
|
383 ...annotation, |
411 range: { |
384 range: { |
412 start: action.start, |
385 start: action.start, |
413 end: action.end |
386 end: action.end |
414 } |
387 } |
415 }; |
388 }; |
416 } |
389 } |
417 |
|
418 return annotation; |
390 return annotation; |
419 }); |
391 }); |
420 return hasChangedRange ? newAnnotations : annotationsForBlock; |
392 return hasChangedRange ? newAnnotations : annotationsForBlock; |
421 }); |
393 }); |
422 |
|
423 case 'ANNOTATION_REMOVE_SOURCE': |
394 case 'ANNOTATION_REMOVE_SOURCE': |
424 return (0,external_lodash_namespaceObject.mapValues)(state, annotationsForBlock => { |
395 return mapValues(state, annotationsForBlock => { |
425 return filterWithReference(annotationsForBlock, annotation => { |
396 return filterWithReference(annotationsForBlock, annotation => { |
426 return annotation.source !== action.source; |
397 return annotation.source !== action.source; |
427 }); |
398 }); |
428 }); |
399 }); |
429 } |
400 } |
430 |
|
431 return state; |
401 return state; |
432 } |
402 } |
433 /* harmony default export */ var reducer = (annotations); |
403 /* harmony default export */ const reducer = (annotations); |
434 |
|
435 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js |
|
436 |
|
437 |
|
438 var LEAF_KEY, hasWeakMap; |
|
439 |
|
440 /** |
|
441 * Arbitrary value used as key for referencing cache object in WeakMap tree. |
|
442 * |
|
443 * @type {Object} |
|
444 */ |
|
445 LEAF_KEY = {}; |
|
446 |
|
447 /** |
|
448 * Whether environment supports WeakMap. |
|
449 * |
|
450 * @type {boolean} |
|
451 */ |
|
452 hasWeakMap = typeof WeakMap !== 'undefined'; |
|
453 |
|
454 /** |
|
455 * Returns the first argument as the sole entry in an array. |
|
456 * |
|
457 * @param {*} value Value to return. |
|
458 * |
|
459 * @return {Array} Value returned as entry in array. |
|
460 */ |
|
461 function arrayOf( value ) { |
|
462 return [ value ]; |
|
463 } |
|
464 |
|
465 /** |
|
466 * Returns true if the value passed is object-like, or false otherwise. A value |
|
467 * is object-like if it can support property assignment, e.g. object or array. |
|
468 * |
|
469 * @param {*} value Value to test. |
|
470 * |
|
471 * @return {boolean} Whether value is object-like. |
|
472 */ |
|
473 function isObjectLike( value ) { |
|
474 return !! value && 'object' === typeof value; |
|
475 } |
|
476 |
|
477 /** |
|
478 * Creates and returns a new cache object. |
|
479 * |
|
480 * @return {Object} Cache object. |
|
481 */ |
|
482 function createCache() { |
|
483 var cache = { |
|
484 clear: function() { |
|
485 cache.head = null; |
|
486 }, |
|
487 }; |
|
488 |
|
489 return cache; |
|
490 } |
|
491 |
|
492 /** |
|
493 * Returns true if entries within the two arrays are strictly equal by |
|
494 * reference from a starting index. |
|
495 * |
|
496 * @param {Array} a First array. |
|
497 * @param {Array} b Second array. |
|
498 * @param {number} fromIndex Index from which to start comparison. |
|
499 * |
|
500 * @return {boolean} Whether arrays are shallowly equal. |
|
501 */ |
|
502 function isShallowEqual( a, b, fromIndex ) { |
|
503 var i; |
|
504 |
|
505 if ( a.length !== b.length ) { |
|
506 return false; |
|
507 } |
|
508 |
|
509 for ( i = fromIndex; i < a.length; i++ ) { |
|
510 if ( a[ i ] !== b[ i ] ) { |
|
511 return false; |
|
512 } |
|
513 } |
|
514 |
|
515 return true; |
|
516 } |
|
517 |
|
518 /** |
|
519 * Returns a memoized selector function. The getDependants function argument is |
|
520 * called before the memoized selector and is expected to return an immutable |
|
521 * reference or array of references on which the selector depends for computing |
|
522 * its own return value. The memoize cache is preserved only as long as those |
|
523 * dependant references remain the same. If getDependants returns a different |
|
524 * reference(s), the cache is cleared and the selector value regenerated. |
|
525 * |
|
526 * @param {Function} selector Selector function. |
|
527 * @param {Function} getDependants Dependant getter returning an immutable |
|
528 * reference or array of reference used in |
|
529 * cache bust consideration. |
|
530 * |
|
531 * @return {Function} Memoized selector. |
|
532 */ |
|
533 /* harmony default export */ function rememo(selector, getDependants ) { |
|
534 var rootCache, getCache; |
|
535 |
|
536 // Use object source as dependant if getter not provided |
|
537 if ( ! getDependants ) { |
|
538 getDependants = arrayOf; |
|
539 } |
|
540 |
|
541 /** |
|
542 * Returns the root cache. If WeakMap is supported, this is assigned to the |
|
543 * root WeakMap cache set, otherwise it is a shared instance of the default |
|
544 * cache object. |
|
545 * |
|
546 * @return {(WeakMap|Object)} Root cache object. |
|
547 */ |
|
548 function getRootCache() { |
|
549 return rootCache; |
|
550 } |
|
551 |
|
552 /** |
|
553 * Returns the cache for a given dependants array. When possible, a WeakMap |
|
554 * will be used to create a unique cache for each set of dependants. This |
|
555 * is feasible due to the nature of WeakMap in allowing garbage collection |
|
556 * to occur on entries where the key object is no longer referenced. Since |
|
557 * WeakMap requires the key to be an object, this is only possible when the |
|
558 * dependant is object-like. The root cache is created as a hierarchy where |
|
559 * each top-level key is the first entry in a dependants set, the value a |
|
560 * WeakMap where each key is the next dependant, and so on. This continues |
|
561 * so long as the dependants are object-like. If no dependants are object- |
|
562 * like, then the cache is shared across all invocations. |
|
563 * |
|
564 * @see isObjectLike |
|
565 * |
|
566 * @param {Array} dependants Selector dependants. |
|
567 * |
|
568 * @return {Object} Cache object. |
|
569 */ |
|
570 function getWeakMapCache( dependants ) { |
|
571 var caches = rootCache, |
|
572 isUniqueByDependants = true, |
|
573 i, dependant, map, cache; |
|
574 |
|
575 for ( i = 0; i < dependants.length; i++ ) { |
|
576 dependant = dependants[ i ]; |
|
577 |
|
578 // Can only compose WeakMap from object-like key. |
|
579 if ( ! isObjectLike( dependant ) ) { |
|
580 isUniqueByDependants = false; |
|
581 break; |
|
582 } |
|
583 |
|
584 // Does current segment of cache already have a WeakMap? |
|
585 if ( caches.has( dependant ) ) { |
|
586 // Traverse into nested WeakMap. |
|
587 caches = caches.get( dependant ); |
|
588 } else { |
|
589 // Create, set, and traverse into a new one. |
|
590 map = new WeakMap(); |
|
591 caches.set( dependant, map ); |
|
592 caches = map; |
|
593 } |
|
594 } |
|
595 |
|
596 // We use an arbitrary (but consistent) object as key for the last item |
|
597 // in the WeakMap to serve as our running cache. |
|
598 if ( ! caches.has( LEAF_KEY ) ) { |
|
599 cache = createCache(); |
|
600 cache.isUniqueByDependants = isUniqueByDependants; |
|
601 caches.set( LEAF_KEY, cache ); |
|
602 } |
|
603 |
|
604 return caches.get( LEAF_KEY ); |
|
605 } |
|
606 |
|
607 // Assign cache handler by availability of WeakMap |
|
608 getCache = hasWeakMap ? getWeakMapCache : getRootCache; |
|
609 |
|
610 /** |
|
611 * Resets root memoization cache. |
|
612 */ |
|
613 function clear() { |
|
614 rootCache = hasWeakMap ? new WeakMap() : createCache(); |
|
615 } |
|
616 |
|
617 // eslint-disable-next-line jsdoc/check-param-names |
|
618 /** |
|
619 * The augmented selector call, considering first whether dependants have |
|
620 * changed before passing it to underlying memoize function. |
|
621 * |
|
622 * @param {Object} source Source object for derivation. |
|
623 * @param {...*} extraArgs Additional arguments to pass to selector. |
|
624 * |
|
625 * @return {*} Selector result. |
|
626 */ |
|
627 function callSelector( /* source, ...extraArgs */ ) { |
|
628 var len = arguments.length, |
|
629 cache, node, i, args, dependants; |
|
630 |
|
631 // Create copy of arguments (avoid leaking deoptimization). |
|
632 args = new Array( len ); |
|
633 for ( i = 0; i < len; i++ ) { |
|
634 args[ i ] = arguments[ i ]; |
|
635 } |
|
636 |
|
637 dependants = getDependants.apply( null, args ); |
|
638 cache = getCache( dependants ); |
|
639 |
|
640 // If not guaranteed uniqueness by dependants (primitive type or lack |
|
641 // of WeakMap support), shallow compare against last dependants and, if |
|
642 // references have changed, destroy cache to recalculate result. |
|
643 if ( ! cache.isUniqueByDependants ) { |
|
644 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { |
|
645 cache.clear(); |
|
646 } |
|
647 |
|
648 cache.lastDependants = dependants; |
|
649 } |
|
650 |
|
651 node = cache.head; |
|
652 while ( node ) { |
|
653 // Check whether node arguments match arguments |
|
654 if ( ! isShallowEqual( node.args, args, 1 ) ) { |
|
655 node = node.next; |
|
656 continue; |
|
657 } |
|
658 |
|
659 // At this point we can assume we've found a match |
|
660 |
|
661 // Surface matched node to head if not already |
|
662 if ( node !== cache.head ) { |
|
663 // Adjust siblings to point to each other. |
|
664 node.prev.next = node.next; |
|
665 if ( node.next ) { |
|
666 node.next.prev = node.prev; |
|
667 } |
|
668 |
|
669 node.next = cache.head; |
|
670 node.prev = null; |
|
671 cache.head.prev = node; |
|
672 cache.head = node; |
|
673 } |
|
674 |
|
675 // Return immediately |
|
676 return node.val; |
|
677 } |
|
678 |
|
679 // No cached value found. Continue to insertion phase: |
|
680 |
|
681 node = { |
|
682 // Generate the result from original function |
|
683 val: selector.apply( null, args ), |
|
684 }; |
|
685 |
|
686 // Avoid including the source object in the cache. |
|
687 args[ 0 ] = null; |
|
688 node.args = args; |
|
689 |
|
690 // Don't need to check whether node is already head, since it would |
|
691 // have been returned above already if it was |
|
692 |
|
693 // Shift existing head down list |
|
694 if ( cache.head ) { |
|
695 cache.head.prev = node; |
|
696 node.next = cache.head; |
|
697 } |
|
698 |
|
699 cache.head = node; |
|
700 |
|
701 return node.val; |
|
702 } |
|
703 |
|
704 callSelector.getDependants = getDependants; |
|
705 callSelector.clear = clear; |
|
706 clear(); |
|
707 |
|
708 return callSelector; |
|
709 } |
|
710 |
404 |
711 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/selectors.js |
405 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/selectors.js |
712 /** |
406 /** |
713 * External dependencies |
407 * WordPress dependencies |
714 */ |
408 */ |
715 |
409 |
716 |
410 |
717 /** |
411 /** |
718 * Shared reference to an empty array for cases where it is important to avoid |
412 * Shared reference to an empty array for cases where it is important to avoid |
721 * This should be used as a last resort, since the normalized data should be |
415 * This should be used as a last resort, since the normalized data should be |
722 * maintained by the reducer result in state. |
416 * maintained by the reducer result in state. |
723 * |
417 * |
724 * @type {Array} |
418 * @type {Array} |
725 */ |
419 */ |
726 |
|
727 const EMPTY_ARRAY = []; |
420 const EMPTY_ARRAY = []; |
|
421 |
728 /** |
422 /** |
729 * Returns the annotations for a specific client ID. |
423 * Returns the annotations for a specific client ID. |
730 * |
424 * |
731 * @param {Object} state Editor state. |
425 * @param {Object} state Editor state. |
732 * @param {string} clientId The ID of the block to get the annotations for. |
426 * @param {string} clientId The ID of the block to get the annotations for. |
733 * |
427 * |
734 * @return {Array} The annotations applicable to this block. |
428 * @return {Array} The annotations applicable to this block. |
735 */ |
429 */ |
736 |
430 const __experimentalGetAnnotationsForBlock = (0,external_wp_data_namespaceObject.createSelector)((state, blockClientId) => { |
737 const __experimentalGetAnnotationsForBlock = rememo((state, blockClientId) => { |
|
738 var _state$blockClientId; |
431 var _state$blockClientId; |
739 |
432 return ((_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => { |
740 return ((_state$blockClientId = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => { |
|
741 return annotation.selector === 'block'; |
433 return annotation.selector === 'block'; |
742 }); |
434 }); |
743 }, (state, blockClientId) => { |
435 }, (state, blockClientId) => { |
744 var _state$blockClientId2; |
436 var _state$blockClientId2; |
745 |
437 return [(_state$blockClientId2 = state?.[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY]; |
746 return [(_state$blockClientId2 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY]; |
|
747 }); |
438 }); |
748 function __experimentalGetAllAnnotationsForBlock(state, blockClientId) { |
439 function __experimentalGetAllAnnotationsForBlock(state, blockClientId) { |
749 var _state$blockClientId3; |
440 var _state$blockClientId3; |
750 |
441 return (_state$blockClientId3 = state?.[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY; |
751 return (_state$blockClientId3 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY; |
442 } |
752 } |
443 |
753 /** |
444 /** |
754 * Returns the annotations that apply to the given RichText instance. |
445 * Returns the annotations that apply to the given RichText instance. |
755 * |
446 * |
756 * Both a blockClientId and a richTextIdentifier are required. This is because |
447 * Both a blockClientId and a richTextIdentifier are required. This is because |
757 * a block might have multiple `RichText` components. This does mean that every |
448 * a block might have multiple `RichText` components. This does mean that every |
760 * @param {Object} state Editor state. |
451 * @param {Object} state Editor state. |
761 * @param {string} blockClientId The client ID for the block. |
452 * @param {string} blockClientId The client ID for the block. |
762 * @param {string} richTextIdentifier Unique identifier that identifies the given RichText. |
453 * @param {string} richTextIdentifier Unique identifier that identifies the given RichText. |
763 * @return {Array} All the annotations relevant for the `RichText`. |
454 * @return {Array} All the annotations relevant for the `RichText`. |
764 */ |
455 */ |
765 |
456 const __experimentalGetAnnotationsForRichText = (0,external_wp_data_namespaceObject.createSelector)((state, blockClientId, richTextIdentifier) => { |
766 const __experimentalGetAnnotationsForRichText = rememo((state, blockClientId, richTextIdentifier) => { |
|
767 var _state$blockClientId4; |
457 var _state$blockClientId4; |
768 |
458 return ((_state$blockClientId4 = state?.[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => { |
769 return ((_state$blockClientId4 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => { |
|
770 return annotation.selector === 'range' && richTextIdentifier === annotation.richTextIdentifier; |
459 return annotation.selector === 'range' && richTextIdentifier === annotation.richTextIdentifier; |
771 }).map(annotation => { |
460 }).map(annotation => { |
772 const { |
461 const { |
773 range, |
462 range, |
774 ...other |
463 ...other |
775 } = annotation; |
464 } = annotation; |
776 return { ...range, |
465 return { |
|
466 ...range, |
777 ...other |
467 ...other |
778 }; |
468 }; |
779 }); |
469 }); |
780 }, (state, blockClientId) => { |
470 }, (state, blockClientId) => { |
781 var _state$blockClientId5; |
471 var _state$blockClientId5; |
782 |
472 return [(_state$blockClientId5 = state?.[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY]; |
783 return [(_state$blockClientId5 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY]; |
|
784 }); |
473 }); |
|
474 |
785 /** |
475 /** |
786 * Returns all annotations in the editor state. |
476 * Returns all annotations in the editor state. |
787 * |
477 * |
788 * @param {Object} state Editor state. |
478 * @param {Object} state Editor state. |
789 * @return {Array} All annotations currently applied. |
479 * @return {Array} All annotations currently applied. |
790 */ |
480 */ |
791 |
|
792 function __experimentalGetAnnotations(state) { |
481 function __experimentalGetAnnotations(state) { |
793 return (0,external_lodash_namespaceObject.flatMap)(state, annotations => { |
482 return Object.values(state).flat(); |
794 return annotations; |
483 } |
795 }); |
484 |
796 } |
485 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/native.js |
797 |
486 const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto); |
|
487 /* harmony default export */ const esm_browser_native = ({ |
|
488 randomUUID |
|
489 }); |
798 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js |
490 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js |
799 // Unique ID creation requires a high quality random # generator. In the browser we therefore |
491 // Unique ID creation requires a high quality random # generator. In the browser we therefore |
800 // require the crypto API and do not support built-in fallback to lower quality random number |
492 // require the crypto API and do not support built-in fallback to lower quality random number |
801 // generators (like Math.random()). |
493 // generators (like Math.random()). |
802 var getRandomValues; |
494 let getRandomValues; |
803 var rnds8 = new Uint8Array(16); |
495 const rnds8 = new Uint8Array(16); |
804 function rng() { |
496 function rng() { |
805 // lazy load so that environments that need to polyfill have a chance to do so |
497 // lazy load so that environments that need to polyfill have a chance to do so |
806 if (!getRandomValues) { |
498 if (!getRandomValues) { |
807 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, |
499 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. |
808 // find the complete implementation of crypto (msCrypto) on IE11. |
500 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto); |
809 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto); |
|
810 |
501 |
811 if (!getRandomValues) { |
502 if (!getRandomValues) { |
812 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); |
503 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); |
813 } |
504 } |
814 } |
505 } |
815 |
506 |
816 return getRandomValues(rnds8); |
507 return getRandomValues(rnds8); |
817 } |
508 } |
818 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js |
|
819 /* harmony default export */ var regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i); |
|
820 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js |
|
821 |
|
822 |
|
823 function validate(uuid) { |
|
824 return typeof uuid === 'string' && regex.test(uuid); |
|
825 } |
|
826 |
|
827 /* harmony default export */ var esm_browser_validate = (validate); |
|
828 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js |
509 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js |
829 |
510 |
830 /** |
511 /** |
831 * Convert array of 16 byte values to UUID string format of the form: |
512 * Convert array of 16 byte values to UUID string format of the form: |
832 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
513 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
833 */ |
514 */ |
834 |
515 |
835 var byteToHex = []; |
516 const byteToHex = []; |
836 |
517 |
837 for (var i = 0; i < 256; ++i) { |
518 for (let i = 0; i < 256; ++i) { |
838 byteToHex.push((i + 0x100).toString(16).substr(1)); |
519 byteToHex.push((i + 0x100).toString(16).slice(1)); |
839 } |
520 } |
840 |
521 |
841 function stringify(arr) { |
522 function unsafeStringify(arr, offset = 0) { |
842 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; |
|
843 // Note: Be careful editing this code! It's been tuned for performance |
523 // Note: Be careful editing this code! It's been tuned for performance |
844 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 |
524 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 |
845 var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one |
525 return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]; |
|
526 } |
|
527 |
|
528 function stringify(arr, offset = 0) { |
|
529 const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one |
846 // of the following: |
530 // of the following: |
847 // - One or more input array values don't map to a hex octet (leading to |
531 // - One or more input array values don't map to a hex octet (leading to |
848 // "undefined" in the uuid) |
532 // "undefined" in the uuid) |
849 // - Invalid input values for the RFC `version` or `variant` fields |
533 // - Invalid input values for the RFC `version` or `variant` fields |
850 |
534 |
851 if (!esm_browser_validate(uuid)) { |
535 if (!validate(uuid)) { |
852 throw TypeError('Stringified UUID is invalid'); |
536 throw TypeError('Stringified UUID is invalid'); |
853 } |
537 } |
854 |
538 |
855 return uuid; |
539 return uuid; |
856 } |
540 } |
857 |
541 |
858 /* harmony default export */ var esm_browser_stringify = (stringify); |
542 /* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify))); |
859 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js |
543 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js |
860 |
544 |
861 |
545 |
862 |
546 |
|
547 |
863 function v4(options, buf, offset) { |
548 function v4(options, buf, offset) { |
|
549 if (esm_browser_native.randomUUID && !buf && !options) { |
|
550 return esm_browser_native.randomUUID(); |
|
551 } |
|
552 |
864 options = options || {}; |
553 options = options || {}; |
865 var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` |
554 const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` |
866 |
555 |
867 rnds[6] = rnds[6] & 0x0f | 0x40; |
556 rnds[6] = rnds[6] & 0x0f | 0x40; |
868 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided |
557 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided |
869 |
558 |
870 if (buf) { |
559 if (buf) { |
871 offset = offset || 0; |
560 offset = offset || 0; |
872 |
561 |
873 for (var i = 0; i < 16; ++i) { |
562 for (let i = 0; i < 16; ++i) { |
874 buf[offset + i] = rnds[i]; |
563 buf[offset + i] = rnds[i]; |
875 } |
564 } |
876 |
565 |
877 return buf; |
566 return buf; |
878 } |
567 } |
879 |
568 |
880 return esm_browser_stringify(rnds); |
569 return unsafeStringify(rnds); |
881 } |
570 } |
882 |
571 |
883 /* harmony default export */ var esm_browser_v4 = (v4); |
572 /* harmony default export */ const esm_browser_v4 = (v4); |
884 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/actions.js |
573 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/actions.js |
885 /** |
574 /** |
886 * External dependencies |
575 * External dependencies |
887 */ |
576 */ |
|
577 |
888 |
578 |
889 /** |
579 /** |
890 * @typedef WPAnnotationRange |
580 * @typedef WPAnnotationRange |
891 * |
581 * |
892 * @property {number} start The offset where the annotation should start. |
582 * @property {number} start The offset where the annotation should start. |
911 * @param {string} [annotation.source="default"] The source that added the annotation. |
601 * @param {string} [annotation.source="default"] The source that added the annotation. |
912 * @param {string} [annotation.id] The ID the annotation should have. Generates a UUID by default. |
602 * @param {string} [annotation.id] The ID the annotation should have. Generates a UUID by default. |
913 * |
603 * |
914 * @return {Object} Action object. |
604 * @return {Object} Action object. |
915 */ |
605 */ |
916 |
606 function __experimentalAddAnnotation({ |
917 function __experimentalAddAnnotation(_ref) { |
607 blockClientId, |
918 let { |
608 richTextIdentifier = null, |
919 blockClientId, |
609 range = null, |
920 richTextIdentifier = null, |
610 selector = 'range', |
921 range = null, |
611 source = 'default', |
922 selector = 'range', |
612 id = esm_browser_v4() |
923 source = 'default', |
613 }) { |
924 id = esm_browser_v4() |
|
925 } = _ref; |
|
926 const action = { |
614 const action = { |
927 type: 'ANNOTATION_ADD', |
615 type: 'ANNOTATION_ADD', |
928 id, |
616 id, |
929 blockClientId, |
617 blockClientId, |
930 richTextIdentifier, |
618 richTextIdentifier, |
931 source, |
619 source, |
932 selector |
620 selector |
933 }; |
621 }; |
934 |
|
935 if (selector === 'range') { |
622 if (selector === 'range') { |
936 action.range = range; |
623 action.range = range; |
937 } |
624 } |
938 |
|
939 return action; |
625 return action; |
940 } |
626 } |
|
627 |
941 /** |
628 /** |
942 * Removes an annotation with a specific ID. |
629 * Removes an annotation with a specific ID. |
943 * |
630 * |
944 * @param {string} annotationId The annotation to remove. |
631 * @param {string} annotationId The annotation to remove. |
945 * |
632 * |
946 * @return {Object} Action object. |
633 * @return {Object} Action object. |
947 */ |
634 */ |
948 |
|
949 function __experimentalRemoveAnnotation(annotationId) { |
635 function __experimentalRemoveAnnotation(annotationId) { |
950 return { |
636 return { |
951 type: 'ANNOTATION_REMOVE', |
637 type: 'ANNOTATION_REMOVE', |
952 annotationId |
638 annotationId |
953 }; |
639 }; |
954 } |
640 } |
|
641 |
955 /** |
642 /** |
956 * Updates the range of an annotation. |
643 * Updates the range of an annotation. |
957 * |
644 * |
958 * @param {string} annotationId ID of the annotation to update. |
645 * @param {string} annotationId ID of the annotation to update. |
959 * @param {number} start The start of the new range. |
646 * @param {number} start The start of the new range. |
960 * @param {number} end The end of the new range. |
647 * @param {number} end The end of the new range. |
961 * |
648 * |
962 * @return {Object} Action object. |
649 * @return {Object} Action object. |
963 */ |
650 */ |
964 |
|
965 function __experimentalUpdateAnnotationRange(annotationId, start, end) { |
651 function __experimentalUpdateAnnotationRange(annotationId, start, end) { |
966 return { |
652 return { |
967 type: 'ANNOTATION_UPDATE_RANGE', |
653 type: 'ANNOTATION_UPDATE_RANGE', |
968 annotationId, |
654 annotationId, |
969 start, |
655 start, |
970 end |
656 end |
971 }; |
657 }; |
972 } |
658 } |
|
659 |
973 /** |
660 /** |
974 * Removes all annotations of a specific source. |
661 * Removes all annotations of a specific source. |
975 * |
662 * |
976 * @param {string} source The source to remove. |
663 * @param {string} source The source to remove. |
977 * |
664 * |
978 * @return {Object} Action object. |
665 * @return {Object} Action object. |
979 */ |
666 */ |
980 |
|
981 function __experimentalRemoveAnnotationsBySource(source) { |
667 function __experimentalRemoveAnnotationsBySource(source) { |
982 return { |
668 return { |
983 type: 'ANNOTATION_REMOVE_SOURCE', |
669 type: 'ANNOTATION_REMOVE_SOURCE', |
984 source |
670 source |
985 }; |
671 }; |