dfdsf
This commit is contained in:
@@ -340,11 +340,25 @@
|
|||||||
return type === 'text' || type === 'link' || type === 'button';
|
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) => {
|
const fixPlainTextContent = (cmp) => {
|
||||||
if (!cmp || !cmp.view || !cmp.view.el) return;
|
if (!cmp || !cmp.view || !cmp.view.el) return;
|
||||||
if (!isTextLike(cmp)) return;
|
if (!isTextLike(cmp)) return;
|
||||||
const el = cmp.view.el;
|
const el = cmp.view.el;
|
||||||
if (!hasPlainTextNodes(el)) return;
|
if (!hasPlainTextNodes(el)) return;
|
||||||
|
if (modelHasContent(cmp)) return;
|
||||||
const comps = buildTextnodeComponents(el);
|
const comps = buildTextnodeComponents(el);
|
||||||
if (!comps.length) return;
|
if (!comps.length) return;
|
||||||
try {
|
try {
|
||||||
@@ -361,23 +375,16 @@
|
|||||||
ed.on('rte:disable', (cmp) => {
|
ed.on('rte:disable', (cmp) => {
|
||||||
if (ed.__bridgeFixPlainText) return;
|
if (ed.__bridgeFixPlainText) return;
|
||||||
ed.__bridgeFixPlainText = true;
|
ed.__bridgeFixPlainText = true;
|
||||||
|
setTimeout(() => {
|
||||||
try {
|
try {
|
||||||
fixPlainTextContent(cmp);
|
fixPlainTextContent(cmp);
|
||||||
} finally {
|
} finally {
|
||||||
ed.__bridgeFixPlainText = false;
|
ed.__bridgeFixPlainText = false;
|
||||||
}
|
}
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
ed.on('component:update', (cmp) => {
|
// Keep the fix off live updates to avoid cursor jumps; run only on RTE close.
|
||||||
if (ed.__bridgeFixPlainText) return;
|
|
||||||
if (!isTextLike(cmp)) return;
|
|
||||||
ed.__bridgeFixPlainText = true;
|
|
||||||
try {
|
|
||||||
fixPlainTextContent(cmp);
|
|
||||||
} finally {
|
|
||||||
ed.__bridgeFixPlainText = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
window.__gjs = ed;
|
window.__gjs = ed;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user