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