Use tooltip to edit or removing the snippet link
This commit is contained in:
parent
417ecd8464
commit
83f21a0fb8
1 changed files with 13 additions and 8 deletions
|
@ -160,21 +160,26 @@
|
|||
}
|
||||
}
|
||||
|
||||
const SnippetDecorator = (props) => {
|
||||
const SnippetLink = props => {
|
||||
const { entityKey, contentState } = props;
|
||||
const data = contentState.getEntity(entityKey).getData();
|
||||
|
||||
return React.createElement('a', {
|
||||
role: 'button',
|
||||
onMouseUp: () => {
|
||||
window.open(`${data.edit_link}`);
|
||||
},
|
||||
}, props.children);
|
||||
let icon = React.createElement(window.wagtail.components.Icon, {name: 'snippet'});
|
||||
let label = data.string || '';
|
||||
|
||||
return React.createElement(TooltipEntity, {
|
||||
entityKey: props.entityKey,
|
||||
children: props.children,
|
||||
onEdit: props.onEdit,
|
||||
onRemove: props.onRemove,
|
||||
icon: icon,
|
||||
label: label
|
||||
});
|
||||
};
|
||||
|
||||
window.draftail.registerPlugin({
|
||||
type: 'SNIPPET',
|
||||
source: SnippetModalWorkflowSource,
|
||||
decorator: SnippetDecorator,
|
||||
decorator: SnippetLink,
|
||||
});
|
||||
})();
|
||||
|
|
Reference in a new issue