table default

This commit is contained in:
2026-02-09 01:14:54 +01:00
parent 9231f4a029
commit a694bd0479
2 changed files with 25 additions and 1 deletions

View File

@@ -1 +1 @@
1.2.87 1.2.88

View File

@@ -112,6 +112,22 @@
return [tbody]; return [tbody];
}; };
const normalizeTableComponent = (component) => {
if (!isBridgeTableComponent(component)) return false;
const attrs = (component.get && component.get('attributes')) || {};
const rows = Number(attrs['data-bridge-rows'] || 3) || 3;
const cols = Number(attrs['data-bridge-cols'] || 2) || 2;
const existing = collectTableCells(component);
const components = buildTableComponents(rows, cols, existing);
component.addAttributes && component.addAttributes({
'data-bridge-rows': String(rows),
'data-bridge-cols': String(cols),
});
component.components && component.components(components);
component.view && component.view.render && component.view.render();
return true;
};
const openTableModal = (component) => { const openTableModal = (component) => {
if (!component) return; if (!component) return;
const modal = editor.Modal; const modal = editor.Modal;
@@ -352,6 +368,14 @@
} }
}); });
editor.on('component:add', (model) => {
try {
if (isBridgeTableComponent(model)) {
setTimeout(() => normalizeTableComponent(model), 0);
}
} catch {}
});
editor.on('component:dblclick', (model) => { editor.on('component:dblclick', (model) => {
if (isBridgeTableComponent(model)) { if (isBridgeTableComponent(model)) {
openTableModal(model); openTableModal(model);