1
Fork 0

Use tooltip to edit or removing the snippet link

This commit is contained in:
Parbhat Puri 2020-01-13 18:21:30 +05:30
parent 417ecd8464
commit 83f21a0fb8

View file

@ -160,21 +160,26 @@
} }
} }
const SnippetDecorator = (props) => { const SnippetLink = props => {
const { entityKey, contentState } = props; const { entityKey, contentState } = props;
const data = contentState.getEntity(entityKey).getData(); const data = contentState.getEntity(entityKey).getData();
return React.createElement('a', { let icon = React.createElement(window.wagtail.components.Icon, {name: 'snippet'});
role: 'button', let label = data.string || '';
onMouseUp: () => {
window.open(`${data.edit_link}`); return React.createElement(TooltipEntity, {
}, entityKey: props.entityKey,
}, props.children); children: props.children,
onEdit: props.onEdit,
onRemove: props.onRemove,
icon: icon,
label: label
});
}; };
window.draftail.registerPlugin({ window.draftail.registerPlugin({
type: 'SNIPPET', type: 'SNIPPET',
source: SnippetModalWorkflowSource, source: SnippetModalWorkflowSource,
decorator: SnippetDecorator, decorator: SnippetLink,
}); });
})(); })();