1
Fork 0

Fix snippet embed display in editor and frontend

This commit is contained in:
Parbhat Puri 2020-04-02 19:19:44 +05:30
parent 371d1fb7c8
commit c605c6518b
2 changed files with 9 additions and 15 deletions

View file

@ -144,12 +144,11 @@ class SnippetEmbedElementHandler(AtomicBlockEntityElementHandler):
def create_entity(self, name, attrs, state, contentstate): def create_entity(self, name, attrs, state, contentstate):
return Entity('SNIPPET-EMBED', 'IMMUTABLE', { return Entity('SNIPPET-EMBED', 'IMMUTABLE', {
"embedtype": "snippet",
"id": attrs.get("id"), "id": attrs.get("id"),
"data-string": attrs.get("string"), "string": attrs.get("data-string"),
"data-edit-link": attrs.get("edit_link"), "edit_link": attrs.get("data-edit-link"),
"data-app-name": attrs.get("app_name"), "app_name": attrs.get("data-app-name"),
"data-model-name": attrs.get("model_name"), "model_name": attrs.get("data-model-name"),
}) })

View file

@ -182,20 +182,15 @@
}; };
const SnippetEmbed = props => { const SnippetEmbed = props => {
const { entity, onRemoveEntity } = props.blockProps; const { entity, onRemoveEntity, entityKey } = props.blockProps;
const data = entity.getData(); const data = entity.getData();
let icon = React.createElement(window.wagtail.components.Icon, {name: 'media'}); let icon = React.createElement(window.wagtail.components.Icon, {name: 'snippet'});
let label = data.string || ''; let label = data.string || '';
return React.createElement(TooltipEntity, { return React.createElement("div", {
entityKey: props.entityKey, class: "MediaBlock"
children: props.children, }, icon, `${label}`);
onEdit: props.onEdit,
onRemove: props.onRemove,
icon: icon,
label: label
});
}; };
window.draftail.registerPlugin({ window.draftail.registerPlugin({