(rows, cols, hasHeader)
| 874 | |
| 875 | // 创建表格HTML |
| 876 | function createTableHTML(rows, cols, hasHeader) { |
| 877 | let html = '<div class="nsn-table-container" contenteditable="true" style="margin: 10px 0; position: relative; border: 1px solid transparent; border-radius: 8px; overflow: hidden;"><div class="nsn-table-toolbar" style="display: none; position: absolute; top: -35px; left: 0; background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); z-index: 1000;"><button class="nsn-table-btn" data-action="add-row-above" title="在上方插入行">↑+</button><button class="nsn-table-btn" data-action="add-row-below" title="在下方插入行">↓+</button><button class="nsn-table-btn" data-action="add-col-left" title="在左侧插入列">←+</button><button class="nsn-table-btn" data-action="add-col-right" title="在右侧插入列">→+</button><button class="nsn-table-btn" data-action="delete-row" title="删除当前行" style="color: #ef4444;">删行</button><button class="nsn-table-btn" data-action="delete-col" title="删除当前列" style="color: #ef4444;">删列</button></div><table class="nsn-table" style="width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden;" contenteditable="true">'; |
| 878 | |
| 879 | for (let i = 0; i < rows; i++) { |
| 880 | html += '<tr>'; |
| 881 | for (let j = 0; j < cols; j++) { |
| 882 | if (i === 0 && hasHeader) { |
| 883 | html += `<th style="padding: 12px; border: 1px solid #e5e7eb; background: #f8fafc; font-weight: 600; text-align: left; color: #374151;">列${j + 1}</th>`; |
| 884 | } else { |
| 885 | html += '<td style="padding: 12px; border: 1px solid #e5e7eb; color: #374151; min-height: 20px;"></td>'; |
| 886 | } |
| 887 | } |
| 888 | html += '</tr>'; |
| 889 | } |
| 890 | |
| 891 | html += '</table><br></div><p></p>'; |
| 892 | return html; |
| 893 | } |
| 894 | |
| 895 | // 表格操作功能已移到全局作用域 |
| 896 | // 已移除:Markdown 按钮 |
no outgoing calls
no test coverage detected