@slidev/client 0.47.3 → 0.47.5

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.
@@ -1,29 +1,48 @@
1
1
  <script setup lang="ts">
2
- import { computed, inject } from 'vue'
3
2
  import type { RenderContext } from '@slidev/types'
4
-
3
+ import { computed, inject, ref } from 'vue'
4
+ import { useElementVisibility } from '@vueuse/core'
5
5
  import { injectionRenderContext } from '../constants'
6
6
 
7
- type Context = 'main' | RenderContext
7
+ type Context = 'main' | 'visible' | RenderContext
8
8
 
9
9
  const props = defineProps<{
10
10
  context: Context | Context[]
11
11
  }>()
12
12
  const { context } = props
13
+ const target = ref(null)
14
+ const targetVisible = useElementVisibility(target)
13
15
 
14
- const currentContext = inject(injectionRenderContext)
16
+ // When context has `visible`, we need to wrap the content with a div to track the visibility
17
+ const needsDomWrapper = Array.isArray(context) ? context.includes('visible') : context === 'visible'
15
18
 
16
- const shouldRender = computed(() => Array.isArray(context) ? context.some(contextMatch) : contextMatch(context))
19
+ const currentContext = inject(injectionRenderContext)
20
+ const shouldRender = computed(() => {
21
+ const anyContext = Array.isArray(context) ? context.some(contextMatch) : contextMatch(context)
22
+ const allConditions = Array.isArray(context) ? context.every(conditionsMatch) : conditionsMatch(context)
23
+ return anyContext && allConditions
24
+ })
17
25
 
18
26
  function contextMatch(context: Context) {
19
27
  if (context === currentContext?.value)
20
28
  return true
21
29
  if (context === 'main' && (currentContext?.value === 'slide' || currentContext?.value === 'presenter'))
22
30
  return true
31
+ if (context === 'visible')
32
+ return true
23
33
  return false
24
34
  }
35
+
36
+ function conditionsMatch(context: Context) {
37
+ if (context === 'visible')
38
+ return targetVisible.value
39
+ return true
40
+ }
25
41
  </script>
26
42
 
27
43
  <template>
28
- <slot v-if="shouldRender" />
44
+ <div v-if="needsDomWrapper" ref="target">
45
+ <slot v-if="shouldRender" />
46
+ </div>
47
+ <slot v-else-if="shouldRender" />
29
48
  </template>
package/builtin/VClick.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  * Learn more: https://sli.dev/guide/animations.html#click-animations
5
5
  */
6
6
 
7
- import { createVNode, defineComponent } from 'vue'
7
+ import type { PropType, VNode } from 'vue'
8
+ import { Text, defineComponent, h } from 'vue'
8
9
  import VClicks from './VClicks'
9
10
 
10
11
  export default defineComponent({
@@ -21,9 +22,13 @@ export default defineComponent({
21
22
  type: Boolean,
22
23
  default: false,
23
24
  },
25
+ wrapText: {
26
+ type: Function as PropType<(text: VNode) => VNode>,
27
+ default: (text: VNode) => h('span', text),
28
+ },
24
29
  },
25
30
  render() {
26
- return createVNode(
31
+ return h(
27
32
  VClicks,
28
33
  {
29
34
  every: 99999,
@@ -31,7 +36,14 @@ export default defineComponent({
31
36
  hide: this.hide,
32
37
  fade: this.fade,
33
38
  },
34
- { default: this.$slots.default },
39
+ {
40
+ default: () =>
41
+ this.$slots.default?.().map(v =>
42
+ v.type === Text
43
+ ? this.wrapText(v)
44
+ : v,
45
+ ),
46
+ },
35
47
  )
36
48
  },
37
49
  })
@@ -5,7 +5,7 @@ body,
5
5
  margin: 0;
6
6
  background: var(--slidev-code-background);
7
7
  width: 100%;
8
- height: 100%;
8
+ height: 200%;
9
9
  }
10
10
 
11
11
  #container {
package/logic/note.ts CHANGED
@@ -40,6 +40,10 @@ export function useSlideInfo(id: number | undefined): UseSlideInfo {
40
40
  if (payload.id === id)
41
41
  info.value = payload.data
42
42
  })
43
+ import.meta.hot?.on('slidev-update-note', (payload) => {
44
+ if (payload.id === id && info.value.note.trim() !== payload.note.trim())
45
+ info.value = { ...info.value, ...payload }
46
+ })
43
47
  }
44
48
 
45
49
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
- "version": "0.47.3",
3
+ "version": "0.47.5",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -20,9 +20,9 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@antfu/utils": "^0.7.7",
23
- "@iconify-json/carbon": "^1.1.28",
23
+ "@iconify-json/carbon": "^1.1.30",
24
24
  "@iconify-json/ph": "^1.1.11",
25
- "@shikijs/vitepress-twoslash": "^1.0.0-beta.5",
25
+ "@shikijs/vitepress-twoslash": "^1.1.1",
26
26
  "@unhead/vue": "^1.8.10",
27
27
  "@unocss/reset": "^0.58.5",
28
28
  "@vueuse/core": "^10.7.2",
@@ -44,12 +44,12 @@
44
44
  "recordrtc": "^5.6.2",
45
45
  "resolve": "^1.22.8",
46
46
  "unocss": "^0.58.5",
47
- "vue": "^3.4.15",
47
+ "vue": "^3.4.18",
48
48
  "vue-router": "^4.2.5",
49
- "@slidev/parser": "0.47.3",
50
- "@slidev/types": "0.47.3"
49
+ "@slidev/parser": "0.47.5",
50
+ "@slidev/types": "0.47.5"
51
51
  },
52
52
  "devDependencies": {
53
- "vite": "^5.0.12"
53
+ "vite": "^5.1.1"
54
54
  }
55
55
  }
@@ -1,6 +1,6 @@
1
1
  import type { Ref, WritableComputedRef } from 'vue'
2
2
  import { watch } from 'vue'
3
- import * as CodeMirror from 'codemirror'
3
+ import * as _CodeMirror from 'codemirror'
4
4
  import 'codemirror/mode/javascript/javascript'
5
5
  import 'codemirror/mode/css/css'
6
6
  import 'codemirror/mode/markdown/markdown'
@@ -9,6 +9,10 @@ import 'codemirror/mode/htmlmixed/htmlmixed'
9
9
  import 'codemirror/addon/display/placeholder'
10
10
  import 'codemirror/lib/codemirror.css'
11
11
 
12
+ // eslint-disable-next-line ts/ban-ts-comment
13
+ // @ts-expect-error
14
+ const CodeMirror: typeof _CodeMirror = _CodeMirror.fromTextArea ? _CodeMirror : globalThis.CodeMirror
15
+
12
16
  export async function useCodeMirror(
13
17
  textarea: Ref<HTMLTextAreaElement | null | undefined>,
14
18
  input: Ref<string> | WritableComputedRef<string>,