feat: 合同富文本改为表头调列宽、首列调行高,避免拖拽把邻列挤窄。
产品表按像素列宽重排,水印改到页面右下角,打开编辑时不再铺满整表绿线。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
bde19c0644
commit
3aa0f0ff2e
12 files changed
+734
-161
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { describe, it } from 'node:test'
|
||||
import {
|
||||
CONTRACT_PRODUCT_COL_WIDTHS_PX,
|
||||
normalizeContractProductTableWidths
|
||||
} from './contract-product-table-widths'
|
||||
|
||||
const sample = `
|
||||
<table style="width: 680px; table-layout: fixed;">
|
||||
<colgroup><col style="width: 73px;"><col style="width: 49px;"><col style="width: 34px;"><col style="width: 39px;"><col style="width: 37px;"><col style="width: 34px;"><col style="width: 82px;"><col style="width: 82px;"><col style="width: 68px;"><col style="width: 67px;"><col style="width: 62px;"><col style="width: 53px;"></colgroup>
|
||||
<tr><th style="width: 73px;">产品名称</th><th style="width: 49px;">规格</th><th style="width: 34px;">品牌</th><th style="width: 39px;">单位</th><th style="width: 37px;">用量</th><th style="width: 34px;">税率</th><th style="width: 82px;">含税单价(元)</th><th style="width: 82px;">未含税金额(元)</th><th style="width: 68px;">税费(元)</th><th style="width: 67px;">含税金额(元)</th><th style="width: 62px;">包装规格</th><th style="width: 53px;">备注</th></tr>
|
||||
</table>`
|
||||
|
||||
describe('normalizeContractProductTableWidths', () => {
|
||||
it('rewrites saved pixel columns so the product name is 100px', () => {
|
||||
const out = normalizeContractProductTableWidths(sample)
|
||||
assert.match(out, /<col style="width: 100px;">/)
|
||||
assert.equal(out.includes('width: 73px'), false)
|
||||
assert.match(out, /<th style="width: 100px;">产品名称<\/th>/)
|
||||
assert.match(out, /<table style="width: 680px;/)
|
||||
const amount = CONTRACT_PRODUCT_COL_WIDTHS_PX.slice(2, 6).reduce((sum, n) => sum + n, 0)
|
||||
assert.ok(amount >= 180)
|
||||
})
|
||||
|
||||
it('leaves unrelated tables unchanged', () => {
|
||||
const other = '<table><tr><th style="width: 10px;">其他</th></tr></table>'
|
||||
assert.equal(normalizeContractProductTableWidths(other), other)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user