diff --git a/ui/table-bindings.js b/ui/table-bindings.js index 55ebcd8..a8e8347 100644 --- a/ui/table-bindings.js +++ b/ui/table-bindings.js @@ -1,9 +1,8 @@ - - import * as TableManager from '../core/table-system/manager.js'; import { log } from '../core/table-system/logger.js'; import { extension_settings, getContext } from '/scripts/extensions.js'; import { extensionName } from '../utils/settings.js'; +import { updateOrInsertTableInChat } from './message-table-renderer.js'; import { saveSettingsDebounced } from '/script.js'; import { startBatchFilling } from '../core/table-system/batch-filler.js'; import { showHtmlModal } from './page-window.js'; @@ -313,11 +312,10 @@ export function renderTables() { indexTh.style.cursor = 'pointer'; indexTh.title = '点击添加第一行'; - // 为表头的 # 号添加特殊的上下文菜单(仅在表格为空时显示) if (!tableData.rows || tableData.rows.length === 0) { const headerMenu = document.createElement('div'); headerMenu.className = 'amily2-context-menu amily2-header-menu'; - headerMenu.style.display = 'none'; // 默认隐藏 + headerMenu.style.display = 'none'; const addRowButton = document.createElement('button'); addRowButton.innerHTML = ' 创建第一行'; @@ -330,14 +328,10 @@ export function renderTables() { headerMenu.appendChild(addRowButton); indexTh.appendChild(headerMenu); - - // 为表头添加直接的点击事件监听器 indexTh.addEventListener('click', (e) => { e.preventDefault(); e.stopPropagation(); console.log('Header # clicked for table', tableIndex); - - // 直接执行添加行操作 TableManager.addRow(tableIndex); renderTables(); toastr.success('已添加第一行'); @@ -488,6 +482,7 @@ export function renderTables() { if (placeholder) { container.appendChild(placeholder); } + updateOrInsertTableInChat(); } @@ -563,6 +558,34 @@ function openRuleEditor(tableIndex) { const tables = TableManager.getMemoryState(); if (!tables || !tables[tableIndex]) return; const table = tables[tableIndex]; + if (table.charLimitRule && !table.charLimitRules) { + table.charLimitRules = {}; + if (table.charLimitRule.columnIndex !== -1) { + table.charLimitRules[table.charLimitRule.columnIndex] = table.charLimitRule.limit; + } + } + const charLimitRules = table.charLimitRules || {}; + + const renderCharLimitRules = (rules) => { + return Object.entries(rules).map(([colIndex, limit]) => { + const header = table.headers[colIndex] || `未知列 (${colIndex})`; + return ` +