This commit is contained in:
2025-12-10 00:12:01 +01:00
parent fbd458f02d
commit eba2625693

View File

@@ -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', {