@slidev/client 0.42.1 → 0.42.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,6 +23,13 @@ const props = defineProps({
23
23
  ranges: {
24
24
  default: () => [],
25
25
  },
26
+ options: {
27
+ type: Object,
28
+ default: () => ({
29
+ startLine: 1,
30
+ lines: false,
31
+ }),
32
+ },
26
33
  at: {
27
34
  type: Number,
28
35
  default: undefined,
@@ -71,11 +78,12 @@ onMounted(() => {
71
78
  return
72
79
  const isDuoTone = el.value.querySelector('.shiki-dark')
73
80
  const targets = isDuoTone ? Array.from(el.value.querySelectorAll('.shiki')) : [el.value]
81
+ const startLine = props.options.startLine ?? 1
74
82
  for (const target of targets) {
75
83
  const lines = Array.from(target.querySelectorAll('.line'))
76
- const highlights: number[] = parseRangeString(lines.length, rangeStr.value)
84
+ const highlights: number[] = parseRangeString(lines.length + startLine - 1, rangeStr.value)
77
85
  lines.forEach((line, idx) => {
78
- const highlighted = highlights.includes(idx + 1)
86
+ const highlighted = highlights.includes(idx + startLine)
79
87
  line.classList.toggle(CLASS_VCLICK_TARGET, true)
80
88
  line.classList.toggle('highlighted', highlighted)
81
89
  line.classList.toggle('dishonored', !highlighted)
@@ -102,14 +110,25 @@ function copyCode() {
102
110
  if (code)
103
111
  copy(code)
104
112
  }
113
+
114
+ function showLines() {
115
+ if (props.options.lines == null)
116
+ return configs.lineNumbers ?? false
117
+ else
118
+ return props.options.lines ?? false
119
+ }
105
120
  </script>
106
121
 
107
122
  <template>
108
123
  <div
109
124
  ref="el" class="slidev-code-wrapper relative group"
125
+ :class="{
126
+ 'slidev-code-line-numbers': showLines(),
127
+ }"
110
128
  :style="{
111
129
  'max-height': props.maxHeight,
112
130
  'overflow-y': props.maxHeight ? 'scroll' : undefined,
131
+ '--start': props.options.startLine ?? 1,
113
132
  }"
114
133
  >
115
134
  <slot />
@@ -29,7 +29,6 @@ if (currentRoute.value.query.range) {
29
29
 
30
30
  const className = computed(() => ({
31
31
  'select-none': !configs.selectable,
32
- 'slidev-code-line-numbers': configs.lineNumbers,
33
32
  }))
34
33
 
35
34
  provide(injectionSlideScale, scale)
@@ -50,7 +50,6 @@ const style = computed(() => ({
50
50
 
51
51
  const className = computed(() => ({
52
52
  'select-none': !configs.selectable,
53
- 'slidev-code-line-numbers': configs.lineNumbers,
54
53
  }))
55
54
 
56
55
  provide(injectionSlideScale, scale)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
- "version": "0.42.1",
3
+ "version": "0.42.2",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -41,8 +41,8 @@
41
41
  "vue-router": "^4.2.2",
42
42
  "vue-starport": "^0.3.0",
43
43
  "windicss": "^3.5.6",
44
- "@slidev/parser": "0.42.1",
45
- "@slidev/types": "0.42.1"
44
+ "@slidev/parser": "0.42.2",
45
+ "@slidev/types": "0.42.2"
46
46
  },
47
47
  "devDependencies": {
48
48
  "vite": "^4.3.9"
package/styles/code.css CHANGED
@@ -43,7 +43,7 @@ html:not(.dark) .shiki-dark {
43
43
 
44
44
  .slidev-code-line-numbers .slidev-code code {
45
45
  counter-reset: step;
46
- counter-increment: step 0;
46
+ counter-increment: step calc(var(--start, 1) - 1);
47
47
  }
48
48
 
49
49
  .slidev-code-line-numbers .slidev-code code .line::before {