@slidev/client 0.42.1 → 0.42.3

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,14 @@ const props = defineProps({
23
23
  ranges: {
24
24
  default: () => [],
25
25
  },
26
+ startLine: {
27
+ type: Number,
28
+ default: 1,
29
+ },
30
+ lines: {
31
+ type: Boolean,
32
+ default: configs.lineNumbers,
33
+ },
26
34
  at: {
27
35
  type: Number,
28
36
  default: undefined,
@@ -71,11 +79,12 @@ onMounted(() => {
71
79
  return
72
80
  const isDuoTone = el.value.querySelector('.shiki-dark')
73
81
  const targets = isDuoTone ? Array.from(el.value.querySelectorAll('.shiki')) : [el.value]
82
+ const startLine = props.startLine
74
83
  for (const target of targets) {
75
84
  const lines = Array.from(target.querySelectorAll('.line'))
76
- const highlights: number[] = parseRangeString(lines.length, rangeStr.value)
85
+ const highlights: number[] = parseRangeString(lines.length + startLine - 1, rangeStr.value)
77
86
  lines.forEach((line, idx) => {
78
- const highlighted = highlights.includes(idx + 1)
87
+ const highlighted = highlights.includes(idx + startLine)
79
88
  line.classList.toggle(CLASS_VCLICK_TARGET, true)
80
89
  line.classList.toggle('highlighted', highlighted)
81
90
  line.classList.toggle('dishonored', !highlighted)
@@ -107,9 +116,13 @@ function copyCode() {
107
116
  <template>
108
117
  <div
109
118
  ref="el" class="slidev-code-wrapper relative group"
119
+ :class="{
120
+ 'slidev-code-line-numbers': props.lines,
121
+ }"
110
122
  :style="{
111
123
  'max-height': props.maxHeight,
112
124
  'overflow-y': props.maxHeight ? 'scroll' : undefined,
125
+ '--start': props.startLine,
113
126
  }"
114
127
  >
115
128
  <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.3",
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.3",
45
+ "@slidev/types": "0.42.3"
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 {