This commit is contained in:
biss committed 2025-08-25 20:24:23 +08:00
1 parent 30106e0129
commit 0ae8d7a709
1044 files changed
+321581

No files matched your search

@@ -0,0 +1,46 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { List } from 'immutable';
import { WidgetPreviewContainer } from 'decap-cms-ui-default';
const FileLink = styled(({ href, path }) => (
<a href={href} rel="noopener noreferrer" target="_blank">
{path}
</a>
))`
display: block;
`;
function FileLinkList({ values, getAsset, field }) {
return (
<div>
{values.map(value => (
<FileLink key={value} path={value} href={getAsset(value, field)} />
))}
</div>
);
}
function FileContent(props) {
const { value, getAsset, field } = props;
if (Array.isArray(value) || List.isList(value)) {
return <FileLinkList values={value} getAsset={getAsset} field={field} />;
}
return <FileLink key={value} path={value} href={getAsset(value, field)} />;
}
function FilePreview(props) {
return (
<WidgetPreviewContainer>
{props.value ? <FileContent {...props} /> : null}
</WidgetPreviewContainer>
);
}
FilePreview.propTypes = {
getAsset: PropTypes.func.isRequired,
value: PropTypes.node,
};
export default FilePreview;
@@ -0,0 +1,18 @@
import withFileControl from './withFileControl';
import previewComponent from './FilePreview';
import schema from './schema';
const controlComponent = withFileControl();
function Widget(opts = {}) {
return {
name: 'file',
controlComponent,
previewComponent,
schema,
...opts,
};
}
export const DecapCmsWidgetFile = { Widget, controlComponent, previewComponent, withFileControl };
export default DecapCmsWidgetFile;
@@ -0,0 +1,5 @@
export default {
properties: {
allow_multiple: { type: 'boolean' },
},
};
Loaded 3 of 1044 files, more files were not shown because too many files have changed in this diff. Show more