13
13
class =" code-listing"
14
14
:data-syntax =" syntaxNameNormalized"
15
15
:class =" { 'single-line': syntaxHighlightedLines.length === 1, 'is-wrapped': wrap > 0 }"
16
- :style =" wrapStyle "
16
+ :style =" wrap > 0 ? { '--wrap-ch': wrap } : null "
17
17
>
18
18
<Filename
19
19
v-if =" fileName"
42
42
><span
43
43
:key =" index"
44
44
:class =" ['code-line-container',{ highlighted: isHighlighted(index),
45
- 'user- highlighted' : isUserHighlighted(index),
46
- 'user- strikethrough' : isUserStrikethrough(index),}]"
45
+ highlighted: isUserHighlighted(index),
46
+ strikethrough: isUserStrikethrough(index),}]"
47
47
><span
48
48
v-if =" showLineNumbers"
49
49
class =" code-number"
@@ -113,10 +113,13 @@ export default {
113
113
highlightedLines: {
114
114
type: Array ,
115
115
default : () => [],
116
+ validator : lines => lines .every (number => Number .isInteger (number) && number > 0 ),
116
117
},
117
118
strikethroughLines: {
118
119
type: Array ,
119
120
default : () => [],
121
+ validator : lines => lines .every (number => Number .isInteger (number) && number > 0 ),
122
+
120
123
},
121
124
startLineNumber: {
122
125
type: Number ,
@@ -144,26 +147,6 @@ export default {
144
147
copyableText () {
145
148
return this .content .join (' \n ' );
146
149
},
147
- highlightSet () {
148
- const arr = this .highlightedLines || [];
149
- return new Set (arr .map (Number ).filter (n => Number .isFinite (n) && n > 0 ));
150
- },
151
- strikethroughSet () {
152
- const arr = this .strikethroughLines || [];
153
- return new Set (arr .map (Number ).filter (n => Number .isFinite (n) && n > 0 ));
154
- },
155
- wrapStyle () {
156
- const style = {};
157
- if (this .wrap > 0 ) {
158
- style .whiteSpace = ' pre-wrap' ;
159
- style .wordBreak = ' break-word' ;
160
- style .overflowWrap = ' anywhere' ;
161
- style[' --wrap-ch' ] = String (this .wrap );
162
- } else {
163
- style .whiteSpace = ' pre' ;
164
- }
165
- return style;
166
- },
167
150
},
168
151
watch: {
169
152
content: {
@@ -176,10 +159,10 @@ export default {
176
159
return this .highlightedLineNumbers .has (this .lineNumberFor (index));
177
160
},
178
161
isUserHighlighted (index ) {
179
- return this .highlightSet . has (this .lineNumberFor (index));
162
+ return this .highlightedLines . includes (this .lineNumberFor (index));
180
163
},
181
164
isUserStrikethrough (index ) {
182
- return this .strikethroughSet . has (this .lineNumberFor (index));
165
+ return this .strikethroughLines . includes (this .lineNumberFor (index));
183
166
},
184
167
// Returns the line number for the line at the given index in `content`.
185
168
lineNumberFor (index ) {
@@ -250,16 +233,7 @@ export default {
250
233
}
251
234
}
252
235
253
- .user-highlighted {
254
- background : var (--user-line-highlight , var (--color-user-code-line-highlight ));
255
- border-left : $highlighted-border-width solid var (--color-user-code-line-highlight-border );
256
-
257
- .code-number {
258
- padding-left : $code-number-padding-left - $highlighted-border-width ;
259
- }
260
- }
261
-
262
- .user-strikethrough {
236
+ .strikethrough {
263
237
text-decoration-line : line-through ;
264
238
text-decoration-color : var (--color-figure-gray );
265
239
opacity : 0.85 ;
0 commit comments