@slidev/client 0.30.2 → 0.30.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.
package/builtin/Tweet.vue CHANGED
@@ -21,10 +21,11 @@ const tweet = ref<HTMLElement | null>()
21
21
 
22
22
  const vm = getCurrentInstance()!
23
23
  const loaded = ref(false)
24
+ const tweetNotFound = ref(false)
24
25
 
25
26
  async function create() {
26
27
  // @ts-expect-error global
27
- await window.twttr.widgets.createTweet(
28
+ const element = await window.twttr.widgets.createTweet(
28
29
  props.id.toString(),
29
30
  tweet.value,
30
31
  {
@@ -33,6 +34,8 @@ async function create() {
33
34
  },
34
35
  )
35
36
  loaded.value = true
37
+ if (element === undefined)
38
+ tweetNotFound.value = true
36
39
  }
37
40
 
38
41
  // @ts-expect-error global
@@ -55,10 +58,11 @@ else {
55
58
 
56
59
  <template>
57
60
  <Transform :scale="scale || 1">
58
- <div ref="tweet" class="tweet" data-waitfor="iframe">
59
- <div v-if="!loaded" class="w-30 h-30 my-10px bg-gray-400 bg-opacity-10 rounded-lg flex opacity-50">
61
+ <div ref="tweet" class="tweet" :data-waitfor="tweetNotFound ? '' : 'iframe'">
62
+ <div v-if="!loaded || tweetNotFound" class="w-30 h-30 my-10px bg-gray-400 bg-opacity-10 rounded-lg flex opacity-50">
60
63
  <div class="m-auto animate-pulse text-4xl">
61
64
  <carbon:logo-twitter />
65
+ <span v-if="tweetNotFound">Could not load tweet with id="{{ props.id }}"</span>
62
66
  </div>
63
67
  </div>
64
68
  </div>
@@ -8,7 +8,7 @@ import Goto from './Goto.vue'
8
8
 
9
9
  const WebCamera = shallowRef<any>()
10
10
  const RecordingDialog = shallowRef<any>()
11
- if (__DEV__) {
11
+ if (__SLIDEV_FEATURE_RECORD__) {
12
12
  import('./WebCamera.vue').then(v => WebCamera.value = v.default)
13
13
  import('./RecordingDialog.vue').then(v => RecordingDialog.value = v.default)
14
14
  }
@@ -17,9 +17,7 @@ if (__DEV__) {
17
17
  <template>
18
18
  <SlidesOverview v-model="showOverview" />
19
19
  <Goto />
20
- <template v-if="__DEV__">
21
- <WebCamera v-if="WebCamera" />
22
- <RecordingDialog v-if="RecordingDialog" v-model="showRecordingDialog" />
23
- </template>
20
+ <WebCamera v-if="WebCamera" />
21
+ <RecordingDialog v-if="RecordingDialog" v-model="showRecordingDialog" />
24
22
  <InfoDialog v-if="configs.info" v-model="showInfoDialog" />
25
23
  </template>
@@ -1,16 +1,29 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, nextTick, ref, watch } from 'vue'
3
- import { go, total } from '../logic/nav'
3
+ import { go, rawRoutes, total } from '../logic/nav'
4
4
  import { showGotoDialog } from '../state'
5
5
 
6
6
  const input = ref<HTMLInputElement>()
7
7
  const text = ref('')
8
- const num = computed(() => +text.value)
9
- const valid = computed(() => !isNaN(num.value) && num.value > 0 && num.value <= total.value)
8
+
9
+ const valid = computed(() => {
10
+ if (text.value.startsWith('/')) {
11
+ return !!rawRoutes.find(r => r.path === text.value.substring(1))
12
+ }
13
+ else {
14
+ const num = +text.value
15
+ return !isNaN(num) && num > 0 && num <= total.value
16
+ }
17
+ })
10
18
 
11
19
  function goTo() {
12
- if (valid.value)
13
- go(num.value)
20
+ if (valid.value) {
21
+ if (text.value.startsWith('/'))
22
+ go(text.value.substring(1))
23
+
24
+ else
25
+ go(+text.value)
26
+ }
14
27
  close()
15
28
  }
16
29
 
@@ -31,8 +44,8 @@ watch(showGotoDialog, async(show) => {
31
44
 
32
45
  // remove the g character coming from the key that triggered showGotoDialog (e.g. in Firefox)
33
46
  watch(text, (t) => {
34
- if (t.match(/^[^0-9]/))
35
- text.value = text.value.substr(1)
47
+ if (t.match(/^[^0-9/]/))
48
+ text.value = text.value.substring(1)
36
49
  })
37
50
  </script>
38
51
 
@@ -35,7 +35,7 @@ const barStyle = computed(() => props.persist
35
35
  )
36
36
 
37
37
  const RecordingControls = shallowRef<any>()
38
- if (__DEV__)
38
+ if (__SLIDEV_FEATURE_RECORD__)
39
39
  import('./RecordingControls.vue').then(v => RecordingControls.value = v.default)
40
40
 
41
41
  const DrawingControls = shallowRef<any>()
@@ -79,7 +79,7 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
79
79
 
80
80
  <VerticalDivider />
81
81
 
82
- <template v-if="__DEV__ && !isEmbedded">
82
+ <template v-if="!isEmbedded">
83
83
  <template v-if="!isPresenter && !md && RecordingControls">
84
84
  <RecordingControls />
85
85
  <VerticalDivider />
package/logic/nav.ts CHANGED
@@ -113,7 +113,7 @@ export async function prevSlide(lastClicks = true) {
113
113
  router.replace({ query: { ...route.value.query, clicks: clicksTotal.value } })
114
114
  }
115
115
 
116
- export function go(page: number, clicks?: number) {
116
+ export function go(page: number | string, clicks?: number) {
117
117
  return router.push({ path: getPath(page), query: { ...route.value.query, clicks } })
118
118
  }
119
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
- "version": "0.30.2",
3
+ "version": "0.30.3",
4
4
  "description": "Presentation slides for developers",
5
5
  "homepage": "https://sli.dev",
6
6
  "bugs": "https://github.com/slidevjs/slidev/issues",
@@ -13,8 +13,8 @@
13
13
  "funding": "https://github.com/sponsors/antfu",
14
14
  "dependencies": {
15
15
  "@antfu/utils": "^0.5.1",
16
- "@slidev/parser": "0.30.2",
17
- "@slidev/types": "0.30.2",
16
+ "@slidev/parser": "0.30.3",
17
+ "@slidev/types": "0.30.3",
18
18
  "@vueuse/core": "^8.2.5",
19
19
  "@vueuse/head": "^0.7.5",
20
20
  "@vueuse/motion": "^2.0.0-beta.18",