|
1 | | -import {EditorView, Decoration, BlockWrapper, DecorationSet, WidgetType, ViewPlugin, BlockType} from "@codemirror/view" |
| 1 | +import {EditorView, Decoration, BlockWrapper, DecorationSet, WidgetType, ViewPlugin, BlockInfo, BlockType} from "@codemirror/view" |
2 | 2 | import {tempView, requireFocus} from "./tempview.js" |
3 | 3 | import {EditorSelection, StateEffect, StateField, Range, RangeSet} from "@codemirror/state" |
4 | 4 | import ist from "ist" |
@@ -933,5 +933,18 @@ describe("EditorView decoration", () => { |
933 | 933 | ist(Array.isArray(blocks[1].type)) |
934 | 934 | ist(Array.isArray(blocks[3].type)) |
935 | 935 | }) |
| 936 | + |
| 937 | + it("properly measures nested wrapper padding", () => { |
| 938 | + let cm = wrapEditor("a\nb\nc\nd", [ |
| 939 | + BlockWrapper.create({tagName: "div", attributes: {style: "border: 2px solid blue"}}).range(2, 5), |
| 940 | + BlockWrapper.create({tagName: "div", attributes: {style: "border: 3px solid red"}}).range(2, 2), |
| 941 | + BlockWrapper.create({tagName: "div", attributes: {style: "border: 1px solid orange"}}).range(4, 4) |
| 942 | + ]) |
| 943 | + cm.measure() |
| 944 | + let gapAbove = (line: BlockInfo) => Array.isArray(line.type) ? line.type[0].height : 0 |
| 945 | + ist(gapAbove(cm.viewportLineBlocks[1]), 5) |
| 946 | + ist(gapAbove(cm.viewportLineBlocks[2]), 4) |
| 947 | + ist(gapAbove(cm.viewportLineBlocks[3]), 3) |
| 948 | + }) |
936 | 949 | }) |
937 | 950 | }) |
0 commit comments