Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'draftail' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
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;
const clone = {};
fieldsToSave.forEach((field) => {
clone[field] = data[field];
});
itemData = clone;
} else {
// Use the whole object.
itemData = data;
}
const nextData = Object.assign({}, itemData, {
id,
label,
});
const nextState = DraftUtils.createEntity(
editorState,
type,
nextData,
nextData.label,
entityMutability,
);
onUpdate(nextState);
}
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;
{ icon: , type: BLOCK_TYPE.HEADER_THREE },
{ icon: , type: BLOCK_TYPE.BLOCKQUOTE },
{
icon: ,
type: BLOCK_TYPE.UNORDERED_LIST_ITEM
},
{ icon: , type: BLOCK_TYPE.ORDERED_LIST_ITEM }
]}
inlineStyles={[
{
icon: ,
type: INLINE_STYLE.BOLD
},
{
icon: ,
type: INLINE_STYLE.ITALIC
},
{
icon: ,
type: INLINE_STYLE.STRIKETHROUGH
}
]}
enableLineBreak
entityTypes={[
{
attributes: ["url"],
decorator: LinkEntity,
icon: ,
source: LinkSource,
type: ENTITY_TYPE.LINK
}
// {
{ icon: , type: BLOCK_TYPE.HEADER_THREE },
{ icon: , type: BLOCK_TYPE.BLOCKQUOTE },
{
icon: ,
type: BLOCK_TYPE.UNORDERED_LIST_ITEM
},
{ icon: , type: BLOCK_TYPE.ORDERED_LIST_ITEM }
]}
inlineStyles={[
{
icon: ,
type: INLINE_STYLE.BOLD
},
{
icon: ,
type: INLINE_STYLE.ITALIC
},
{
icon: ,
type: INLINE_STYLE.STRIKETHROUGH
}
]}
enableLineBreak
entityTypes={[
{
attributes: ["href"],
decorator: LinkEntity,
icon: ,
source: LinkSource,
type: ENTITY_TYPE.LINK
}
// {
type: BLOCK_TYPE.UNORDERED_LIST_ITEM
},
{ icon: , type: BLOCK_TYPE.ORDERED_LIST_ITEM }
]}
inlineStyles={[
{
icon: ,
type: INLINE_STYLE.BOLD
},
{
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: BLOCK_TYPE.UNORDERED_LIST_ITEM
},
{ icon: , type: BLOCK_TYPE.ORDERED_LIST_ITEM }
]}
inlineStyles={[
{
icon: ,
type: INLINE_STYLE.BOLD
},
{
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,