@wordpress/format-library 5.4.0 → 5.5.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 +2 -0
- package/build/image/index.js +40 -15
- package/build/image/index.js.map +1 -1
- package/build/language/index.js +8 -1
- package/build/language/index.js.map +1 -1
- package/build-module/image/index.js +42 -16
- package/build-module/image/index.js.map +1 -1
- package/build-module/language/index.js +9 -2
- package/build-module/language/index.js.map +1 -1
- package/build-style/style-rtl.css +6 -9
- package/build-style/style.css +6 -9
- package/package.json +14 -14
- package/src/image/index.js +54 -15
- package/src/image/style.scss +3 -10
- package/src/language/index.js +10 -2
package/CHANGELOG.md
CHANGED
package/build/image/index.js
CHANGED
|
@@ -9,7 +9,6 @@ var _i18n = require("@wordpress/i18n");
|
|
|
9
9
|
var _element = require("@wordpress/element");
|
|
10
10
|
var _richText = require("@wordpress/rich-text");
|
|
11
11
|
var _blockEditor = require("@wordpress/block-editor");
|
|
12
|
-
var _icons = require("@wordpress/icons");
|
|
13
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
13
|
/**
|
|
15
14
|
* WordPress dependencies
|
|
@@ -40,9 +39,13 @@ function InlineUI({
|
|
|
40
39
|
contentRef
|
|
41
40
|
}) {
|
|
42
41
|
const {
|
|
43
|
-
style
|
|
42
|
+
style,
|
|
43
|
+
alt
|
|
44
44
|
} = activeObjectAttributes;
|
|
45
|
-
const
|
|
45
|
+
const width = style?.replace(/\D/g, '');
|
|
46
|
+
const [editedWidth, setEditedWidth] = (0, _element.useState)(width);
|
|
47
|
+
const [editedAlt, setEditedAlt] = (0, _element.useState)(alt);
|
|
48
|
+
const hasChanged = editedWidth !== width || editedAlt !== alt;
|
|
46
49
|
const popoverAnchor = (0, _richText.useAnchor)({
|
|
47
50
|
editableContentElement: contentRef.current,
|
|
48
51
|
settings: image
|
|
@@ -60,7 +63,8 @@ function InlineUI({
|
|
|
60
63
|
type: name,
|
|
61
64
|
attributes: {
|
|
62
65
|
...activeObjectAttributes,
|
|
63
|
-
style: width ? `width: ${
|
|
66
|
+
style: width ? `width: ${editedWidth}px;` : '',
|
|
67
|
+
alt: editedAlt
|
|
64
68
|
}
|
|
65
69
|
};
|
|
66
70
|
onChange({
|
|
@@ -69,20 +73,41 @@ function InlineUI({
|
|
|
69
73
|
});
|
|
70
74
|
event.preventDefault();
|
|
71
75
|
},
|
|
72
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.
|
|
73
|
-
|
|
74
|
-
spacing: "0",
|
|
76
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
77
|
+
spacing: 4,
|
|
75
78
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalNumberControl, {
|
|
76
|
-
|
|
79
|
+
__next40pxDefaultSize: true,
|
|
77
80
|
label: (0, _i18n.__)('Width'),
|
|
78
|
-
value:
|
|
81
|
+
value: editedWidth,
|
|
79
82
|
min: 1,
|
|
80
|
-
onChange: newWidth =>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
label: (0, _i18n.__)('
|
|
85
|
-
|
|
83
|
+
onChange: newWidth => {
|
|
84
|
+
setEditedWidth(newWidth);
|
|
85
|
+
}
|
|
86
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextareaControl, {
|
|
87
|
+
label: (0, _i18n.__)('Alternative text'),
|
|
88
|
+
__nextHasNoMarginBottom: true,
|
|
89
|
+
value: editedAlt,
|
|
90
|
+
onChange: newAlt => {
|
|
91
|
+
setEditedAlt(newAlt);
|
|
92
|
+
},
|
|
93
|
+
help: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
94
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ExternalLink, {
|
|
95
|
+
href:
|
|
96
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
97
|
+
(0, _i18n.__)('https://www.w3.org/WAI/tutorials/images/decision-tree/'),
|
|
98
|
+
children: (0, _i18n.__)('Describe the purpose of the image.')
|
|
99
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), (0, _i18n.__)('Leave empty if decorative.')]
|
|
100
|
+
})
|
|
101
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalHStack, {
|
|
102
|
+
justify: "right",
|
|
103
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
104
|
+
disabled: !hasChanged,
|
|
105
|
+
accessibleWhenDisabled: true,
|
|
106
|
+
variant: "primary",
|
|
107
|
+
type: "submit",
|
|
108
|
+
size: "compact",
|
|
109
|
+
children: (0, _i18n.__)('Apply')
|
|
110
|
+
})
|
|
86
111
|
})]
|
|
87
112
|
})
|
|
88
113
|
})
|
package/build/image/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_element","_richText","_blockEditor","_icons","_jsxRuntime","ALLOWED_MEDIA_TYPES","name","title","__","image","exports","keywords","object","tagName","className","attributes","style","url","alt","edit","Edit","InlineUI","value","onChange","activeObjectAttributes","contentRef","width","setWidth","useState","replace","popoverAnchor","useAnchor","editableContentElement","current","settings","jsx","Popover","placement","focusOnMount","anchor","children","onSubmit","event","newReplacements","replacements","slice","start","type","preventDefault","jsxs","__experimentalHStack","alignment","spacing","__experimentalNumberControl","label","min","newWidth","Button","icon","keyboardReturn","onFocus","isObjectActive","MediaUploadCheck","MediaUpload","allowedTypes","onSelect","id","imgWidth","insertObject","Math","render","open","RichTextToolbarButton","SVG","xmlns","viewBox","Path","d","onClick","isActive"],"sources":["@wordpress/format-library/src/image/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPath,\n\tSVG,\n\tPopover,\n\tButton,\n\t__experimentalNumberControl as NumberControl,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\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';\nimport { keyboardReturn } from '@wordpress/icons';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nconst name = 'core/image';\nconst title = __( 'Inline image' );\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 } = activeObjectAttributes;\n\tconst [ width, setWidth ] = useState( style?.replace( /\\D/g, '' ) );\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\tplacement=\"bottom\"\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: width ? `width: ${ width }px;` : '',\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<HStack alignment=\"bottom\" spacing=\"0\">\n\t\t\t\t\t<NumberControl\n\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__image-container-value\"\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tvalue={ width }\n\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\tonChange={ ( newWidth ) => setWidth( newWidth ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__image-container-button\"\n\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\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\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={ 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"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAQA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAAkD,IAAAM,WAAA,GAAAN,OAAA;AAnBlD;AACA;AACA;;AAmBA,MAAMO,mBAAmB,GAAG,CAAE,OAAO,CAAE;AAEvC,MAAMC,IAAI,GAAG,YAAY;AACzB,MAAMC,KAAK,GAAG,IAAAC,QAAE,EA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C4D,QAAQ,EAAGA,CAAE;QAAEC,EAAE;QAAEjD,GAAG;QAAEC,GAAG;QAAEQ,KAAK,EAAEyC;MAAS,CAAC,KAAM;QACnD5C,QAAQ,CACP,IAAA6C,sBAAY,EAAE9C,KAAK,EAAE;UACpByB,IAAI,EAAEzC,IAAI;UACVS,UAAU,EAAE;YACXD,SAAS,EAAG,YAAYoD,EAAI,EAAC;YAC7BlD,KAAK,EAAG,UAAUqD,IAAI,CAACd,GAAG,CACzBY,QAAQ,EACR,GACD,CAAG,KAAI;YACPlD,GAAG;YACHC;UACD;QACD,CAAE,CACH,CAAC;QACD0C,OAAO,CAAC,CAAC;MACV,CAAG;MACHU,MAAM,EAAGA,CAAE;QAAEC;MAAK,CAAC,kBAClB,IAAAnE,WAAA,CAAA+B,GAAA,EAACjC,YAAA,CAAAsE,qBAAqB;QACrBd,IAAI,eACH,IAAAtD,WAAA,CAAA+B,GAAA,EAACtC,WAAA,CAAA4E,GAAG;UACHC,KAAK,EAAC,4BAA4B;UAClCC,OAAO,EAAC,WAAW;UAAAnC,QAAA,eAEnB,IAAApC,WAAA,CAAA+B,GAAA,EAACtC,WAAA,CAAA+E,IAAI;YAACC,CAAC,EAAC;UAA4R,CAAE;QAAC,CACnS,CACL;QACDtE,KAAK,EAAGA,KAAO;QACfuE,OAAO,EAAGP,IAAM;QAChBQ,QAAQ,EAAGlB;MAAgB,CAC3B;IACC,CACH,CAAC,EACAA,cAAc,iBACf,IAAAzD,WAAA,CAAA+B,GAAA,EAACd,QAAQ;MACRC,KAAK,EAAGA,KAAO;MACfC,QAAQ,EAAGA,QAAU;MACrBC,sBAAsB,EAAGA,sBAAwB;MACjDC,UAAU,EAAGA;IAAY,CACzB,CACD;EAAA,CACgB,CAAC;AAErB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_element","_richText","_blockEditor","_jsxRuntime","ALLOWED_MEDIA_TYPES","name","title","__","image","exports","keywords","object","tagName","className","attributes","style","url","alt","edit","Edit","InlineUI","value","onChange","activeObjectAttributes","contentRef","width","replace","editedWidth","setEditedWidth","useState","editedAlt","setEditedAlt","hasChanged","popoverAnchor","useAnchor","editableContentElement","current","settings","jsx","Popover","placement","focusOnMount","anchor","children","onSubmit","event","newReplacements","replacements","slice","start","type","preventDefault","jsxs","__experimentalVStack","spacing","__experimentalNumberControl","__next40pxDefaultSize","label","min","newWidth","TextareaControl","__nextHasNoMarginBottom","newAlt","help","Fragment","ExternalLink","href","__experimentalHStack","justify","Button","disabled","accessibleWhenDisabled","variant","size","onFocus","isObjectActive","MediaUploadCheck","MediaUpload","allowedTypes","onSelect","id","imgWidth","insertObject","Math","render","open","RichTextToolbarButton","icon","SVG","xmlns","viewBox","Path","d","onClick","isActive"],"sources":["@wordpress/format-library/src/image/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPath,\n\tSVG,\n\tPopover,\n\tButton,\n\tExternalLink,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalNumberControl as NumberControl,\n\tTextareaControl,\n} from '@wordpress/components';\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\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\tplacement=\"bottom\"\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: width ? `width: ${ editedWidth }px;` : '',\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<VStack spacing={ 4 }>\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\t__nextHasNoMarginBottom\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<ExternalLink\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</ExternalLink>\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<HStack 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</HStack>\n\t\t\t\t</VStack>\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\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={ 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\t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EAAGA,sBAAwB;MACjDC,UAAU,EAAGA;IAAY,CACzB,CACD;EAAA,CACgB,CAAC;AAErB","ignoreList":[]}
|
package/build/language/index.js
CHANGED
|
@@ -76,7 +76,9 @@ function InlineLanguageUI({
|
|
|
76
76
|
className: "block-editor-format-toolbar__language-popover",
|
|
77
77
|
anchor: popoverAnchor,
|
|
78
78
|
onClose: onClose,
|
|
79
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
79
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
80
|
+
as: "form",
|
|
81
|
+
spacing: 4,
|
|
80
82
|
className: "block-editor-format-toolbar__language-container-content",
|
|
81
83
|
onSubmit: event => {
|
|
82
84
|
event.preventDefault();
|
|
@@ -90,11 +92,15 @@ function InlineLanguageUI({
|
|
|
90
92
|
onClose();
|
|
91
93
|
},
|
|
92
94
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextControl, {
|
|
95
|
+
__next40pxDefaultSize: true,
|
|
96
|
+
__nextHasNoMarginBottom: true,
|
|
93
97
|
label: title,
|
|
94
98
|
value: lang,
|
|
95
99
|
onChange: val => setLang(val),
|
|
96
100
|
help: (0, _i18n.__)('A valid language attribute, like "en" or "fr".')
|
|
97
101
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SelectControl, {
|
|
102
|
+
__next40pxDefaultSize: true,
|
|
103
|
+
__nextHasNoMarginBottom: true,
|
|
98
104
|
label: (0, _i18n.__)('Text direction'),
|
|
99
105
|
value: dir,
|
|
100
106
|
options: [{
|
|
@@ -108,6 +114,7 @@ function InlineLanguageUI({
|
|
|
108
114
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalHStack, {
|
|
109
115
|
alignment: "right",
|
|
110
116
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
117
|
+
__next40pxDefaultSize: true,
|
|
111
118
|
variant: "primary",
|
|
112
119
|
type: "submit",
|
|
113
120
|
text: (0, _i18n.__)('Apply')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_blockEditor","_components","_element","_richText","_icons","_jsxRuntime","name","title","__","language","exports","tagName","className","edit","Edit","isActive","value","onChange","contentRef","isPopoverVisible","setIsPopoverVisible","useState","togglePopover","state","jsxs","Fragment","children","jsx","RichTextToolbarButton","icon","languageIcon","label","onClick","removeFormat","role","InlineLanguageUI","onClose","popoverAnchor","useAnchor","editableContentElement","current","settings","lang","setLang","dir","setDir","Popover","anchor","onSubmit","event","preventDefault","applyFormat","type","attributes","TextControl","val","help","SelectControl","options","__experimentalHStack","alignment","Button","variant","text"],"sources":["@wordpress/format-library/src/language/index.js"],"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\t__experimentalHStack as HStack,\n} from '@wordpress/components';\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\ttagName: 'bdo',\n\tclassName: null,\n\tedit: Edit,\n\ttitle,\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<form\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\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<HStack alignment=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\ttext={ __( 'Apply' ) }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t</
|
|
1
|
+
{"version":3,"names":["_i18n","require","_blockEditor","_components","_element","_richText","_icons","_jsxRuntime","name","title","__","language","exports","tagName","className","edit","Edit","isActive","value","onChange","contentRef","isPopoverVisible","setIsPopoverVisible","useState","togglePopover","state","jsxs","Fragment","children","jsx","RichTextToolbarButton","icon","languageIcon","label","onClick","removeFormat","role","InlineLanguageUI","onClose","popoverAnchor","useAnchor","editableContentElement","current","settings","lang","setLang","dir","setDir","Popover","anchor","__experimentalVStack","as","spacing","onSubmit","event","preventDefault","applyFormat","type","attributes","TextControl","__next40pxDefaultSize","__nextHasNoMarginBottom","val","help","SelectControl","options","__experimentalHStack","alignment","Button","variant","text"],"sources":["@wordpress/format-library/src/language/index.js"],"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\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\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\ttagName: 'bdo',\n\tclassName: null,\n\tedit: Edit,\n\ttitle,\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<VStack\n\t\t\t\tas=\"form\"\n\t\t\t\tspacing={ 4 }\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\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\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\t__nextHasNoMarginBottom\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<HStack alignment=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\ttext={ __( 'Apply' ) }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</Popover>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,YAAA,GAAA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wD,WAAW;QACXC,qBAAqB;QACrBC,uBAAuB;QACvB5B,KAAK,EAAGxB,KAAO;QACfS,KAAK,EAAG0B,IAAM;QACdzB,QAAQ,EAAK2C,GAAG,IAAMjB,OAAO,CAAEiB,GAAI,CAAG;QACtCC,IAAI,EAAG,IAAArD,QAAE,EACR,gDACD;MAAG,CACH,CAAC,eACF,IAAAH,WAAA,CAAAsB,GAAA,EAAC1B,WAAA,CAAA6D,aAAa;QACbJ,qBAAqB;QACrBC,uBAAuB;QACvB5B,KAAK,EAAG,IAAAvB,QAAE,EAAE,gBAAiB,CAAG;QAChCQ,KAAK,EAAG4B,GAAK;QACbmB,OAAO,EAAG,CACT;UACChC,KAAK,EAAE,IAAAvB,QAAE,EAAE,eAAgB,CAAC;UAC5BQ,KAAK,EAAE;QACR,CAAC,EACD;UACCe,KAAK,EAAE,IAAAvB,QAAE,EAAE,eAAgB,CAAC;UAC5BQ,KAAK,EAAE;QACR,CAAC,CACC;QACHC,QAAQ,EAAK2C,GAAG,IAAMf,MAAM,CAAEe,GAAI;MAAG,CACrC,CAAC,eACF,IAAAvD,WAAA,CAAAsB,GAAA,EAAC1B,WAAA,CAAA+D,oBAAM;QAACC,SAAS,EAAC,OAAO;QAAAvC,QAAA,eACxB,IAAArB,WAAA,CAAAsB,GAAA,EAAC1B,WAAA,CAAAiE,MAAM;UACNR,qBAAqB;UACrBS,OAAO,EAAC,SAAS;UACjBZ,IAAI,EAAC,QAAQ;UACba,IAAI,EAAG,IAAA5D,QAAE,EAAE,OAAQ;QAAG,CACtB;MAAC,CACK,CAAC;IAAA,CACF;EAAC,CACD,CAAC;AAEZ","ignoreList":[]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { Path, SVG, Popover, Button,
|
|
4
|
+
import { Path, SVG, Popover, Button, ExternalLink, __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalNumberControl as NumberControl, TextareaControl } from '@wordpress/components';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { useState } from '@wordpress/element';
|
|
7
7
|
import { insertObject, useAnchor } from '@wordpress/rich-text';
|
|
8
8
|
import { MediaUpload, RichTextToolbarButton, MediaUploadCheck } from '@wordpress/block-editor';
|
|
9
|
-
import { keyboardReturn } from '@wordpress/icons';
|
|
10
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
const ALLOWED_MEDIA_TYPES = ['image'];
|
|
13
13
|
const name = 'core/image';
|
|
@@ -34,9 +34,13 @@ function InlineUI({
|
|
|
34
34
|
contentRef
|
|
35
35
|
}) {
|
|
36
36
|
const {
|
|
37
|
-
style
|
|
37
|
+
style,
|
|
38
|
+
alt
|
|
38
39
|
} = activeObjectAttributes;
|
|
39
|
-
const
|
|
40
|
+
const width = style?.replace(/\D/g, '');
|
|
41
|
+
const [editedWidth, setEditedWidth] = useState(width);
|
|
42
|
+
const [editedAlt, setEditedAlt] = useState(alt);
|
|
43
|
+
const hasChanged = editedWidth !== width || editedAlt !== alt;
|
|
40
44
|
const popoverAnchor = useAnchor({
|
|
41
45
|
editableContentElement: contentRef.current,
|
|
42
46
|
settings: image
|
|
@@ -54,7 +58,8 @@ function InlineUI({
|
|
|
54
58
|
type: name,
|
|
55
59
|
attributes: {
|
|
56
60
|
...activeObjectAttributes,
|
|
57
|
-
style: width ? `width: ${
|
|
61
|
+
style: width ? `width: ${editedWidth}px;` : '',
|
|
62
|
+
alt: editedAlt
|
|
58
63
|
}
|
|
59
64
|
};
|
|
60
65
|
onChange({
|
|
@@ -63,20 +68,41 @@ function InlineUI({
|
|
|
63
68
|
});
|
|
64
69
|
event.preventDefault();
|
|
65
70
|
},
|
|
66
|
-
children: /*#__PURE__*/_jsxs(
|
|
67
|
-
|
|
68
|
-
spacing: "0",
|
|
71
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
72
|
+
spacing: 4,
|
|
69
73
|
children: [/*#__PURE__*/_jsx(NumberControl, {
|
|
70
|
-
|
|
74
|
+
__next40pxDefaultSize: true,
|
|
71
75
|
label: __('Width'),
|
|
72
|
-
value:
|
|
76
|
+
value: editedWidth,
|
|
73
77
|
min: 1,
|
|
74
|
-
onChange: newWidth =>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
label: __('
|
|
79
|
-
|
|
78
|
+
onChange: newWidth => {
|
|
79
|
+
setEditedWidth(newWidth);
|
|
80
|
+
}
|
|
81
|
+
}), /*#__PURE__*/_jsx(TextareaControl, {
|
|
82
|
+
label: __('Alternative text'),
|
|
83
|
+
__nextHasNoMarginBottom: true,
|
|
84
|
+
value: editedAlt,
|
|
85
|
+
onChange: newAlt => {
|
|
86
|
+
setEditedAlt(newAlt);
|
|
87
|
+
},
|
|
88
|
+
help: /*#__PURE__*/_jsxs(_Fragment, {
|
|
89
|
+
children: [/*#__PURE__*/_jsx(ExternalLink, {
|
|
90
|
+
href:
|
|
91
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
92
|
+
__('https://www.w3.org/WAI/tutorials/images/decision-tree/'),
|
|
93
|
+
children: __('Describe the purpose of the image.')
|
|
94
|
+
}), /*#__PURE__*/_jsx("br", {}), __('Leave empty if decorative.')]
|
|
95
|
+
})
|
|
96
|
+
}), /*#__PURE__*/_jsx(HStack, {
|
|
97
|
+
justify: "right",
|
|
98
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
99
|
+
disabled: !hasChanged,
|
|
100
|
+
accessibleWhenDisabled: true,
|
|
101
|
+
variant: "primary",
|
|
102
|
+
type: "submit",
|
|
103
|
+
size: "compact",
|
|
104
|
+
children: __('Apply')
|
|
105
|
+
})
|
|
80
106
|
})]
|
|
81
107
|
})
|
|
82
108
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Path","SVG","Popover","Button","__experimentalNumberControl","NumberControl","__experimentalHStack","HStack","__","useState","insertObject","useAnchor","MediaUpload","RichTextToolbarButton","MediaUploadCheck","keyboardReturn","jsx","_jsx","jsxs","_jsxs","ALLOWED_MEDIA_TYPES","name","title","image","keywords","object","tagName","className","attributes","style","url","alt","edit","Edit","InlineUI","value","onChange","activeObjectAttributes","contentRef","width","setWidth","replace","popoverAnchor","editableContentElement","current","settings","placement","focusOnMount","anchor","children","onSubmit","event","newReplacements","replacements","slice","start","type","preventDefault","alignment","spacing","label","min","newWidth","icon","onFocus","isObjectActive","allowedTypes","onSelect","id","imgWidth","Math","render","open","xmlns","viewBox","d","onClick","isActive"],"sources":["@wordpress/format-library/src/image/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPath,\n\tSVG,\n\tPopover,\n\tButton,\n\t__experimentalNumberControl as NumberControl,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\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';\nimport { keyboardReturn } from '@wordpress/icons';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nconst name = 'core/image';\nconst title = __( 'Inline image' );\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 } = activeObjectAttributes;\n\tconst [ width, setWidth ] = useState( style?.replace( /\\D/g, '' ) );\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\tplacement=\"bottom\"\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: width ? `width: ${ width }px;` : '',\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<HStack alignment=\"bottom\" spacing=\"0\">\n\t\t\t\t\t<NumberControl\n\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__image-container-value\"\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tvalue={ width }\n\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\tonChange={ ( newWidth ) => setWidth( newWidth ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__image-container-button\"\n\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\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\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={ 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"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,GAAG,EACHC,OAAO,EACPC,MAAM,EACNC,2BAA2B,IAAIC,aAAa,EAC5CC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,YAAY,EAAEC,SAAS,QAAQ,sBAAsB;AAC9D,SACCC,WAAW,EACXC,qBAAqB,EACrBC,gBAAgB,QACV,yBAAyB;AAChC,SAASC,cAAc,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAElD,MAAMC,mBAAmB,GAAG,CAAE,OAAO,CAAE;AAEvC,MAAMC,IAAI,GAAG,YAAY;AACzB,MAAMC,KAAK,GAAGd,EAAE,CAAE,cAAe,CAAC;AAElC,OAAO,MAAMe,KAAK,GAAG;EACpBF,IAAI;EACJC,KAAK;EACLE,QAAQ,EAAE,CAAEhB,EAAE,CAAE,OAAQ,CAAC,EAAEA,EAAE,CAAE,OAAQ,CAAC,CAAE;EAC1CiB,MAAM,EAAE,IAAI;EACZC,OAAO,EAAE,KAAK;EACdC,SAAS,EAAE,IAAI;EACfC,UAAU,EAAE;IACXD,SAAS,EAAE,OAAO;IAClBE,KAAK,EAAE,OAAO;IACdC,GAAG,EAAE,KAAK;IACVC,GAAG,EAAE;EACN,CAAC;EACDC,IAAI,EAAEC;AACP,CAAC;AAED,SAASC,QAAQA,CAAE;EAAEC,KAAK;EAAEC,QAAQ;EAAEC,sBAAsB;EAAEC;AAAW,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B,CAC3B;IACC,CACH,CAAC,EACAA,cAAc,iBACfhD,IAAA,CAACiB,QAAQ;MACRC,KAAK,EAAGA,KAAO;MACfC,QAAQ,EAAGA,QAAU;MACrBC,sBAAsB,EAAGA,sBAAwB;MACjDC,UAAU,EAAGA;IAAY,CACzB,CACD;EAAA,CACgB,CAAC;AAErB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Path","SVG","Popover","Button","ExternalLink","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalNumberControl","NumberControl","TextareaControl","__","useState","insertObject","useAnchor","MediaUpload","RichTextToolbarButton","MediaUploadCheck","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ALLOWED_MEDIA_TYPES","name","title","image","keywords","object","tagName","className","attributes","style","url","alt","edit","Edit","InlineUI","value","onChange","activeObjectAttributes","contentRef","width","replace","editedWidth","setEditedWidth","editedAlt","setEditedAlt","hasChanged","popoverAnchor","editableContentElement","current","settings","placement","focusOnMount","anchor","children","onSubmit","event","newReplacements","replacements","slice","start","type","preventDefault","spacing","__next40pxDefaultSize","label","min","newWidth","__nextHasNoMarginBottom","newAlt","help","href","justify","disabled","accessibleWhenDisabled","variant","size","onFocus","isObjectActive","allowedTypes","onSelect","id","imgWidth","Math","render","open","icon","xmlns","viewBox","d","onClick","isActive"],"sources":["@wordpress/format-library/src/image/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPath,\n\tSVG,\n\tPopover,\n\tButton,\n\tExternalLink,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalNumberControl as NumberControl,\n\tTextareaControl,\n} from '@wordpress/components';\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\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\tplacement=\"bottom\"\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: width ? `width: ${ editedWidth }px;` : '',\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<VStack spacing={ 4 }>\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\t__nextHasNoMarginBottom\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<ExternalLink\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</ExternalLink>\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<HStack 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</HStack>\n\t\t\t\t</VStack>\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\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={ 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"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,GAAG,EACHC,OAAO,EACPC,MAAM,EACNC,YAAY,EACZC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,2BAA2B,IAAIC,aAAa,EAC5CC,eAAe,QACT,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,YAAY,EAAEC,SAAS,QAAQ,sBAAsB;AAC9D,SACCC,WAAW,EACXC,qBAAqB,EACrBC,gBAAgB,QACV,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEjC,MAAMC,mBAAmB,GAAG,CAAE,OAAO,CAAE;AAEvC,MAAMC,IAAI,GAAG,YAAY;AACzB,MAAMC,KAAK,GAAGf,EAAE,CAAE,cAAe,CAAC;AAElC,OAAO,MAAMgB,KAAK,GAAG;EACpBF,IAAI;EACJC,KAAK;EACLE,QAAQ,EAAE,CAAEjB,EAAE,CAAE,OAAQ,CAAC,EAAEA,EAAE,CAAE,OAAQ,CAAC,CAAE;EAC1C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,sBAAwB;MACjDC,UAAU,EAAGA;IAAY,CACzB,CACD;EAAA,CACgB,CAAC;AAErB","ignoreList":[]}
|
|
@@ -7,7 +7,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { RichTextToolbarButton } from '@wordpress/block-editor';
|
|
10
|
-
import { TextControl, SelectControl, Button, Popover, __experimentalHStack as HStack } from '@wordpress/components';
|
|
10
|
+
import { TextControl, SelectControl, Button, Popover, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
|
|
11
11
|
import { useState } from '@wordpress/element';
|
|
12
12
|
import { applyFormat, removeFormat, useAnchor } from '@wordpress/rich-text';
|
|
13
13
|
import { language as languageIcon } from '@wordpress/icons';
|
|
@@ -71,7 +71,9 @@ function InlineLanguageUI({
|
|
|
71
71
|
className: "block-editor-format-toolbar__language-popover",
|
|
72
72
|
anchor: popoverAnchor,
|
|
73
73
|
onClose: onClose,
|
|
74
|
-
children: /*#__PURE__*/_jsxs(
|
|
74
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
75
|
+
as: "form",
|
|
76
|
+
spacing: 4,
|
|
75
77
|
className: "block-editor-format-toolbar__language-container-content",
|
|
76
78
|
onSubmit: event => {
|
|
77
79
|
event.preventDefault();
|
|
@@ -85,11 +87,15 @@ function InlineLanguageUI({
|
|
|
85
87
|
onClose();
|
|
86
88
|
},
|
|
87
89
|
children: [/*#__PURE__*/_jsx(TextControl, {
|
|
90
|
+
__next40pxDefaultSize: true,
|
|
91
|
+
__nextHasNoMarginBottom: true,
|
|
88
92
|
label: title,
|
|
89
93
|
value: lang,
|
|
90
94
|
onChange: val => setLang(val),
|
|
91
95
|
help: __('A valid language attribute, like "en" or "fr".')
|
|
92
96
|
}), /*#__PURE__*/_jsx(SelectControl, {
|
|
97
|
+
__next40pxDefaultSize: true,
|
|
98
|
+
__nextHasNoMarginBottom: true,
|
|
93
99
|
label: __('Text direction'),
|
|
94
100
|
value: dir,
|
|
95
101
|
options: [{
|
|
@@ -103,6 +109,7 @@ function InlineLanguageUI({
|
|
|
103
109
|
}), /*#__PURE__*/_jsx(HStack, {
|
|
104
110
|
alignment: "right",
|
|
105
111
|
children: /*#__PURE__*/_jsx(Button, {
|
|
112
|
+
__next40pxDefaultSize: true,
|
|
106
113
|
variant: "primary",
|
|
107
114
|
type: "submit",
|
|
108
115
|
text: __('Apply')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","RichTextToolbarButton","TextControl","SelectControl","Button","Popover","__experimentalHStack","HStack","useState","applyFormat","removeFormat","useAnchor","language","languageIcon","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","name","title","tagName","className","edit","Edit","isActive","value","onChange","contentRef","isPopoverVisible","setIsPopoverVisible","togglePopover","state","children","icon","label","onClick","role","InlineLanguageUI","onClose","popoverAnchor","editableContentElement","current","settings","lang","setLang","dir","setDir","anchor","onSubmit","event","preventDefault","type","attributes","val","help","options","alignment","variant","text"],"sources":["@wordpress/format-library/src/language/index.js"],"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\t__experimentalHStack as HStack,\n} from '@wordpress/components';\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\ttagName: 'bdo',\n\tclassName: null,\n\tedit: Edit,\n\ttitle,\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<form\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\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<HStack alignment=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\ttext={ __( 'Apply' ) }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t</
|
|
1
|
+
{"version":3,"names":["__","RichTextToolbarButton","TextControl","SelectControl","Button","Popover","__experimentalHStack","HStack","__experimentalVStack","VStack","useState","applyFormat","removeFormat","useAnchor","language","languageIcon","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","name","title","tagName","className","edit","Edit","isActive","value","onChange","contentRef","isPopoverVisible","setIsPopoverVisible","togglePopover","state","children","icon","label","onClick","role","InlineLanguageUI","onClose","popoverAnchor","editableContentElement","current","settings","lang","setLang","dir","setDir","anchor","as","spacing","onSubmit","event","preventDefault","type","attributes","__next40pxDefaultSize","__nextHasNoMarginBottom","val","help","options","alignment","variant","text"],"sources":["@wordpress/format-library/src/language/index.js"],"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\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\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\ttagName: 'bdo',\n\tclassName: null,\n\tedit: Edit,\n\ttitle,\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<VStack\n\t\t\t\tas=\"form\"\n\t\t\t\tspacing={ 4 }\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\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\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\t__nextHasNoMarginBottom\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<HStack alignment=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit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AAU,EAAE;YACXX,IAAI;YACJE;UACD;QACD,CAAE,CACH,CAAC;QACDP,OAAO,CAAC,CAAC;MACV,CAAG;MAAAN,QAAA,gBAEHnB,IAAA,CAACf,WAAW;QACXyD,qBAAqB;QACrBC,uBAAuB;QACvBtB,KAAK,EAAGf,KAAO;QACfM,KAAK,EAAGkB,IAAM;QACdjB,QAAQ,EAAK+B,GAAG,IAAMb,OAAO,CAAEa,GAAI,CAAG;QACtCC,IAAI,EAAG9D,EAAE,CACR,gDACD;MAAG,CACH,CAAC,eACFiB,IAAA,CAACd,aAAa;QACbwD,qBAAqB;QACrBC,uBAAuB;QACvBtB,KAAK,EAAGtC,EAAE,CAAE,gBAAiB,CAAG;QAChC6B,KAAK,EAAGoB,GAAK;QACbc,OAAO,EAAG,CACT;UACCzB,KAAK,EAAEtC,EAAE,CAAE,eAAgB,CAAC;UAC5B6B,KAAK,EAAE;QACR,CAAC,EACD;UACCS,KAAK,EAAEtC,EAAE,CAAE,eAAgB,CAAC;UAC5B6B,KAAK,EAAE;QACR,CAAC,CACC;QACHC,QAAQ,EAAK+B,GAAG,IAAMX,MAAM,CAAEW,GAAI;MAAG,CACrC,CAAC,eACF5C,IAAA,CAACV,MAAM;QAACyD,SAAS,EAAC,OAAO;QAAA5B,QAAA,eACxBnB,IAAA,CAACb,MAAM;UACNuD,qBAAqB;UACrBM,OAAO,EAAC,SAAS;UACjBR,IAAI,EAAC,QAAQ;UACbS,IAAI,EAAGlE,EAAE,CAAE,OAAQ;QAAG,CACtB;MAAC,CACK,CAAC;IAAA,CACF;EAAC,CACD,CAAC;AAEZ","ignoreList":[]}
|
|
@@ -33,6 +33,9 @@
|
|
|
33
33
|
* Grid System.
|
|
34
34
|
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
35
35
|
*/
|
|
36
|
+
/**
|
|
37
|
+
* Radius scale.
|
|
38
|
+
*/
|
|
36
39
|
/**
|
|
37
40
|
* Dimensions.
|
|
38
41
|
*/
|
|
@@ -107,15 +110,9 @@
|
|
|
107
110
|
.block-editor-format-toolbar__image-popover {
|
|
108
111
|
z-index: 159990;
|
|
109
112
|
}
|
|
110
|
-
.block-editor-format-toolbar__image-popover .block-editor-format-toolbar__image-container-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
max-width: 500px;
|
|
114
|
-
}
|
|
115
|
-
.block-editor-format-toolbar__image-popover .block-editor-format-toolbar__image-container-button {
|
|
116
|
-
height: 30px;
|
|
117
|
-
margin-bottom: 8px;
|
|
118
|
-
margin-left: 8px;
|
|
113
|
+
.block-editor-format-toolbar__image-popover .block-editor-format-toolbar__image-container-content {
|
|
114
|
+
width: 260px;
|
|
115
|
+
padding: 16px;
|
|
119
116
|
}
|
|
120
117
|
|
|
121
118
|
.block-editor-format-toolbar__link-container-content {
|
package/build-style/style.css
CHANGED
|
@@ -33,6 +33,9 @@
|
|
|
33
33
|
* Grid System.
|
|
34
34
|
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
35
35
|
*/
|
|
36
|
+
/**
|
|
37
|
+
* Radius scale.
|
|
38
|
+
*/
|
|
36
39
|
/**
|
|
37
40
|
* Dimensions.
|
|
38
41
|
*/
|
|
@@ -107,15 +110,9 @@
|
|
|
107
110
|
.block-editor-format-toolbar__image-popover {
|
|
108
111
|
z-index: 159990;
|
|
109
112
|
}
|
|
110
|
-
.block-editor-format-toolbar__image-popover .block-editor-format-toolbar__image-container-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
max-width: 500px;
|
|
114
|
-
}
|
|
115
|
-
.block-editor-format-toolbar__image-popover .block-editor-format-toolbar__image-container-button {
|
|
116
|
-
height: 30px;
|
|
117
|
-
margin-bottom: 8px;
|
|
118
|
-
margin-right: 8px;
|
|
113
|
+
.block-editor-format-toolbar__image-popover .block-editor-format-toolbar__image-container-content {
|
|
114
|
+
width: 260px;
|
|
115
|
+
padding: 16px;
|
|
119
116
|
}
|
|
120
117
|
|
|
121
118
|
.block-editor-format-toolbar__link-container-content {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/format-library",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Format library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/a11y": "^4.
|
|
31
|
-
"@wordpress/block-editor": "^
|
|
32
|
-
"@wordpress/components": "^28.
|
|
33
|
-
"@wordpress/compose": "^7.
|
|
34
|
-
"@wordpress/data": "^10.
|
|
35
|
-
"@wordpress/element": "^6.
|
|
36
|
-
"@wordpress/html-entities": "^4.
|
|
37
|
-
"@wordpress/i18n": "^5.
|
|
38
|
-
"@wordpress/icons": "^10.
|
|
39
|
-
"@wordpress/private-apis": "^1.
|
|
40
|
-
"@wordpress/rich-text": "^7.
|
|
41
|
-
"@wordpress/url": "^4.
|
|
30
|
+
"@wordpress/a11y": "^4.5.0",
|
|
31
|
+
"@wordpress/block-editor": "^14.0.0",
|
|
32
|
+
"@wordpress/components": "^28.5.0",
|
|
33
|
+
"@wordpress/compose": "^7.5.0",
|
|
34
|
+
"@wordpress/data": "^10.5.0",
|
|
35
|
+
"@wordpress/element": "^6.5.0",
|
|
36
|
+
"@wordpress/html-entities": "^4.5.0",
|
|
37
|
+
"@wordpress/i18n": "^5.5.0",
|
|
38
|
+
"@wordpress/icons": "^10.5.0",
|
|
39
|
+
"@wordpress/private-apis": "^1.5.0",
|
|
40
|
+
"@wordpress/rich-text": "^7.5.0",
|
|
41
|
+
"@wordpress/url": "^4.5.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": "^18.0.0",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "c3101ab024e2bfc85d525c6d247e0d57cafc9fd9"
|
|
51
51
|
}
|
package/src/image/index.js
CHANGED
|
@@ -6,8 +6,11 @@ import {
|
|
|
6
6
|
SVG,
|
|
7
7
|
Popover,
|
|
8
8
|
Button,
|
|
9
|
-
|
|
9
|
+
ExternalLink,
|
|
10
10
|
__experimentalHStack as HStack,
|
|
11
|
+
__experimentalVStack as VStack,
|
|
12
|
+
__experimentalNumberControl as NumberControl,
|
|
13
|
+
TextareaControl,
|
|
11
14
|
} from '@wordpress/components';
|
|
12
15
|
import { __ } from '@wordpress/i18n';
|
|
13
16
|
import { useState } from '@wordpress/element';
|
|
@@ -17,7 +20,6 @@ import {
|
|
|
17
20
|
RichTextToolbarButton,
|
|
18
21
|
MediaUploadCheck,
|
|
19
22
|
} from '@wordpress/block-editor';
|
|
20
|
-
import { keyboardReturn } from '@wordpress/icons';
|
|
21
23
|
|
|
22
24
|
const ALLOWED_MEDIA_TYPES = [ 'image' ];
|
|
23
25
|
|
|
@@ -41,8 +43,11 @@ export const image = {
|
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
function InlineUI( { value, onChange, activeObjectAttributes, contentRef } ) {
|
|
44
|
-
const { style } = activeObjectAttributes;
|
|
45
|
-
const
|
|
46
|
+
const { style, alt } = activeObjectAttributes;
|
|
47
|
+
const width = style?.replace( /\D/g, '' );
|
|
48
|
+
const [ editedWidth, setEditedWidth ] = useState( width );
|
|
49
|
+
const [ editedAlt, setEditedAlt ] = useState( alt );
|
|
50
|
+
const hasChanged = editedWidth !== width || editedAlt !== alt;
|
|
46
51
|
const popoverAnchor = useAnchor( {
|
|
47
52
|
editableContentElement: contentRef.current,
|
|
48
53
|
settings: image,
|
|
@@ -64,7 +69,8 @@ function InlineUI( { value, onChange, activeObjectAttributes, contentRef } ) {
|
|
|
64
69
|
type: name,
|
|
65
70
|
attributes: {
|
|
66
71
|
...activeObjectAttributes,
|
|
67
|
-
style: width ? `width: ${
|
|
72
|
+
style: width ? `width: ${ editedWidth }px;` : '',
|
|
73
|
+
alt: editedAlt,
|
|
68
74
|
},
|
|
69
75
|
};
|
|
70
76
|
|
|
@@ -76,21 +82,54 @@ function InlineUI( { value, onChange, activeObjectAttributes, contentRef } ) {
|
|
|
76
82
|
event.preventDefault();
|
|
77
83
|
} }
|
|
78
84
|
>
|
|
79
|
-
<
|
|
85
|
+
<VStack spacing={ 4 }>
|
|
80
86
|
<NumberControl
|
|
81
|
-
|
|
87
|
+
__next40pxDefaultSize
|
|
82
88
|
label={ __( 'Width' ) }
|
|
83
|
-
value={
|
|
89
|
+
value={ editedWidth }
|
|
84
90
|
min={ 1 }
|
|
85
|
-
onChange={ ( newWidth ) =>
|
|
91
|
+
onChange={ ( newWidth ) => {
|
|
92
|
+
setEditedWidth( newWidth );
|
|
93
|
+
} }
|
|
86
94
|
/>
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
<TextareaControl
|
|
96
|
+
label={ __( 'Alternative text' ) }
|
|
97
|
+
__nextHasNoMarginBottom
|
|
98
|
+
value={ editedAlt }
|
|
99
|
+
onChange={ ( newAlt ) => {
|
|
100
|
+
setEditedAlt( newAlt );
|
|
101
|
+
} }
|
|
102
|
+
help={
|
|
103
|
+
<>
|
|
104
|
+
<ExternalLink
|
|
105
|
+
href={
|
|
106
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
107
|
+
__(
|
|
108
|
+
'https://www.w3.org/WAI/tutorials/images/decision-tree/'
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
>
|
|
112
|
+
{ __(
|
|
113
|
+
'Describe the purpose of the image.'
|
|
114
|
+
) }
|
|
115
|
+
</ExternalLink>
|
|
116
|
+
<br />
|
|
117
|
+
{ __( 'Leave empty if decorative.' ) }
|
|
118
|
+
</>
|
|
119
|
+
}
|
|
92
120
|
/>
|
|
93
|
-
|
|
121
|
+
<HStack justify="right">
|
|
122
|
+
<Button
|
|
123
|
+
disabled={ ! hasChanged }
|
|
124
|
+
accessibleWhenDisabled
|
|
125
|
+
variant="primary"
|
|
126
|
+
type="submit"
|
|
127
|
+
size="compact"
|
|
128
|
+
>
|
|
129
|
+
{ __( 'Apply' ) }
|
|
130
|
+
</Button>
|
|
131
|
+
</HStack>
|
|
132
|
+
</VStack>
|
|
94
133
|
</form>
|
|
95
134
|
</Popover>
|
|
96
135
|
);
|
package/src/image/style.scss
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
.block-editor-format-toolbar__image-popover {
|
|
2
2
|
z-index: z-index(".block-editor-format-toolbar__image-popover");
|
|
3
3
|
|
|
4
|
-
.block-editor-format-toolbar__image-container-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
max-width: 500px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.block-editor-format-toolbar__image-container-button {
|
|
11
|
-
height: $grid-unit-10 * 4 - ($border-width * 2);
|
|
12
|
-
margin-bottom: $grid-unit-10;
|
|
13
|
-
margin-right: $grid-unit-10;
|
|
4
|
+
.block-editor-format-toolbar__image-container-content {
|
|
5
|
+
width: 260px;
|
|
6
|
+
padding: $grid-unit-20;
|
|
14
7
|
}
|
|
15
8
|
}
|
package/src/language/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
Button,
|
|
14
14
|
Popover,
|
|
15
15
|
__experimentalHStack as HStack,
|
|
16
|
+
__experimentalVStack as VStack,
|
|
16
17
|
} from '@wordpress/components';
|
|
17
18
|
import { useState } from '@wordpress/element';
|
|
18
19
|
import { applyFormat, removeFormat, useAnchor } from '@wordpress/rich-text';
|
|
@@ -78,7 +79,9 @@ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) {
|
|
|
78
79
|
anchor={ popoverAnchor }
|
|
79
80
|
onClose={ onClose }
|
|
80
81
|
>
|
|
81
|
-
<
|
|
82
|
+
<VStack
|
|
83
|
+
as="form"
|
|
84
|
+
spacing={ 4 }
|
|
82
85
|
className="block-editor-format-toolbar__language-container-content"
|
|
83
86
|
onSubmit={ ( event ) => {
|
|
84
87
|
event.preventDefault();
|
|
@@ -95,6 +98,8 @@ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) {
|
|
|
95
98
|
} }
|
|
96
99
|
>
|
|
97
100
|
<TextControl
|
|
101
|
+
__next40pxDefaultSize
|
|
102
|
+
__nextHasNoMarginBottom
|
|
98
103
|
label={ title }
|
|
99
104
|
value={ lang }
|
|
100
105
|
onChange={ ( val ) => setLang( val ) }
|
|
@@ -103,6 +108,8 @@ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) {
|
|
|
103
108
|
) }
|
|
104
109
|
/>
|
|
105
110
|
<SelectControl
|
|
111
|
+
__next40pxDefaultSize
|
|
112
|
+
__nextHasNoMarginBottom
|
|
106
113
|
label={ __( 'Text direction' ) }
|
|
107
114
|
value={ dir }
|
|
108
115
|
options={ [
|
|
@@ -119,12 +126,13 @@ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) {
|
|
|
119
126
|
/>
|
|
120
127
|
<HStack alignment="right">
|
|
121
128
|
<Button
|
|
129
|
+
__next40pxDefaultSize
|
|
122
130
|
variant="primary"
|
|
123
131
|
type="submit"
|
|
124
132
|
text={ __( 'Apply' ) }
|
|
125
133
|
/>
|
|
126
134
|
</HStack>
|
|
127
|
-
</
|
|
135
|
+
</VStack>
|
|
128
136
|
</Popover>
|
|
129
137
|
);
|
|
130
138
|
}
|