author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1 |
/******/ (() => { // webpackBootstrap |
19 | 2 |
/******/ "use strict"; |
3 |
/******/ // The require scope |
|
4 |
/******/ var __webpack_require__ = {}; |
|
5 |
/******/ |
|
6 |
/************************************************************************/ |
|
7 |
/******/ /* webpack/runtime/define property getters */ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
8 |
/******/ (() => { |
19 | 9 |
/******/ // define getter functions for harmony exports |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
10 |
/******/ __webpack_require__.d = (exports, definition) => { |
19 | 11 |
/******/ for(var key in definition) { |
12 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
|
13 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
|
14 |
/******/ } |
|
15 |
/******/ } |
|
9 | 16 |
/******/ }; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
17 |
/******/ })(); |
19 | 18 |
/******/ |
19 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
20 |
/******/ (() => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
21 |
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
22 |
/******/ })(); |
19 | 23 |
/******/ |
24 |
/******/ /* webpack/runtime/make namespace object */ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
25 |
/******/ (() => { |
19 | 26 |
/******/ // define __esModule on exports |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
27 |
/******/ __webpack_require__.r = (exports) => { |
19 | 28 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
29 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
30 |
/******/ } |
|
31 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
32 |
/******/ }; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
33 |
/******/ })(); |
19 | 34 |
/******/ |
9 | 35 |
/************************************************************************/ |
19 | 36 |
var __webpack_exports__ = {}; |
18 | 37 |
// ESM COMPAT FLAG |
38 |
__webpack_require__.r(__webpack_exports__); |
|
39 |
||
40 |
// EXPORTS |
|
19 | 41 |
__webpack_require__.d(__webpack_exports__, { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
42 |
store: () => (/* reexport */ store) |
19 | 43 |
}); |
18 | 44 |
|
45 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/selectors.js |
|
46 |
var selectors_namespaceObject = {}; |
|
47 |
__webpack_require__.r(selectors_namespaceObject); |
|
19 | 48 |
__webpack_require__.d(selectors_namespaceObject, { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
49 |
__experimentalGetAllAnnotationsForBlock: () => (__experimentalGetAllAnnotationsForBlock), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
50 |
__experimentalGetAnnotations: () => (__experimentalGetAnnotations), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
51 |
__experimentalGetAnnotationsForBlock: () => (__experimentalGetAnnotationsForBlock), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
52 |
__experimentalGetAnnotationsForRichText: () => (__experimentalGetAnnotationsForRichText) |
19 | 53 |
}); |
18 | 54 |
|
55 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/actions.js |
|
56 |
var actions_namespaceObject = {}; |
|
57 |
__webpack_require__.r(actions_namespaceObject); |
|
19 | 58 |
__webpack_require__.d(actions_namespaceObject, { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
59 |
__experimentalAddAnnotation: () => (__experimentalAddAnnotation), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
60 |
__experimentalRemoveAnnotation: () => (__experimentalRemoveAnnotation), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
61 |
__experimentalRemoveAnnotationsBySource: () => (__experimentalRemoveAnnotationsBySource), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
62 |
__experimentalUpdateAnnotationRange: () => (__experimentalUpdateAnnotationRange) |
19 | 63 |
}); |
18 | 64 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
65 |
;// external ["wp","richText"] |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
66 |
const external_wp_richText_namespaceObject = window["wp"]["richText"]; |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
67 |
;// external ["wp","i18n"] |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
68 |
const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
69 |
;// ./node_modules/@wordpress/annotations/build-module/store/constants.js |
18 | 70 |
/** |
71 |
* The identifier for the data store. |
|
72 |
* |
|
73 |
* @type {string} |
|
74 |
*/ |
|
75 |
const STORE_NAME = 'core/annotations'; |
|
9 | 76 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
77 |
;// ./node_modules/@wordpress/annotations/build-module/format/annotation.js |
18 | 78 |
/** |
79 |
* WordPress dependencies |
|
80 |
*/ |
|
81 |
||
82 |
||
83 |
const FORMAT_NAME = 'core/annotation'; |
|
84 |
const ANNOTATION_ATTRIBUTE_PREFIX = 'annotation-text-'; |
|
85 |
/** |
|
86 |
* Internal dependencies |
|
87 |
*/ |
|
88 |
||
89 |
||
90 |
/** |
|
91 |
* Applies given annotations to the given record. |
|
92 |
* |
|
19 | 93 |
* @param {Object} record The record to apply annotations to. |
94 |
* @param {Array} annotations The annotation to apply. |
|
18 | 95 |
* @return {Object} A record with the annotations applied. |
96 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
97 |
function applyAnnotations(record, annotations = []) { |
18 | 98 |
annotations.forEach(annotation => { |
99 |
let { |
|
100 |
start, |
|
101 |
end |
|
102 |
} = annotation; |
|
103 |
if (start > record.text.length) { |
|
104 |
start = record.text.length; |
|
105 |
} |
|
106 |
if (end > record.text.length) { |
|
107 |
end = record.text.length; |
|
108 |
} |
|
109 |
const className = ANNOTATION_ATTRIBUTE_PREFIX + annotation.source; |
|
110 |
const id = ANNOTATION_ATTRIBUTE_PREFIX + annotation.id; |
|
19 | 111 |
record = (0,external_wp_richText_namespaceObject.applyFormat)(record, { |
18 | 112 |
type: FORMAT_NAME, |
113 |
attributes: { |
|
114 |
className, |
|
115 |
id |
|
116 |
} |
|
117 |
}, start, end); |
|
118 |
}); |
|
119 |
return record; |
|
120 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
121 |
|
18 | 122 |
/** |
123 |
* Removes annotations from the given record. |
|
124 |
* |
|
125 |
* @param {Object} record Record to remove annotations from. |
|
126 |
* @return {Object} The cleaned record. |
|
127 |
*/ |
|
128 |
function removeAnnotations(record) { |
|
19 | 129 |
return removeFormat(record, 'core/annotation', 0, record.text.length); |
18 | 130 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
131 |
|
18 | 132 |
/** |
133 |
* Retrieves the positions of annotations inside an array of formats. |
|
134 |
* |
|
135 |
* @param {Array} formats Formats with annotations in there. |
|
136 |
* @return {Object} ID keyed positions of annotations. |
|
137 |
*/ |
|
138 |
function retrieveAnnotationPositions(formats) { |
|
139 |
const positions = {}; |
|
140 |
formats.forEach((characterFormats, i) => { |
|
141 |
characterFormats = characterFormats || []; |
|
142 |
characterFormats = characterFormats.filter(format => format.type === FORMAT_NAME); |
|
143 |
characterFormats.forEach(format => { |
|
144 |
let { |
|
145 |
id |
|
146 |
} = format.attributes; |
|
147 |
id = id.replace(ANNOTATION_ATTRIBUTE_PREFIX, ''); |
|
148 |
if (!positions.hasOwnProperty(id)) { |
|
149 |
positions[id] = { |
|
150 |
start: i |
|
151 |
}; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
152 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
153 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
154 |
// Annotations refer to positions between characters. |
18 | 155 |
// Formats refer to the character themselves. |
156 |
// So we need to adjust for that here. |
|
157 |
positions[id].end = i + 1; |
|
158 |
}); |
|
159 |
}); |
|
160 |
return positions; |
|
161 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
162 |
|
18 | 163 |
/** |
164 |
* Updates annotations in the state based on positions retrieved from RichText. |
|
165 |
* |
|
166 |
* @param {Array} annotations The annotations that are currently applied. |
|
167 |
* @param {Array} positions The current positions of the given annotations. |
|
168 |
* @param {Object} actions |
|
169 |
* @param {Function} actions.removeAnnotation Function to remove an annotation from the state. |
|
170 |
* @param {Function} actions.updateAnnotationRange Function to update an annotation range in the state. |
|
171 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
172 |
function updateAnnotationsWithPositions(annotations, positions, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
173 |
removeAnnotation, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
174 |
updateAnnotationRange |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
175 |
}) { |
18 | 176 |
annotations.forEach(currentAnnotation => { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
177 |
const position = positions[currentAnnotation.id]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
178 |
// If we cannot find an annotation, delete it. |
18 | 179 |
if (!position) { |
180 |
// Apparently the annotation has been removed, so remove it from the state: |
|
181 |
// Remove... |
|
182 |
removeAnnotation(currentAnnotation.id); |
|
183 |
return; |
|
9 | 184 |
} |
18 | 185 |
const { |
186 |
start, |
|
187 |
end |
|
188 |
} = currentAnnotation; |
|
189 |
if (start !== position.start || end !== position.end) { |
|
190 |
updateAnnotationRange(currentAnnotation.id, position.start, position.end); |
|
191 |
} |
|
192 |
}); |
|
9 | 193 |
} |
19 | 194 |
const annotation = { |
18 | 195 |
name: FORMAT_NAME, |
19 | 196 |
title: (0,external_wp_i18n_namespaceObject.__)('Annotation'), |
18 | 197 |
tagName: 'mark', |
198 |
className: 'annotation-text', |
|
199 |
attributes: { |
|
200 |
className: 'class', |
|
201 |
id: 'id' |
|
202 |
}, |
|
203 |
edit() { |
|
204 |
return null; |
|
205 |
}, |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
206 |
__experimentalGetPropsForEditableTreePreparation(select, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
207 |
richTextIdentifier, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
208 |
blockClientId |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
209 |
}) { |
18 | 210 |
return { |
211 |
annotations: select(STORE_NAME).__experimentalGetAnnotationsForRichText(blockClientId, richTextIdentifier) |
|
212 |
}; |
|
213 |
}, |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
214 |
__experimentalCreatePrepareEditableTree({ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
215 |
annotations |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
216 |
}) { |
18 | 217 |
return (formats, text) => { |
218 |
if (annotations.length === 0) { |
|
219 |
return formats; |
|
220 |
} |
|
221 |
let record = { |
|
222 |
formats, |
|
223 |
text |
|
224 |
}; |
|
225 |
record = applyAnnotations(record, annotations); |
|
226 |
return record.formats; |
|
227 |
}; |
|
228 |
}, |
|
229 |
__experimentalGetPropsForEditableTreeChangeHandler(dispatch) { |
|
230 |
return { |
|
231 |
removeAnnotation: dispatch(STORE_NAME).__experimentalRemoveAnnotation, |
|
232 |
updateAnnotationRange: dispatch(STORE_NAME).__experimentalUpdateAnnotationRange |
|
233 |
}; |
|
234 |
}, |
|
235 |
__experimentalCreateOnChangeEditableValue(props) { |
|
236 |
return formats => { |
|
237 |
const positions = retrieveAnnotationPositions(formats); |
|
238 |
const { |
|
239 |
removeAnnotation, |
|
240 |
updateAnnotationRange, |
|
241 |
annotations |
|
242 |
} = props; |
|
243 |
updateAnnotationsWithPositions(annotations, positions, { |
|
244 |
removeAnnotation, |
|
245 |
updateAnnotationRange |
|
246 |
}); |
|
247 |
}; |
|
248 |
} |
|
249 |
}; |
|
250 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
251 |
;// ./node_modules/@wordpress/annotations/build-module/format/index.js |
18 | 252 |
/** |
253 |
* WordPress dependencies |
|
254 |
*/ |
|
255 |
||
256 |
||
257 |
/** |
|
258 |
* Internal dependencies |
|
259 |
*/ |
|
260 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
261 |
const { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
262 |
name: format_name, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
263 |
...settings |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
264 |
} = annotation; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
265 |
(0,external_wp_richText_namespaceObject.registerFormatType)(format_name, settings); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
266 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
267 |
;// external ["wp","hooks"] |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
268 |
const external_wp_hooks_namespaceObject = window["wp"]["hooks"]; |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
269 |
;// external ["wp","data"] |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
270 |
const external_wp_data_namespaceObject = window["wp"]["data"]; |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
271 |
;// ./node_modules/@wordpress/annotations/build-module/block/index.js |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
272 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
273 |
* WordPress dependencies |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
274 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
275 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
276 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
277 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
278 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
279 |
* Internal dependencies |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
280 |
*/ |
18 | 281 |
|
282 |
/** |
|
283 |
* Adds annotation className to the block-list-block component. |
|
284 |
* |
|
285 |
* @param {Object} OriginalComponent The original BlockListBlock component. |
|
286 |
* @return {Object} The enhanced component. |
|
287 |
*/ |
|
288 |
const addAnnotationClassName = OriginalComponent => { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
289 |
return (0,external_wp_data_namespaceObject.withSelect)((select, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
290 |
clientId, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
291 |
className |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
292 |
}) => { |
18 | 293 |
const annotations = select(STORE_NAME).__experimentalGetAnnotationsForBlock(clientId); |
294 |
return { |
|
295 |
className: annotations.map(annotation => { |
|
296 |
return 'is-annotated-by-' + annotation.source; |
|
297 |
}).concat(className).filter(Boolean).join(' ') |
|
298 |
}; |
|
299 |
})(OriginalComponent); |
|
300 |
}; |
|
19 | 301 |
(0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/annotations', addAnnotationClassName); |
18 | 302 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
303 |
;// ./node_modules/@wordpress/annotations/build-module/store/reducer.js |
18 | 304 |
/** |
305 |
* Filters an array based on the predicate, but keeps the reference the same if |
|
306 |
* the array hasn't changed. |
|
307 |
* |
|
308 |
* @param {Array} collection The collection to filter. |
|
309 |
* @param {Function} predicate Function that determines if the item should stay |
|
310 |
* in the array. |
|
311 |
* @return {Array} Filtered array. |
|
312 |
*/ |
|
313 |
function filterWithReference(collection, predicate) { |
|
314 |
const filteredCollection = collection.filter(predicate); |
|
315 |
return collection.length === filteredCollection.length ? collection : filteredCollection; |
|
316 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
317 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
318 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
319 |
* Creates a new object with the same keys, but with `callback()` called as |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
320 |
* a transformer function on each of the values. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
321 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
322 |
* @param {Object} obj The object to transform. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
323 |
* @param {Function} callback The function to transform each object value. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
324 |
* @return {Array} Transformed object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
325 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
326 |
const mapValues = (obj, callback) => Object.entries(obj).reduce((acc, [key, value]) => ({ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
327 |
...acc, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
328 |
[key]: callback(value) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
329 |
}), {}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
330 |
|
18 | 331 |
/** |
332 |
* Verifies whether the given annotations is a valid annotation. |
|
333 |
* |
|
334 |
* @param {Object} annotation The annotation to verify. |
|
335 |
* @return {boolean} Whether the given annotation is valid. |
|
336 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
337 |
function isValidAnnotationRange(annotation) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
338 |
return typeof annotation.start === 'number' && typeof annotation.end === 'number' && annotation.start <= annotation.end; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
339 |
} |
16 | 340 |
|
18 | 341 |
/** |
342 |
* Reducer managing annotations. |
|
343 |
* |
|
344 |
* @param {Object} state The annotations currently shown in the editor. |
|
345 |
* @param {Object} action Dispatched action. |
|
346 |
* |
|
347 |
* @return {Array} Updated state. |
|
348 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
349 |
function annotations(state = {}, action) { |
18 | 350 |
var _state$blockClientId; |
351 |
switch (action.type) { |
|
352 |
case 'ANNOTATION_ADD': |
|
353 |
const blockClientId = action.blockClientId; |
|
354 |
const newAnnotation = { |
|
355 |
id: action.id, |
|
356 |
blockClientId, |
|
357 |
richTextIdentifier: action.richTextIdentifier, |
|
358 |
source: action.source, |
|
359 |
selector: action.selector, |
|
360 |
range: action.range |
|
361 |
}; |
|
362 |
if (newAnnotation.selector === 'range' && !isValidAnnotationRange(newAnnotation.range)) { |
|
363 |
return state; |
|
364 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
365 |
const previousAnnotationsForBlock = (_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
366 |
return { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
367 |
...state, |
18 | 368 |
[blockClientId]: [...previousAnnotationsForBlock, newAnnotation] |
369 |
}; |
|
370 |
case 'ANNOTATION_REMOVE': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
371 |
return mapValues(state, annotationsForBlock => { |
18 | 372 |
return filterWithReference(annotationsForBlock, annotation => { |
373 |
return annotation.id !== action.annotationId; |
|
374 |
}); |
|
375 |
}); |
|
376 |
case 'ANNOTATION_UPDATE_RANGE': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
377 |
return mapValues(state, annotationsForBlock => { |
18 | 378 |
let hasChangedRange = false; |
379 |
const newAnnotations = annotationsForBlock.map(annotation => { |
|
380 |
if (annotation.id === action.annotationId) { |
|
381 |
hasChangedRange = true; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
382 |
return { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
383 |
...annotation, |
18 | 384 |
range: { |
385 |
start: action.start, |
|
386 |
end: action.end |
|
387 |
} |
|
388 |
}; |
|
389 |
} |
|
390 |
return annotation; |
|
391 |
}); |
|
392 |
return hasChangedRange ? newAnnotations : annotationsForBlock; |
|
393 |
}); |
|
394 |
case 'ANNOTATION_REMOVE_SOURCE': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
395 |
return mapValues(state, annotationsForBlock => { |
18 | 396 |
return filterWithReference(annotationsForBlock, annotation => { |
397 |
return annotation.source !== action.source; |
|
398 |
}); |
|
399 |
}); |
|
400 |
} |
|
401 |
return state; |
|
16 | 402 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
403 |
/* harmony default export */ const reducer = (annotations); |
19 | 404 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
405 |
;// ./node_modules/@wordpress/annotations/build-module/store/selectors.js |
19 | 406 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
407 |
* WordPress dependencies |
19 | 408 |
*/ |
409 |
||
410 |
||
411 |
/** |
|
412 |
* Shared reference to an empty array for cases where it is important to avoid |
|
413 |
* returning a new array reference on every invocation, as in a connected or |
|
414 |
* other pure component which performs `shouldComponentUpdate` check on props. |
|
415 |
* This should be used as a last resort, since the normalized data should be |
|
416 |
* maintained by the reducer result in state. |
|
417 |
* |
|
418 |
* @type {Array} |
|
419 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
420 |
const EMPTY_ARRAY = []; |
19 | 421 |
|
422 |
/** |
|
423 |
* Returns the annotations for a specific client ID. |
|
424 |
* |
|
425 |
* @param {Object} state Editor state. |
|
426 |
* @param {string} clientId The ID of the block to get the annotations for. |
|
427 |
* |
|
428 |
* @return {Array} The annotations applicable to this block. |
|
429 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
430 |
const __experimentalGetAnnotationsForBlock = (0,external_wp_data_namespaceObject.createSelector)((state, blockClientId) => { |
19 | 431 |
var _state$blockClientId; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
432 |
return ((_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => { |
19 | 433 |
return annotation.selector === 'block'; |
434 |
}); |
|
435 |
}, (state, blockClientId) => { |
|
436 |
var _state$blockClientId2; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
437 |
return [(_state$blockClientId2 = state?.[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY]; |
9 | 438 |
}); |
19 | 439 |
function __experimentalGetAllAnnotationsForBlock(state, blockClientId) { |
440 |
var _state$blockClientId3; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
441 |
return (_state$blockClientId3 = state?.[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
442 |
} |
19 | 443 |
|
444 |
/** |
|
445 |
* Returns the annotations that apply to the given RichText instance. |
|
446 |
* |
|
447 |
* Both a blockClientId and a richTextIdentifier are required. This is because |
|
448 |
* a block might have multiple `RichText` components. This does mean that every |
|
449 |
* block needs to implement annotations itself. |
|
450 |
* |
|
451 |
* @param {Object} state Editor state. |
|
452 |
* @param {string} blockClientId The client ID for the block. |
|
453 |
* @param {string} richTextIdentifier Unique identifier that identifies the given RichText. |
|
454 |
* @return {Array} All the annotations relevant for the `RichText`. |
|
455 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
456 |
const __experimentalGetAnnotationsForRichText = (0,external_wp_data_namespaceObject.createSelector)((state, blockClientId, richTextIdentifier) => { |
19 | 457 |
var _state$blockClientId4; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
458 |
return ((_state$blockClientId4 = state?.[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => { |
19 | 459 |
return annotation.selector === 'range' && richTextIdentifier === annotation.richTextIdentifier; |
460 |
}).map(annotation => { |
|
461 |
const { |
|
462 |
range, |
|
463 |
...other |
|
464 |
} = annotation; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
465 |
return { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
466 |
...range, |
19 | 467 |
...other |
468 |
}; |
|
469 |
}); |
|
470 |
}, (state, blockClientId) => { |
|
471 |
var _state$blockClientId5; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
472 |
return [(_state$blockClientId5 = state?.[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
473 |
}); |
19 | 474 |
|
475 |
/** |
|
476 |
* Returns all annotations in the editor state. |
|
477 |
* |
|
478 |
* @param {Object} state Editor state. |
|
479 |
* @return {Array} All annotations currently applied. |
|
480 |
*/ |
|
481 |
function __experimentalGetAnnotations(state) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
482 |
return Object.values(state).flat(); |
19 | 483 |
} |
484 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
485 |
;// ./node_modules/@wordpress/annotations/node_modules/uuid/dist/esm-browser/native.js |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
486 |
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
487 |
/* harmony default export */ const esm_browser_native = ({ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
488 |
randomUUID |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
489 |
}); |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
490 |
;// ./node_modules/@wordpress/annotations/node_modules/uuid/dist/esm-browser/rng.js |
19 | 491 |
// Unique ID creation requires a high quality random # generator. In the browser we therefore |
492 |
// require the crypto API and do not support built-in fallback to lower quality random number |
|
493 |
// generators (like Math.random()). |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
494 |
let getRandomValues; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
495 |
const rnds8 = new Uint8Array(16); |
19 | 496 |
function rng() { |
497 |
// lazy load so that environments that need to polyfill have a chance to do so |
|
498 |
if (!getRandomValues) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
499 |
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
500 |
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto); |
19 | 501 |
|
502 |
if (!getRandomValues) { |
|
503 |
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); |
|
504 |
} |
|
505 |
} |
|
506 |
||
507 |
return getRandomValues(rnds8); |
|
508 |
} |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
509 |
;// ./node_modules/@wordpress/annotations/node_modules/uuid/dist/esm-browser/stringify.js |
19 | 510 |
|
511 |
/** |
|
512 |
* Convert array of 16 byte values to UUID string format of the form: |
|
513 |
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
|
514 |
*/ |
|
515 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
516 |
const byteToHex = []; |
19 | 517 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
518 |
for (let i = 0; i < 256; ++i) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
519 |
byteToHex.push((i + 0x100).toString(16).slice(1)); |
19 | 520 |
} |
521 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
522 |
function unsafeStringify(arr, offset = 0) { |
19 | 523 |
// Note: Be careful editing this code! It's been tuned for performance |
524 |
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
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]]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
526 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
527 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
528 |
function stringify(arr, offset = 0) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
529 |
const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one |
19 | 530 |
// of the following: |
531 |
// - One or more input array values don't map to a hex octet (leading to |
|
532 |
// "undefined" in the uuid) |
|
533 |
// - Invalid input values for the RFC `version` or `variant` fields |
|
534 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
535 |
if (!validate(uuid)) { |
19 | 536 |
throw TypeError('Stringified UUID is invalid'); |
537 |
} |
|
538 |
||
539 |
return uuid; |
|
540 |
} |
|
541 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
542 |
/* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify))); |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
543 |
;// ./node_modules/@wordpress/annotations/node_modules/uuid/dist/esm-browser/v4.js |
19 | 544 |
|
9 | 545 |
|
546 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
547 |
|
19 | 548 |
function v4(options, buf, offset) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
549 |
if (esm_browser_native.randomUUID && !buf && !options) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
550 |
return esm_browser_native.randomUUID(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
551 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
552 |
|
19 | 553 |
options = options || {}; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
554 |
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` |
19 | 555 |
|
556 |
rnds[6] = rnds[6] & 0x0f | 0x40; |
|
557 |
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided |
|
558 |
||
559 |
if (buf) { |
|
560 |
offset = offset || 0; |
|
561 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
562 |
for (let i = 0; i < 16; ++i) { |
19 | 563 |
buf[offset + i] = rnds[i]; |
564 |
} |
|
565 |
||
566 |
return buf; |
|
567 |
} |
|
568 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
569 |
return unsafeStringify(rnds); |
19 | 570 |
} |
571 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
572 |
/* harmony default export */ const esm_browser_v4 = (v4); |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
573 |
;// ./node_modules/@wordpress/annotations/build-module/store/actions.js |
19 | 574 |
/** |
575 |
* External dependencies |
|
576 |
*/ |
|
577 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
578 |
|
19 | 579 |
/** |
580 |
* @typedef WPAnnotationRange |
|
581 |
* |
|
582 |
* @property {number} start The offset where the annotation should start. |
|
583 |
* @property {number} end The offset where the annotation should end. |
|
584 |
*/ |
|
9 | 585 |
|
19 | 586 |
/** |
587 |
* Adds an annotation to a block. |
|
588 |
* |
|
589 |
* The `block` attribute refers to a block ID that needs to be annotated. |
|
590 |
* `isBlockAnnotation` controls whether or not the annotation is a block |
|
591 |
* annotation. The `source` is the source of the annotation, this will be used |
|
592 |
* to identity groups of annotations. |
|
593 |
* |
|
594 |
* The `range` property is only relevant if the selector is 'range'. |
|
595 |
* |
|
596 |
* @param {Object} annotation The annotation to add. |
|
597 |
* @param {string} annotation.blockClientId The blockClientId to add the annotation to. |
|
598 |
* @param {string} annotation.richTextIdentifier Identifier for the RichText instance the annotation applies to. |
|
599 |
* @param {WPAnnotationRange} annotation.range The range at which to apply this annotation. |
|
600 |
* @param {string} [annotation.selector="range"] The way to apply this annotation. |
|
601 |
* @param {string} [annotation.source="default"] The source that added the annotation. |
|
602 |
* @param {string} [annotation.id] The ID the annotation should have. Generates a UUID by default. |
|
603 |
* |
|
604 |
* @return {Object} Action object. |
|
605 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
606 |
function __experimentalAddAnnotation({ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
607 |
blockClientId, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
608 |
richTextIdentifier = null, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
609 |
range = null, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
610 |
selector = 'range', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
611 |
source = 'default', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
612 |
id = esm_browser_v4() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
613 |
}) { |
19 | 614 |
const action = { |
615 |
type: 'ANNOTATION_ADD', |
|
616 |
id, |
|
617 |
blockClientId, |
|
618 |
richTextIdentifier, |
|
619 |
source, |
|
620 |
selector |
|
621 |
}; |
|
622 |
if (selector === 'range') { |
|
623 |
action.range = range; |
|
624 |
} |
|
625 |
return action; |
|
626 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
627 |
|
19 | 628 |
/** |
629 |
* Removes an annotation with a specific ID. |
|
630 |
* |
|
631 |
* @param {string} annotationId The annotation to remove. |
|
632 |
* |
|
633 |
* @return {Object} Action object. |
|
634 |
*/ |
|
635 |
function __experimentalRemoveAnnotation(annotationId) { |
|
636 |
return { |
|
637 |
type: 'ANNOTATION_REMOVE', |
|
638 |
annotationId |
|
639 |
}; |
|
640 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
641 |
|
19 | 642 |
/** |
643 |
* Updates the range of an annotation. |
|
644 |
* |
|
645 |
* @param {string} annotationId ID of the annotation to update. |
|
646 |
* @param {number} start The start of the new range. |
|
647 |
* @param {number} end The end of the new range. |
|
648 |
* |
|
649 |
* @return {Object} Action object. |
|
650 |
*/ |
|
651 |
function __experimentalUpdateAnnotationRange(annotationId, start, end) { |
|
652 |
return { |
|
653 |
type: 'ANNOTATION_UPDATE_RANGE', |
|
654 |
annotationId, |
|
655 |
start, |
|
656 |
end |
|
657 |
}; |
|
658 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
659 |
|
19 | 660 |
/** |
661 |
* Removes all annotations of a specific source. |
|
662 |
* |
|
663 |
* @param {string} source The source to remove. |
|
664 |
* |
|
665 |
* @return {Object} Action object. |
|
666 |
*/ |
|
667 |
function __experimentalRemoveAnnotationsBySource(source) { |
|
668 |
return { |
|
669 |
type: 'ANNOTATION_REMOVE_SOURCE', |
|
670 |
source |
|
671 |
}; |
|
672 |
} |
|
673 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
674 |
;// ./node_modules/@wordpress/annotations/build-module/store/index.js |
19 | 675 |
/** |
676 |
* WordPress dependencies |
|
677 |
*/ |
|
678 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
679 |
|
19 | 680 |
/** |
681 |
* Internal dependencies |
|
682 |
*/ |
|
683 |
||
684 |
||
685 |
||
686 |
||
687 |
/** |
|
688 |
* Module Constants |
|
689 |
*/ |
|
690 |
||
9 | 691 |
|
19 | 692 |
/** |
693 |
* Store definition for the annotations namespace. |
|
694 |
* |
|
695 |
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
|
696 |
* |
|
697 |
* @type {Object} |
|
698 |
*/ |
|
699 |
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { |
|
700 |
reducer: reducer, |
|
701 |
selectors: selectors_namespaceObject, |
|
702 |
actions: actions_namespaceObject |
|
703 |
}); |
|
704 |
(0,external_wp_data_namespaceObject.register)(store); |
|
705 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
706 |
;// ./node_modules/@wordpress/annotations/build-module/index.js |
19 | 707 |
/** |
708 |
* Internal dependencies |
|
709 |
*/ |
|
710 |
||
711 |
||
712 |
||
713 |
||
714 |
(window.wp = window.wp || {}).annotations = __webpack_exports__; |
|
715 |
/******/ })() |
|
716 |
; |