1 /******/ (function() { // webpackBootstrap |
1 /******/ (() => { // webpackBootstrap |
2 /******/ "use strict"; |
2 /******/ "use strict"; |
3 /******/ // The require scope |
3 /******/ // The require scope |
4 /******/ var __webpack_require__ = {}; |
4 /******/ var __webpack_require__ = {}; |
5 /******/ |
5 /******/ |
6 /************************************************************************/ |
6 /************************************************************************/ |
7 /******/ /* webpack/runtime/make namespace object */ |
7 /******/ /* webpack/runtime/make namespace object */ |
8 /******/ !function() { |
8 /******/ (() => { |
9 /******/ // define __esModule on exports |
9 /******/ // define __esModule on exports |
10 /******/ __webpack_require__.r = function(exports) { |
10 /******/ __webpack_require__.r = (exports) => { |
11 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
11 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
12 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
12 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
13 /******/ } |
13 /******/ } |
14 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
14 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
15 /******/ }; |
15 /******/ }; |
16 /******/ }(); |
16 /******/ })(); |
17 /******/ |
17 /******/ |
18 /************************************************************************/ |
18 /************************************************************************/ |
19 var __webpack_exports__ = {}; |
19 var __webpack_exports__ = {}; |
20 // ESM COMPAT FLAG |
20 // ESM COMPAT FLAG |
21 __webpack_require__.r(__webpack_exports__); |
21 __webpack_require__.r(__webpack_exports__); |
22 |
22 |
23 ;// CONCATENATED MODULE: external ["wp","richText"] |
23 ;// CONCATENATED MODULE: external ["wp","richText"] |
24 var external_wp_richText_namespaceObject = window["wp"]["richText"]; |
24 const 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"] |
25 ;// CONCATENATED MODULE: external ["wp","i18n"] |
28 var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
26 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
29 ;// CONCATENATED MODULE: external ["wp","blockEditor"] |
27 ;// CONCATENATED MODULE: external ["wp","blockEditor"] |
30 var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; |
28 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; |
31 ;// CONCATENATED MODULE: external ["wp","primitives"] |
29 ;// CONCATENATED MODULE: external ["wp","primitives"] |
32 var external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
30 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
|
31 ;// CONCATENATED MODULE: external "ReactJSXRuntime" |
|
32 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; |
33 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-bold.js |
33 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-bold.js |
34 |
34 /** |
35 |
35 * WordPress dependencies |
36 /** |
36 */ |
37 * WordPress dependencies |
37 |
38 */ |
38 |
39 |
39 const formatBold = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
40 const formatBold = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
41 xmlns: "http://www.w3.org/2000/svg", |
40 xmlns: "http://www.w3.org/2000/svg", |
42 viewBox: "0 0 24 24" |
41 viewBox: "0 0 24 24", |
43 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
42 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
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" |
43 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 })); |
44 }) |
46 /* harmony default export */ var format_bold = (formatBold); |
45 }); |
|
46 /* harmony default export */ const format_bold = (formatBold); |
47 |
47 |
48 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/bold/index.js |
48 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/bold/index.js |
49 |
49 /** |
50 |
50 * WordPress dependencies |
51 /** |
51 */ |
52 * WordPress dependencies |
52 |
53 */ |
53 |
|
54 |
54 |
55 |
55 |
56 |
56 |
57 |
57 |
58 |
58 const bold_name = 'core/bold'; |
59 const bold_name = 'core/bold'; |
59 |
|
60 const title = (0,external_wp_i18n_namespaceObject.__)('Bold'); |
60 const title = (0,external_wp_i18n_namespaceObject.__)('Bold'); |
61 |
|
62 const bold = { |
61 const bold = { |
63 name: bold_name, |
62 name: bold_name, |
64 title, |
63 title, |
65 tagName: 'strong', |
64 tagName: 'strong', |
66 className: null, |
65 className: null, |
67 |
66 edit({ |
68 edit(_ref) { |
67 isActive, |
69 let { |
68 value, |
70 isActive, |
69 onChange, |
71 value, |
70 onFocus |
72 onChange, |
71 }) { |
73 onFocus |
|
74 } = _ref; |
|
75 |
|
76 function onToggle() { |
72 function onToggle() { |
77 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
73 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
78 type: bold_name, |
74 type: bold_name, |
79 title |
75 title |
80 })); |
76 })); |
81 } |
77 } |
82 |
|
83 function onClick() { |
78 function onClick() { |
84 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
79 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
85 type: bold_name |
80 type: bold_name |
86 })); |
81 })); |
87 onFocus(); |
82 onFocus(); |
88 } |
83 } |
89 |
84 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
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, { |
85 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
91 type: "primary", |
86 type: "primary", |
92 character: "b", |
87 character: "b", |
93 onUse: onToggle |
88 onUse: onToggle |
94 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
89 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
95 name: "bold", |
90 name: "bold", |
96 icon: format_bold, |
91 icon: format_bold, |
97 title: title, |
92 title: title, |
98 onClick: onClick, |
93 onClick: onClick, |
99 isActive: isActive, |
94 isActive: isActive, |
100 shortcutType: "primary", |
95 shortcutType: "primary", |
101 shortcutCharacter: "b" |
96 shortcutCharacter: "b" |
102 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { |
97 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { |
103 inputType: "formatBold", |
98 inputType: "formatBold", |
104 onInput: onToggle |
99 onInput: onToggle |
105 })); |
100 })] |
106 } |
101 }); |
107 |
102 } |
108 }; |
103 }; |
109 |
104 |
110 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/code.js |
105 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/code.js |
111 |
106 /** |
112 |
107 * WordPress dependencies |
113 /** |
108 */ |
114 * WordPress dependencies |
109 |
115 */ |
110 |
116 |
111 const code = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
117 const code = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
118 viewBox: "0 0 24 24", |
112 viewBox: "0 0 24 24", |
119 xmlns: "http://www.w3.org/2000/svg" |
113 xmlns: "http://www.w3.org/2000/svg", |
120 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
114 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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" |
115 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 })); |
116 }) |
123 /* harmony default export */ var library_code = (code); |
117 }); |
|
118 /* harmony default export */ const library_code = (code); |
124 |
119 |
125 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/code/index.js |
120 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/code/index.js |
126 |
121 /** |
127 |
122 * WordPress dependencies |
128 /** |
123 */ |
129 * WordPress dependencies |
124 |
130 */ |
125 |
|
126 |
131 |
127 |
132 |
128 |
133 |
129 |
134 |
130 |
135 const code_name = 'core/code'; |
131 const code_name = 'core/code'; |
136 |
|
137 const code_title = (0,external_wp_i18n_namespaceObject.__)('Inline code'); |
132 const code_title = (0,external_wp_i18n_namespaceObject.__)('Inline code'); |
138 |
|
139 const code_code = { |
133 const code_code = { |
140 name: code_name, |
134 name: code_name, |
141 title: code_title, |
135 title: code_title, |
142 tagName: 'code', |
136 tagName: 'code', |
143 className: null, |
137 className: null, |
144 |
|
145 __unstableInputRule(value) { |
138 __unstableInputRule(value) { |
146 const BACKTICK = '`'; |
139 const BACKTICK = '`'; |
147 const { |
140 const { |
148 start, |
141 start, |
149 text |
142 text |
150 } = value; |
143 } = value; |
151 const characterBefore = text.slice(start - 1, start); // Quick check the text for the necessary character. |
144 const characterBefore = text[start - 1]; |
152 |
145 |
|
146 // Quick check the text for the necessary character. |
153 if (characterBefore !== BACKTICK) { |
147 if (characterBefore !== BACKTICK) { |
154 return value; |
148 return value; |
155 } |
149 } |
156 |
150 if (start - 2 < 0) { |
157 const textBefore = text.slice(0, start - 1); |
151 return value; |
158 const indexBefore = textBefore.lastIndexOf(BACKTICK); |
152 } |
159 |
153 const indexBefore = text.lastIndexOf(BACKTICK, start - 2); |
160 if (indexBefore === -1) { |
154 if (indexBefore === -1) { |
161 return value; |
155 return value; |
162 } |
156 } |
163 |
|
164 const startIndex = indexBefore; |
157 const startIndex = indexBefore; |
165 const endIndex = start - 2; |
158 const endIndex = start - 2; |
166 |
|
167 if (startIndex === endIndex) { |
159 if (startIndex === endIndex) { |
168 return value; |
160 return value; |
169 } |
161 } |
170 |
|
171 value = (0,external_wp_richText_namespaceObject.remove)(value, startIndex, startIndex + 1); |
162 value = (0,external_wp_richText_namespaceObject.remove)(value, startIndex, startIndex + 1); |
172 value = (0,external_wp_richText_namespaceObject.remove)(value, endIndex, endIndex + 1); |
163 value = (0,external_wp_richText_namespaceObject.remove)(value, endIndex, endIndex + 1); |
173 value = (0,external_wp_richText_namespaceObject.applyFormat)(value, { |
164 value = (0,external_wp_richText_namespaceObject.applyFormat)(value, { |
174 type: code_name |
165 type: code_name |
175 }, startIndex, endIndex); |
166 }, startIndex, endIndex); |
176 return value; |
167 return value; |
177 }, |
168 }, |
178 |
169 edit({ |
179 edit(_ref) { |
170 value, |
180 let { |
171 onChange, |
181 value, |
172 onFocus, |
182 onChange, |
173 isActive |
183 onFocus, |
174 }) { |
184 isActive |
|
185 } = _ref; |
|
186 |
|
187 function onClick() { |
175 function onClick() { |
188 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
176 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
189 type: code_name, |
177 type: code_name, |
190 title: code_title |
178 title: code_title |
191 })); |
179 })); |
192 onFocus(); |
180 onFocus(); |
193 } |
181 } |
194 |
182 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
195 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
183 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
196 icon: library_code, |
184 type: "access", |
197 title: code_title, |
185 character: "x", |
198 onClick: onClick, |
186 onUse: onClick |
199 isActive: isActive, |
187 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
200 role: "menuitemcheckbox" |
188 icon: library_code, |
|
189 title: code_title, |
|
190 onClick: onClick, |
|
191 isActive: isActive, |
|
192 role: "menuitemcheckbox" |
|
193 })] |
201 }); |
194 }); |
202 } |
195 } |
203 |
|
204 }; |
196 }; |
205 |
197 |
206 ;// CONCATENATED MODULE: external ["wp","components"] |
198 ;// CONCATENATED MODULE: external ["wp","components"] |
207 var external_wp_components_namespaceObject = window["wp"]["components"]; |
199 const external_wp_components_namespaceObject = window["wp"]["components"]; |
|
200 ;// CONCATENATED MODULE: external ["wp","element"] |
|
201 const external_wp_element_namespaceObject = window["wp"]["element"]; |
208 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard-return.js |
202 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard-return.js |
209 |
203 /** |
210 |
204 * WordPress dependencies |
211 /** |
205 */ |
212 * WordPress dependencies |
206 |
213 */ |
207 |
214 |
208 const keyboardReturn = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
215 const keyboardReturn = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
216 xmlns: "http://www.w3.org/2000/svg", |
209 xmlns: "http://www.w3.org/2000/svg", |
217 viewBox: "-2 -2 24 24" |
210 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
218 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
211 d: "m6.734 16.106 2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.158 1.093-1.028-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" |
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" |
212 }) |
220 })); |
213 }); |
221 /* harmony default export */ var keyboard_return = (keyboardReturn); |
214 /* harmony default export */ const keyboard_return = (keyboardReturn); |
222 |
215 |
223 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/image/index.js |
216 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/image/index.js |
224 |
217 /** |
225 |
218 * WordPress dependencies |
226 /** |
219 */ |
227 * WordPress dependencies |
220 |
228 */ |
221 |
229 |
222 |
230 |
223 |
231 |
224 |
232 |
225 |
233 |
226 |
234 |
227 |
235 const ALLOWED_MEDIA_TYPES = ['image']; |
228 const ALLOWED_MEDIA_TYPES = ['image']; |
236 const image_name = 'core/image'; |
229 const image_name = 'core/image'; |
237 |
|
238 const image_title = (0,external_wp_i18n_namespaceObject.__)('Inline image'); |
230 const image_title = (0,external_wp_i18n_namespaceObject.__)('Inline image'); |
239 |
|
240 const image_image = { |
231 const image_image = { |
241 name: image_name, |
232 name: image_name, |
242 title: image_title, |
233 title: image_title, |
243 keywords: [(0,external_wp_i18n_namespaceObject.__)('photo'), (0,external_wp_i18n_namespaceObject.__)('media')], |
234 keywords: [(0,external_wp_i18n_namespaceObject.__)('photo'), (0,external_wp_i18n_namespaceObject.__)('media')], |
244 object: true, |
235 object: true, |
250 url: 'src', |
241 url: 'src', |
251 alt: 'alt' |
242 alt: 'alt' |
252 }, |
243 }, |
253 edit: Edit |
244 edit: Edit |
254 }; |
245 }; |
255 |
246 function InlineUI({ |
256 function InlineUI(_ref) { |
247 value, |
257 let { |
248 onChange, |
258 value, |
249 activeObjectAttributes, |
259 onChange, |
250 contentRef |
260 activeObjectAttributes, |
251 }) { |
261 contentRef |
|
262 } = _ref; |
|
263 const { |
252 const { |
264 style |
253 style |
265 } = activeObjectAttributes; |
254 } = activeObjectAttributes; |
266 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)(style === null || style === void 0 ? void 0 : style.replace(/\D/g, '')); |
255 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)(style?.replace(/\D/g, '')); |
267 const anchorRef = (0,external_wp_richText_namespaceObject.useAnchorRef)({ |
256 const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({ |
268 ref: contentRef, |
257 editableContentElement: contentRef.current, |
269 value, |
|
270 settings: image_image |
258 settings: image_image |
271 }); |
259 }); |
272 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { |
260 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover, { |
273 position: "bottom center", |
261 placement: "bottom", |
274 focusOnMount: false, |
262 focusOnMount: false, |
275 anchorRef: anchorRef, |
263 anchor: popoverAnchor, |
276 className: "block-editor-format-toolbar__image-popover" |
264 className: "block-editor-format-toolbar__image-popover", |
277 }, (0,external_wp_element_namespaceObject.createElement)("form", { |
265 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", { |
278 className: "block-editor-format-toolbar__image-container-content", |
266 className: "block-editor-format-toolbar__image-container-content", |
279 onSubmit: event => { |
267 onSubmit: event => { |
280 const newReplacements = value.replacements.slice(); |
268 const newReplacements = value.replacements.slice(); |
281 newReplacements[value.start] = { |
269 newReplacements[value.start] = { |
282 type: image_name, |
270 type: image_name, |
283 attributes: { ...activeObjectAttributes, |
271 attributes: { |
284 style: width ? `width: ${width}px;` : '' |
272 ...activeObjectAttributes, |
285 } |
273 style: width ? `width: ${width}px;` : '' |
286 }; |
274 } |
287 onChange({ ...value, |
275 }; |
288 replacements: newReplacements |
276 onChange({ |
289 }); |
277 ...value, |
290 event.preventDefault(); |
278 replacements: newReplacements |
291 } |
279 }); |
292 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { |
280 event.preventDefault(); |
293 className: "block-editor-format-toolbar__image-container-value", |
281 }, |
294 type: "number", |
282 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, { |
295 label: (0,external_wp_i18n_namespaceObject.__)('Width'), |
283 alignment: "bottom", |
296 value: width, |
284 spacing: "0", |
297 min: 1, |
285 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, { |
298 onChange: newWidth => setWidth(newWidth) |
286 className: "block-editor-format-toolbar__image-container-value", |
299 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
287 label: (0,external_wp_i18n_namespaceObject.__)('Width'), |
300 icon: keyboard_return, |
288 value: width, |
301 label: (0,external_wp_i18n_namespaceObject.__)('Apply'), |
289 min: 1, |
302 type: "submit" |
290 onChange: newWidth => setWidth(newWidth) |
303 }))); |
291 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, { |
304 } |
292 className: "block-editor-format-toolbar__image-container-button", |
305 |
293 icon: keyboard_return, |
306 function Edit(_ref2) { |
294 label: (0,external_wp_i18n_namespaceObject.__)('Apply'), |
307 let { |
295 type: "submit" |
308 value, |
296 })] |
309 onChange, |
297 }) |
310 onFocus, |
298 }) |
311 isObjectActive, |
299 }); |
312 activeObjectAttributes, |
300 } |
313 contentRef |
301 function Edit({ |
314 } = _ref2; |
302 value, |
315 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); |
303 onChange, |
316 |
304 onFocus, |
317 function openModal() { |
305 isObjectActive, |
318 setIsModalOpen(true); |
306 activeObjectAttributes, |
319 } |
307 contentRef |
320 |
308 }) { |
321 function closeModal() { |
309 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, { |
322 setIsModalOpen(false); |
310 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.MediaUpload, { |
323 } |
311 allowedTypes: ALLOWED_MEDIA_TYPES, |
324 |
312 onSelect: ({ |
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, { |
|
327 xmlns: "http://www.w3.org/2000/svg", |
|
328 viewBox: "0 0 24 24" |
|
329 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { |
|
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 |
|
335 }), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUpload, { |
|
336 allowedTypes: ALLOWED_MEDIA_TYPES, |
|
337 onSelect: _ref3 => { |
|
338 let { |
|
339 id, |
313 id, |
340 url, |
314 url, |
341 alt, |
315 alt, |
342 width: imgWidth |
316 width: imgWidth |
343 } = _ref3; |
317 }) => { |
344 closeModal(); |
318 onChange((0,external_wp_richText_namespaceObject.insertObject)(value, { |
345 onChange((0,external_wp_richText_namespaceObject.insertObject)(value, { |
319 type: image_name, |
346 type: image_name, |
320 attributes: { |
347 attributes: { |
321 className: `wp-image-${id}`, |
348 className: `wp-image-${id}`, |
322 style: `width: ${Math.min(imgWidth, 150)}px;`, |
349 style: `width: ${Math.min(imgWidth, 150)}px;`, |
323 url, |
350 url, |
324 alt |
351 alt |
325 } |
352 } |
326 })); |
353 })); |
327 onFocus(); |
354 onFocus(); |
328 }, |
355 }, |
329 render: ({ |
356 onClose: closeModal, |
|
357 render: _ref4 => { |
|
358 let { |
|
359 open |
330 open |
360 } = _ref4; |
331 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
361 open(); |
332 icon: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SVG, { |
362 return null; |
333 xmlns: "http://www.w3.org/2000/svg", |
363 } |
334 viewBox: "0 0 24 24", |
364 }), isObjectActive && (0,external_wp_element_namespaceObject.createElement)(InlineUI, { |
335 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, { |
365 value: value, |
336 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" |
366 onChange: onChange, |
337 }) |
367 activeObjectAttributes: activeObjectAttributes, |
338 }), |
368 contentRef: contentRef |
339 title: image_title, |
369 })); |
340 onClick: open, |
|
341 isActive: isObjectActive |
|
342 }) |
|
343 }), isObjectActive && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InlineUI, { |
|
344 value: value, |
|
345 onChange: onChange, |
|
346 activeObjectAttributes: activeObjectAttributes, |
|
347 contentRef: contentRef |
|
348 })] |
|
349 }); |
370 } |
350 } |
371 |
351 |
372 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-italic.js |
352 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-italic.js |
373 |
353 /** |
374 |
354 * WordPress dependencies |
375 /** |
355 */ |
376 * WordPress dependencies |
356 |
377 */ |
357 |
378 |
358 const formatItalic = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
379 const formatItalic = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
380 xmlns: "http://www.w3.org/2000/svg", |
359 xmlns: "http://www.w3.org/2000/svg", |
381 viewBox: "0 0 24 24" |
360 viewBox: "0 0 24 24", |
382 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
361 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
383 d: "M12.5 5L10 19h1.9l2.5-14z" |
362 d: "M12.5 5L10 19h1.9l2.5-14z" |
384 })); |
363 }) |
385 /* harmony default export */ var format_italic = (formatItalic); |
364 }); |
|
365 /* harmony default export */ const format_italic = (formatItalic); |
386 |
366 |
387 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/italic/index.js |
367 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/italic/index.js |
388 |
368 /** |
389 |
369 * WordPress dependencies |
390 /** |
370 */ |
391 * WordPress dependencies |
371 |
392 */ |
372 |
|
373 |
393 |
374 |
394 |
375 |
395 |
376 |
396 |
377 |
397 const italic_name = 'core/italic'; |
378 const italic_name = 'core/italic'; |
398 |
|
399 const italic_title = (0,external_wp_i18n_namespaceObject.__)('Italic'); |
379 const italic_title = (0,external_wp_i18n_namespaceObject.__)('Italic'); |
400 |
|
401 const italic = { |
380 const italic = { |
402 name: italic_name, |
381 name: italic_name, |
403 title: italic_title, |
382 title: italic_title, |
404 tagName: 'em', |
383 tagName: 'em', |
405 className: null, |
384 className: null, |
406 |
385 edit({ |
407 edit(_ref) { |
386 isActive, |
408 let { |
387 value, |
409 isActive, |
388 onChange, |
410 value, |
389 onFocus |
411 onChange, |
390 }) { |
412 onFocus |
|
413 } = _ref; |
|
414 |
|
415 function onToggle() { |
391 function onToggle() { |
416 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
392 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
417 type: italic_name, |
393 type: italic_name, |
418 title: italic_title |
394 title: italic_title |
419 })); |
395 })); |
420 } |
396 } |
421 |
|
422 function onClick() { |
397 function onClick() { |
423 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
398 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
424 type: italic_name |
399 type: italic_name |
425 })); |
400 })); |
426 onFocus(); |
401 onFocus(); |
427 } |
402 } |
428 |
403 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
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, { |
404 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
430 type: "primary", |
405 type: "primary", |
431 character: "i", |
406 character: "i", |
432 onUse: onToggle |
407 onUse: onToggle |
433 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
408 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
434 name: "italic", |
409 name: "italic", |
435 icon: format_italic, |
410 icon: format_italic, |
436 title: italic_title, |
411 title: italic_title, |
437 onClick: onClick, |
412 onClick: onClick, |
438 isActive: isActive, |
413 isActive: isActive, |
439 shortcutType: "primary", |
414 shortcutType: "primary", |
440 shortcutCharacter: "i" |
415 shortcutCharacter: "i" |
441 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { |
416 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { |
442 inputType: "formatItalic", |
417 inputType: "formatItalic", |
443 onInput: onToggle |
418 onInput: onToggle |
444 })); |
419 })] |
445 } |
420 }); |
446 |
421 } |
447 }; |
422 }; |
448 |
423 |
449 ;// CONCATENATED MODULE: external ["wp","url"] |
424 ;// CONCATENATED MODULE: external ["wp","url"] |
450 var external_wp_url_namespaceObject = window["wp"]["url"]; |
425 const external_wp_url_namespaceObject = window["wp"]["url"]; |
451 ;// CONCATENATED MODULE: external ["wp","htmlEntities"] |
426 ;// CONCATENATED MODULE: external ["wp","htmlEntities"] |
452 var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; |
427 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; |
453 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link-off.js |
428 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link.js |
454 |
429 /** |
455 |
430 * WordPress dependencies |
456 /** |
431 */ |
457 * WordPress dependencies |
432 |
458 */ |
433 |
459 |
434 const link_link = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
460 const linkOff = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
461 xmlns: "http://www.w3.org/2000/svg", |
435 xmlns: "http://www.w3.org/2000/svg", |
462 viewBox: "0 0 24 24" |
436 viewBox: "0 0 24 24", |
463 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
437 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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" |
438 d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" |
465 })); |
439 }) |
466 /* harmony default export */ var link_off = (linkOff); |
440 }); |
467 |
441 /* harmony default export */ const library_link = (link_link); |
468 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link.js |
|
469 |
|
470 |
|
471 /** |
|
472 * WordPress dependencies |
|
473 */ |
|
474 |
|
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); |
|
482 |
442 |
483 ;// CONCATENATED MODULE: external ["wp","a11y"] |
443 ;// CONCATENATED MODULE: external ["wp","a11y"] |
484 var external_wp_a11y_namespaceObject = window["wp"]["a11y"]; |
444 const external_wp_a11y_namespaceObject = window["wp"]["a11y"]; |
485 ;// CONCATENATED MODULE: external ["wp","data"] |
445 ;// CONCATENATED MODULE: external ["wp","data"] |
486 var external_wp_data_namespaceObject = window["wp"]["data"]; |
446 const 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 |
447 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/utils.js |
490 /** |
|
491 * External dependencies |
|
492 */ |
|
493 |
|
494 /** |
448 /** |
495 * WordPress dependencies |
449 * WordPress dependencies |
496 */ |
450 */ |
497 |
451 |
498 |
452 |
501 * |
455 * |
502 * @param {string} href The href. |
456 * @param {string} href The href. |
503 * |
457 * |
504 * @return {boolean} Is the href invalid? |
458 * @return {boolean} Is the href invalid? |
505 */ |
459 */ |
506 |
|
507 function isValidHref(href) { |
460 function isValidHref(href) { |
508 if (!href) { |
461 if (!href) { |
509 return false; |
462 return false; |
510 } |
463 } |
511 |
|
512 const trimmedHref = href.trim(); |
464 const trimmedHref = href.trim(); |
513 |
|
514 if (!trimmedHref) { |
465 if (!trimmedHref) { |
515 return false; |
466 return false; |
516 } // Does the href start with something that looks like a URL protocol? |
467 } |
517 |
468 |
518 |
469 // Does the href start with something that looks like a URL protocol? |
519 if (/^\S+:/.test(trimmedHref)) { |
470 if (/^\S+:/.test(trimmedHref)) { |
520 const protocol = (0,external_wp_url_namespaceObject.getProtocol)(trimmedHref); |
471 const protocol = (0,external_wp_url_namespaceObject.getProtocol)(trimmedHref); |
521 |
|
522 if (!(0,external_wp_url_namespaceObject.isValidProtocol)(protocol)) { |
472 if (!(0,external_wp_url_namespaceObject.isValidProtocol)(protocol)) { |
523 return false; |
473 return false; |
524 } // Add some extra checks for http(s) URIs, since these are the most common use-case. |
474 } |
|
475 |
|
476 // 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. |
477 // This ensures URIs with an http protocol have exactly two forward slashes following the protocol. |
526 |
478 if (protocol.startsWith('http') && !/^https?:\/\/[^\/\s]/i.test(trimmedHref)) { |
527 |
|
528 if ((0,external_lodash_namespaceObject.startsWith)(protocol, 'http') && !/^https?:\/\/[^\/\s]/i.test(trimmedHref)) { |
|
529 return false; |
479 return false; |
530 } |
480 } |
531 |
|
532 const authority = (0,external_wp_url_namespaceObject.getAuthority)(trimmedHref); |
481 const authority = (0,external_wp_url_namespaceObject.getAuthority)(trimmedHref); |
533 |
|
534 if (!(0,external_wp_url_namespaceObject.isValidAuthority)(authority)) { |
482 if (!(0,external_wp_url_namespaceObject.isValidAuthority)(authority)) { |
535 return false; |
483 return false; |
536 } |
484 } |
537 |
|
538 const path = (0,external_wp_url_namespaceObject.getPath)(trimmedHref); |
485 const path = (0,external_wp_url_namespaceObject.getPath)(trimmedHref); |
539 |
|
540 if (path && !(0,external_wp_url_namespaceObject.isValidPath)(path)) { |
486 if (path && !(0,external_wp_url_namespaceObject.isValidPath)(path)) { |
541 return false; |
487 return false; |
542 } |
488 } |
543 |
|
544 const queryString = (0,external_wp_url_namespaceObject.getQueryString)(trimmedHref); |
489 const queryString = (0,external_wp_url_namespaceObject.getQueryString)(trimmedHref); |
545 |
|
546 if (queryString && !(0,external_wp_url_namespaceObject.isValidQueryString)(queryString)) { |
490 if (queryString && !(0,external_wp_url_namespaceObject.isValidQueryString)(queryString)) { |
547 return false; |
491 return false; |
548 } |
492 } |
549 |
|
550 const fragment = (0,external_wp_url_namespaceObject.getFragment)(trimmedHref); |
493 const fragment = (0,external_wp_url_namespaceObject.getFragment)(trimmedHref); |
551 |
|
552 if (fragment && !(0,external_wp_url_namespaceObject.isValidFragment)(fragment)) { |
494 if (fragment && !(0,external_wp_url_namespaceObject.isValidFragment)(fragment)) { |
553 return false; |
495 return false; |
554 } |
496 } |
555 } // Validate anchor links. |
497 } |
556 |
498 |
557 |
499 // Validate anchor links. |
558 if ((0,external_lodash_namespaceObject.startsWith)(trimmedHref, '#') && !(0,external_wp_url_namespaceObject.isValidFragment)(trimmedHref)) { |
500 if (trimmedHref.startsWith('#') && !(0,external_wp_url_namespaceObject.isValidFragment)(trimmedHref)) { |
559 return false; |
501 return false; |
560 } |
502 } |
561 |
|
562 return true; |
503 return true; |
563 } |
504 } |
|
505 |
564 /** |
506 /** |
565 * Generates the format object that will be applied to the link text. |
507 * Generates the format object that will be applied to the link text. |
566 * |
508 * |
567 * @param {Object} options |
509 * @param {Object} options |
568 * @param {string} options.url The href of the link. |
510 * @param {string} options.url The href of the link. |
569 * @param {string} options.type The type of the link. |
511 * @param {string} options.type The type of the link. |
570 * @param {string} options.id The ID of the link. |
512 * @param {string} options.id The ID of the link. |
571 * @param {boolean} options.opensInNewWindow Whether this link will open in a new window. |
513 * @param {boolean} options.opensInNewWindow Whether this link will open in a new window. |
572 * |
514 * @param {boolean} options.nofollow Whether this link is marked as no follow relationship. |
573 * @return {Object} The final format object. |
515 * @return {Object} The final format object. |
574 */ |
516 */ |
575 |
517 function createLinkFormat({ |
576 function createLinkFormat(_ref) { |
518 url, |
577 let { |
519 type, |
578 url, |
520 id, |
579 type, |
521 opensInNewWindow, |
580 id, |
522 nofollow |
581 opensInNewWindow |
523 }) { |
582 } = _ref; |
|
583 const format = { |
524 const format = { |
584 type: 'core/link', |
525 type: 'core/link', |
585 attributes: { |
526 attributes: { |
586 url |
527 url |
587 } |
528 } |
588 }; |
529 }; |
589 if (type) format.attributes.type = type; |
530 if (type) { |
590 if (id) format.attributes.id = id; |
531 format.attributes.type = type; |
591 |
532 } |
|
533 if (id) { |
|
534 format.attributes.id = id; |
|
535 } |
592 if (opensInNewWindow) { |
536 if (opensInNewWindow) { |
593 format.attributes.target = '_blank'; |
537 format.attributes.target = '_blank'; |
594 format.attributes.rel = 'noreferrer noopener'; |
538 format.attributes.rel = format.attributes.rel ? format.attributes.rel + ' noreferrer noopener' : 'noreferrer noopener'; |
595 } |
539 } |
596 |
540 if (nofollow) { |
|
541 format.attributes.rel = format.attributes.rel ? format.attributes.rel + ' nofollow' : 'nofollow'; |
|
542 } |
597 return format; |
543 return format; |
598 } |
544 } |
|
545 |
599 /* eslint-disable jsdoc/no-undefined-types */ |
546 /* eslint-disable jsdoc/no-undefined-types */ |
600 |
|
601 /** |
547 /** |
602 * Get the start and end boundaries of a given format from a rich text value. |
548 * Get the start and end boundaries of a given format from a rich text value. |
603 * |
549 * |
604 * |
550 * |
605 * @param {RichTextValue} value the rich text value to interrogate. |
551 * @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`). |
552 * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`). |
607 * @param {number?} startIndex optional startIndex to seek from. |
553 * @param {number?} startIndex optional startIndex to seek from. |
608 * @param {number?} endIndex optional endIndex to seek from. |
554 * @param {number?} endIndex optional endIndex to seek from. |
609 * @return {Object} object containing start and end values for the given format. |
555 * @return {Object} object containing start and end values for the given format. |
610 */ |
556 */ |
611 |
|
612 /* eslint-enable jsdoc/no-undefined-types */ |
557 /* eslint-enable jsdoc/no-undefined-types */ |
613 |
558 function getFormatBoundary(value, format, startIndex = value.start, endIndex = value.end) { |
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 = { |
559 const EMPTY_BOUNDARIES = { |
618 start: null, |
560 start: null, |
619 end: null |
561 end: null |
620 }; |
562 }; |
621 const { |
563 const { |
622 formats |
564 formats |
623 } = value; |
565 } = value; |
624 let targetFormat; |
566 let targetFormat; |
625 let initialIndex; |
567 let initialIndex; |
626 |
568 if (!formats?.length) { |
627 if (!(formats !== null && formats !== void 0 && formats.length)) { |
|
628 return EMPTY_BOUNDARIES; |
569 return EMPTY_BOUNDARIES; |
629 } // Clone formats to avoid modifying source formats. |
570 } |
630 |
571 |
631 |
572 // Clone formats to avoid modifying source formats. |
632 const newFormats = formats.slice(); |
573 const newFormats = formats.slice(); |
633 const formatAtStart = (0,external_lodash_namespaceObject.find)(newFormats[startIndex], { |
574 const formatAtStart = newFormats[startIndex]?.find(({ |
634 type: format.type |
575 type |
635 }); |
576 }) => type === format.type); |
636 const formatAtEnd = (0,external_lodash_namespaceObject.find)(newFormats[endIndex], { |
577 const formatAtEnd = newFormats[endIndex]?.find(({ |
637 type: format.type |
578 type |
638 }); |
579 }) => type === format.type); |
639 const formatAtEndMinusOne = (0,external_lodash_namespaceObject.find)(newFormats[endIndex - 1], { |
580 const formatAtEndMinusOne = newFormats[endIndex - 1]?.find(({ |
640 type: format.type |
581 type |
641 }); |
582 }) => type === format.type); |
642 |
|
643 if (!!formatAtStart) { |
583 if (!!formatAtStart) { |
644 // Set values to conform to "start" |
584 // Set values to conform to "start" |
645 targetFormat = formatAtStart; |
585 targetFormat = formatAtStart; |
646 initialIndex = startIndex; |
586 initialIndex = startIndex; |
647 } else if (!!formatAtEnd) { |
587 } else if (!!formatAtEnd) { |
759 * Internal dependencies |
666 * Internal dependencies |
760 */ |
667 */ |
761 |
668 |
762 |
669 |
763 |
670 |
764 |
671 const LINK_SETTINGS = [...external_wp_blockEditor_namespaceObject.__experimentalLinkControl.DEFAULT_LINK_SETTINGS, { |
765 |
672 id: 'nofollow', |
766 function InlineLinkUI(_ref) { |
673 title: (0,external_wp_i18n_namespaceObject.__)('Mark as nofollow') |
767 let { |
674 }]; |
768 isActive, |
675 function InlineLinkUI({ |
769 activeAttributes, |
676 isActive, |
770 addingLink, |
677 activeAttributes, |
771 value, |
678 value, |
772 onChange, |
679 onChange, |
773 speak, |
680 onFocusOutside, |
774 stopAddingLink, |
681 stopAddingLink, |
775 contentRef |
682 contentRef, |
776 } = _ref; |
683 focusOnMount |
777 const richLinkTextValue = getRichTextValueFromSelection(value, isActive); // Get the text content minus any HTML tags. |
684 }) { |
778 |
685 const richLinkTextValue = getRichTextValueFromSelection(value, isActive); |
|
686 |
|
687 // Get the text content minus any HTML tags. |
779 const richTextText = richLinkTextValue.text; |
688 const richTextText = richLinkTextValue.text; |
780 /** |
689 const { |
781 * Pending settings to be applied to the next link. When inserting a new |
690 selectionChange |
782 * link, toggle values cannot be applied immediately, because there is not |
691 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); |
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 */ |
|
788 |
|
789 const [nextLinkValue, setNextLinkValue] = (0,external_wp_element_namespaceObject.useState)(); |
|
790 const { |
692 const { |
791 createPageEntity, |
693 createPageEntity, |
792 userCanCreatePages |
694 userCanCreatePages, |
|
695 selectionStart |
793 } = (0,external_wp_data_namespaceObject.useSelect)(select => { |
696 } = (0,external_wp_data_namespaceObject.useSelect)(select => { |
794 const { |
697 const { |
795 getSettings |
698 getSettings, |
|
699 getSelectionStart |
796 } = select(external_wp_blockEditor_namespaceObject.store); |
700 } = select(external_wp_blockEditor_namespaceObject.store); |
797 |
|
798 const _settings = getSettings(); |
701 const _settings = getSettings(); |
799 |
|
800 return { |
702 return { |
801 createPageEntity: _settings.__experimentalCreatePageEntity, |
703 createPageEntity: _settings.__experimentalCreatePageEntity, |
802 userCanCreatePages: _settings.__experimentalUserCanCreatePages |
704 userCanCreatePages: _settings.__experimentalUserCanCreatePages, |
|
705 selectionStart: getSelectionStart() |
803 }; |
706 }; |
804 }, []); |
707 }, []); |
805 const linkValue = { |
708 const linkValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({ |
806 url: activeAttributes.url, |
709 url: activeAttributes.url, |
807 type: activeAttributes.type, |
710 type: activeAttributes.type, |
808 id: activeAttributes.id, |
711 id: activeAttributes.id, |
809 opensInNewTab: activeAttributes.target === '_blank', |
712 opensInNewTab: activeAttributes.target === '_blank', |
810 title: richTextText, |
713 nofollow: activeAttributes.rel?.includes('nofollow'), |
811 ...nextLinkValue |
714 title: richTextText |
812 }; |
715 }), [activeAttributes.id, activeAttributes.rel, activeAttributes.target, activeAttributes.type, activeAttributes.url, richTextText]); |
813 |
|
814 function removeLink() { |
716 function removeLink() { |
815 const newValue = (0,external_wp_richText_namespaceObject.removeFormat)(value, 'core/link'); |
717 const newValue = (0,external_wp_richText_namespaceObject.removeFormat)(value, 'core/link'); |
816 onChange(newValue); |
718 onChange(newValue); |
817 stopAddingLink(); |
719 stopAddingLink(); |
818 speak((0,external_wp_i18n_namespaceObject.__)('Link removed.'), 'assertive'); |
720 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link removed.'), 'assertive'); |
819 } |
721 } |
820 |
|
821 function onChangeLink(nextValue) { |
722 function onChangeLink(nextValue) { |
822 // Merge with values from state, both for the purpose of assigning the |
723 const hasLink = linkValue?.url; |
823 // next state value, and for use in constructing the new link format if |
724 const isNewLink = !hasLink; |
824 // the link is ready to be applied. |
725 |
825 nextValue = { ...nextLinkValue, |
726 // Merge the next value with the current link value. |
|
727 nextValue = { |
|
728 ...linkValue, |
826 ...nextValue |
729 ...nextValue |
827 }; // LinkControl calls `onChange` immediately upon the toggling a setting. |
730 }; |
828 |
|
829 const didToggleSetting = linkValue.opensInNewTab !== nextValue.opensInNewTab && linkValue.url === nextValue.url; // If change handler was called as a result of a settings change during |
|
830 // link insertion, it must be held in state until the link is ready to |
|
831 // be applied. |
|
832 |
|
833 const didToggleSettingForNewLink = didToggleSetting && nextValue.url === undefined; // If link will be assigned, the state value can be considered flushed. |
|
834 // Otherwise, persist the pending changes. |
|
835 |
|
836 setNextLinkValue(didToggleSettingForNewLink ? nextValue : undefined); |
|
837 |
|
838 if (didToggleSettingForNewLink) { |
|
839 return; |
|
840 } |
|
841 |
|
842 const newUrl = (0,external_wp_url_namespaceObject.prependHTTP)(nextValue.url); |
731 const newUrl = (0,external_wp_url_namespaceObject.prependHTTP)(nextValue.url); |
843 const linkFormat = createLinkFormat({ |
732 const linkFormat = createLinkFormat({ |
844 url: newUrl, |
733 url: newUrl, |
845 type: nextValue.type, |
734 type: nextValue.type, |
846 id: nextValue.id !== undefined && nextValue.id !== null ? String(nextValue.id) : undefined, |
735 id: nextValue.id !== undefined && nextValue.id !== null ? String(nextValue.id) : undefined, |
847 opensInNewWindow: nextValue.opensInNewTab |
736 opensInNewWindow: nextValue.opensInNewTab, |
|
737 nofollow: nextValue.nofollow |
848 }); |
738 }); |
849 const newText = nextValue.title || newUrl; |
739 const newText = nextValue.title || newUrl; |
850 |
740 |
|
741 // Scenario: we have any active text selection or an active format. |
|
742 let newValue; |
851 if ((0,external_wp_richText_namespaceObject.isCollapsed)(value) && !isActive) { |
743 if ((0,external_wp_richText_namespaceObject.isCollapsed)(value) && !isActive) { |
852 // Scenario: we don't have any actively selected text or formats. |
744 // 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)({ |
745 const inserted = (0,external_wp_richText_namespaceObject.insert)(value, newText); |
|
746 newValue = (0,external_wp_richText_namespaceObject.applyFormat)(inserted, linkFormat, value.start, value.start + newText.length); |
|
747 onChange(newValue); |
|
748 |
|
749 // Close the Link UI. |
|
750 stopAddingLink(); |
|
751 |
|
752 // Move the selection to the end of the inserted link outside of the format boundary |
|
753 // so the user can continue typing after the link. |
|
754 selectionChange({ |
|
755 clientId: selectionStart.clientId, |
|
756 identifier: selectionStart.attributeKey, |
|
757 start: value.start + newText.length + 1 |
|
758 }); |
|
759 return; |
|
760 } else if (newText === richTextText) { |
|
761 newValue = (0,external_wp_richText_namespaceObject.applyFormat)(value, linkFormat); |
|
762 } else { |
|
763 // Scenario: Editing an existing link. |
|
764 |
|
765 // Create new RichText value for the new text in order that we |
|
766 // can apply formats to it. |
|
767 newValue = (0,external_wp_richText_namespaceObject.create)({ |
854 text: newText |
768 text: newText |
855 }), linkFormat, 0, newText.length); |
769 }); |
856 onChange((0,external_wp_richText_namespaceObject.insert)(value, toInsert)); |
770 // Apply the new Link format to this new text value. |
|
771 newValue = (0,external_wp_richText_namespaceObject.applyFormat)(newValue, linkFormat, 0, newText.length); |
|
772 |
|
773 // Get the boundaries of the active link format. |
|
774 const boundary = getFormatBoundary(value, { |
|
775 type: 'core/link' |
|
776 }); |
|
777 |
|
778 // Split the value at the start of the active link format. |
|
779 // Passing "start" as the 3rd parameter is required to ensure |
|
780 // the second half of the split value is split at the format's |
|
781 // start boundary and avoids relying on the value's "end" property |
|
782 // which may not correspond correctly. |
|
783 const [valBefore, valAfter] = (0,external_wp_richText_namespaceObject.split)(value, boundary.start, boundary.start); |
|
784 |
|
785 // Update the original (full) RichTextValue replacing the |
|
786 // target text with the *new* RichTextValue containing: |
|
787 // 1. The new text content. |
|
788 // 2. The new link format. |
|
789 // As "replace" will operate on the first match only, it is |
|
790 // run only against the second half of the value which was |
|
791 // split at the active format's boundary. This avoids a bug |
|
792 // with incorrectly targetted replacements. |
|
793 // See: https://github.com/WordPress/gutenberg/issues/41771. |
|
794 // Note original formats will be lost when applying this change. |
|
795 // That is expected behaviour. |
|
796 // See: https://github.com/WordPress/gutenberg/pull/33849#issuecomment-936134179. |
|
797 const newValAfter = (0,external_wp_richText_namespaceObject.replace)(valAfter, richTextText, newValue); |
|
798 newValue = (0,external_wp_richText_namespaceObject.concat)(valBefore, newValAfter); |
|
799 } |
|
800 onChange(newValue); |
|
801 |
|
802 // Focus should only be returned to the rich text on submit if this link is not |
|
803 // being created for the first time. If it is then focus should remain within the |
|
804 // Link UI because it should remain open for the user to modify the link they have |
|
805 // just created. |
|
806 if (!isNewLink) { |
|
807 stopAddingLink(); |
|
808 } |
|
809 if (!isValidHref(newUrl)) { |
|
810 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Warning: the link has been inserted but may have errors. Please test it.'), 'assertive'); |
|
811 } else if (isActive) { |
|
812 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link edited.'), 'assertive'); |
857 } else { |
813 } else { |
858 // Scenario: we have any active text selection or an active format. |
814 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link inserted.'), 'assertive'); |
859 let newValue; |
815 } |
860 |
816 } |
861 if (newText === richTextText) { |
817 const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({ |
862 // If we're not updating the text then ignore. |
818 editableContentElement: contentRef.current, |
863 newValue = (0,external_wp_richText_namespaceObject.applyFormat)(value, linkFormat); |
819 settings: { |
864 } else { |
820 ...build_module_link_link, |
865 // Create new RichText value for the new text in order that we |
821 isActive |
866 // can apply formats to it. |
822 } |
867 newValue = (0,external_wp_richText_namespaceObject.create)({ |
823 }); |
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 |
|
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(); |
|
891 } |
|
892 |
|
893 if (!isValidHref(newUrl)) { |
|
894 speak((0,external_wp_i18n_namespaceObject.__)('Warning: the link has been inserted but may have errors. Please test it.'), 'assertive'); |
|
895 } else if (isActive) { |
|
896 speak((0,external_wp_i18n_namespaceObject.__)('Link edited.'), 'assertive'); |
|
897 } else { |
|
898 speak((0,external_wp_i18n_namespaceObject.__)('Link inserted.'), 'assertive'); |
|
899 } |
|
900 } |
|
901 |
|
902 const anchorRef = (0,external_wp_richText_namespaceObject.useAnchorRef)({ |
|
903 ref: contentRef, |
|
904 value, |
|
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 |
|
912 // otherwise it causes a render of the content. |
|
913 |
|
914 const focusOnMount = (0,external_wp_element_namespaceObject.useRef)(addingLink ? 'firstElement' : false); |
|
915 |
|
916 async function handleCreate(pageTitle) { |
824 async function handleCreate(pageTitle) { |
917 const page = await createPageEntity({ |
825 const page = await createPageEntity({ |
918 title: pageTitle, |
826 title: pageTitle, |
919 status: 'draft' |
827 status: 'draft' |
920 }); |
828 }); |
924 title: page.title.rendered, |
832 title: page.title.rendered, |
925 url: page.link, |
833 url: page.link, |
926 kind: 'post-type' |
834 kind: 'post-type' |
927 }; |
835 }; |
928 } |
836 } |
929 |
|
930 function createButtonText(searchTerm) { |
837 function createButtonText(searchTerm) { |
931 return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( |
838 return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: search term. */ |
932 /* translators: %s: search term. */ |
839 (0,external_wp_i18n_namespaceObject.__)('Create page: <mark>%s</mark>'), searchTerm), { |
933 (0,external_wp_i18n_namespaceObject.__)('Create Page: <mark>%s</mark>'), searchTerm), { |
840 mark: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("mark", {}) |
934 mark: (0,external_wp_element_namespaceObject.createElement)("mark", null) |
|
935 }); |
841 }); |
936 } |
842 } |
937 |
843 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover, { |
938 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { |
844 anchor: popoverAnchor, |
939 anchorRef: anchorRef, |
845 animate: false, |
940 focusOnMount: focusOnMount.current, |
|
941 onClose: stopAddingLink, |
846 onClose: stopAddingLink, |
942 position: "bottom center" |
847 onFocusOutside: onFocusOutside, |
943 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLinkControl, { |
848 placement: "bottom", |
944 key: forceRemountKey, |
849 offset: 8, |
945 value: linkValue, |
850 shift: true, |
946 onChange: onChangeLink, |
851 focusOnMount: focusOnMount, |
947 onRemove: removeLink, |
852 constrainTabbing: true, |
948 forceIsEditingLink: addingLink, |
853 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalLinkControl, { |
949 hasRichPreviews: true, |
854 value: linkValue, |
950 createSuggestion: createPageEntity && handleCreate, |
855 onChange: onChangeLink, |
951 withCreateSuggestion: userCanCreatePages, |
856 onRemove: removeLink, |
952 createSuggestionButtonText: createButtonText, |
857 hasRichPreviews: true, |
953 hasTextControl: true |
858 createSuggestion: createPageEntity && handleCreate, |
954 })); |
859 withCreateSuggestion: userCanCreatePages, |
955 } |
860 createSuggestionButtonText: createButtonText, |
956 |
861 hasTextControl: true, |
|
862 settings: LINK_SETTINGS, |
|
863 showInitialSuggestions: true, |
|
864 suggestionsQuery: { |
|
865 // always show Pages as initial suggestions |
|
866 initialSuggestionsSearchOptions: { |
|
867 type: 'post', |
|
868 subtype: 'page', |
|
869 perPage: 20 |
|
870 } |
|
871 } |
|
872 }) |
|
873 }); |
|
874 } |
957 function getRichTextValueFromSelection(value, isActive) { |
875 function getRichTextValueFromSelection(value, isActive) { |
958 // Default to the selection ranges on the RichTextValue object. |
876 // Default to the selection ranges on the RichTextValue object. |
959 let textStart = value.start; |
877 let textStart = value.start; |
960 let textEnd = value.end; // If the format is currently active then the rich text value |
878 let textEnd = value.end; |
|
879 |
|
880 // If the format is currently active then the rich text value |
961 // should always be taken from the bounds of the active format |
881 // should always be taken from the bounds of the active format |
962 // and not the selected text. |
882 // and not the selected text. |
963 |
|
964 if (isActive) { |
883 if (isActive) { |
965 const boundary = getFormatBoundary(value, { |
884 const boundary = getFormatBoundary(value, { |
966 type: 'core/link' |
885 type: 'core/link' |
967 }); |
886 }); |
968 textStart = boundary.start; // Text *selection* always extends +1 beyond the edge of the format. |
887 textStart = boundary.start; |
|
888 |
|
889 // Text *selection* always extends +1 beyond the edge of the format. |
969 // We account for that here. |
890 // We account for that here. |
970 |
|
971 textEnd = boundary.end + 1; |
891 textEnd = boundary.end + 1; |
972 } // Get a RichTextValue containing the selected text content. |
892 } |
973 |
893 |
974 |
894 // Get a RichTextValue containing the selected text content. |
975 return (0,external_wp_richText_namespaceObject.slice)(value, textStart, textEnd); |
895 return (0,external_wp_richText_namespaceObject.slice)(value, textStart, textEnd); |
976 } |
896 } |
977 |
897 /* harmony default export */ const inline = (InlineLinkUI); |
978 /* harmony default export */ var inline = ((0,external_wp_components_namespaceObject.withSpokenMessages)(InlineLinkUI)); |
|
979 |
898 |
980 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/index.js |
899 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/index.js |
981 |
900 /** |
982 |
901 * WordPress dependencies |
983 /** |
902 */ |
984 * WordPress dependencies |
903 |
985 */ |
|
986 |
904 |
987 |
905 |
988 |
906 |
989 |
907 |
990 |
908 |
995 * Internal dependencies |
913 * Internal dependencies |
996 */ |
914 */ |
997 |
915 |
998 |
916 |
999 |
917 |
|
918 |
|
919 |
1000 const link_name = 'core/link'; |
920 const link_name = 'core/link'; |
1001 |
|
1002 const link_title = (0,external_wp_i18n_namespaceObject.__)('Link'); |
921 const link_title = (0,external_wp_i18n_namespaceObject.__)('Link'); |
1003 |
922 function link_Edit({ |
1004 function link_Edit(_ref) { |
923 isActive, |
1005 let { |
924 activeAttributes, |
1006 isActive, |
925 value, |
1007 activeAttributes, |
926 onChange, |
1008 value, |
927 onFocus, |
1009 onChange, |
928 contentRef |
1010 onFocus, |
929 }) { |
1011 contentRef |
|
1012 } = _ref; |
|
1013 const [addingLink, setAddingLink] = (0,external_wp_element_namespaceObject.useState)(false); |
930 const [addingLink, setAddingLink] = (0,external_wp_element_namespaceObject.useState)(false); |
1014 |
931 |
1015 function addLink() { |
932 // We only need to store the button element that opened the popover. We can ignore the other states, as they will be handled by the onFocus prop to return to the rich text field. |
|
933 const [openedBy, setOpenedBy] = (0,external_wp_element_namespaceObject.useState)(null); |
|
934 (0,external_wp_element_namespaceObject.useEffect)(() => { |
|
935 // When the link becomes inactive (i.e. isActive is false), reset the editingLink state |
|
936 // and the creatingLink state. This means that if the Link UI is displayed and the link |
|
937 // becomes inactive (e.g. used arrow keys to move cursor outside of link bounds), the UI will close. |
|
938 if (!isActive) { |
|
939 setAddingLink(false); |
|
940 } |
|
941 }, [isActive]); |
|
942 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { |
|
943 const editableContentElement = contentRef.current; |
|
944 if (!editableContentElement) { |
|
945 return; |
|
946 } |
|
947 function handleClick(event) { |
|
948 // There is a situation whereby there is an existing link in the rich text |
|
949 // and the user clicks on the leftmost edge of that link and fails to activate |
|
950 // the link format, but the click event still fires on the `<a>` element. |
|
951 // This causes the `editingLink` state to be set to `true` and the link UI |
|
952 // to be rendered in "creating" mode. We need to check isActive to see if |
|
953 // we have an active link format. |
|
954 const link = event.target.closest('[contenteditable] a'); |
|
955 if (!link || |
|
956 // other formats (e.g. bold) may be nested within the link. |
|
957 !isActive) { |
|
958 return; |
|
959 } |
|
960 setAddingLink(true); |
|
961 setOpenedBy({ |
|
962 el: link, |
|
963 action: 'click' |
|
964 }); |
|
965 } |
|
966 editableContentElement.addEventListener('click', handleClick); |
|
967 return () => { |
|
968 editableContentElement.removeEventListener('click', handleClick); |
|
969 }; |
|
970 }, [contentRef, isActive]); |
|
971 function addLink(target) { |
1016 const text = (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.slice)(value)); |
972 const text = (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.slice)(value)); |
1017 |
973 if (!isActive && text && (0,external_wp_url_namespaceObject.isURL)(text) && isValidHref(text)) { |
1018 if (text && (0,external_wp_url_namespaceObject.isURL)(text) && isValidHref(text)) { |
|
1019 onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, { |
974 onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, { |
1020 type: link_name, |
975 type: link_name, |
1021 attributes: { |
976 attributes: { |
1022 url: text |
977 url: text |
1023 } |
978 } |
1024 })); |
979 })); |
1025 } else if (text && (0,external_wp_url_namespaceObject.isEmail)(text)) { |
980 } else if (!isActive && text && (0,external_wp_url_namespaceObject.isEmail)(text)) { |
1026 onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, { |
981 onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, { |
1027 type: link_name, |
982 type: link_name, |
1028 attributes: { |
983 attributes: { |
1029 url: `mailto:${text}` |
984 url: `mailto:${text}` |
1030 } |
985 } |
1031 })); |
986 })); |
1032 } else { |
987 } else { |
|
988 if (target) { |
|
989 setOpenedBy({ |
|
990 el: target, |
|
991 action: null // We don't need to distinguish between click or keyboard here |
|
992 }); |
|
993 } |
1033 setAddingLink(true); |
994 setAddingLink(true); |
1034 } |
995 } |
1035 } |
996 } |
1036 |
997 |
|
998 /** |
|
999 * Runs when the popover is closed via escape keypress, unlinking the selected text, |
|
1000 * but _not_ on a click outside the popover. onFocusOutside handles that. |
|
1001 */ |
1037 function stopAddingLink() { |
1002 function stopAddingLink() { |
|
1003 // Don't let the click handler on the toolbar button trigger again. |
|
1004 |
|
1005 // There are two places for us to return focus to on Escape keypress: |
|
1006 // 1. The rich text field. |
|
1007 // 2. The toolbar button. |
|
1008 |
|
1009 // The toolbar button is the only one we need to handle returning focus to. |
|
1010 // Otherwise, we rely on the passed in onFocus to return focus to the rich text field. |
|
1011 |
|
1012 // Close the popover |
1038 setAddingLink(false); |
1013 setAddingLink(false); |
1039 onFocus(); |
1014 |
1040 } |
1015 // Return focus to the toolbar button or the rich text field |
1041 |
1016 if (openedBy?.el?.tagName === 'BUTTON') { |
|
1017 openedBy.el.focus(); |
|
1018 } else { |
|
1019 onFocus(); |
|
1020 } |
|
1021 // Remove the openedBy state |
|
1022 setOpenedBy(null); |
|
1023 } |
|
1024 |
|
1025 // Test for this: |
|
1026 // 1. Click on the link button |
|
1027 // 2. Click the Options button in the top right of header |
|
1028 // 3. Focus should be in the dropdown of the Options button |
|
1029 // 4. Press Escape |
|
1030 // 5. Focus should be on the Options button |
|
1031 function onFocusOutside() { |
|
1032 setAddingLink(false); |
|
1033 setOpenedBy(null); |
|
1034 } |
1042 function onRemoveFormat() { |
1035 function onRemoveFormat() { |
1043 onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, link_name)); |
1036 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'); |
1037 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link removed.'), 'assertive'); |
1045 } |
1038 } |
1046 |
1039 |
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, { |
1040 // Only autofocus if we have clicked a link within the editor |
1048 type: "primary", |
1041 const shouldAutoFocus = !(openedBy?.el?.tagName === 'A' && openedBy?.action === 'click'); |
1049 character: "k", |
1042 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
1050 onUse: addLink |
1043 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
1051 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
1044 type: "primary", |
1052 type: "primaryShift", |
1045 character: "k", |
1053 character: "k", |
1046 onUse: addLink |
1054 onUse: onRemoveFormat |
1047 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
1055 }), isActive && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
1048 type: "primaryShift", |
1056 name: "link", |
1049 character: "k", |
1057 icon: link_off, |
1050 onUse: onRemoveFormat |
1058 title: (0,external_wp_i18n_namespaceObject.__)('Unlink'), |
1051 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
1059 onClick: onRemoveFormat, |
1052 name: "link", |
1060 isActive: isActive, |
1053 icon: library_link, |
1061 shortcutType: "primaryShift", |
1054 title: isActive ? (0,external_wp_i18n_namespaceObject.__)('Link') : link_title, |
1062 shortcutCharacter: "k" |
1055 onClick: event => { |
1063 }), !isActive && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
1056 addLink(event.currentTarget); |
1064 name: "link", |
1057 }, |
1065 icon: library_link, |
1058 isActive: isActive || addingLink, |
1066 title: link_title, |
1059 shortcutType: "primary", |
1067 onClick: addLink, |
1060 shortcutCharacter: "k", |
1068 isActive: isActive, |
1061 "aria-haspopup": "true", |
1069 shortcutType: "primary", |
1062 "aria-expanded": addingLink |
1070 shortcutCharacter: "k" |
1063 }), addingLink && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inline, { |
1071 }), (addingLink || isActive) && (0,external_wp_element_namespaceObject.createElement)(inline, { |
1064 stopAddingLink: stopAddingLink, |
1072 addingLink: addingLink, |
1065 onFocusOutside: onFocusOutside, |
1073 stopAddingLink: stopAddingLink, |
1066 isActive: isActive, |
1074 isActive: isActive, |
1067 activeAttributes: activeAttributes, |
1075 activeAttributes: activeAttributes, |
1068 value: value, |
1076 value: value, |
1069 onChange: onChange, |
1077 onChange: onChange, |
1070 contentRef: contentRef, |
1078 contentRef: contentRef |
1071 focusOnMount: shouldAutoFocus ? 'firstElement' : false |
1079 })); |
1072 })] |
1080 } |
1073 }); |
1081 |
1074 } |
1082 const build_module_link_link = { |
1075 const build_module_link_link = { |
1083 name: link_name, |
1076 name: link_name, |
1084 title: link_title, |
1077 title: link_title, |
1085 tagName: 'a', |
1078 tagName: 'a', |
1086 className: null, |
1079 className: null, |
1087 attributes: { |
1080 attributes: { |
1088 url: 'href', |
1081 url: 'href', |
1089 type: 'data-type', |
1082 type: 'data-type', |
1090 id: 'data-id', |
1083 id: 'data-id', |
1091 target: 'target' |
1084 _id: 'id', |
|
1085 target: 'target', |
|
1086 rel: 'rel' |
1092 }, |
1087 }, |
1093 |
1088 __unstablePasteRule(value, { |
1094 __unstablePasteRule(value, _ref2) { |
1089 html, |
1095 let { |
1090 plainText |
1096 html, |
1091 }) { |
1097 plainText |
1092 const pastedText = (html || plainText).replace(/<[^>]+>/g, '').trim(); |
1098 } = _ref2; |
1093 |
1099 |
1094 // A URL was pasted, turn the selection into a link. |
1100 if ((0,external_wp_richText_namespaceObject.isCollapsed)(value)) { |
1095 // For the link pasting feature, allow only http(s) protocols. |
|
1096 if (!(0,external_wp_url_namespaceObject.isURL)(pastedText) || !/^https?:/.test(pastedText)) { |
1101 return value; |
1097 return value; |
1102 } |
1098 } |
1103 |
1099 |
1104 const pastedText = (html || plainText).replace(/<[^>]+>/g, '').trim(); // A URL was pasted, turn the selection into a link. |
1100 // Allows us to ask for this information when we get a report. |
1105 |
|
1106 if (!(0,external_wp_url_namespaceObject.isURL)(pastedText)) { |
|
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); |
1101 window.console.log('Created link:\n\n', pastedText); |
1112 return (0,external_wp_richText_namespaceObject.applyFormat)(value, { |
1102 const format = { |
1113 type: link_name, |
1103 type: link_name, |
1114 attributes: { |
1104 attributes: { |
1115 url: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(pastedText) |
1105 url: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(pastedText) |
1116 } |
1106 } |
1117 }); |
1107 }; |
|
1108 if ((0,external_wp_richText_namespaceObject.isCollapsed)(value)) { |
|
1109 return (0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.applyFormat)((0,external_wp_richText_namespaceObject.create)({ |
|
1110 text: plainText |
|
1111 }), format, 0, plainText.length)); |
|
1112 } |
|
1113 return (0,external_wp_richText_namespaceObject.applyFormat)(value, format); |
1118 }, |
1114 }, |
1119 |
|
1120 edit: link_Edit |
1115 edit: link_Edit |
1121 }; |
1116 }; |
1122 |
1117 |
1123 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-strikethrough.js |
1118 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-strikethrough.js |
1124 |
1119 /** |
1125 |
1120 * WordPress dependencies |
1126 /** |
1121 */ |
1127 * WordPress dependencies |
1122 |
1128 */ |
1123 |
1129 |
1124 const formatStrikethrough = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
1130 const formatStrikethrough = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
1131 xmlns: "http://www.w3.org/2000/svg", |
1125 xmlns: "http://www.w3.org/2000/svg", |
1132 viewBox: "0 0 24 24" |
1126 viewBox: "0 0 24 24", |
1133 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
1127 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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" |
1128 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 })); |
1129 }) |
1136 /* harmony default export */ var format_strikethrough = (formatStrikethrough); |
1130 }); |
|
1131 /* harmony default export */ const format_strikethrough = (formatStrikethrough); |
1137 |
1132 |
1138 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/strikethrough/index.js |
1133 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/strikethrough/index.js |
1139 |
1134 /** |
1140 |
1135 * WordPress dependencies |
1141 /** |
1136 */ |
1142 * WordPress dependencies |
1137 |
1143 */ |
1138 |
|
1139 |
1144 |
1140 |
1145 |
1141 |
1146 |
1142 |
1147 |
1143 |
1148 const strikethrough_name = 'core/strikethrough'; |
1144 const strikethrough_name = 'core/strikethrough'; |
1149 |
|
1150 const strikethrough_title = (0,external_wp_i18n_namespaceObject.__)('Strikethrough'); |
1145 const strikethrough_title = (0,external_wp_i18n_namespaceObject.__)('Strikethrough'); |
1151 |
|
1152 const strikethrough = { |
1146 const strikethrough = { |
1153 name: strikethrough_name, |
1147 name: strikethrough_name, |
1154 title: strikethrough_title, |
1148 title: strikethrough_title, |
1155 tagName: 's', |
1149 tagName: 's', |
1156 className: null, |
1150 className: null, |
1157 |
1151 edit({ |
1158 edit(_ref) { |
1152 isActive, |
1159 let { |
1153 value, |
1160 isActive, |
1154 onChange, |
1161 value, |
1155 onFocus |
1162 onChange, |
1156 }) { |
1163 onFocus |
|
1164 } = _ref; |
|
1165 |
|
1166 function onClick() { |
1157 function onClick() { |
1167 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
1158 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
1168 type: strikethrough_name, |
1159 type: strikethrough_name, |
1169 title: strikethrough_title |
1160 title: strikethrough_title |
1170 })); |
1161 })); |
1171 onFocus(); |
1162 onFocus(); |
1172 } |
1163 } |
1173 |
1164 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
1174 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
1165 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
1175 icon: format_strikethrough, |
1166 type: "access", |
1176 title: strikethrough_title, |
1167 character: "d", |
1177 onClick: onClick, |
1168 onUse: onClick |
1178 isActive: isActive, |
1169 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
1179 role: "menuitemcheckbox" |
1170 icon: format_strikethrough, |
|
1171 title: strikethrough_title, |
|
1172 onClick: onClick, |
|
1173 isActive: isActive, |
|
1174 role: "menuitemcheckbox" |
|
1175 })] |
1180 }); |
1176 }); |
1181 } |
1177 } |
1182 |
|
1183 }; |
1178 }; |
1184 |
1179 |
1185 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/underline/index.js |
1180 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/underline/index.js |
1186 |
1181 /** |
1187 |
1182 * WordPress dependencies |
1188 /** |
1183 */ |
1189 * WordPress dependencies |
1184 |
1190 */ |
1185 |
|
1186 |
1191 |
1187 |
1192 |
1188 |
1193 |
1189 |
1194 const underline_name = 'core/underline'; |
1190 const underline_name = 'core/underline'; |
1195 |
|
1196 const underline_title = (0,external_wp_i18n_namespaceObject.__)('Underline'); |
1191 const underline_title = (0,external_wp_i18n_namespaceObject.__)('Underline'); |
1197 |
|
1198 const underline = { |
1192 const underline = { |
1199 name: underline_name, |
1193 name: underline_name, |
1200 title: underline_title, |
1194 title: underline_title, |
1201 tagName: 'span', |
1195 tagName: 'span', |
1202 className: null, |
1196 className: null, |
1203 attributes: { |
1197 attributes: { |
1204 style: 'style' |
1198 style: 'style' |
1205 }, |
1199 }, |
1206 |
1200 edit({ |
1207 edit(_ref) { |
1201 value, |
1208 let { |
1202 onChange |
1209 value, |
1203 }) { |
1210 onChange |
|
1211 } = _ref; |
|
1212 |
|
1213 const onToggle = () => { |
1204 const onToggle = () => { |
1214 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
1205 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
1215 type: underline_name, |
1206 type: underline_name, |
1216 attributes: { |
1207 attributes: { |
1217 style: 'text-decoration: underline;' |
1208 style: 'text-decoration: underline;' |
1218 }, |
1209 }, |
1219 title: underline_title |
1210 title: underline_title |
1220 })); |
1211 })); |
1221 }; |
1212 }; |
1222 |
1213 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
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, { |
1214 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
1224 type: "primary", |
1215 type: "primary", |
1225 character: "u", |
1216 character: "u", |
1226 onUse: onToggle |
1217 onUse: onToggle |
1227 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { |
1218 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { |
1228 inputType: "formatUnderline", |
1219 inputType: "formatUnderline", |
1229 onInput: onToggle |
1220 onInput: onToggle |
1230 })); |
1221 })] |
1231 } |
1222 }); |
1232 |
1223 } |
1233 }; |
1224 }; |
1234 |
1225 |
1235 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js |
1226 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js |
1236 /** |
1227 /** |
1237 * WordPress dependencies |
1228 * WordPress dependencies |
1238 */ |
1229 */ |
|
1230 |
1239 |
1231 |
1240 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ |
1232 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ |
1241 |
1233 |
1242 /** |
1234 /** |
1243 * Return an SVG icon. |
1235 * Return an SVG icon. |
1244 * |
1236 * |
1245 * @param {IconProps} props icon is the SVG component to render |
1237 * @param {IconProps} props icon is the SVG component to render |
1246 * size is a number specifiying the icon size in pixels |
1238 * size is a number specifiying the icon size in pixels |
1247 * Other props will be passed to wrapped SVG component |
1239 * Other props will be passed to wrapped SVG component |
|
1240 * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element. |
1248 * |
1241 * |
1249 * @return {JSX.Element} Icon component |
1242 * @return {JSX.Element} Icon component |
1250 */ |
1243 */ |
1251 |
1244 function Icon({ |
1252 function Icon(_ref) { |
1245 icon, |
1253 let { |
1246 size = 24, |
1254 icon, |
1247 ...props |
1255 size = 24, |
1248 }, ref) { |
1256 ...props |
|
1257 } = _ref; |
|
1258 return (0,external_wp_element_namespaceObject.cloneElement)(icon, { |
1249 return (0,external_wp_element_namespaceObject.cloneElement)(icon, { |
1259 width: size, |
1250 width: size, |
1260 height: size, |
1251 height: size, |
1261 ...props |
1252 ...props, |
|
1253 ref |
1262 }); |
1254 }); |
1263 } |
1255 } |
1264 |
1256 /* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon)); |
1265 /* harmony default export */ var icon = (Icon); |
|
1266 |
1257 |
1267 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/text-color.js |
1258 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/text-color.js |
1268 |
1259 /** |
1269 |
1260 * WordPress dependencies |
1270 /** |
1261 */ |
1271 * WordPress dependencies |
1262 |
1272 */ |
1263 |
1273 |
1264 const textColor = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
1274 const textColor = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
1275 xmlns: "http://www.w3.org/2000/svg", |
1265 xmlns: "http://www.w3.org/2000/svg", |
1276 viewBox: "0 0 24 24" |
1266 viewBox: "0 0 24 24", |
1277 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
1267 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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" |
1268 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 })); |
1269 }) |
1280 /* harmony default export */ var text_color = (textColor); |
1270 }); |
|
1271 /* harmony default export */ const text_color = (textColor); |
|
1272 |
|
1273 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/color.js |
|
1274 /** |
|
1275 * WordPress dependencies |
|
1276 */ |
|
1277 |
|
1278 |
|
1279 const color = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
|
1280 viewBox: "0 0 24 24", |
|
1281 xmlns: "http://www.w3.org/2000/svg", |
|
1282 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
|
1283 d: "M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z" |
|
1284 }) |
|
1285 }); |
|
1286 /* harmony default export */ const library_color = (color); |
|
1287 |
|
1288 ;// CONCATENATED MODULE: external ["wp","privateApis"] |
|
1289 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; |
|
1290 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/lock-unlock.js |
|
1291 /** |
|
1292 * WordPress dependencies |
|
1293 */ |
|
1294 |
|
1295 const { |
|
1296 lock, |
|
1297 unlock |
|
1298 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/format-library'); |
1281 |
1299 |
1282 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/text-color/inline.js |
1300 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/text-color/inline.js |
1283 |
|
1284 |
|
1285 /** |
|
1286 * External dependencies |
|
1287 */ |
|
1288 |
|
1289 /** |
1301 /** |
1290 * WordPress dependencies |
1302 * WordPress dependencies |
1291 */ |
1303 */ |
1292 |
1304 |
1293 |
1305 |
1300 * Internal dependencies |
1312 * Internal dependencies |
1301 */ |
1313 */ |
1302 |
1314 |
1303 |
1315 |
1304 |
1316 |
1305 function parseCSS() { |
1317 |
1306 let css = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; |
1318 const { |
|
1319 Tabs |
|
1320 } = unlock(external_wp_components_namespaceObject.privateApis); |
|
1321 const TABS = [{ |
|
1322 name: 'color', |
|
1323 title: (0,external_wp_i18n_namespaceObject.__)('Text') |
|
1324 }, { |
|
1325 name: 'backgroundColor', |
|
1326 title: (0,external_wp_i18n_namespaceObject.__)('Background') |
|
1327 }]; |
|
1328 function parseCSS(css = '') { |
1307 return css.split(';').reduce((accumulator, rule) => { |
1329 return css.split(';').reduce((accumulator, rule) => { |
1308 if (rule) { |
1330 if (rule) { |
1309 const [property, value] = rule.split(':'); |
1331 const [property, value] = rule.split(':'); |
1310 if (property === 'color') accumulator.color = value; |
1332 if (property === 'color') { |
1311 if (property === 'background-color' && value !== transparentValue) accumulator.backgroundColor = value; |
1333 accumulator.color = value; |
1312 } |
1334 } |
1313 |
1335 if (property === 'background-color' && value !== transparentValue) { |
|
1336 accumulator.backgroundColor = value; |
|
1337 } |
|
1338 } |
1314 return accumulator; |
1339 return accumulator; |
1315 }, {}); |
1340 }, {}); |
1316 } |
1341 } |
1317 |
1342 function parseClassName(className = '', colorSettings) { |
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) => { |
1343 return className.split(' ').reduce((accumulator, name) => { |
1322 // `colorSlug` could contain dashes, so simply match the start and end. |
1344 // `colorSlug` could contain dashes, so simply match the start and end. |
1323 if (name.startsWith('has-') && name.endsWith('-color')) { |
1345 if (name.startsWith('has-') && name.endsWith('-color')) { |
1324 const colorSlug = name.replace(/^has-/, '').replace(/-color$/, ''); |
1346 const colorSlug = name.replace(/^has-/, '').replace(/-color$/, ''); |
1325 const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues)(colorSettings, colorSlug); |
1347 const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues)(colorSettings, colorSlug); |
1326 accumulator.color = colorObject.color; |
1348 accumulator.color = colorObject.color; |
1327 } |
1349 } |
1328 |
|
1329 return accumulator; |
1350 return accumulator; |
1330 }, {}); |
1351 }, {}); |
1331 } |
1352 } |
1332 function getActiveColors(value, name, colorSettings) { |
1353 function getActiveColors(value, name, colorSettings) { |
1333 const activeColorFormat = (0,external_wp_richText_namespaceObject.getActiveFormat)(value, name); |
1354 const activeColorFormat = (0,external_wp_richText_namespaceObject.getActiveFormat)(value, name); |
1334 |
|
1335 if (!activeColorFormat) { |
1355 if (!activeColorFormat) { |
1336 return {}; |
1356 return {}; |
1337 } |
1357 } |
1338 |
1358 return { |
1339 return { ...parseCSS(activeColorFormat.attributes.style), |
1359 ...parseCSS(activeColorFormat.attributes.style), |
1340 ...parseClassName(activeColorFormat.attributes.class, colorSettings) |
1360 ...parseClassName(activeColorFormat.attributes.class, colorSettings) |
1341 }; |
1361 }; |
1342 } |
1362 } |
1343 |
|
1344 function setColors(value, name, colorSettings, colors) { |
1363 function setColors(value, name, colorSettings, colors) { |
1345 const { |
1364 const { |
1346 color, |
1365 color, |
1347 backgroundColor |
1366 backgroundColor |
1348 } = { ...getActiveColors(value, name, colorSettings), |
1367 } = { |
|
1368 ...getActiveColors(value, name, colorSettings), |
1349 ...colors |
1369 ...colors |
1350 }; |
1370 }; |
1351 |
|
1352 if (!color && !backgroundColor) { |
1371 if (!color && !backgroundColor) { |
1353 return (0,external_wp_richText_namespaceObject.removeFormat)(value, name); |
1372 return (0,external_wp_richText_namespaceObject.removeFormat)(value, name); |
1354 } |
1373 } |
1355 |
|
1356 const styles = []; |
1374 const styles = []; |
1357 const classNames = []; |
1375 const classNames = []; |
1358 const attributes = {}; |
1376 const attributes = {}; |
1359 |
|
1360 if (backgroundColor) { |
1377 if (backgroundColor) { |
1361 styles.push(['background-color', backgroundColor].join(':')); |
1378 styles.push(['background-color', backgroundColor].join(':')); |
1362 } else { |
1379 } else { |
1363 // Override default browser color for mark element. |
1380 // Override default browser color for mark element. |
1364 styles.push(['background-color', transparentValue].join(':')); |
1381 styles.push(['background-color', transparentValue].join(':')); |
1365 } |
1382 } |
1366 |
|
1367 if (color) { |
1383 if (color) { |
1368 const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByColorValue)(colorSettings, color); |
1384 const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByColorValue)(colorSettings, color); |
1369 |
|
1370 if (colorObject) { |
1385 if (colorObject) { |
1371 classNames.push((0,external_wp_blockEditor_namespaceObject.getColorClassName)('color', colorObject.slug)); |
1386 classNames.push((0,external_wp_blockEditor_namespaceObject.getColorClassName)('color', colorObject.slug)); |
1372 } else { |
1387 } else { |
1373 styles.push(['color', color].join(':')); |
1388 styles.push(['color', color].join(':')); |
1374 } |
1389 } |
1375 } |
1390 } |
1376 |
1391 if (styles.length) { |
1377 if (styles.length) attributes.style = styles.join(';'); |
1392 attributes.style = styles.join(';'); |
1378 if (classNames.length) attributes.class = classNames.join(' '); |
1393 } |
|
1394 if (classNames.length) { |
|
1395 attributes.class = classNames.join(' '); |
|
1396 } |
1379 return (0,external_wp_richText_namespaceObject.applyFormat)(value, { |
1397 return (0,external_wp_richText_namespaceObject.applyFormat)(value, { |
1380 type: name, |
1398 type: name, |
1381 attributes |
1399 attributes |
1382 }); |
1400 }); |
1383 } |
1401 } |
1384 |
1402 function ColorPicker({ |
1385 function ColorPicker(_ref) { |
1403 name, |
1386 let { |
1404 property, |
1387 name, |
1405 value, |
1388 property, |
1406 onChange |
1389 value, |
1407 }) { |
1390 onChange |
|
1391 } = _ref; |
|
1392 const colors = (0,external_wp_data_namespaceObject.useSelect)(select => { |
1408 const colors = (0,external_wp_data_namespaceObject.useSelect)(select => { |
|
1409 var _getSettings$colors; |
1393 const { |
1410 const { |
1394 getSettings |
1411 getSettings |
1395 } = select(external_wp_blockEditor_namespaceObject.store); |
1412 } = select(external_wp_blockEditor_namespaceObject.store); |
1396 return (0,external_lodash_namespaceObject.get)(getSettings(), ['colors'], []); |
1413 return (_getSettings$colors = getSettings().colors) !== null && _getSettings$colors !== void 0 ? _getSettings$colors : []; |
1397 }, []); |
1414 }, []); |
1398 const onColorChange = (0,external_wp_element_namespaceObject.useCallback)(color => { |
1415 const onColorChange = (0,external_wp_element_namespaceObject.useCallback)(color => { |
1399 onChange(setColors(value, name, colors, { |
1416 onChange(setColors(value, name, colors, { |
1400 [property]: color |
1417 [property]: color |
1401 })); |
1418 })); |
1402 }, [colors, onChange, property]); |
1419 }, [colors, onChange, property]); |
1403 const activeColors = (0,external_wp_element_namespaceObject.useMemo)(() => getActiveColors(value, name, colors), [name, value, colors]); |
1420 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, { |
1421 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.ColorPalette, { |
1405 value: activeColors[property], |
1422 value: activeColors[property], |
1406 onChange: onColorChange |
1423 onChange: onColorChange |
1407 }); |
1424 }); |
1408 } |
1425 } |
1409 |
1426 function InlineColorUI({ |
1410 function InlineColorUI(_ref2) { |
1427 name, |
1411 let { |
1428 value, |
1412 name, |
1429 onChange, |
1413 value, |
1430 onClose, |
1414 onChange, |
1431 contentRef, |
1415 onClose, |
1432 isActive |
1416 contentRef |
1433 }) { |
1417 } = _ref2; |
1434 const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({ |
1418 |
1435 editableContentElement: contentRef.current, |
1419 /* |
1436 settings: { |
1420 As you change the text color by typing a HEX value into a field, |
1437 ...text_color_textColor, |
1421 the return value of document.getSelection jumps to the field you're editing, |
1438 isActive |
1422 not the highlighted text. Given that useAnchorRef uses document.getSelection, |
1439 } |
1423 it will return null, since it can't find the <mark> element within the HEX input. |
1440 }); |
1424 This caches the last truthy value of the selection anchor reference. |
1441 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover, { |
1425 */ |
|
1426 const anchorRef = (0,external_wp_blockEditor_namespaceObject.useCachedTruthy)((0,external_wp_richText_namespaceObject.useAnchorRef)({ |
|
1427 ref: contentRef, |
|
1428 value, |
|
1429 settings: text_color_textColor |
|
1430 })); |
|
1431 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { |
|
1432 onClose: onClose, |
1442 onClose: onClose, |
1433 className: "components-inline-color-popover", |
1443 className: "format-library__inline-color-popover", |
1434 anchorRef: anchorRef |
1444 anchor: popoverAnchor, |
1435 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, { |
1445 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Tabs, { |
1436 tabs: [{ |
1446 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabList, { |
1437 name: 'color', |
1447 children: TABS.map(tab => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, { |
1438 title: (0,external_wp_i18n_namespaceObject.__)('Text') |
1448 tabId: tab.name, |
1439 }, { |
1449 children: tab.title |
1440 name: 'backgroundColor', |
1450 }, tab.name)) |
1441 title: (0,external_wp_i18n_namespaceObject.__)('Background') |
1451 }), TABS.map(tab => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabPanel, { |
1442 }] |
1452 tabId: tab.name, |
1443 }, tab => (0,external_wp_element_namespaceObject.createElement)(ColorPicker, { |
1453 focusable: false, |
1444 name: name, |
1454 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ColorPicker, { |
1445 property: tab.name, |
1455 name: name, |
1446 value: value, |
1456 property: tab.name, |
1447 onChange: onChange |
1457 value: value, |
1448 }))); |
1458 onChange: onChange |
|
1459 }) |
|
1460 }, tab.name))] |
|
1461 }) |
|
1462 }); |
1449 } |
1463 } |
1450 |
1464 |
1451 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/text-color/index.js |
1465 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/text-color/index.js |
1452 |
|
1453 |
|
1454 /** |
|
1455 * External dependencies |
|
1456 */ |
|
1457 |
|
1458 /** |
1466 /** |
1459 * WordPress dependencies |
1467 * WordPress dependencies |
1460 */ |
1468 */ |
1461 |
1469 |
1462 |
1470 |
1465 |
1473 |
1466 |
1474 |
1467 /** |
1475 /** |
1468 * Internal dependencies |
1476 * Internal dependencies |
1469 */ |
1477 */ |
|
1478 |
|
1479 |
1470 |
1480 |
1471 |
1481 |
1472 const transparentValue = 'rgba(0, 0, 0, 0)'; |
1482 const transparentValue = 'rgba(0, 0, 0, 0)'; |
1473 const text_color_name = 'core/text-color'; |
1483 const text_color_name = 'core/text-color'; |
1474 |
|
1475 const text_color_title = (0,external_wp_i18n_namespaceObject.__)('Highlight'); |
1484 const text_color_title = (0,external_wp_i18n_namespaceObject.__)('Highlight'); |
1476 |
|
1477 const EMPTY_ARRAY = []; |
1485 const EMPTY_ARRAY = []; |
1478 |
|
1479 function getComputedStyleProperty(element, property) { |
1486 function getComputedStyleProperty(element, property) { |
1480 const { |
1487 const { |
1481 ownerDocument |
1488 ownerDocument |
1482 } = element; |
1489 } = element; |
1483 const { |
1490 const { |
1484 defaultView |
1491 defaultView |
1485 } = ownerDocument; |
1492 } = ownerDocument; |
1486 const style = defaultView.getComputedStyle(element); |
1493 const style = defaultView.getComputedStyle(element); |
1487 const value = style.getPropertyValue(property); |
1494 const value = style.getPropertyValue(property); |
1488 |
|
1489 if (property === 'background-color' && value === transparentValue && element.parentElement) { |
1495 if (property === 'background-color' && value === transparentValue && element.parentElement) { |
1490 return getComputedStyleProperty(element.parentElement, property); |
1496 return getComputedStyleProperty(element.parentElement, property); |
1491 } |
1497 } |
1492 |
|
1493 return value; |
1498 return value; |
1494 } |
1499 } |
1495 |
1500 function fillComputedColors(element, { |
1496 function fillComputedColors(element, _ref) { |
1501 color, |
1497 let { |
1502 backgroundColor |
1498 color, |
1503 }) { |
1499 backgroundColor |
|
1500 } = _ref; |
|
1501 |
|
1502 if (!color && !backgroundColor) { |
1504 if (!color && !backgroundColor) { |
1503 return; |
1505 return; |
1504 } |
1506 } |
1505 |
|
1506 return { |
1507 return { |
1507 color: color || getComputedStyleProperty(element, 'color'), |
1508 color: color || getComputedStyleProperty(element, 'color'), |
1508 backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element, 'background-color') : backgroundColor |
1509 backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element, 'background-color') : backgroundColor |
1509 }; |
1510 }; |
1510 } |
1511 } |
1511 |
1512 function TextColorEdit({ |
1512 function TextColorEdit(_ref2) { |
1513 value, |
1513 let { |
1514 onChange, |
1514 value, |
1515 isActive, |
1515 onChange, |
1516 activeAttributes, |
1516 isActive, |
1517 contentRef |
1517 activeAttributes, |
1518 }) { |
1518 contentRef |
1519 const [allowCustomControl, colors = EMPTY_ARRAY] = (0,external_wp_blockEditor_namespaceObject.useSettings)('color.custom', 'color.palette'); |
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); |
1520 const [isAddingColor, setIsAddingColor] = (0,external_wp_element_namespaceObject.useState)(false); |
1523 const enableIsAddingColor = (0,external_wp_element_namespaceObject.useCallback)(() => setIsAddingColor(true), [setIsAddingColor]); |
1521 const enableIsAddingColor = (0,external_wp_element_namespaceObject.useCallback)(() => setIsAddingColor(true), [setIsAddingColor]); |
1524 const disableIsAddingColor = (0,external_wp_element_namespaceObject.useCallback)(() => setIsAddingColor(false), [setIsAddingColor]); |
1522 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]); |
1523 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; |
1524 const hasColorsToChoose = colors.length || !allowCustomControl; |
1527 |
|
1528 if (!hasColorsToChoose && !isActive) { |
1525 if (!hasColorsToChoose && !isActive) { |
1529 return null; |
1526 return null; |
1530 } |
1527 } |
1531 |
1528 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
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, { |
1529 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
1533 className: "format-library-text-color-button", |
1530 className: "format-library-text-color-button", |
1534 isActive: isActive, |
1531 isActive: isActive, |
1535 icon: (0,external_wp_element_namespaceObject.createElement)(icon, { |
1532 icon: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, { |
1536 icon: text_color, |
1533 icon: Object.keys(activeAttributes).length ? text_color : library_color, |
1537 style: colorIndicatorStyle |
1534 style: colorIndicatorStyle |
1538 }), |
1535 }), |
1539 title: text_color_title // If has no colors to choose but a color is active remove the color onClick. |
1536 title: text_color_title |
1540 , |
1537 // If has no colors to choose but a color is active remove the color onClick. |
1541 onClick: hasColorsToChoose ? enableIsAddingColor : () => onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, text_color_name)), |
1538 , |
1542 role: "menuitemcheckbox" |
1539 onClick: hasColorsToChoose ? enableIsAddingColor : () => onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, text_color_name)), |
1543 }), isAddingColor && (0,external_wp_element_namespaceObject.createElement)(InlineColorUI, { |
1540 role: "menuitemcheckbox" |
1544 name: text_color_name, |
1541 }), isAddingColor && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InlineColorUI, { |
1545 onClose: disableIsAddingColor, |
1542 name: text_color_name, |
1546 activeAttributes: activeAttributes, |
1543 onClose: disableIsAddingColor, |
1547 value: value, |
1544 activeAttributes: activeAttributes, |
1548 onChange: onChange, |
1545 value: value, |
1549 contentRef: contentRef |
1546 onChange: onChange, |
1550 })); |
1547 contentRef: contentRef, |
1551 } |
1548 isActive: isActive |
1552 |
1549 })] |
|
1550 }); |
|
1551 } |
1553 const text_color_textColor = { |
1552 const text_color_textColor = { |
1554 name: text_color_name, |
1553 name: text_color_name, |
1555 title: text_color_title, |
1554 title: text_color_title, |
1556 tagName: 'mark', |
1555 tagName: 'mark', |
1557 className: 'has-inline-color', |
1556 className: 'has-inline-color', |
1558 attributes: { |
1557 attributes: { |
1559 style: 'style', |
1558 style: 'style', |
1560 class: 'class' |
1559 class: 'class' |
1561 }, |
1560 }, |
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 |
|
1582 edit: TextColorEdit |
1561 edit: TextColorEdit |
1583 }; |
1562 }; |
1584 |
1563 |
1585 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/subscript.js |
1564 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/subscript.js |
1586 |
1565 /** |
1587 |
1566 * WordPress dependencies |
1588 /** |
1567 */ |
1589 * WordPress dependencies |
1568 |
1590 */ |
1569 |
1591 |
1570 const subscript = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
1592 const subscript = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
1593 xmlns: "http://www.w3.org/2000/svg", |
1571 xmlns: "http://www.w3.org/2000/svg", |
1594 viewBox: "0 0 24 24" |
1572 viewBox: "0 0 24 24", |
1595 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
1573 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
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" |
1574 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 })); |
1575 }) |
1598 /* harmony default export */ var library_subscript = (subscript); |
1576 }); |
|
1577 /* harmony default export */ const library_subscript = (subscript); |
1599 |
1578 |
1600 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/subscript/index.js |
1579 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/subscript/index.js |
1601 |
1580 /** |
1602 |
1581 * WordPress dependencies |
1603 /** |
1582 */ |
1604 * WordPress dependencies |
1583 |
1605 */ |
|
1606 |
1584 |
1607 |
1585 |
1608 |
1586 |
1609 |
1587 |
1610 const subscript_name = 'core/subscript'; |
1588 const subscript_name = 'core/subscript'; |
1611 |
|
1612 const subscript_title = (0,external_wp_i18n_namespaceObject.__)('Subscript'); |
1589 const subscript_title = (0,external_wp_i18n_namespaceObject.__)('Subscript'); |
1613 |
|
1614 const subscript_subscript = { |
1590 const subscript_subscript = { |
1615 name: subscript_name, |
1591 name: subscript_name, |
1616 title: subscript_title, |
1592 title: subscript_title, |
1617 tagName: 'sub', |
1593 tagName: 'sub', |
1618 className: null, |
1594 className: null, |
1619 |
1595 edit({ |
1620 edit(_ref) { |
1596 isActive, |
1621 let { |
1597 value, |
1622 isActive, |
1598 onChange, |
1623 value, |
1599 onFocus |
1624 onChange, |
1600 }) { |
1625 onFocus |
|
1626 } = _ref; |
|
1627 |
|
1628 function onToggle() { |
1601 function onToggle() { |
1629 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
1602 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
1630 type: subscript_name, |
1603 type: subscript_name, |
1631 title: subscript_title |
1604 title: subscript_title |
1632 })); |
1605 })); |
1633 } |
1606 } |
1634 |
|
1635 function onClick() { |
1607 function onClick() { |
1636 onToggle(); |
1608 onToggle(); |
1637 onFocus(); |
1609 onFocus(); |
1638 } |
1610 } |
1639 |
1611 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
1640 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
|
1641 icon: library_subscript, |
1612 icon: library_subscript, |
1642 title: subscript_title, |
1613 title: subscript_title, |
1643 onClick: onClick, |
1614 onClick: onClick, |
1644 isActive: isActive, |
1615 isActive: isActive, |
1645 role: "menuitemcheckbox" |
1616 role: "menuitemcheckbox" |
1646 }); |
1617 }); |
1647 } |
1618 } |
1648 |
|
1649 }; |
1619 }; |
1650 |
1620 |
1651 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/superscript.js |
1621 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/superscript.js |
1652 |
1622 /** |
1653 |
1623 * WordPress dependencies |
1654 /** |
1624 */ |
1655 * WordPress dependencies |
1625 |
1656 */ |
1626 |
1657 |
1627 const superscript = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
1658 const superscript = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
1659 xmlns: "http://www.w3.org/2000/svg", |
1628 xmlns: "http://www.w3.org/2000/svg", |
1660 viewBox: "0 0 24 24" |
1629 viewBox: "0 0 24 24", |
1661 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
1630 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
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" |
1631 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 })); |
1632 }) |
1664 /* harmony default export */ var library_superscript = (superscript); |
1633 }); |
|
1634 /* harmony default export */ const library_superscript = (superscript); |
1665 |
1635 |
1666 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/superscript/index.js |
1636 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/superscript/index.js |
1667 |
1637 /** |
1668 |
1638 * WordPress dependencies |
1669 /** |
1639 */ |
1670 * WordPress dependencies |
1640 |
1671 */ |
|
1672 |
1641 |
1673 |
1642 |
1674 |
1643 |
1675 |
1644 |
1676 const superscript_name = 'core/superscript'; |
1645 const superscript_name = 'core/superscript'; |
1677 |
|
1678 const superscript_title = (0,external_wp_i18n_namespaceObject.__)('Superscript'); |
1646 const superscript_title = (0,external_wp_i18n_namespaceObject.__)('Superscript'); |
1679 |
|
1680 const superscript_superscript = { |
1647 const superscript_superscript = { |
1681 name: superscript_name, |
1648 name: superscript_name, |
1682 title: superscript_title, |
1649 title: superscript_title, |
1683 tagName: 'sup', |
1650 tagName: 'sup', |
1684 className: null, |
1651 className: null, |
1685 |
1652 edit({ |
1686 edit(_ref) { |
1653 isActive, |
1687 let { |
1654 value, |
1688 isActive, |
1655 onChange, |
1689 value, |
1656 onFocus |
1690 onChange, |
1657 }) { |
1691 onFocus |
|
1692 } = _ref; |
|
1693 |
|
1694 function onToggle() { |
1658 function onToggle() { |
1695 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
1659 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
1696 type: superscript_name, |
1660 type: superscript_name, |
1697 title: superscript_title |
1661 title: superscript_title |
1698 })); |
1662 })); |
1699 } |
1663 } |
1700 |
|
1701 function onClick() { |
1664 function onClick() { |
1702 onToggle(); |
1665 onToggle(); |
1703 onFocus(); |
1666 onFocus(); |
1704 } |
1667 } |
1705 |
1668 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
1706 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
|
1707 icon: library_superscript, |
1669 icon: library_superscript, |
1708 title: superscript_title, |
1670 title: superscript_title, |
1709 onClick: onClick, |
1671 onClick: onClick, |
1710 isActive: isActive, |
1672 isActive: isActive, |
1711 role: "menuitemcheckbox" |
1673 role: "menuitemcheckbox" |
1712 }); |
1674 }); |
1713 } |
1675 } |
1714 |
|
1715 }; |
1676 }; |
1716 |
1677 |
1717 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/button.js |
1678 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/button.js |
1718 |
1679 /** |
1719 |
1680 * WordPress dependencies |
1720 /** |
1681 */ |
1721 * WordPress dependencies |
1682 |
1722 */ |
1683 |
1723 |
1684 const button_button = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
1724 const button_button = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
1725 viewBox: "0 0 24 24", |
1685 viewBox: "0 0 24 24", |
1726 xmlns: "http://www.w3.org/2000/svg" |
1686 xmlns: "http://www.w3.org/2000/svg", |
1727 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
1687 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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" |
1688 d: "M8 12.5h8V11H8v1.5Z M19 6.5H5a2 2 0 0 0-2 2V15a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a2 2 0 0 0-2-2ZM5 8h14a.5.5 0 0 1 .5.5V15a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V8.5A.5.5 0 0 1 5 8Z" |
1729 })); |
1689 }) |
1730 /* harmony default export */ var library_button = (button_button); |
1690 }); |
|
1691 /* harmony default export */ const library_button = (button_button); |
1731 |
1692 |
1732 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/keyboard/index.js |
1693 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/keyboard/index.js |
1733 |
1694 /** |
1734 |
1695 * WordPress dependencies |
1735 /** |
1696 */ |
1736 * WordPress dependencies |
1697 |
1737 */ |
|
1738 |
1698 |
1739 |
1699 |
1740 |
1700 |
1741 |
1701 |
1742 const keyboard_name = 'core/keyboard'; |
1702 const keyboard_name = 'core/keyboard'; |
1743 |
|
1744 const keyboard_title = (0,external_wp_i18n_namespaceObject.__)('Keyboard input'); |
1703 const keyboard_title = (0,external_wp_i18n_namespaceObject.__)('Keyboard input'); |
1745 |
|
1746 const keyboard = { |
1704 const keyboard = { |
1747 name: keyboard_name, |
1705 name: keyboard_name, |
1748 title: keyboard_title, |
1706 title: keyboard_title, |
1749 tagName: 'kbd', |
1707 tagName: 'kbd', |
1750 className: null, |
1708 className: null, |
1751 |
1709 edit({ |
1752 edit(_ref) { |
1710 isActive, |
1753 let { |
1711 value, |
1754 isActive, |
1712 onChange, |
1755 value, |
1713 onFocus |
1756 onChange, |
1714 }) { |
1757 onFocus |
|
1758 } = _ref; |
|
1759 |
|
1760 function onToggle() { |
1715 function onToggle() { |
1761 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
1716 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { |
1762 type: keyboard_name, |
1717 type: keyboard_name, |
1763 title: keyboard_title |
1718 title: keyboard_title |
1764 })); |
1719 })); |
1765 } |
1720 } |
1766 |
|
1767 function onClick() { |
1721 function onClick() { |
1768 onToggle(); |
1722 onToggle(); |
1769 onFocus(); |
1723 onFocus(); |
1770 } |
1724 } |
1771 |
1725 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
1772 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
|
1773 icon: library_button, |
1726 icon: library_button, |
1774 title: keyboard_title, |
1727 title: keyboard_title, |
1775 onClick: onClick, |
1728 onClick: onClick, |
1776 isActive: isActive, |
1729 isActive: isActive, |
1777 role: "menuitemcheckbox" |
1730 role: "menuitemcheckbox" |
1778 }); |
1731 }); |
1779 } |
1732 } |
1780 |
|
1781 }; |
1733 }; |
1782 |
1734 |
|
1735 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/help.js |
|
1736 /** |
|
1737 * WordPress dependencies |
|
1738 */ |
|
1739 |
|
1740 |
|
1741 const help = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
|
1742 xmlns: "http://www.w3.org/2000/svg", |
|
1743 viewBox: "0 0 24 24", |
|
1744 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
|
1745 d: "M12 4.75a7.25 7.25 0 100 14.5 7.25 7.25 0 000-14.5zM3.25 12a8.75 8.75 0 1117.5 0 8.75 8.75 0 01-17.5 0zM12 8.75a1.5 1.5 0 01.167 2.99c-.465.052-.917.44-.917 1.01V14h1.5v-.845A3 3 0 109 10.25h1.5a1.5 1.5 0 011.5-1.5zM11.25 15v1.5h1.5V15h-1.5z" |
|
1746 }) |
|
1747 }); |
|
1748 /* harmony default export */ const library_help = (help); |
|
1749 |
|
1750 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/unknown/index.js |
|
1751 /** |
|
1752 * WordPress dependencies |
|
1753 */ |
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 const unknown_name = 'core/unknown'; |
|
1760 const unknown_title = (0,external_wp_i18n_namespaceObject.__)('Clear Unknown Formatting'); |
|
1761 function selectionContainsUnknownFormats(value) { |
|
1762 if ((0,external_wp_richText_namespaceObject.isCollapsed)(value)) { |
|
1763 return false; |
|
1764 } |
|
1765 const selectedValue = (0,external_wp_richText_namespaceObject.slice)(value); |
|
1766 return selectedValue.formats.some(formats => { |
|
1767 return formats.some(format => format.type === unknown_name); |
|
1768 }); |
|
1769 } |
|
1770 const unknown = { |
|
1771 name: unknown_name, |
|
1772 title: unknown_title, |
|
1773 tagName: '*', |
|
1774 className: null, |
|
1775 edit({ |
|
1776 isActive, |
|
1777 value, |
|
1778 onChange, |
|
1779 onFocus |
|
1780 }) { |
|
1781 if (!isActive && !selectionContainsUnknownFormats(value)) { |
|
1782 return null; |
|
1783 } |
|
1784 function onClick() { |
|
1785 onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, unknown_name)); |
|
1786 onFocus(); |
|
1787 } |
|
1788 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
|
1789 name: "unknown", |
|
1790 icon: library_help, |
|
1791 title: unknown_title, |
|
1792 onClick: onClick, |
|
1793 isActive: true |
|
1794 }); |
|
1795 } |
|
1796 }; |
|
1797 |
|
1798 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/language.js |
|
1799 /** |
|
1800 * WordPress dependencies |
|
1801 */ |
|
1802 |
|
1803 |
|
1804 const language = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
|
1805 xmlns: "http://www.w3.org/2000/svg", |
|
1806 viewBox: "0 0 24 24", |
|
1807 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
|
1808 d: "M17.5 10h-1.7l-3.7 10.5h1.7l.9-2.6h3.9l.9 2.6h1.7L17.5 10zm-2.2 6.3 1.4-4 1.4 4h-2.8zm-4.8-3.8c1.6-1.8 2.9-3.6 3.7-5.7H16V5.2h-5.8V3H8.8v2.2H3v1.5h9.6c-.7 1.6-1.8 3.1-3.1 4.6C8.6 10.2 7.8 9 7.2 8H5.6c.6 1.4 1.7 2.9 2.9 4.4l-2.4 2.4c-.3.4-.7.8-1.1 1.2l1 1 1.2-1.2c.8-.8 1.6-1.5 2.3-2.3.8.9 1.7 1.7 2.5 2.5l.6-1.5c-.7-.6-1.4-1.3-2.1-2z" |
|
1809 }) |
|
1810 }); |
|
1811 /* harmony default export */ const library_language = (language); |
|
1812 |
|
1813 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/language/index.js |
|
1814 /** |
|
1815 * WordPress dependencies |
|
1816 */ |
|
1817 |
|
1818 |
|
1819 /** |
|
1820 * WordPress dependencies |
|
1821 */ |
|
1822 |
|
1823 |
|
1824 |
|
1825 |
|
1826 |
|
1827 |
|
1828 |
|
1829 |
|
1830 const language_name = 'core/language'; |
|
1831 const language_title = (0,external_wp_i18n_namespaceObject.__)('Language'); |
|
1832 const language_language = { |
|
1833 name: language_name, |
|
1834 tagName: 'bdo', |
|
1835 className: null, |
|
1836 edit: language_Edit, |
|
1837 title: language_title |
|
1838 }; |
|
1839 function language_Edit({ |
|
1840 isActive, |
|
1841 value, |
|
1842 onChange, |
|
1843 contentRef |
|
1844 }) { |
|
1845 const [isPopoverVisible, setIsPopoverVisible] = (0,external_wp_element_namespaceObject.useState)(false); |
|
1846 const togglePopover = () => { |
|
1847 setIsPopoverVisible(state => !state); |
|
1848 }; |
|
1849 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
|
1850 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { |
|
1851 icon: library_language, |
|
1852 label: language_title, |
|
1853 title: language_title, |
|
1854 onClick: () => { |
|
1855 if (isActive) { |
|
1856 onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, language_name)); |
|
1857 } else { |
|
1858 togglePopover(); |
|
1859 } |
|
1860 }, |
|
1861 isActive: isActive, |
|
1862 role: "menuitemcheckbox" |
|
1863 }), isPopoverVisible && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InlineLanguageUI, { |
|
1864 value: value, |
|
1865 onChange: onChange, |
|
1866 onClose: togglePopover, |
|
1867 contentRef: contentRef |
|
1868 })] |
|
1869 }); |
|
1870 } |
|
1871 function InlineLanguageUI({ |
|
1872 value, |
|
1873 contentRef, |
|
1874 onChange, |
|
1875 onClose |
|
1876 }) { |
|
1877 const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({ |
|
1878 editableContentElement: contentRef.current, |
|
1879 settings: language_language |
|
1880 }); |
|
1881 const [lang, setLang] = (0,external_wp_element_namespaceObject.useState)(''); |
|
1882 const [dir, setDir] = (0,external_wp_element_namespaceObject.useState)('ltr'); |
|
1883 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover, { |
|
1884 className: "block-editor-format-toolbar__language-popover", |
|
1885 anchor: popoverAnchor, |
|
1886 onClose: onClose, |
|
1887 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("form", { |
|
1888 className: "block-editor-format-toolbar__language-container-content", |
|
1889 onSubmit: event => { |
|
1890 event.preventDefault(); |
|
1891 onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, { |
|
1892 type: language_name, |
|
1893 attributes: { |
|
1894 lang, |
|
1895 dir |
|
1896 } |
|
1897 })); |
|
1898 onClose(); |
|
1899 }, |
|
1900 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, { |
|
1901 label: language_title, |
|
1902 value: lang, |
|
1903 onChange: val => setLang(val), |
|
1904 help: (0,external_wp_i18n_namespaceObject.__)('A valid language attribute, like "en" or "fr".') |
|
1905 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, { |
|
1906 label: (0,external_wp_i18n_namespaceObject.__)('Text direction'), |
|
1907 value: dir, |
|
1908 options: [{ |
|
1909 label: (0,external_wp_i18n_namespaceObject.__)('Left to right'), |
|
1910 value: 'ltr' |
|
1911 }, { |
|
1912 label: (0,external_wp_i18n_namespaceObject.__)('Right to left'), |
|
1913 value: 'rtl' |
|
1914 }], |
|
1915 onChange: val => setDir(val) |
|
1916 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHStack, { |
|
1917 alignment: "right", |
|
1918 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, { |
|
1919 variant: "primary", |
|
1920 type: "submit", |
|
1921 text: (0,external_wp_i18n_namespaceObject.__)('Apply') |
|
1922 }) |
|
1923 })] |
|
1924 }) |
|
1925 }); |
|
1926 } |
|
1927 |
|
1928 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/non-breaking-space/index.js |
|
1929 /** |
|
1930 * WordPress dependencies |
|
1931 */ |
|
1932 |
|
1933 |
|
1934 |
|
1935 |
|
1936 const non_breaking_space_name = 'core/non-breaking-space'; |
|
1937 const non_breaking_space_title = (0,external_wp_i18n_namespaceObject.__)('Non breaking space'); |
|
1938 const nonBreakingSpace = { |
|
1939 name: non_breaking_space_name, |
|
1940 title: non_breaking_space_title, |
|
1941 tagName: 'nbsp', |
|
1942 className: null, |
|
1943 edit({ |
|
1944 value, |
|
1945 onChange |
|
1946 }) { |
|
1947 function addNonBreakingSpace() { |
|
1948 onChange((0,external_wp_richText_namespaceObject.insert)(value, '\u00a0')); |
|
1949 } |
|
1950 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { |
|
1951 type: "primaryShift", |
|
1952 character: " ", |
|
1953 onUse: addNonBreakingSpace |
|
1954 }); |
|
1955 } |
|
1956 }; |
|
1957 |
1783 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/default-formats.js |
1958 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/default-formats.js |
1784 /** |
1959 /** |
1785 * Internal dependencies |
1960 * Internal dependencies |
1786 */ |
1961 */ |
1787 |
1962 |