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