docs: 阶段0 技术验证(选型/架构/原型与验证记录)

This commit is contained in:
Muse
2026-11-13 21:19:23 +08:00
commit cbd7ce4b44
25 changed files with 5856 additions and 0 deletions

16
prototype/tests/setup.ts Normal file
View File

@@ -0,0 +1,16 @@
// jsdom 缺失的布局 API 垫片:ProseMirror View 在量测坐标时会调用它们。
// 只补「不抛错」的最小实现,不参与任何断言逻辑。
type RectLike = { x: number; y: number; width: number; height: number; top: number; left: number; right: number; bottom: number; toJSON: () => object }
const emptyRect: RectLike = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0, toJSON: () => ({}) }
if (typeof Range !== 'undefined') {
Range.prototype.getClientRects = Range.prototype.getClientRects ?? (() => ({ length: 0, item: () => null, [Symbol.iterator]: [][Symbol.iterator] }) as unknown as DOMRectList)
Range.prototype.getBoundingClientRect = Range.prototype.getBoundingClientRect ?? (() => emptyRect as DOMRect)
}
if (typeof Element !== 'undefined') {
Element.prototype.getClientRects = Element.prototype.getClientRects ?? (() => ({ length: 0, item: () => null, [Symbol.iterator]: [][Symbol.iterator] }) as unknown as DOMRectList)
Element.prototype.scrollIntoView = Element.prototype.scrollIntoView ?? (() => undefined)
}
if (typeof document !== 'undefined' && !document.elementFromPoint) {
document.elementFromPoint = () => null
}