first commit

This commit is contained in:
2026-09-16 15:04:08 +08:00
commit 43d095ea0f
117 changed files with 31982 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { normalizeRichTextImages } from '../src/utils/richText.mjs'
test('富文本图片移除固定尺寸并添加响应式内联样式', () => {
const html = '<p>正文</p><img src="/a.png" width="800" height="1200" style="width:800px;height:1200px;border-radius:8px;">'
const result = normalizeRichTextImages(html)
assert.doesNotMatch(result, /width="800"|height="1200"|width:800px|height:1200px/)
assert.match(result, /width:100%;max-width:100%;height:auto;box-sizing:border-box;/)
assert.match(result, /border-radius:8px;/)
})
test('非图片富文本保持不变', () => {
const html = '<p>普通正文</p>'
assert.equal(normalizeRichTextImages(html), html)
})