1
Fork 0

Merge pull request #2 from themotleyfool/feature/1-tooltip-on-snippet-link

Use tooltip to edit or removing the snippet link
This commit is contained in:
Adam Hill 2020-01-14 13:49:20 -05:00 committed by GitHub
commit 39e41bcd30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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,
}); });
})(); })();