@wordpress/media-fields 0.15.0 → 0.16.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 +6 -0
- package/build/alt_text/index.cjs +18 -0
- package/build/alt_text/index.cjs.map +2 -2
- package/build/attached_to/edit.cjs +0 -1
- package/build/attached_to/edit.cjs.map +2 -2
- package/build-module/alt_text/index.mjs +19 -1
- package/build-module/alt_text/index.mjs.map +2 -2
- package/build-module/attached_to/edit.mjs +0 -1
- package/build-module/attached_to/edit.mjs.map +2 -2
- package/build-style/style-rtl.css +8 -2
- package/build-style/style.css +8 -2
- package/build-types/alt_text/index.d.ts.map +1 -1
- package/build-types/attached_to/edit.d.ts +1 -1
- package/build-types/attached_to/edit.d.ts.map +1 -1
- package/build-types/attached_to/view.d.ts +1 -1
- package/build-types/attached_to/view.d.ts.map +1 -1
- package/build-types/author/view.d.ts +1 -1
- package/build-types/author/view.d.ts.map +1 -1
- package/build-types/filename/view.d.ts +1 -1
- package/build-types/filename/view.d.ts.map +1 -1
- package/build-types/media_thumbnail/view.d.ts +1 -1
- package/build-types/media_thumbnail/view.d.ts.map +1 -1
- package/build-types/stories/index.story.d.ts +4 -3
- package/build-types/stories/index.story.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/alt_text/index.tsx +18 -0
- package/src/attached_to/edit.tsx +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.16.0 (2026-07-14)
|
|
6
|
+
|
|
7
|
+
### Enhancements
|
|
8
|
+
|
|
9
|
+
- Widen React peer dependency ranges to `^18 || ^19` to support both React 18 and React 19 environments ([#80024](https://github.com/WordPress/gutenberg/pull/80024)).
|
|
10
|
+
|
|
5
11
|
## 0.15.0 (2026-07-01)
|
|
6
12
|
|
|
7
13
|
## 0.14.0 (2026-06-24)
|
package/build/alt_text/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ __export(alt_text_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(alt_text_exports);
|
|
26
26
|
var import_i18n = require("@wordpress/i18n");
|
|
27
27
|
var import_components = require("@wordpress/components");
|
|
28
|
+
var import_ui = require("@wordpress/ui");
|
|
28
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
30
|
var altTextField = {
|
|
30
31
|
id: "alt_text",
|
|
@@ -39,6 +40,23 @@ var altTextField = {
|
|
|
39
40
|
label: field.label,
|
|
40
41
|
value: data.alt_text || "",
|
|
41
42
|
onChange: (value) => onChange({ alt_text: value }),
|
|
43
|
+
help: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
44
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
45
|
+
import_ui.Link,
|
|
46
|
+
{
|
|
47
|
+
href: (
|
|
48
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
49
|
+
(0, import_i18n.__)(
|
|
50
|
+
"https://www.w3.org/WAI/tutorials/images/decision-tree/"
|
|
51
|
+
)
|
|
52
|
+
),
|
|
53
|
+
openInNewTab: true,
|
|
54
|
+
children: (0, import_i18n.__)("Describe the purpose of the image.")
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
58
|
+
(0, import_i18n.__)("Leave empty if decorative.")
|
|
59
|
+
] }),
|
|
42
60
|
rows: 2
|
|
43
61
|
}
|
|
44
62
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/alt_text/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextareaControl } from '@wordpress/components';\nimport type { Field } from '@wordpress/dataviews';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\n\nconst altTextField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'alt_text',\n\ttype: 'text',\n\tlabel: __( 'Alt text' ),\n\tisVisible: ( item ) => item?.media_type === 'image',\n\trender: ( { item } ) => item?.alt_text || '-',\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<TextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ data.alt_text || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { alt_text: value } ) }\n\t\t\t\trows={ 2 }\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default altTextField;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,wBAAgC;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextareaControl } from '@wordpress/components';\nimport { Link } from '@wordpress/ui';\nimport type { Field } from '@wordpress/dataviews';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\n\nconst altTextField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'alt_text',\n\ttype: 'text',\n\tlabel: __( 'Alt text' ),\n\tisVisible: ( item ) => item?.media_type === 'image',\n\trender: ( { item } ) => item?.alt_text || '-',\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<TextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ data.alt_text || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { alt_text: value } ) }\n\t\t\t\thelp={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\thref={\n\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__(\n\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)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\topenInNewTab\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Describe the purpose of the image.' ) }\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t<br />\n\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\trows={ 2 }\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default altTextField;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,wBAAgC;AAChC,gBAAqB;AAiBhB;AAbL,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,UAAW;AAAA,EACtB,WAAW,CAAE,SAAU,MAAM,eAAe;AAAA,EAC5C,QAAQ,CAAE,EAAE,KAAK,MAAO,MAAM,YAAY;AAAA,EAC1C,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,OAAQ,KAAK,YAAY;AAAA,QACzB,UAAW,CAAE,UAAW,SAAU,EAAE,UAAU,MAAM,CAAE;AAAA,QACtD,MACC,4EACC;AAAA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA;AAAA,oBAEC;AAAA,kBACC;AAAA,gBACD;AAAA;AAAA,cAED,cAAY;AAAA,cAEV,8BAAI,oCAAqC;AAAA;AAAA,UAC5C;AAAA,UACA,4CAAC,QAAG;AAAA,cACF,gBAAI,4BAA6B;AAAA,WACpC;AAAA,QAED,MAAO;AAAA;AAAA,IACR;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/attached_to/edit.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { Button, ComboboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, createInterpolateElement } from '@wordpress/element';\nimport { debounce } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\nimport { getRenderedContent } from '../utils/get-rendered-content';\n\nexport type SearchResult = {\n\t/**\n\t * Post or term id.\n\t */\n\tid: number;\n\t/**\n\t * Link url.\n\t */\n\turl: string;\n\t/**\n\t * Title of the link.\n\t */\n\ttitle: string;\n\t/**\n\t * The taxonomy or post type slug or type URL.\n\t */\n\ttype: string;\n\t/**\n\t * Link kind of post-type or taxonomy\n\t */\n\tkind?: string;\n};\n\nexport default function MediaAttachedToEdit( {\n\tdata,\n\tonChange,\n}: DataFormControlProps< MediaItem > ) {\n\tconst defaultPost =\n\t\t!! data.post && !! data?._embedded?.[ 'wp:attached-to' ]?.[ 0 ]\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: getRenderedContent(\n\t\t\t\t\t\t\tdata._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.title\n\t\t\t\t\t\t),\n\t\t\t\t\t\tvalue: data.post.toString(),\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: [];\n\tconst [ options, setOptions ] =\n\t\tuseState< { label: string; value: string }[] >( defaultPost );\n\tconst [ searchResults, setSearchResults ] = useState< SearchResult[] >(\n\t\t[]\n\t);\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ value, setValue ] = useState< string | null >(\n\t\tdata?.post?.toString() ?? null\n\t);\n\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes(),\n\t\t[]\n\t);\n\tconst handleDetach = () => {\n\t\tonChange( {\n\t\t\tpost: 0,\n\t\t\t_embedded: { ...data?._embedded, 'wp:attached-to': undefined },\n\t\t} );\n\t\tsetValue( null );\n\t\tsetOptions( [] );\n\t};\n\n\tconst onValueChange = async ( filterValue: string ) => {\n\t\tsetIsLoading( true );\n\t\tconst results = await fetchLinkSuggestions(\n\t\t\tfilterValue,\n\t\t\t/*\n\t\t\t * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.\n\t\t\t * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.\n\t\t\t */\n\t\t\t{ type: 'post', isInitialSuggestions: true },\n\t\t\t{}\n\t\t);\n\t\tsetSearchResults( results );\n\t\tconst suggestions = results.map( ( result ) => {\n\t\t\treturn {\n\t\t\t\tlabel: result.title,\n\t\t\t\tvalue: result.id.toString(),\n\t\t\t};\n\t\t} );\n\t\tconst includeCurrent =\n\t\t\t! filterValue &&\n\t\t\tsuggestions.findIndex( ( s ) => s.value === value ) === -1;\n\t\tsetOptions( suggestions.concat( includeCurrent ? defaultPost : [] ) );\n\t\tsetIsLoading( false );\n\t};\n\n\t/**\n\t * Handle selection.\n\t *\n\t * @param {Object} selectedPostId The selected post id.\n\t */\n\tconst handleSelectOption = (\n\t\tselectedPostId: string | null | undefined\n\t) => {\n\t\tif ( ! selectedPostId ) {\n\t\t\thandleDetach();\n\t\t\treturn;\n\t\t}\n\t\tsetValue( selectedPostId );\n\t\tif ( selectedPostId ) {\n\t\t\tconst selectedPost = searchResults.find(\n\t\t\t\t( result ) => result.id === Number( selectedPostId )\n\t\t\t);\n\t\t\t// Although unlikely, it's technically possible for selectedPost to not be found.\n\t\t\t// E.g. if the user selects an option just as new search results are loaded.\n\t\t\t// TODO: Add error handling for when selectedPost is not found.\n\t\t\tif ( selectedPost && postTypes ) {\n\t\t\t\tconst postType = postTypes.find(\n\t\t\t\t\t( _postType: { slug: string } ) =>\n\t\t\t\t\t\t_postType.slug === selectedPost?.type\n\t\t\t\t);\n\n\t\t\t\tconst attachedTo = {\n\t\t\t\t\t...( postType && { type: postType.slug } ),\n\t\t\t\t\tid: Number( selectedPostId ),\n\t\t\t\t\ttitle: {\n\t\t\t\t\t\traw: selectedPost.title,\n\t\t\t\t\t\trendered: selectedPost.title,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tonChange( {\n\t\t\t\t\tpost: Number( selectedPostId ),\n\t\t\t\t\t_embedded: {\n\t\t\t\t\t\t...data?._embedded,\n\t\t\t\t\t\t'wp:attached-to': [ attachedTo ],\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t};\n\n\tconst help = createInterpolateElement(\n\t\t__(\n\t\t\t'Search for a post or page to attach this media to or <button>detach current</button>.'\n\t\t),\n\t\t{\n\t\t\tbutton: (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tonClick={ handleDetach }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tdisabled={ ! value }\n\t\t\t\t/>\n\t\t\t),\n\t\t}\n\t);\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\tclassName=\"dataviews-media-field__attached-to\"\n\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAGO;AACP,wBAAwC;AACxC,kBAAmB;AACnB,qBAAmD;AACnD,qBAAyB;AACzB,kBAA0B;AAO1B,kCAAmC;AA4I/B;AAnHW,SAAR,oBAAsC;AAAA,EAC5C;AAAA,EACA;AACD,GAAuC;AACtC,QAAM,cACL,CAAC,CAAE,KAAK,QAAQ,CAAC,CAAE,MAAM,YAAa,gBAAiB,IAAK,CAAE,IAC3D;AAAA,IACA;AAAA,MACC,WAAO;AAAA,QACN,KAAK,YAAa,gBAAiB,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;AACvB,mBAAa;AACb;AAAA,IACD;AACA,aAAU,cAAe;AACzB,QAAK,gBAAiB;AACrB,YAAM,eAAe,cAAc;AAAA,QAClC,CAAE,WAAY,OAAO,OAAO,OAAQ,cAAe;AAAA,MACpD;AAIA,UAAK,gBAAgB,WAAY;AAChC,cAAM,WAAW,UAAU;AAAA,UAC1B,CAAE,cACD,UAAU,SAAS,cAAc;AAAA,QACnC;AAEA,cAAM,aAAa;AAAA,UAClB,GAAK,YAAY,EAAE,MAAM,SAAS,KAAK;AAAA,UACvC,IAAI,OAAQ,cAAe;AAAA,UAC3B,OAAO;AAAA,YACN,KAAK,aAAa;AAAA,YAClB,UAAU,aAAa;AAAA,UACxB;AAAA,QACD;AAEA,iBAAU;AAAA,UACT,MAAM,OAAQ,cAAe;AAAA,UAC7B,WAAW;AAAA,YACV,GAAG,MAAM;AAAA,YACT,kBAAkB,CAAE,UAAW;AAAA,UAChC;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAEA,QAAM,WAAO;AAAA,QACZ;AAAA,MACC;AAAA,IACD;AAAA,IACA;AAAA,MACC,QACC;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,SAAU;AAAA,UACV,SAAQ;AAAA,UACR,wBAAsB;AAAA,UACtB,UAAW,CAAE;AAAA;AAAA,MACd;AAAA,IAEF;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { Button, ComboboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, createInterpolateElement } from '@wordpress/element';\nimport { debounce } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\nimport { getRenderedContent } from '../utils/get-rendered-content';\n\nexport type SearchResult = {\n\t/**\n\t * Post or term id.\n\t */\n\tid: number;\n\t/**\n\t * Link url.\n\t */\n\turl: string;\n\t/**\n\t * Title of the link.\n\t */\n\ttitle: string;\n\t/**\n\t * The taxonomy or post type slug or type URL.\n\t */\n\ttype: string;\n\t/**\n\t * Link kind of post-type or taxonomy\n\t */\n\tkind?: string;\n};\n\nexport default function MediaAttachedToEdit( {\n\tdata,\n\tonChange,\n}: DataFormControlProps< MediaItem > ) {\n\tconst defaultPost =\n\t\t!! data.post && !! data?._embedded?.[ 'wp:attached-to' ]?.[ 0 ]\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: getRenderedContent(\n\t\t\t\t\t\t\tdata._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.title\n\t\t\t\t\t\t),\n\t\t\t\t\t\tvalue: data.post.toString(),\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: [];\n\tconst [ options, setOptions ] =\n\t\tuseState< { label: string; value: string }[] >( defaultPost );\n\tconst [ searchResults, setSearchResults ] = useState< SearchResult[] >(\n\t\t[]\n\t);\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ value, setValue ] = useState< string | null >(\n\t\tdata?.post?.toString() ?? null\n\t);\n\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes(),\n\t\t[]\n\t);\n\tconst handleDetach = () => {\n\t\tonChange( {\n\t\t\tpost: 0,\n\t\t\t_embedded: { ...data?._embedded, 'wp:attached-to': undefined },\n\t\t} );\n\t\tsetValue( null );\n\t\tsetOptions( [] );\n\t};\n\n\tconst onValueChange = async ( filterValue: string ) => {\n\t\tsetIsLoading( true );\n\t\tconst results = await fetchLinkSuggestions(\n\t\t\tfilterValue,\n\t\t\t/*\n\t\t\t * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.\n\t\t\t * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.\n\t\t\t */\n\t\t\t{ type: 'post', isInitialSuggestions: true },\n\t\t\t{}\n\t\t);\n\t\tsetSearchResults( results );\n\t\tconst suggestions = results.map( ( result ) => {\n\t\t\treturn {\n\t\t\t\tlabel: result.title,\n\t\t\t\tvalue: result.id.toString(),\n\t\t\t};\n\t\t} );\n\t\tconst includeCurrent =\n\t\t\t! filterValue &&\n\t\t\tsuggestions.findIndex( ( s ) => s.value === value ) === -1;\n\t\tsetOptions( suggestions.concat( includeCurrent ? defaultPost : [] ) );\n\t\tsetIsLoading( false );\n\t};\n\n\t/**\n\t * Handle selection.\n\t *\n\t * @param {Object} selectedPostId The selected post id.\n\t */\n\tconst handleSelectOption = (\n\t\tselectedPostId: string | null | undefined\n\t) => {\n\t\tif ( ! selectedPostId ) {\n\t\t\thandleDetach();\n\t\t\treturn;\n\t\t}\n\t\tsetValue( selectedPostId );\n\t\tif ( selectedPostId ) {\n\t\t\tconst selectedPost = searchResults.find(\n\t\t\t\t( result ) => result.id === Number( selectedPostId )\n\t\t\t);\n\t\t\t// Although unlikely, it's technically possible for selectedPost to not be found.\n\t\t\t// E.g. if the user selects an option just as new search results are loaded.\n\t\t\t// TODO: Add error handling for when selectedPost is not found.\n\t\t\tif ( selectedPost && postTypes ) {\n\t\t\t\tconst postType = postTypes.find(\n\t\t\t\t\t( _postType: { slug: string } ) =>\n\t\t\t\t\t\t_postType.slug === selectedPost?.type\n\t\t\t\t);\n\n\t\t\t\tconst attachedTo = {\n\t\t\t\t\t...( postType && { type: postType.slug } ),\n\t\t\t\t\tid: Number( selectedPostId ),\n\t\t\t\t\ttitle: {\n\t\t\t\t\t\traw: selectedPost.title,\n\t\t\t\t\t\trendered: selectedPost.title,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tonChange( {\n\t\t\t\t\tpost: Number( selectedPostId ),\n\t\t\t\t\t_embedded: {\n\t\t\t\t\t\t...data?._embedded,\n\t\t\t\t\t\t'wp:attached-to': [ attachedTo ],\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t};\n\n\tconst help = createInterpolateElement(\n\t\t__(\n\t\t\t'Search for a post or page to attach this media to or <button>detach current</button>.'\n\t\t),\n\t\t{\n\t\t\tbutton: (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tonClick={ handleDetach }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tdisabled={ ! value }\n\t\t\t\t/>\n\t\t\t),\n\t\t}\n\t);\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\tclassName=\"dataviews-media-field__attached-to\"\n\t\t\tisLoading={ isLoading }\n\t\t\tlabel={ __( 'Attached to' ) }\n\t\t\thelp={ help }\n\t\t\tvalue={ value }\n\t\t\toptions={ options }\n\t\t\tonFilterValueChange={ debounce(\n\t\t\t\t( filterValue: unknown ) =>\n\t\t\t\t\tonValueChange( filterValue as string ),\n\t\t\t\t300\n\t\t\t) }\n\t\t\tonChange={ handleSelectOption }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAGO;AACP,wBAAwC;AACxC,kBAAmB;AACnB,qBAAmD;AACnD,qBAAyB;AACzB,kBAA0B;AAO1B,kCAAmC;AA4I/B;AAnHW,SAAR,oBAAsC;AAAA,EAC5C;AAAA,EACA;AACD,GAAuC;AACtC,QAAM,cACL,CAAC,CAAE,KAAK,QAAQ,CAAC,CAAE,MAAM,YAAa,gBAAiB,IAAK,CAAE,IAC3D;AAAA,IACA;AAAA,MACC,WAAO;AAAA,QACN,KAAK,YAAa,gBAAiB,IAAK,CAAE,GAAG;AAAA,MAC9C;AAAA,MACA,OAAO,KAAK,KAAK,SAAS;AAAA,IAC3B;AAAA,EACA,IACA,CAAC;AACL,QAAM,CAAE,SAAS,UAAW,QAC3B,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Ae;AAAA,MACpD;AAIA,UAAK,gBAAgB,WAAY;AAChC,cAAM,WAAW,UAAU;AAAA,UAC1B,CAAE,cACD,UAAU,SAAS,cAAc;AAAA,QACnC;AAEA,cAAM,aAAa;AAAA,UAClB,GAAK,YAAY,EAAE,MAAM,SAAS,KAAK;AAAA,UACvC,IAAI,OAAQ,cAAe;AAAA,UAC3B,OAAO;AAAA,YACN,KAAK,aAAa;AAAA,YAClB,UAAU,aAAa;AAAA,UACxB;AAAA,QACD;AAEA,iBAAU;AAAA,UACT,MAAM,OAAQ,cAAe;AAAA,UAC7B,WAAW;AAAA,YACV,GAAG,MAAM;AAAA,YACT,kBAAkB,CAAE,UAAW;AAAA,UAChC;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAEA,QAAM,WAAO;AAAA,QACZ;AAAA,MACC;AAAA,IACD;AAAA,IACA;AAAA,MACC,QACC;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,SAAU;AAAA,UACV,SAAQ;AAAA,UACR,wBAAsB;AAAA,UACtB,UAAW,CAAE;AAAA;AAAA,MACd;AAAA,IAEF;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV;AAAA,MACA,WAAQ,gBAAI,aAAc;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,yBAAsB;AAAA,QACrB,CAAE,gBACD,cAAe,WAAsB;AAAA,QACtC;AAAA,MACD;AAAA,MACA,UAAW;AAAA,MACX,qBAAmB;AAAA;AAAA,EACpB;AAEF;",
|
|
6
6
|
"names": ["coreStore", "fetchLinkSuggestions"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// packages/media-fields/src/alt_text/index.tsx
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
3
|
import { TextareaControl } from "@wordpress/components";
|
|
4
|
-
import {
|
|
4
|
+
import { Link } from "@wordpress/ui";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
var altTextField = {
|
|
6
7
|
id: "alt_text",
|
|
7
8
|
type: "text",
|
|
@@ -15,6 +16,23 @@ var altTextField = {
|
|
|
15
16
|
label: field.label,
|
|
16
17
|
value: data.alt_text || "",
|
|
17
18
|
onChange: (value) => onChange({ alt_text: value }),
|
|
19
|
+
help: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
20
|
+
/* @__PURE__ */ jsx(
|
|
21
|
+
Link,
|
|
22
|
+
{
|
|
23
|
+
href: (
|
|
24
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
25
|
+
__(
|
|
26
|
+
"https://www.w3.org/WAI/tutorials/images/decision-tree/"
|
|
27
|
+
)
|
|
28
|
+
),
|
|
29
|
+
openInNewTab: true,
|
|
30
|
+
children: __("Describe the purpose of the image.")
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
34
|
+
__("Leave empty if decorative.")
|
|
35
|
+
] }),
|
|
18
36
|
rows: 2
|
|
19
37
|
}
|
|
20
38
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/alt_text/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextareaControl } from '@wordpress/components';\nimport type { Field } from '@wordpress/dataviews';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\n\nconst altTextField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'alt_text',\n\ttype: 'text',\n\tlabel: __( 'Alt text' ),\n\tisVisible: ( item ) => item?.media_type === 'image',\n\trender: ( { item } ) => item?.alt_text || '-',\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<TextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ data.alt_text || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { alt_text: value } ) }\n\t\t\t\trows={ 2 }\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default altTextField;\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,uBAAuB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextareaControl } from '@wordpress/components';\nimport { Link } from '@wordpress/ui';\nimport type { Field } from '@wordpress/dataviews';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\n\nconst altTextField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'alt_text',\n\ttype: 'text',\n\tlabel: __( 'Alt text' ),\n\tisVisible: ( item ) => item?.media_type === 'image',\n\trender: ( { item } ) => item?.alt_text || '-',\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<TextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ data.alt_text || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { alt_text: value } ) }\n\t\t\t\thelp={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\thref={\n\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__(\n\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)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\topenInNewTab\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Describe the purpose of the image.' ) }\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t<br />\n\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\trows={ 2 }\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default altTextField;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAChC,SAAS,YAAY;AAiBhB,mBACC,KADD;AAbL,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,UAAW;AAAA,EACtB,WAAW,CAAE,SAAU,MAAM,eAAe;AAAA,EAC5C,QAAQ,CAAE,EAAE,KAAK,MAAO,MAAM,YAAY;AAAA,EAC1C,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,OAAQ,KAAK,YAAY;AAAA,QACzB,UAAW,CAAE,UAAW,SAAU,EAAE,UAAU,MAAM,CAAE;AAAA,QACtD,MACC,iCACC;AAAA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA;AAAA,gBAEC;AAAA,kBACC;AAAA,gBACD;AAAA;AAAA,cAED,cAAY;AAAA,cAEV,aAAI,oCAAqC;AAAA;AAAA,UAC5C;AAAA,UACA,oBAAC,QAAG;AAAA,UACF,GAAI,4BAA6B;AAAA,WACpC;AAAA,QAED,MAAO;AAAA;AAAA,IACR;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/attached_to/edit.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { Button, ComboboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, createInterpolateElement } from '@wordpress/element';\nimport { debounce } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\nimport { getRenderedContent } from '../utils/get-rendered-content';\n\nexport type SearchResult = {\n\t/**\n\t * Post or term id.\n\t */\n\tid: number;\n\t/**\n\t * Link url.\n\t */\n\turl: string;\n\t/**\n\t * Title of the link.\n\t */\n\ttitle: string;\n\t/**\n\t * The taxonomy or post type slug or type URL.\n\t */\n\ttype: string;\n\t/**\n\t * Link kind of post-type or taxonomy\n\t */\n\tkind?: string;\n};\n\nexport default function MediaAttachedToEdit( {\n\tdata,\n\tonChange,\n}: DataFormControlProps< MediaItem > ) {\n\tconst defaultPost =\n\t\t!! data.post && !! data?._embedded?.[ 'wp:attached-to' ]?.[ 0 ]\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: getRenderedContent(\n\t\t\t\t\t\t\tdata._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.title\n\t\t\t\t\t\t),\n\t\t\t\t\t\tvalue: data.post.toString(),\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: [];\n\tconst [ options, setOptions ] =\n\t\tuseState< { label: string; value: string }[] >( defaultPost );\n\tconst [ searchResults, setSearchResults ] = useState< SearchResult[] >(\n\t\t[]\n\t);\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ value, setValue ] = useState< string | null >(\n\t\tdata?.post?.toString() ?? null\n\t);\n\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes(),\n\t\t[]\n\t);\n\tconst handleDetach = () => {\n\t\tonChange( {\n\t\t\tpost: 0,\n\t\t\t_embedded: { ...data?._embedded, 'wp:attached-to': undefined },\n\t\t} );\n\t\tsetValue( null );\n\t\tsetOptions( [] );\n\t};\n\n\tconst onValueChange = async ( filterValue: string ) => {\n\t\tsetIsLoading( true );\n\t\tconst results = await fetchLinkSuggestions(\n\t\t\tfilterValue,\n\t\t\t/*\n\t\t\t * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.\n\t\t\t * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.\n\t\t\t */\n\t\t\t{ type: 'post', isInitialSuggestions: true },\n\t\t\t{}\n\t\t);\n\t\tsetSearchResults( results );\n\t\tconst suggestions = results.map( ( result ) => {\n\t\t\treturn {\n\t\t\t\tlabel: result.title,\n\t\t\t\tvalue: result.id.toString(),\n\t\t\t};\n\t\t} );\n\t\tconst includeCurrent =\n\t\t\t! filterValue &&\n\t\t\tsuggestions.findIndex( ( s ) => s.value === value ) === -1;\n\t\tsetOptions( suggestions.concat( includeCurrent ? defaultPost : [] ) );\n\t\tsetIsLoading( false );\n\t};\n\n\t/**\n\t * Handle selection.\n\t *\n\t * @param {Object} selectedPostId The selected post id.\n\t */\n\tconst handleSelectOption = (\n\t\tselectedPostId: string | null | undefined\n\t) => {\n\t\tif ( ! selectedPostId ) {\n\t\t\thandleDetach();\n\t\t\treturn;\n\t\t}\n\t\tsetValue( selectedPostId );\n\t\tif ( selectedPostId ) {\n\t\t\tconst selectedPost = searchResults.find(\n\t\t\t\t( result ) => result.id === Number( selectedPostId )\n\t\t\t);\n\t\t\t// Although unlikely, it's technically possible for selectedPost to not be found.\n\t\t\t// E.g. if the user selects an option just as new search results are loaded.\n\t\t\t// TODO: Add error handling for when selectedPost is not found.\n\t\t\tif ( selectedPost && postTypes ) {\n\t\t\t\tconst postType = postTypes.find(\n\t\t\t\t\t( _postType: { slug: string } ) =>\n\t\t\t\t\t\t_postType.slug === selectedPost?.type\n\t\t\t\t);\n\n\t\t\t\tconst attachedTo = {\n\t\t\t\t\t...( postType && { type: postType.slug } ),\n\t\t\t\t\tid: Number( selectedPostId ),\n\t\t\t\t\ttitle: {\n\t\t\t\t\t\traw: selectedPost.title,\n\t\t\t\t\t\trendered: selectedPost.title,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tonChange( {\n\t\t\t\t\tpost: Number( selectedPostId ),\n\t\t\t\t\t_embedded: {\n\t\t\t\t\t\t...data?._embedded,\n\t\t\t\t\t\t'wp:attached-to': [ attachedTo ],\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t};\n\n\tconst help = createInterpolateElement(\n\t\t__(\n\t\t\t'Search for a post or page to attach this media to or <button>detach current</button>.'\n\t\t),\n\t\t{\n\t\t\tbutton: (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tonClick={ handleDetach }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tdisabled={ ! value }\n\t\t\t\t/>\n\t\t\t),\n\t\t}\n\t);\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\tclassName=\"dataviews-media-field__attached-to\"\n\t\t\
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC,sCAAsC;AAAA,EACtC,SAAS;AAAA,OACH;AACP,SAAS,QAAQ,uBAAuB;AACxC,SAAS,UAAU;AACnB,SAAS,UAAU,gCAAgC;AACnD,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAO1B,SAAS,0BAA0B;AA4I/B;AAnHW,SAAR,oBAAsC;AAAA,EAC5C;AAAA,EACA;AACD,GAAuC;AACtC,QAAM,cACL,CAAC,CAAE,KAAK,QAAQ,CAAC,CAAE,MAAM,YAAa,gBAAiB,IAAK,CAAE,IAC3D;AAAA,IACA;AAAA,MACC,OAAO;AAAA,QACN,KAAK,YAAa,gBAAiB,IAAK,CAAE,GAAG;AAAA,MAC9C;AAAA,MACA,OAAO,KAAK,KAAK,SAAS;AAAA,IAC3B;AAAA,EACA,IACA,CAAC;AACL,QAAM,CAAE,SAAS,UAAW,IAC3B,SAAgD,WAAY;AAC7D,QAAM,CAAE,eAAe,gBAAiB,IAAI;AAAA,IAC3C,CAAC;AAAA,EACF;AACA,QAAM,CAAE,WAAW,YAAa,IAAI,SAAU,KAAM;AACpD,QAAM,CAAE,OAAO,QAAS,IAAI;AAAA,IAC3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,IAAI,OAAQ,cAAe;AAAA,UAC3B,OAAO;AAAA,YACN,KAAK,aAAa;AAAA,YAClB,UAAU,aAAa;AAAA,UACxB;AAAA,QACD;AAEA,iBAAU;AAAA,UACT,MAAM,OAAQ,cAAe;AAAA,UAC7B,WAAW;AAAA,YACV,GAAG,MAAM;AAAA,YACT,kBAAkB,CAAE,UAAW;AAAA,UAChC;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAEA,QAAM,OAAO;AAAA,IACZ;AAAA,MACC;AAAA,IACD;AAAA,IACA;AAAA,MACC,QACC;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,SAAU;AAAA,UACV,SAAQ;AAAA,UACR,wBAAsB;AAAA,UACtB,UAAW,CAAE;AAAA;AAAA,MACd;AAAA,IAEF;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { Button, ComboboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, createInterpolateElement } from '@wordpress/element';\nimport { debounce } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\nimport { getRenderedContent } from '../utils/get-rendered-content';\n\nexport type SearchResult = {\n\t/**\n\t * Post or term id.\n\t */\n\tid: number;\n\t/**\n\t * Link url.\n\t */\n\turl: string;\n\t/**\n\t * Title of the link.\n\t */\n\ttitle: string;\n\t/**\n\t * The taxonomy or post type slug or type URL.\n\t */\n\ttype: string;\n\t/**\n\t * Link kind of post-type or taxonomy\n\t */\n\tkind?: string;\n};\n\nexport default function MediaAttachedToEdit( {\n\tdata,\n\tonChange,\n}: DataFormControlProps< MediaItem > ) {\n\tconst defaultPost =\n\t\t!! data.post && !! data?._embedded?.[ 'wp:attached-to' ]?.[ 0 ]\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: getRenderedContent(\n\t\t\t\t\t\t\tdata._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.title\n\t\t\t\t\t\t),\n\t\t\t\t\t\tvalue: data.post.toString(),\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: [];\n\tconst [ options, setOptions ] =\n\t\tuseState< { label: string; value: string }[] >( defaultPost );\n\tconst [ searchResults, setSearchResults ] = useState< SearchResult[] >(\n\t\t[]\n\t);\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ value, setValue ] = useState< string | null >(\n\t\tdata?.post?.toString() ?? null\n\t);\n\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes(),\n\t\t[]\n\t);\n\tconst handleDetach = () => {\n\t\tonChange( {\n\t\t\tpost: 0,\n\t\t\t_embedded: { ...data?._embedded, 'wp:attached-to': undefined },\n\t\t} );\n\t\tsetValue( null );\n\t\tsetOptions( [] );\n\t};\n\n\tconst onValueChange = async ( filterValue: string ) => {\n\t\tsetIsLoading( true );\n\t\tconst results = await fetchLinkSuggestions(\n\t\t\tfilterValue,\n\t\t\t/*\n\t\t\t * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.\n\t\t\t * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.\n\t\t\t */\n\t\t\t{ type: 'post', isInitialSuggestions: true },\n\t\t\t{}\n\t\t);\n\t\tsetSearchResults( results );\n\t\tconst suggestions = results.map( ( result ) => {\n\t\t\treturn {\n\t\t\t\tlabel: result.title,\n\t\t\t\tvalue: result.id.toString(),\n\t\t\t};\n\t\t} );\n\t\tconst includeCurrent =\n\t\t\t! filterValue &&\n\t\t\tsuggestions.findIndex( ( s ) => s.value === value ) === -1;\n\t\tsetOptions( suggestions.concat( includeCurrent ? defaultPost : [] ) );\n\t\tsetIsLoading( false );\n\t};\n\n\t/**\n\t * Handle selection.\n\t *\n\t * @param {Object} selectedPostId The selected post id.\n\t */\n\tconst handleSelectOption = (\n\t\tselectedPostId: string | null | undefined\n\t) => {\n\t\tif ( ! selectedPostId ) {\n\t\t\thandleDetach();\n\t\t\treturn;\n\t\t}\n\t\tsetValue( selectedPostId );\n\t\tif ( selectedPostId ) {\n\t\t\tconst selectedPost = searchResults.find(\n\t\t\t\t( result ) => result.id === Number( selectedPostId )\n\t\t\t);\n\t\t\t// Although unlikely, it's technically possible for selectedPost to not be found.\n\t\t\t// E.g. if the user selects an option just as new search results are loaded.\n\t\t\t// TODO: Add error handling for when selectedPost is not found.\n\t\t\tif ( selectedPost && postTypes ) {\n\t\t\t\tconst postType = postTypes.find(\n\t\t\t\t\t( _postType: { slug: string } ) =>\n\t\t\t\t\t\t_postType.slug === selectedPost?.type\n\t\t\t\t);\n\n\t\t\t\tconst attachedTo = {\n\t\t\t\t\t...( postType && { type: postType.slug } ),\n\t\t\t\t\tid: Number( selectedPostId ),\n\t\t\t\t\ttitle: {\n\t\t\t\t\t\traw: selectedPost.title,\n\t\t\t\t\t\trendered: selectedPost.title,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tonChange( {\n\t\t\t\t\tpost: Number( selectedPostId ),\n\t\t\t\t\t_embedded: {\n\t\t\t\t\t\t...data?._embedded,\n\t\t\t\t\t\t'wp:attached-to': [ attachedTo ],\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t};\n\n\tconst help = createInterpolateElement(\n\t\t__(\n\t\t\t'Search for a post or page to attach this media to or <button>detach current</button>.'\n\t\t),\n\t\t{\n\t\t\tbutton: (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tonClick={ handleDetach }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tdisabled={ ! value }\n\t\t\t\t/>\n\t\t\t),\n\t\t}\n\t);\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\tclassName=\"dataviews-media-field__attached-to\"\n\t\t\tisLoading={ isLoading }\n\t\t\tlabel={ __( 'Attached to' ) }\n\t\t\thelp={ help }\n\t\t\tvalue={ value }\n\t\t\toptions={ options }\n\t\t\tonFilterValueChange={ debounce(\n\t\t\t\t( filterValue: unknown ) =>\n\t\t\t\t\tonValueChange( filterValue as string ),\n\t\t\t\t300\n\t\t\t) }\n\t\t\tonChange={ handleSelectOption }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC,sCAAsC;AAAA,EACtC,SAAS;AAAA,OACH;AACP,SAAS,QAAQ,uBAAuB;AACxC,SAAS,UAAU;AACnB,SAAS,UAAU,gCAAgC;AACnD,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAO1B,SAAS,0BAA0B;AA4I/B;AAnHW,SAAR,oBAAsC;AAAA,EAC5C;AAAA,EACA;AACD,GAAuC;AACtC,QAAM,cACL,CAAC,CAAE,KAAK,QAAQ,CAAC,CAAE,MAAM,YAAa,gBAAiB,IAAK,CAAE,IAC3D;AAAA,IACA;AAAA,MACC,OAAO;AAAA,QACN,KAAK,YAAa,gBAAiB,IAAK,CAAE,GAAG;AAAA,MAC9C;AAAA,MACA,OAAO,KAAK,KAAK,SAAS;AAAA,IAC3B;AAAA,EACA,IACA,CAAC;AACL,QAAM,CAAE,SAAS,UAAW,IAC3B,SAAgD,WAAY;AAC7D,QAAM,CAAE,eAAe,gBAAiB,IAAI;AAAA,IAC3C,CAAC;AAAA,EACF;AACA,QAAM,CAAE,WAAW,YAAa,IAAI,SAAU,KAAM;AACpD,QAAM,CAAE,OAAO,QAAS,IAAI;AAAA,IAC3B,MAAM,MAAM,SAAS,KAAK;AAAA,EAC3B;AAEA,QAAM,YAAY;AAAA,IACjB,CAAE,WAAY,OAAQ,SAAU,EAAE,aAAa;AAAA,IAC/C,CA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AAAA,UACT,MAAM,OAAQ,cAAe;AAAA,UAC7B,WAAW;AAAA,YACV,GAAG,MAAM;AAAA,YACT,kBAAkB,CAAE,UAAW;AAAA,UAChC;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAEA,QAAM,OAAO;AAAA,IACZ;AAAA,MACC;AAAA,IACD;AAAA,IACA;AAAA,MACC,QACC;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,SAAU;AAAA,UACV,SAAQ;AAAA,UACR,wBAAsB;AAAA,UACtB,UAAW,CAAE;AAAA;AAAA,MACd;AAAA,IAEF;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV;AAAA,MACA,OAAQ,GAAI,aAAc;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,qBAAsB;AAAA,QACrB,CAAE,gBACD,cAAe,WAAsB;AAAA,QACtC;AAAA,MACD;AAAA,MACA,UAAW;AAAA,MACX,qBAAmB;AAAA;AAAA,EACpB;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -67,6 +67,12 @@
|
|
|
67
67
|
/**
|
|
68
68
|
* Focus styles.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Standard focus rings for the WordPress Design System.
|
|
72
|
+
*
|
|
73
|
+
* Apply `outset-ring__focus` inside the relevant pseudo-class at the call site,
|
|
74
|
+
* e.g. `&:focus { @include outset-ring__focus(); }`.
|
|
75
|
+
*/
|
|
70
76
|
/**
|
|
71
77
|
* Applies editor left position to the selector passed as argument
|
|
72
78
|
*/
|
|
@@ -187,8 +193,8 @@
|
|
|
187
193
|
padding: 0 16px;
|
|
188
194
|
width: 100%;
|
|
189
195
|
container-type: inline-size;
|
|
190
|
-
font-family: -apple-system,
|
|
191
|
-
font-weight: 400;
|
|
196
|
+
font-family: -apple-system, system-ui, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
197
|
+
font-weight: var(--wpds-typography-font-weight-default, 400);
|
|
192
198
|
font-size: 12px;
|
|
193
199
|
line-height: 16px;
|
|
194
200
|
}
|
package/build-style/style.css
CHANGED
|
@@ -67,6 +67,12 @@
|
|
|
67
67
|
/**
|
|
68
68
|
* Focus styles.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Standard focus rings for the WordPress Design System.
|
|
72
|
+
*
|
|
73
|
+
* Apply `outset-ring__focus` inside the relevant pseudo-class at the call site,
|
|
74
|
+
* e.g. `&:focus { @include outset-ring__focus(); }`.
|
|
75
|
+
*/
|
|
70
76
|
/**
|
|
71
77
|
* Applies editor left position to the selector passed as argument
|
|
72
78
|
*/
|
|
@@ -187,8 +193,8 @@
|
|
|
187
193
|
padding: 0 16px;
|
|
188
194
|
width: 100%;
|
|
189
195
|
container-type: inline-size;
|
|
190
|
-
font-family: -apple-system,
|
|
191
|
-
font-weight: 400;
|
|
196
|
+
font-family: -apple-system, system-ui, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
197
|
+
font-weight: var(--wpds-typography-font-weight-default, 400);
|
|
192
198
|
font-size: 12px;
|
|
193
199
|
line-height: 16px;
|
|
194
200
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/alt_text/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/alt_text/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAElE,QAAA,MAAM,YAAY,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAmC5D,CAAC;eAEa,YAAY"}
|
|
@@ -25,5 +25,5 @@ export type SearchResult = {
|
|
|
25
25
|
*/
|
|
26
26
|
kind?: string;
|
|
27
27
|
};
|
|
28
|
-
export default function MediaAttachedToEdit({ data, onChange }: DataFormControlProps<MediaItem>): import("react").JSX.Element;
|
|
28
|
+
export default function MediaAttachedToEdit({ data, onChange, }: DataFormControlProps<MediaItem>): import("react").JSX.Element;
|
|
29
29
|
//# sourceMappingURL=edit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/attached_to/edit.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,MAAM,YAAY,GAAG;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,IAAI,EACJ,QAAQ,
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/attached_to/edit.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,MAAM,YAAY,GAAG;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,IAAI,EACJ,QAAQ,GACR,EAAE,oBAAoB,CAAE,SAAS,CAAE,+BA4InC"}
|
|
@@ -3,5 +3,5 @@ import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
|
3
3
|
* Internal dependencies
|
|
4
4
|
*/
|
|
5
5
|
import type { MediaItem } from '../types';
|
|
6
|
-
export default function MediaAttachedToView({ item }: DataViewRenderFieldProps<MediaItem>): import("react").JSX.Element;
|
|
6
|
+
export default function MediaAttachedToView({ item, }: DataViewRenderFieldProps<MediaItem>): import("react").JSX.Element;
|
|
7
7
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/attached_to/view.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,IAAI,
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/attached_to/view.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,IAAI,GACJ,EAAE,wBAAwB,CAAE,SAAS,CAAE,+BA0BvC"}
|
|
@@ -3,5 +3,5 @@ import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
|
3
3
|
* Internal dependencies
|
|
4
4
|
*/
|
|
5
5
|
import type { MediaItem } from '../types';
|
|
6
|
-
export default function AuthorView({ item }: DataViewRenderFieldProps<MediaItem>): import("react").JSX.Element;
|
|
6
|
+
export default function AuthorView({ item, }: DataViewRenderFieldProps<MediaItem>): import("react").JSX.Element;
|
|
7
7
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/author/view.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAE,EACnC,IAAI,
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/author/view.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAE,EACnC,IAAI,GACJ,EAAE,wBAAwB,CAAE,SAAS,CAAE,+BAsDvC"}
|
|
@@ -3,5 +3,5 @@ import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
|
3
3
|
* Internal dependencies
|
|
4
4
|
*/
|
|
5
5
|
import type { MediaItem } from '../types';
|
|
6
|
-
export default function FileNameView({ item }: DataViewRenderFieldProps<MediaItem>): "" | import("react").JSX.Element;
|
|
6
|
+
export default function FileNameView({ item, }: DataViewRenderFieldProps<MediaItem>): "" | import("react").JSX.Element;
|
|
7
7
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/filename/view.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGrE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAO1C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,EACrC,IAAI,
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/filename/view.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGrE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAO1C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,EACrC,IAAI,GACJ,EAAE,wBAAwB,CAAE,SAAS,CAAE,oCAkCvC"}
|
|
@@ -10,5 +10,5 @@ import type { MediaItem } from '../types';
|
|
|
10
10
|
* @param configSizes The target display size string (e.g. '900px').
|
|
11
11
|
*/
|
|
12
12
|
export declare function getBestImageUrl(featuredMedia: Attachment | MediaItem, configSizes?: string): string;
|
|
13
|
-
export default function MediaThumbnailView({ item, config }: DataViewRenderFieldProps<MediaItem>): import("react").JSX.Element | null;
|
|
13
|
+
export default function MediaThumbnailView({ item, config, }: DataViewRenderFieldProps<MediaItem>): import("react").JSX.Element | null;
|
|
14
14
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/media_thumbnail/view.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAKrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,aAAa,EAAE,UAAU,GAAG,SAAS,EACrC,WAAW,CAAC,EAAE,MAAM,GAClB,MAAM,CAwCR;AA4FD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAE,EAC3C,IAAI,EACJ,MAAM,
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/media_thumbnail/view.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAKrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,aAAa,EAAE,UAAU,GAAG,SAAS,EACrC,WAAW,CAAC,EAAE,MAAM,GAClB,MAAM,CAwCR;AA4FD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAE,EAC3C,IAAI,EACJ,MAAM,GACN,EAAE,wBAAwB,CAAE,SAAS,CAAE,sCA4CvC"}
|
|
@@ -4,10 +4,11 @@ declare const _default: {
|
|
|
4
4
|
component: typeof DataForm;
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
7
|
+
declare const DataFormsComponent: ({ type }: {
|
|
8
|
+
type: 'regular' | 'panel';
|
|
9
|
+
}) => import("react").JSX.Element;
|
|
7
10
|
export declare const DataFormsPreview: {
|
|
8
|
-
render:
|
|
9
|
-
type: 'regular' | 'panel';
|
|
10
|
-
}) => import("react").JSX.Element;
|
|
11
|
+
render: typeof DataFormsComponent;
|
|
11
12
|
argTypes: {
|
|
12
13
|
type: {
|
|
13
14
|
control: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAa,MAAM,sBAAsB,CAAC;;IAsB1D,KAAK;IACL,SAAS;;;
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAa,MAAM,sBAAsB,CAAC;;IAsB1D,KAAK;IACL,SAAS;;;AAuRV,QAAA,MAAM,kBAAkB,aAAe;IAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAA;CAAE,gCA4CnE,CAAC;AAEF,eAAO,MAAM,gBAAgB;IAC5B,MAAM;IACN,QAAQ;QACP,IAAI;YACH,OAAO;gBAAI,IAAI;;YACf,WAAW;YACX,OAAO;;;IAGT,IAAI;QACH,IAAI;;CAEL,CAAC;AAEF,eAAO,MAAM,gBAAgB,mCAsC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/media-fields",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Reusable field definitions for displaying and editing media attachment properties in WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -48,19 +48,19 @@
|
|
|
48
48
|
"src/**/*.scss"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@wordpress/base-styles": "^
|
|
52
|
-
"@wordpress/components": "^
|
|
53
|
-
"@wordpress/compose": "^8.
|
|
54
|
-
"@wordpress/core-data": "^7.
|
|
55
|
-
"@wordpress/data": "^10.
|
|
56
|
-
"@wordpress/dataviews": "^17.
|
|
57
|
-
"@wordpress/date": "^5.
|
|
58
|
-
"@wordpress/element": "^8.
|
|
59
|
-
"@wordpress/i18n": "^6.
|
|
60
|
-
"@wordpress/icons": "^15.
|
|
61
|
-
"@wordpress/primitives": "^4.
|
|
62
|
-
"@wordpress/ui": "^0.
|
|
63
|
-
"@wordpress/url": "^4.
|
|
51
|
+
"@wordpress/base-styles": "^11.0.0",
|
|
52
|
+
"@wordpress/components": "^37.0.0",
|
|
53
|
+
"@wordpress/compose": "^8.4.0",
|
|
54
|
+
"@wordpress/core-data": "^7.51.0",
|
|
55
|
+
"@wordpress/data": "^10.51.0",
|
|
56
|
+
"@wordpress/dataviews": "^17.2.0",
|
|
57
|
+
"@wordpress/date": "^5.51.0",
|
|
58
|
+
"@wordpress/element": "^8.3.0",
|
|
59
|
+
"@wordpress/i18n": "^6.24.0",
|
|
60
|
+
"@wordpress/icons": "^15.2.0",
|
|
61
|
+
"@wordpress/primitives": "^4.51.0",
|
|
62
|
+
"@wordpress/ui": "^0.18.0",
|
|
63
|
+
"@wordpress/url": "^4.51.0",
|
|
64
64
|
"clsx": "^2.1.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"@types/jest": "^29.5.14"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@types/react": "^18
|
|
74
|
-
"react": "^18
|
|
73
|
+
"@types/react": "^18 || ^19",
|
|
74
|
+
"react": "^18 || ^19"
|
|
75
75
|
},
|
|
76
76
|
"peerDependenciesMeta": {
|
|
77
77
|
"@types/react": {
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "e9a74f9c14095a34398ecd4d1f7a908e55051205"
|
|
85
85
|
}
|
package/src/alt_text/index.tsx
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { TextareaControl } from '@wordpress/components';
|
|
6
|
+
import { Link } from '@wordpress/ui';
|
|
6
7
|
import type { Field } from '@wordpress/dataviews';
|
|
7
8
|
import type { Attachment, Updatable } from '@wordpress/core-data';
|
|
8
9
|
|
|
@@ -18,6 +19,23 @@ const altTextField: Partial< Field< Updatable< Attachment > > > = {
|
|
|
18
19
|
label={ field.label }
|
|
19
20
|
value={ data.alt_text || '' }
|
|
20
21
|
onChange={ ( value ) => onChange( { alt_text: value } ) }
|
|
22
|
+
help={
|
|
23
|
+
<>
|
|
24
|
+
<Link
|
|
25
|
+
href={
|
|
26
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
27
|
+
__(
|
|
28
|
+
'https://www.w3.org/WAI/tutorials/images/decision-tree/'
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
openInNewTab
|
|
32
|
+
>
|
|
33
|
+
{ __( 'Describe the purpose of the image.' ) }
|
|
34
|
+
</Link>
|
|
35
|
+
<br />
|
|
36
|
+
{ __( 'Leave empty if decorative.' ) }
|
|
37
|
+
</>
|
|
38
|
+
}
|
|
21
39
|
rows={ 2 }
|
|
22
40
|
/>
|
|
23
41
|
);
|
package/src/attached_to/edit.tsx
CHANGED