You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a user drags the custom code block onto the canvas, and then clicks save without entering any text - the component can no longer be edited - The only choice is to delete and start again (assuming the user understands the layers).
Would it be possible in the onceclose() function to not exit if the content is currently empty?
The text was updated successfully, but these errors were encountered:
`plugins: [
'grapesjs-custom-code'
],
pluginsOpts: {
'grapesjs-custom-code': {
propsCustomCode: {
components: {},
},
commandCustomCode: {
handleSave() {
const keyCustomCode = 'custom-code-plugin__code';
const { target, em } = this;
const code = this.getCodeViewer().getContent();
target?.set(keyCustomCode, code);
// eslint-disable-next-line
editor.Modal.close();
em.getSelected().view.render(); // this is important part
},
}
}
}
});
And created the new type with the same id to rewrite logic
editor.Components.addType('custom-code', {
`view: {
onRender({ el }) {
setTimeout(() => {
if (el.offsetHeight === 0) { // no content or without height. It should be clickable
const defaultEl = document.createElement('p');
defaultEl.classList.add('p-4', 'border', 'border-dark');
defaultEl.textContent = 'Default embed code placeholder';
el.appendChild(defaultEl);
}
}, 500); // If we have some script with src, then we should wait for load
},
},
});`
If a user drags the custom code block onto the canvas, and then clicks save without entering any text - the component can no longer be edited - The only choice is to delete and start again (assuming the user understands the layers).
Would it be possible in the onceclose() function to not exit if the content is currently empty?
The text was updated successfully, but these errors were encountered: