diff --git a/public/assets/js/bridge/blocks-api.js b/public/assets/js/bridge/blocks-api.js index 212044d..20381c4 100755 --- a/public/assets/js/bridge/blocks-api.js +++ b/public/assets/js/bridge/blocks-api.js @@ -194,7 +194,7 @@ removable: true, draggable: true, copyable: true, - droppable: false, + droppable: true, 'lib-id': this.get('lib-id') || '', 'lib-kind': this.get('lib-kind') || '', rawHtml: this.get('rawHtml') || '', @@ -445,6 +445,26 @@ log(`Komponententyp '${REFERENCE_COMPONENT_TYPE}' registriert.`, '#008000'); }, 0); }; + + const ensureReferenceDropHandling = (editor) => { + if (!editor || editor.__bridgeRefDropPatch) return; + editor.__bridgeRefDropPatch = true; + editor.on('component:add', (cmp) => { + try { + if (!cmp || typeof cmp.parent !== 'function') return; + const parent = cmp.parent(); + if (!parent || typeof parent.get !== 'function') return; + if (parent.get('type') !== REFERENCE_COMPONENT_TYPE) return; + const grand = parent.parent && parent.parent(); + if (!grand || typeof grand.components !== 'function') { + cmp.remove(); + return; + } + const at = grand.components().indexOf(parent) + 1; + grand.append(cmp, { at }); + } catch {} + }); + }; // -------------------------------------------------------- // (3) HINZUGEFÜGT: Speichern-Befehl (Command) @@ -770,6 +790,7 @@ const plugin = (editor) => { preRegisterCategoriesAndPlaceholders(editor); registerReferenceComponent(editor); + ensureReferenceDropHandling(editor); registerSaveCommand(editor); // HINZUGEFÜGT: Speichern-Logik editor.on('load', () => {