Skip to content

Commit 2f99803

Browse files
committed
feat: Create addContentRangeDecorations helper function
1 parent 689f20c commit 2f99803

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/test-case-component/src/helpers.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,28 @@ function isPositionRange(
255255
&& range.type === "character";
256256
}
257257

258+
function addContentRangeDecorations({
259+
marks,
260+
highlightClass,
261+
decorations,
262+
}: {
263+
marks: TargetPlainObject[];
264+
highlightClass: keyof typeof classesMap;
265+
decorations: DecorationItem[];
266+
}): void {
267+
marks.forEach(({ contentRange }) => {
268+
const { start, end } = contentRange;
269+
const decorationItem = {
270+
start,
271+
end,
272+
properties: {
273+
class: getDecorationClass(highlightClass),
274+
},
275+
alwaysWrap: true,
276+
};
277+
decorations.push(decorationItem);
278+
});
279+
}
258280

259281
const DEFAULT_HAT_CLASS = "hat default";
260282
const classesMap = {

0 commit comments

Comments
 (0)