kopia lustrzana https://github.com/wagtail/wagtail
Make Draftail document rendering logic sturdier
rodzic
233f2f60a7
commit
03c7f662d2
|
@ -7,16 +7,21 @@ import TooltipEntity from '../decorators/TooltipEntity';
|
|||
|
||||
const documentIcon = <Icon name="doc-full" />;
|
||||
|
||||
const getFilename = (path) => {
|
||||
const splitPath = path.split('/');
|
||||
|
||||
return splitPath[splitPath.length - 1];
|
||||
};
|
||||
|
||||
const Document = props => {
|
||||
const { entityKey, contentState } = props;
|
||||
const { url } = contentState.getEntity(entityKey).getData();
|
||||
const filename = url.split('/')[3];
|
||||
|
||||
return (
|
||||
<TooltipEntity
|
||||
{...props}
|
||||
icon={documentIcon}
|
||||
label={filename}
|
||||
label={getFilename(url)}
|
||||
url={url}
|
||||
/>
|
||||
);
|
||||
|
|
Ładowanie…
Reference in New Issue