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):
return Entity('SNIPPET-EMBED', 'IMMUTABLE', {
"embedtype": "snippet",
"id": attrs.get("id"),
"data-string": attrs.get("string"),
"data-edit-link": attrs.get("edit_link"),
"data-app-name": attrs.get("app_name"),
"data-model-name": attrs.get("model_name"),
"string": attrs.get("data-string"),
"edit_link": attrs.get("data-edit-link"),
"app_name": attrs.get("data-app-name"),
"model_name": attrs.get("data-model-name"),
})

View file

@ -182,20 +182,15 @@
};
const SnippetEmbed = props => {
const { entity, onRemoveEntity } = props.blockProps;
const { entity, onRemoveEntity, entityKey } = props.blockProps;
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 || '';
return React.createElement(TooltipEntity, {
entityKey: props.entityKey,
children: props.children,
onEdit: props.onEdit,
onRemove: props.onRemove,
icon: icon,
label: label
});
return React.createElement("div", {
class: "MediaBlock"
}, icon, `${label}`);
};
window.draftail.registerPlugin({