@wordpress/media-editor 0.2.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/LICENSE.md +788 -0
- package/README.md +121 -0
- package/build/components/media-editor-provider/index.cjs +59 -0
- package/build/components/media-editor-provider/index.cjs.map +7 -0
- package/build/components/media-form/index.cjs +71 -0
- package/build/components/media-form/index.cjs.map +7 -0
- package/build/components/media-preview/index.cjs +119 -0
- package/build/components/media-preview/index.cjs.map +7 -0
- package/build/index.cjs +47 -0
- package/build/index.cjs.map +7 -0
- package/build/utils/get-media-type.cjs +45 -0
- package/build/utils/get-media-type.cjs.map +7 -0
- package/build/utils/index.cjs +31 -0
- package/build/utils/index.cjs.map +7 -0
- package/build-module/components/media-editor-provider/index.mjs +33 -0
- package/build-module/components/media-editor-provider/index.mjs.map +7 -0
- package/build-module/components/media-form/index.mjs +50 -0
- package/build-module/components/media-form/index.mjs.map +7 -0
- package/build-module/components/media-preview/index.mjs +98 -0
- package/build-module/components/media-preview/index.mjs.map +7 -0
- package/build-module/index.mjs +10 -0
- package/build-module/index.mjs.map +7 -0
- package/build-module/utils/get-media-type.mjs +20 -0
- package/build-module/utils/get-media-type.mjs.map +7 -0
- package/build-module/utils/index.mjs +6 -0
- package/build-module/utils/index.mjs.map +7 -0
- package/build-style/style-rtl.css +127 -0
- package/build-style/style.css +127 -0
- package/build-types/components/media-editor-provider/index.d.ts +62 -0
- package/build-types/components/media-editor-provider/index.d.ts.map +1 -0
- package/build-types/components/media-form/index.d.ts +22 -0
- package/build-types/components/media-form/index.d.ts.map +1 -0
- package/build-types/components/media-preview/index.d.ts +15 -0
- package/build-types/components/media-preview/index.d.ts.map +1 -0
- package/build-types/index.d.ts +8 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/utils/get-media-type.d.ts +14 -0
- package/build-types/utils/get-media-type.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/package.json +57 -0
- package/src/components/media-editor-provider/index.tsx +90 -0
- package/src/components/media-form/index.tsx +87 -0
- package/src/components/media-preview/index.tsx +154 -0
- package/src/components/media-preview/style.scss +89 -0
- package/src/index.ts +15 -0
- package/src/style.scss +2 -0
- package/src/utils/get-media-type.ts +29 -0
- package/src/utils/index.ts +2 -0
- package/tsconfig.json +13 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// packages/media-editor/src/components/media-form/index.tsx
|
|
2
|
+
import { DataForm } from "@wordpress/dataviews";
|
|
3
|
+
import { Spinner, __experimentalVStack as VStack } from "@wordpress/components";
|
|
4
|
+
import { useMediaEditorContext } from "../media-editor-provider/index.mjs";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
function MediaForm({
|
|
7
|
+
form: formOverrides,
|
|
8
|
+
header
|
|
9
|
+
}) {
|
|
10
|
+
const { media, fields, onChange } = useMediaEditorContext();
|
|
11
|
+
if (!media || !onChange) {
|
|
12
|
+
return /* @__PURE__ */ jsx("div", { className: "media-editor-form media-editor-form--loading", children: /* @__PURE__ */ jsx(Spinner, {}) });
|
|
13
|
+
}
|
|
14
|
+
const defaultForm = {
|
|
15
|
+
layout: {
|
|
16
|
+
type: "panel"
|
|
17
|
+
},
|
|
18
|
+
fields: fields.map((field) => {
|
|
19
|
+
if (["title", "alt_text", "caption", "description"].includes(
|
|
20
|
+
field.id
|
|
21
|
+
)) {
|
|
22
|
+
return {
|
|
23
|
+
id: field.id,
|
|
24
|
+
layout: {
|
|
25
|
+
type: "regular",
|
|
26
|
+
labelPosition: "top"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return field.id;
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
const form = formOverrides || defaultForm;
|
|
34
|
+
return /* @__PURE__ */ jsx("div", { className: "media-editor-form", children: /* @__PURE__ */ jsxs(VStack, { spacing: 4, children: [
|
|
35
|
+
header,
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
DataForm,
|
|
38
|
+
{
|
|
39
|
+
data: media,
|
|
40
|
+
fields,
|
|
41
|
+
form,
|
|
42
|
+
onChange
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
] }) });
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
MediaForm as default
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/media-form/index.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DataForm } from '@wordpress/dataviews';\nimport type { Form, Field } from '@wordpress/dataviews';\nimport { Spinner, __experimentalVStack as VStack } from '@wordpress/components';\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport type { Media } from '../media-editor-provider';\n\n/**\n * Props for MediaForm component.\n */\nexport interface MediaFormProps {\n\tform?: Form;\n\theader?: ReactNode;\n}\n\n/**\n * MediaForm component for editing media metadata.\n *\n * Renders a DataForm with fields for editing media properties like\n * title, alt text, caption, description, etc.\n *\n * @param props - Component props.\n * @param props.form - Optional form configuration.\n * @param props.header - Optional header content to display above the form.\n * @return The MediaForm component.\n */\nexport default function MediaForm( {\n\tform: formOverrides,\n\theader,\n}: MediaFormProps ) {\n\tconst { media, fields, onChange } = useMediaEditorContext();\n\n\tif ( ! media || ! onChange ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-form media-editor-form--loading\">\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Default form structure with panel layout\n\tconst defaultForm: Form = {\n\t\tlayout: {\n\t\t\ttype: 'panel',\n\t\t},\n\t\tfields: fields.map( ( field: Field< Media > ) => {\n\t\t\t// Use regular layout for main editable fields\n\t\t\tif (\n\t\t\t\t[ 'title', 'alt_text', 'caption', 'description' ].includes(\n\t\t\t\t\tfield.id\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\tid: field.id,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\ttype: 'regular',\n\t\t\t\t\t\tlabelPosition: 'top',\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn field.id;\n\t\t} ),\n\t};\n\n\tconst form = formOverrides || defaultForm;\n\n\treturn (\n\t\t<div className=\"media-editor-form\">\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t{ header }\n\t\t\t\t<DataForm\n\t\t\t\t\tdata={ media }\n\t\t\t\t\tfields={ fields }\n\t\t\t\t\tform={ form }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,gBAAgB;AAEzB,SAAS,SAAS,wBAAwB,cAAc;AAMxD,SAAS,6BAA6B;AA+BlC,cAiCD,YAjCC;AATW,SAAR,UAA4B;AAAA,EAClC,MAAM;AAAA,EACN;AACD,GAAoB;AACnB,QAAM,EAAE,OAAO,QAAQ,SAAS,IAAI,sBAAsB;AAE1D,MAAK,CAAE,SAAS,CAAE,UAAW;AAC5B,WACC,oBAAC,SAAI,WAAU,gDACd,8BAAC,WAAQ,GACV;AAAA,EAEF;AAGA,QAAM,cAAoB;AAAA,IACzB,QAAQ;AAAA,MACP,MAAM;AAAA,IACP;AAAA,IACA,QAAQ,OAAO,IAAK,CAAE,UAA2B;AAEhD,UACC,CAAE,SAAS,YAAY,WAAW,aAAc,EAAE;AAAA,QACjD,MAAM;AAAA,MACP,GACC;AACD,eAAO;AAAA,UACN,IAAI,MAAM;AAAA,UACV,QAAQ;AAAA,YACP,MAAM;AAAA,YACN,eAAe;AAAA,UAChB;AAAA,QACD;AAAA,MACD;AACA,aAAO,MAAM;AAAA,IACd,CAAE;AAAA,EACH;AAEA,QAAM,OAAO,iBAAiB;AAE9B,SACC,oBAAC,SAAI,WAAU,qBACd,+BAAC,UAAO,SAAU,GACf;AAAA;AAAA,IACF;AAAA,MAAC;AAAA;AAAA,QACA,MAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KACD,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// packages/media-editor/src/components/media-preview/index.tsx
|
|
2
|
+
import { Spinner } from "@wordpress/components";
|
|
3
|
+
import { useState } from "@wordpress/element";
|
|
4
|
+
import { __ } from "@wordpress/i18n";
|
|
5
|
+
import { useMediaEditorContext } from "../media-editor-provider/index.mjs";
|
|
6
|
+
import { getMediaTypeFromMimeType } from "../../utils/index.mjs";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
function MediaPreviewContent({
|
|
9
|
+
mediaType,
|
|
10
|
+
mediaUrl,
|
|
11
|
+
altText,
|
|
12
|
+
displayTitle,
|
|
13
|
+
mimeType,
|
|
14
|
+
onLoad,
|
|
15
|
+
onError,
|
|
16
|
+
loadingState
|
|
17
|
+
}) {
|
|
18
|
+
switch (mediaType.type) {
|
|
19
|
+
case "image":
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
"img",
|
|
22
|
+
{
|
|
23
|
+
className: loadingState === "loaded" ? "loaded" : "",
|
|
24
|
+
src: mediaUrl,
|
|
25
|
+
alt: altText || "",
|
|
26
|
+
onLoad,
|
|
27
|
+
onError
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
case "video":
|
|
31
|
+
return /* @__PURE__ */ jsx("video", { src: mediaUrl, controls: true, onError, children: displayTitle });
|
|
32
|
+
case "audio":
|
|
33
|
+
return /* @__PURE__ */ jsx("audio", { src: mediaUrl, controls: true, onError, children: displayTitle });
|
|
34
|
+
default:
|
|
35
|
+
return /* @__PURE__ */ jsxs("div", { className: "media-editor-preview__file-info", children: [
|
|
36
|
+
/* @__PURE__ */ jsx("p", { className: "media-editor-preview__file-name", children: displayTitle }),
|
|
37
|
+
/* @__PURE__ */ jsx("p", { className: "media-editor-preview__mime-type", children: mimeType }),
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
"a",
|
|
40
|
+
{
|
|
41
|
+
href: mediaUrl,
|
|
42
|
+
target: "_blank",
|
|
43
|
+
rel: "noopener noreferrer",
|
|
44
|
+
className: "media-editor-preview__download-link",
|
|
45
|
+
children: __("View file")
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
] });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function MediaPreview(props) {
|
|
52
|
+
const [loadingState, setLoadingState] = useState("loading");
|
|
53
|
+
const { media } = useMediaEditorContext();
|
|
54
|
+
const {
|
|
55
|
+
source_url: mediaUrl,
|
|
56
|
+
mime_type: mimeType,
|
|
57
|
+
alt_text: altText,
|
|
58
|
+
title
|
|
59
|
+
} = media || {};
|
|
60
|
+
const mediaType = getMediaTypeFromMimeType(mimeType);
|
|
61
|
+
if (!mediaUrl) {
|
|
62
|
+
return /* @__PURE__ */ jsx("div", { className: "media-editor-preview media-editor-preview--empty", children: /* @__PURE__ */ jsx("p", { children: __("No media file available.") }) });
|
|
63
|
+
}
|
|
64
|
+
if (loadingState === "error") {
|
|
65
|
+
return /* @__PURE__ */ jsxs("div", { className: "media-editor-preview media-editor-preview--error", children: [
|
|
66
|
+
/* @__PURE__ */ jsx("p", { children: __("Failed to load media file.") }),
|
|
67
|
+
/* @__PURE__ */ jsx("p", { className: "media-editor-preview__url", children: mediaUrl })
|
|
68
|
+
] });
|
|
69
|
+
}
|
|
70
|
+
const displayTitle = typeof title === "string" ? title : title?.rendered || title?.raw;
|
|
71
|
+
return /* @__PURE__ */ jsxs(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
...props,
|
|
75
|
+
className: `media-editor-preview media-editor-preview--${mediaType.type}`,
|
|
76
|
+
children: [
|
|
77
|
+
mediaType.type === "image" && loadingState === "loading" && /* @__PURE__ */ jsx("div", { className: "media-editor-preview__spinner", children: /* @__PURE__ */ jsx(Spinner, {}) }),
|
|
78
|
+
/* @__PURE__ */ jsx(
|
|
79
|
+
MediaPreviewContent,
|
|
80
|
+
{
|
|
81
|
+
mediaType,
|
|
82
|
+
mediaUrl,
|
|
83
|
+
altText,
|
|
84
|
+
displayTitle,
|
|
85
|
+
mimeType,
|
|
86
|
+
onLoad: () => setLoadingState("loaded"),
|
|
87
|
+
onError: () => setLoadingState("error"),
|
|
88
|
+
loadingState
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
MediaPreview as default
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/media-preview/index.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Spinner } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport { getMediaTypeFromMimeType } from '../../utils';\n\n/**\n * Props for MediaPreview component.\n */\nexport interface MediaPreviewProps {\n\t[ key: string ]: any; // TODO: Define specific props as needed, this will likely be for click handlers, accessibility attributes, etc.\n}\n\n/**\n * Props for MediaPreviewContent component.\n */\ninterface MediaPreviewContentProps {\n\tmediaType: { type: string };\n\tmediaUrl: string;\n\taltText?: string;\n\tdisplayTitle?: string;\n\tmimeType?: string;\n\tonLoad: () => void;\n\tonError: () => void;\n\tloadingState: 'loading' | 'loaded' | 'error';\n}\n\nfunction MediaPreviewContent( {\n\tmediaType,\n\tmediaUrl,\n\taltText,\n\tdisplayTitle,\n\tmimeType,\n\tonLoad,\n\tonError,\n\tloadingState,\n}: MediaPreviewContentProps ) {\n\tswitch ( mediaType.type ) {\n\t\tcase 'image':\n\t\t\treturn (\n\t\t\t\t<img\n\t\t\t\t\tclassName={ loadingState === 'loaded' ? 'loaded' : '' }\n\t\t\t\t\tsrc={ mediaUrl }\n\t\t\t\t\talt={ altText || '' }\n\t\t\t\t\tonLoad={ onLoad }\n\t\t\t\t\tonError={ onError }\n\t\t\t\t/>\n\t\t\t);\n\t\tcase 'video':\n\t\t\treturn (\n\t\t\t\t<video src={ mediaUrl } controls onError={ onError }>\n\t\t\t\t\t{ displayTitle }\n\t\t\t\t</video>\n\t\t\t);\n\t\tcase 'audio':\n\t\t\treturn (\n\t\t\t\t<audio src={ mediaUrl } controls onError={ onError }>\n\t\t\t\t\t{ displayTitle }\n\t\t\t\t</audio>\n\t\t\t);\n\t\tdefault:\n\t\t\treturn (\n\t\t\t\t<div className=\"media-editor-preview__file-info\">\n\t\t\t\t\t<p className=\"media-editor-preview__file-name\">\n\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t</p>\n\t\t\t\t\t<p className=\"media-editor-preview__mime-type\">\n\t\t\t\t\t\t{ mimeType }\n\t\t\t\t\t</p>\n\t\t\t\t\t<a\n\t\t\t\t\t\thref={ mediaUrl }\n\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\tclassName=\"media-editor-preview__download-link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'View file' ) }\n\t\t\t\t\t</a>\n\t\t\t\t</div>\n\t\t\t);\n\t}\n}\n\n/**\n * MediaPreview component displays the media file in the editor canvas.\n * Supports images, videos, audio files, and generic file displays.\n *\n * @param props - Component props including click handlers and accessibility attributes.\n * @return The MediaPreview component.\n */\nexport default function MediaPreview( props: MediaPreviewProps ) {\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'loading' | 'loaded' | 'error'\n\t>( 'loading' );\n\tconst { media } = useMediaEditorContext();\n\n\tconst {\n\t\tsource_url: mediaUrl,\n\t\tmime_type: mimeType,\n\t\talt_text: altText,\n\t\ttitle,\n\t} = media || {};\n\n\tconst mediaType = getMediaTypeFromMimeType( mimeType );\n\n\tif ( ! mediaUrl ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-preview media-editor-preview--empty\">\n\t\t\t\t<p>{ __( 'No media file available.' ) }</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( loadingState === 'error' ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-preview media-editor-preview--error\">\n\t\t\t\t<p>{ __( 'Failed to load media file.' ) }</p>\n\t\t\t\t<p className=\"media-editor-preview__url\">{ mediaUrl }</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst displayTitle =\n\t\ttypeof title === 'string' ? title : title?.rendered || title?.raw;\n\n\treturn (\n\t\t<div\n\t\t\t{ ...props }\n\t\t\tclassName={ `media-editor-preview media-editor-preview--${ mediaType.type }` }\n\t\t>\n\t\t\t{ mediaType.type === 'image' && loadingState === 'loading' && (\n\t\t\t\t<div className=\"media-editor-preview__spinner\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<MediaPreviewContent\n\t\t\t\tmediaType={ mediaType }\n\t\t\t\tmediaUrl={ mediaUrl }\n\t\t\t\taltText={ altText }\n\t\t\t\tdisplayTitle={ displayTitle }\n\t\t\t\tmimeType={ mimeType }\n\t\t\t\tonLoad={ () => setLoadingState( 'loaded' ) }\n\t\t\t\tonError={ () => setLoadingState( 'error' ) }\n\t\t\t\tloadingState={ loadingState }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,UAAU;AAKnB,SAAS,6BAA6B;AACtC,SAAS,gCAAgC;AAoCrC,cAsBA,YAtBA;AAbJ,SAAS,oBAAqB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA8B;AAC7B,UAAS,UAAU,MAAO;AAAA,IACzB,KAAK;AACJ,aACC;AAAA,QAAC;AAAA;AAAA,UACA,WAAY,iBAAiB,WAAW,WAAW;AAAA,UACnD,KAAM;AAAA,UACN,KAAM,WAAW;AAAA,UACjB;AAAA,UACA;AAAA;AAAA,MACD;AAAA,IAEF,KAAK;AACJ,aACC,oBAAC,WAAM,KAAM,UAAW,UAAQ,MAAC,SAC9B,wBACH;AAAA,IAEF,KAAK;AACJ,aACC,oBAAC,WAAM,KAAM,UAAW,UAAQ,MAAC,SAC9B,wBACH;AAAA,IAEF;AACC,aACC,qBAAC,SAAI,WAAU,mCACd;AAAA,4BAAC,OAAE,WAAU,mCACV,wBACH;AAAA,QACA,oBAAC,OAAE,WAAU,mCACV,oBACH;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,MAAO;AAAA,YACP,QAAO;AAAA,YACP,KAAI;AAAA,YACJ,WAAU;AAAA,YAER,aAAI,WAAY;AAAA;AAAA,QACnB;AAAA,SACD;AAAA,EAEH;AACD;AASe,SAAR,aAA+B,OAA2B;AAChE,QAAM,CAAE,cAAc,eAAgB,IAAI,SAEvC,SAAU;AACb,QAAM,EAAE,MAAM,IAAI,sBAAsB;AAExC,QAAM;AAAA,IACL,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,UAAU;AAAA,IACV;AAAA,EACD,IAAI,SAAS,CAAC;AAEd,QAAM,YAAY,yBAA0B,QAAS;AAErD,MAAK,CAAE,UAAW;AACjB,WACC,oBAAC,SAAI,WAAU,oDACd,8BAAC,OAAI,aAAI,0BAA2B,GAAG,GACxC;AAAA,EAEF;AAEA,MAAK,iBAAiB,SAAU;AAC/B,WACC,qBAAC,SAAI,WAAU,oDACd;AAAA,0BAAC,OAAI,aAAI,4BAA6B,GAAG;AAAA,MACzC,oBAAC,OAAE,WAAU,6BAA8B,oBAAU;AAAA,OACtD;AAAA,EAEF;AAEA,QAAM,eACL,OAAO,UAAU,WAAW,QAAQ,OAAO,YAAY,OAAO;AAE/D,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,WAAY,8CAA+C,UAAU,IAAK;AAAA,MAExE;AAAA,kBAAU,SAAS,WAAW,iBAAiB,aAChD,oBAAC,SAAI,WAAU,iCACd,8BAAC,WAAQ,GACV;AAAA,QAED;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,QAAS,MAAM,gBAAiB,QAAS;AAAA,YACzC,SAAU,MAAM,gBAAiB,OAAQ;AAAA,YACzC;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// packages/media-editor/src/index.ts
|
|
2
|
+
import { MediaEditorProvider } from "./components/media-editor-provider/index.mjs";
|
|
3
|
+
import { default as default2 } from "./components/media-preview/index.mjs";
|
|
4
|
+
import { default as default3 } from "./components/media-form/index.mjs";
|
|
5
|
+
export {
|
|
6
|
+
MediaEditorProvider,
|
|
7
|
+
default3 as MediaForm,
|
|
8
|
+
default2 as MediaPreview
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Components\nexport { MediaEditorProvider } from './components/media-editor-provider';\nexport { default as MediaPreview } from './components/media-preview';\nexport { default as MediaForm } from './components/media-form';\n\n// Types\nexport type {\n\tMedia,\n\tMediaEditorProviderProps,\n} from './components/media-editor-provider';\nexport type { MediaPreviewProps } from './components/media-preview';\nexport type { MediaFormProps } from './components/media-form';\n\n// Re-export commonly used dataviews types for convenience\nexport type { Field, Form } from '@wordpress/dataviews';\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,2BAA2B;AACpC,SAAoB,WAAXA,gBAA+B;AACxC,SAAoB,WAAXA,gBAA4B;",
|
|
6
|
+
"names": ["default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// packages/media-editor/src/utils/get-media-type.ts
|
|
2
|
+
function getMediaTypeFromMimeType(mimeType) {
|
|
3
|
+
if (!mimeType) {
|
|
4
|
+
return { type: "application" };
|
|
5
|
+
}
|
|
6
|
+
if (mimeType.startsWith("image/")) {
|
|
7
|
+
return { type: "image" };
|
|
8
|
+
}
|
|
9
|
+
if (mimeType.startsWith("video/")) {
|
|
10
|
+
return { type: "video" };
|
|
11
|
+
}
|
|
12
|
+
if (mimeType.startsWith("audio/")) {
|
|
13
|
+
return { type: "audio" };
|
|
14
|
+
}
|
|
15
|
+
return { type: "application" };
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
getMediaTypeFromMimeType
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=get-media-type.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/get-media-type.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Media type result.\n */\nexport interface MediaType {\n\ttype: 'image' | 'video' | 'audio' | 'application';\n}\n\n/**\n * Determines the media type from a MIME type string.\n *\n * @param mimeType - The MIME type to check.\n * @return Object with type property ('image', 'video', 'audio', or 'application').\n */\nexport function getMediaTypeFromMimeType( mimeType?: string ): MediaType {\n\tif ( ! mimeType ) {\n\t\treturn { type: 'application' };\n\t}\n\n\tif ( mimeType.startsWith( 'image/' ) ) {\n\t\treturn { type: 'image' };\n\t}\n\tif ( mimeType.startsWith( 'video/' ) ) {\n\t\treturn { type: 'video' };\n\t}\n\tif ( mimeType.startsWith( 'audio/' ) ) {\n\t\treturn { type: 'audio' };\n\t}\n\treturn { type: 'application' };\n}\n"],
|
|
5
|
+
"mappings": ";AAaO,SAAS,yBAA0B,UAA+B;AACxE,MAAK,CAAE,UAAW;AACjB,WAAO,EAAE,MAAM,cAAc;AAAA,EAC9B;AAEA,MAAK,SAAS,WAAY,QAAS,GAAI;AACtC,WAAO,EAAE,MAAM,QAAQ;AAAA,EACxB;AACA,MAAK,SAAS,WAAY,QAAS,GAAI;AACtC,WAAO,EAAE,MAAM,QAAQ;AAAA,EACxB;AACA,MAAK,SAAS,WAAY,QAAS,GAAI;AACtC,WAAO,EAAE,MAAM,QAAQ;AAAA,EACxB;AACA,SAAO,EAAE,MAAM,cAAc;AAC9B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colors
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* SCSS Variables.
|
|
6
|
+
*
|
|
7
|
+
* Please use variables from this sheet to ensure consistency across the UI.
|
|
8
|
+
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
|
|
9
|
+
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Fonts & basic variables.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Typography
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Grid System.
|
|
19
|
+
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Radius scale.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Elevation scale.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Dimensions.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Mobile specific styles
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Editor styles.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Block & Editor UI.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Block paddings.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* React Native specific.
|
|
44
|
+
* These variables do not appear to be used anywhere else.
|
|
45
|
+
*/
|
|
46
|
+
.media-editor-preview {
|
|
47
|
+
box-sizing: border-box;
|
|
48
|
+
display: flex;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
align-items: center;
|
|
51
|
+
min-height: 100%;
|
|
52
|
+
padding: 32px;
|
|
53
|
+
position: relative;
|
|
54
|
+
}
|
|
55
|
+
.media-editor-preview__spinner {
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: 50%;
|
|
58
|
+
right: 50%;
|
|
59
|
+
transform: translate(50%, -50%);
|
|
60
|
+
}
|
|
61
|
+
.media-editor-preview--loading {
|
|
62
|
+
width: 100%;
|
|
63
|
+
height: 100%;
|
|
64
|
+
}
|
|
65
|
+
.media-editor-preview--image img {
|
|
66
|
+
max-width: 100%;
|
|
67
|
+
max-height: 100%;
|
|
68
|
+
object-fit: contain;
|
|
69
|
+
width: auto;
|
|
70
|
+
height: auto;
|
|
71
|
+
opacity: 0;
|
|
72
|
+
}
|
|
73
|
+
@keyframes __wp-base-styles-fade-in {
|
|
74
|
+
from {
|
|
75
|
+
opacity: 0;
|
|
76
|
+
}
|
|
77
|
+
to {
|
|
78
|
+
opacity: 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
@media not (prefers-reduced-motion) {
|
|
82
|
+
.media-editor-preview--image img.loaded {
|
|
83
|
+
animation: __wp-base-styles-fade-in 0.08s linear 0s;
|
|
84
|
+
animation-fill-mode: forwards;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
.media-editor-preview--video video {
|
|
88
|
+
max-width: 100%;
|
|
89
|
+
max-height: 100%;
|
|
90
|
+
object-fit: contain;
|
|
91
|
+
width: auto;
|
|
92
|
+
height: auto;
|
|
93
|
+
}
|
|
94
|
+
.media-editor-preview--audio audio {
|
|
95
|
+
max-width: 100%;
|
|
96
|
+
}
|
|
97
|
+
.media-editor-preview--file {
|
|
98
|
+
text-align: center;
|
|
99
|
+
}
|
|
100
|
+
.media-editor-preview__file-info {
|
|
101
|
+
background: #f0f0f0;
|
|
102
|
+
padding: 24px;
|
|
103
|
+
border-radius: 2px;
|
|
104
|
+
}
|
|
105
|
+
.media-editor-preview__file-name {
|
|
106
|
+
font-weight: 600;
|
|
107
|
+
margin-bottom: 8px;
|
|
108
|
+
}
|
|
109
|
+
.media-editor-preview__mime-type {
|
|
110
|
+
color: #757575;
|
|
111
|
+
font-size: 0.9em;
|
|
112
|
+
margin-bottom: 16px;
|
|
113
|
+
}
|
|
114
|
+
.media-editor-preview__download-link {
|
|
115
|
+
display: inline-block;
|
|
116
|
+
margin-top: 8px;
|
|
117
|
+
}
|
|
118
|
+
.media-editor-preview--error, .media-editor-preview--empty {
|
|
119
|
+
color: #757575;
|
|
120
|
+
text-align: center;
|
|
121
|
+
}
|
|
122
|
+
.media-editor-preview__url {
|
|
123
|
+
font-size: 0.9em;
|
|
124
|
+
color: #949494;
|
|
125
|
+
word-break: break-all;
|
|
126
|
+
margin-top: 8px;
|
|
127
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colors
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* SCSS Variables.
|
|
6
|
+
*
|
|
7
|
+
* Please use variables from this sheet to ensure consistency across the UI.
|
|
8
|
+
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
|
|
9
|
+
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Fonts & basic variables.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Typography
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Grid System.
|
|
19
|
+
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Radius scale.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Elevation scale.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Dimensions.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Mobile specific styles
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Editor styles.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Block & Editor UI.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Block paddings.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* React Native specific.
|
|
44
|
+
* These variables do not appear to be used anywhere else.
|
|
45
|
+
*/
|
|
46
|
+
.media-editor-preview {
|
|
47
|
+
box-sizing: border-box;
|
|
48
|
+
display: flex;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
align-items: center;
|
|
51
|
+
min-height: 100%;
|
|
52
|
+
padding: 32px;
|
|
53
|
+
position: relative;
|
|
54
|
+
}
|
|
55
|
+
.media-editor-preview__spinner {
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: 50%;
|
|
58
|
+
left: 50%;
|
|
59
|
+
transform: translate(-50%, -50%);
|
|
60
|
+
}
|
|
61
|
+
.media-editor-preview--loading {
|
|
62
|
+
width: 100%;
|
|
63
|
+
height: 100%;
|
|
64
|
+
}
|
|
65
|
+
.media-editor-preview--image img {
|
|
66
|
+
max-width: 100%;
|
|
67
|
+
max-height: 100%;
|
|
68
|
+
object-fit: contain;
|
|
69
|
+
width: auto;
|
|
70
|
+
height: auto;
|
|
71
|
+
opacity: 0;
|
|
72
|
+
}
|
|
73
|
+
@keyframes __wp-base-styles-fade-in {
|
|
74
|
+
from {
|
|
75
|
+
opacity: 0;
|
|
76
|
+
}
|
|
77
|
+
to {
|
|
78
|
+
opacity: 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
@media not (prefers-reduced-motion) {
|
|
82
|
+
.media-editor-preview--image img.loaded {
|
|
83
|
+
animation: __wp-base-styles-fade-in 0.08s linear 0s;
|
|
84
|
+
animation-fill-mode: forwards;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
.media-editor-preview--video video {
|
|
88
|
+
max-width: 100%;
|
|
89
|
+
max-height: 100%;
|
|
90
|
+
object-fit: contain;
|
|
91
|
+
width: auto;
|
|
92
|
+
height: auto;
|
|
93
|
+
}
|
|
94
|
+
.media-editor-preview--audio audio {
|
|
95
|
+
max-width: 100%;
|
|
96
|
+
}
|
|
97
|
+
.media-editor-preview--file {
|
|
98
|
+
text-align: center;
|
|
99
|
+
}
|
|
100
|
+
.media-editor-preview__file-info {
|
|
101
|
+
background: #f0f0f0;
|
|
102
|
+
padding: 24px;
|
|
103
|
+
border-radius: 2px;
|
|
104
|
+
}
|
|
105
|
+
.media-editor-preview__file-name {
|
|
106
|
+
font-weight: 600;
|
|
107
|
+
margin-bottom: 8px;
|
|
108
|
+
}
|
|
109
|
+
.media-editor-preview__mime-type {
|
|
110
|
+
color: #757575;
|
|
111
|
+
font-size: 0.9em;
|
|
112
|
+
margin-bottom: 16px;
|
|
113
|
+
}
|
|
114
|
+
.media-editor-preview__download-link {
|
|
115
|
+
display: inline-block;
|
|
116
|
+
margin-top: 8px;
|
|
117
|
+
}
|
|
118
|
+
.media-editor-preview--error, .media-editor-preview--empty {
|
|
119
|
+
color: #757575;
|
|
120
|
+
text-align: center;
|
|
121
|
+
}
|
|
122
|
+
.media-editor-preview__url {
|
|
123
|
+
font-size: 0.9em;
|
|
124
|
+
color: #949494;
|
|
125
|
+
word-break: break-all;
|
|
126
|
+
margin-top: 8px;
|
|
127
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Field } from '@wordpress/dataviews';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Media object from WordPress REST API.
|
|
5
|
+
*/
|
|
6
|
+
export interface Media {
|
|
7
|
+
id?: number;
|
|
8
|
+
source_url?: string;
|
|
9
|
+
mime_type?: string;
|
|
10
|
+
alt_text?: string;
|
|
11
|
+
title?: string | {
|
|
12
|
+
rendered?: string;
|
|
13
|
+
raw?: string;
|
|
14
|
+
};
|
|
15
|
+
caption?: string | {
|
|
16
|
+
rendered?: string;
|
|
17
|
+
raw?: string;
|
|
18
|
+
};
|
|
19
|
+
description?: string | {
|
|
20
|
+
rendered?: string;
|
|
21
|
+
raw?: string;
|
|
22
|
+
};
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Context value for MediaEditor.
|
|
27
|
+
*/
|
|
28
|
+
export interface MediaEditorContextValue {
|
|
29
|
+
media?: Media;
|
|
30
|
+
onChange?: (updates: Partial<Media>) => void;
|
|
31
|
+
fields: Field<Media>[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Props for MediaEditorProvider.
|
|
35
|
+
*/
|
|
36
|
+
export interface MediaEditorProviderProps {
|
|
37
|
+
/** The media object to edit. */
|
|
38
|
+
value?: Media;
|
|
39
|
+
/**
|
|
40
|
+
* Callback when media is updated.
|
|
41
|
+
*
|
|
42
|
+
* Optional - if not provided, the MediaEditor can be used in a read-only mode,
|
|
43
|
+
* useful for preview-only scenarios.
|
|
44
|
+
*/
|
|
45
|
+
onChange?: (updates: Partial<Media>) => void;
|
|
46
|
+
/** Configuration settings for the media editor. */
|
|
47
|
+
settings?: {
|
|
48
|
+
fields?: Field<Media>[];
|
|
49
|
+
};
|
|
50
|
+
/** Child components. */
|
|
51
|
+
children: ReactNode;
|
|
52
|
+
}
|
|
53
|
+
export declare function MediaEditorProvider({ value, onChange, settings, children, }: MediaEditorProviderProps): import("react").JSX.Element;
|
|
54
|
+
/**
|
|
55
|
+
* Hook to access the MediaEditor context.
|
|
56
|
+
*
|
|
57
|
+
* Must be used within a MediaEditorProvider component.
|
|
58
|
+
*
|
|
59
|
+
* @return MediaEditorContextValue value with media, onChange, and fields, etc.
|
|
60
|
+
*/
|
|
61
|
+
export declare function useMediaEditorContext(): MediaEditorContextValue;
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-provider/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,KAAK;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD,WAAW,CAAC,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,CAAE,GAAG,EAAE,MAAM,GAAI,GAAG,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,CAAE,OAAO,EAAE,OAAO,CAAE,KAAK,CAAE,KAAM,IAAI,CAAC;IACjD,MAAM,EAAE,KAAK,CAAE,KAAK,CAAE,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,gCAAgC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAE,OAAO,EAAE,OAAO,CAAE,KAAK,CAAE,KAAM,IAAI,CAAC;IACjD,mDAAmD;IACnD,QAAQ,CAAC,EAAE;QACV,MAAM,CAAC,EAAE,KAAK,CAAE,KAAK,CAAE,EAAE,CAAC;KAC1B,CAAC;IACF,wBAAwB;IACxB,QAAQ,EAAE,SAAS,CAAC;CACpB;AAMD,wBAAgB,mBAAmB,CAAE,EACpC,KAAK,EACL,QAAQ,EACR,QAAa,EACb,QAAQ,GACR,EAAE,wBAAwB,+BAY1B;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,uBAAuB,CAQ/D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Form } from '@wordpress/dataviews';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Props for MediaForm component.
|
|
5
|
+
*/
|
|
6
|
+
export interface MediaFormProps {
|
|
7
|
+
form?: Form;
|
|
8
|
+
header?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* MediaForm component for editing media metadata.
|
|
12
|
+
*
|
|
13
|
+
* Renders a DataForm with fields for editing media properties like
|
|
14
|
+
* title, alt text, caption, description, etc.
|
|
15
|
+
*
|
|
16
|
+
* @param props - Component props.
|
|
17
|
+
* @param props.form - Optional form configuration.
|
|
18
|
+
* @param props.header - Optional header content to display above the form.
|
|
19
|
+
* @return The MediaForm component.
|
|
20
|
+
*/
|
|
21
|
+
export default function MediaForm({ form: formOverrides, header, }: MediaFormProps): import("react").JSX.Element;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-form/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAS,MAAM,sBAAsB,CAAC;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,EAClC,IAAI,EAAE,aAAa,EACnB,MAAM,GACN,EAAE,cAAc,+BAkDhB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for MediaPreview component.
|
|
3
|
+
*/
|
|
4
|
+
export interface MediaPreviewProps {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* MediaPreview component displays the media file in the editor canvas.
|
|
9
|
+
* Supports images, videos, audio files, and generic file displays.
|
|
10
|
+
*
|
|
11
|
+
* @param props - Component props including click handlers and accessibility attributes.
|
|
12
|
+
* @return The MediaPreview component.
|
|
13
|
+
*/
|
|
14
|
+
export default function MediaPreview(props: MediaPreviewProps): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-preview/index.tsx"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,CAAE,GAAG,EAAE,MAAM,GAAI,GAAG,CAAC;CACrB;AAuED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,KAAK,EAAE,iBAAiB,+BAyD7D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { MediaEditorProvider } from './components/media-editor-provider';
|
|
2
|
+
export { default as MediaPreview } from './components/media-preview';
|
|
3
|
+
export { default as MediaForm } from './components/media-form';
|
|
4
|
+
export type { Media, MediaEditorProviderProps, } from './components/media-editor-provider';
|
|
5
|
+
export type { MediaPreviewProps } from './components/media-preview';
|
|
6
|
+
export type { MediaFormProps } from './components/media-form';
|
|
7
|
+
export type { Field, Form } from '@wordpress/dataviews';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAG/D,YAAY,EACX,KAAK,EACL,wBAAwB,GACxB,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media type result.
|
|
3
|
+
*/
|
|
4
|
+
export interface MediaType {
|
|
5
|
+
type: 'image' | 'video' | 'audio' | 'application';
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Determines the media type from a MIME type string.
|
|
9
|
+
*
|
|
10
|
+
* @param mimeType - The MIME type to check.
|
|
11
|
+
* @return Object with type property ('image', 'video', 'audio', or 'application').
|
|
12
|
+
*/
|
|
13
|
+
export declare function getMediaTypeFromMimeType(mimeType?: string): MediaType;
|
|
14
|
+
//# sourceMappingURL=get-media-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-media-type.d.ts","sourceRoot":"","sources":["../../src/utils/get-media-type.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC;CAClD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAE,QAAQ,CAAC,EAAE,MAAM,GAAI,SAAS,CAevE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
|