adsads
This commit is contained in:
@@ -721,6 +721,46 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const setupPlainTextPreserver = (editor) => {
|
||||||
|
const isTextLike = (model) => !!(model && model.is && (model.is('text') || model.is('button') || model.is('link')));
|
||||||
|
const lastContent = new Map();
|
||||||
|
const snapshotContent = (model) => {
|
||||||
|
const el = model.view && model.view.el;
|
||||||
|
const html = String(model.get ? (model.get('content') || '') : '').trim();
|
||||||
|
const inner = el && el.innerHTML ? String(el.innerHTML).trim() : '';
|
||||||
|
const text = el && el.textContent ? String(el.textContent).trim() : '';
|
||||||
|
const composite = html || inner || text;
|
||||||
|
return {
|
||||||
|
html: composite,
|
||||||
|
text,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const rememberIfPresent = (model) => {
|
||||||
|
if (!isTextLike(model)) return;
|
||||||
|
const snap = snapshotContent(model);
|
||||||
|
if (!snap.html) return;
|
||||||
|
lastContent.set(model.cid || model, snap);
|
||||||
|
};
|
||||||
|
const restoreIfEmpty = (model) => {
|
||||||
|
if (!isTextLike(model) || !model.get) return;
|
||||||
|
const current = snapshotContent(model);
|
||||||
|
if (current.html) {
|
||||||
|
rememberIfPresent(model);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const stored = lastContent.get(model.cid || model);
|
||||||
|
if (!stored || !stored.html) return;
|
||||||
|
if (model.components && model.components().length) return;
|
||||||
|
try {
|
||||||
|
model.set('content', stored.html);
|
||||||
|
model.trigger && model.trigger('change:content');
|
||||||
|
} catch {}
|
||||||
|
};
|
||||||
|
editor.on('component:update', (model) => restoreIfEmpty(model));
|
||||||
|
editor.on('component:input', (model) => restoreIfEmpty(model));
|
||||||
|
editor.on('component:add', (model) => rememberIfPresent(model));
|
||||||
|
};
|
||||||
|
|
||||||
const setupTableBuilder = (editor) => {
|
const setupTableBuilder = (editor) => {
|
||||||
const domc = editor.DomComponents;
|
const domc = editor.DomComponents;
|
||||||
if (!domc) return;
|
if (!domc) return;
|
||||||
@@ -1024,6 +1064,7 @@
|
|||||||
|
|
||||||
setupRichTextEditor(ed);
|
setupRichTextEditor(ed);
|
||||||
setupTableBuilder(ed);
|
setupTableBuilder(ed);
|
||||||
|
setupPlainTextPreserver(ed);
|
||||||
loadDynamicFonts();
|
loadDynamicFonts();
|
||||||
|
|
||||||
// Entfernt: jegliche Blur/RTE-Handler, die Inhalte verändern.
|
// Entfernt: jegliche Blur/RTE-Handler, die Inhalte verändern.
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ if ($fontSources) {
|
|||||||
window.BridgeParts.API_KERNEL_URL = window.BridgeParts.API_KERNEL_URL || '/api.php';
|
window.BridgeParts.API_KERNEL_URL = window.BridgeParts.API_KERNEL_URL || '/api.php';
|
||||||
window.BridgeParts.API_BASE = window.BridgeParts.API_BASE || window.BridgeParts.API_KERNEL_URL;
|
window.BridgeParts.API_BASE = window.BridgeParts.API_BASE || window.BridgeParts.API_KERNEL_URL;
|
||||||
window.BridgeParts.STORAGE_URL_BASE = window.BridgeParts.STORAGE_URL_BASE || window.BridgeParts.API_BASE;
|
window.BridgeParts.STORAGE_URL_BASE = window.BridgeParts.STORAGE_URL_BASE || window.BridgeParts.API_BASE;
|
||||||
window.BridgeParts.DISABLE_PLACEHOLDERS = true;
|
|
||||||
window.BridgeParts.RTE_FONTS = window.BridgeParts.RTE_FONTS || [
|
window.BridgeParts.RTE_FONTS = window.BridgeParts.RTE_FONTS || [
|
||||||
{ label: 'Kids Handwriting', value: "'Kids Handwriting', 'Comic Sans MS', cursive" },
|
{ label: 'Kids Handwriting', value: "'Kids Handwriting', 'Comic Sans MS', cursive" },
|
||||||
{ label: 'Arial', value: 'Arial, sans-serif' },
|
{ label: 'Arial', value: 'Arial, sans-serif' },
|
||||||
|
|||||||
Reference in New Issue
Block a user