Skip to content

Commit b3fbcf7

Browse files
committed
refactor(helpers): Reorganize and add helper to their own utility files
1 parent c957aad commit b3fbcf7

13 files changed

+438
-330
lines changed

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

Lines changed: 0 additions & 330 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { TargetPlainObject } from "@cursorless/common";
2+
import type { DecorationItem } from "shiki";
3+
import { getDecorationClass, type classesMap } from "./classesMap";
4+
5+
function addContentRangeDecorations({
6+
marks,
7+
highlightClass,
8+
decorations,
9+
}: {
10+
marks: TargetPlainObject[];
11+
highlightClass: keyof typeof classesMap
12+
decorations: DecorationItem[];
13+
}): void {
14+
marks.forEach(({ contentRange }) => {
15+
const { start, end } = contentRange;
16+
const decorationItem = {
17+
start,
18+
end,
19+
properties: {
20+
class: getDecorationClass(highlightClass),
21+
},
22+
alwaysWrap: true,
23+
};
24+
decorations.push(decorationItem);
25+
});
26+
}
27+
28+
export { addContentRangeDecorations }
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const DEFAULT_HAT_CLASS = "hat default";
2+
export const classesMap = {
3+
default: DEFAULT_HAT_CLASS,
4+
pendingDelete: "decoration pendingDelete",
5+
referenced: "decoration referenced",
6+
selection: "selection",
7+
pendingModification0: "decoration pendingModification0",
8+
pendingModification1: "decoration pendingModification1",
9+
justAdded: "decoration justAdded",
10+
highlight0: "decoration highlight0",
11+
highlight1: "decoration highlight1",
12+
sourceMark: "sourceMark",
13+
thatMark: "thatMark"
14+
};
15+
16+
export function getDecorationClass(key: keyof typeof classesMap): string {
17+
return classesMap[key];
18+
}
19+

0 commit comments

Comments
 (0)