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:
commit
39e41bcd30
1 changed files with 13 additions and 8 deletions
|
@ -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,
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
Reference in a new issue