@wordpress/media-fields 0.19.2-next.v.202609031004.0 → 0.20.1-next.v.202609171837.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 +10 -1
- package/build/alt_text/index.cjs +20 -28
- package/build/alt_text/index.cjs.map +3 -3
- package/build/attached_to/edit.cjs.map +2 -2
- package/build/author/index.cjs +0 -5
- package/build/author/index.cjs.map +2 -2
- package/build/caption/index.cjs +3 -12
- package/build/caption/index.cjs.map +3 -3
- package/build/description/index.cjs +3 -11
- package/build/description/index.cjs.map +3 -3
- package/build/media_dimensions/index.cjs.map +2 -2
- package/build-module/alt_text/index.mjs +20 -28
- package/build-module/alt_text/index.mjs.map +2 -2
- package/build-module/attached_to/edit.mjs.map +2 -2
- package/build-module/author/index.mjs +0 -5
- package/build-module/author/index.mjs.map +2 -2
- package/build-module/caption/index.mjs +3 -12
- package/build-module/caption/index.mjs.map +2 -2
- package/build-module/description/index.mjs +3 -11
- package/build-module/description/index.mjs.map +2 -2
- package/build-module/media_dimensions/index.mjs.map +2 -2
- package/build-types/alt_text/index.d.ts.map +1 -1
- package/build-types/author/index.d.ts.map +1 -1
- package/build-types/caption/index.d.ts.map +1 -1
- package/build-types/description/index.d.ts.map +1 -1
- package/package.json +16 -17
- package/src/alt_text/index.tsx +20 -27
- package/src/attached_to/edit.tsx +1 -1
- package/src/attached_to/test/view.jsdom.test.tsx +1 -0
- package/src/author/index.tsx +0 -8
- package/src/caption/index.tsx +3 -10
- package/src/description/index.tsx +3 -10
- package/src/filename/test/view.jsdom.test.tsx +1 -0
- package/src/media_dimensions/index.ts +1 -1
- package/src/media_thumbnail/test/get-best-image-url.jsdom.test.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
## 0.
|
|
5
|
+
## 0.20.0 (2026-09-10)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- `author`: Drop the custom `sort` callback, which read `_embedded.author` from the arguments although `Field.sort` receives the field values (the author ids), so every comparison returned `0` and in-memory sorting by author was a no-op. The field now sorts by author id through the `integer` type, matching the order the REST API returns for `orderby=author` ([#82559](https://github.com/WordPress/gutenberg/pull/82559)).
|
|
10
|
+
- `alt_text`, `caption`, `description`: Pass the field's disabled state to the textarea control, so disabling one of these fields stops it accepting input. ([#82516](https://github.com/WordPress/gutenberg/pull/82516))
|
|
6
11
|
|
|
7
12
|
### Internal
|
|
8
13
|
|
|
14
|
+
- `caption`: Replace the custom `Edit` component with the built-in `textarea` control ([#82539](https://github.com/WordPress/gutenberg/pull/82539)).
|
|
15
|
+
- `alt_text`: Replace the custom `Edit` component with the built-in `textarea` control, passing the help text as the field's `description` ([#82539](https://github.com/WordPress/gutenberg/pull/82539)).
|
|
16
|
+
- `description`: Replace the custom `Edit` component with the built-in `textarea` control ([#82539](https://github.com/WordPress/gutenberg/pull/82539)).
|
|
9
17
|
- Remove unused dependencies `@wordpress/date` and `@wordpress/primitives` ([#82103](https://github.com/WordPress/gutenberg/pull/82103)).
|
|
10
18
|
- Remove tsconfig project references to packages that are not dependencies ([#82106](https://github.com/WordPress/gutenberg/pull/82106)).
|
|
11
19
|
|
|
@@ -21,6 +29,7 @@
|
|
|
21
29
|
### Bug Fixes
|
|
22
30
|
|
|
23
31
|
- `attached_to`: Reserve room for the suggestions so the field's DataForm panel dropdown is placed with space for them, instead of being sized to the row and then crushing them into a box too small to scroll comfortably. Also don't expand the suggestion list until the user searches, debounce the search so a request isn't fired per keystroke, allow re-attaching straight after detaching, and drop the detach link from the help text in favour of the field's own reset button ([#81122](https://github.com/WordPress/gutenberg/issues/81122)).
|
|
32
|
+
|
|
24
33
|
## 0.17.0 (2026-07-29)
|
|
25
34
|
|
|
26
35
|
## 0.16.0 (2026-07-14)
|
package/build/alt_text/index.cjs
CHANGED
|
@@ -24,42 +24,34 @@ __export(alt_text_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(alt_text_exports);
|
|
26
26
|
var import_i18n = require("@wordpress/i18n");
|
|
27
|
-
var import_components = require("@wordpress/components");
|
|
28
27
|
var import_ui = require("@wordpress/ui");
|
|
29
28
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
29
|
var altTextField = {
|
|
31
30
|
id: "alt_text",
|
|
32
31
|
type: "text",
|
|
33
32
|
label: (0, import_i18n.__)("Alt text"),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
38
|
-
import_components.TextareaControl,
|
|
33
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
34
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
35
|
+
import_ui.Link,
|
|
39
36
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
] }),
|
|
60
|
-
rows: 2
|
|
37
|
+
href: (
|
|
38
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
39
|
+
(0, import_i18n.__)(
|
|
40
|
+
"https://www.w3.org/WAI/tutorials/images/decision-tree/"
|
|
41
|
+
)
|
|
42
|
+
),
|
|
43
|
+
openInNewTab: true,
|
|
44
|
+
children: (0, import_i18n.__)("Describe the purpose of the image.")
|
|
61
45
|
}
|
|
62
|
-
)
|
|
46
|
+
),
|
|
47
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
48
|
+
(0, import_i18n.__)("Leave empty if decorative.")
|
|
49
|
+
] }),
|
|
50
|
+
isVisible: (item) => item?.media_type === "image",
|
|
51
|
+
render: ({ item }) => item?.alt_text || "-",
|
|
52
|
+
Edit: {
|
|
53
|
+
control: "textarea",
|
|
54
|
+
rows: 2
|
|
63
55
|
},
|
|
64
56
|
enableSorting: false,
|
|
65
57
|
filterBy: false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/alt_text/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\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\tdescription: (\n\t\t<>\n\t\t\t<Link\n\t\t\t\thref={\n\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__(\n\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\topenInNewTab\n\t\t\t>\n\t\t\t\t{ __( 'Describe the purpose of the image.' ) }\n\t\t\t</Link>\n\t\t\t<br />\n\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t</>\n\t),\n\tisVisible: ( item ) => item?.media_type === 'image',\n\trender: ( { item } ) => item?.alt_text || '-',\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 2,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default altTextField;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,gBAAqB;AASnB;AALF,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,UAAW;AAAA,EACtB,aACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA;AAAA,cAEC;AAAA,YACC;AAAA,UACD;AAAA;AAAA,QAED,cAAY;AAAA,QAEV,8BAAI,oCAAqC;AAAA;AAAA,IAC5C;AAAA,IACA,4CAAC,QAAG;AAAA,QACF,gBAAI,4BAA6B;AAAA,KACpC;AAAA,EAED,WAAW,CAAE,SAAU,MAAM,eAAe;AAAA,EAC5C,QAAQ,CAAE,EAAE,KAAK,MAAO,MAAM,YAAY;AAAA,EAC1C,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,mBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/attached_to/edit.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { ComboboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDebounce, useEvent } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAGO;AACP,wBAAgC;AAChC,kBAAmB;AACnB,qBAAyB;AACzB,qBAAsC;AACtC,kBAA0B;AAG1B,kCAAmC;AA0IjC;AAjHa,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,
|
|
4
|
+
"sourcesContent": ["import {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { ComboboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDebounce, useEvent } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\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\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};\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// `onValueChange` closes over state, so it's wrapped in `useEvent` to give\n\t// `useDebounce` a stable function. Debouncing an inline function instead\n\t// rebuilds the timer on every render, so nothing is debounced and each\n\t// keystroke fires its own request.\n\tconst debouncedValueChange = useDebounce( useEvent( onValueChange ), 300 );\n\n\t/**\n\t * Handle selection.\n\t *\n\t * @param {Object} selectedPostId The selected post id.\n\t */\n\tconst handleSelectOption = ( selectedPostId: string | null ) => {\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\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={ __( 'Attach this file to a single post or page.' ) }\n\t\t\tvalue={ value }\n\t\t\toptions={ options }\n\t\t\tonFilterValueChange={ ( filterValue: unknown ) =>\n\t\t\t\tdebouncedValueChange( filterValue as string )\n\t\t\t}\n\t\t\tonChange={ handleSelectOption }\n\t\t\thideLabelFromVision\n\t\t\t// Opening the panel shouldn't imply the user has decided to change\n\t\t\t// the attachment, so wait for them to search before showing the list.\n\t\t\texpandOnFocus={ false }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["coreStore", "fetchLinkSuggestions"]
|
|
7
7
|
}
|
package/build/author/index.cjs
CHANGED
|
@@ -58,11 +58,6 @@ var authorField = {
|
|
|
58
58
|
}));
|
|
59
59
|
},
|
|
60
60
|
render: import_view.default,
|
|
61
|
-
sort: (a, b, direction) => {
|
|
62
|
-
const nameA = a._embedded?.author?.[0]?.name || "";
|
|
63
|
-
const nameB = b._embedded?.author?.[0]?.name || "";
|
|
64
|
-
return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
|
|
65
|
-
},
|
|
66
61
|
filterBy: {
|
|
67
62
|
operators: ["isAny", "isNone"]
|
|
68
63
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/author/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type { MediaItem } from '../types';\nimport AuthorView from './view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Partial< Field< MediaItem > > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords< Author >(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\twho: 'authors',\n\t\t\t\t\t_fields: 'id,name',\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\trender: AuthorView,\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAmB;AACnB,kBAA8B;AAC9B,uBAAuC;AAEvC,kBAAuB;AAOvB,IAAM,cAA6C;AAAA,EAClD,WAAO,gBAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,UAAM,2BAAe,iBAAAA,KAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,QAAQ,YAAAC;AAAA,EACR,
|
|
4
|
+
"sourcesContent": ["import type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type { MediaItem } from '../types';\nimport AuthorView from './view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Partial< Field< MediaItem > > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords< Author >(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\twho: 'authors',\n\t\t\t\t\t_fields: 'id,name',\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\trender: AuthorView,\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n\treadOnly: true,\n};\n\nexport default authorField;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAmB;AACnB,kBAA8B;AAC9B,uBAAuC;AAEvC,kBAAuB;AAOvB,IAAM,cAA6C;AAAA,EAClD,WAAO,gBAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,UAAM,2BAAe,iBAAAA,KAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,QAAQ,YAAAC;AAAA,EACR,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": ["coreDataStore", "AuthorView"]
|
|
7
7
|
}
|
package/build/caption/index.cjs
CHANGED
|
@@ -24,25 +24,16 @@ __export(caption_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(caption_exports);
|
|
26
26
|
var import_i18n = require("@wordpress/i18n");
|
|
27
|
-
var import_components = require("@wordpress/components");
|
|
28
27
|
var import_get_raw_content = require("../utils/get-raw-content.cjs");
|
|
29
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
28
|
var captionField = {
|
|
31
29
|
id: "caption",
|
|
32
30
|
type: "text",
|
|
33
31
|
label: (0, import_i18n.__)("Caption"),
|
|
34
32
|
getValue: ({ item }) => (0, import_get_raw_content.getRawContent)(item?.caption),
|
|
35
33
|
render: ({ item }) => (0, import_get_raw_content.getRawContent)(item?.caption) || "-",
|
|
36
|
-
Edit:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
label: field.label,
|
|
41
|
-
value: (0, import_get_raw_content.getRawContent)(data.caption) || "",
|
|
42
|
-
onChange: (value) => onChange({ caption: value }),
|
|
43
|
-
rows: 2
|
|
44
|
-
}
|
|
45
|
-
);
|
|
34
|
+
Edit: {
|
|
35
|
+
control: "textarea",
|
|
36
|
+
rows: 2
|
|
46
37
|
},
|
|
47
38
|
enableSorting: false,
|
|
48
39
|
filterBy: false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/caption/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst captionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'caption',\n\ttype: 'text',\n\tlabel: __( 'Caption' ),\n\tgetValue: ( { item } ) => getRawContent( item?.caption ),\n\trender: ( { item } ) => getRawContent( item?.caption ) || '-',\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 2,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default captionField;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AAGnB,6BAA8B;AAE9B,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,SAAU;AAAA,EACrB,UAAU,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,OAAQ;AAAA,EACvD,QAAQ,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,OAAQ,KAAK;AAAA,EAC1D,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,kBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -24,7 +24,6 @@ __export(description_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(description_exports);
|
|
26
26
|
var import_i18n = require("@wordpress/i18n");
|
|
27
|
-
var import_components = require("@wordpress/components");
|
|
28
27
|
var import_get_raw_content = require("../utils/get-raw-content.cjs");
|
|
29
28
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
29
|
var descriptionField = {
|
|
@@ -33,16 +32,9 @@ var descriptionField = {
|
|
|
33
32
|
label: (0, import_i18n.__)("Description"),
|
|
34
33
|
getValue: ({ item }) => (0, import_get_raw_content.getRawContent)(item?.description),
|
|
35
34
|
render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: (0, import_get_raw_content.getRawContent)(item?.description) || "-" }),
|
|
36
|
-
Edit:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
label: field.label,
|
|
41
|
-
value: (0, import_get_raw_content.getRawContent)(data.description) || "",
|
|
42
|
-
onChange: (value) => onChange({ description: value }),
|
|
43
|
-
rows: 5
|
|
44
|
-
}
|
|
45
|
-
);
|
|
35
|
+
Edit: {
|
|
36
|
+
control: "textarea",
|
|
37
|
+
rows: 5
|
|
46
38
|
},
|
|
47
39
|
enableSorting: false,
|
|
48
40
|
filterBy: false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/description/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst descriptionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'description',\n\ttype: 'text',\n\tlabel: __( 'Description' ),\n\tgetValue: ( { item } ) => getRawContent( item?.description ),\n\trender: ( { item } ) => (\n\t\t<div>{ getRawContent( item?.description ) || '-' }</div>\n\t),\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 5,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default descriptionField;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AAGnB,6BAA8B;AAQ5B;AANF,IAAM,mBAAgE;AAAA,EACrE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,aAAc;AAAA,EACzB,UAAU,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,WAAY;AAAA,EAC3D,QAAQ,CAAE,EAAE,KAAK,MAChB,4CAAC,SAAM,oDAAe,MAAM,WAAY,KAAK,KAAK;AAAA,EAEnD,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,sBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/media_dimensions/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { __, _x, sprintf } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\n\nconst mediaDimensionsField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'media_dimensions',\n\ttype: 'text',\n\tlabel: __( 'Dimensions' ),\n\tgetValue: ( { item } ) =>\n\t\titem?.media_details?.width && item?.media_details?.height\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: 1: Width. 2: Height.\n\t\t\t\t\t_x( '%1$s × %2$s', 'image dimensions' ),\n\t\t\t\t\titem?.media_details?.width?.toString(),\n\t\t\t\t\titem?.media_details?.height?.toString()\n\t\t\t
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgC;AAIhC,IAAM,uBAAoE;AAAA,EACzE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,YAAa;AAAA,EACxB,UAAU,CAAE,EAAE,KAAK,MAClB,MAAM,eAAe,SAAS,MAAM,eAAe,aAChD;AAAA;AAAA,QAEA,gBAAI,eAAe,kBAAmB;AAAA,IACtC,MAAM,eAAe,OAAO,SAAS;AAAA,IACrC,MAAM,eAAe,QAAQ,SAAS;AAAA,
|
|
4
|
+
"sourcesContent": ["import { __, _x, sprintf } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\n\nconst mediaDimensionsField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'media_dimensions',\n\ttype: 'text',\n\tlabel: __( 'Dimensions' ),\n\tgetValue: ( { item } ) =>\n\t\titem?.media_details?.width && item?.media_details?.height\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: 1: Width. 2: Height.\n\t\t\t\t\t_x( '%1$s × %2$s', 'image dimensions' ),\n\t\t\t\t\titem?.media_details?.width?.toString(),\n\t\t\t\t\titem?.media_details?.height?.toString()\n\t\t\t\t)\n\t\t\t: '',\n\tisVisible: ( item ) => {\n\t\treturn !! ( item?.media_details?.width && item?.media_details?.height );\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n\treadOnly: true,\n};\n\nexport default mediaDimensionsField;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgC;AAIhC,IAAM,uBAAoE;AAAA,EACzE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,YAAa;AAAA,EACxB,UAAU,CAAE,EAAE,KAAK,MAClB,MAAM,eAAe,SAAS,MAAM,eAAe,aAChD;AAAA;AAAA,QAEA,gBAAI,eAAe,kBAAmB;AAAA,IACtC,MAAM,eAAe,OAAO,SAAS;AAAA,IACrC,MAAM,eAAe,QAAQ,SAAS;AAAA,EACvC,IACC;AAAA,EACJ,WAAW,CAAE,SAAU;AACtB,WAAO,CAAC,EAAI,MAAM,eAAe,SAAS,MAAM,eAAe;AAAA,EAChE;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AACX;AAEA,IAAO,2BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,41 +1,33 @@
|
|
|
1
1
|
// packages/media-fields/src/alt_text/index.tsx
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
import { TextareaControl as WCTextareaControl } from "@wordpress/components";
|
|
4
3
|
import { Link } from "@wordpress/ui";
|
|
5
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
var altTextField = {
|
|
7
6
|
id: "alt_text",
|
|
8
7
|
type: "text",
|
|
9
8
|
label: __("Alt text"),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return /* @__PURE__ */ jsx(
|
|
14
|
-
WCTextareaControl,
|
|
9
|
+
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10
|
+
/* @__PURE__ */ jsx(
|
|
11
|
+
Link,
|
|
15
12
|
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
] }),
|
|
36
|
-
rows: 2
|
|
13
|
+
href: (
|
|
14
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
15
|
+
__(
|
|
16
|
+
"https://www.w3.org/WAI/tutorials/images/decision-tree/"
|
|
17
|
+
)
|
|
18
|
+
),
|
|
19
|
+
openInNewTab: true,
|
|
20
|
+
children: __("Describe the purpose of the image.")
|
|
37
21
|
}
|
|
38
|
-
)
|
|
22
|
+
),
|
|
23
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
24
|
+
__("Leave empty if decorative.")
|
|
25
|
+
] }),
|
|
26
|
+
isVisible: (item) => item?.media_type === "image",
|
|
27
|
+
render: ({ item }) => item?.alt_text || "-",
|
|
28
|
+
Edit: {
|
|
29
|
+
control: "textarea",
|
|
30
|
+
rows: 2
|
|
39
31
|
},
|
|
40
32
|
enableSorting: false,
|
|
41
33
|
filterBy: false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/alt_text/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport {
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\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\tdescription: (\n\t\t<>\n\t\t\t<Link\n\t\t\t\thref={\n\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__(\n\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\topenInNewTab\n\t\t\t>\n\t\t\t\t{ __( 'Describe the purpose of the image.' ) }\n\t\t\t</Link>\n\t\t\t<br />\n\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t</>\n\t),\n\tisVisible: ( item ) => item?.media_type === 'image',\n\trender: ( { item } ) => item?.alt_text || '-',\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 2,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default altTextField;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,YAAY;AASnB,mBACC,KADD;AALF,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,UAAW;AAAA,EACtB,aACC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA;AAAA,UAEC;AAAA,YACC;AAAA,UACD;AAAA;AAAA,QAED,cAAY;AAAA,QAEV,aAAI,oCAAqC;AAAA;AAAA,IAC5C;AAAA,IACA,oBAAC,QAAG;AAAA,IACF,GAAI,4BAA6B;AAAA,KACpC;AAAA,EAED,WAAW,CAAE,SAAU,MAAM,eAAe;AAAA,EAC5C,QAAQ,CAAE,EAAE,KAAK,MAAO,MAAM,YAAY;AAAA,EAC1C,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;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": ["import {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { ComboboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDebounce, useEvent } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\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
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACC,sCAAsC;AAAA,EACtC,SAAS;AAAA,OACH;AACP,SAAS,uBAAuB;AAChC,SAAS,UAAU;AACnB,SAAS,gBAAgB;AACzB,SAAS,aAAa,gBAAgB;AACtC,SAAS,iBAAiB;AAG1B,SAAS,0BAA0B;AA0IjC;AAjHa,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,
|
|
4
|
+
"sourcesContent": ["import {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { ComboboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDebounce, useEvent } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\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\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};\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// `onValueChange` closes over state, so it's wrapped in `useEvent` to give\n\t// `useDebounce` a stable function. Debouncing an inline function instead\n\t// rebuilds the timer on every render, so nothing is debounced and each\n\t// keystroke fires its own request.\n\tconst debouncedValueChange = useDebounce( useEvent( onValueChange ), 300 );\n\n\t/**\n\t * Handle selection.\n\t *\n\t * @param {Object} selectedPostId The selected post id.\n\t */\n\tconst handleSelectOption = ( selectedPostId: string | null ) => {\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\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={ __( 'Attach this file to a single post or page.' ) }\n\t\t\tvalue={ value }\n\t\t\toptions={ options }\n\t\t\tonFilterValueChange={ ( filterValue: unknown ) =>\n\t\t\t\tdebouncedValueChange( filterValue as string )\n\t\t\t}\n\t\t\tonChange={ handleSelectOption }\n\t\t\thideLabelFromVision\n\t\t\t// Opening the panel shouldn't imply the user has decided to change\n\t\t\t// the attachment, so wait for them to search before showing the list.\n\t\t\texpandOnFocus={ false }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,11 +24,6 @@ var authorField = {
|
|
|
24
24
|
}));
|
|
25
25
|
},
|
|
26
26
|
render: AuthorView,
|
|
27
|
-
sort: (a, b, direction) => {
|
|
28
|
-
const nameA = a._embedded?.author?.[0]?.name || "";
|
|
29
|
-
const nameB = b._embedded?.author?.[0]?.name || "";
|
|
30
|
-
return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
|
|
31
|
-
},
|
|
32
27
|
filterBy: {
|
|
33
28
|
operators: ["isAny", "isNone"]
|
|
34
29
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/author/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type { MediaItem } from '../types';\nimport AuthorView from './view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Partial< Field< MediaItem > > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords< Author >(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\twho: 'authors',\n\t\t\t\t\t_fields: 'id,name',\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\trender: AuthorView,\n\
|
|
5
|
-
"mappings": ";AACA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,qBAAqB;AAEvC,OAAO,gBAAgB;AAOvB,IAAM,cAA6C;AAAA,EAClD,OAAO,GAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,MAAM,cAAe,aAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,QAAQ;AAAA,EACR,
|
|
4
|
+
"sourcesContent": ["import type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type { MediaItem } from '../types';\nimport AuthorView from './view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Partial< Field< MediaItem > > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords< Author >(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\twho: 'authors',\n\t\t\t\t\t_fields: 'id,name',\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\trender: AuthorView,\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n\treadOnly: true,\n};\n\nexport default authorField;\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,qBAAqB;AAEvC,OAAO,gBAAgB;AAOvB,IAAM,cAA6C;AAAA,EAClD,OAAO,GAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,MAAM,cAAe,aAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
// packages/media-fields/src/caption/index.tsx
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
import { TextareaControl as WCTextareaControl } from "@wordpress/components";
|
|
4
3
|
import { getRawContent } from "../utils/get-raw-content.mjs";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
4
|
var captionField = {
|
|
7
5
|
id: "caption",
|
|
8
6
|
type: "text",
|
|
9
7
|
label: __("Caption"),
|
|
10
8
|
getValue: ({ item }) => getRawContent(item?.caption),
|
|
11
9
|
render: ({ item }) => getRawContent(item?.caption) || "-",
|
|
12
|
-
Edit:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
label: field.label,
|
|
17
|
-
value: getRawContent(data.caption) || "",
|
|
18
|
-
onChange: (value) => onChange({ caption: value }),
|
|
19
|
-
rows: 2
|
|
20
|
-
}
|
|
21
|
-
);
|
|
10
|
+
Edit: {
|
|
11
|
+
control: "textarea",
|
|
12
|
+
rows: 2
|
|
22
13
|
},
|
|
23
14
|
enableSorting: false,
|
|
24
15
|
filterBy: false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/caption/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst captionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'caption',\n\ttype: 'text',\n\tlabel: __( 'Caption' ),\n\tgetValue: ( { item } ) => getRawContent( item?.caption ),\n\trender: ( { item } ) => getRawContent( item?.caption ) || '-',\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 2,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default captionField;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AAGnB,SAAS,qBAAqB;AAE9B,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,SAAU;AAAA,EACrB,UAAU,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,OAAQ;AAAA,EACvD,QAAQ,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,OAAQ,KAAK;AAAA,EAC1D,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,kBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// packages/media-fields/src/description/index.tsx
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
import { TextareaControl as WCTextareaControl } from "@wordpress/components";
|
|
4
3
|
import { getRawContent } from "../utils/get-raw-content.mjs";
|
|
5
4
|
import { jsx } from "react/jsx-runtime";
|
|
6
5
|
var descriptionField = {
|
|
@@ -9,16 +8,9 @@ var descriptionField = {
|
|
|
9
8
|
label: __("Description"),
|
|
10
9
|
getValue: ({ item }) => getRawContent(item?.description),
|
|
11
10
|
render: ({ item }) => /* @__PURE__ */ jsx("div", { children: getRawContent(item?.description) || "-" }),
|
|
12
|
-
Edit:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
label: field.label,
|
|
17
|
-
value: getRawContent(data.description) || "",
|
|
18
|
-
onChange: (value) => onChange({ description: value }),
|
|
19
|
-
rows: 5
|
|
20
|
-
}
|
|
21
|
-
);
|
|
11
|
+
Edit: {
|
|
12
|
+
control: "textarea",
|
|
13
|
+
rows: 5
|
|
22
14
|
},
|
|
23
15
|
enableSorting: false,
|
|
24
16
|
filterBy: false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/description/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst descriptionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'description',\n\ttype: 'text',\n\tlabel: __( 'Description' ),\n\tgetValue: ( { item } ) => getRawContent( item?.description ),\n\trender: ( { item } ) => (\n\t\t<div>{ getRawContent( item?.description ) || '-' }</div>\n\t),\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 5,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default descriptionField;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AAGnB,SAAS,qBAAqB;AAQ5B;AANF,IAAM,mBAAgE;AAAA,EACrE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,aAAc;AAAA,EACzB,UAAU,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,WAAY;AAAA,EAC3D,QAAQ,CAAE,EAAE,KAAK,MAChB,oBAAC,SAAM,wBAAe,MAAM,WAAY,KAAK,KAAK;AAAA,EAEnD,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/media_dimensions/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { __, _x, sprintf } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\n\nconst mediaDimensionsField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'media_dimensions',\n\ttype: 'text',\n\tlabel: __( 'Dimensions' ),\n\tgetValue: ( { item } ) =>\n\t\titem?.media_details?.width && item?.media_details?.height\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: 1: Width. 2: Height.\n\t\t\t\t\t_x( '%1$s × %2$s', 'image dimensions' ),\n\t\t\t\t\titem?.media_details?.width?.toString(),\n\t\t\t\t\titem?.media_details?.height?.toString()\n\t\t\t
|
|
5
|
-
"mappings": ";AAAA,SAAS,IAAI,IAAI,eAAe;AAIhC,IAAM,uBAAoE;AAAA,EACzE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,YAAa;AAAA,EACxB,UAAU,CAAE,EAAE,KAAK,MAClB,MAAM,eAAe,SAAS,MAAM,eAAe,SAChD;AAAA;AAAA,IAEA,GAAI,eAAe,kBAAmB;AAAA,IACtC,MAAM,eAAe,OAAO,SAAS;AAAA,IACrC,MAAM,eAAe,QAAQ,SAAS;AAAA,
|
|
4
|
+
"sourcesContent": ["import { __, _x, sprintf } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\n\nconst mediaDimensionsField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'media_dimensions',\n\ttype: 'text',\n\tlabel: __( 'Dimensions' ),\n\tgetValue: ( { item } ) =>\n\t\titem?.media_details?.width && item?.media_details?.height\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: 1: Width. 2: Height.\n\t\t\t\t\t_x( '%1$s × %2$s', 'image dimensions' ),\n\t\t\t\t\titem?.media_details?.width?.toString(),\n\t\t\t\t\titem?.media_details?.height?.toString()\n\t\t\t\t)\n\t\t\t: '',\n\tisVisible: ( item ) => {\n\t\treturn !! ( item?.media_details?.width && item?.media_details?.height );\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n\treadOnly: true,\n};\n\nexport default mediaDimensionsField;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,IAAI,IAAI,eAAe;AAIhC,IAAM,uBAAoE;AAAA,EACzE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,YAAa;AAAA,EACxB,UAAU,CAAE,EAAE,KAAK,MAClB,MAAM,eAAe,SAAS,MAAM,eAAe,SAChD;AAAA;AAAA,IAEA,GAAI,eAAe,kBAAmB;AAAA,IACtC,MAAM,eAAe,OAAO,SAAS;AAAA,IACrC,MAAM,eAAe,QAAQ,SAAS;AAAA,EACvC,IACC;AAAA,EACJ,WAAW,CAAE,SAAU;AACtB,WAAO,CAAC,EAAI,MAAM,eAAe,SAAS,MAAM,eAAe;AAAA,EAChE;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AACX;AAEA,IAAO,2BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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":"AAEA,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,CA6B5D,CAAC;eAEa,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/author/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAIlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAQ1C,QAAA,MAAM,WAAW,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/author/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAIlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAQ1C,QAAA,MAAM,WAAW,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CA0B7C,CAAC;eAEa,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/caption/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/caption/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,QAAA,MAAM,YAAY,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAY5D,CAAC;eAEa,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/description/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/description/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,QAAA,MAAM,gBAAgB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAchE,CAAC;eAEa,gBAAgB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/media-fields",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1-next.v.202609171837.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,25 +48,24 @@
|
|
|
48
48
|
"src/**/*.scss"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@wordpress/base-styles": "^13.
|
|
52
|
-
"@wordpress/components": "^
|
|
53
|
-
"@wordpress/compose": "^8.
|
|
54
|
-
"@wordpress/core-data": "^8.0.
|
|
55
|
-
"@wordpress/data": "^10.
|
|
56
|
-
"@wordpress/dataviews": "^19.0.
|
|
57
|
-
"@wordpress/element": "^8.
|
|
58
|
-
"@wordpress/i18n": "^6.
|
|
59
|
-
"@wordpress/icons": "^
|
|
60
|
-
"@wordpress/ui": "^0.
|
|
61
|
-
"@wordpress/url": "^4.
|
|
51
|
+
"@wordpress/base-styles": "^13.2.1-next.v.202609171837.0",
|
|
52
|
+
"@wordpress/components": "^41.0.1-next.v.202609171837.0",
|
|
53
|
+
"@wordpress/compose": "^8.8.2-next.v.202609171837.0",
|
|
54
|
+
"@wordpress/core-data": "^8.0.2-next.v.202609171837.0",
|
|
55
|
+
"@wordpress/data": "^10.56.1-next.v.202609171837.0",
|
|
56
|
+
"@wordpress/dataviews": "^19.0.2-next.v.202609171837.0",
|
|
57
|
+
"@wordpress/element": "^8.7.1-next.v.202609171837.0",
|
|
58
|
+
"@wordpress/i18n": "^6.28.1-next.v.202609171837.0",
|
|
59
|
+
"@wordpress/icons": "^17.0.1-next.v.202609171837.0",
|
|
60
|
+
"@wordpress/ui": "^0.23.1-next.v.202609171837.0",
|
|
61
|
+
"@wordpress/url": "^4.55.1-next.v.202609171837.0",
|
|
62
62
|
"clsx": "^2.1.1"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@testing-library/dom": "^10.4.1",
|
|
66
|
-
"@testing-library/jest-dom": "^
|
|
67
|
-
"@testing-library/react": "^16.3.
|
|
68
|
-
"
|
|
69
|
-
"vitest": "^4.1.10"
|
|
66
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
67
|
+
"@testing-library/react": "^16.3.3",
|
|
68
|
+
"vitest": "^5.0.0"
|
|
70
69
|
},
|
|
71
70
|
"peerDependencies": {
|
|
72
71
|
"@types/react": "^18 || ^19",
|
|
@@ -80,5 +79,5 @@
|
|
|
80
79
|
"publishConfig": {
|
|
81
80
|
"access": "public"
|
|
82
81
|
},
|
|
83
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "7fc9f6676debc888d2f071d17cb71837040d4b48"
|
|
84
83
|
}
|
package/src/alt_text/index.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
|
-
import { TextareaControl as WCTextareaControl } from '@wordpress/components';
|
|
3
2
|
import { Link } from '@wordpress/ui';
|
|
4
3
|
import type { Field } from '@wordpress/dataviews';
|
|
5
4
|
import type { Attachment, Updatable } from '@wordpress/core-data';
|
|
@@ -8,34 +7,28 @@ const altTextField: Partial< Field< Updatable< Attachment > > > = {
|
|
|
8
7
|
id: 'alt_text',
|
|
9
8
|
type: 'text',
|
|
10
9
|
label: __( 'Alt text' ),
|
|
10
|
+
description: (
|
|
11
|
+
<>
|
|
12
|
+
<Link
|
|
13
|
+
href={
|
|
14
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
15
|
+
__(
|
|
16
|
+
'https://www.w3.org/WAI/tutorials/images/decision-tree/'
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
openInNewTab
|
|
20
|
+
>
|
|
21
|
+
{ __( 'Describe the purpose of the image.' ) }
|
|
22
|
+
</Link>
|
|
23
|
+
<br />
|
|
24
|
+
{ __( 'Leave empty if decorative.' ) }
|
|
25
|
+
</>
|
|
26
|
+
),
|
|
11
27
|
isVisible: ( item ) => item?.media_type === 'image',
|
|
12
28
|
render: ( { item } ) => item?.alt_text || '-',
|
|
13
|
-
Edit:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
label={ field.label }
|
|
17
|
-
value={ data.alt_text || '' }
|
|
18
|
-
onChange={ ( value ) => onChange( { alt_text: value } ) }
|
|
19
|
-
help={
|
|
20
|
-
<>
|
|
21
|
-
<Link
|
|
22
|
-
href={
|
|
23
|
-
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
24
|
-
__(
|
|
25
|
-
'https://www.w3.org/WAI/tutorials/images/decision-tree/'
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
openInNewTab
|
|
29
|
-
>
|
|
30
|
-
{ __( 'Describe the purpose of the image.' ) }
|
|
31
|
-
</Link>
|
|
32
|
-
<br />
|
|
33
|
-
{ __( 'Leave empty if decorative.' ) }
|
|
34
|
-
</>
|
|
35
|
-
}
|
|
36
|
-
rows={ 2 }
|
|
37
|
-
/>
|
|
38
|
-
);
|
|
29
|
+
Edit: {
|
|
30
|
+
control: 'textarea',
|
|
31
|
+
rows: 2,
|
|
39
32
|
},
|
|
40
33
|
enableSorting: false,
|
|
41
34
|
filterBy: false,
|
package/src/attached_to/edit.tsx
CHANGED
package/src/author/index.tsx
CHANGED
|
@@ -32,14 +32,6 @@ const authorField: Partial< Field< MediaItem > > = {
|
|
|
32
32
|
} ) );
|
|
33
33
|
},
|
|
34
34
|
render: AuthorView,
|
|
35
|
-
sort: ( a, b, direction ) => {
|
|
36
|
-
const nameA = a._embedded?.author?.[ 0 ]?.name || '';
|
|
37
|
-
const nameB = b._embedded?.author?.[ 0 ]?.name || '';
|
|
38
|
-
|
|
39
|
-
return direction === 'asc'
|
|
40
|
-
? nameA.localeCompare( nameB )
|
|
41
|
-
: nameB.localeCompare( nameA );
|
|
42
|
-
},
|
|
43
35
|
filterBy: {
|
|
44
36
|
operators: [ 'isAny', 'isNone' ],
|
|
45
37
|
},
|
package/src/caption/index.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
|
-
import { TextareaControl as WCTextareaControl } from '@wordpress/components';
|
|
3
2
|
import type { Attachment, Updatable } from '@wordpress/core-data';
|
|
4
3
|
import type { Field } from '@wordpress/dataviews';
|
|
5
4
|
import { getRawContent } from '../utils/get-raw-content';
|
|
@@ -10,15 +9,9 @@ const captionField: Partial< Field< Updatable< Attachment > > > = {
|
|
|
10
9
|
label: __( 'Caption' ),
|
|
11
10
|
getValue: ( { item } ) => getRawContent( item?.caption ),
|
|
12
11
|
render: ( { item } ) => getRawContent( item?.caption ) || '-',
|
|
13
|
-
Edit:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
label={ field.label }
|
|
17
|
-
value={ getRawContent( data.caption ) || '' }
|
|
18
|
-
onChange={ ( value ) => onChange( { caption: value } ) }
|
|
19
|
-
rows={ 2 }
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
12
|
+
Edit: {
|
|
13
|
+
control: 'textarea',
|
|
14
|
+
rows: 2,
|
|
22
15
|
},
|
|
23
16
|
enableSorting: false,
|
|
24
17
|
filterBy: false,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
|
-
import { TextareaControl as WCTextareaControl } from '@wordpress/components';
|
|
3
2
|
import type { Attachment, Updatable } from '@wordpress/core-data';
|
|
4
3
|
import type { Field } from '@wordpress/dataviews';
|
|
5
4
|
import { getRawContent } from '../utils/get-raw-content';
|
|
@@ -12,15 +11,9 @@ const descriptionField: Partial< Field< Updatable< Attachment > > > = {
|
|
|
12
11
|
render: ( { item } ) => (
|
|
13
12
|
<div>{ getRawContent( item?.description ) || '-' }</div>
|
|
14
13
|
),
|
|
15
|
-
Edit:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
label={ field.label }
|
|
19
|
-
value={ getRawContent( data.description ) || '' }
|
|
20
|
-
onChange={ ( value ) => onChange( { description: value } ) }
|
|
21
|
-
rows={ 5 }
|
|
22
|
-
/>
|
|
23
|
-
);
|
|
14
|
+
Edit: {
|
|
15
|
+
control: 'textarea',
|
|
16
|
+
rows: 5,
|
|
24
17
|
},
|
|
25
18
|
enableSorting: false,
|
|
26
19
|
filterBy: false,
|
|
@@ -13,7 +13,7 @@ const mediaDimensionsField: Partial< Field< Updatable< Attachment > > > = {
|
|
|
13
13
|
_x( '%1$s × %2$s', 'image dimensions' ),
|
|
14
14
|
item?.media_details?.width?.toString(),
|
|
15
15
|
item?.media_details?.height?.toString()
|
|
16
|
-
|
|
16
|
+
)
|
|
17
17
|
: '',
|
|
18
18
|
isVisible: ( item ) => {
|
|
19
19
|
return !! ( item?.media_details?.width && item?.media_details?.height );
|