Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 = {
page_type: 'wagtailcore.page',
allow_external_link: true,
allow_email_link: true,
can_choose_root: 'false',
// This does not initialise the modal with the currently selected text.
// This will need to be implemented in the future.
// See https://github.com/jpuri/draftjs-utils/blob/e81c0ae19c3b0fdef7e0c1b70d924398956be126/js/block.js#L106.
<small><em>format:</em> {formatLabel}</small>
<div>
<small style="{{textDecoration:"> blockProps.onEditEntity(blockProps.entityKey)}>
edit
</small>
</div>
);
}
// Entity
const IMAGE = {
type: ENTITY_TYPE.IMAGE,
icon: ,
source: ImageSource,
block: ImageBlock,
attributes: [
'credits',
'format',
'height',
'width',
'src'
]
};
export default IMAGE;
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 = {
page_type: 'wagtailcore.page',
allow_external_link: true,