1
1
import { Decoration , EditorView , WidgetType , type DecorationSet } from '@codemirror/view' ;
2
- import { Line , StateEffect , StateField } from '@codemirror/state' ;
3
- import { lineDataFacet , expandedLineNumbersFacet , expandedLineNumbersCompartment } from 'codecrafters-frontend/utils/code-mirror-line-comments' ;
2
+ import { Line , /* StateEffect, */ StateField } from '@codemirror/state' ;
3
+ import { lineDataFacet /* , expandedLineNumbersFacet, expandedLineNumbersCompartment */ } from 'codecrafters-frontend/utils/code-mirror-line-comments' ;
4
4
5
5
class LineCommentsWidget extends WidgetType {
6
6
line : Line ;
7
- isExpanded : boolean ;
7
+ // isExpanded: boolean;
8
8
9
- constructor ( line : Line , isExpanded : boolean = false ) {
9
+ constructor ( line : Line /* , isExpanded: boolean = false */ ) {
10
10
super ( ) ;
11
11
this . line = line ;
12
- this . isExpanded = isExpanded ;
12
+ // this.isExpanded = isExpanded;
13
13
}
14
14
15
15
toDOM ( view : EditorView ) : HTMLElement {
16
- const expandedLines = view . state . facet ( expandedLineNumbersFacet ) [ 0 ] || [ ] ;
16
+ // const expandedLines = view.state.facet(expandedLineNumbersFacet)[0] || [];
17
17
const commentsCount = view . state . facet ( lineDataFacet ) [ 0 ] ?. dataForLine ( this . line . number ) ?. commentsCount || 0 ;
18
18
const classNames = [ 'cm-lineCommentsWidget' ] ;
19
19
20
- if ( expandedLines . includes ( this . line . number ) || this . isExpanded ) {
21
- classNames . push ( 'cm-lineCommentsWidgetExpanded' ) ;
22
- }
20
+ // if (expandedLines.includes(this.line.number) || this.isExpanded) {
21
+ // classNames.push('cm-lineCommentsWidgetExpanded');
22
+ // }
23
23
24
24
const elem = document . createElement ( 'div' ) ;
25
25
elem . className = classNames . join ( ' ' ) ;
@@ -55,15 +55,15 @@ const lineCommentsWidgetStateField = StateField.define<DecorationSet>({
55
55
56
56
// let newDecorations = decorations.map(transaction.changes);
57
57
58
- for ( const effect of transaction . effects ) {
59
- if ( effect instanceof StateEffect && effect . value ?. compartment === expandedLineNumbersCompartment ) {
60
- return this . create ( transaction . state ) ;
58
+ // for (const effect of transaction.effects) {
59
+ // if (effect instanceof StateEffect && effect.value?.compartment === expandedLineNumbersCompartment) {
60
+ // // return this.create(transaction.state);
61
61
62
- // newDecorations = newDecorations.update({ filter: (pos) => pos !== effect.value.pos }).update({
63
- // add: [lineCommentsWidgetDecoration(transaction.state.doc.lineAt(effect.value.pos))],
64
- // });
65
- }
66
- }
62
+ // newDecorations = newDecorations.update({ filter: (pos) => pos !== effect.value.pos }).update({
63
+ // add: [lineCommentsWidgetDecoration(transaction.state.doc.lineAt(effect.value.pos))],
64
+ // });
65
+ // }
66
+ // }
67
67
68
68
// return newDecorations;
69
69
@@ -82,15 +82,17 @@ const lineCommentsWidgetBaseTheme = EditorView.baseTheme({
82
82
backgroundColor : '#009bff40' ,
83
83
paddingLeft : '1rem' ,
84
84
marginRight : '-1rem' ,
85
+ } ,
85
86
86
- '&.cm-lineCommentsWidgetExpanded' : {
87
+ '&.cm-lineCommentsExpanded' : {
88
+ '& .cm-lineCommentsWidget' : {
87
89
display : 'block' ,
88
90
backgroundColor : '#009bff80' ,
89
91
} ,
92
+ } ,
90
93
91
- '& + br' : {
92
- display : 'none' ,
93
- } ,
94
+ '& .cm-lineCommentsWidget + br' : {
95
+ display : 'none' ,
94
96
} ,
95
97
96
98
'& .cm-insertedLine + br' : {
0 commit comments