@wordpress/format-library 5.48.0 → 5.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/build/image/index.cjs +5 -3
- package/build/image/index.cjs.map +3 -3
- package/build/language/index.cjs +6 -5
- package/build/language/index.cjs.map +3 -3
- package/build/link/css-classes-setting.cjs +1 -1
- package/build/link/css-classes-setting.cjs.map +3 -3
- package/build/math/index.cjs +30 -14
- package/build/math/index.cjs.map +3 -3
- package/build/non-breaking-space/index.cjs +1 -1
- package/build/non-breaking-space/index.cjs.map +1 -1
- package/build/text-color/inline.cjs +6 -7
- package/build/text-color/inline.cjs.map +3 -3
- package/build-module/image/index.mjs +5 -6
- package/build-module/image/index.mjs.map +2 -2
- package/build-module/language/index.mjs +7 -8
- package/build-module/language/index.mjs.map +2 -2
- package/build-module/link/css-classes-setting.mjs +3 -4
- package/build-module/link/css-classes-setting.mjs.map +2 -2
- package/build-module/math/index.mjs +37 -16
- package/build-module/math/index.mjs.map +2 -2
- package/build-module/non-breaking-space/index.mjs +1 -1
- package/build-module/non-breaking-space/index.mjs.map +1 -1
- package/build-module/text-color/inline.mjs +7 -11
- package/build-module/text-color/inline.mjs.map +2 -2
- package/package.json +22 -18
- package/src/image/index.js +8 -9
- package/src/language/index.js +8 -9
- package/src/link/css-classes-setting.js +3 -4
- package/src/math/index.js +50 -17
- package/src/text-color/inline.js +11 -16
- package/src/default-formats.native.js +0 -10
- package/src/link/index.native.js +0 -176
- package/src/link/modal-screens/link-picker-screen.native.js +0 -61
- package/src/link/modal-screens/link-settings-screen.native.js +0 -229
- package/src/link/modal-screens/screens.native.js +0 -4
- package/src/link/modal.native.js +0 -44
- package/src/link/modal.native.scss +0 -16
- package/src/link/test/__snapshots__/modal.native.js.snap +0 -553
- package/src/link/test/index.native.js +0 -145
- package/src/link/test/modal.native.js +0 -18
- package/src/text-color/index.native.js +0 -172
- package/src/text-color/inline.native.js +0 -169
- package/src/text-color/style.native.scss +0 -22
- package/src/text-color/test/__snapshots__/index.native.js.snap +0 -23
- package/src/text-color/test/index.native.js +0 -192
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
## 5.
|
|
5
|
+
## 5.49.0 (2026-06-24)
|
|
6
|
+
|
|
7
|
+
### Enhancements
|
|
8
|
+
|
|
9
|
+
- Math format: seed the LaTeX input from the current selection when marking text as math, and toggle an active math object back to its LaTeX source when the button is clicked again. ([79052](https://github.com/WordPress/gutenberg/pull/79052))
|
|
10
|
+
|
|
11
|
+
## 5.48.1 (2026-06-16)
|
|
12
|
+
|
|
13
|
+
## 5.48.0 (2026-06-10)
|
|
6
14
|
|
|
7
15
|
## 5.47.0 (2026-05-27)
|
|
8
16
|
|
package/build/image/index.cjs
CHANGED
|
@@ -23,6 +23,7 @@ __export(image_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(image_exports);
|
|
25
25
|
var import_components = require("@wordpress/components");
|
|
26
|
+
var import_ui = require("@wordpress/ui");
|
|
26
27
|
var import_i18n = require("@wordpress/i18n");
|
|
27
28
|
var import_element = require("@wordpress/element");
|
|
28
29
|
var import_rich_text = require("@wordpress/rich-text");
|
|
@@ -89,7 +90,7 @@ function InlineUI({ value, onChange, activeObjectAttributes, contentRef }) {
|
|
|
89
90
|
});
|
|
90
91
|
event.preventDefault();
|
|
91
92
|
},
|
|
92
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
93
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "column", gap: "lg", children: [
|
|
93
94
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
94
95
|
import_components.__experimentalNumberControl,
|
|
95
96
|
{
|
|
@@ -112,8 +113,9 @@ function InlineUI({ value, onChange, activeObjectAttributes, contentRef }) {
|
|
|
112
113
|
},
|
|
113
114
|
help: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
114
115
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
-
|
|
116
|
+
import_ui.Link,
|
|
116
117
|
{
|
|
118
|
+
openInNewTab: true,
|
|
117
119
|
href: (
|
|
118
120
|
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
119
121
|
(0, import_i18n.__)(
|
|
@@ -130,7 +132,7 @@ function InlineUI({ value, onChange, activeObjectAttributes, contentRef }) {
|
|
|
130
132
|
] })
|
|
131
133
|
}
|
|
132
134
|
),
|
|
133
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Stack, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
134
136
|
import_components.Button,
|
|
135
137
|
{
|
|
136
138
|
disabled: !hasChanged,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/image/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tPath,\n\tSVG,\n\tPopover,\n\tButton,\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tPath,\n\tSVG,\n\tPopover,\n\tButton,\n\t__experimentalNumberControl as NumberControl,\n\tTextareaControl,\n} from '@wordpress/components';\nimport { Link, Stack } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { insertObject, useAnchor } from '@wordpress/rich-text';\nimport {\n\tMediaUpload,\n\tRichTextToolbarButton,\n\tMediaUploadCheck,\n} from '@wordpress/block-editor';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nconst name = 'core/image';\nconst title = __( 'Inline image' );\n\n/**\n * Extracts the image ID from the className attribute.\n *\n * @param {Object} activeObjectAttributes The attributes of the active object.\n * @return {number|undefined} The extracted image ID or undefined if not found.\n */\nfunction getCurrentImageId( activeObjectAttributes ) {\n\tif ( ! activeObjectAttributes?.className ) {\n\t\treturn undefined;\n\t}\n\n\tconst [ , id ] =\n\t\tactiveObjectAttributes.className.match( /wp-image-(\\d+)/ ) ?? [];\n\n\treturn id ? parseInt( id, 10 ) : undefined;\n}\n\nexport const image = {\n\tname,\n\ttitle,\n\tkeywords: [ __( 'photo' ), __( 'media' ) ],\n\tobject: true,\n\ttagName: 'img',\n\tclassName: null,\n\tattributes: {\n\t\tclassName: 'class',\n\t\tstyle: 'style',\n\t\turl: 'src',\n\t\talt: 'alt',\n\t},\n\tedit: Edit,\n};\n\nfunction InlineUI( { value, onChange, activeObjectAttributes, contentRef } ) {\n\tconst { style, alt } = activeObjectAttributes;\n\tconst width = style?.replace( /\\D/g, '' );\n\tconst [ editedWidth, setEditedWidth ] = useState( width );\n\tconst [ editedAlt, setEditedAlt ] = useState( alt );\n\tconst hasChanged = editedWidth !== width || editedAlt !== alt;\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: image,\n\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tclassName=\"block-editor-format-toolbar__image-popover\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"block-editor-format-toolbar__image-container-content\"\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tconst newReplacements = value.replacements.slice();\n\n\t\t\t\t\tnewReplacements[ value.start ] = {\n\t\t\t\t\t\ttype: name,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t...activeObjectAttributes,\n\t\t\t\t\t\t\tstyle: editedWidth\n\t\t\t\t\t\t\t\t? `width: ${ editedWidth }px;`\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t\t\talt: editedAlt,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...value,\n\t\t\t\t\t\treplacements: newReplacements,\n\t\t\t\t\t} );\n\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Stack direction=\"column\" gap=\"lg\">\n\t\t\t\t\t<NumberControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tvalue={ editedWidth }\n\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\tonChange={ ( newWidth ) => {\n\t\t\t\t\t\t\tsetEditedWidth( newWidth );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\tvalue={ editedAlt }\n\t\t\t\t\t\tonChange={ ( newAlt ) => {\n\t\t\t\t\t\t\tsetEditedAlt( newAlt );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\topenInNewTab\n\t\t\t\t\t\t\t\t\thref={\n\t\t\t\t\t\t\t\t\t\t// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<Stack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdisabled={ ! hasChanged }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Stack>\n\t\t\t\t</Stack>\n\t\t\t</form>\n\t\t</Popover>\n\t);\n}\n\nfunction Edit( {\n\tvalue,\n\tonChange,\n\tonFocus,\n\tisObjectActive,\n\tactiveObjectAttributes,\n\tcontentRef,\n} ) {\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<MediaUpload\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tvalue={ getCurrentImageId( activeObjectAttributes ) }\n\t\t\t\tonSelect={ ( { id, url, alt, width: imgWidth } ) => {\n\t\t\t\t\tonChange(\n\t\t\t\t\t\tinsertObject( value, {\n\t\t\t\t\t\t\ttype: name,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\tclassName: `wp-image-${ id }`,\n\t\t\t\t\t\t\t\tstyle: `width: ${ Math.min(\n\t\t\t\t\t\t\t\t\timgWidth,\n\t\t\t\t\t\t\t\t\t150\n\t\t\t\t\t\t\t\t) }px;`,\n\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\talt,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t\tonFocus();\n\t\t\t\t} }\n\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<SVG\n\t\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<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\" />\n\t\t\t\t\t\t\t</SVG>\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ isObjectActive ? __( 'Replace image' ) : title }\n\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\tisActive={ isObjectActive }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t{ isObjectActive && (\n\t\t\t\t<InlineUI\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tactiveObjectAttributes={ activeObjectAttributes }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</MediaUploadCheck>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAOO;AACP,gBAA4B;AAC5B,kBAAmB;AACnB,qBAAyB;AACzB,uBAAwC;AACxC,0BAIO;AAkFF;AAhFL,IAAM,sBAAsB,CAAE,OAAQ;AAEtC,IAAM,OAAO;AACb,IAAM,YAAQ,gBAAI,cAAe;AAQjC,SAAS,kBAAmB,wBAAyB;AACpD,MAAK,CAAE,wBAAwB,WAAY;AAC1C,WAA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AO;AAAA,cACpB,MAAM;AAAA,cACN,YAAY;AAAA,gBACX,WAAW,YAAa,EAAG;AAAA,gBAC3B,OAAO,UAAW,KAAK;AAAA,kBACtB;AAAA,kBACA;AAAA,gBACD,CAAE;AAAA,gBACF;AAAA,gBACA;AAAA,cACD;AAAA,YACD,CAAE;AAAA,UACH;AACA,kBAAQ;AAAA,QACT;AAAA,QACA,QAAS,CAAE,EAAE,KAAK,MACjB;AAAA,UAAC;AAAA;AAAA,YACA,MACC;AAAA,cAAC;AAAA;AAAA,gBACA,OAAM;AAAA,gBACN,SAAQ;AAAA,gBAER,sDAAC,0BAAK,GAAE,8RAA6R;AAAA;AAAA,YACtS;AAAA,YAED,OAAQ,qBAAiB,gBAAI,eAAgB,IAAI;AAAA,YACjD,SAAU;AAAA,YACV,UAAW;AAAA;AAAA,QACZ;AAAA;AAAA,IAEF;AAAA,IACE,kBACD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
|
|
6
|
+
"names": ["NumberControl"]
|
|
7
7
|
}
|
package/build/language/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ module.exports = __toCommonJS(language_exports);
|
|
|
25
25
|
var import_i18n = require("@wordpress/i18n");
|
|
26
26
|
var import_block_editor = require("@wordpress/block-editor");
|
|
27
27
|
var import_components = require("@wordpress/components");
|
|
28
|
+
var import_ui = require("@wordpress/ui");
|
|
28
29
|
var import_element = require("@wordpress/element");
|
|
29
30
|
var import_rich_text = require("@wordpress/rich-text");
|
|
30
31
|
var import_icons = require("@wordpress/icons");
|
|
@@ -90,10 +91,11 @@ function InlineLanguageUI({ value, contentRef, onChange, onClose }) {
|
|
|
90
91
|
anchor: popoverAnchor,
|
|
91
92
|
onClose,
|
|
92
93
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
93
|
-
|
|
94
|
+
import_ui.Stack,
|
|
94
95
|
{
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("form", {}),
|
|
97
|
+
direction: "column",
|
|
98
|
+
gap: "lg",
|
|
97
99
|
className: "block-editor-format-toolbar__language-container-content",
|
|
98
100
|
onSubmit: (event) => {
|
|
99
101
|
event.preventDefault();
|
|
@@ -112,7 +114,6 @@ function InlineLanguageUI({ value, contentRef, onChange, onClose }) {
|
|
|
112
114
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
113
115
|
import_components.TextControl,
|
|
114
116
|
{
|
|
115
|
-
__next40pxDefaultSize: true,
|
|
116
117
|
label: title,
|
|
117
118
|
value: lang,
|
|
118
119
|
onChange: (val) => setLang(val),
|
|
@@ -140,7 +141,7 @@ function InlineLanguageUI({ value, contentRef, onChange, onClose }) {
|
|
|
140
141
|
onChange: (val) => setDir(val)
|
|
141
142
|
}
|
|
142
143
|
),
|
|
143
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Stack, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
145
|
import_components.Button,
|
|
145
146
|
{
|
|
146
147
|
__next40pxDefaultSize: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/language/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * WordPress dependencies\n */\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport {\n\tTextControl,\n\tSelectControl,\n\tButton,\n\tPopover,\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAKnB,0BAAsC;AACtC,
|
|
6
|
-
"names": ["languageIcon"
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * WordPress dependencies\n */\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport {\n\tTextControl,\n\tSelectControl,\n\tButton,\n\tPopover,\n} from '@wordpress/components';\nimport { Stack } from '@wordpress/ui';\nimport { useState } from '@wordpress/element';\nimport { applyFormat, removeFormat, useAnchor } from '@wordpress/rich-text';\nimport { language as languageIcon } from '@wordpress/icons';\n\nconst name = 'core/language';\nconst title = __( 'Language' );\n\nexport const language = {\n\tname,\n\ttitle,\n\ttagName: 'bdo',\n\tclassName: null,\n\tattributes: {\n\t\tlang: 'lang',\n\t\tdir: 'dir',\n\t},\n\tedit: Edit,\n};\n\nfunction Edit( { isActive, value, onChange, contentRef } ) {\n\tconst [ isPopoverVisible, setIsPopoverVisible ] = useState( false );\n\tconst togglePopover = () => {\n\t\tsetIsPopoverVisible( ( state ) => ! state );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ languageIcon }\n\t\t\t\tlabel={ title }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tif ( isActive ) {\n\t\t\t\t\t\tonChange( removeFormat( value, name ) );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttogglePopover();\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isPopoverVisible && (\n\t\t\t\t<InlineLanguageUI\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonClose={ togglePopover }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction InlineLanguageUI( { value, contentRef, onChange, onClose } ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: language,\n\t} );\n\n\tconst [ lang, setLang ] = useState( '' );\n\tconst [ dir, setDir ] = useState( 'ltr' );\n\n\treturn (\n\t\t<Popover\n\t\t\tclassName=\"block-editor-format-toolbar__language-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t\tonClose={ onClose }\n\t\t>\n\t\t\t<Stack\n\t\t\t\trender={ <form /> }\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t\tclassName=\"block-editor-format-toolbar__language-container-content\"\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonChange(\n\t\t\t\t\t\tapplyFormat( value, {\n\t\t\t\t\t\t\ttype: name,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\tlang,\n\t\t\t\t\t\t\t\tdir,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ title }\n\t\t\t\t\tvalue={ lang }\n\t\t\t\t\tonChange={ ( val ) => setLang( val ) }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'A valid language attribute, like \"en\" or \"fr\".'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Text direction' ) }\n\t\t\t\t\tvalue={ dir }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Left to right' ),\n\t\t\t\t\t\t\tvalue: 'ltr',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Right to left' ),\n\t\t\t\t\t\t\tvalue: 'rtl',\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t\tonChange={ ( val ) => setDir( val ) }\n\t\t\t\t/>\n\t\t\t\t<Stack justify=\"right\">\n\t\t\t\t\t<Button\n\t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I,OAAQ;AAAA;AAAA,YACpB,GACD;AAAA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["languageIcon"]
|
|
7
7
|
}
|
|
@@ -52,7 +52,7 @@ var CSSClassesSettingComponent = ({ setting, value, onChange }) => {
|
|
|
52
52
|
};
|
|
53
53
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("fieldset", { children: [
|
|
54
54
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("legend", {}), children: setting.title }),
|
|
55
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
55
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "column", gap: "md", children: [
|
|
56
56
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
57
57
|
import_components.CheckboxControl,
|
|
58
58
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/link/css-classes-setting.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalInputControl as InputControl,\n\tCheckboxControl,\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAyB;AACzB,qBAA8B;AAC9B,kBAAmB;AACnB,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalInputControl as InputControl,\n\tCheckboxControl,\n} from '@wordpress/components';\nimport { Stack, VisuallyHidden } from '@wordpress/ui';\n\n/**\n * CSSClassesSettingComponent\n *\n * Presents a toggleable text input for editing link CSS classes. The input\n * is shown when the toggle is enabled or when there is already a value. When\n * toggled off and a value exists, it resets the value to an empty string.\n *\n * @param {Object} props - Component props.\n * @param {Object} props.setting - Setting configuration object.\n * @param {Object} props.value - Current link value object.\n * @param {Function} props.onChange - Callback when value changes.\n */\nconst CSSClassesSettingComponent = ( { setting, value, onChange } ) => {\n\tconst hasValue = value ? value?.cssClasses?.length > 0 : false;\n\tconst [ isSettingActive, setIsSettingActive ] = useState( hasValue );\n\tconst instanceId = useInstanceId( CSSClassesSettingComponent );\n\tconst controlledRegionId = `css-classes-setting-${ instanceId }`;\n\n\t// Sanitize user input: replace commas with spaces, collapse repeated spaces, and trim\n\tconst handleSettingChange = ( newValue ) => {\n\t\tconst sanitizedValue =\n\t\t\ttypeof newValue === 'string'\n\t\t\t\t? newValue.replace( /,/g, ' ' ).replace( /\\s+/g, ' ' ).trim()\n\t\t\t\t: newValue;\n\t\tonChange( {\n\t\t\t...value,\n\t\t\t[ setting.id ]: sanitizedValue,\n\t\t} );\n\t};\n\n\tconst handleCheckboxChange = () => {\n\t\tif ( isSettingActive ) {\n\t\t\tif ( hasValue ) {\n\t\t\t\t// Reset the value when hiding the input and a value exists.\n\t\t\t\thandleSettingChange( '' );\n\t\t\t}\n\t\t\tsetIsSettingActive( false );\n\t\t} else {\n\t\t\tsetIsSettingActive( true );\n\t\t}\n\t};\n\n\treturn (\n\t\t<fieldset>\n\t\t\t<VisuallyHidden render={ <legend /> }>\n\t\t\t\t{ setting.title }\n\t\t\t</VisuallyHidden>\n\t\t\t<Stack direction=\"column\" gap=\"md\">\n\t\t\t\t<CheckboxControl\n\t\t\t\t\tlabel={ setting.title }\n\t\t\t\t\tonChange={ handleCheckboxChange }\n\t\t\t\t\tchecked={ isSettingActive || hasValue }\n\t\t\t\t\taria-expanded={ isSettingActive }\n\t\t\t\t\taria-controls={\n\t\t\t\t\t\tisSettingActive ? controlledRegionId : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t{ isSettingActive && (\n\t\t\t\t\t<div id={ controlledRegionId }>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\tlabel={ __( 'CSS classes' ) }\n\t\t\t\t\t\t\tvalue={ value?.cssClasses }\n\t\t\t\t\t\t\tonChange={ handleSettingChange }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Separate multiple classes with spaces.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t__unstableInputWidth=\"100%\"\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</Stack>\n\t\t</fieldset>\n\t);\n};\n\nexport default CSSClassesSettingComponent;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAyB;AACzB,qBAA8B;AAC9B,kBAAmB;AACnB,wBAGO;AACP,gBAAsC;AA8CV;AAhC5B,IAAM,6BAA6B,CAAE,EAAE,SAAS,OAAO,SAAS,MAAO;AACtE,QAAM,WAAW,QAAQ,OAAO,YAAY,SAAS,IAAI;AACzD,QAAM,CAAE,iBAAiB,kBAAmB,QAAI,yBAAU,QAAS;AACnE,QAAM,iBAAa,8BAAe,0BAA2B;AAC7D,QAAM,qBAAqB,uBAAwB,UAAW;AAG9D,QAAM,sBAAsB,CAAE,aAAc;AAC3C,UAAM,iBACL,OAAO,aAAa,WACjB,SAAS,QAAS,MAAM,GAAI,EAAE,QAAS,QAAQ,GAAI,EAAE,KAAK,IAC1D;AACJ,aAAU;AAAA,MACT,GAAG;AAAA,MACH,CAAE,QAAQ,EAAG,GAAG;AAAA,IACjB,CAAE;AAAA,EACH;AAEA,QAAM,uBAAuB,MAAM;AAClC,QAAK,iBAAkB;AACtB,UAAK,UAAW;AAEf,4BAAqB,EAAG;AAAA,MACzB;AACA,yBAAoB,KAAM;AAAA,IAC3B,OAAO;AACN,yBAAoB,IAAK;AAAA,IAC1B;AAAA,EACD;AAEA,SACC,6CAAC,cACA;AAAA,gDAAC,4BAAe,QAAS,4CAAC,YAAO,GAC9B,kBAAQ,OACX;AAAA,IACA,6CAAC,mBAAM,WAAU,UAAS,KAAI,MAC7B;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ,QAAQ;AAAA,UAChB,UAAW;AAAA,UACX,SAAU,mBAAmB;AAAA,UAC7B,iBAAgB;AAAA,UAChB,iBACC,kBAAkB,qBAAqB;AAAA;AAAA,MAEzC;AAAA,MACE,mBACD,4CAAC,SAAI,IAAK,oBACT;AAAA,QAAC,kBAAAA;AAAA,QAAA;AAAA,UACA,WAAQ,gBAAI,aAAc;AAAA,UAC1B,OAAQ,OAAO;AAAA,UACf,UAAW;AAAA,UACX,UAAO;AAAA,YACN;AAAA,UACD;AAAA,UACA,sBAAqB;AAAA,UACrB,uBAAqB;AAAA;AAAA,MACtB,GACD;AAAA,OAEF;AAAA,KACD;AAEF;AAEA,IAAO,8BAAQ;",
|
|
6
|
+
"names": ["InputControl"]
|
|
7
7
|
}
|
package/build/math/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ var import_element = require("@wordpress/element");
|
|
|
37
37
|
var import_rich_text = require("@wordpress/rich-text");
|
|
38
38
|
var import_block_editor = require("@wordpress/block-editor");
|
|
39
39
|
var import_components = require("@wordpress/components");
|
|
40
|
+
var import_ui = require("@wordpress/ui");
|
|
40
41
|
var import_icons = require("@wordpress/icons");
|
|
41
42
|
var import_a11y = require("@wordpress/a11y");
|
|
42
43
|
var import_lock_unlock = require("../lock-unlock.cjs");
|
|
@@ -99,11 +100,10 @@ function InlineUI({
|
|
|
99
100
|
focusOnMount: false,
|
|
100
101
|
anchor: popoverAnchor,
|
|
101
102
|
className: "block-editor-format-toolbar__math-popover",
|
|
102
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { minWidth: "300px", padding: "4px" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
103
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { minWidth: "300px", padding: "4px" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "column", gap: "xs", children: [
|
|
103
104
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
104
105
|
import_components.TextControl,
|
|
105
106
|
{
|
|
106
|
-
__next40pxDefaultSize: true,
|
|
107
107
|
hideLabelFromVision: true,
|
|
108
108
|
label: (0, import_i18n.__)("LaTeX math syntax"),
|
|
109
109
|
value: latex,
|
|
@@ -146,24 +146,40 @@ function Edit({
|
|
|
146
146
|
setLatexToMathML(() => module2.default);
|
|
147
147
|
});
|
|
148
148
|
}, []);
|
|
149
|
+
function onClick() {
|
|
150
|
+
let newValue;
|
|
151
|
+
if (isObjectActive) {
|
|
152
|
+
const latex = activeObjectAttributes?.["data-latex"] || "";
|
|
153
|
+
newValue = (0, import_rich_text.insert)(value, latex);
|
|
154
|
+
newValue.start = newValue.end - latex.length;
|
|
155
|
+
} else {
|
|
156
|
+
const selectedText = (0, import_rich_text.getTextContent)((0, import_rich_text.slice)(value));
|
|
157
|
+
let innerHTML = "";
|
|
158
|
+
if (selectedText && latexToMathML) {
|
|
159
|
+
try {
|
|
160
|
+
innerHTML = latexToMathML(selectedText, {
|
|
161
|
+
displayMode: false
|
|
162
|
+
});
|
|
163
|
+
} catch {
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
newValue = (0, import_rich_text.insertObject)(value, {
|
|
167
|
+
type: name,
|
|
168
|
+
attributes: { "data-latex": selectedText },
|
|
169
|
+
innerHTML
|
|
170
|
+
});
|
|
171
|
+
newValue.start = newValue.end - 1;
|
|
172
|
+
}
|
|
173
|
+
onChange(newValue);
|
|
174
|
+
onFocus();
|
|
175
|
+
}
|
|
149
176
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
150
177
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
151
178
|
import_block_editor.RichTextToolbarButton,
|
|
152
179
|
{
|
|
153
180
|
icon: import_icons.math,
|
|
154
181
|
title,
|
|
155
|
-
onClick
|
|
156
|
-
const newValue = (0, import_rich_text.insertObject)(value, {
|
|
157
|
-
type: name,
|
|
158
|
-
attributes: {
|
|
159
|
-
"data-latex": ""
|
|
160
|
-
},
|
|
161
|
-
innerHTML: ""
|
|
162
|
-
});
|
|
163
|
-
newValue.start = newValue.end - 1;
|
|
164
|
-
onChange(newValue);
|
|
165
|
-
onFocus();
|
|
166
|
-
},
|
|
182
|
+
onClick,
|
|
167
183
|
isActive: isObjectActive
|
|
168
184
|
}
|
|
169
185
|
),
|
package/build/math/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/math/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,qBAAoC;AACpC,
|
|
6
|
-
"names": ["componentsPrivateApis", "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tinsert,\n\tinsertObject,\n\tslice,\n\tgetTextContent,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport {\n\tPopover,\n\tTextControl,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { Stack } from '@wordpress/ui';\nimport { math as icon } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { Badge: WCBadge } = unlock( componentsPrivateApis );\n\nconst name = 'core/math';\nconst title = __( 'Math' );\n\nfunction InlineUI( {\n\tvalue,\n\tonChange,\n\tactiveAttributes,\n\tcontentRef,\n\tlatexToMathML,\n} ) {\n\tconst [ latex, setLatex ] = useState(\n\t\tactiveAttributes?.[ 'data-latex' ] || ''\n\t);\n\tconst [ error, setError ] = useState( null );\n\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: math,\n\t} );\n\n\t// Update the math object in real-time as the user types\n\tconst handleLatexChange = ( newLatex ) => {\n\t\tlet mathML = '';\n\n\t\tsetLatex( newLatex );\n\n\t\tif ( newLatex ) {\n\t\t\ttry {\n\t\t\t\tmathML = latexToMathML( newLatex, { displayMode: false } );\n\t\t\t\tsetError( null );\n\t\t\t} catch ( err ) {\n\t\t\t\tsetError( err.message );\n\t\t\t\tspeak(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: error message returned when parsing LaTeX. */\n\t\t\t\t\t\t__( 'Error parsing mathematical expression: %s' ),\n\t\t\t\t\t\terr.message\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst newReplacements = value.replacements.slice();\n\t\tnewReplacements[ value.start ] = {\n\t\t\ttype: name,\n\t\t\tattributes: {\n\t\t\t\t'data-latex': newLatex,\n\t\t\t},\n\t\t\tinnerHTML: mathML,\n\t\t};\n\n\t\tonChange( {\n\t\t\t...value,\n\t\t\treplacements: newReplacements,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<Popover\n\t\t\tplacement=\"bottom-start\"\n\t\t\toffset={ 8 }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tclassName=\"block-editor-format-toolbar__math-popover\"\n\t\t>\n\t\t\t<div style={ { minWidth: '300px', padding: '4px' } }>\n\t\t\t\t<Stack direction=\"column\" gap=\"xs\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tlabel={ __( 'LaTeX math syntax' ) }\n\t\t\t\t\t\tvalue={ latex }\n\t\t\t\t\t\tonChange={ handleLatexChange }\n\t\t\t\t\t\tplaceholder={ __( 'e.g., x^2, \\\\frac{a}{b}' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__math-input\"\n\t\t\t\t\t/>\n\t\t\t\t\t{ error && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<WCBadge\n\t\t\t\t\t\t\t\tintent=\"error\"\n\t\t\t\t\t\t\t\tclassName=\"wp-block-math__error\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: error message returned when parsing LaTeX. */\n\t\t\t\t\t\t\t\t\t__( 'Error: %s' ),\n\t\t\t\t\t\t\t\t\terror\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</WCBadge>\n\t\t\t\t\t\t\t<style children=\".wp-block-math__error .components-badge__content{white-space:normal}\" />\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</Stack>\n\t\t\t</div>\n\t\t</Popover>\n\t);\n}\n\nfunction Edit( {\n\tvalue,\n\tonChange,\n\tonFocus,\n\tisObjectActive,\n\tactiveObjectAttributes,\n\tcontentRef,\n} ) {\n\tconst [ latexToMathML, setLatexToMathML ] = useState();\n\n\tuseEffect( () => {\n\t\timport( '@wordpress/latex-to-mathml' ).then( ( module ) => {\n\t\t\tsetLatexToMathML( () => module.default );\n\t\t} );\n\t}, [] );\n\n\tfunction onClick() {\n\t\tlet newValue;\n\n\t\tif ( isObjectActive ) {\n\t\t\t// Revert the active math object to its LaTeX source so clicking\n\t\t\t// the button toggles back to the exact text it was created from.\n\t\t\t// Keep the restored text selected so it can be edited or\n\t\t\t// re-marked right away.\n\t\t\tconst latex = activeObjectAttributes?.[ 'data-latex' ] || '';\n\t\t\tnewValue = insert( value, latex );\n\t\t\tnewValue.start = newValue.end - latex.length;\n\t\t} else {\n\t\t\t// If there's a selection, seed the format with it so you can type\n\t\t\t// LaTeX inline and then mark it as math.\n\t\t\tconst selectedText = getTextContent( slice( value ) );\n\t\t\tlet innerHTML = '';\n\t\t\tif ( selectedText && latexToMathML ) {\n\t\t\t\ttry {\n\t\t\t\t\tinnerHTML = latexToMathML( selectedText, {\n\t\t\t\t\t\tdisplayMode: false,\n\t\t\t\t\t} );\n\t\t\t\t} catch {\n\t\t\t\t\t// Leave unrendered; the popover opens with the text\n\t\t\t\t\t// prefilled so the expression can be corrected.\n\t\t\t\t}\n\t\t\t}\n\t\t\tnewValue = insertObject( value, {\n\t\t\t\ttype: name,\n\t\t\t\tattributes: { 'data-latex': selectedText },\n\t\t\t\tinnerHTML,\n\t\t\t} );\n\t\t\tnewValue.start = newValue.end - 1;\n\t\t}\n\n\t\tonChange( newValue );\n\t\tonFocus();\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ icon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isObjectActive }\n\t\t\t/>\n\t\t\t{ isObjectActive && (\n\t\t\t\t<InlineUI\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tactiveAttributes={ activeObjectAttributes }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\tlatexToMathML={ latexToMathML }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const math = {\n\tname,\n\ttitle,\n\ttagName: 'math',\n\tclassName: null,\n\tattributes: {\n\t\t'data-latex': 'data-latex',\n\t},\n\tcontentEditable: false,\n\tedit: Edit,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA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AAA,MACD;AACA,qBAAW,+BAAc,OAAO;AAAA,QAC/B,MAAM;AAAA,QACN,YAAY,EAAE,cAAc,aAAa;AAAA,QACzC;AAAA,MACD,CAAE;AACF,eAAS,QAAQ,SAAS,MAAM;AAAA,IACjC;AAEA,aAAU,QAAS;AACnB,YAAQ;AAAA,EACT;AAEA,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAO,aAAAC;AAAA,QACP;AAAA,QACA;AAAA,QACA,UAAW;AAAA;AAAA,IACZ;AAAA,IACE,kBACD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAmB;AAAA,QACnB;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;AAEO,IAAM,OAAO;AAAA,EACnB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AAAA,IACX,cAAc;AAAA,EACf;AAAA,EACA,iBAAiB;AAAA,EACjB,MAAM;AACP;",
|
|
6
|
+
"names": ["componentsPrivateApis", "module", "icon"]
|
|
7
7
|
}
|
|
@@ -35,7 +35,7 @@ var nonBreakingSpace = {
|
|
|
35
35
|
className: null,
|
|
36
36
|
edit({ value, onChange }) {
|
|
37
37
|
function addNonBreakingSpace() {
|
|
38
|
-
onChange((0, import_rich_text.insert)(value, "
|
|
38
|
+
onChange((0, import_rich_text.insert)(value, " "));
|
|
39
39
|
}
|
|
40
40
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
41
|
import_block_editor.RichTextShortcut,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/non-breaking-space/index.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { insert } from '@wordpress/rich-text';\nimport { RichTextShortcut } from '@wordpress/block-editor';\n\nconst name = 'core/non-breaking-space';\nconst title = __( 'Non breaking space' );\n\nexport const nonBreakingSpace = {\n\tname,\n\ttitle,\n\ttagName: 'nbsp',\n\tclassName: null,\n\tedit( { value, onChange } ) {\n\t\tfunction addNonBreakingSpace() {\n\t\t\tonChange( insert( value, '\\u00a0' ) );\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextShortcut\n\t\t\t\ttype=\"primaryShift\"\n\t\t\t\tcharacter=\" \"\n\t\t\t\tonUse={ addNonBreakingSpace }\n\t\t\t/>\n\t\t);\n\t},\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,uBAAuB;AACvB,0BAAiC;AAgB9B;AAdH,IAAM,OAAO;AACb,IAAM,YAAQ,gBAAI,oBAAqB;AAEhC,IAAM,mBAAmB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,OAAO,SAAS,GAAI;AAC3B,aAAS,sBAAsB;AAC9B,mBAAU,yBAAQ,OAAO,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,uBAAuB;AACvB,0BAAiC;AAgB9B;AAdH,IAAM,OAAO;AACb,IAAM,YAAQ,gBAAI,oBAAqB;AAEhC,IAAM,mBAAmB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,OAAO,SAAS,GAAI;AAC3B,aAAS,sBAAsB;AAC9B,mBAAU,yBAAQ,OAAO,GAAS,CAAE;AAAA,IACrC;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,WAAU;AAAA,QACV,OAAQ;AAAA;AAAA,IACT;AAAA,EAEF;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -29,11 +29,10 @@ var import_data = require("@wordpress/data");
|
|
|
29
29
|
var import_rich_text = require("@wordpress/rich-text");
|
|
30
30
|
var import_block_editor = require("@wordpress/block-editor");
|
|
31
31
|
var import_components = require("@wordpress/components");
|
|
32
|
+
var import_ui = require("@wordpress/ui");
|
|
32
33
|
var import_i18n = require("@wordpress/i18n");
|
|
33
34
|
var import_index = require("./index.cjs");
|
|
34
|
-
var import_lock_unlock = require("../lock-unlock.cjs");
|
|
35
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
-
var { Tabs } = (0, import_lock_unlock.unlock)(import_components.privateApis);
|
|
37
36
|
var TABS = [
|
|
38
37
|
{ name: "color", title: (0, import_i18n.__)("Text") },
|
|
39
38
|
{ name: "backgroundColor", title: (0, import_i18n.__)("Background") }
|
|
@@ -148,13 +147,13 @@ function InlineColorUI({
|
|
|
148
147
|
onClose,
|
|
149
148
|
className: "format-library__inline-color-popover",
|
|
150
149
|
anchor: popoverAnchor,
|
|
151
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tabs, { children: [
|
|
152
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.
|
|
150
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Tabs.Root, { defaultValue: TABS[0].name, children: [
|
|
151
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.List, { children: TABS.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.Tab, { value: tab.name, children: tab.title }, tab.name)) }),
|
|
153
152
|
TABS.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
154
|
-
Tabs.
|
|
153
|
+
import_ui.Tabs.Panel,
|
|
155
154
|
{
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
value: tab.name,
|
|
156
|
+
tabIndex: -1,
|
|
158
157
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
159
158
|
ColorPicker,
|
|
160
159
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/text-color/inline.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,kBAA0B;AAC1B,uBAKO;AACP,0BAMO;AACP,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Popover } from '@wordpress/components';\nimport { Tabs } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\n\nconst TABS = [\n\t{ name: 'color', title: __( 'Text' ) },\n\t{ name: 'backgroundColor', title: __( 'Background' ) },\n];\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) {\n\t\t\t\taccumulator.color = value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'background-color' &&\n\t\t\t\tvalue !== transparentValue\n\t\t\t) {\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t\t}\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) {\n\t\tattributes.style = styles.join( ';' );\n\t}\n\tif ( classNames.length ) {\n\t\tattributes.class = classNames.join( ' ' );\n\t}\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ ( color ) => {\n\t\t\t\tonChange(\n\t\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t\t);\n\t\t\t} }\n\t\t\tenableAlpha\n\t\t\t// Prevent the text and color picker from overlapping.\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n\tisActive,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: { ...settings, isActive },\n\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"format-library__inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<Tabs.Root defaultValue={ TABS[ 0 ].name }>\n\t\t\t\t<Tabs.List>\n\t\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab value={ tab.name } key={ tab.name }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.List>\n\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t<Tabs.Panel\n\t\t\t\t\t\tvalue={ tab.name }\n\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\tkey={ tab.name }\n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AA,cAAC;AAAA;AAAA,gBACA;AAAA,gBACA,UAAW,IAAI;AAAA,gBACf;AAAA,gBACA;AAAA;AAAA,YACD;AAAA;AAAA,UAPM,IAAI;AAAA,QAQX,CACC;AAAA,SACH;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["blockEditorStore", "settings"]
|
|
7
7
|
}
|
|
@@ -4,12 +4,10 @@ import {
|
|
|
4
4
|
SVG,
|
|
5
5
|
Popover,
|
|
6
6
|
Button,
|
|
7
|
-
ExternalLink,
|
|
8
|
-
__experimentalHStack as HStack,
|
|
9
|
-
__experimentalVStack as VStack,
|
|
10
7
|
__experimentalNumberControl as NumberControl,
|
|
11
8
|
TextareaControl
|
|
12
9
|
} from "@wordpress/components";
|
|
10
|
+
import { Link, Stack } from "@wordpress/ui";
|
|
13
11
|
import { __ } from "@wordpress/i18n";
|
|
14
12
|
import { useState } from "@wordpress/element";
|
|
15
13
|
import { insertObject, useAnchor } from "@wordpress/rich-text";
|
|
@@ -80,7 +78,7 @@ function InlineUI({ value, onChange, activeObjectAttributes, contentRef }) {
|
|
|
80
78
|
});
|
|
81
79
|
event.preventDefault();
|
|
82
80
|
},
|
|
83
|
-
children: /* @__PURE__ */ jsxs(
|
|
81
|
+
children: /* @__PURE__ */ jsxs(Stack, { direction: "column", gap: "lg", children: [
|
|
84
82
|
/* @__PURE__ */ jsx(
|
|
85
83
|
NumberControl,
|
|
86
84
|
{
|
|
@@ -103,8 +101,9 @@ function InlineUI({ value, onChange, activeObjectAttributes, contentRef }) {
|
|
|
103
101
|
},
|
|
104
102
|
help: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
105
103
|
/* @__PURE__ */ jsx(
|
|
106
|
-
|
|
104
|
+
Link,
|
|
107
105
|
{
|
|
106
|
+
openInNewTab: true,
|
|
108
107
|
href: (
|
|
109
108
|
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
110
109
|
__(
|
|
@@ -121,7 +120,7 @@ function InlineUI({ value, onChange, activeObjectAttributes, contentRef }) {
|
|
|
121
120
|
] })
|
|
122
121
|
}
|
|
123
122
|
),
|
|
124
|
-
/* @__PURE__ */ jsx(
|
|
123
|
+
/* @__PURE__ */ jsx(Stack, { justify: "right", children: /* @__PURE__ */ jsx(
|
|
125
124
|
Button,
|
|
126
125
|
{
|
|
127
126
|
disabled: !hasChanged,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/image/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tPath,\n\tSVG,\n\tPopover,\n\tButton,\n\
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tPath,\n\tSVG,\n\tPopover,\n\tButton,\n\t__experimentalNumberControl as NumberControl,\n\tTextareaControl,\n} from '@wordpress/components';\nimport { Link, Stack } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { insertObject, useAnchor } from '@wordpress/rich-text';\nimport {\n\tMediaUpload,\n\tRichTextToolbarButton,\n\tMediaUploadCheck,\n} from '@wordpress/block-editor';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nconst name = 'core/image';\nconst title = __( 'Inline image' );\n\n/**\n * Extracts the image ID from the className attribute.\n *\n * @param {Object} activeObjectAttributes The attributes of the active object.\n * @return {number|undefined} The extracted image ID or undefined if not found.\n */\nfunction getCurrentImageId( activeObjectAttributes ) {\n\tif ( ! activeObjectAttributes?.className ) {\n\t\treturn undefined;\n\t}\n\n\tconst [ , id ] =\n\t\tactiveObjectAttributes.className.match( /wp-image-(\\d+)/ ) ?? [];\n\n\treturn id ? parseInt( id, 10 ) : undefined;\n}\n\nexport const image = {\n\tname,\n\ttitle,\n\tkeywords: [ __( 'photo' ), __( 'media' ) ],\n\tobject: true,\n\ttagName: 'img',\n\tclassName: null,\n\tattributes: {\n\t\tclassName: 'class',\n\t\tstyle: 'style',\n\t\turl: 'src',\n\t\talt: 'alt',\n\t},\n\tedit: Edit,\n};\n\nfunction InlineUI( { value, onChange, activeObjectAttributes, contentRef } ) {\n\tconst { style, alt } = activeObjectAttributes;\n\tconst width = style?.replace( /\\D/g, '' );\n\tconst [ editedWidth, setEditedWidth ] = useState( width );\n\tconst [ editedAlt, setEditedAlt ] = useState( alt );\n\tconst hasChanged = editedWidth !== width || editedAlt !== alt;\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: image,\n\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tclassName=\"block-editor-format-toolbar__image-popover\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"block-editor-format-toolbar__image-container-content\"\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tconst newReplacements = value.replacements.slice();\n\n\t\t\t\t\tnewReplacements[ value.start ] = {\n\t\t\t\t\t\ttype: name,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t...activeObjectAttributes,\n\t\t\t\t\t\t\tstyle: editedWidth\n\t\t\t\t\t\t\t\t? `width: ${ editedWidth }px;`\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t\t\talt: editedAlt,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...value,\n\t\t\t\t\t\treplacements: newReplacements,\n\t\t\t\t\t} );\n\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Stack direction=\"column\" gap=\"lg\">\n\t\t\t\t\t<NumberControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tvalue={ editedWidth }\n\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\tonChange={ ( newWidth ) => {\n\t\t\t\t\t\t\tsetEditedWidth( newWidth );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\tvalue={ editedAlt }\n\t\t\t\t\t\tonChange={ ( newAlt ) => {\n\t\t\t\t\t\t\tsetEditedAlt( newAlt );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\topenInNewTab\n\t\t\t\t\t\t\t\t\thref={\n\t\t\t\t\t\t\t\t\t\t// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<Stack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdisabled={ ! hasChanged }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Stack>\n\t\t\t\t</Stack>\n\t\t\t</form>\n\t\t</Popover>\n\t);\n}\n\nfunction Edit( {\n\tvalue,\n\tonChange,\n\tonFocus,\n\tisObjectActive,\n\tactiveObjectAttributes,\n\tcontentRef,\n} ) {\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<MediaUpload\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tvalue={ getCurrentImageId( activeObjectAttributes ) }\n\t\t\t\tonSelect={ ( { id, url, alt, width: imgWidth } ) => {\n\t\t\t\t\tonChange(\n\t\t\t\t\t\tinsertObject( value, {\n\t\t\t\t\t\t\ttype: name,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\tclassName: `wp-image-${ id }`,\n\t\t\t\t\t\t\t\tstyle: `width: ${ Math.min(\n\t\t\t\t\t\t\t\t\timgWidth,\n\t\t\t\t\t\t\t\t\t150\n\t\t\t\t\t\t\t\t) }px;`,\n\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\talt,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t\tonFocus();\n\t\t\t\t} }\n\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<SVG\n\t\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<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\" />\n\t\t\t\t\t\t\t</SVG>\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ isObjectActive ? __( 'Replace image' ) : title }\n\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\tisActive={ isObjectActive }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t{ isObjectActive && (\n\t\t\t\t<InlineUI\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tactiveObjectAttributes={ activeObjectAttributes }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</MediaUploadCheck>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,+BAA+B;AAAA,EAC/B;AAAA,OACM;AACP,SAAS,MAAM,aAAa;AAC5B,SAAS,UAAU;AACnB,SAAS,gBAAgB;AACzB,SAAS,cAAc,iBAAiB;AACxC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAkFF,SAgBE,UAhBF,KAgBE,YAhBF;AAhFL,IAAM,sBAAsB,CAAE,OAAQ;AAEtC,IAAM,OAAO;AACb,IAAM,QAAQ,GAAI,cAAe;AAQjC,SAAS,kBAAmB,wBAAyB;AACpD,MAAK,CAAE,wBAAwB,WAAY;AAC1C,WAAO;AAAA,EACR;AAEA,QAAM,CAAE,EAAE,EAAG,IACZ,uBAAuB,UAAU,MAAO,gBAAiB,KAAK,CAAC;AAEhE,SAAO,KAAK,SAAU,IAAI,EAAG,IAAI;AAClC;AAEO,IAAM,QAAQ;AAAA,EACpB;AAAA,EACA;AAAA,EACA,UAAU,CAAE,GAAI,OAAQ,GAAG,GAAI,OAAQ,CAAE;AAAA,EACzC,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WA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;AAAA,gBACA,OAAM;AAAA,gBACN,SAAQ;AAAA,gBAER,8BAAC,QAAK,GAAE,8RAA6R;AAAA;AAAA,YACtS;AAAA,YAED,OAAQ,iBAAiB,GAAI,eAAgB,IAAI;AAAA,YACjD,SAAU;AAAA,YACV,UAAW;AAAA;AAAA,QACZ;AAAA;AAAA,IAEF;AAAA,IACE,kBACD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,10 +5,9 @@ import {
|
|
|
5
5
|
TextControl,
|
|
6
6
|
SelectControl,
|
|
7
7
|
Button,
|
|
8
|
-
Popover
|
|
9
|
-
__experimentalHStack as HStack,
|
|
10
|
-
__experimentalVStack as VStack
|
|
8
|
+
Popover
|
|
11
9
|
} from "@wordpress/components";
|
|
10
|
+
import { Stack } from "@wordpress/ui";
|
|
12
11
|
import { useState } from "@wordpress/element";
|
|
13
12
|
import { applyFormat, removeFormat, useAnchor } from "@wordpress/rich-text";
|
|
14
13
|
import { language as languageIcon } from "@wordpress/icons";
|
|
@@ -74,10 +73,11 @@ function InlineLanguageUI({ value, contentRef, onChange, onClose }) {
|
|
|
74
73
|
anchor: popoverAnchor,
|
|
75
74
|
onClose,
|
|
76
75
|
children: /* @__PURE__ */ jsxs(
|
|
77
|
-
|
|
76
|
+
Stack,
|
|
78
77
|
{
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
render: /* @__PURE__ */ jsx("form", {}),
|
|
79
|
+
direction: "column",
|
|
80
|
+
gap: "lg",
|
|
81
81
|
className: "block-editor-format-toolbar__language-container-content",
|
|
82
82
|
onSubmit: (event) => {
|
|
83
83
|
event.preventDefault();
|
|
@@ -96,7 +96,6 @@ function InlineLanguageUI({ value, contentRef, onChange, onClose }) {
|
|
|
96
96
|
/* @__PURE__ */ jsx(
|
|
97
97
|
TextControl,
|
|
98
98
|
{
|
|
99
|
-
__next40pxDefaultSize: true,
|
|
100
99
|
label: title,
|
|
101
100
|
value: lang,
|
|
102
101
|
onChange: (val) => setLang(val),
|
|
@@ -124,7 +123,7 @@ function InlineLanguageUI({ value, contentRef, onChange, onClose }) {
|
|
|
124
123
|
onChange: (val) => setDir(val)
|
|
125
124
|
}
|
|
126
125
|
),
|
|
127
|
-
/* @__PURE__ */ jsx(
|
|
126
|
+
/* @__PURE__ */ jsx(Stack, { justify: "right", children: /* @__PURE__ */ jsx(
|
|
128
127
|
Button,
|
|
129
128
|
{
|
|
130
129
|
__next40pxDefaultSize: true,
|