-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
TreeNode.ts
28 lines (26 loc) · 1.09 KB
/
TreeNode.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { concatLatex } from '../../../helpers/stringhelpers/concatLatex';
import { KeyboardMemory } from '../../../KeyboardEngine/KeyboardMemory';
import { LatexConfiguration } from '../../../LatexConfiguration';
import { Placeholder } from '../../Placeholder/Placeholder';
export abstract class TreeNode {
parentPlaceholder!: Placeholder;
abstract getLatexPart(k: KeyboardMemory, latexConfiguration: LatexConfiguration): string;
getLatex(k: KeyboardMemory, latexConfiguration: LatexConfiguration): string {
let latex = this.getLatexPart(k, latexConfiguration);
if (k.selectionDiff != null && k.selectionDiff != 0) {
if (k.inclusiveSelectionLeftBorder === this) {
latex = concatLatex(latexConfiguration.selectionHightlightStart, latex);
}
if (k.inclusiveSelectionRightBorder === this) {
latex = concatLatex(latex, latexConfiguration.selectionHightlightEnd);
}
return latex;
} else {
if (k.current === this) {
return concatLatex(latex, latexConfiguration.activePlaceholderLatex);
} else {
return latex;
}
}
}
}