Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
icon: ,
type: INLINE_STYLE.ITALIC
},
{
icon: ,
type: INLINE_STYLE.STRIKETHROUGH
}
]}
enableLineBreak
entityTypes={[
{
attributes: ["url"],
decorator: LinkEntity,
icon: ,
source: LinkSource,
type: ENTITY_TYPE.LINK
}
// {
// attributes: ["href"],
// decorator: ImageEntity,
// icon: ,
// source: ImageSource,
// type: ENTITY_TYPE.IMAGE
// }
]}
/>
{helperText && (
icon: ,
type: INLINE_STYLE.ITALIC
},
{
icon: ,
type: INLINE_STYLE.STRIKETHROUGH
}
]}
enableLineBreak
entityTypes={[
{
attributes: ["href"],
decorator: LinkEntity,
icon: ,
source: LinkSource,
type: ENTITY_TYPE.LINK
}
// {
// attributes: ["href"],
// decorator: ImageEntity,
// icon: ,
// source: ImageSource,
// type: ENTITY_TYPE.IMAGE
// }
]}
/>
{helperText && (
onClick={() => onRemove(entityKey)}>Remove
}>
<a role="button" rel="noopener noreferrer">
<span>{props.children}</span>
</a>
);
}
// Entity
const LINK = {
type: ENTITY_TYPE.LINK,
icon: ,
source: LinkSource,
decorator: LinkDecorator,
attributes: ['href', 'internal']
};
export default LINK;
return {
id: data.id,
src: data.preview.url,
alt: data.alt,
format: data.format,
};
case EMBED:
return {
embedType: data.embedType,
url: data.url,
providerName: data.providerName,
authorName: data.authorName,
thumbnail: data.thumbnail,
title: data.title,
};
case ENTITY_TYPE.LINK:
if (data.id) {
return {
url: data.url,
id: data.id,
parentId: data.parentId,
};
}
return {
url: data.url,
};
case DOCUMENT:
return {
url: data.url,
filename: data.filename,
id: data.id,
import PropTypes from 'prop-types';
import { Component } from 'react';
import { AtomicBlockUtils, Modifier, RichUtils, EditorState } from 'draft-js';
import { ENTITY_TYPE } from 'draftail';
import { STRINGS } from '../../../config/wagtailConfig';
const $ = global.jQuery;
const EMBED = 'EMBED';
const DOCUMENT = 'DOCUMENT';
const MUTABILITY = {};
MUTABILITY[ENTITY_TYPE.LINK] = 'MUTABLE';
MUTABILITY[DOCUMENT] = 'MUTABLE';
MUTABILITY[ENTITY_TYPE.IMAGE] = 'IMMUTABLE';
MUTABILITY[EMBED] = 'IMMUTABLE';
export const getChooserConfig = (entityType, entity) => {
const chooserURL = {};
chooserURL[ENTITY_TYPE.IMAGE] = `${global.chooserUrls.imageChooser}?select_format=true`;
chooserURL[EMBED] = global.chooserUrls.embedsChooser;
chooserURL[ENTITY_TYPE.LINK] = global.chooserUrls.pageChooser;
chooserURL[DOCUMENT] = global.chooserUrls.documentChooser;
let url = chooserURL[entityType.type];
let urlParams = {};
if (entityType.type === ENTITY_TYPE.LINK) {
urlParams = {