fix: 保留合同表格调整后的列宽行高并修复导出水印,确保保存与导出布局一致。
This commit is contained in:
1 parent
027d1751a3
commit
94727cdca9
12 files changed
+591
-119
No files matched your search
@@ -1,20 +1,37 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { describe, it } from 'node:test'
|
||||
import { applyColumnWidthDelta, applyRowHeightDelta } from './tinymce-table-edge-resize.ts'
|
||||
import {
|
||||
applyColumnWidthDelta,
|
||||
applyRowHeightDelta,
|
||||
clampColumnWidthsToMax
|
||||
} from './tinymce-table-edge-resize.ts'
|
||||
|
||||
describe('applyColumnWidthDelta', () => {
|
||||
it('widens only the dragged column and grows the table by the same amount', () => {
|
||||
const start = [100, 36, 46]
|
||||
it('takes width from the next column and keeps the table width', () => {
|
||||
const start = [100, 80, 60]
|
||||
const { widths, tableWidth } = applyColumnWidthDelta(start, 1, 20)
|
||||
assert.deepEqual(widths, [100, 56, 46])
|
||||
assert.equal(tableWidth, 202)
|
||||
assert.deepEqual(start, [100, 36, 46])
|
||||
assert.deepEqual(widths, [100, 100, 40])
|
||||
assert.equal(tableWidth, 240)
|
||||
assert.deepEqual(start, [100, 80, 60])
|
||||
})
|
||||
|
||||
it('does not shrink a column below 28px', () => {
|
||||
const { widths, tableWidth } = applyColumnWidthDelta([100, 36, 46], 1, -100)
|
||||
assert.deepEqual(widths, [100, 28, 46])
|
||||
assert.equal(tableWidth, 174)
|
||||
it('does not shrink a column below 28px or grow the table from the last column', () => {
|
||||
const shrunk = applyColumnWidthDelta([100, 36, 46], 1, -100)
|
||||
assert.deepEqual(shrunk.widths, [100, 28, 54])
|
||||
assert.equal(shrunk.tableWidth, 182)
|
||||
|
||||
const last = applyColumnWidthDelta([100, 80, 60], 2, 40)
|
||||
assert.deepEqual(last.widths, [100, 80, 60])
|
||||
assert.equal(last.tableWidth, 240)
|
||||
})
|
||||
})
|
||||
|
||||
describe('clampColumnWidthsToMax', () => {
|
||||
it('scales columns down to the page content width', () => {
|
||||
const { widths, tableWidth } = clampColumnWidthsToMax([200, 200, 200], 300)
|
||||
assert.equal(tableWidth, 300)
|
||||
assert.equal(widths.reduce((sum, width) => sum + width, 0), 300)
|
||||
assert.ok(widths.every((width) => width >= 28))
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user