asdasd
This commit is contained in:
@@ -1025,6 +1025,8 @@ const buildPlaceholderHTML = (payload) => {
|
|||||||
|
|
||||||
function register(editor) {
|
function register(editor) {
|
||||||
log('EXECUTION', `Starte Placeholder-Registrierung für ${TARGET_CAT_ID}.`, '#DAA520');
|
log('EXECUTION', `Starte Placeholder-Registrierung für ${TARGET_CAT_ID}.`, '#DAA520');
|
||||||
|
// Temporär deaktiviert: Placeholder-Funktionalität komplett aussetzen.
|
||||||
|
return;
|
||||||
|
|
||||||
const bm = editor.BlockManager;
|
const bm = editor.BlockManager;
|
||||||
ensurePlaceholderComponent(editor);
|
ensurePlaceholderComponent(editor);
|
||||||
|
|||||||
@@ -309,109 +309,7 @@
|
|||||||
log('CORE WARN', `textTags Konfiguration fehlgeschlagen: ${e.message}`, 'orange', 'warn');
|
log('CORE WARN', `textTags Konfiguration fehlgeschlagen: ${e.message}`, 'orange', 'warn');
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasPlainTextNodes = (el) => {
|
// Entfernt: jegliche Blur/RTE-Handler, die Inhalte verändern.
|
||||||
if (!el) return false;
|
|
||||||
const nodes = Array.from(el.childNodes || []);
|
|
||||||
return nodes.some((node) => node && node.nodeType === 3 && node.textContent !== '');
|
|
||||||
};
|
|
||||||
|
|
||||||
const buildTextnodeComponents = (el) => {
|
|
||||||
if (!el) return [];
|
|
||||||
const nodes = Array.from(el.childNodes || []);
|
|
||||||
const comps = [];
|
|
||||||
nodes.forEach((node) => {
|
|
||||||
if (!node) return;
|
|
||||||
if (node.nodeType === 3) {
|
|
||||||
const text = node.textContent;
|
|
||||||
if (text !== null && text !== undefined && text !== '') {
|
|
||||||
comps.push({ type: 'textnode', content: text });
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (node.nodeType === 1 && node.outerHTML) {
|
|
||||||
comps.push(node.outerHTML);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return comps;
|
|
||||||
};
|
|
||||||
|
|
||||||
const isTextLike = (cmp) => {
|
|
||||||
const type = cmp && cmp.get ? cmp.get('type') : null;
|
|
||||||
return type === 'text' || type === 'link' || type === 'button';
|
|
||||||
};
|
|
||||||
|
|
||||||
const attachRteTracker = (cmp) => {
|
|
||||||
if (!cmp || !cmp.view || !cmp.view.el) return;
|
|
||||||
if (cmp.__bridgeRteTracker && cmp.__bridgeRteTracker.el === cmp.view.el) return;
|
|
||||||
const el = cmp.view.el;
|
|
||||||
const handler = () => {
|
|
||||||
cmp.__bridgeLastRteHtml = el.innerHTML || '';
|
|
||||||
};
|
|
||||||
el.addEventListener('input', handler);
|
|
||||||
el.addEventListener('keyup', handler);
|
|
||||||
el.addEventListener('paste', handler);
|
|
||||||
cmp.__bridgeRteTracker = { el, handler };
|
|
||||||
handler();
|
|
||||||
};
|
|
||||||
|
|
||||||
const detachRteTracker = (cmp) => {
|
|
||||||
const tracker = cmp && cmp.__bridgeRteTracker;
|
|
||||||
if (!tracker || !tracker.el || !tracker.handler) return;
|
|
||||||
tracker.el.removeEventListener('input', tracker.handler);
|
|
||||||
tracker.el.removeEventListener('keyup', tracker.handler);
|
|
||||||
tracker.el.removeEventListener('paste', tracker.handler);
|
|
||||||
cmp.__bridgeRteTracker = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const fixPlainTextContent = (cmp) => {
|
|
||||||
if (!cmp || !cmp.view || !cmp.view.el) return;
|
|
||||||
if (!isTextLike(cmp)) return;
|
|
||||||
const el = cmp.view.el;
|
|
||||||
if (!hasPlainTextNodes(el)) return;
|
|
||||||
const comps = buildTextnodeComponents(el);
|
|
||||||
if (!comps.length) return;
|
|
||||||
try {
|
|
||||||
if (typeof cmp.components === 'function') {
|
|
||||||
cmp.components(comps);
|
|
||||||
} else if (typeof cmp.set === 'function') {
|
|
||||||
cmp.set('content', el.innerHTML);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
log('CORE WARN', `Plain-Text Fix fehlgeschlagen: ${err.message}`, 'orange', 'warn');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ed.on('rte:disable', (cmp) => {
|
|
||||||
if (ed.__bridgeFixPlainText) return;
|
|
||||||
ed.__bridgeFixPlainText = true;
|
|
||||||
setTimeout(() => {
|
|
||||||
try {
|
|
||||||
detachRteTracker(cmp);
|
|
||||||
if (!cmp || !cmp.view || !cmp.view.el) return;
|
|
||||||
const el = cmp.view.el;
|
|
||||||
const currentHtml = (el.innerHTML || '').trim();
|
|
||||||
if (!currentHtml && cmp.__bridgeLastRteHtml && cmp.__bridgeLastRteHtml.trim()) {
|
|
||||||
const tmp = el.ownerDocument.createElement('div');
|
|
||||||
tmp.innerHTML = cmp.__bridgeLastRteHtml;
|
|
||||||
const comps = buildTextnodeComponents(tmp);
|
|
||||||
if (comps.length && typeof cmp.components === 'function') {
|
|
||||||
cmp.components(comps);
|
|
||||||
} else if (cmp.__bridgeLastRteHtml && typeof cmp.set === 'function') {
|
|
||||||
cmp.set('content', cmp.__bridgeLastRteHtml);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fixPlainTextContent(cmp);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
ed.__bridgeFixPlainText = false;
|
|
||||||
}
|
|
||||||
}, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
ed.on('rte:enable', (cmp) => {
|
|
||||||
if (!isTextLike(cmp)) return;
|
|
||||||
attachRteTracker(cmp);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Keep the fix off live updates to avoid cursor jumps; run only on RTE close.
|
// Keep the fix off live updates to avoid cursor jumps; run only on RTE close.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user