19
|
1 |
/******/ (function() { // webpackBootstrap |
|
2 |
/******/ "use strict"; |
|
3 |
/******/ // The require scope |
|
4 |
/******/ var __webpack_require__ = {}; |
|
5 |
/******/ |
|
6 |
/************************************************************************/ |
|
7 |
/******/ /* webpack/runtime/make namespace object */ |
|
8 |
/******/ !function() { |
|
9 |
/******/ // define __esModule on exports |
|
10 |
/******/ __webpack_require__.r = function(exports) { |
|
11 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
12 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
13 |
/******/ } |
|
14 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
9
|
15 |
/******/ }; |
19
|
16 |
/******/ }(); |
|
17 |
/******/ |
9
|
18 |
/************************************************************************/ |
19
|
19 |
var __webpack_exports__ = {}; |
|
20 |
// ESM COMPAT FLAG |
|
21 |
__webpack_require__.r(__webpack_exports__); |
16
|
22 |
|
19
|
23 |
;// CONCATENATED MODULE: external ["wp","richText"] |
|
24 |
var external_wp_richText_namespaceObject = window["wp"]["richText"]; |
|
25 |
;// CONCATENATED MODULE: external ["wp","element"] |
|
26 |
var external_wp_element_namespaceObject = window["wp"]["element"]; |
|
27 |
;// CONCATENATED MODULE: external ["wp","i18n"] |
|
28 |
var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
|
29 |
;// CONCATENATED MODULE: external ["wp","blockEditor"] |
|
30 |
var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; |
|
31 |
;// CONCATENATED MODULE: external ["wp","primitives"] |
|
32 |
var external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
|
33 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-bold.js |
18
|
34 |
|
16
|
35 |
|
|
36 |
/** |
|
37 |
* WordPress dependencies |
|
38 |
*/ |
18
|
39 |
|
19
|
40 |
const formatBold = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
18
|
41 |
xmlns: "http://www.w3.org/2000/svg", |
|
42 |
viewBox: "0 0 24 24" |
19
|
43 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
16
|
44 |
d: "M14.7 11.3c1-.6 1.5-1.6 1.5-3 0-2.3-1.3-3.4-4-3.4H7v14h5.8c1.4 0 2.5-.3 3.3-1 .8-.7 1.2-1.7 1.2-2.9.1-1.9-.8-3.1-2.6-3.7zm-5.1-4h2.3c.6 0 1.1.1 1.4.4.3.3.5.7.5 1.2s-.2 1-.5 1.2c-.3.3-.8.4-1.4.4H9.6V7.3zm4.6 9c-.4.3-1 .4-1.7.4H9.6v-3.9h2.9c.7 0 1.3.2 1.7.5.4.3.6.8.6 1.5s-.2 1.2-.6 1.5z" |
|
45 |
})); |
|
46 |
/* harmony default export */ var format_bold = (formatBold); |
9
|
47 |
|
19
|
48 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/bold/index.js |
9
|
49 |
|
|
50 |
|
|
51 |
/** |
|
52 |
* WordPress dependencies |
|
53 |
*/ |
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
18
|
58 |
const bold_name = 'core/bold'; |
16
|
59 |
|
19
|
60 |
const title = (0,external_wp_i18n_namespaceObject.__)('Bold'); |
16
|
61 |
|
18
|
62 |
const bold = { |
9
|
63 |
name: bold_name, |
18
|
64 |
title, |
9
|
65 |
tagName: 'strong', |
|
66 |
className: null, |
16
|
67 |
|
19
|
68 |
edit(_ref) { |
|
69 |
let { |
|
70 |
isActive, |
|
71 |
value, |
|
72 |
onChange, |
|
73 |
onFocus |
|
74 |
} = _ref; |
|
75 |
|
16
|
76 |
function onToggle() { |
19
|
77 |
onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
|
78 |
type: bold_name, |
|
79 |
title |
9
|
80 |
})); |
16
|
81 |
} |
|
82 |
|
|
83 |
function onClick() { |
19
|
84 |
onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
|
85 |
type: bold_name |
|
86 |
})); |
16
|
87 |
onFocus(); |
|
88 |
} |
9
|
89 |
|
19
|
90 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
9
|
91 |
type: "primary", |
|
92 |
character: "b", |
|
93 |
onUse: onToggle |
19
|
94 |
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
9
|
95 |
name: "bold", |
16
|
96 |
icon: format_bold, |
|
97 |
title: title, |
|
98 |
onClick: onClick, |
9
|
99 |
isActive: isActive, |
|
100 |
shortcutType: "primary", |
|
101 |
shortcutCharacter: "b" |
19
|
102 |
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { |
9
|
103 |
inputType: "formatBold", |
|
104 |
onInput: onToggle |
|
105 |
})); |
|
106 |
} |
18
|
107 |
|
9
|
108 |
}; |
|
109 |
|
19
|
110 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/code.js |
|
111 |
|
|
112 |
|
|
113 |
/** |
|
114 |
* WordPress dependencies |
|
115 |
*/ |
16
|
116 |
|
19
|
117 |
const code = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
118 |
viewBox: "0 0 24 24", |
|
119 |
xmlns: "http://www.w3.org/2000/svg" |
|
120 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
|
121 |
d: "M20.8 10.7l-4.3-4.3-1.1 1.1 4.3 4.3c.1.1.1.3 0 .4l-4.3 4.3 1.1 1.1 4.3-4.3c.7-.8.7-1.9 0-2.6zM4.2 11.8l4.3-4.3-1-1-4.3 4.3c-.7.7-.7 1.8 0 2.5l4.3 4.3 1.1-1.1-4.3-4.3c-.2-.1-.2-.3-.1-.4z" |
|
122 |
})); |
|
123 |
/* harmony default export */ var library_code = (code); |
|
124 |
|
|
125 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/code/index.js |
9
|
126 |
|
|
127 |
|
|
128 |
/** |
|
129 |
* WordPress dependencies |
|
130 |
*/ |
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
18
|
135 |
const code_name = 'core/code'; |
16
|
136 |
|
19
|
137 |
const code_title = (0,external_wp_i18n_namespaceObject.__)('Inline code'); |
16
|
138 |
|
18
|
139 |
const code_code = { |
9
|
140 |
name: code_name, |
16
|
141 |
title: code_title, |
9
|
142 |
tagName: 'code', |
|
143 |
className: null, |
18
|
144 |
|
|
145 |
__unstableInputRule(value) { |
|
146 |
const BACKTICK = '`'; |
|
147 |
const { |
|
148 |
start, |
|
149 |
text |
|
150 |
} = value; |
|
151 |
const characterBefore = text.slice(start - 1, start); // Quick check the text for the necessary character. |
16
|
152 |
|
|
153 |
if (characterBefore !== BACKTICK) { |
|
154 |
return value; |
|
155 |
} |
|
156 |
|
18
|
157 |
const textBefore = text.slice(0, start - 1); |
|
158 |
const indexBefore = textBefore.lastIndexOf(BACKTICK); |
16
|
159 |
|
|
160 |
if (indexBefore === -1) { |
|
161 |
return value; |
|
162 |
} |
|
163 |
|
18
|
164 |
const startIndex = indexBefore; |
|
165 |
const endIndex = start - 2; |
16
|
166 |
|
|
167 |
if (startIndex === endIndex) { |
|
168 |
return value; |
|
169 |
} |
|
170 |
|
19
|
171 |
value = (0,external_wp_richText_namespaceObject.remove)(value, startIndex, startIndex + 1); |
|
172 |
value = (0,external_wp_richText_namespaceObject.remove)(value, endIndex, endIndex + 1); |
|
173 |
value = (0,external_wp_richText_namespaceObject.applyFormat)(value, { |
16
|
174 |
type: code_name |
|
175 |
}, startIndex, endIndex); |
|
176 |
return value; |
|
177 |
}, |
9
|
178 |
|
19
|
179 |
edit(_ref) { |
|
180 |
let { |
|
181 |
value, |
|
182 |
onChange, |
|
183 |
onFocus, |
|
184 |
isActive |
|
185 |
} = _ref; |
|
186 |
|
16
|
187 |
function onClick() { |
19
|
188 |
onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
|
189 |
type: code_name, |
|
190 |
title: code_title |
9
|
191 |
})); |
16
|
192 |
onFocus(); |
|
193 |
} |
|
194 |
|
19
|
195 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
|
196 |
icon: library_code, |
16
|
197 |
title: code_title, |
|
198 |
onClick: onClick, |
19
|
199 |
isActive: isActive, |
|
200 |
role: "menuitemcheckbox" |
16
|
201 |
}); |
9
|
202 |
} |
18
|
203 |
|
9
|
204 |
}; |
|
205 |
|
19
|
206 |
;// CONCATENATED MODULE: external ["wp","components"] |
|
207 |
var external_wp_components_namespaceObject = window["wp"]["components"]; |
|
208 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard-return.js |
|
209 |
|
|
210 |
|
|
211 |
/** |
|
212 |
* WordPress dependencies |
|
213 |
*/ |
16
|
214 |
|
19
|
215 |
const keyboardReturn = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
216 |
xmlns: "http://www.w3.org/2000/svg", |
|
217 |
viewBox: "-2 -2 24 24" |
|
218 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
|
219 |
d: "M6.734 16.106l2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.157 1.093-1.027-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734z" |
|
220 |
})); |
|
221 |
/* harmony default export */ var keyboard_return = (keyboardReturn); |
9
|
222 |
|
19
|
223 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/image/index.js |
9
|
224 |
|
|
225 |
|
|
226 |
/** |
|
227 |
* WordPress dependencies |
|
228 |
*/ |
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
18
|
235 |
const ALLOWED_MEDIA_TYPES = ['image']; |
|
236 |
const image_name = 'core/image'; |
16
|
237 |
|
19
|
238 |
const image_title = (0,external_wp_i18n_namespaceObject.__)('Inline image'); |
9
|
239 |
|
18
|
240 |
const image_image = { |
9
|
241 |
name: image_name, |
16
|
242 |
title: image_title, |
19
|
243 |
keywords: [(0,external_wp_i18n_namespaceObject.__)('photo'), (0,external_wp_i18n_namespaceObject.__)('media')], |
9
|
244 |
object: true, |
|
245 |
tagName: 'img', |
|
246 |
className: null, |
|
247 |
attributes: { |
|
248 |
className: 'class', |
|
249 |
style: 'style', |
|
250 |
url: 'src', |
|
251 |
alt: 'alt' |
|
252 |
}, |
18
|
253 |
edit: Edit |
|
254 |
}; |
9
|
255 |
|
19
|
256 |
function InlineUI(_ref) { |
|
257 |
let { |
|
258 |
value, |
|
259 |
onChange, |
|
260 |
activeObjectAttributes, |
|
261 |
contentRef |
|
262 |
} = _ref; |
18
|
263 |
const { |
|
264 |
style |
|
265 |
} = activeObjectAttributes; |
19
|
266 |
const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)(style === null || style === void 0 ? void 0 : style.replace(/\D/g, '')); |
|
267 |
const anchorRef = (0,external_wp_richText_namespaceObject.useAnchorRef)({ |
18
|
268 |
ref: contentRef, |
|
269 |
value, |
|
270 |
settings: image_image |
|
271 |
}); |
19
|
272 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { |
18
|
273 |
position: "bottom center", |
|
274 |
focusOnMount: false, |
|
275 |
anchorRef: anchorRef, |
|
276 |
className: "block-editor-format-toolbar__image-popover" |
19
|
277 |
}, (0,external_wp_element_namespaceObject.createElement)("form", { |
18
|
278 |
className: "block-editor-format-toolbar__image-container-content", |
|
279 |
onSubmit: event => { |
|
280 |
const newReplacements = value.replacements.slice(); |
|
281 |
newReplacements[value.start] = { |
|
282 |
type: image_name, |
|
283 |
attributes: { ...activeObjectAttributes, |
19
|
284 |
style: width ? `width: ${width}px;` : '' |
9
|
285 |
} |
18
|
286 |
}; |
|
287 |
onChange({ ...value, |
|
288 |
replacements: newReplacements |
|
289 |
}); |
|
290 |
event.preventDefault(); |
|
291 |
} |
19
|
292 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { |
18
|
293 |
className: "block-editor-format-toolbar__image-container-value", |
|
294 |
type: "number", |
19
|
295 |
label: (0,external_wp_i18n_namespaceObject.__)('Width'), |
18
|
296 |
value: width, |
|
297 |
min: 1, |
|
298 |
onChange: newWidth => setWidth(newWidth) |
19
|
299 |
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
|
300 |
icon: keyboard_return, |
|
301 |
label: (0,external_wp_i18n_namespaceObject.__)('Apply'), |
18
|
302 |
type: "submit" |
|
303 |
}))); |
|
304 |
} |
9
|
305 |
|
19
|
306 |
function Edit(_ref2) { |
|
307 |
let { |
|
308 |
value, |
|
309 |
onChange, |
|
310 |
onFocus, |
|
311 |
isObjectActive, |
|
312 |
activeObjectAttributes, |
|
313 |
contentRef |
|
314 |
} = _ref2; |
|
315 |
const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); |
9
|
316 |
|
18
|
317 |
function openModal() { |
|
318 |
setIsModalOpen(true); |
|
319 |
} |
|
320 |
|
|
321 |
function closeModal() { |
|
322 |
setIsModalOpen(false); |
|
323 |
} |
9
|
324 |
|
19
|
325 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
|
326 |
icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, { |
18
|
327 |
xmlns: "http://www.w3.org/2000/svg", |
|
328 |
viewBox: "0 0 24 24" |
19
|
329 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { |
18
|
330 |
d: "M4 18.5h16V17H4v1.5zM16 13v1.5h4V13h-4zM5.1 15h7.8c.6 0 1.1-.5 1.1-1.1V6.1c0-.6-.5-1.1-1.1-1.1H5.1C4.5 5 4 5.5 4 6.1v7.8c0 .6.5 1.1 1.1 1.1zm.4-8.5h7V10l-1-1c-.3-.3-.8-.3-1 0l-1.6 1.5-1.2-.7c-.3-.2-.6-.2-.9 0l-1.3 1V6.5zm0 6.1l1.8-1.3 1.3.8c.3.2.7.2.9-.1l1.5-1.4 1.5 1.4v1.5h-7v-.9z" |
|
331 |
})), |
|
332 |
title: image_title, |
|
333 |
onClick: openModal, |
|
334 |
isActive: isObjectActive |
19
|
335 |
}), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUpload, { |
18
|
336 |
allowedTypes: ALLOWED_MEDIA_TYPES, |
19
|
337 |
onSelect: _ref3 => { |
|
338 |
let { |
|
339 |
id, |
|
340 |
url, |
|
341 |
alt, |
|
342 |
width: imgWidth |
|
343 |
} = _ref3; |
18
|
344 |
closeModal(); |
19
|
345 |
onChange((0,external_wp_richText_namespaceObject.insertObject)(value, { |
18
|
346 |
type: image_name, |
|
347 |
attributes: { |
|
348 |
className: `wp-image-${id}`, |
|
349 |
style: `width: ${Math.min(imgWidth, 150)}px;`, |
|
350 |
url, |
|
351 |
alt |
9
|
352 |
} |
18
|
353 |
})); |
|
354 |
onFocus(); |
|
355 |
}, |
|
356 |
onClose: closeModal, |
19
|
357 |
render: _ref4 => { |
|
358 |
let { |
|
359 |
open |
|
360 |
} = _ref4; |
18
|
361 |
open(); |
|
362 |
return null; |
|
363 |
} |
19
|
364 |
}), isObjectActive && (0,external_wp_element_namespaceObject.createElement)(InlineUI, { |
18
|
365 |
value: value, |
|
366 |
onChange: onChange, |
|
367 |
activeObjectAttributes: activeObjectAttributes, |
|
368 |
contentRef: contentRef |
|
369 |
})); |
|
370 |
} |
9
|
371 |
|
19
|
372 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-italic.js |
16
|
373 |
|
|
374 |
|
|
375 |
/** |
|
376 |
* WordPress dependencies |
|
377 |
*/ |
|
378 |
|
19
|
379 |
const formatItalic = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
16
|
380 |
xmlns: "http://www.w3.org/2000/svg", |
|
381 |
viewBox: "0 0 24 24" |
19
|
382 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
16
|
383 |
d: "M12.5 5L10 19h1.9l2.5-14z" |
|
384 |
})); |
|
385 |
/* harmony default export */ var format_italic = (formatItalic); |
|
386 |
|
19
|
387 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/italic/index.js |
9
|
388 |
|
|
389 |
|
|
390 |
/** |
|
391 |
* WordPress dependencies |
|
392 |
*/ |
|
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
18
|
397 |
const italic_name = 'core/italic'; |
16
|
398 |
|
19
|
399 |
const italic_title = (0,external_wp_i18n_namespaceObject.__)('Italic'); |
16
|
400 |
|
18
|
401 |
const italic = { |
9
|
402 |
name: italic_name, |
16
|
403 |
title: italic_title, |
9
|
404 |
tagName: 'em', |
|
405 |
className: null, |
16
|
406 |
|
19
|
407 |
edit(_ref) { |
|
408 |
let { |
|
409 |
isActive, |
|
410 |
value, |
|
411 |
onChange, |
|
412 |
onFocus |
|
413 |
} = _ref; |
|
414 |
|
16
|
415 |
function onToggle() { |
19
|
416 |
onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
|
417 |
type: italic_name, |
|
418 |
title: italic_title |
9
|
419 |
})); |
16
|
420 |
} |
|
421 |
|
|
422 |
function onClick() { |
19
|
423 |
onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
|
424 |
type: italic_name |
|
425 |
})); |
16
|
426 |
onFocus(); |
|
427 |
} |
9
|
428 |
|
19
|
429 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
9
|
430 |
type: "primary", |
|
431 |
character: "i", |
|
432 |
onUse: onToggle |
19
|
433 |
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
9
|
434 |
name: "italic", |
16
|
435 |
icon: format_italic, |
|
436 |
title: italic_title, |
|
437 |
onClick: onClick, |
9
|
438 |
isActive: isActive, |
|
439 |
shortcutType: "primary", |
|
440 |
shortcutCharacter: "i" |
19
|
441 |
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { |
9
|
442 |
inputType: "formatItalic", |
|
443 |
onInput: onToggle |
|
444 |
})); |
|
445 |
} |
18
|
446 |
|
9
|
447 |
}; |
|
448 |
|
19
|
449 |
;// CONCATENATED MODULE: external ["wp","url"] |
|
450 |
var external_wp_url_namespaceObject = window["wp"]["url"]; |
|
451 |
;// CONCATENATED MODULE: external ["wp","htmlEntities"] |
|
452 |
var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; |
|
453 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link-off.js |
|
454 |
|
16
|
455 |
|
19
|
456 |
/** |
|
457 |
* WordPress dependencies |
|
458 |
*/ |
16
|
459 |
|
19
|
460 |
const linkOff = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
461 |
xmlns: "http://www.w3.org/2000/svg", |
|
462 |
viewBox: "0 0 24 24" |
|
463 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
|
464 |
d: "M15.6 7.3h-.7l1.6-3.5-.9-.4-3.9 8.5H9v1.5h2l-1.3 2.8H8.4c-2 0-3.7-1.7-3.7-3.7s1.7-3.7 3.7-3.7H10V7.3H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H9l-1.4 3.2.9.4 5.7-12.5h1.4c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.9 0 5.2-2.3 5.2-5.2 0-2.9-2.4-5.2-5.2-5.2z" |
|
465 |
})); |
|
466 |
/* harmony default export */ var link_off = (linkOff); |
|
467 |
|
|
468 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link.js |
16
|
469 |
|
19
|
470 |
|
|
471 |
/** |
|
472 |
* WordPress dependencies |
|
473 |
*/ |
16
|
474 |
|
19
|
475 |
const link_link = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
476 |
xmlns: "http://www.w3.org/2000/svg", |
|
477 |
viewBox: "0 0 24 24" |
|
478 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
|
479 |
d: "M15.6 7.2H14v1.5h1.6c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.8 0 5.2-2.3 5.2-5.2 0-2.9-2.3-5.2-5.2-5.2zM4.7 12.4c0-2 1.7-3.7 3.7-3.7H10V7.2H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H10v-1.5H8.4c-2 0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z" |
|
480 |
})); |
|
481 |
/* harmony default export */ var library_link = (link_link); |
16
|
482 |
|
19
|
483 |
;// CONCATENATED MODULE: external ["wp","a11y"] |
|
484 |
var external_wp_a11y_namespaceObject = window["wp"]["a11y"]; |
|
485 |
;// CONCATENATED MODULE: external ["wp","data"] |
|
486 |
var external_wp_data_namespaceObject = window["wp"]["data"]; |
|
487 |
;// CONCATENATED MODULE: external "lodash" |
|
488 |
var external_lodash_namespaceObject = window["lodash"]; |
|
489 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/utils.js |
9
|
490 |
/** |
|
491 |
* External dependencies |
|
492 |
*/ |
|
493 |
|
|
494 |
/** |
|
495 |
* WordPress dependencies |
|
496 |
*/ |
|
497 |
|
|
498 |
|
|
499 |
/** |
|
500 |
* Check for issues with the provided href. |
|
501 |
* |
|
502 |
* @param {string} href The href. |
|
503 |
* |
|
504 |
* @return {boolean} Is the href invalid? |
|
505 |
*/ |
|
506 |
|
|
507 |
function isValidHref(href) { |
|
508 |
if (!href) { |
|
509 |
return false; |
|
510 |
} |
|
511 |
|
18
|
512 |
const trimmedHref = href.trim(); |
9
|
513 |
|
|
514 |
if (!trimmedHref) { |
|
515 |
return false; |
|
516 |
} // Does the href start with something that looks like a URL protocol? |
|
517 |
|
|
518 |
|
|
519 |
if (/^\S+:/.test(trimmedHref)) { |
19
|
520 |
const protocol = (0,external_wp_url_namespaceObject.getProtocol)(trimmedHref); |
9
|
521 |
|
19
|
522 |
if (!(0,external_wp_url_namespaceObject.isValidProtocol)(protocol)) { |
9
|
523 |
return false; |
|
524 |
} // Add some extra checks for http(s) URIs, since these are the most common use-case. |
|
525 |
// This ensures URIs with an http protocol have exactly two forward slashes following the protocol. |
|
526 |
|
|
527 |
|
19
|
528 |
if ((0,external_lodash_namespaceObject.startsWith)(protocol, 'http') && !/^https?:\/\/[^\/\s]/i.test(trimmedHref)) { |
9
|
529 |
return false; |
|
530 |
} |
|
531 |
|
19
|
532 |
const authority = (0,external_wp_url_namespaceObject.getAuthority)(trimmedHref); |
9
|
533 |
|
19
|
534 |
if (!(0,external_wp_url_namespaceObject.isValidAuthority)(authority)) { |
9
|
535 |
return false; |
|
536 |
} |
|
537 |
|
19
|
538 |
const path = (0,external_wp_url_namespaceObject.getPath)(trimmedHref); |
9
|
539 |
|
19
|
540 |
if (path && !(0,external_wp_url_namespaceObject.isValidPath)(path)) { |
9
|
541 |
return false; |
|
542 |
} |
|
543 |
|
19
|
544 |
const queryString = (0,external_wp_url_namespaceObject.getQueryString)(trimmedHref); |
9
|
545 |
|
19
|
546 |
if (queryString && !(0,external_wp_url_namespaceObject.isValidQueryString)(queryString)) { |
9
|
547 |
return false; |
|
548 |
} |
|
549 |
|
19
|
550 |
const fragment = (0,external_wp_url_namespaceObject.getFragment)(trimmedHref); |
9
|
551 |
|
19
|
552 |
if (fragment && !(0,external_wp_url_namespaceObject.isValidFragment)(fragment)) { |
9
|
553 |
return false; |
|
554 |
} |
|
555 |
} // Validate anchor links. |
|
556 |
|
|
557 |
|
19
|
558 |
if ((0,external_lodash_namespaceObject.startsWith)(trimmedHref, '#') && !(0,external_wp_url_namespaceObject.isValidFragment)(trimmedHref)) { |
9
|
559 |
return false; |
|
560 |
} |
|
561 |
|
|
562 |
return true; |
|
563 |
} |
|
564 |
/** |
|
565 |
* Generates the format object that will be applied to the link text. |
|
566 |
* |
16
|
567 |
* @param {Object} options |
|
568 |
* @param {string} options.url The href of the link. |
|
569 |
* @param {string} options.type The type of the link. |
|
570 |
* @param {string} options.id The ID of the link. |
|
571 |
* @param {boolean} options.opensInNewWindow Whether this link will open in a new window. |
9
|
572 |
* |
|
573 |
* @return {Object} The final format object. |
|
574 |
*/ |
|
575 |
|
19
|
576 |
function createLinkFormat(_ref) { |
|
577 |
let { |
|
578 |
url, |
|
579 |
type, |
|
580 |
id, |
|
581 |
opensInNewWindow |
|
582 |
} = _ref; |
18
|
583 |
const format = { |
9
|
584 |
type: 'core/link', |
|
585 |
attributes: { |
18
|
586 |
url |
9
|
587 |
} |
|
588 |
}; |
16
|
589 |
if (type) format.attributes.type = type; |
|
590 |
if (id) format.attributes.id = id; |
9
|
591 |
|
|
592 |
if (opensInNewWindow) { |
|
593 |
format.attributes.target = '_blank'; |
|
594 |
format.attributes.rel = 'noreferrer noopener'; |
|
595 |
} |
|
596 |
|
|
597 |
return format; |
|
598 |
} |
19
|
599 |
/* eslint-disable jsdoc/no-undefined-types */ |
9
|
600 |
|
19
|
601 |
/** |
|
602 |
* Get the start and end boundaries of a given format from a rich text value. |
|
603 |
* |
|
604 |
* |
|
605 |
* @param {RichTextValue} value the rich text value to interrogate. |
|
606 |
* @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`). |
|
607 |
* @param {number?} startIndex optional startIndex to seek from. |
|
608 |
* @param {number?} endIndex optional endIndex to seek from. |
|
609 |
* @return {Object} object containing start and end values for the given format. |
|
610 |
*/ |
|
611 |
|
|
612 |
/* eslint-enable jsdoc/no-undefined-types */ |
|
613 |
|
|
614 |
function getFormatBoundary(value, format) { |
|
615 |
let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.start; |
|
616 |
let endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : value.end; |
|
617 |
const EMPTY_BOUNDARIES = { |
|
618 |
start: null, |
|
619 |
end: null |
|
620 |
}; |
|
621 |
const { |
|
622 |
formats |
|
623 |
} = value; |
|
624 |
let targetFormat; |
|
625 |
let initialIndex; |
|
626 |
|
|
627 |
if (!(formats !== null && formats !== void 0 && formats.length)) { |
|
628 |
return EMPTY_BOUNDARIES; |
|
629 |
} // Clone formats to avoid modifying source formats. |
|
630 |
|
|
631 |
|
|
632 |
const newFormats = formats.slice(); |
|
633 |
const formatAtStart = (0,external_lodash_namespaceObject.find)(newFormats[startIndex], { |
|
634 |
type: format.type |
|
635 |
}); |
|
636 |
const formatAtEnd = (0,external_lodash_namespaceObject.find)(newFormats[endIndex], { |
|
637 |
type: format.type |
|
638 |
}); |
|
639 |
const formatAtEndMinusOne = (0,external_lodash_namespaceObject.find)(newFormats[endIndex - 1], { |
|
640 |
type: format.type |
|
641 |
}); |
|
642 |
|
|
643 |
if (!!formatAtStart) { |
|
644 |
// Set values to conform to "start" |
|
645 |
targetFormat = formatAtStart; |
|
646 |
initialIndex = startIndex; |
|
647 |
} else if (!!formatAtEnd) { |
|
648 |
// Set values to conform to "end" |
|
649 |
targetFormat = formatAtEnd; |
|
650 |
initialIndex = endIndex; |
|
651 |
} else if (!!formatAtEndMinusOne) { |
|
652 |
// This is an edge case which will occur if you create a format, then place |
|
653 |
// the caret just before the format and hit the back ARROW key. The resulting |
|
654 |
// value object will have start and end +1 beyond the edge of the format boundary. |
|
655 |
targetFormat = formatAtEndMinusOne; |
|
656 |
initialIndex = endIndex - 1; |
|
657 |
} else { |
|
658 |
return EMPTY_BOUNDARIES; |
|
659 |
} |
|
660 |
|
|
661 |
const index = newFormats[initialIndex].indexOf(targetFormat); |
|
662 |
const walkingArgs = [newFormats, initialIndex, targetFormat, index]; // Walk the startIndex "backwards" to the leading "edge" of the matching format. |
|
663 |
|
|
664 |
startIndex = walkToStart(...walkingArgs); // Walk the endIndex "forwards" until the trailing "edge" of the matching format. |
|
665 |
|
|
666 |
endIndex = walkToEnd(...walkingArgs); // Safe guard: start index cannot be less than 0. |
|
667 |
|
|
668 |
startIndex = startIndex < 0 ? 0 : startIndex; // // Return the indicies of the "edges" as the boundaries. |
|
669 |
|
|
670 |
return { |
|
671 |
start: startIndex, |
|
672 |
end: endIndex |
|
673 |
}; |
|
674 |
} |
|
675 |
/** |
|
676 |
* Walks forwards/backwards towards the boundary of a given format within an |
|
677 |
* array of format objects. Returns the index of the boundary. |
|
678 |
* |
|
679 |
* @param {Array} formats the formats to search for the given format type. |
|
680 |
* @param {number} initialIndex the starting index from which to walk. |
|
681 |
* @param {Object} targetFormatRef a reference to the format type object being sought. |
|
682 |
* @param {number} formatIndex the index at which we expect the target format object to be. |
|
683 |
* @param {string} direction either 'forwards' or 'backwards' to indicate the direction. |
|
684 |
* @return {number} the index of the boundary of the given format. |
|
685 |
*/ |
|
686 |
|
|
687 |
function walkToBoundary(formats, initialIndex, targetFormatRef, formatIndex, direction) { |
|
688 |
let index = initialIndex; |
|
689 |
const directions = { |
|
690 |
forwards: 1, |
|
691 |
backwards: -1 |
|
692 |
}; |
|
693 |
const directionIncrement = directions[direction] || 1; // invalid direction arg default to forwards |
|
694 |
|
|
695 |
const inverseDirectionIncrement = directionIncrement * -1; |
|
696 |
|
|
697 |
while (formats[index] && formats[index][formatIndex] === targetFormatRef) { |
|
698 |
// Increment/decrement in the direction of operation. |
|
699 |
index = index + directionIncrement; |
|
700 |
} // Restore by one in inverse direction of operation |
|
701 |
// to avoid out of bounds. |
|
702 |
|
|
703 |
|
|
704 |
index = index + inverseDirectionIncrement; |
|
705 |
return index; |
|
706 |
} |
|
707 |
|
|
708 |
const walkToStart = (0,external_lodash_namespaceObject.partialRight)(walkToBoundary, 'backwards'); |
|
709 |
const walkToEnd = (0,external_lodash_namespaceObject.partialRight)(walkToBoundary, 'forwards'); |
|
710 |
|
|
711 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/use-link-instance-key.js |
|
712 |
// Weakly referenced map allows unused ids to be garbage collected. |
|
713 |
const weakMap = new WeakMap(); // Incrementing zero-based ID value. |
|
714 |
|
|
715 |
let id = -1; |
|
716 |
const prefix = 'link-control-instance'; |
|
717 |
|
|
718 |
function getKey(_id) { |
|
719 |
return `${prefix}-${_id}`; |
|
720 |
} |
|
721 |
/** |
|
722 |
* Builds a unique link control key for the given object reference. |
|
723 |
* |
|
724 |
* @param {Object} instance an unique object reference specific to this link control instance. |
|
725 |
* @return {string} the unique key to use for this link control. |
|
726 |
*/ |
|
727 |
|
|
728 |
|
|
729 |
function useLinkInstanceKey(instance) { |
|
730 |
if (!instance) { |
|
731 |
return; |
|
732 |
} |
|
733 |
|
|
734 |
if (weakMap.has(instance)) { |
|
735 |
return getKey(weakMap.get(instance)); |
|
736 |
} |
|
737 |
|
|
738 |
id += 1; |
|
739 |
weakMap.set(instance, id); |
|
740 |
return getKey(id); |
|
741 |
} |
|
742 |
|
|
743 |
/* harmony default export */ var use_link_instance_key = (useLinkInstanceKey); |
|
744 |
|
|
745 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/inline.js |
9
|
746 |
|
|
747 |
|
|
748 |
/** |
|
749 |
* WordPress dependencies |
|
750 |
*/ |
|
751 |
|
|
752 |
|
|
753 |
|
|
754 |
|
|
755 |
|
|
756 |
|
19
|
757 |
|
9
|
758 |
/** |
|
759 |
* Internal dependencies |
|
760 |
*/ |
|
761 |
|
|
762 |
|
|
763 |
|
16
|
764 |
|
19
|
765 |
|
|
766 |
function InlineLinkUI(_ref) { |
|
767 |
let { |
|
768 |
isActive, |
|
769 |
activeAttributes, |
|
770 |
addingLink, |
|
771 |
value, |
|
772 |
onChange, |
|
773 |
speak, |
|
774 |
stopAddingLink, |
|
775 |
contentRef |
|
776 |
} = _ref; |
|
777 |
const richLinkTextValue = getRichTextValueFromSelection(value, isActive); // Get the text content minus any HTML tags. |
|
778 |
|
|
779 |
const richTextText = richLinkTextValue.text; |
16
|
780 |
/** |
|
781 |
* Pending settings to be applied to the next link. When inserting a new |
|
782 |
* link, toggle values cannot be applied immediately, because there is not |
|
783 |
* yet a link for them to apply to. Thus, they are maintained in a state |
|
784 |
* value until the time that the link can be inserted or edited. |
|
785 |
* |
|
786 |
* @type {[Object|undefined,Function]} |
|
787 |
*/ |
19
|
788 |
|
|
789 |
const [nextLinkValue, setNextLinkValue] = (0,external_wp_element_namespaceObject.useState)(); |
|
790 |
const { |
|
791 |
createPageEntity, |
|
792 |
userCanCreatePages |
|
793 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => { |
|
794 |
const { |
|
795 |
getSettings |
|
796 |
} = select(external_wp_blockEditor_namespaceObject.store); |
|
797 |
|
|
798 |
const _settings = getSettings(); |
|
799 |
|
|
800 |
return { |
|
801 |
createPageEntity: _settings.__experimentalCreatePageEntity, |
|
802 |
userCanCreatePages: _settings.__experimentalUserCanCreatePages |
|
803 |
}; |
|
804 |
}, []); |
18
|
805 |
const linkValue = { |
16
|
806 |
url: activeAttributes.url, |
|
807 |
type: activeAttributes.type, |
|
808 |
id: activeAttributes.id, |
18
|
809 |
opensInNewTab: activeAttributes.target === '_blank', |
19
|
810 |
title: richTextText, |
18
|
811 |
...nextLinkValue |
|
812 |
}; |
16
|
813 |
|
19
|
814 |
function removeLink() { |
|
815 |
const newValue = (0,external_wp_richText_namespaceObject.removeFormat)(value, 'core/link'); |
|
816 |
onChange(newValue); |
|
817 |
stopAddingLink(); |
|
818 |
speak((0,external_wp_i18n_namespaceObject.__)('Link removed.'), 'assertive'); |
|
819 |
} |
|
820 |
|
16
|
821 |
function onChangeLink(nextValue) { |
|
822 |
// Merge with values from state, both for the purpose of assigning the |
|
823 |
// next state value, and for use in constructing the new link format if |
|
824 |
// the link is ready to be applied. |
18
|
825 |
nextValue = { ...nextLinkValue, |
|
826 |
...nextValue |
|
827 |
}; // LinkControl calls `onChange` immediately upon the toggling a setting. |
16
|
828 |
|
18
|
829 |
const didToggleSetting = linkValue.opensInNewTab !== nextValue.opensInNewTab && linkValue.url === nextValue.url; // If change handler was called as a result of a settings change during |
16
|
830 |
// link insertion, it must be held in state until the link is ready to |
|
831 |
// be applied. |
|
832 |
|
18
|
833 |
const didToggleSettingForNewLink = didToggleSetting && nextValue.url === undefined; // If link will be assigned, the state value can be considered flushed. |
16
|
834 |
// Otherwise, persist the pending changes. |
|
835 |
|
|
836 |
setNextLinkValue(didToggleSettingForNewLink ? nextValue : undefined); |
|
837 |
|
|
838 |
if (didToggleSettingForNewLink) { |
|
839 |
return; |
9
|
840 |
} |
16
|
841 |
|
19
|
842 |
const newUrl = (0,external_wp_url_namespaceObject.prependHTTP)(nextValue.url); |
|
843 |
const linkFormat = createLinkFormat({ |
16
|
844 |
url: newUrl, |
|
845 |
type: nextValue.type, |
|
846 |
id: nextValue.id !== undefined && nextValue.id !== null ? String(nextValue.id) : undefined, |
|
847 |
opensInNewWindow: nextValue.opensInNewTab |
|
848 |
}); |
19
|
849 |
const newText = nextValue.title || newUrl; |
16
|
850 |
|
19
|
851 |
if ((0,external_wp_richText_namespaceObject.isCollapsed)(value) && !isActive) { |
|
852 |
// Scenario: we don't have any actively selected text or formats. |
|
853 |
const toInsert = (0,external_wp_richText_namespaceObject.applyFormat)((0,external_wp_richText_namespaceObject.create)({ |
16
|
854 |
text: newText |
19
|
855 |
}), linkFormat, 0, newText.length); |
|
856 |
onChange((0,external_wp_richText_namespaceObject.insert)(value, toInsert)); |
16
|
857 |
} else { |
19
|
858 |
// Scenario: we have any active text selection or an active format. |
|
859 |
let newValue; |
|
860 |
|
|
861 |
if (newText === richTextText) { |
|
862 |
// If we're not updating the text then ignore. |
|
863 |
newValue = (0,external_wp_richText_namespaceObject.applyFormat)(value, linkFormat); |
|
864 |
} else { |
|
865 |
// Create new RichText value for the new text in order that we |
|
866 |
// can apply formats to it. |
|
867 |
newValue = (0,external_wp_richText_namespaceObject.create)({ |
|
868 |
text: newText |
|
869 |
}); // Apply the new Link format to this new text value. |
|
870 |
|
|
871 |
newValue = (0,external_wp_richText_namespaceObject.applyFormat)(newValue, linkFormat, 0, newText.length); // Update the original (full) RichTextValue replacing the |
|
872 |
// target text with the *new* RichTextValue containing: |
|
873 |
// 1. The new text content. |
|
874 |
// 2. The new link format. |
|
875 |
// Note original formats will be lost when applying this change. |
|
876 |
// That is expected behaviour. |
|
877 |
// See: https://github.com/WordPress/gutenberg/pull/33849#issuecomment-936134179. |
|
878 |
|
|
879 |
newValue = (0,external_wp_richText_namespaceObject.replace)(value, richTextText, newValue); |
|
880 |
} |
|
881 |
|
16
|
882 |
newValue.start = newValue.end; |
|
883 |
newValue.activeFormats = []; |
|
884 |
onChange(newValue); |
|
885 |
} // Focus should only be shifted back to the formatted segment when the |
|
886 |
// URL is submitted. |
|
887 |
|
|
888 |
|
|
889 |
if (!didToggleSetting) { |
|
890 |
stopAddingLink(); |
9
|
891 |
} |
16
|
892 |
|
|
893 |
if (!isValidHref(newUrl)) { |
19
|
894 |
speak((0,external_wp_i18n_namespaceObject.__)('Warning: the link has been inserted but may have errors. Please test it.'), 'assertive'); |
16
|
895 |
} else if (isActive) { |
19
|
896 |
speak((0,external_wp_i18n_namespaceObject.__)('Link edited.'), 'assertive'); |
16
|
897 |
} else { |
19
|
898 |
speak((0,external_wp_i18n_namespaceObject.__)('Link inserted.'), 'assertive'); |
9
|
899 |
} |
16
|
900 |
} |
|
901 |
|
19
|
902 |
const anchorRef = (0,external_wp_richText_namespaceObject.useAnchorRef)({ |
18
|
903 |
ref: contentRef, |
|
904 |
value, |
19
|
905 |
settings: build_module_link_link |
|
906 |
}); // Generate a string based key that is unique to this anchor reference. |
|
907 |
// This is used to force re-mount the LinkControl component to avoid |
|
908 |
// potential stale state bugs caused by the component not being remounted |
|
909 |
// See https://github.com/WordPress/gutenberg/pull/34742. |
|
910 |
|
|
911 |
const forceRemountKey = use_link_instance_key(anchorRef); // The focusOnMount prop shouldn't evolve during render of a Popover |
18
|
912 |
// otherwise it causes a render of the content. |
|
913 |
|
19
|
914 |
const focusOnMount = (0,external_wp_element_namespaceObject.useRef)(addingLink ? 'firstElement' : false); |
|
915 |
|
|
916 |
async function handleCreate(pageTitle) { |
|
917 |
const page = await createPageEntity({ |
|
918 |
title: pageTitle, |
|
919 |
status: 'draft' |
|
920 |
}); |
|
921 |
return { |
|
922 |
id: page.id, |
|
923 |
type: page.type, |
|
924 |
title: page.title.rendered, |
|
925 |
url: page.link, |
|
926 |
kind: 'post-type' |
|
927 |
}; |
|
928 |
} |
|
929 |
|
|
930 |
function createButtonText(searchTerm) { |
|
931 |
return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( |
|
932 |
/* translators: %s: search term. */ |
|
933 |
(0,external_wp_i18n_namespaceObject.__)('Create Page: <mark>%s</mark>'), searchTerm), { |
|
934 |
mark: (0,external_wp_element_namespaceObject.createElement)("mark", null) |
|
935 |
}); |
|
936 |
} |
|
937 |
|
|
938 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { |
16
|
939 |
anchorRef: anchorRef, |
18
|
940 |
focusOnMount: focusOnMount.current, |
16
|
941 |
onClose: stopAddingLink, |
|
942 |
position: "bottom center" |
19
|
943 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLinkControl, { |
|
944 |
key: forceRemountKey, |
16
|
945 |
value: linkValue, |
|
946 |
onChange: onChangeLink, |
19
|
947 |
onRemove: removeLink, |
|
948 |
forceIsEditingLink: addingLink, |
|
949 |
hasRichPreviews: true, |
|
950 |
createSuggestion: createPageEntity && handleCreate, |
|
951 |
withCreateSuggestion: userCanCreatePages, |
|
952 |
createSuggestionButtonText: createButtonText, |
|
953 |
hasTextControl: true |
16
|
954 |
})); |
|
955 |
} |
|
956 |
|
19
|
957 |
function getRichTextValueFromSelection(value, isActive) { |
|
958 |
// Default to the selection ranges on the RichTextValue object. |
|
959 |
let textStart = value.start; |
|
960 |
let textEnd = value.end; // If the format is currently active then the rich text value |
|
961 |
// should always be taken from the bounds of the active format |
|
962 |
// and not the selected text. |
9
|
963 |
|
19
|
964 |
if (isActive) { |
|
965 |
const boundary = getFormatBoundary(value, { |
|
966 |
type: 'core/link' |
|
967 |
}); |
|
968 |
textStart = boundary.start; // Text *selection* always extends +1 beyond the edge of the format. |
|
969 |
// We account for that here. |
|
970 |
|
|
971 |
textEnd = boundary.end + 1; |
|
972 |
} // Get a RichTextValue containing the selected text content. |
|
973 |
|
|
974 |
|
|
975 |
return (0,external_wp_richText_namespaceObject.slice)(value, textStart, textEnd); |
|
976 |
} |
|
977 |
|
|
978 |
/* harmony default export */ var inline = ((0,external_wp_components_namespaceObject.withSpokenMessages)(InlineLinkUI)); |
|
979 |
|
|
980 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/index.js |
9
|
981 |
|
|
982 |
|
|
983 |
/** |
|
984 |
* WordPress dependencies |
|
985 |
*/ |
|
986 |
|
|
987 |
|
|
988 |
|
|
989 |
|
|
990 |
|
|
991 |
|
16
|
992 |
|
|
993 |
|
9
|
994 |
/** |
|
995 |
* Internal dependencies |
|
996 |
*/ |
|
997 |
|
|
998 |
|
19
|
999 |
|
18
|
1000 |
const link_name = 'core/link'; |
|
1001 |
|
19
|
1002 |
const link_title = (0,external_wp_i18n_namespaceObject.__)('Link'); |
18
|
1003 |
|
19
|
1004 |
function link_Edit(_ref) { |
|
1005 |
let { |
|
1006 |
isActive, |
|
1007 |
activeAttributes, |
|
1008 |
value, |
|
1009 |
onChange, |
|
1010 |
onFocus, |
|
1011 |
contentRef |
|
1012 |
} = _ref; |
|
1013 |
const [addingLink, setAddingLink] = (0,external_wp_element_namespaceObject.useState)(false); |
18
|
1014 |
|
|
1015 |
function addLink() { |
19
|
1016 |
const text = (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.slice)(value)); |
18
|
1017 |
|
19
|
1018 |
if (text && (0,external_wp_url_namespaceObject.isURL)(text) && isValidHref(text)) { |
|
1019 |
onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, { |
18
|
1020 |
type: link_name, |
|
1021 |
attributes: { |
|
1022 |
url: text |
|
1023 |
} |
|
1024 |
})); |
19
|
1025 |
} else if (text && (0,external_wp_url_namespaceObject.isEmail)(text)) { |
|
1026 |
onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, { |
18
|
1027 |
type: link_name, |
|
1028 |
attributes: { |
|
1029 |
url: `mailto:${text}` |
|
1030 |
} |
|
1031 |
})); |
|
1032 |
} else { |
|
1033 |
setAddingLink(true); |
|
1034 |
} |
|
1035 |
} |
|
1036 |
|
|
1037 |
function stopAddingLink() { |
|
1038 |
setAddingLink(false); |
|
1039 |
onFocus(); |
|
1040 |
} |
16
|
1041 |
|
18
|
1042 |
function onRemoveFormat() { |
19
|
1043 |
onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, link_name)); |
|
1044 |
(0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link removed.'), 'assertive'); |
18
|
1045 |
} |
16
|
1046 |
|
19
|
1047 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
18
|
1048 |
type: "primary", |
|
1049 |
character: "k", |
|
1050 |
onUse: addLink |
19
|
1051 |
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
18
|
1052 |
type: "primaryShift", |
|
1053 |
character: "k", |
|
1054 |
onUse: onRemoveFormat |
19
|
1055 |
}), isActive && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
18
|
1056 |
name: "link", |
19
|
1057 |
icon: link_off, |
|
1058 |
title: (0,external_wp_i18n_namespaceObject.__)('Unlink'), |
18
|
1059 |
onClick: onRemoveFormat, |
|
1060 |
isActive: isActive, |
|
1061 |
shortcutType: "primaryShift", |
|
1062 |
shortcutCharacter: "k" |
19
|
1063 |
}), !isActive && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
18
|
1064 |
name: "link", |
19
|
1065 |
icon: library_link, |
18
|
1066 |
title: link_title, |
|
1067 |
onClick: addLink, |
|
1068 |
isActive: isActive, |
|
1069 |
shortcutType: "primary", |
|
1070 |
shortcutCharacter: "k" |
19
|
1071 |
}), (addingLink || isActive) && (0,external_wp_element_namespaceObject.createElement)(inline, { |
18
|
1072 |
addingLink: addingLink, |
|
1073 |
stopAddingLink: stopAddingLink, |
|
1074 |
isActive: isActive, |
|
1075 |
activeAttributes: activeAttributes, |
|
1076 |
value: value, |
|
1077 |
onChange: onChange, |
|
1078 |
contentRef: contentRef |
|
1079 |
})); |
|
1080 |
} |
|
1081 |
|
19
|
1082 |
const build_module_link_link = { |
9
|
1083 |
name: link_name, |
16
|
1084 |
title: link_title, |
9
|
1085 |
tagName: 'a', |
|
1086 |
className: null, |
|
1087 |
attributes: { |
|
1088 |
url: 'href', |
16
|
1089 |
type: 'data-type', |
|
1090 |
id: 'data-id', |
9
|
1091 |
target: 'target' |
|
1092 |
}, |
16
|
1093 |
|
19
|
1094 |
__unstablePasteRule(value, _ref2) { |
|
1095 |
let { |
|
1096 |
html, |
|
1097 |
plainText |
|
1098 |
} = _ref2; |
|
1099 |
|
|
1100 |
if ((0,external_wp_richText_namespaceObject.isCollapsed)(value)) { |
16
|
1101 |
return value; |
|
1102 |
} |
|
1103 |
|
19
|
1104 |
const pastedText = (html || plainText).replace(/<[^>]+>/g, '').trim(); // A URL was pasted, turn the selection into a link. |
16
|
1105 |
|
19
|
1106 |
if (!(0,external_wp_url_namespaceObject.isURL)(pastedText)) { |
16
|
1107 |
return value; |
|
1108 |
} // Allows us to ask for this information when we get a report. |
|
1109 |
|
|
1110 |
|
|
1111 |
window.console.log('Created link:\n\n', pastedText); |
19
|
1112 |
return (0,external_wp_richText_namespaceObject.applyFormat)(value, { |
16
|
1113 |
type: link_name, |
|
1114 |
attributes: { |
19
|
1115 |
url: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(pastedText) |
16
|
1116 |
} |
|
1117 |
}); |
|
1118 |
}, |
9
|
1119 |
|
18
|
1120 |
edit: link_Edit |
9
|
1121 |
}; |
|
1122 |
|
19
|
1123 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-strikethrough.js |
|
1124 |
|
|
1125 |
|
|
1126 |
/** |
|
1127 |
* WordPress dependencies |
|
1128 |
*/ |
16
|
1129 |
|
19
|
1130 |
const formatStrikethrough = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
1131 |
xmlns: "http://www.w3.org/2000/svg", |
|
1132 |
viewBox: "0 0 24 24" |
|
1133 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
|
1134 |
d: "M9.1 9v-.5c0-.6.2-1.1.7-1.4.5-.3 1.2-.5 2-.5.7 0 1.4.1 2.1.3.7.2 1.4.5 2.1.9l.2-1.9c-.6-.3-1.2-.5-1.9-.7-.8-.1-1.6-.2-2.4-.2-1.5 0-2.7.3-3.6 1-.8.7-1.2 1.5-1.2 2.6V9h2zM20 12H4v1h8.3c.3.1.6.2.8.3.5.2.9.5 1.1.8.3.3.4.7.4 1.2 0 .7-.2 1.1-.8 1.5-.5.3-1.2.5-2.1.5-.8 0-1.6-.1-2.4-.3-.8-.2-1.5-.5-2.2-.8L7 18.1c.5.2 1.2.4 2 .6.8.2 1.6.3 2.4.3 1.7 0 3-.3 3.9-1 .9-.7 1.3-1.6 1.3-2.8 0-.9-.2-1.7-.7-2.2H20v-1z" |
|
1135 |
})); |
|
1136 |
/* harmony default export */ var format_strikethrough = (formatStrikethrough); |
|
1137 |
|
|
1138 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/strikethrough/index.js |
9
|
1139 |
|
|
1140 |
|
|
1141 |
/** |
|
1142 |
* WordPress dependencies |
|
1143 |
*/ |
|
1144 |
|
|
1145 |
|
|
1146 |
|
|
1147 |
|
18
|
1148 |
const strikethrough_name = 'core/strikethrough'; |
16
|
1149 |
|
19
|
1150 |
const strikethrough_title = (0,external_wp_i18n_namespaceObject.__)('Strikethrough'); |
16
|
1151 |
|
18
|
1152 |
const strikethrough = { |
9
|
1153 |
name: strikethrough_name, |
16
|
1154 |
title: strikethrough_title, |
9
|
1155 |
tagName: 's', |
|
1156 |
className: null, |
16
|
1157 |
|
19
|
1158 |
edit(_ref) { |
|
1159 |
let { |
|
1160 |
isActive, |
|
1161 |
value, |
|
1162 |
onChange, |
|
1163 |
onFocus |
|
1164 |
} = _ref; |
|
1165 |
|
16
|
1166 |
function onClick() { |
19
|
1167 |
onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
|
1168 |
type: strikethrough_name, |
|
1169 |
title: strikethrough_title |
9
|
1170 |
})); |
16
|
1171 |
onFocus(); |
|
1172 |
} |
|
1173 |
|
19
|
1174 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
|
1175 |
icon: format_strikethrough, |
16
|
1176 |
title: strikethrough_title, |
|
1177 |
onClick: onClick, |
19
|
1178 |
isActive: isActive, |
|
1179 |
role: "menuitemcheckbox" |
16
|
1180 |
}); |
9
|
1181 |
} |
18
|
1182 |
|
9
|
1183 |
}; |
|
1184 |
|
19
|
1185 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/underline/index.js |
9
|
1186 |
|
|
1187 |
|
|
1188 |
/** |
|
1189 |
* WordPress dependencies |
|
1190 |
*/ |
|
1191 |
|
|
1192 |
|
|
1193 |
|
18
|
1194 |
const underline_name = 'core/underline'; |
19
|
1195 |
|
|
1196 |
const underline_title = (0,external_wp_i18n_namespaceObject.__)('Underline'); |
|
1197 |
|
18
|
1198 |
const underline = { |
9
|
1199 |
name: underline_name, |
19
|
1200 |
title: underline_title, |
9
|
1201 |
tagName: 'span', |
|
1202 |
className: null, |
|
1203 |
attributes: { |
|
1204 |
style: 'style' |
|
1205 |
}, |
|
1206 |
|
19
|
1207 |
edit(_ref) { |
|
1208 |
let { |
|
1209 |
value, |
|
1210 |
onChange |
|
1211 |
} = _ref; |
|
1212 |
|
18
|
1213 |
const onToggle = () => { |
19
|
1214 |
onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
9
|
1215 |
type: underline_name, |
|
1216 |
attributes: { |
|
1217 |
style: 'text-decoration: underline;' |
19
|
1218 |
}, |
|
1219 |
title: underline_title |
9
|
1220 |
})); |
|
1221 |
}; |
|
1222 |
|
19
|
1223 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
9
|
1224 |
type: "primary", |
|
1225 |
character: "u", |
|
1226 |
onUse: onToggle |
19
|
1227 |
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { |
9
|
1228 |
inputType: "formatUnderline", |
|
1229 |
onInput: onToggle |
|
1230 |
})); |
|
1231 |
} |
18
|
1232 |
|
9
|
1233 |
}; |
|
1234 |
|
19
|
1235 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js |
|
1236 |
/** |
|
1237 |
* WordPress dependencies |
|
1238 |
*/ |
|
1239 |
|
|
1240 |
/** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ |
|
1241 |
|
|
1242 |
/** |
|
1243 |
* Return an SVG icon. |
|
1244 |
* |
|
1245 |
* @param {IconProps} props icon is the SVG component to render |
|
1246 |
* size is a number specifiying the icon size in pixels |
|
1247 |
* Other props will be passed to wrapped SVG component |
|
1248 |
* |
|
1249 |
* @return {JSX.Element} Icon component |
|
1250 |
*/ |
16
|
1251 |
|
19
|
1252 |
function Icon(_ref) { |
|
1253 |
let { |
|
1254 |
icon, |
|
1255 |
size = 24, |
|
1256 |
...props |
|
1257 |
} = _ref; |
|
1258 |
return (0,external_wp_element_namespaceObject.cloneElement)(icon, { |
|
1259 |
width: size, |
|
1260 |
height: size, |
|
1261 |
...props |
|
1262 |
}); |
|
1263 |
} |
|
1264 |
|
|
1265 |
/* harmony default export */ var icon = (Icon); |
16
|
1266 |
|
19
|
1267 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/text-color.js |
|
1268 |
|
|
1269 |
|
|
1270 |
/** |
|
1271 |
* WordPress dependencies |
|
1272 |
*/ |
16
|
1273 |
|
19
|
1274 |
const textColor = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
1275 |
xmlns: "http://www.w3.org/2000/svg", |
|
1276 |
viewBox: "0 0 24 24" |
|
1277 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
|
1278 |
d: "M12.9 6h-2l-4 11h1.9l1.1-3h4.2l1.1 3h1.9L12.9 6zm-2.5 6.5l1.5-4.9 1.7 4.9h-3.2z" |
|
1279 |
})); |
|
1280 |
/* harmony default export */ var text_color = (textColor); |
|
1281 |
|
|
1282 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/text-color/inline.js |
16
|
1283 |
|
|
1284 |
|
18
|
1285 |
/** |
|
1286 |
* External dependencies |
|
1287 |
*/ |
|
1288 |
|
|
1289 |
/** |
|
1290 |
* WordPress dependencies |
|
1291 |
*/ |
|
1292 |
|
|
1293 |
|
|
1294 |
|
|
1295 |
|
|
1296 |
|
19
|
1297 |
|
|
1298 |
|
18
|
1299 |
/** |
|
1300 |
* Internal dependencies |
|
1301 |
*/ |
|
1302 |
|
|
1303 |
|
19
|
1304 |
|
|
1305 |
function parseCSS() { |
|
1306 |
let css = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; |
|
1307 |
return css.split(';').reduce((accumulator, rule) => { |
|
1308 |
if (rule) { |
|
1309 |
const [property, value] = rule.split(':'); |
|
1310 |
if (property === 'color') accumulator.color = value; |
|
1311 |
if (property === 'background-color' && value !== transparentValue) accumulator.backgroundColor = value; |
|
1312 |
} |
|
1313 |
|
|
1314 |
return accumulator; |
|
1315 |
}, {}); |
|
1316 |
} |
|
1317 |
|
|
1318 |
function parseClassName() { |
|
1319 |
let className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; |
|
1320 |
let colorSettings = arguments.length > 1 ? arguments[1] : undefined; |
|
1321 |
return className.split(' ').reduce((accumulator, name) => { |
|
1322 |
// `colorSlug` could contain dashes, so simply match the start and end. |
|
1323 |
if (name.startsWith('has-') && name.endsWith('-color')) { |
|
1324 |
const colorSlug = name.replace(/^has-/, '').replace(/-color$/, ''); |
|
1325 |
const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues)(colorSettings, colorSlug); |
|
1326 |
accumulator.color = colorObject.color; |
|
1327 |
} |
|
1328 |
|
|
1329 |
return accumulator; |
|
1330 |
}, {}); |
|
1331 |
} |
|
1332 |
function getActiveColors(value, name, colorSettings) { |
|
1333 |
const activeColorFormat = (0,external_wp_richText_namespaceObject.getActiveFormat)(value, name); |
18
|
1334 |
|
|
1335 |
if (!activeColorFormat) { |
19
|
1336 |
return {}; |
18
|
1337 |
} |
|
1338 |
|
19
|
1339 |
return { ...parseCSS(activeColorFormat.attributes.style), |
|
1340 |
...parseClassName(activeColorFormat.attributes.class, colorSettings) |
|
1341 |
}; |
18
|
1342 |
} |
|
1343 |
|
19
|
1344 |
function setColors(value, name, colorSettings, colors) { |
|
1345 |
const { |
|
1346 |
color, |
|
1347 |
backgroundColor |
|
1348 |
} = { ...getActiveColors(value, name, colorSettings), |
|
1349 |
...colors |
|
1350 |
}; |
|
1351 |
|
|
1352 |
if (!color && !backgroundColor) { |
|
1353 |
return (0,external_wp_richText_namespaceObject.removeFormat)(value, name); |
|
1354 |
} |
|
1355 |
|
|
1356 |
const styles = []; |
|
1357 |
const classNames = []; |
|
1358 |
const attributes = {}; |
|
1359 |
|
|
1360 |
if (backgroundColor) { |
|
1361 |
styles.push(['background-color', backgroundColor].join(':')); |
|
1362 |
} else { |
|
1363 |
// Override default browser color for mark element. |
|
1364 |
styles.push(['background-color', transparentValue].join(':')); |
|
1365 |
} |
|
1366 |
|
|
1367 |
if (color) { |
|
1368 |
const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByColorValue)(colorSettings, color); |
|
1369 |
|
|
1370 |
if (colorObject) { |
|
1371 |
classNames.push((0,external_wp_blockEditor_namespaceObject.getColorClassName)('color', colorObject.slug)); |
|
1372 |
} else { |
|
1373 |
styles.push(['color', color].join(':')); |
|
1374 |
} |
|
1375 |
} |
|
1376 |
|
|
1377 |
if (styles.length) attributes.style = styles.join(';'); |
|
1378 |
if (classNames.length) attributes.class = classNames.join(' '); |
|
1379 |
return (0,external_wp_richText_namespaceObject.applyFormat)(value, { |
|
1380 |
type: name, |
|
1381 |
attributes |
|
1382 |
}); |
|
1383 |
} |
|
1384 |
|
|
1385 |
function ColorPicker(_ref) { |
|
1386 |
let { |
|
1387 |
name, |
|
1388 |
property, |
|
1389 |
value, |
|
1390 |
onChange |
|
1391 |
} = _ref; |
|
1392 |
const colors = (0,external_wp_data_namespaceObject.useSelect)(select => { |
18
|
1393 |
const { |
|
1394 |
getSettings |
19
|
1395 |
} = select(external_wp_blockEditor_namespaceObject.store); |
|
1396 |
return (0,external_lodash_namespaceObject.get)(getSettings(), ['colors'], []); |
|
1397 |
}, []); |
|
1398 |
const onColorChange = (0,external_wp_element_namespaceObject.useCallback)(color => { |
|
1399 |
onChange(setColors(value, name, colors, { |
|
1400 |
[property]: color |
|
1401 |
})); |
|
1402 |
}, [colors, onChange, property]); |
|
1403 |
const activeColors = (0,external_wp_element_namespaceObject.useMemo)(() => getActiveColors(value, name, colors), [name, value, colors]); |
|
1404 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.ColorPalette, { |
|
1405 |
value: activeColors[property], |
18
|
1406 |
onChange: onColorChange |
|
1407 |
}); |
19
|
1408 |
} |
18
|
1409 |
|
19
|
1410 |
function InlineColorUI(_ref2) { |
|
1411 |
let { |
|
1412 |
name, |
|
1413 |
value, |
|
1414 |
onChange, |
|
1415 |
onClose, |
|
1416 |
contentRef |
|
1417 |
} = _ref2; |
|
1418 |
|
|
1419 |
/* |
|
1420 |
As you change the text color by typing a HEX value into a field, |
|
1421 |
the return value of document.getSelection jumps to the field you're editing, |
|
1422 |
not the highlighted text. Given that useAnchorRef uses document.getSelection, |
|
1423 |
it will return null, since it can't find the <mark> element within the HEX input. |
|
1424 |
This caches the last truthy value of the selection anchor reference. |
|
1425 |
*/ |
|
1426 |
const anchorRef = (0,external_wp_blockEditor_namespaceObject.useCachedTruthy)((0,external_wp_richText_namespaceObject.useAnchorRef)({ |
18
|
1427 |
ref: contentRef, |
|
1428 |
value, |
19
|
1429 |
settings: text_color_textColor |
|
1430 |
})); |
|
1431 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { |
18
|
1432 |
onClose: onClose, |
|
1433 |
className: "components-inline-color-popover", |
|
1434 |
anchorRef: anchorRef |
19
|
1435 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, { |
|
1436 |
tabs: [{ |
|
1437 |
name: 'color', |
|
1438 |
title: (0,external_wp_i18n_namespaceObject.__)('Text') |
|
1439 |
}, { |
|
1440 |
name: 'backgroundColor', |
|
1441 |
title: (0,external_wp_i18n_namespaceObject.__)('Background') |
|
1442 |
}] |
|
1443 |
}, tab => (0,external_wp_element_namespaceObject.createElement)(ColorPicker, { |
18
|
1444 |
name: name, |
19
|
1445 |
property: tab.name, |
18
|
1446 |
value: value, |
|
1447 |
onChange: onChange |
19
|
1448 |
}))); |
18
|
1449 |
} |
|
1450 |
|
19
|
1451 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/text-color/index.js |
16
|
1452 |
|
|
1453 |
|
|
1454 |
/** |
|
1455 |
* External dependencies |
|
1456 |
*/ |
|
1457 |
|
|
1458 |
/** |
|
1459 |
* WordPress dependencies |
|
1460 |
*/ |
|
1461 |
|
|
1462 |
|
|
1463 |
|
|
1464 |
|
|
1465 |
|
|
1466 |
|
|
1467 |
/** |
|
1468 |
* Internal dependencies |
|
1469 |
*/ |
|
1470 |
|
|
1471 |
|
19
|
1472 |
const transparentValue = 'rgba(0, 0, 0, 0)'; |
18
|
1473 |
const text_color_name = 'core/text-color'; |
16
|
1474 |
|
19
|
1475 |
const text_color_title = (0,external_wp_i18n_namespaceObject.__)('Highlight'); |
16
|
1476 |
|
18
|
1477 |
const EMPTY_ARRAY = []; |
16
|
1478 |
|
19
|
1479 |
function getComputedStyleProperty(element, property) { |
|
1480 |
const { |
|
1481 |
ownerDocument |
|
1482 |
} = element; |
|
1483 |
const { |
|
1484 |
defaultView |
|
1485 |
} = ownerDocument; |
|
1486 |
const style = defaultView.getComputedStyle(element); |
|
1487 |
const value = style.getPropertyValue(property); |
|
1488 |
|
|
1489 |
if (property === 'background-color' && value === transparentValue && element.parentElement) { |
|
1490 |
return getComputedStyleProperty(element.parentElement, property); |
|
1491 |
} |
|
1492 |
|
|
1493 |
return value; |
|
1494 |
} |
|
1495 |
|
|
1496 |
function fillComputedColors(element, _ref) { |
|
1497 |
let { |
|
1498 |
color, |
|
1499 |
backgroundColor |
|
1500 |
} = _ref; |
16
|
1501 |
|
19
|
1502 |
if (!color && !backgroundColor) { |
|
1503 |
return; |
|
1504 |
} |
|
1505 |
|
|
1506 |
return { |
|
1507 |
color: color || getComputedStyleProperty(element, 'color'), |
|
1508 |
backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element, 'background-color') : backgroundColor |
|
1509 |
}; |
|
1510 |
} |
16
|
1511 |
|
19
|
1512 |
function TextColorEdit(_ref2) { |
|
1513 |
let { |
|
1514 |
value, |
|
1515 |
onChange, |
|
1516 |
isActive, |
|
1517 |
activeAttributes, |
|
1518 |
contentRef |
|
1519 |
} = _ref2; |
|
1520 |
const allowCustomControl = (0,external_wp_blockEditor_namespaceObject.useSetting)('color.custom'); |
|
1521 |
const colors = (0,external_wp_blockEditor_namespaceObject.useSetting)('color.palette') || EMPTY_ARRAY; |
|
1522 |
const [isAddingColor, setIsAddingColor] = (0,external_wp_element_namespaceObject.useState)(false); |
|
1523 |
const enableIsAddingColor = (0,external_wp_element_namespaceObject.useCallback)(() => setIsAddingColor(true), [setIsAddingColor]); |
|
1524 |
const disableIsAddingColor = (0,external_wp_element_namespaceObject.useCallback)(() => setIsAddingColor(false), [setIsAddingColor]); |
|
1525 |
const colorIndicatorStyle = (0,external_wp_element_namespaceObject.useMemo)(() => fillComputedColors(contentRef.current, getActiveColors(value, text_color_name, colors)), [value, colors]); |
|
1526 |
const hasColorsToChoose = !(0,external_lodash_namespaceObject.isEmpty)(colors) || !allowCustomControl; |
16
|
1527 |
|
|
1528 |
if (!hasColorsToChoose && !isActive) { |
|
1529 |
return null; |
|
1530 |
} |
|
1531 |
|
19
|
1532 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
16
|
1533 |
className: "format-library-text-color-button", |
19
|
1534 |
isActive: isActive, |
|
1535 |
icon: (0,external_wp_element_namespaceObject.createElement)(icon, { |
|
1536 |
icon: text_color, |
16
|
1537 |
style: colorIndicatorStyle |
19
|
1538 |
}), |
|
1539 |
title: text_color_title // If has no colors to choose but a color is active remove the color onClick. |
16
|
1540 |
, |
19
|
1541 |
onClick: hasColorsToChoose ? enableIsAddingColor : () => onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, text_color_name)), |
|
1542 |
role: "menuitemcheckbox" |
|
1543 |
}), isAddingColor && (0,external_wp_element_namespaceObject.createElement)(InlineColorUI, { |
16
|
1544 |
name: text_color_name, |
|
1545 |
onClose: disableIsAddingColor, |
|
1546 |
activeAttributes: activeAttributes, |
|
1547 |
value: value, |
18
|
1548 |
onChange: onChange, |
|
1549 |
contentRef: contentRef |
16
|
1550 |
})); |
|
1551 |
} |
|
1552 |
|
19
|
1553 |
const text_color_textColor = { |
16
|
1554 |
name: text_color_name, |
|
1555 |
title: text_color_title, |
19
|
1556 |
tagName: 'mark', |
16
|
1557 |
className: 'has-inline-color', |
|
1558 |
attributes: { |
|
1559 |
style: 'style', |
|
1560 |
class: 'class' |
|
1561 |
}, |
19
|
1562 |
|
|
1563 |
/* |
|
1564 |
* Since this format relies on the <mark> tag, it's important to |
|
1565 |
* prevent the default yellow background color applied by most |
|
1566 |
* browsers. The solution is to detect when this format is used with a |
|
1567 |
* text color but no background color, and in such cases to override |
|
1568 |
* the default styling with a transparent background. |
|
1569 |
* |
|
1570 |
* @see https://github.com/WordPress/gutenberg/pull/35516 |
|
1571 |
*/ |
|
1572 |
__unstableFilterAttributeValue(key, value) { |
|
1573 |
if (key !== 'style') return value; // We should not add a background-color if it's already set. |
|
1574 |
|
|
1575 |
if (value && value.includes('background-color')) return value; |
|
1576 |
const addedCSS = ['background-color', transparentValue].join(':'); // Prepend `addedCSS` to avoid a double `;;` as any the existing CSS |
|
1577 |
// rules will already include a `;`. |
|
1578 |
|
|
1579 |
return value ? [addedCSS, value].join(';') : addedCSS; |
|
1580 |
}, |
|
1581 |
|
16
|
1582 |
edit: TextColorEdit |
|
1583 |
}; |
|
1584 |
|
19
|
1585 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/subscript.js |
16
|
1586 |
|
|
1587 |
|
|
1588 |
/** |
|
1589 |
* WordPress dependencies |
|
1590 |
*/ |
|
1591 |
|
19
|
1592 |
const subscript = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
16
|
1593 |
xmlns: "http://www.w3.org/2000/svg", |
|
1594 |
viewBox: "0 0 24 24" |
19
|
1595 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
16
|
1596 |
d: "M16.9 18.3l.8-1.2c.4-.6.7-1.2.9-1.6.2-.4.3-.8.3-1.2 0-.3-.1-.7-.2-1-.1-.3-.4-.5-.6-.7-.3-.2-.6-.3-1-.3s-.8.1-1.1.2c-.3.1-.7.3-1 .6l.2 1.3c.3-.3.5-.5.8-.6s.6-.2.9-.2c.3 0 .5.1.7.2.2.2.2.4.2.7 0 .3-.1.5-.2.8-.1.3-.4.7-.8 1.3L15 19.4h4.3v-1.2h-2.4zM14.1 7.2h-2L9.5 11 6.9 7.2h-2l3.6 5.3L4.7 18h2l2.7-4 2.7 4h2l-3.8-5.5 3.8-5.3z" |
|
1597 |
})); |
|
1598 |
/* harmony default export */ var library_subscript = (subscript); |
|
1599 |
|
19
|
1600 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/subscript/index.js |
16
|
1601 |
|
|
1602 |
|
|
1603 |
/** |
|
1604 |
* WordPress dependencies |
|
1605 |
*/ |
|
1606 |
|
|
1607 |
|
|
1608 |
|
|
1609 |
|
18
|
1610 |
const subscript_name = 'core/subscript'; |
16
|
1611 |
|
19
|
1612 |
const subscript_title = (0,external_wp_i18n_namespaceObject.__)('Subscript'); |
16
|
1613 |
|
18
|
1614 |
const subscript_subscript = { |
16
|
1615 |
name: subscript_name, |
|
1616 |
title: subscript_title, |
|
1617 |
tagName: 'sub', |
|
1618 |
className: null, |
|
1619 |
|
19
|
1620 |
edit(_ref) { |
|
1621 |
let { |
|
1622 |
isActive, |
|
1623 |
value, |
|
1624 |
onChange, |
|
1625 |
onFocus |
|
1626 |
} = _ref; |
|
1627 |
|
16
|
1628 |
function onToggle() { |
19
|
1629 |
onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
|
1630 |
type: subscript_name, |
|
1631 |
title: subscript_title |
16
|
1632 |
})); |
|
1633 |
} |
|
1634 |
|
|
1635 |
function onClick() { |
|
1636 |
onToggle(); |
|
1637 |
onFocus(); |
|
1638 |
} |
|
1639 |
|
19
|
1640 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
16
|
1641 |
icon: library_subscript, |
|
1642 |
title: subscript_title, |
|
1643 |
onClick: onClick, |
19
|
1644 |
isActive: isActive, |
|
1645 |
role: "menuitemcheckbox" |
16
|
1646 |
}); |
|
1647 |
} |
18
|
1648 |
|
16
|
1649 |
}; |
|
1650 |
|
19
|
1651 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/superscript.js |
16
|
1652 |
|
|
1653 |
|
|
1654 |
/** |
|
1655 |
* WordPress dependencies |
|
1656 |
*/ |
|
1657 |
|
19
|
1658 |
const superscript = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
16
|
1659 |
xmlns: "http://www.w3.org/2000/svg", |
|
1660 |
viewBox: "0 0 24 24" |
19
|
1661 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
16
|
1662 |
d: "M16.9 10.3l.8-1.3c.4-.6.7-1.2.9-1.6.2-.4.3-.8.3-1.2 0-.3-.1-.7-.2-1-.2-.2-.4-.4-.7-.6-.3-.2-.6-.3-1-.3s-.8.1-1.1.2c-.3.1-.7.3-1 .6l.1 1.3c.3-.3.5-.5.8-.6s.6-.2.9-.2c.3 0 .5.1.7.2.2.2.2.4.2.7 0 .3-.1.5-.2.8-.1.3-.4.7-.8 1.3l-1.8 2.8h4.3v-1.2h-2.2zm-2.8-3.1h-2L9.5 11 6.9 7.2h-2l3.6 5.3L4.7 18h2l2.7-4 2.7 4h2l-3.8-5.5 3.8-5.3z" |
|
1663 |
})); |
|
1664 |
/* harmony default export */ var library_superscript = (superscript); |
|
1665 |
|
19
|
1666 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/superscript/index.js |
16
|
1667 |
|
|
1668 |
|
|
1669 |
/** |
|
1670 |
* WordPress dependencies |
|
1671 |
*/ |
|
1672 |
|
|
1673 |
|
|
1674 |
|
|
1675 |
|
18
|
1676 |
const superscript_name = 'core/superscript'; |
16
|
1677 |
|
19
|
1678 |
const superscript_title = (0,external_wp_i18n_namespaceObject.__)('Superscript'); |
16
|
1679 |
|
18
|
1680 |
const superscript_superscript = { |
16
|
1681 |
name: superscript_name, |
|
1682 |
title: superscript_title, |
|
1683 |
tagName: 'sup', |
|
1684 |
className: null, |
|
1685 |
|
19
|
1686 |
edit(_ref) { |
|
1687 |
let { |
|
1688 |
isActive, |
|
1689 |
value, |
|
1690 |
onChange, |
|
1691 |
onFocus |
|
1692 |
} = _ref; |
|
1693 |
|
16
|
1694 |
function onToggle() { |
19
|
1695 |
onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
|
1696 |
type: superscript_name, |
|
1697 |
title: superscript_title |
16
|
1698 |
})); |
|
1699 |
} |
|
1700 |
|
|
1701 |
function onClick() { |
|
1702 |
onToggle(); |
|
1703 |
onFocus(); |
|
1704 |
} |
|
1705 |
|
19
|
1706 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
16
|
1707 |
icon: library_superscript, |
|
1708 |
title: superscript_title, |
|
1709 |
onClick: onClick, |
19
|
1710 |
isActive: isActive, |
|
1711 |
role: "menuitemcheckbox" |
16
|
1712 |
}); |
|
1713 |
} |
18
|
1714 |
|
|
1715 |
}; |
|
1716 |
|
19
|
1717 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/button.js |
|
1718 |
|
|
1719 |
|
|
1720 |
/** |
|
1721 |
* WordPress dependencies |
|
1722 |
*/ |
18
|
1723 |
|
19
|
1724 |
const button_button = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
1725 |
viewBox: "0 0 24 24", |
|
1726 |
xmlns: "http://www.w3.org/2000/svg" |
|
1727 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
|
1728 |
d: "M19 6.5H5c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-7c0-1.1-.9-2-2-2zm.5 9c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-7c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v7zM8 12.8h8v-1.5H8v1.5z" |
|
1729 |
})); |
|
1730 |
/* harmony default export */ var library_button = (button_button); |
|
1731 |
|
|
1732 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/keyboard/index.js |
18
|
1733 |
|
|
1734 |
|
|
1735 |
/** |
|
1736 |
* WordPress dependencies |
|
1737 |
*/ |
|
1738 |
|
|
1739 |
|
|
1740 |
|
|
1741 |
|
|
1742 |
const keyboard_name = 'core/keyboard'; |
|
1743 |
|
19
|
1744 |
const keyboard_title = (0,external_wp_i18n_namespaceObject.__)('Keyboard input'); |
18
|
1745 |
|
|
1746 |
const keyboard = { |
|
1747 |
name: keyboard_name, |
|
1748 |
title: keyboard_title, |
|
1749 |
tagName: 'kbd', |
|
1750 |
className: null, |
|
1751 |
|
19
|
1752 |
edit(_ref) { |
|
1753 |
let { |
|
1754 |
isActive, |
|
1755 |
value, |
|
1756 |
onChange, |
|
1757 |
onFocus |
|
1758 |
} = _ref; |
|
1759 |
|
18
|
1760 |
function onToggle() { |
19
|
1761 |
onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
|
1762 |
type: keyboard_name, |
|
1763 |
title: keyboard_title |
18
|
1764 |
})); |
|
1765 |
} |
|
1766 |
|
|
1767 |
function onClick() { |
|
1768 |
onToggle(); |
|
1769 |
onFocus(); |
|
1770 |
} |
|
1771 |
|
19
|
1772 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
|
1773 |
icon: library_button, |
18
|
1774 |
title: keyboard_title, |
|
1775 |
onClick: onClick, |
19
|
1776 |
isActive: isActive, |
|
1777 |
role: "menuitemcheckbox" |
18
|
1778 |
}); |
|
1779 |
} |
|
1780 |
|
16
|
1781 |
}; |
|
1782 |
|
19
|
1783 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/default-formats.js |
9
|
1784 |
/** |
|
1785 |
* Internal dependencies |
|
1786 |
*/ |
|
1787 |
|
|
1788 |
|
|
1789 |
|
|
1790 |
|
|
1791 |
|
|
1792 |
|
|
1793 |
|
16
|
1794 |
|
|
1795 |
|
|
1796 |
|
18
|
1797 |
|
19
|
1798 |
/* harmony default export */ var default_formats = ([bold, code_code, image_image, italic, build_module_link_link, strikethrough, underline, text_color_textColor, subscript_subscript, superscript_superscript, keyboard]); |
9
|
1799 |
|
19
|
1800 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/index.js |
9
|
1801 |
/** |
|
1802 |
* WordPress dependencies |
|
1803 |
*/ |
|
1804 |
|
|
1805 |
/** |
|
1806 |
* Internal dependencies |
|
1807 |
*/ |
|
1808 |
|
|
1809 |
|
19
|
1810 |
default_formats.forEach(_ref => { |
|
1811 |
let { |
|
1812 |
name, |
|
1813 |
...settings |
|
1814 |
} = _ref; |
|
1815 |
return (0,external_wp_richText_namespaceObject.registerFormatType)(name, settings); |
|
1816 |
}); |
9
|
1817 |
|
19
|
1818 |
(window.wp = window.wp || {}).formatLibrary = __webpack_exports__; |
|
1819 |
/******/ })() |
|
1820 |
; |