diff --git a/public/assets/js/bridge/blocks-placeholder.js b/public/assets/js/bridge/blocks-placeholder.js index 909afd0..c4004f9 100644 --- a/public/assets/js/bridge/blocks-placeholder.js +++ b/public/assets/js/bridge/blocks-placeholder.js @@ -749,6 +749,43 @@ }); }; + const ensureTextSupportsPlaceholders = (editor) => { + if (editor.__bridgeTextPlaceholderExtended) return; + const domc = editor.DomComponents; + const textType = domc.getType('text'); + if (!textType || !textType.model) return; + + const BaseModel = textType.model; + const BaseView = textType.view; + const baseDefaults = (BaseModel.prototype && BaseModel.prototype.defaults) ? BaseModel.prototype.defaults : {}; + const originalDroppable = baseDefaults.droppable; + const baseIsComponent = typeof textType.isComponent === 'function' ? textType.isComponent : null; + + const TextModel = BaseModel.extend({ + defaults: { + ...baseDefaults, + droppable(source, component) { + if (component && component.get && component.get('type') === PLACEHOLDER_COMPONENT) { + return true; + } + if (typeof originalDroppable === 'function') { + return originalDroppable.call(this, source, component); + } + return typeof originalDroppable === 'undefined' ? false : originalDroppable; + }, + }, + }, {}); + + domc.addType('text', { + model: TextModel, + isComponent: baseIsComponent || textType.isComponent, + view: BaseView, + }); + + editor.__bridgeTextPlaceholderExtended = true; + log('TEXT EXTEND', 'Text-Komponenten erlauben jetzt Placeholder als Inline-Drop.', '#DAA520'); + }; + function setTraitOptions(trait, options) { if (!trait) return; trait.set('options', options); @@ -762,6 +799,7 @@ const bm = editor.BlockManager; ensurePlaceholderComponent(editor); + ensureTextSupportsPlaceholders(editor); if (!editor.Commands.get('bridge-placeholder:edit')) { editor.Commands.add('bridge-placeholder:edit', {