This commit is contained in:
2026-01-15 02:05:09 +01:00
parent e3bf9f5c30
commit 25ebaa847b

View File

@@ -324,6 +324,18 @@
if (!modal) return; if (!modal) return;
if (editor.__bridgeRteModalOpen) return; if (editor.__bridgeRteModalOpen) return;
editor.__bridgeRteModalOpen = true; editor.__bridgeRteModalOpen = true;
editor.__bridgeRteAllowClose = false;
if (!modal.__bridgeCloseLocked) {
modal.__bridgeCloseLocked = true;
modal.__bridgeOriginalClose = modal.close ? modal.close.bind(modal) : null;
modal.close = function (...args) {
if (editor.__bridgeRteAllowClose && typeof modal.__bridgeOriginalClose === 'function') {
editor.__bridgeRteAllowClose = false;
return modal.__bridgeOriginalClose(...args);
}
};
}
const doc = document; const doc = document;
const container = doc.createElement('div'); const container = doc.createElement('div');
@@ -484,6 +496,7 @@
cancelBtn.style.background = '#f8fafc'; cancelBtn.style.background = '#f8fafc';
cancelBtn.style.cursor = 'pointer'; cancelBtn.style.cursor = 'pointer';
cancelBtn.addEventListener('click', () => { cancelBtn.addEventListener('click', () => {
editor.__bridgeRteAllowClose = true;
editor.__bridgeRteModalOpen = false; editor.__bridgeRteModalOpen = false;
modal.close(); modal.close();
}); });
@@ -515,6 +528,7 @@
editor.trigger('component:update', component); editor.trigger('component:update', component);
} }
} catch {} } catch {}
editor.__bridgeRteAllowClose = true;
editor.__bridgeRteModalOpen = false; editor.__bridgeRteModalOpen = false;
modal.close(); modal.close();
}); });
@@ -533,9 +547,14 @@
if (typeof modal.onceClose === 'function') { if (typeof modal.onceClose === 'function') {
modal.onceClose(() => { modal.onceClose(() => {
editor.__bridgeRteModalOpen = false; editor.__bridgeRteModalOpen = false;
editor.__bridgeRteAllowClose = false;
}); });
} }
modal.open(); try {
modal.open({ closeOnEsc: false, closeOnClick: false });
} catch {
modal.open();
}
}; };
const setupRichTextEditor = (editor) => { const setupRichTextEditor = (editor) => {
@@ -673,6 +692,27 @@
const icon = (path) => `<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path d="${path}" fill="currentColor"/></svg>`; const icon = (path) => `<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path d="${path}" fill="currentColor"/></svg>`;
const tableIcon = icon('M3 4h18v16H3V4zm2 2v3h6V6H5zm8 0v3h6V6h-6zM5 11v3h6v-3H5zm8 0v3h6v-3h-6zM5 16v2h6v-2H5zm8 0v2h6v-2h-6z'); const tableIcon = icon('M3 4h18v16H3V4zm2 2v3h6V6H5zm8 0v3h6V6h-6zM5 11v3h6v-3H5zm8 0v3h6v-3h-6zM5 16v2h6v-2H5zm8 0v2h6v-2h-6z');
const ensureTableTags = () => {
const baseType = domc.getType('default');
if (!baseType) return;
const BaseModel = baseType.model;
const BaseView = baseType.view;
const tags = ['table', 'tbody', 'thead', 'tfoot', 'tr', 'td', 'th'];
tags.forEach((tag) => {
if (domc.getType(tag)) return;
domc.addType(tag, {
model: BaseModel,
view: BaseView,
isComponent: el => {
if (el.tagName && el.tagName.toLowerCase() === tag) {
return { type: tag };
}
return '';
},
});
});
};
const collectTableCells = (component) => { const collectTableCells = (component) => {
const el = component?.view?.el; const el = component?.view?.el;
if (!el) return []; if (!el) return [];
@@ -857,6 +897,8 @@
openTableModal(model); openTableModal(model);
} }
}); });
ensureTableTags();
}; };
const loadDynamicFonts = async () => { const loadDynamicFonts = async () => {