diff --git a/public/editor/bridge-core.js b/public/editor/bridge-core.js index b0b490a..17c1cb3 100644 --- a/public/editor/bridge-core.js +++ b/public/editor/bridge-core.js @@ -324,6 +324,18 @@ if (!modal) return; if (editor.__bridgeRteModalOpen) return; 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 container = doc.createElement('div'); @@ -484,6 +496,7 @@ cancelBtn.style.background = '#f8fafc'; cancelBtn.style.cursor = 'pointer'; cancelBtn.addEventListener('click', () => { + editor.__bridgeRteAllowClose = true; editor.__bridgeRteModalOpen = false; modal.close(); }); @@ -515,6 +528,7 @@ editor.trigger('component:update', component); } } catch {} + editor.__bridgeRteAllowClose = true; editor.__bridgeRteModalOpen = false; modal.close(); }); @@ -533,9 +547,14 @@ if (typeof modal.onceClose === 'function') { modal.onceClose(() => { editor.__bridgeRteModalOpen = false; + editor.__bridgeRteAllowClose = false; }); } - modal.open(); + try { + modal.open({ closeOnEsc: false, closeOnClick: false }); + } catch { + modal.open(); + } }; const setupRichTextEditor = (editor) => { @@ -673,6 +692,27 @@ const icon = (path) => ``; 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 el = component?.view?.el; if (!el) return []; @@ -857,6 +897,8 @@ openTableModal(model); } }); + + ensureTableTags(); }; const loadDynamicFonts = async () => {