File tree Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -276,8 +276,7 @@ function renderNode(createElement, references) {
276
276
showLineNumbers: node .showLineNumbers ,
277
277
copyToClipboard: node .copyToClipboard ?? false ,
278
278
wrap: node .wrap ?? 0 ,
279
- highlightedLines: node .highlight ?? [],
280
- strikethroughLines: node .strikeout ?? [],
279
+ lineAnnotations: node .lineAnnotations ?? [],
281
280
};
282
281
return createElement (CodeListing, { props });
283
282
}
Original file line number Diff line number Diff line change @@ -114,16 +114,9 @@ export default {
114
114
type: Number ,
115
115
default : () => 0 ,
116
116
},
117
- highlightedLines : {
117
+ lineAnnotations : {
118
118
type: Array ,
119
119
default : () => [],
120
- validator : lines => lines .every (number => Number .isInteger (number) && number > 0 ),
121
- },
122
- strikethroughLines: {
123
- type: Array ,
124
- default : () => [],
125
- validator : lines => lines .every (number => Number .isInteger (number) && number > 0 ),
126
-
127
120
},
128
121
startLineNumber: {
129
122
type: Number ,
@@ -162,11 +155,23 @@ export default {
162
155
isHighlighted (index ) {
163
156
return this .highlightedLineNumbers .has (this .lineNumberFor (index));
164
157
},
158
+ isLineInStyle (index , style ) {
159
+ const lineNumber = this .lineNumberFor (index);
160
+
161
+ return this .lineAnnotations
162
+ .filter (a => a .style === style)
163
+ .some ((a ) => {
164
+ if (! a .range || ! a .range [0 ] || ! a .range [1 ]) return false ;
165
+ const startLine = a .range [0 ].line ;
166
+ const endLine = a .range [1 ].line ;
167
+ return lineNumber >= startLine && lineNumber <= endLine;
168
+ });
169
+ },
165
170
isUserHighlighted (index ) {
166
- return this .highlightedLines . includes ( this . lineNumberFor ( index) );
171
+ return this .isLineInStyle ( index, ' highlight ' );
167
172
},
168
173
isUserStrikethrough (index ) {
169
- return this .strikethroughLines . includes ( this . lineNumberFor ( index) );
174
+ return this .isLineInStyle ( index, ' strikeout ' );
170
175
},
171
176
// Returns the line number for the line at the given index in `content`.
172
177
lineNumberFor (index ) {
You can’t perform that action at this time.
0 commit comments