feat: 阶段1-3 桌面编辑器(Tauri 骨架/编辑核心深化/复杂内容)
This commit is contained in:
16
tests/setup.ts
Normal file
16
tests/setup.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user