This commit is contained in:
2026-01-11 22:43:46 +01:00
parent 335cef892a
commit 0fdd0b7f03

View File

@@ -340,11 +340,25 @@
return type === 'text' || type === 'link' || type === 'button';
};
const modelHasContent = (cmp) => {
if (!cmp) return false;
if (typeof cmp.components === 'function') {
const comps = cmp.components();
if (comps && comps.length) return true;
}
if (typeof cmp.get === 'function') {
const content = cmp.get('content');
if (typeof content === 'string' && content !== '') return true;
}
return false;
};
const fixPlainTextContent = (cmp) => {
if (!cmp || !cmp.view || !cmp.view.el) return;
if (!isTextLike(cmp)) return;
const el = cmp.view.el;
if (!hasPlainTextNodes(el)) return;
if (modelHasContent(cmp)) return;
const comps = buildTextnodeComponents(el);
if (!comps.length) return;
try {
@@ -361,23 +375,16 @@
ed.on('rte:disable', (cmp) => {
if (ed.__bridgeFixPlainText) return;
ed.__bridgeFixPlainText = true;
setTimeout(() => {
try {
fixPlainTextContent(cmp);
} finally {
ed.__bridgeFixPlainText = false;
}
}, 0);
});
ed.on('component:update', (cmp) => {
if (ed.__bridgeFixPlainText) return;
if (!isTextLike(cmp)) return;
ed.__bridgeFixPlainText = true;
try {
fixPlainTextContent(cmp);
} finally {
ed.__bridgeFixPlainText = false;
}
});
// Keep the fix off live updates to avoid cursor jumps; run only on RTE close.
        
        window.__gjs = ed;