| 1 |
var wp; |
| 2 |
(wp ||= {}).formatLibrary = (() => { |
| 3 |
var __create = Object.create; |
| 4 |
var __defProp = Object.defineProperty; |
| 5 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 6 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
| 7 |
var __getProtoOf = Object.getPrototypeOf; |
| 8 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 9 |
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { |
| 10 |
get: (a, b) => (typeof require !== "undefined" ? require : a)[b] |
| 11 |
}) : x)(function(x) { |
| 12 |
if (typeof require !== "undefined") return require.apply(this, arguments); |
| 13 |
throw Error('Dynamic require of "' + x + '" is not supported'); |
| 14 |
}); |
| 15 |
var __commonJS = (cb, mod) => function __require2() { |
| 16 |
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; |
| 17 |
}; |
| 18 |
var __copyProps = (to, from, except, desc) => { |
| 19 |
if (from && typeof from === "object" || typeof from === "function") { |
| 20 |
for (let key of __getOwnPropNames(from)) |
| 21 |
if (!__hasOwnProp.call(to, key) && key !== except) |
| 22 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
| 23 |
} |
| 24 |
return to; |
| 25 |
}; |
| 26 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
| 27 |
// If the importer is in node compatibility mode or this is not an ESM |
| 28 |
// file that has been converted to a CommonJS file using a Babel- |
| 29 |
// compatible transform (i.e. "__esModule" has not been set), then set |
| 30 |
// "default" to the CommonJS "module.exports" for node compatibility. |
| 31 |
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
| 32 |
mod |
| 33 |
)); |
| 34 |
|
| 35 |
// package-external:@wordpress/rich-text |
| 36 |
var require_rich_text = __commonJS({ |
| 37 |
"package-external:@wordpress/rich-text"(exports, module) { |
| 38 |
module.exports = window.wp.richText; |
| 39 |
} |
| 40 |
}); |
| 41 |
|
| 42 |
// package-external:@wordpress/i18n |
| 43 |
var require_i18n = __commonJS({ |
| 44 |
"package-external:@wordpress/i18n"(exports, module) { |
| 45 |
module.exports = window.wp.i18n; |
| 46 |
} |
| 47 |
}); |
| 48 |
|
| 49 |
// package-external:@wordpress/block-editor |
| 50 |
var require_block_editor = __commonJS({ |
| 51 |
"package-external:@wordpress/block-editor"(exports, module) { |
| 52 |
module.exports = window.wp.blockEditor; |
| 53 |
} |
| 54 |
}); |
| 55 |
|
| 56 |
// package-external:@wordpress/element |
| 57 |
var require_element = __commonJS({ |
| 58 |
"package-external:@wordpress/element"(exports, module) { |
| 59 |
module.exports = window.wp.element; |
| 60 |
} |
| 61 |
}); |
| 62 |
|
| 63 |
// package-external:@wordpress/primitives |
| 64 |
var require_primitives = __commonJS({ |
| 65 |
"package-external:@wordpress/primitives"(exports, module) { |
| 66 |
module.exports = window.wp.primitives; |
| 67 |
} |
| 68 |
}); |
| 69 |
|
| 70 |
// vendor-external:react/jsx-runtime |
| 71 |
var require_jsx_runtime = __commonJS({ |
| 72 |
"vendor-external:react/jsx-runtime"(exports, module) { |
| 73 |
module.exports = window.ReactJSXRuntime; |
| 74 |
} |
| 75 |
}); |
| 76 |
|
| 77 |
// package-external:@wordpress/components |
| 78 |
var require_components = __commonJS({ |
| 79 |
"package-external:@wordpress/components"(exports, module) { |
| 80 |
module.exports = window.wp.components; |
| 81 |
} |
| 82 |
}); |
| 83 |
|
| 84 |
// package-external:@wordpress/url |
| 85 |
var require_url = __commonJS({ |
| 86 |
"package-external:@wordpress/url"(exports, module) { |
| 87 |
module.exports = window.wp.url; |
| 88 |
} |
| 89 |
}); |
| 90 |
|
| 91 |
// package-external:@wordpress/html-entities |
| 92 |
var require_html_entities = __commonJS({ |
| 93 |
"package-external:@wordpress/html-entities"(exports, module) { |
| 94 |
module.exports = window.wp.htmlEntities; |
| 95 |
} |
| 96 |
}); |
| 97 |
|
| 98 |
// package-external:@wordpress/a11y |
| 99 |
var require_a11y = __commonJS({ |
| 100 |
"package-external:@wordpress/a11y"(exports, module) { |
| 101 |
module.exports = window.wp.a11y; |
| 102 |
} |
| 103 |
}); |
| 104 |
|
| 105 |
// package-external:@wordpress/data |
| 106 |
var require_data = __commonJS({ |
| 107 |
"package-external:@wordpress/data"(exports, module) { |
| 108 |
module.exports = window.wp.data; |
| 109 |
} |
| 110 |
}); |
| 111 |
|
| 112 |
// package-external:@wordpress/compose |
| 113 |
var require_compose = __commonJS({ |
| 114 |
"package-external:@wordpress/compose"(exports, module) { |
| 115 |
module.exports = window.wp.compose; |
| 116 |
} |
| 117 |
}); |
| 118 |
|
| 119 |
// vendor-external:react |
| 120 |
var require_react = __commonJS({ |
| 121 |
"vendor-external:react"(exports, module) { |
| 122 |
module.exports = window.React; |
| 123 |
} |
| 124 |
}); |
| 125 |
|
| 126 |
// package-external:@wordpress/private-apis |
| 127 |
var require_private_apis = __commonJS({ |
| 128 |
"package-external:@wordpress/private-apis"(exports, module) { |
| 129 |
module.exports = window.wp.privateApis; |
| 130 |
} |
| 131 |
}); |
| 132 |
|
| 133 |
// packages/format-library/build-module/index.mjs |
| 134 |
var import_rich_text18 = __toESM(require_rich_text(), 1); |
| 135 |
|
| 136 |
// packages/format-library/build-module/bold/index.mjs |
| 137 |
var import_i18n = __toESM(require_i18n(), 1); |
| 138 |
var import_rich_text = __toESM(require_rich_text(), 1); |
| 139 |
var import_block_editor = __toESM(require_block_editor(), 1); |
| 140 |
|
| 141 |
// packages/icons/build-module/icon/index.mjs |
| 142 |
var import_element = __toESM(require_element(), 1); |
| 143 |
var icon_default = (0, import_element.forwardRef)( |
| 144 |
({ icon, size = 24, ...props }, ref) => { |
| 145 |
return (0, import_element.cloneElement)(icon, { |
| 146 |
width: size, |
| 147 |
height: size, |
| 148 |
...props, |
| 149 |
ref |
| 150 |
}); |
| 151 |
} |
| 152 |
); |
| 153 |
|
| 154 |
// packages/icons/build-module/library/button.mjs |
| 155 |
var import_primitives = __toESM(require_primitives(), 1); |
| 156 |
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); |
| 157 |
var button_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { 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" }) }); |
| 158 |
|
| 159 |
// packages/icons/build-module/library/code.mjs |
| 160 |
var import_primitives2 = __toESM(require_primitives(), 1); |
| 161 |
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); |
| 162 |
var code_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { 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" }) }); |
| 163 |
|
| 164 |
// packages/icons/build-module/library/color.mjs |
| 165 |
var import_primitives3 = __toESM(require_primitives(), 1); |
| 166 |
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); |
| 167 |
var color_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { 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" }) }); |
| 168 |
|
| 169 |
// packages/icons/build-module/library/format-bold.mjs |
| 170 |
var import_primitives4 = __toESM(require_primitives(), 1); |
| 171 |
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); |
| 172 |
var format_bold_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { 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" }) }); |
| 173 |
|
| 174 |
// packages/icons/build-module/library/format-italic.mjs |
| 175 |
var import_primitives5 = __toESM(require_primitives(), 1); |
| 176 |
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); |
| 177 |
var format_italic_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M12.5 5L10 19h1.9l2.5-14z" }) }); |
| 178 |
|
| 179 |
// packages/icons/build-module/library/format-strikethrough.mjs |
| 180 |
var import_primitives6 = __toESM(require_primitives(), 1); |
| 181 |
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); |
| 182 |
var format_strikethrough_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { 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" }) }); |
| 183 |
|
| 184 |
// packages/icons/build-module/library/help.mjs |
| 185 |
var import_primitives7 = __toESM(require_primitives(), 1); |
| 186 |
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); |
| 187 |
var help_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { d: "M12 4a8 8 0 1 1 .001 16.001A8 8 0 0 1 12 4Zm0 1.5a6.5 6.5 0 1 0-.001 13.001A6.5 6.5 0 0 0 12 5.5Zm.75 11h-1.5V15h1.5v1.5Zm-.445-9.234a3 3 0 0 1 .445 5.89V14h-1.5v-1.25c0-.57.452-.958.917-1.01A1.5 1.5 0 0 0 12 8.75a1.5 1.5 0 0 0-1.5 1.5H9a3 3 0 0 1 3.305-2.984Z" }) }); |
| 188 |
|
| 189 |
// packages/icons/build-module/library/language.mjs |
| 190 |
var import_primitives8 = __toESM(require_primitives(), 1); |
| 191 |
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); |
| 192 |
var language_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { 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" }) }); |
| 193 |
|
| 194 |
// packages/icons/build-module/library/link.mjs |
| 195 |
var import_primitives9 = __toESM(require_primitives(), 1); |
| 196 |
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); |
| 197 |
var link_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { 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" }) }); |
| 198 |
|
| 199 |
// packages/icons/build-module/library/math.mjs |
| 200 |
var import_primitives10 = __toESM(require_primitives(), 1); |
| 201 |
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); |
| 202 |
var math_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { d: "M11.2 6.8c-.7 0-1.4.5-1.6 1.1l-2.8 7.5-1.2-1.8c-.1-.2-.4-.3-.6-.3H3v1.5h1.6l1.2 1.8c.6.9 1.9.7 2.2-.3l2.9-7.9s.1-.2.2-.2h7.8V6.7h-7.8Zm5.3 3.4-1.9 1.9-1.9-1.9-1.1 1.1 1.9 1.9-1.9 1.9 1.1 1.1 1.9-1.9 1.9 1.9 1.1-1.1-1.9-1.9 1.9-1.9-1.1-1.1Z" }) }); |
| 203 |
|
| 204 |
// packages/icons/build-module/library/subscript.mjs |
| 205 |
var import_primitives11 = __toESM(require_primitives(), 1); |
| 206 |
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); |
| 207 |
var subscript_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { 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" }) }); |
| 208 |
|
| 209 |
// packages/icons/build-module/library/superscript.mjs |
| 210 |
var import_primitives12 = __toESM(require_primitives(), 1); |
| 211 |
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); |
| 212 |
var superscript_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { 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" }) }); |
| 213 |
|
| 214 |
// packages/icons/build-module/library/text-color.mjs |
| 215 |
var import_primitives13 = __toESM(require_primitives(), 1); |
| 216 |
var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); |
| 217 |
var text_color_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { 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" }) }); |
| 218 |
|
| 219 |
// packages/format-library/build-module/bold/index.mjs |
| 220 |
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1); |
| 221 |
var name = "core/bold"; |
| 222 |
var title = (0, import_i18n.__)("Bold"); |
| 223 |
var bold = { |
| 224 |
name, |
| 225 |
title, |
| 226 |
tagName: "strong", |
| 227 |
className: null, |
| 228 |
edit({ isActive, value, onChange, onFocus, isVisible = true }) { |
| 229 |
function onToggle() { |
| 230 |
onChange((0, import_rich_text.toggleFormat)(value, { type: name, title })); |
| 231 |
} |
| 232 |
function onClick() { |
| 233 |
onChange((0, import_rich_text.toggleFormat)(value, { type: name })); |
| 234 |
onFocus(); |
| 235 |
} |
| 236 |
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [ |
| 237 |
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)( |
| 238 |
import_block_editor.RichTextShortcut, |
| 239 |
{ |
| 240 |
type: "primary", |
| 241 |
character: "b", |
| 242 |
onUse: onToggle |
| 243 |
} |
| 244 |
), |
| 245 |
isVisible && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( |
| 246 |
import_block_editor.RichTextToolbarButton, |
| 247 |
{ |
| 248 |
name: "bold", |
| 249 |
icon: format_bold_default, |
| 250 |
title, |
| 251 |
onClick, |
| 252 |
isActive, |
| 253 |
shortcutType: "primary", |
| 254 |
shortcutCharacter: "b" |
| 255 |
} |
| 256 |
), |
| 257 |
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)( |
| 258 |
import_block_editor.__unstableRichTextInputEvent, |
| 259 |
{ |
| 260 |
inputType: "formatBold", |
| 261 |
onInput: onToggle |
| 262 |
} |
| 263 |
) |
| 264 |
] }); |
| 265 |
} |
| 266 |
}; |
| 267 |
|
| 268 |
// packages/format-library/build-module/code/index.mjs |
| 269 |
var import_i18n2 = __toESM(require_i18n(), 1); |
| 270 |
var import_rich_text2 = __toESM(require_rich_text(), 1); |
| 271 |
var import_block_editor2 = __toESM(require_block_editor(), 1); |
| 272 |
var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1); |
| 273 |
var name2 = "core/code"; |
| 274 |
var title2 = (0, import_i18n2.__)("Inline code"); |
| 275 |
var code = { |
| 276 |
name: name2, |
| 277 |
title: title2, |
| 278 |
tagName: "code", |
| 279 |
className: null, |
| 280 |
__unstableInputRule(value) { |
| 281 |
const BACKTICK = "`"; |
| 282 |
const { start, text } = value; |
| 283 |
const characterBefore = text[start - 1]; |
| 284 |
if (characterBefore !== BACKTICK) { |
| 285 |
return value; |
| 286 |
} |
| 287 |
if (start - 2 < 0) { |
| 288 |
return value; |
| 289 |
} |
| 290 |
const indexBefore = text.lastIndexOf(BACKTICK, start - 2); |
| 291 |
if (indexBefore === -1) { |
| 292 |
return value; |
| 293 |
} |
| 294 |
const startIndex = indexBefore; |
| 295 |
const endIndex = start - 2; |
| 296 |
if (startIndex === endIndex) { |
| 297 |
return value; |
| 298 |
} |
| 299 |
value = (0, import_rich_text2.remove)(value, startIndex, startIndex + 1); |
| 300 |
value = (0, import_rich_text2.remove)(value, endIndex, endIndex + 1); |
| 301 |
value = (0, import_rich_text2.applyFormat)(value, { type: name2 }, startIndex, endIndex); |
| 302 |
return value; |
| 303 |
}, |
| 304 |
edit({ value, onChange, onFocus, isActive }) { |
| 305 |
function onClick() { |
| 306 |
onChange((0, import_rich_text2.toggleFormat)(value, { type: name2, title: title2 })); |
| 307 |
onFocus(); |
| 308 |
} |
| 309 |
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [ |
| 310 |
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)( |
| 311 |
import_block_editor2.RichTextShortcut, |
| 312 |
{ |
| 313 |
type: "access", |
| 314 |
character: "x", |
| 315 |
onUse: onClick |
| 316 |
} |
| 317 |
), |
| 318 |
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)( |
| 319 |
import_block_editor2.RichTextToolbarButton, |
| 320 |
{ |
| 321 |
icon: code_default, |
| 322 |
title: title2, |
| 323 |
onClick, |
| 324 |
isActive, |
| 325 |
role: "menuitemcheckbox" |
| 326 |
} |
| 327 |
) |
| 328 |
] }); |
| 329 |
} |
| 330 |
}; |
| 331 |
|
| 332 |
// packages/format-library/build-module/image/index.mjs |
| 333 |
var import_components = __toESM(require_components(), 1); |
| 334 |
var import_i18n3 = __toESM(require_i18n(), 1); |
| 335 |
var import_element2 = __toESM(require_element(), 1); |
| 336 |
var import_rich_text3 = __toESM(require_rich_text(), 1); |
| 337 |
var import_block_editor3 = __toESM(require_block_editor(), 1); |
| 338 |
var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1); |
| 339 |
var ALLOWED_MEDIA_TYPES = ["image"]; |
| 340 |
var name3 = "core/image"; |
| 341 |
var title3 = (0, import_i18n3.__)("Inline image"); |
| 342 |
function getCurrentImageId(activeObjectAttributes) { |
| 343 |
if (!activeObjectAttributes?.className) { |
| 344 |
return void 0; |
| 345 |
} |
| 346 |
const [, id] = activeObjectAttributes.className.match(/wp-image-(\d+)/) ?? []; |
| 347 |
return id ? parseInt(id, 10) : void 0; |
| 348 |
} |
| 349 |
var image = { |
| 350 |
name: name3, |
| 351 |
title: title3, |
| 352 |
keywords: [(0, import_i18n3.__)("photo"), (0, import_i18n3.__)("media")], |
| 353 |
object: true, |
| 354 |
tagName: "img", |
| 355 |
className: null, |
| 356 |
attributes: { |
| 357 |
className: "class", |
| 358 |
style: "style", |
| 359 |
url: "src", |
| 360 |
alt: "alt" |
| 361 |
}, |
| 362 |
edit: Edit |
| 363 |
}; |
| 364 |
function InlineUI({ value, onChange, activeObjectAttributes, contentRef }) { |
| 365 |
const { style, alt } = activeObjectAttributes; |
| 366 |
const width = style?.replace(/\D/g, ""); |
| 367 |
const [editedWidth, setEditedWidth] = (0, import_element2.useState)(width); |
| 368 |
const [editedAlt, setEditedAlt] = (0, import_element2.useState)(alt); |
| 369 |
const hasChanged = editedWidth !== width || editedAlt !== alt; |
| 370 |
const popoverAnchor = (0, import_rich_text3.useAnchor)({ |
| 371 |
editableContentElement: contentRef.current, |
| 372 |
settings: image |
| 373 |
}); |
| 374 |
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( |
| 375 |
import_components.Popover, |
| 376 |
{ |
| 377 |
focusOnMount: false, |
| 378 |
anchor: popoverAnchor, |
| 379 |
className: "block-editor-format-toolbar__image-popover", |
| 380 |
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( |
| 381 |
"form", |
| 382 |
{ |
| 383 |
className: "block-editor-format-toolbar__image-container-content", |
| 384 |
onSubmit: (event) => { |
| 385 |
const newReplacements = value.replacements.slice(); |
| 386 |
newReplacements[value.start] = { |
| 387 |
type: name3, |
| 388 |
attributes: { |
| 389 |
...activeObjectAttributes, |
| 390 |
style: editedWidth ? `width: ${editedWidth}px;` : "", |
| 391 |
alt: editedAlt |
| 392 |
} |
| 393 |
}; |
| 394 |
onChange({ |
| 395 |
...value, |
| 396 |
replacements: newReplacements |
| 397 |
}); |
| 398 |
event.preventDefault(); |
| 399 |
}, |
| 400 |
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_components.__experimentalVStack, { spacing: 4, children: [ |
| 401 |
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)( |
| 402 |
import_components.__experimentalNumberControl, |
| 403 |
{ |
| 404 |
__next40pxDefaultSize: true, |
| 405 |
label: (0, import_i18n3.__)("Width"), |
| 406 |
value: editedWidth, |
| 407 |
min: 1, |
| 408 |
onChange: (newWidth) => { |
| 409 |
setEditedWidth(newWidth); |
| 410 |
} |
| 411 |
} |
| 412 |
), |
| 413 |
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)( |
| 414 |
import_components.TextareaControl, |
| 415 |
{ |
| 416 |
label: (0, import_i18n3.__)("Alternative text"), |
| 417 |
value: editedAlt, |
| 418 |
onChange: (newAlt) => { |
| 419 |
setEditedAlt(newAlt); |
| 420 |
}, |
| 421 |
help: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [ |
| 422 |
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)( |
| 423 |
import_components.ExternalLink, |
| 424 |
{ |
| 425 |
href: ( |
| 426 |
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations. |
| 427 |
(0, import_i18n3.__)( |
| 428 |
"https://www.w3.org/WAI/tutorials/images/decision-tree/" |
| 429 |
) |
| 430 |
), |
| 431 |
children: (0, import_i18n3.__)( |
| 432 |
"Describe the purpose of the image." |
| 433 |
) |
| 434 |
} |
| 435 |
), |
| 436 |
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("br", {}), |
| 437 |
(0, import_i18n3.__)("Leave empty if decorative.") |
| 438 |
] }) |
| 439 |
} |
| 440 |
), |
| 441 |
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_components.__experimentalHStack, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( |
| 442 |
import_components.Button, |
| 443 |
{ |
| 444 |
disabled: !hasChanged, |
| 445 |
accessibleWhenDisabled: true, |
| 446 |
variant: "primary", |
| 447 |
type: "submit", |
| 448 |
size: "compact", |
| 449 |
children: (0, import_i18n3.__)("Apply") |
| 450 |
} |
| 451 |
) }) |
| 452 |
] }) |
| 453 |
} |
| 454 |
) |
| 455 |
} |
| 456 |
); |
| 457 |
} |
| 458 |
function Edit({ |
| 459 |
value, |
| 460 |
onChange, |
| 461 |
onFocus, |
| 462 |
isObjectActive, |
| 463 |
activeObjectAttributes, |
| 464 |
contentRef |
| 465 |
}) { |
| 466 |
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_block_editor3.MediaUploadCheck, { children: [ |
| 467 |
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)( |
| 468 |
import_block_editor3.MediaUpload, |
| 469 |
{ |
| 470 |
allowedTypes: ALLOWED_MEDIA_TYPES, |
| 471 |
value: getCurrentImageId(activeObjectAttributes), |
| 472 |
onSelect: ({ id, url, alt, width: imgWidth }) => { |
| 473 |
onChange( |
| 474 |
(0, import_rich_text3.insertObject)(value, { |
| 475 |
type: name3, |
| 476 |
attributes: { |
| 477 |
className: `wp-image-${id}`, |
| 478 |
style: `width: ${Math.min( |
| 479 |
imgWidth, |
| 480 |
150 |
| 481 |
)}px;`, |
| 482 |
url, |
| 483 |
alt |
| 484 |
} |
| 485 |
}) |
| 486 |
); |
| 487 |
onFocus(); |
| 488 |
}, |
| 489 |
render: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( |
| 490 |
import_block_editor3.RichTextToolbarButton, |
| 491 |
{ |
| 492 |
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( |
| 493 |
import_components.SVG, |
| 494 |
{ |
| 495 |
xmlns: "http://www.w3.org/2000/svg", |
| 496 |
viewBox: "0 0 24 24", |
| 497 |
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_components.Path, { 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" }) |
| 498 |
} |
| 499 |
), |
| 500 |
title: isObjectActive ? (0, import_i18n3.__)("Replace image") : title3, |
| 501 |
onClick: open, |
| 502 |
isActive: isObjectActive |
| 503 |
} |
| 504 |
) |
| 505 |
} |
| 506 |
), |
| 507 |
isObjectActive && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( |
| 508 |
InlineUI, |
| 509 |
{ |
| 510 |
value, |
| 511 |
onChange, |
| 512 |
activeObjectAttributes, |
| 513 |
contentRef |
| 514 |
} |
| 515 |
) |
| 516 |
] }); |
| 517 |
} |
| 518 |
|
| 519 |
// packages/format-library/build-module/italic/index.mjs |
| 520 |
var import_i18n4 = __toESM(require_i18n(), 1); |
| 521 |
var import_rich_text4 = __toESM(require_rich_text(), 1); |
| 522 |
var import_block_editor4 = __toESM(require_block_editor(), 1); |
| 523 |
var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1); |
| 524 |
var name4 = "core/italic"; |
| 525 |
var title4 = (0, import_i18n4.__)("Italic"); |
| 526 |
var italic = { |
| 527 |
name: name4, |
| 528 |
title: title4, |
| 529 |
tagName: "em", |
| 530 |
className: null, |
| 531 |
edit({ isActive, value, onChange, onFocus, isVisible = true }) { |
| 532 |
function onToggle() { |
| 533 |
onChange((0, import_rich_text4.toggleFormat)(value, { type: name4, title: title4 })); |
| 534 |
} |
| 535 |
function onClick() { |
| 536 |
onChange((0, import_rich_text4.toggleFormat)(value, { type: name4 })); |
| 537 |
onFocus(); |
| 538 |
} |
| 539 |
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [ |
| 540 |
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)( |
| 541 |
import_block_editor4.RichTextShortcut, |
| 542 |
{ |
| 543 |
type: "primary", |
| 544 |
character: "i", |
| 545 |
onUse: onToggle |
| 546 |
} |
| 547 |
), |
| 548 |
isVisible && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)( |
| 549 |
import_block_editor4.RichTextToolbarButton, |
| 550 |
{ |
| 551 |
name: "italic", |
| 552 |
icon: format_italic_default, |
| 553 |
title: title4, |
| 554 |
onClick, |
| 555 |
isActive, |
| 556 |
shortcutType: "primary", |
| 557 |
shortcutCharacter: "i" |
| 558 |
} |
| 559 |
), |
| 560 |
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)( |
| 561 |
import_block_editor4.__unstableRichTextInputEvent, |
| 562 |
{ |
| 563 |
inputType: "formatItalic", |
| 564 |
onInput: onToggle |
| 565 |
} |
| 566 |
) |
| 567 |
] }); |
| 568 |
} |
| 569 |
}; |
| 570 |
|
| 571 |
// packages/format-library/build-module/link/index.mjs |
| 572 |
var import_i18n7 = __toESM(require_i18n(), 1); |
| 573 |
var import_element6 = __toESM(require_element(), 1); |
| 574 |
var import_rich_text6 = __toESM(require_rich_text(), 1); |
| 575 |
var import_url3 = __toESM(require_url(), 1); |
| 576 |
var import_block_editor6 = __toESM(require_block_editor(), 1); |
| 577 |
var import_html_entities = __toESM(require_html_entities(), 1); |
| 578 |
var import_a11y2 = __toESM(require_a11y(), 1); |
| 579 |
|
| 580 |
// packages/format-library/build-module/link/inline.mjs |
| 581 |
var import_element5 = __toESM(require_element(), 1); |
| 582 |
var import_i18n6 = __toESM(require_i18n(), 1); |
| 583 |
var import_a11y = __toESM(require_a11y(), 1); |
| 584 |
var import_components3 = __toESM(require_components(), 1); |
| 585 |
var import_url2 = __toESM(require_url(), 1); |
| 586 |
var import_rich_text5 = __toESM(require_rich_text(), 1); |
| 587 |
var import_block_editor5 = __toESM(require_block_editor(), 1); |
| 588 |
var import_data = __toESM(require_data(), 1); |
| 589 |
|
| 590 |
// packages/format-library/build-module/link/utils.mjs |
| 591 |
var import_url = __toESM(require_url(), 1); |
| 592 |
function isValidHref(href) { |
| 593 |
if (!href) { |
| 594 |
return false; |
| 595 |
} |
| 596 |
const trimmedHref = href.trim(); |
| 597 |
if (!trimmedHref) { |
| 598 |
return false; |
| 599 |
} |
| 600 |
if (/^\S+:/.test(trimmedHref)) { |
| 601 |
const protocol = (0, import_url.getProtocol)(trimmedHref); |
| 602 |
if (!(0, import_url.isValidProtocol)(protocol)) { |
| 603 |
return false; |
| 604 |
} |
| 605 |
if (protocol.startsWith("http") && !/^https?:\/\/[^\/\s]/i.test(trimmedHref)) { |
| 606 |
return false; |
| 607 |
} |
| 608 |
const authority = (0, import_url.getAuthority)(trimmedHref); |
| 609 |
if (!(0, import_url.isValidAuthority)(authority)) { |
| 610 |
return false; |
| 611 |
} |
| 612 |
const path = (0, import_url.getPath)(trimmedHref); |
| 613 |
if (path && !(0, import_url.isValidPath)(path)) { |
| 614 |
return false; |
| 615 |
} |
| 616 |
const queryString = (0, import_url.getQueryString)(trimmedHref); |
| 617 |
if (queryString && !(0, import_url.isValidQueryString)(queryString)) { |
| 618 |
return false; |
| 619 |
} |
| 620 |
const fragment = (0, import_url.getFragment)(trimmedHref); |
| 621 |
if (fragment && !(0, import_url.isValidFragment)(fragment)) { |
| 622 |
return false; |
| 623 |
} |
| 624 |
} |
| 625 |
if (trimmedHref.startsWith("#") && !(0, import_url.isValidFragment)(trimmedHref)) { |
| 626 |
return false; |
| 627 |
} |
| 628 |
return true; |
| 629 |
} |
| 630 |
function createLinkFormat({ |
| 631 |
url, |
| 632 |
type, |
| 633 |
id, |
| 634 |
opensInNewWindow, |
| 635 |
nofollow, |
| 636 |
cssClasses |
| 637 |
}) { |
| 638 |
const format = { |
| 639 |
type: "core/link", |
| 640 |
attributes: { |
| 641 |
url |
| 642 |
} |
| 643 |
}; |
| 644 |
if (type) { |
| 645 |
format.attributes.type = type; |
| 646 |
} |
| 647 |
if (id) { |
| 648 |
format.attributes.id = id; |
| 649 |
} |
| 650 |
if (opensInNewWindow) { |
| 651 |
format.attributes.target = "_blank"; |
| 652 |
format.attributes.rel = format.attributes.rel ? format.attributes.rel + " noopener" : "noopener"; |
| 653 |
} |
| 654 |
if (nofollow) { |
| 655 |
format.attributes.rel = format.attributes.rel ? format.attributes.rel + " nofollow" : "nofollow"; |
| 656 |
} |
| 657 |
const trimmedCssClasses = cssClasses?.trim(); |
| 658 |
if (trimmedCssClasses?.length) { |
| 659 |
format.attributes.class = trimmedCssClasses; |
| 660 |
} |
| 661 |
return format; |
| 662 |
} |
| 663 |
function getFormatBoundary(value, format, startIndex = value.start, endIndex = value.end) { |
| 664 |
const EMPTY_BOUNDARIES = { |
| 665 |
start: void 0, |
| 666 |
end: void 0 |
| 667 |
}; |
| 668 |
const { formats } = value; |
| 669 |
let targetFormat; |
| 670 |
let initialIndex; |
| 671 |
if (!formats?.length) { |
| 672 |
return EMPTY_BOUNDARIES; |
| 673 |
} |
| 674 |
const newFormats = formats.slice(); |
| 675 |
const formatAtStart = newFormats[startIndex]?.find( |
| 676 |
({ type }) => type === format.type |
| 677 |
); |
| 678 |
const formatAtEnd = newFormats[endIndex]?.find( |
| 679 |
({ type }) => type === format.type |
| 680 |
); |
| 681 |
const formatAtEndMinusOne = newFormats[endIndex - 1]?.find( |
| 682 |
({ type }) => type === format.type |
| 683 |
); |
| 684 |
if (!!formatAtStart) { |
| 685 |
targetFormat = formatAtStart; |
| 686 |
initialIndex = startIndex; |
| 687 |
} else if (!!formatAtEnd) { |
| 688 |
targetFormat = formatAtEnd; |
| 689 |
initialIndex = endIndex; |
| 690 |
} else if (!!formatAtEndMinusOne) { |
| 691 |
targetFormat = formatAtEndMinusOne; |
| 692 |
initialIndex = endIndex - 1; |
| 693 |
} else { |
| 694 |
return EMPTY_BOUNDARIES; |
| 695 |
} |
| 696 |
const index = newFormats[initialIndex].indexOf(targetFormat); |
| 697 |
const walkingArgs = [newFormats, initialIndex, targetFormat, index]; |
| 698 |
startIndex = walkToStart(...walkingArgs); |
| 699 |
endIndex = walkToEnd(...walkingArgs); |
| 700 |
startIndex = startIndex < 0 ? 0 : startIndex; |
| 701 |
return { |
| 702 |
start: startIndex, |
| 703 |
end: endIndex + 1 |
| 704 |
}; |
| 705 |
} |
| 706 |
function walkToBoundary(formats, initialIndex, targetFormatRef, formatIndex, direction) { |
| 707 |
let index = initialIndex; |
| 708 |
const directions = { |
| 709 |
forwards: 1, |
| 710 |
backwards: -1 |
| 711 |
}; |
| 712 |
const directionIncrement = directions[direction] || 1; |
| 713 |
const inverseDirectionIncrement = directionIncrement * -1; |
| 714 |
while (formats[index] && formats[index][formatIndex] === targetFormatRef) { |
| 715 |
index = index + directionIncrement; |
| 716 |
} |
| 717 |
index = index + inverseDirectionIncrement; |
| 718 |
return index; |
| 719 |
} |
| 720 |
var partialRight = (fn, ...partialArgs) => (...args) => fn(...args, ...partialArgs); |
| 721 |
var walkToStart = partialRight(walkToBoundary, "backwards"); |
| 722 |
var walkToEnd = partialRight(walkToBoundary, "forwards"); |
| 723 |
|
| 724 |
// packages/format-library/build-module/link/css-classes-setting.mjs |
| 725 |
var import_element4 = __toESM(require_element(), 1); |
| 726 |
var import_compose = __toESM(require_compose(), 1); |
| 727 |
var import_i18n5 = __toESM(require_i18n(), 1); |
| 728 |
var import_components2 = __toESM(require_components(), 1); |
| 729 |
|
| 730 |
// node_modules/@base-ui/utils/esm/useRefWithInit.js |
| 731 |
var React = __toESM(require_react(), 1); |
| 732 |
var UNINITIALIZED = {}; |
| 733 |
function useRefWithInit(init, initArg) { |
| 734 |
const ref = React.useRef(UNINITIALIZED); |
| 735 |
if (ref.current === UNINITIALIZED) { |
| 736 |
ref.current = init(initArg); |
| 737 |
} |
| 738 |
return ref; |
| 739 |
} |
| 740 |
|
| 741 |
// node_modules/@base-ui/utils/esm/warn.js |
| 742 |
var set; |
| 743 |
if (true) { |
| 744 |
set = /* @__PURE__ */ new Set(); |
| 745 |
} |
| 746 |
function warn(...messages) { |
| 747 |
if (true) { |
| 748 |
const messageKey = messages.join(" "); |
| 749 |
if (!set.has(messageKey)) { |
| 750 |
set.add(messageKey); |
| 751 |
console.warn(`Base UI: ${messageKey}`); |
| 752 |
} |
| 753 |
} |
| 754 |
} |
| 755 |
|
| 756 |
// node_modules/@base-ui/react/esm/internals/useRenderElement.js |
| 757 |
var React4 = __toESM(require_react(), 1); |
| 758 |
|
| 759 |
// node_modules/@base-ui/utils/esm/useMergedRefs.js |
| 760 |
function useMergedRefs(a, b, c, d) { |
| 761 |
const forkRef = useRefWithInit(createForkRef).current; |
| 762 |
if (didChange(forkRef, a, b, c, d)) { |
| 763 |
update(forkRef, [a, b, c, d]); |
| 764 |
} |
| 765 |
return forkRef.callback; |
| 766 |
} |
| 767 |
function useMergedRefsN(refs) { |
| 768 |
const forkRef = useRefWithInit(createForkRef).current; |
| 769 |
if (didChangeN(forkRef, refs)) { |
| 770 |
update(forkRef, refs); |
| 771 |
} |
| 772 |
return forkRef.callback; |
| 773 |
} |
| 774 |
function createForkRef() { |
| 775 |
return { |
| 776 |
callback: null, |
| 777 |
cleanup: null, |
| 778 |
refs: [] |
| 779 |
}; |
| 780 |
} |
| 781 |
function didChange(forkRef, a, b, c, d) { |
| 782 |
return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d; |
| 783 |
} |
| 784 |
function didChangeN(forkRef, newRefs) { |
| 785 |
return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]); |
| 786 |
} |
| 787 |
function update(forkRef, refs) { |
| 788 |
forkRef.refs = refs; |
| 789 |
if (refs.every((ref) => ref == null)) { |
| 790 |
forkRef.callback = null; |
| 791 |
return; |
| 792 |
} |
| 793 |
forkRef.callback = (instance) => { |
| 794 |
if (forkRef.cleanup) { |
| 795 |
forkRef.cleanup(); |
| 796 |
forkRef.cleanup = null; |
| 797 |
} |
| 798 |
if (instance != null) { |
| 799 |
const cleanupCallbacks = Array(refs.length).fill(null); |
| 800 |
for (let i = 0; i < refs.length; i += 1) { |
| 801 |
const ref = refs[i]; |
| 802 |
if (ref == null) { |
| 803 |
continue; |
| 804 |
} |
| 805 |
switch (typeof ref) { |
| 806 |
case "function": { |
| 807 |
const refCleanup = ref(instance); |
| 808 |
if (typeof refCleanup === "function") { |
| 809 |
cleanupCallbacks[i] = refCleanup; |
| 810 |
} |
| 811 |
break; |
| 812 |
} |
| 813 |
case "object": { |
| 814 |
ref.current = instance; |
| 815 |
break; |
| 816 |
} |
| 817 |
default: |
| 818 |
} |
| 819 |
} |
| 820 |
forkRef.cleanup = () => { |
| 821 |
for (let i = 0; i < refs.length; i += 1) { |
| 822 |
const ref = refs[i]; |
| 823 |
if (ref == null) { |
| 824 |
continue; |
| 825 |
} |
| 826 |
switch (typeof ref) { |
| 827 |
case "function": { |
| 828 |
const cleanupCallback = cleanupCallbacks[i]; |
| 829 |
if (typeof cleanupCallback === "function") { |
| 830 |
cleanupCallback(); |
| 831 |
} else { |
| 832 |
ref(null); |
| 833 |
} |
| 834 |
break; |
| 835 |
} |
| 836 |
case "object": { |
| 837 |
ref.current = null; |
| 838 |
break; |
| 839 |
} |
| 840 |
default: |
| 841 |
} |
| 842 |
} |
| 843 |
}; |
| 844 |
} |
| 845 |
}; |
| 846 |
} |
| 847 |
|
| 848 |
// node_modules/@base-ui/utils/esm/getReactElementRef.js |
| 849 |
var React3 = __toESM(require_react(), 1); |
| 850 |
|
| 851 |
// node_modules/@base-ui/utils/esm/reactVersion.js |
| 852 |
var React2 = __toESM(require_react(), 1); |
| 853 |
var majorVersion = parseInt(React2.version, 10); |
| 854 |
function isReactVersionAtLeast(reactVersionToCheck) { |
| 855 |
return majorVersion >= reactVersionToCheck; |
| 856 |
} |
| 857 |
|
| 858 |
// node_modules/@base-ui/utils/esm/getReactElementRef.js |
| 859 |
function getReactElementRef(element) { |
| 860 |
if (!/* @__PURE__ */ React3.isValidElement(element)) { |
| 861 |
return null; |
| 862 |
} |
| 863 |
const reactElement = element; |
| 864 |
const propsWithRef = reactElement.props; |
| 865 |
return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null; |
| 866 |
} |
| 867 |
|
| 868 |
// node_modules/@base-ui/utils/esm/mergeObjects.js |
| 869 |
function mergeObjects(a, b) { |
| 870 |
if (a && !b) { |
| 871 |
return a; |
| 872 |
} |
| 873 |
if (!a && b) { |
| 874 |
return b; |
| 875 |
} |
| 876 |
if (a || b) { |
| 877 |
return { |
| 878 |
...a, |
| 879 |
...b |
| 880 |
}; |
| 881 |
} |
| 882 |
return void 0; |
| 883 |
} |
| 884 |
|
| 885 |
// node_modules/@base-ui/utils/esm/empty.js |
| 886 |
var EMPTY_ARRAY = Object.freeze([]); |
| 887 |
var EMPTY_OBJECT = Object.freeze({}); |
| 888 |
|
| 889 |
// node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js |
| 890 |
function getStateAttributesProps(state, customMapping) { |
| 891 |
const props = {}; |
| 892 |
for (const key in state) { |
| 893 |
const value = state[key]; |
| 894 |
if (customMapping?.hasOwnProperty(key)) { |
| 895 |
const customProps = customMapping[key](value); |
| 896 |
if (customProps != null) { |
| 897 |
Object.assign(props, customProps); |
| 898 |
} |
| 899 |
continue; |
| 900 |
} |
| 901 |
if (value === true) { |
| 902 |
props[`data-${key.toLowerCase()}`] = ""; |
| 903 |
} else if (value) { |
| 904 |
props[`data-${key.toLowerCase()}`] = value.toString(); |
| 905 |
} |
| 906 |
} |
| 907 |
return props; |
| 908 |
} |
| 909 |
|
| 910 |
// node_modules/@base-ui/react/esm/utils/resolveClassName.js |
| 911 |
function resolveClassName(className, state) { |
| 912 |
return typeof className === "function" ? className(state) : className; |
| 913 |
} |
| 914 |
|
| 915 |
// node_modules/@base-ui/react/esm/utils/resolveStyle.js |
| 916 |
function resolveStyle(style, state) { |
| 917 |
return typeof style === "function" ? style(state) : style; |
| 918 |
} |
| 919 |
|
| 920 |
// node_modules/@base-ui/react/esm/merge-props/mergeProps.js |
| 921 |
var EMPTY_PROPS = {}; |
| 922 |
function mergeProps(a, b, c, d, e) { |
| 923 |
if (!c && !d && !e && !a) { |
| 924 |
return createInitialMergedProps(b); |
| 925 |
} |
| 926 |
let merged = createInitialMergedProps(a); |
| 927 |
if (b) { |
| 928 |
merged = mergeInto(merged, b); |
| 929 |
} |
| 930 |
if (c) { |
| 931 |
merged = mergeInto(merged, c); |
| 932 |
} |
| 933 |
if (d) { |
| 934 |
merged = mergeInto(merged, d); |
| 935 |
} |
| 936 |
if (e) { |
| 937 |
merged = mergeInto(merged, e); |
| 938 |
} |
| 939 |
return merged; |
| 940 |
} |
| 941 |
function mergePropsN(props) { |
| 942 |
if (props.length === 0) { |
| 943 |
return EMPTY_PROPS; |
| 944 |
} |
| 945 |
if (props.length === 1) { |
| 946 |
return createInitialMergedProps(props[0]); |
| 947 |
} |
| 948 |
let merged = createInitialMergedProps(props[0]); |
| 949 |
for (let i = 1; i < props.length; i += 1) { |
| 950 |
merged = mergeInto(merged, props[i]); |
| 951 |
} |
| 952 |
return merged; |
| 953 |
} |
| 954 |
function createInitialMergedProps(inputProps) { |
| 955 |
if (isPropsGetter(inputProps)) { |
| 956 |
return { |
| 957 |
...resolvePropsGetter(inputProps, EMPTY_PROPS) |
| 958 |
}; |
| 959 |
} |
| 960 |
return copyInitialProps(inputProps); |
| 961 |
} |
| 962 |
function mergeInto(merged, inputProps) { |
| 963 |
if (isPropsGetter(inputProps)) { |
| 964 |
return resolvePropsGetter(inputProps, merged); |
| 965 |
} |
| 966 |
return mutablyMergeInto(merged, inputProps); |
| 967 |
} |
| 968 |
function copyInitialProps(inputProps) { |
| 969 |
const copiedProps = { |
| 970 |
...inputProps |
| 971 |
}; |
| 972 |
for (const propName in copiedProps) { |
| 973 |
const propValue = copiedProps[propName]; |
| 974 |
if (isEventHandler(propName, propValue)) { |
| 975 |
copiedProps[propName] = wrapEventHandler(propValue); |
| 976 |
} |
| 977 |
} |
| 978 |
return copiedProps; |
| 979 |
} |
| 980 |
function mutablyMergeInto(mergedProps, externalProps) { |
| 981 |
if (!externalProps) { |
| 982 |
return mergedProps; |
| 983 |
} |
| 984 |
for (const propName in externalProps) { |
| 985 |
const externalPropValue = externalProps[propName]; |
| 986 |
switch (propName) { |
| 987 |
case "style": { |
| 988 |
mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue); |
| 989 |
break; |
| 990 |
} |
| 991 |
case "className": { |
| 992 |
mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue); |
| 993 |
break; |
| 994 |
} |
| 995 |
default: { |
| 996 |
if (isEventHandler(propName, externalPropValue)) { |
| 997 |
mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue); |
| 998 |
} else { |
| 999 |
mergedProps[propName] = externalPropValue; |
| 1000 |
} |
| 1001 |
} |
| 1002 |
} |
| 1003 |
} |
| 1004 |
return mergedProps; |
| 1005 |
} |
| 1006 |
function isEventHandler(key, value) { |
| 1007 |
const code0 = key.charCodeAt(0); |
| 1008 |
const code1 = key.charCodeAt(1); |
| 1009 |
const code2 = key.charCodeAt(2); |
| 1010 |
return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined"); |
| 1011 |
} |
| 1012 |
function isPropsGetter(inputProps) { |
| 1013 |
return typeof inputProps === "function"; |
| 1014 |
} |
| 1015 |
function resolvePropsGetter(inputProps, previousProps) { |
| 1016 |
if (isPropsGetter(inputProps)) { |
| 1017 |
return inputProps(previousProps); |
| 1018 |
} |
| 1019 |
return inputProps ?? EMPTY_PROPS; |
| 1020 |
} |
| 1021 |
function mergeEventHandlers(ourHandler, theirHandler) { |
| 1022 |
if (!theirHandler) { |
| 1023 |
return ourHandler; |
| 1024 |
} |
| 1025 |
if (!ourHandler) { |
| 1026 |
return wrapEventHandler(theirHandler); |
| 1027 |
} |
| 1028 |
return (...args) => { |
| 1029 |
const event = args[0]; |
| 1030 |
if (isSyntheticEvent(event)) { |
| 1031 |
const baseUIEvent = event; |
| 1032 |
makeEventPreventable(baseUIEvent); |
| 1033 |
const result2 = theirHandler(...args); |
| 1034 |
if (!baseUIEvent.baseUIHandlerPrevented) { |
| 1035 |
ourHandler?.(...args); |
| 1036 |
} |
| 1037 |
return result2; |
| 1038 |
} |
| 1039 |
const result = theirHandler(...args); |
| 1040 |
ourHandler?.(...args); |
| 1041 |
return result; |
| 1042 |
}; |
| 1043 |
} |
| 1044 |
function wrapEventHandler(handler) { |
| 1045 |
if (!handler) { |
| 1046 |
return handler; |
| 1047 |
} |
| 1048 |
return (...args) => { |
| 1049 |
const event = args[0]; |
| 1050 |
if (isSyntheticEvent(event)) { |
| 1051 |
makeEventPreventable(event); |
| 1052 |
} |
| 1053 |
return handler(...args); |
| 1054 |
}; |
| 1055 |
} |
| 1056 |
function makeEventPreventable(event) { |
| 1057 |
event.preventBaseUIHandler = () => { |
| 1058 |
event.baseUIHandlerPrevented = true; |
| 1059 |
}; |
| 1060 |
return event; |
| 1061 |
} |
| 1062 |
function mergeClassNames(ourClassName, theirClassName) { |
| 1063 |
if (theirClassName) { |
| 1064 |
if (ourClassName) { |
| 1065 |
return theirClassName + " " + ourClassName; |
| 1066 |
} |
| 1067 |
return theirClassName; |
| 1068 |
} |
| 1069 |
return ourClassName; |
| 1070 |
} |
| 1071 |
function isSyntheticEvent(event) { |
| 1072 |
return event != null && typeof event === "object" && "nativeEvent" in event; |
| 1073 |
} |
| 1074 |
|
| 1075 |
// node_modules/@base-ui/react/esm/internals/useRenderElement.js |
| 1076 |
var import_react = __toESM(require_react(), 1); |
| 1077 |
function useRenderElement(element, componentProps, params = {}) { |
| 1078 |
const renderProp = componentProps.render; |
| 1079 |
const outProps = useRenderElementProps(componentProps, params); |
| 1080 |
if (params.enabled === false) { |
| 1081 |
return null; |
| 1082 |
} |
| 1083 |
const state = params.state ?? EMPTY_OBJECT; |
| 1084 |
return evaluateRenderProp(element, renderProp, outProps, state); |
| 1085 |
} |
| 1086 |
function useRenderElementProps(componentProps, params = {}) { |
| 1087 |
const { |
| 1088 |
className: classNameProp, |
| 1089 |
style: styleProp, |
| 1090 |
render: renderProp |
| 1091 |
} = componentProps; |
| 1092 |
const { |
| 1093 |
state = EMPTY_OBJECT, |
| 1094 |
ref, |
| 1095 |
props, |
| 1096 |
stateAttributesMapping, |
| 1097 |
enabled = true |
| 1098 |
} = params; |
| 1099 |
const className = enabled ? resolveClassName(classNameProp, state) : void 0; |
| 1100 |
const style = enabled ? resolveStyle(styleProp, state) : void 0; |
| 1101 |
const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT; |
| 1102 |
const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0; |
| 1103 |
const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT; |
| 1104 |
if (typeof document !== "undefined") { |
| 1105 |
if (!enabled) { |
| 1106 |
useMergedRefs(null, null); |
| 1107 |
} else if (Array.isArray(ref)) { |
| 1108 |
outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]); |
| 1109 |
} else { |
| 1110 |
outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref); |
| 1111 |
} |
| 1112 |
} |
| 1113 |
if (!enabled) { |
| 1114 |
return EMPTY_OBJECT; |
| 1115 |
} |
| 1116 |
if (className !== void 0) { |
| 1117 |
outProps.className = mergeClassNames(outProps.className, className); |
| 1118 |
} |
| 1119 |
if (style !== void 0) { |
| 1120 |
outProps.style = mergeObjects(outProps.style, style); |
| 1121 |
} |
| 1122 |
return outProps; |
| 1123 |
} |
| 1124 |
function resolveRenderFunctionProps(props) { |
| 1125 |
if (Array.isArray(props)) { |
| 1126 |
return mergePropsN(props); |
| 1127 |
} |
| 1128 |
return mergeProps(void 0, props); |
| 1129 |
} |
| 1130 |
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); |
| 1131 |
var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/; |
| 1132 |
var LOWERCASE_CHARACTER_PATTERN = /[a-z]/; |
| 1133 |
function evaluateRenderProp(element, render, props, state) { |
| 1134 |
if (render) { |
| 1135 |
if (typeof render === "function") { |
| 1136 |
if (true) { |
| 1137 |
warnIfRenderPropLooksLikeComponent(render); |
| 1138 |
} |
| 1139 |
return render(props, state); |
| 1140 |
} |
| 1141 |
const mergedProps = mergeProps(props, render.props); |
| 1142 |
mergedProps.ref = props.ref; |
| 1143 |
let newElement = render; |
| 1144 |
if (newElement?.$$typeof === REACT_LAZY_TYPE) { |
| 1145 |
const children = React4.Children.toArray(render); |
| 1146 |
newElement = children[0]; |
| 1147 |
} |
| 1148 |
if (true) { |
| 1149 |
if (!/* @__PURE__ */ React4.isValidElement(newElement)) { |
| 1150 |
throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n")); |
| 1151 |
} |
| 1152 |
} |
| 1153 |
return /* @__PURE__ */ React4.cloneElement(newElement, mergedProps); |
| 1154 |
} |
| 1155 |
if (element) { |
| 1156 |
if (typeof element === "string") { |
| 1157 |
return renderTag(element, props); |
| 1158 |
} |
| 1159 |
} |
| 1160 |
throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8)); |
| 1161 |
} |
| 1162 |
function warnIfRenderPropLooksLikeComponent(renderFn) { |
| 1163 |
const functionName = renderFn.name; |
| 1164 |
if (functionName.length === 0) { |
| 1165 |
return; |
| 1166 |
} |
| 1167 |
if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) { |
| 1168 |
return; |
| 1169 |
} |
| 1170 |
if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) { |
| 1171 |
return; |
| 1172 |
} |
| 1173 |
warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop"); |
| 1174 |
} |
| 1175 |
function renderTag(Tag, props) { |
| 1176 |
if (Tag === "button") { |
| 1177 |
return /* @__PURE__ */ (0, import_react.createElement)("button", { |
| 1178 |
type: "button", |
| 1179 |
...props, |
| 1180 |
key: props.key |
| 1181 |
}); |
| 1182 |
} |
| 1183 |
if (Tag === "img") { |
| 1184 |
return /* @__PURE__ */ (0, import_react.createElement)("img", { |
| 1185 |
alt: "", |
| 1186 |
...props, |
| 1187 |
key: props.key |
| 1188 |
}); |
| 1189 |
} |
| 1190 |
return /* @__PURE__ */ React4.createElement(Tag, props); |
| 1191 |
} |
| 1192 |
|
| 1193 |
// node_modules/@base-ui/react/esm/use-render/useRender.js |
| 1194 |
function useRender(params) { |
| 1195 |
return useRenderElement(params.defaultTagName ?? "div", params, params); |
| 1196 |
} |
| 1197 |
|
| 1198 |
// packages/ui/build-module/visually-hidden/visually-hidden.mjs |
| 1199 |
var import_element3 = __toESM(require_element(), 1); |
| 1200 |
var STYLE_HASH_ATTRIBUTE = "data-wp-hash"; |
| 1201 |
function getRuntime() { |
| 1202 |
const globalScope = globalThis; |
| 1203 |
if (globalScope.__wpStyleRuntime) { |
| 1204 |
return globalScope.__wpStyleRuntime; |
| 1205 |
} |
| 1206 |
globalScope.__wpStyleRuntime = { |
| 1207 |
documents: /* @__PURE__ */ new Map(), |
| 1208 |
styles: /* @__PURE__ */ new Map(), |
| 1209 |
injectedStyles: /* @__PURE__ */ new WeakMap() |
| 1210 |
}; |
| 1211 |
if (typeof document !== "undefined") { |
| 1212 |
registerDocument(document); |
| 1213 |
} |
| 1214 |
return globalScope.__wpStyleRuntime; |
| 1215 |
} |
| 1216 |
function documentContainsStyleHash(targetDocument, hash) { |
| 1217 |
if (!targetDocument.head) { |
| 1218 |
return false; |
| 1219 |
} |
| 1220 |
for (const style of targetDocument.head.querySelectorAll( |
| 1221 |
`style[${STYLE_HASH_ATTRIBUTE}]` |
| 1222 |
)) { |
| 1223 |
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) { |
| 1224 |
return true; |
| 1225 |
} |
| 1226 |
} |
| 1227 |
return false; |
| 1228 |
} |
| 1229 |
function injectStyle(targetDocument, hash, css) { |
| 1230 |
if (!targetDocument.head) { |
| 1231 |
return; |
| 1232 |
} |
| 1233 |
const runtime = getRuntime(); |
| 1234 |
let injectedStyles = runtime.injectedStyles.get(targetDocument); |
| 1235 |
if (!injectedStyles) { |
| 1236 |
injectedStyles = /* @__PURE__ */ new Set(); |
| 1237 |
runtime.injectedStyles.set(targetDocument, injectedStyles); |
| 1238 |
} |
| 1239 |
if (injectedStyles.has(hash)) { |
| 1240 |
return; |
| 1241 |
} |
| 1242 |
if (documentContainsStyleHash(targetDocument, hash)) { |
| 1243 |
injectedStyles.add(hash); |
| 1244 |
return; |
| 1245 |
} |
| 1246 |
const style = targetDocument.createElement("style"); |
| 1247 |
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash); |
| 1248 |
style.appendChild(targetDocument.createTextNode(css)); |
| 1249 |
targetDocument.head.appendChild(style); |
| 1250 |
injectedStyles.add(hash); |
| 1251 |
} |
| 1252 |
function registerDocument(targetDocument) { |
| 1253 |
const runtime = getRuntime(); |
| 1254 |
runtime.documents.set( |
| 1255 |
targetDocument, |
| 1256 |
(runtime.documents.get(targetDocument) ?? 0) + 1 |
| 1257 |
); |
| 1258 |
for (const [hash, css] of runtime.styles) { |
| 1259 |
injectStyle(targetDocument, hash, css); |
| 1260 |
} |
| 1261 |
return () => { |
| 1262 |
const count = runtime.documents.get(targetDocument); |
| 1263 |
if (count === void 0) { |
| 1264 |
return; |
| 1265 |
} |
| 1266 |
if (count <= 1) { |
| 1267 |
runtime.documents.delete(targetDocument); |
| 1268 |
return; |
| 1269 |
} |
| 1270 |
runtime.documents.set(targetDocument, count - 1); |
| 1271 |
}; |
| 1272 |
} |
| 1273 |
function registerStyle(hash, css) { |
| 1274 |
const runtime = getRuntime(); |
| 1275 |
runtime.styles.set(hash, css); |
| 1276 |
for (const targetDocument of runtime.documents.keys()) { |
| 1277 |
injectStyle(targetDocument, hash, css); |
| 1278 |
} |
| 1279 |
} |
| 1280 |
if (typeof process === "undefined" || true) { |
| 1281 |
registerStyle("c46e8cb841", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}"); |
| 1282 |
} |
| 1283 |
var style_default = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" }; |
| 1284 |
var VisuallyHidden = (0, import_element3.forwardRef)( |
| 1285 |
function VisuallyHidden2({ render, ...restProps }, ref) { |
| 1286 |
const element = useRender({ |
| 1287 |
render, |
| 1288 |
ref, |
| 1289 |
props: mergeProps( |
| 1290 |
{ className: style_default["visually-hidden"] }, |
| 1291 |
restProps, |
| 1292 |
{ |
| 1293 |
// @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it. |
| 1294 |
"data-visually-hidden": "" |
| 1295 |
} |
| 1296 |
) |
| 1297 |
}); |
| 1298 |
return element; |
| 1299 |
} |
| 1300 |
); |
| 1301 |
|
| 1302 |
// packages/format-library/build-module/link/css-classes-setting.mjs |
| 1303 |
var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1); |
| 1304 |
var CSSClassesSettingComponent = ({ setting, value, onChange }) => { |
| 1305 |
const hasValue = value ? value?.cssClasses?.length > 0 : false; |
| 1306 |
const [isSettingActive, setIsSettingActive] = (0, import_element4.useState)(hasValue); |
| 1307 |
const instanceId = (0, import_compose.useInstanceId)(CSSClassesSettingComponent); |
| 1308 |
const controlledRegionId = `css-classes-setting-${instanceId}`; |
| 1309 |
const handleSettingChange = (newValue) => { |
| 1310 |
const sanitizedValue = typeof newValue === "string" ? newValue.replace(/,/g, " ").replace(/\s+/g, " ").trim() : newValue; |
| 1311 |
onChange({ |
| 1312 |
...value, |
| 1313 |
[setting.id]: sanitizedValue |
| 1314 |
}); |
| 1315 |
}; |
| 1316 |
const handleCheckboxChange = () => { |
| 1317 |
if (isSettingActive) { |
| 1318 |
if (hasValue) { |
| 1319 |
handleSettingChange(""); |
| 1320 |
} |
| 1321 |
setIsSettingActive(false); |
| 1322 |
} else { |
| 1323 |
setIsSettingActive(true); |
| 1324 |
} |
| 1325 |
}; |
| 1326 |
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("fieldset", { children: [ |
| 1327 |
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("legend", {}), children: setting.title }), |
| 1328 |
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_components2.__experimentalVStack, { spacing: 3, children: [ |
| 1329 |
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)( |
| 1330 |
import_components2.CheckboxControl, |
| 1331 |
{ |
| 1332 |
label: setting.title, |
| 1333 |
onChange: handleCheckboxChange, |
| 1334 |
checked: isSettingActive || hasValue, |
| 1335 |
"aria-expanded": isSettingActive, |
| 1336 |
"aria-controls": isSettingActive ? controlledRegionId : void 0 |
| 1337 |
} |
| 1338 |
), |
| 1339 |
isSettingActive && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { id: controlledRegionId, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)( |
| 1340 |
import_components2.__experimentalInputControl, |
| 1341 |
{ |
| 1342 |
label: (0, import_i18n5.__)("CSS classes"), |
| 1343 |
value: value?.cssClasses, |
| 1344 |
onChange: handleSettingChange, |
| 1345 |
help: (0, import_i18n5.__)( |
| 1346 |
"Separate multiple classes with spaces." |
| 1347 |
), |
| 1348 |
__unstableInputWidth: "100%", |
| 1349 |
__next40pxDefaultSize: true |
| 1350 |
} |
| 1351 |
) }) |
| 1352 |
] }) |
| 1353 |
] }); |
| 1354 |
}; |
| 1355 |
var css_classes_setting_default = CSSClassesSettingComponent; |
| 1356 |
|
| 1357 |
// packages/format-library/build-module/link/inline.mjs |
| 1358 |
var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1); |
| 1359 |
var LINK_SETTINGS = [ |
| 1360 |
...import_block_editor5.LinkControl.DEFAULT_LINK_SETTINGS, |
| 1361 |
{ |
| 1362 |
id: "nofollow", |
| 1363 |
title: (0, import_i18n6.__)("Mark as nofollow") |
| 1364 |
}, |
| 1365 |
{ |
| 1366 |
id: "cssClasses", |
| 1367 |
title: (0, import_i18n6.__)("Additional CSS class(es)"), |
| 1368 |
render: (setting, value, onChange) => { |
| 1369 |
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( |
| 1370 |
css_classes_setting_default, |
| 1371 |
{ |
| 1372 |
setting, |
| 1373 |
value, |
| 1374 |
onChange |
| 1375 |
} |
| 1376 |
); |
| 1377 |
} |
| 1378 |
} |
| 1379 |
]; |
| 1380 |
function InlineLinkUI({ |
| 1381 |
isActive, |
| 1382 |
activeAttributes, |
| 1383 |
value, |
| 1384 |
onChange, |
| 1385 |
onFocusOutside, |
| 1386 |
stopAddingLink, |
| 1387 |
contentRef, |
| 1388 |
focusOnMount |
| 1389 |
}) { |
| 1390 |
const richLinkTextValue = getRichTextValueFromSelection(value, isActive); |
| 1391 |
const richTextText = richLinkTextValue.text; |
| 1392 |
const { selectionChange } = (0, import_data.useDispatch)(import_block_editor5.store); |
| 1393 |
const { createPageEntity, userCanCreatePages, selectionStart } = (0, import_data.useSelect)( |
| 1394 |
(select) => { |
| 1395 |
const { getSettings, getSelectionStart } = select(import_block_editor5.store); |
| 1396 |
const _settings = getSettings(); |
| 1397 |
return { |
| 1398 |
createPageEntity: _settings.__experimentalCreatePageEntity, |
| 1399 |
userCanCreatePages: _settings.__experimentalUserCanCreatePages, |
| 1400 |
selectionStart: getSelectionStart() |
| 1401 |
}; |
| 1402 |
}, |
| 1403 |
[] |
| 1404 |
); |
| 1405 |
const linkValue = (0, import_element5.useMemo)( |
| 1406 |
() => ({ |
| 1407 |
url: activeAttributes.url, |
| 1408 |
type: activeAttributes.type, |
| 1409 |
id: activeAttributes.id, |
| 1410 |
opensInNewTab: activeAttributes.target === "_blank", |
| 1411 |
nofollow: activeAttributes.rel?.includes("nofollow"), |
| 1412 |
title: richTextText, |
| 1413 |
cssClasses: activeAttributes.class |
| 1414 |
}), |
| 1415 |
[ |
| 1416 |
activeAttributes.class, |
| 1417 |
activeAttributes.id, |
| 1418 |
activeAttributes.rel, |
| 1419 |
activeAttributes.target, |
| 1420 |
activeAttributes.type, |
| 1421 |
activeAttributes.url, |
| 1422 |
richTextText |
| 1423 |
] |
| 1424 |
); |
| 1425 |
function removeLink() { |
| 1426 |
const newValue = (0, import_rich_text5.removeFormat)(value, "core/link"); |
| 1427 |
onChange(newValue); |
| 1428 |
stopAddingLink(); |
| 1429 |
(0, import_a11y.speak)((0, import_i18n6.__)("Link removed."), "assertive"); |
| 1430 |
} |
| 1431 |
function onChangeLink(nextValue) { |
| 1432 |
const hasLink = linkValue?.url; |
| 1433 |
const isNewLink = !hasLink; |
| 1434 |
nextValue = { |
| 1435 |
...linkValue, |
| 1436 |
...nextValue |
| 1437 |
}; |
| 1438 |
const newUrl = (0, import_url2.prependHTTPS)(nextValue.url); |
| 1439 |
const linkFormat = createLinkFormat({ |
| 1440 |
url: newUrl, |
| 1441 |
type: nextValue.type, |
| 1442 |
id: nextValue.id !== void 0 && nextValue.id !== null ? String(nextValue.id) : void 0, |
| 1443 |
opensInNewWindow: nextValue.opensInNewTab, |
| 1444 |
nofollow: nextValue.nofollow, |
| 1445 |
cssClasses: nextValue.cssClasses |
| 1446 |
}); |
| 1447 |
const newText = nextValue.title || newUrl; |
| 1448 |
let newValue; |
| 1449 |
if ((0, import_rich_text5.isCollapsed)(value) && !isActive) { |
| 1450 |
const inserted = (0, import_rich_text5.insert)(value, newText); |
| 1451 |
newValue = (0, import_rich_text5.applyFormat)( |
| 1452 |
inserted, |
| 1453 |
linkFormat, |
| 1454 |
value.start, |
| 1455 |
value.start + newText.length |
| 1456 |
); |
| 1457 |
onChange(newValue); |
| 1458 |
stopAddingLink(); |
| 1459 |
selectionChange({ |
| 1460 |
clientId: selectionStart.clientId, |
| 1461 |
identifier: selectionStart.attributeKey, |
| 1462 |
start: value.start + newText.length + 1 |
| 1463 |
}); |
| 1464 |
return; |
| 1465 |
} else if (newText === richTextText) { |
| 1466 |
const boundary = getFormatBoundary(value, { |
| 1467 |
type: "core/link" |
| 1468 |
}); |
| 1469 |
newValue = (0, import_rich_text5.applyFormat)( |
| 1470 |
value, |
| 1471 |
linkFormat, |
| 1472 |
boundary.start, |
| 1473 |
boundary.end |
| 1474 |
); |
| 1475 |
} else { |
| 1476 |
newValue = (0, import_rich_text5.create)({ text: newText }); |
| 1477 |
newValue = (0, import_rich_text5.applyFormat)(newValue, linkFormat, 0, newText.length); |
| 1478 |
const boundary = getFormatBoundary(value, { |
| 1479 |
type: "core/link" |
| 1480 |
}); |
| 1481 |
const [valBefore, valAfter] = (0, import_rich_text5.split)( |
| 1482 |
value, |
| 1483 |
boundary.start, |
| 1484 |
boundary.start |
| 1485 |
); |
| 1486 |
const newValAfter = (0, import_rich_text5.replace)(valAfter, richTextText, newValue); |
| 1487 |
newValue = (0, import_rich_text5.concat)(valBefore, newValAfter); |
| 1488 |
} |
| 1489 |
onChange(newValue); |
| 1490 |
if (!isNewLink) { |
| 1491 |
stopAddingLink(); |
| 1492 |
} |
| 1493 |
if (!isValidHref(newUrl)) { |
| 1494 |
(0, import_a11y.speak)( |
| 1495 |
(0, import_i18n6.__)( |
| 1496 |
"Warning: the link has been inserted but may have errors. Please test it." |
| 1497 |
), |
| 1498 |
"assertive" |
| 1499 |
); |
| 1500 |
} else if (isActive) { |
| 1501 |
(0, import_a11y.speak)((0, import_i18n6.__)("Link edited."), "assertive"); |
| 1502 |
} else { |
| 1503 |
(0, import_a11y.speak)((0, import_i18n6.__)("Link inserted."), "assertive"); |
| 1504 |
} |
| 1505 |
} |
| 1506 |
const popoverAnchor = (0, import_rich_text5.useAnchor)({ |
| 1507 |
editableContentElement: contentRef.current, |
| 1508 |
settings: { |
| 1509 |
...link, |
| 1510 |
isActive |
| 1511 |
} |
| 1512 |
}); |
| 1513 |
async function handleCreate(pageTitle) { |
| 1514 |
const page = await createPageEntity({ |
| 1515 |
title: pageTitle, |
| 1516 |
status: "draft" |
| 1517 |
}); |
| 1518 |
return { |
| 1519 |
id: page.id, |
| 1520 |
type: page.type, |
| 1521 |
title: page.title.rendered, |
| 1522 |
url: page.link, |
| 1523 |
kind: "post-type" |
| 1524 |
}; |
| 1525 |
} |
| 1526 |
function createButtonText(searchTerm) { |
| 1527 |
return (0, import_element5.createInterpolateElement)( |
| 1528 |
(0, import_i18n6.sprintf)( |
| 1529 |
/* translators: %s: search term. */ |
| 1530 |
(0, import_i18n6.__)("Create page: <mark>%s</mark>"), |
| 1531 |
searchTerm |
| 1532 |
), |
| 1533 |
{ mark: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("mark", {}) } |
| 1534 |
); |
| 1535 |
} |
| 1536 |
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( |
| 1537 |
import_components3.Popover, |
| 1538 |
{ |
| 1539 |
anchor: popoverAnchor, |
| 1540 |
animate: false, |
| 1541 |
onClose: stopAddingLink, |
| 1542 |
onFocusOutside, |
| 1543 |
placement: "bottom", |
| 1544 |
offset: 8, |
| 1545 |
shift: true, |
| 1546 |
focusOnMount, |
| 1547 |
constrainTabbing: true, |
| 1548 |
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( |
| 1549 |
import_block_editor5.LinkControl, |
| 1550 |
{ |
| 1551 |
value: linkValue, |
| 1552 |
onChange: onChangeLink, |
| 1553 |
onRemove: removeLink, |
| 1554 |
hasRichPreviews: true, |
| 1555 |
createSuggestion: createPageEntity && handleCreate, |
| 1556 |
withCreateSuggestion: userCanCreatePages, |
| 1557 |
createSuggestionButtonText: createButtonText, |
| 1558 |
hasTextControl: true, |
| 1559 |
settings: LINK_SETTINGS, |
| 1560 |
showInitialSuggestions: true, |
| 1561 |
suggestionsQuery: { |
| 1562 |
// always show Pages as initial suggestions |
| 1563 |
initialSuggestionsSearchOptions: { |
| 1564 |
type: "post", |
| 1565 |
subtype: "page", |
| 1566 |
perPage: 20 |
| 1567 |
} |
| 1568 |
} |
| 1569 |
} |
| 1570 |
) |
| 1571 |
} |
| 1572 |
); |
| 1573 |
} |
| 1574 |
function getRichTextValueFromSelection(value, isActive) { |
| 1575 |
let textStart = value.start; |
| 1576 |
let textEnd = value.end; |
| 1577 |
if (isActive) { |
| 1578 |
const boundary = getFormatBoundary(value, { |
| 1579 |
type: "core/link" |
| 1580 |
}); |
| 1581 |
textStart = boundary.start; |
| 1582 |
textEnd = boundary.end; |
| 1583 |
} |
| 1584 |
return (0, import_rich_text5.slice)(value, textStart, textEnd); |
| 1585 |
} |
| 1586 |
var inline_default = InlineLinkUI; |
| 1587 |
|
| 1588 |
// packages/format-library/build-module/link/index.mjs |
| 1589 |
var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1); |
| 1590 |
var name5 = "core/link"; |
| 1591 |
var title5 = (0, import_i18n7.__)("Link"); |
| 1592 |
function Edit2({ |
| 1593 |
isActive, |
| 1594 |
activeAttributes, |
| 1595 |
value, |
| 1596 |
onChange, |
| 1597 |
onFocus, |
| 1598 |
contentRef, |
| 1599 |
isVisible = true |
| 1600 |
}) { |
| 1601 |
const [addingLink, setAddingLink] = (0, import_element6.useState)(false); |
| 1602 |
const [openedBy, setOpenedBy] = (0, import_element6.useState)(null); |
| 1603 |
(0, import_element6.useEffect)(() => { |
| 1604 |
if (!isActive) { |
| 1605 |
setAddingLink(false); |
| 1606 |
} |
| 1607 |
}, [isActive]); |
| 1608 |
(0, import_element6.useLayoutEffect)(() => { |
| 1609 |
const editableContentElement = contentRef.current; |
| 1610 |
if (!editableContentElement) { |
| 1611 |
return; |
| 1612 |
} |
| 1613 |
function handleClick(event) { |
| 1614 |
const link2 = event.target.closest("[contenteditable] a"); |
| 1615 |
if (!link2 || // other formats (e.g. bold) may be nested within the link. |
| 1616 |
!isActive) { |
| 1617 |
return; |
| 1618 |
} |
| 1619 |
setAddingLink(true); |
| 1620 |
setOpenedBy({ |
| 1621 |
el: link2, |
| 1622 |
action: "click" |
| 1623 |
}); |
| 1624 |
} |
| 1625 |
editableContentElement.addEventListener("click", handleClick); |
| 1626 |
return () => { |
| 1627 |
editableContentElement.removeEventListener("click", handleClick); |
| 1628 |
}; |
| 1629 |
}, [contentRef, isActive]); |
| 1630 |
function addLink(target) { |
| 1631 |
const text = (0, import_rich_text6.getTextContent)((0, import_rich_text6.slice)(value)); |
| 1632 |
if (!isActive && text && (0, import_url3.isURL)(text) && isValidHref(text)) { |
| 1633 |
onChange( |
| 1634 |
(0, import_rich_text6.applyFormat)(value, { |
| 1635 |
type: name5, |
| 1636 |
attributes: { url: text } |
| 1637 |
}) |
| 1638 |
); |
| 1639 |
} else if (!isActive && text && (0, import_url3.isEmail)(text)) { |
| 1640 |
onChange( |
| 1641 |
(0, import_rich_text6.applyFormat)(value, { |
| 1642 |
type: name5, |
| 1643 |
attributes: { url: `mailto:${text}` } |
| 1644 |
}) |
| 1645 |
); |
| 1646 |
} else if (!isActive && text && (0, import_url3.isPhoneNumber)(text)) { |
| 1647 |
onChange( |
| 1648 |
(0, import_rich_text6.applyFormat)(value, { |
| 1649 |
type: name5, |
| 1650 |
attributes: { url: `tel:${text.replace(/\D/g, "")}` } |
| 1651 |
}) |
| 1652 |
); |
| 1653 |
} else { |
| 1654 |
if (target) { |
| 1655 |
setOpenedBy({ |
| 1656 |
el: target, |
| 1657 |
action: null |
| 1658 |
// We don't need to distinguish between click or keyboard here |
| 1659 |
}); |
| 1660 |
} |
| 1661 |
setAddingLink(true); |
| 1662 |
} |
| 1663 |
} |
| 1664 |
function stopAddingLink() { |
| 1665 |
setAddingLink(false); |
| 1666 |
if (openedBy?.el?.tagName === "BUTTON") { |
| 1667 |
openedBy.el.focus(); |
| 1668 |
} else { |
| 1669 |
onFocus(); |
| 1670 |
} |
| 1671 |
setOpenedBy(null); |
| 1672 |
} |
| 1673 |
function onFocusOutside() { |
| 1674 |
setAddingLink(false); |
| 1675 |
setOpenedBy(null); |
| 1676 |
} |
| 1677 |
function onRemoveFormat() { |
| 1678 |
onChange((0, import_rich_text6.removeFormat)(value, name5)); |
| 1679 |
(0, import_a11y2.speak)((0, import_i18n7.__)("Link removed."), "assertive"); |
| 1680 |
} |
| 1681 |
const shouldAutoFocus = !(openedBy?.el?.tagName === "A" && openedBy?.action === "click"); |
| 1682 |
const hasSelection = !(0, import_rich_text6.isCollapsed)(value); |
| 1683 |
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [ |
| 1684 |
hasSelection && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( |
| 1685 |
import_block_editor6.RichTextShortcut, |
| 1686 |
{ |
| 1687 |
type: "primary", |
| 1688 |
character: "k", |
| 1689 |
onUse: addLink |
| 1690 |
} |
| 1691 |
), |
| 1692 |
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)( |
| 1693 |
import_block_editor6.RichTextShortcut, |
| 1694 |
{ |
| 1695 |
type: "primaryShift", |
| 1696 |
character: "k", |
| 1697 |
onUse: onRemoveFormat |
| 1698 |
} |
| 1699 |
), |
| 1700 |
isVisible && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( |
| 1701 |
import_block_editor6.RichTextToolbarButton, |
| 1702 |
{ |
| 1703 |
name: "link", |
| 1704 |
icon: link_default, |
| 1705 |
title: isActive ? (0, import_i18n7.__)("Link") : title5, |
| 1706 |
onClick: (event) => { |
| 1707 |
addLink(event.currentTarget); |
| 1708 |
}, |
| 1709 |
isActive: isActive || addingLink, |
| 1710 |
shortcutType: "primary", |
| 1711 |
shortcutCharacter: "k", |
| 1712 |
"aria-haspopup": "true", |
| 1713 |
"aria-expanded": addingLink |
| 1714 |
} |
| 1715 |
), |
| 1716 |
isVisible && addingLink && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( |
| 1717 |
inline_default, |
| 1718 |
{ |
| 1719 |
stopAddingLink, |
| 1720 |
onFocusOutside, |
| 1721 |
isActive, |
| 1722 |
activeAttributes, |
| 1723 |
value, |
| 1724 |
onChange, |
| 1725 |
contentRef, |
| 1726 |
focusOnMount: shouldAutoFocus ? "firstElement" : false |
| 1727 |
} |
| 1728 |
) |
| 1729 |
] }); |
| 1730 |
} |
| 1731 |
var link = { |
| 1732 |
name: name5, |
| 1733 |
title: title5, |
| 1734 |
tagName: "a", |
| 1735 |
className: null, |
| 1736 |
attributes: { |
| 1737 |
url: "href", |
| 1738 |
type: "data-type", |
| 1739 |
id: "data-id", |
| 1740 |
_id: "id", |
| 1741 |
target: "target", |
| 1742 |
rel: "rel", |
| 1743 |
class: "class" |
| 1744 |
}, |
| 1745 |
__unstablePasteRule(value, { html, plainText }) { |
| 1746 |
const pastedText = (html || plainText).replace(/<[^>]+>/g, "").trim(); |
| 1747 |
if (!(0, import_url3.isURL)(pastedText) || !/^https?:/.test(pastedText)) { |
| 1748 |
return value; |
| 1749 |
} |
| 1750 |
window.console.log("Created link:\n\n", pastedText); |
| 1751 |
const format = { |
| 1752 |
type: name5, |
| 1753 |
attributes: { |
| 1754 |
url: (0, import_html_entities.decodeEntities)(pastedText) |
| 1755 |
} |
| 1756 |
}; |
| 1757 |
if ((0, import_rich_text6.isCollapsed)(value)) { |
| 1758 |
return (0, import_rich_text6.insert)( |
| 1759 |
value, |
| 1760 |
(0, import_rich_text6.applyFormat)( |
| 1761 |
(0, import_rich_text6.create)({ text: plainText }), |
| 1762 |
format, |
| 1763 |
0, |
| 1764 |
plainText.length |
| 1765 |
) |
| 1766 |
); |
| 1767 |
} |
| 1768 |
return (0, import_rich_text6.applyFormat)(value, format); |
| 1769 |
}, |
| 1770 |
edit: Edit2 |
| 1771 |
}; |
| 1772 |
|
| 1773 |
// packages/format-library/build-module/strikethrough/index.mjs |
| 1774 |
var import_i18n8 = __toESM(require_i18n(), 1); |
| 1775 |
var import_rich_text7 = __toESM(require_rich_text(), 1); |
| 1776 |
var import_block_editor7 = __toESM(require_block_editor(), 1); |
| 1777 |
var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1); |
| 1778 |
var name6 = "core/strikethrough"; |
| 1779 |
var title6 = (0, import_i18n8.__)("Strikethrough"); |
| 1780 |
var strikethrough = { |
| 1781 |
name: name6, |
| 1782 |
title: title6, |
| 1783 |
tagName: "s", |
| 1784 |
className: null, |
| 1785 |
edit({ isActive, value, onChange, onFocus }) { |
| 1786 |
function onClick() { |
| 1787 |
onChange((0, import_rich_text7.toggleFormat)(value, { type: name6, title: title6 })); |
| 1788 |
onFocus(); |
| 1789 |
} |
| 1790 |
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [ |
| 1791 |
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)( |
| 1792 |
import_block_editor7.RichTextShortcut, |
| 1793 |
{ |
| 1794 |
type: "access", |
| 1795 |
character: "d", |
| 1796 |
onUse: onClick |
| 1797 |
} |
| 1798 |
), |
| 1799 |
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)( |
| 1800 |
import_block_editor7.RichTextToolbarButton, |
| 1801 |
{ |
| 1802 |
icon: format_strikethrough_default, |
| 1803 |
title: title6, |
| 1804 |
onClick, |
| 1805 |
isActive, |
| 1806 |
role: "menuitemcheckbox" |
| 1807 |
} |
| 1808 |
) |
| 1809 |
] }); |
| 1810 |
} |
| 1811 |
}; |
| 1812 |
|
| 1813 |
// packages/format-library/build-module/underline/index.mjs |
| 1814 |
var import_i18n9 = __toESM(require_i18n(), 1); |
| 1815 |
var import_rich_text8 = __toESM(require_rich_text(), 1); |
| 1816 |
var import_block_editor8 = __toESM(require_block_editor(), 1); |
| 1817 |
var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1); |
| 1818 |
var name7 = "core/underline"; |
| 1819 |
var title7 = (0, import_i18n9.__)("Underline"); |
| 1820 |
var underline = { |
| 1821 |
name: name7, |
| 1822 |
title: title7, |
| 1823 |
tagName: "span", |
| 1824 |
className: null, |
| 1825 |
attributes: { |
| 1826 |
style: "style" |
| 1827 |
}, |
| 1828 |
edit({ value, onChange }) { |
| 1829 |
const onToggle = () => { |
| 1830 |
onChange( |
| 1831 |
(0, import_rich_text8.toggleFormat)(value, { |
| 1832 |
type: name7, |
| 1833 |
attributes: { |
| 1834 |
style: "text-decoration: underline;" |
| 1835 |
}, |
| 1836 |
title: title7 |
| 1837 |
}) |
| 1838 |
); |
| 1839 |
}; |
| 1840 |
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [ |
| 1841 |
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)( |
| 1842 |
import_block_editor8.RichTextShortcut, |
| 1843 |
{ |
| 1844 |
type: "primary", |
| 1845 |
character: "u", |
| 1846 |
onUse: onToggle |
| 1847 |
} |
| 1848 |
), |
| 1849 |
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)( |
| 1850 |
import_block_editor8.__unstableRichTextInputEvent, |
| 1851 |
{ |
| 1852 |
inputType: "formatUnderline", |
| 1853 |
onInput: onToggle |
| 1854 |
} |
| 1855 |
) |
| 1856 |
] }); |
| 1857 |
} |
| 1858 |
}; |
| 1859 |
|
| 1860 |
// packages/format-library/build-module/text-color/index.mjs |
| 1861 |
var import_i18n11 = __toESM(require_i18n(), 1); |
| 1862 |
var import_element8 = __toESM(require_element(), 1); |
| 1863 |
var import_block_editor10 = __toESM(require_block_editor(), 1); |
| 1864 |
var import_rich_text10 = __toESM(require_rich_text(), 1); |
| 1865 |
|
| 1866 |
// packages/format-library/build-module/text-color/inline.mjs |
| 1867 |
var import_element7 = __toESM(require_element(), 1); |
| 1868 |
var import_data2 = __toESM(require_data(), 1); |
| 1869 |
var import_rich_text9 = __toESM(require_rich_text(), 1); |
| 1870 |
var import_block_editor9 = __toESM(require_block_editor(), 1); |
| 1871 |
var import_components4 = __toESM(require_components(), 1); |
| 1872 |
var import_i18n10 = __toESM(require_i18n(), 1); |
| 1873 |
|
| 1874 |
// packages/format-library/build-module/lock-unlock.mjs |
| 1875 |
var import_private_apis = __toESM(require_private_apis(), 1); |
| 1876 |
var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( |
| 1877 |
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", |
| 1878 |
"@wordpress/format-library" |
| 1879 |
); |
| 1880 |
|
| 1881 |
// packages/format-library/build-module/text-color/inline.mjs |
| 1882 |
var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1); |
| 1883 |
var { Tabs } = unlock(import_components4.privateApis); |
| 1884 |
var TABS = [ |
| 1885 |
{ name: "color", title: (0, import_i18n10.__)("Text") }, |
| 1886 |
{ name: "backgroundColor", title: (0, import_i18n10.__)("Background") } |
| 1887 |
]; |
| 1888 |
function parseCSS(css = "") { |
| 1889 |
return css.split(";").reduce((accumulator, rule) => { |
| 1890 |
if (rule) { |
| 1891 |
const [property, value] = rule.split(":"); |
| 1892 |
if (property === "color") { |
| 1893 |
accumulator.color = value; |
| 1894 |
} |
| 1895 |
if (property === "background-color" && value !== transparentValue) { |
| 1896 |
accumulator.backgroundColor = value; |
| 1897 |
} |
| 1898 |
} |
| 1899 |
return accumulator; |
| 1900 |
}, {}); |
| 1901 |
} |
| 1902 |
function parseClassName(className = "", colorSettings) { |
| 1903 |
return className.split(" ").reduce((accumulator, name16) => { |
| 1904 |
if (name16.startsWith("has-") && name16.endsWith("-color")) { |
| 1905 |
const colorSlug = name16.replace(/^has-/, "").replace(/-color$/, ""); |
| 1906 |
const colorObject = (0, import_block_editor9.getColorObjectByAttributeValues)( |
| 1907 |
colorSettings, |
| 1908 |
colorSlug |
| 1909 |
); |
| 1910 |
accumulator.color = colorObject.color; |
| 1911 |
} |
| 1912 |
return accumulator; |
| 1913 |
}, {}); |
| 1914 |
} |
| 1915 |
function getActiveColors(value, name16, colorSettings) { |
| 1916 |
const activeColorFormat = (0, import_rich_text9.getActiveFormat)(value, name16); |
| 1917 |
if (!activeColorFormat) { |
| 1918 |
return {}; |
| 1919 |
} |
| 1920 |
return { |
| 1921 |
...parseCSS(activeColorFormat.attributes.style), |
| 1922 |
...parseClassName(activeColorFormat.attributes.class, colorSettings) |
| 1923 |
}; |
| 1924 |
} |
| 1925 |
function setColors(value, name16, colorSettings, colors) { |
| 1926 |
const { color, backgroundColor } = { |
| 1927 |
...getActiveColors(value, name16, colorSettings), |
| 1928 |
...colors |
| 1929 |
}; |
| 1930 |
if (!color && !backgroundColor) { |
| 1931 |
return (0, import_rich_text9.removeFormat)(value, name16); |
| 1932 |
} |
| 1933 |
const styles = []; |
| 1934 |
const classNames = []; |
| 1935 |
const attributes = {}; |
| 1936 |
if (backgroundColor) { |
| 1937 |
styles.push(["background-color", backgroundColor].join(":")); |
| 1938 |
} else { |
| 1939 |
styles.push(["background-color", transparentValue].join(":")); |
| 1940 |
} |
| 1941 |
if (color) { |
| 1942 |
const colorObject = (0, import_block_editor9.getColorObjectByColorValue)(colorSettings, color); |
| 1943 |
if (colorObject) { |
| 1944 |
classNames.push((0, import_block_editor9.getColorClassName)("color", colorObject.slug)); |
| 1945 |
} else { |
| 1946 |
styles.push(["color", color].join(":")); |
| 1947 |
} |
| 1948 |
} |
| 1949 |
if (styles.length) { |
| 1950 |
attributes.style = styles.join(";"); |
| 1951 |
} |
| 1952 |
if (classNames.length) { |
| 1953 |
attributes.class = classNames.join(" "); |
| 1954 |
} |
| 1955 |
return (0, import_rich_text9.applyFormat)(value, { type: name16, attributes }); |
| 1956 |
} |
| 1957 |
function ColorPicker({ name: name16, property, value, onChange }) { |
| 1958 |
const colors = (0, import_data2.useSelect)((select) => { |
| 1959 |
const { getSettings } = select(import_block_editor9.store); |
| 1960 |
return getSettings().colors ?? []; |
| 1961 |
}, []); |
| 1962 |
const activeColors = (0, import_element7.useMemo)( |
| 1963 |
() => getActiveColors(value, name16, colors), |
| 1964 |
[name16, value, colors] |
| 1965 |
); |
| 1966 |
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)( |
| 1967 |
import_block_editor9.ColorPalette, |
| 1968 |
{ |
| 1969 |
value: activeColors[property], |
| 1970 |
onChange: (color) => { |
| 1971 |
onChange( |
| 1972 |
setColors(value, name16, colors, { [property]: color }) |
| 1973 |
); |
| 1974 |
}, |
| 1975 |
enableAlpha: true, |
| 1976 |
__experimentalIsRenderedInSidebar: true |
| 1977 |
} |
| 1978 |
); |
| 1979 |
} |
| 1980 |
function InlineColorUI({ |
| 1981 |
name: name16, |
| 1982 |
value, |
| 1983 |
onChange, |
| 1984 |
onClose, |
| 1985 |
contentRef, |
| 1986 |
isActive |
| 1987 |
}) { |
| 1988 |
const popoverAnchor = (0, import_rich_text9.useAnchor)({ |
| 1989 |
editableContentElement: contentRef.current, |
| 1990 |
settings: { ...textColor, isActive } |
| 1991 |
}); |
| 1992 |
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)( |
| 1993 |
import_components4.Popover, |
| 1994 |
{ |
| 1995 |
onClose, |
| 1996 |
className: "format-library__inline-color-popover", |
| 1997 |
anchor: popoverAnchor, |
| 1998 |
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Tabs, { children: [ |
| 1999 |
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Tabs.TabList, { children: TABS.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Tabs.Tab, { tabId: tab.name, children: tab.title }, tab.name)) }), |
| 2000 |
TABS.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)( |
| 2001 |
Tabs.TabPanel, |
| 2002 |
{ |
| 2003 |
tabId: tab.name, |
| 2004 |
focusable: false, |
| 2005 |
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)( |
| 2006 |
ColorPicker, |
| 2007 |
{ |
| 2008 |
name: name16, |
| 2009 |
property: tab.name, |
| 2010 |
value, |
| 2011 |
onChange |
| 2012 |
} |
| 2013 |
) |
| 2014 |
}, |
| 2015 |
tab.name |
| 2016 |
)) |
| 2017 |
] }) |
| 2018 |
} |
| 2019 |
); |
| 2020 |
} |
| 2021 |
|
| 2022 |
// packages/format-library/build-module/text-color/index.mjs |
| 2023 |
var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1); |
| 2024 |
var transparentValue = "rgba(0, 0, 0, 0)"; |
| 2025 |
var name8 = "core/text-color"; |
| 2026 |
var title8 = (0, import_i18n11.__)("Highlight"); |
| 2027 |
var EMPTY_ARRAY2 = []; |
| 2028 |
function getComputedStyleProperty(element, property) { |
| 2029 |
const { ownerDocument } = element; |
| 2030 |
const { defaultView } = ownerDocument; |
| 2031 |
const style = defaultView.getComputedStyle(element); |
| 2032 |
const value = style.getPropertyValue(property); |
| 2033 |
if (property === "background-color" && value === transparentValue && element.parentElement) { |
| 2034 |
return getComputedStyleProperty(element.parentElement, property); |
| 2035 |
} |
| 2036 |
return value; |
| 2037 |
} |
| 2038 |
function fillComputedColors(element, { color, backgroundColor }) { |
| 2039 |
if (!color && !backgroundColor) { |
| 2040 |
return; |
| 2041 |
} |
| 2042 |
return { |
| 2043 |
color: color || getComputedStyleProperty(element, "color"), |
| 2044 |
backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element, "background-color") : backgroundColor |
| 2045 |
}; |
| 2046 |
} |
| 2047 |
function TextColorEdit({ |
| 2048 |
value, |
| 2049 |
onChange, |
| 2050 |
isActive, |
| 2051 |
activeAttributes, |
| 2052 |
contentRef |
| 2053 |
}) { |
| 2054 |
const [allowCustomControl, colors = EMPTY_ARRAY2] = (0, import_block_editor10.useSettings)( |
| 2055 |
"color.custom", |
| 2056 |
"color.palette" |
| 2057 |
); |
| 2058 |
const [isAddingColor, setIsAddingColor] = (0, import_element8.useState)(false); |
| 2059 |
const colorIndicatorStyle = (0, import_element8.useMemo)( |
| 2060 |
() => fillComputedColors( |
| 2061 |
contentRef.current, |
| 2062 |
getActiveColors(value, name8, colors) |
| 2063 |
), |
| 2064 |
[contentRef, value, colors] |
| 2065 |
); |
| 2066 |
const hasColorsToChoose = !!colors.length || allowCustomControl; |
| 2067 |
if (!hasColorsToChoose && !isActive) { |
| 2068 |
return null; |
| 2069 |
} |
| 2070 |
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [ |
| 2071 |
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)( |
| 2072 |
import_block_editor10.RichTextToolbarButton, |
| 2073 |
{ |
| 2074 |
className: "format-library-text-color-button", |
| 2075 |
isActive, |
| 2076 |
icon: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( |
| 2077 |
icon_default, |
| 2078 |
{ |
| 2079 |
icon: Object.keys(activeAttributes).length ? text_color_default : color_default, |
| 2080 |
style: colorIndicatorStyle |
| 2081 |
} |
| 2082 |
), |
| 2083 |
title: title8, |
| 2084 |
onClick: hasColorsToChoose ? () => setIsAddingColor(true) : () => onChange((0, import_rich_text10.removeFormat)(value, name8)), |
| 2085 |
role: "menuitemcheckbox" |
| 2086 |
} |
| 2087 |
), |
| 2088 |
isAddingColor && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( |
| 2089 |
InlineColorUI, |
| 2090 |
{ |
| 2091 |
name: name8, |
| 2092 |
onClose: () => setIsAddingColor(false), |
| 2093 |
activeAttributes, |
| 2094 |
value, |
| 2095 |
onChange, |
| 2096 |
contentRef, |
| 2097 |
isActive |
| 2098 |
} |
| 2099 |
) |
| 2100 |
] }); |
| 2101 |
} |
| 2102 |
var textColor = { |
| 2103 |
name: name8, |
| 2104 |
title: title8, |
| 2105 |
tagName: "mark", |
| 2106 |
className: "has-inline-color", |
| 2107 |
attributes: { |
| 2108 |
style: "style", |
| 2109 |
class: "class" |
| 2110 |
}, |
| 2111 |
edit: TextColorEdit |
| 2112 |
}; |
| 2113 |
|
| 2114 |
// packages/format-library/build-module/subscript/index.mjs |
| 2115 |
var import_i18n12 = __toESM(require_i18n(), 1); |
| 2116 |
var import_rich_text11 = __toESM(require_rich_text(), 1); |
| 2117 |
var import_block_editor11 = __toESM(require_block_editor(), 1); |
| 2118 |
var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1); |
| 2119 |
var name9 = "core/subscript"; |
| 2120 |
var title9 = (0, import_i18n12.__)("Subscript"); |
| 2121 |
var subscript = { |
| 2122 |
name: name9, |
| 2123 |
title: title9, |
| 2124 |
tagName: "sub", |
| 2125 |
className: null, |
| 2126 |
edit({ isActive, value, onChange, onFocus }) { |
| 2127 |
function onToggle() { |
| 2128 |
onChange((0, import_rich_text11.toggleFormat)(value, { type: name9, title: title9 })); |
| 2129 |
} |
| 2130 |
function onClick() { |
| 2131 |
onToggle(); |
| 2132 |
onFocus(); |
| 2133 |
} |
| 2134 |
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)( |
| 2135 |
import_block_editor11.RichTextToolbarButton, |
| 2136 |
{ |
| 2137 |
icon: subscript_default, |
| 2138 |
title: title9, |
| 2139 |
onClick, |
| 2140 |
isActive, |
| 2141 |
role: "menuitemcheckbox" |
| 2142 |
} |
| 2143 |
); |
| 2144 |
} |
| 2145 |
}; |
| 2146 |
|
| 2147 |
// packages/format-library/build-module/superscript/index.mjs |
| 2148 |
var import_i18n13 = __toESM(require_i18n(), 1); |
| 2149 |
var import_rich_text12 = __toESM(require_rich_text(), 1); |
| 2150 |
var import_block_editor12 = __toESM(require_block_editor(), 1); |
| 2151 |
var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1); |
| 2152 |
var name10 = "core/superscript"; |
| 2153 |
var title10 = (0, import_i18n13.__)("Superscript"); |
| 2154 |
var superscript = { |
| 2155 |
name: name10, |
| 2156 |
title: title10, |
| 2157 |
tagName: "sup", |
| 2158 |
className: null, |
| 2159 |
edit({ isActive, value, onChange, onFocus }) { |
| 2160 |
function onToggle() { |
| 2161 |
onChange((0, import_rich_text12.toggleFormat)(value, { type: name10, title: title10 })); |
| 2162 |
} |
| 2163 |
function onClick() { |
| 2164 |
onToggle(); |
| 2165 |
onFocus(); |
| 2166 |
} |
| 2167 |
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)( |
| 2168 |
import_block_editor12.RichTextToolbarButton, |
| 2169 |
{ |
| 2170 |
icon: superscript_default, |
| 2171 |
title: title10, |
| 2172 |
onClick, |
| 2173 |
isActive, |
| 2174 |
role: "menuitemcheckbox" |
| 2175 |
} |
| 2176 |
); |
| 2177 |
} |
| 2178 |
}; |
| 2179 |
|
| 2180 |
// packages/format-library/build-module/keyboard/index.mjs |
| 2181 |
var import_i18n14 = __toESM(require_i18n(), 1); |
| 2182 |
var import_rich_text13 = __toESM(require_rich_text(), 1); |
| 2183 |
var import_block_editor13 = __toESM(require_block_editor(), 1); |
| 2184 |
var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1); |
| 2185 |
var name11 = "core/keyboard"; |
| 2186 |
var title11 = (0, import_i18n14.__)("Keyboard input"); |
| 2187 |
var keyboard = { |
| 2188 |
name: name11, |
| 2189 |
title: title11, |
| 2190 |
tagName: "kbd", |
| 2191 |
className: null, |
| 2192 |
edit({ isActive, value, onChange, onFocus }) { |
| 2193 |
function onToggle() { |
| 2194 |
onChange((0, import_rich_text13.toggleFormat)(value, { type: name11, title: title11 })); |
| 2195 |
} |
| 2196 |
function onClick() { |
| 2197 |
onToggle(); |
| 2198 |
onFocus(); |
| 2199 |
} |
| 2200 |
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)( |
| 2201 |
import_block_editor13.RichTextToolbarButton, |
| 2202 |
{ |
| 2203 |
icon: button_default, |
| 2204 |
title: title11, |
| 2205 |
onClick, |
| 2206 |
isActive, |
| 2207 |
role: "menuitemcheckbox" |
| 2208 |
} |
| 2209 |
); |
| 2210 |
} |
| 2211 |
}; |
| 2212 |
|
| 2213 |
// packages/format-library/build-module/unknown/index.mjs |
| 2214 |
var import_i18n15 = __toESM(require_i18n(), 1); |
| 2215 |
var import_rich_text14 = __toESM(require_rich_text(), 1); |
| 2216 |
var import_block_editor14 = __toESM(require_block_editor(), 1); |
| 2217 |
var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1); |
| 2218 |
var name12 = "core/unknown"; |
| 2219 |
var title12 = (0, import_i18n15.__)("Clear Unknown Formatting"); |
| 2220 |
function selectionContainsUnknownFormats(value) { |
| 2221 |
if ((0, import_rich_text14.isCollapsed)(value)) { |
| 2222 |
return false; |
| 2223 |
} |
| 2224 |
const selectedValue = (0, import_rich_text14.slice)(value); |
| 2225 |
return selectedValue.formats.some((formats) => { |
| 2226 |
return formats.some((format) => format.type === name12); |
| 2227 |
}); |
| 2228 |
} |
| 2229 |
var unknown = { |
| 2230 |
name: name12, |
| 2231 |
title: title12, |
| 2232 |
tagName: "*", |
| 2233 |
className: null, |
| 2234 |
edit({ isActive, value, onChange, onFocus }) { |
| 2235 |
if (!isActive && !selectionContainsUnknownFormats(value)) { |
| 2236 |
return null; |
| 2237 |
} |
| 2238 |
function onClick() { |
| 2239 |
onChange((0, import_rich_text14.removeFormat)(value, name12)); |
| 2240 |
onFocus(); |
| 2241 |
} |
| 2242 |
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( |
| 2243 |
import_block_editor14.RichTextToolbarButton, |
| 2244 |
{ |
| 2245 |
name: "unknown", |
| 2246 |
icon: help_default, |
| 2247 |
title: title12, |
| 2248 |
onClick, |
| 2249 |
isActive: true |
| 2250 |
} |
| 2251 |
); |
| 2252 |
} |
| 2253 |
}; |
| 2254 |
|
| 2255 |
// packages/format-library/build-module/language/index.mjs |
| 2256 |
var import_i18n16 = __toESM(require_i18n(), 1); |
| 2257 |
var import_block_editor15 = __toESM(require_block_editor(), 1); |
| 2258 |
var import_components5 = __toESM(require_components(), 1); |
| 2259 |
var import_element9 = __toESM(require_element(), 1); |
| 2260 |
var import_rich_text15 = __toESM(require_rich_text(), 1); |
| 2261 |
var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1); |
| 2262 |
var name13 = "core/language"; |
| 2263 |
var title13 = (0, import_i18n16.__)("Language"); |
| 2264 |
var language = { |
| 2265 |
name: name13, |
| 2266 |
title: title13, |
| 2267 |
tagName: "bdo", |
| 2268 |
className: null, |
| 2269 |
attributes: { |
| 2270 |
lang: "lang", |
| 2271 |
dir: "dir" |
| 2272 |
}, |
| 2273 |
edit: Edit3 |
| 2274 |
}; |
| 2275 |
function Edit3({ isActive, value, onChange, contentRef }) { |
| 2276 |
const [isPopoverVisible, setIsPopoverVisible] = (0, import_element9.useState)(false); |
| 2277 |
const togglePopover = () => { |
| 2278 |
setIsPopoverVisible((state) => !state); |
| 2279 |
}; |
| 2280 |
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [ |
| 2281 |
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)( |
| 2282 |
import_block_editor15.RichTextToolbarButton, |
| 2283 |
{ |
| 2284 |
icon: language_default, |
| 2285 |
label: title13, |
| 2286 |
title: title13, |
| 2287 |
onClick: () => { |
| 2288 |
if (isActive) { |
| 2289 |
onChange((0, import_rich_text15.removeFormat)(value, name13)); |
| 2290 |
} else { |
| 2291 |
togglePopover(); |
| 2292 |
} |
| 2293 |
}, |
| 2294 |
isActive, |
| 2295 |
role: "menuitemcheckbox" |
| 2296 |
} |
| 2297 |
), |
| 2298 |
isPopoverVisible && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( |
| 2299 |
InlineLanguageUI, |
| 2300 |
{ |
| 2301 |
value, |
| 2302 |
onChange, |
| 2303 |
onClose: togglePopover, |
| 2304 |
contentRef |
| 2305 |
} |
| 2306 |
) |
| 2307 |
] }); |
| 2308 |
} |
| 2309 |
function InlineLanguageUI({ value, contentRef, onChange, onClose }) { |
| 2310 |
const popoverAnchor = (0, import_rich_text15.useAnchor)({ |
| 2311 |
editableContentElement: contentRef.current, |
| 2312 |
settings: language |
| 2313 |
}); |
| 2314 |
const [lang, setLang] = (0, import_element9.useState)(""); |
| 2315 |
const [dir, setDir] = (0, import_element9.useState)("ltr"); |
| 2316 |
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( |
| 2317 |
import_components5.Popover, |
| 2318 |
{ |
| 2319 |
className: "block-editor-format-toolbar__language-popover", |
| 2320 |
anchor: popoverAnchor, |
| 2321 |
onClose, |
| 2322 |
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)( |
| 2323 |
import_components5.__experimentalVStack, |
| 2324 |
{ |
| 2325 |
as: "form", |
| 2326 |
spacing: 4, |
| 2327 |
className: "block-editor-format-toolbar__language-container-content", |
| 2328 |
onSubmit: (event) => { |
| 2329 |
event.preventDefault(); |
| 2330 |
onChange( |
| 2331 |
(0, import_rich_text15.applyFormat)(value, { |
| 2332 |
type: name13, |
| 2333 |
attributes: { |
| 2334 |
lang, |
| 2335 |
dir |
| 2336 |
} |
| 2337 |
}) |
| 2338 |
); |
| 2339 |
onClose(); |
| 2340 |
}, |
| 2341 |
children: [ |
| 2342 |
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)( |
| 2343 |
import_components5.TextControl, |
| 2344 |
{ |
| 2345 |
__next40pxDefaultSize: true, |
| 2346 |
label: title13, |
| 2347 |
value: lang, |
| 2348 |
onChange: (val) => setLang(val), |
| 2349 |
help: (0, import_i18n16.__)( |
| 2350 |
'A valid language attribute, like "en" or "fr".' |
| 2351 |
) |
| 2352 |
} |
| 2353 |
), |
| 2354 |
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)( |
| 2355 |
import_components5.SelectControl, |
| 2356 |
{ |
| 2357 |
__next40pxDefaultSize: true, |
| 2358 |
label: (0, import_i18n16.__)("Text direction"), |
| 2359 |
value: dir, |
| 2360 |
options: [ |
| 2361 |
{ |
| 2362 |
label: (0, import_i18n16.__)("Left to right"), |
| 2363 |
value: "ltr" |
| 2364 |
}, |
| 2365 |
{ |
| 2366 |
label: (0, import_i18n16.__)("Right to left"), |
| 2367 |
value: "rtl" |
| 2368 |
} |
| 2369 |
], |
| 2370 |
onChange: (val) => setDir(val) |
| 2371 |
} |
| 2372 |
), |
| 2373 |
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_components5.__experimentalHStack, { alignment: "right", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( |
| 2374 |
import_components5.Button, |
| 2375 |
{ |
| 2376 |
__next40pxDefaultSize: true, |
| 2377 |
variant: "primary", |
| 2378 |
type: "submit", |
| 2379 |
text: (0, import_i18n16.__)("Apply") |
| 2380 |
} |
| 2381 |
) }) |
| 2382 |
] |
| 2383 |
} |
| 2384 |
) |
| 2385 |
} |
| 2386 |
); |
| 2387 |
} |
| 2388 |
|
| 2389 |
// packages/format-library/build-module/math/index.mjs |
| 2390 |
var import_i18n17 = __toESM(require_i18n(), 1); |
| 2391 |
var import_element10 = __toESM(require_element(), 1); |
| 2392 |
var import_rich_text16 = __toESM(require_rich_text(), 1); |
| 2393 |
var import_block_editor16 = __toESM(require_block_editor(), 1); |
| 2394 |
var import_components6 = __toESM(require_components(), 1); |
| 2395 |
var import_a11y3 = __toESM(require_a11y(), 1); |
| 2396 |
var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1); |
| 2397 |
var { Badge: WCBadge } = unlock(import_components6.privateApis); |
| 2398 |
var name14 = "core/math"; |
| 2399 |
var title14 = (0, import_i18n17.__)("Math"); |
| 2400 |
function InlineUI2({ |
| 2401 |
value, |
| 2402 |
onChange, |
| 2403 |
activeAttributes, |
| 2404 |
contentRef, |
| 2405 |
latexToMathML |
| 2406 |
}) { |
| 2407 |
const [latex, setLatex] = (0, import_element10.useState)( |
| 2408 |
activeAttributes?.["data-latex"] || "" |
| 2409 |
); |
| 2410 |
const [error, setError] = (0, import_element10.useState)(null); |
| 2411 |
const popoverAnchor = (0, import_rich_text16.useAnchor)({ |
| 2412 |
editableContentElement: contentRef.current, |
| 2413 |
settings: math |
| 2414 |
}); |
| 2415 |
const handleLatexChange = (newLatex) => { |
| 2416 |
let mathML = ""; |
| 2417 |
setLatex(newLatex); |
| 2418 |
if (newLatex) { |
| 2419 |
try { |
| 2420 |
mathML = latexToMathML(newLatex, { displayMode: false }); |
| 2421 |
setError(null); |
| 2422 |
} catch (err) { |
| 2423 |
setError(err.message); |
| 2424 |
(0, import_a11y3.speak)( |
| 2425 |
(0, import_i18n17.sprintf)( |
| 2426 |
/* translators: %s: error message returned when parsing LaTeX. */ |
| 2427 |
(0, import_i18n17.__)("Error parsing mathematical expression: %s"), |
| 2428 |
err.message |
| 2429 |
) |
| 2430 |
); |
| 2431 |
return; |
| 2432 |
} |
| 2433 |
} |
| 2434 |
const newReplacements = value.replacements.slice(); |
| 2435 |
newReplacements[value.start] = { |
| 2436 |
type: name14, |
| 2437 |
attributes: { |
| 2438 |
"data-latex": newLatex |
| 2439 |
}, |
| 2440 |
innerHTML: mathML |
| 2441 |
}; |
| 2442 |
onChange({ |
| 2443 |
...value, |
| 2444 |
replacements: newReplacements |
| 2445 |
}); |
| 2446 |
}; |
| 2447 |
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( |
| 2448 |
import_components6.Popover, |
| 2449 |
{ |
| 2450 |
placement: "bottom-start", |
| 2451 |
offset: 8, |
| 2452 |
focusOnMount: false, |
| 2453 |
anchor: popoverAnchor, |
| 2454 |
className: "block-editor-format-toolbar__math-popover", |
| 2455 |
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { style: { minWidth: "300px", padding: "4px" }, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_components6.__experimentalVStack, { spacing: 1, children: [ |
| 2456 |
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)( |
| 2457 |
import_components6.TextControl, |
| 2458 |
{ |
| 2459 |
__next40pxDefaultSize: true, |
| 2460 |
hideLabelFromVision: true, |
| 2461 |
label: (0, import_i18n17.__)("LaTeX math syntax"), |
| 2462 |
value: latex, |
| 2463 |
onChange: handleLatexChange, |
| 2464 |
placeholder: (0, import_i18n17.__)("e.g., x^2, \\frac{a}{b}"), |
| 2465 |
autoComplete: "off", |
| 2466 |
className: "block-editor-format-toolbar__math-input" |
| 2467 |
} |
| 2468 |
), |
| 2469 |
error && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [ |
| 2470 |
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)( |
| 2471 |
WCBadge, |
| 2472 |
{ |
| 2473 |
intent: "error", |
| 2474 |
className: "wp-block-math__error", |
| 2475 |
children: (0, import_i18n17.sprintf)( |
| 2476 |
/* translators: %s: error message returned when parsing LaTeX. */ |
| 2477 |
(0, import_i18n17.__)("Error: %s"), |
| 2478 |
error |
| 2479 |
) |
| 2480 |
} |
| 2481 |
), |
| 2482 |
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("style", { children: ".wp-block-math__error .components-badge__content{white-space:normal}" }) |
| 2483 |
] }) |
| 2484 |
] }) }) |
| 2485 |
} |
| 2486 |
); |
| 2487 |
} |
| 2488 |
function Edit4({ |
| 2489 |
value, |
| 2490 |
onChange, |
| 2491 |
onFocus, |
| 2492 |
isObjectActive, |
| 2493 |
activeObjectAttributes, |
| 2494 |
contentRef |
| 2495 |
}) { |
| 2496 |
const [latexToMathML, setLatexToMathML] = (0, import_element10.useState)(); |
| 2497 |
(0, import_element10.useEffect)(() => { |
| 2498 |
import("@wordpress/latex-to-mathml").then((module) => { |
| 2499 |
setLatexToMathML(() => module.default); |
| 2500 |
}); |
| 2501 |
}, []); |
| 2502 |
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [ |
| 2503 |
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)( |
| 2504 |
import_block_editor16.RichTextToolbarButton, |
| 2505 |
{ |
| 2506 |
icon: math_default, |
| 2507 |
title: title14, |
| 2508 |
onClick: () => { |
| 2509 |
const newValue = (0, import_rich_text16.insertObject)(value, { |
| 2510 |
type: name14, |
| 2511 |
attributes: { |
| 2512 |
"data-latex": "" |
| 2513 |
}, |
| 2514 |
innerHTML: "" |
| 2515 |
}); |
| 2516 |
newValue.start = newValue.end - 1; |
| 2517 |
onChange(newValue); |
| 2518 |
onFocus(); |
| 2519 |
}, |
| 2520 |
isActive: isObjectActive |
| 2521 |
} |
| 2522 |
), |
| 2523 |
isObjectActive && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( |
| 2524 |
InlineUI2, |
| 2525 |
{ |
| 2526 |
value, |
| 2527 |
onChange, |
| 2528 |
activeAttributes: activeObjectAttributes, |
| 2529 |
contentRef, |
| 2530 |
latexToMathML |
| 2531 |
} |
| 2532 |
) |
| 2533 |
] }); |
| 2534 |
} |
| 2535 |
var math = { |
| 2536 |
name: name14, |
| 2537 |
title: title14, |
| 2538 |
tagName: "math", |
| 2539 |
className: null, |
| 2540 |
attributes: { |
| 2541 |
"data-latex": "data-latex" |
| 2542 |
}, |
| 2543 |
contentEditable: false, |
| 2544 |
edit: Edit4 |
| 2545 |
}; |
| 2546 |
|
| 2547 |
// packages/format-library/build-module/non-breaking-space/index.mjs |
| 2548 |
var import_i18n18 = __toESM(require_i18n(), 1); |
| 2549 |
var import_rich_text17 = __toESM(require_rich_text(), 1); |
| 2550 |
var import_block_editor17 = __toESM(require_block_editor(), 1); |
| 2551 |
var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1); |
| 2552 |
var name15 = "core/non-breaking-space"; |
| 2553 |
var title15 = (0, import_i18n18.__)("Non breaking space"); |
| 2554 |
var nonBreakingSpace = { |
| 2555 |
name: name15, |
| 2556 |
title: title15, |
| 2557 |
tagName: "nbsp", |
| 2558 |
className: null, |
| 2559 |
edit({ value, onChange }) { |
| 2560 |
function addNonBreakingSpace() { |
| 2561 |
onChange((0, import_rich_text17.insert)(value, "\xA0")); |
| 2562 |
} |
| 2563 |
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( |
| 2564 |
import_block_editor17.RichTextShortcut, |
| 2565 |
{ |
| 2566 |
type: "primaryShift", |
| 2567 |
character: " ", |
| 2568 |
onUse: addNonBreakingSpace |
| 2569 |
} |
| 2570 |
); |
| 2571 |
} |
| 2572 |
}; |
| 2573 |
|
| 2574 |
// packages/format-library/build-module/default-formats.mjs |
| 2575 |
var default_formats_default = [ |
| 2576 |
bold, |
| 2577 |
code, |
| 2578 |
image, |
| 2579 |
italic, |
| 2580 |
link, |
| 2581 |
strikethrough, |
| 2582 |
underline, |
| 2583 |
textColor, |
| 2584 |
subscript, |
| 2585 |
superscript, |
| 2586 |
keyboard, |
| 2587 |
unknown, |
| 2588 |
language, |
| 2589 |
math, |
| 2590 |
nonBreakingSpace |
| 2591 |
]; |
| 2592 |
|
| 2593 |
// packages/format-library/build-module/index.mjs |
| 2594 |
default_formats_default.forEach( |
| 2595 |
({ name: name16, ...settings }) => (0, import_rich_text18.registerFormatType)(name16, settings) |
| 2596 |
); |
| 2597 |
})(); |
| 2598 |
//# sourceMappingURL=index.js.map |
| 2599 |
|