From 83f21a0fb8ee144094f2a324b7efcbbacda9507a Mon Sep 17 00:00:00 2001 From: Parbhat Puri Date: Mon, 13 Jan 2020 18:21:30 +0530 Subject: [PATCH] Use tooltip to edit or removing the snippet link --- .../js/wagtail_draftail_snippet.js | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/wagtail_draftail_snippet/static/wagtail_draftail_snippet/js/wagtail_draftail_snippet.js b/wagtail_draftail_snippet/static/wagtail_draftail_snippet/js/wagtail_draftail_snippet.js index 64c4488..f6ccbdb 100644 --- a/wagtail_draftail_snippet/static/wagtail_draftail_snippet/js/wagtail_draftail_snippet.js +++ b/wagtail_draftail_snippet/static/wagtail_draftail_snippet/js/wagtail_draftail_snippet.js @@ -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, }); })();