@slidev/client 0.38.3 → 0.38.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.
@@ -0,0 +1,8 @@
1
+ <script setup lang="ts">
2
+ import { isDark } from '../logic/dark'
3
+ </script>
4
+
5
+ <template>
6
+ <slot v-if="isDark" name="dark" />
7
+ <slot v-else name="light" />
8
+ </template>
package/builtin/Toc.vue CHANGED
@@ -9,7 +9,7 @@ Usage:
9
9
  -->
10
10
  <script setup lang='ts'>
11
11
  import { computed, inject } from 'vue'
12
- import type { TocItem } from '../logic/nav'
12
+ import type { TocItem } from '@slidev/types'
13
13
  import { injectionSlidevContext } from '../constants'
14
14
 
15
15
  const props = withDefaults(
@@ -9,9 +9,9 @@ Usage:
9
9
  <script setup lang="ts">
10
10
  import { computed } from 'vue'
11
11
  import { toArray } from '@antfu/utils'
12
+ import type { TocItem } from '@slidev/types'
12
13
  // @ts-expect-error virtual module
13
14
  import Titles from '/@slidev/titles.md'
14
- import type { TocItem } from '../logic/nav'
15
15
 
16
16
  const props = withDefaults(defineProps<{
17
17
  level: number
@@ -47,3 +47,9 @@ const classes = computed(() => {
47
47
  </li>
48
48
  </ol>
49
49
  </template>
50
+
51
+ <style>
52
+ .slidev-toc-item p {
53
+ margin: 0;
54
+ }
55
+ </style>
@@ -1,7 +1,7 @@
1
1
  import type { ComputedRef } from 'vue'
2
2
  import { computed } from 'vue'
3
3
  import type { RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router'
4
- import type { TocItem } from '../logic/nav'
4
+ import type { TocItem } from '@slidev/types'
5
5
  import { addToTree, filterTree, getPath, getTreeWithActiveStatuses } from '../logic/nav'
6
6
  import { rawRoutes } from '../routes'
7
7
 
@@ -97,7 +97,7 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
97
97
  </button>
98
98
  </template>
99
99
 
100
- <template v-if="__SLIDEV_FEATURE_DRAWINGS__ && !configs.drawings.presenterOnly && !isEmbedded">
100
+ <template v-if="__SLIDEV_FEATURE_DRAWINGS__ && (!configs.drawings.presenterOnly || isPresenter) && !isEmbedded">
101
101
  <button class="icon-btn relative" title="Drawing" @click="drawingEnabled = !drawingEnabled">
102
102
  <carbon:pen />
103
103
  <div
@@ -113,7 +113,7 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
113
113
  <RouterLink v-if="isPresenter" :to="nonPresenterLink" class="icon-btn" title="Play Mode">
114
114
  <carbon:presentation-file />
115
115
  </RouterLink>
116
- <RouterLink v-if="showPresenter" :to="presenterLink" class="icon-btn" title="Presenter Mode">
116
+ <RouterLink v-if="__SLIDEV_FEATURE_PRESENTER__ && showPresenter" :to="presenterLink" class="icon-btn" title="Presenter Mode">
117
117
  <carbon:user-speaker />
118
118
  </RouterLink>
119
119
 
@@ -3,7 +3,7 @@ import { parseRangeString } from '@slidev/parser/core'
3
3
  import { computed, provide } from 'vue'
4
4
  import { configs, slideAspect, slideWidth } from '../env'
5
5
  import { injectionSlideScale } from '../constants'
6
- import { rawRoutes, route } from '../logic/nav'
6
+ import { route as currentRoute, rawRoutes } from '../logic/nav'
7
7
  import PrintSlide from './PrintSlide.vue'
8
8
 
9
9
  const props = defineProps<{
@@ -23,8 +23,8 @@ const scale = computed(() => {
23
23
 
24
24
  // Remove the "end" slide
25
25
  let routes = rawRoutes.slice(0, -1)
26
- if (route.value.query.range) {
27
- const r = parseRangeString(routes.length, route.value.query.range)
26
+ if (currentRoute.value.query.range) {
27
+ const r = parseRangeString(routes.length, currentRoute.value.query.range as string)
28
28
  routes = r.map(i => routes[i - 1])
29
29
  }
30
30
 
@@ -71,8 +71,8 @@ watchEffect(() => {
71
71
  class="relative"
72
72
  >
73
73
  <div
74
- class="inline-block border border-gray-400 rounded border-opacity-50 overflow-hidden bg-main hover:border-$slidev-theme-primary"
75
- :class="{ 'border-$slidev-theme-primary': focus(idx + 1) }"
74
+ class="inline-block border rounded border-opacity-50 overflow-hidden bg-main hover:border-$slidev-theme-primary"
75
+ :class="{ 'border-$slidev-theme-primary': focus(idx + 1), 'border-gray-400': !focus(idx + 1) }"
76
76
  :style="themeVars"
77
77
  @click="go(+route.path)"
78
78
  >
package/logic/drawings.ts CHANGED
@@ -52,7 +52,7 @@ export const drawingMode = computed({
52
52
 
53
53
  export const drauuOptions: DrauuOptions = reactive({
54
54
  brush,
55
- acceptsInputTypes: computed(() => drawingEnabled.value ? undefined : ['pen' as const]),
55
+ acceptsInputTypes: computed(() => (drawingEnabled.value && (!configs.drawings.presenterOnly || isPresenter.value)) ? undefined : ['pen' as const]),
56
56
  coordinateTransform: false,
57
57
  })
58
58
  export const drauu = markRaw(createDrauu(drauuOptions))
package/logic/nav.ts CHANGED
@@ -1,23 +1,13 @@
1
1
  import type { Ref } from 'vue'
2
2
  import type { RouteRecordRaw } from 'vue-router'
3
3
  import { computed, nextTick, ref } from 'vue'
4
+ import type { TocItem } from '@slidev/types'
4
5
  import { SwipeDirection, isString, timestamp, usePointerSwipe } from '@vueuse/core'
5
6
  import { rawRoutes, router } from '../routes'
6
7
  import { configs } from '../env'
7
8
  import { useRouteQuery } from './route'
8
9
  import { isDrawing } from './drawings'
9
10
 
10
- export interface TocItem {
11
- active?: boolean
12
- activeParent?: boolean
13
- children: TocItem[]
14
- hasActiveParent?: boolean
15
- level: number
16
- path: string
17
- hideInToc?: boolean
18
- title?: string
19
- }
20
-
21
11
  export { rawRoutes, router }
22
12
 
23
13
  // force update collected elements when the route is fully resolved
@@ -23,7 +23,6 @@ export function renderMermaid(encoded: string, options: any) {
23
23
  })
24
24
  const code = decode(encoded)
25
25
  const id = nanoid()
26
- // @ts-expect-error type mistake
27
26
  const svg = mermaid.render(id, code) as string
28
27
  cache.set(key, svg)
29
28
  return svg
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
- "version": "0.38.3",
3
+ "version": "0.38.5",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -16,34 +16,34 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@antfu/utils": "^0.7.2",
19
- "@unocss/reset": "^0.47.6",
20
- "@vueuse/core": "^9.7.0",
21
- "@vueuse/head": "^1.0.22",
22
- "@vueuse/math": "^9.7.0",
19
+ "@unocss/reset": "^0.48.4",
20
+ "@vueuse/core": "^9.11.1",
21
+ "@vueuse/head": "^1.0.23",
22
+ "@vueuse/math": "^9.11.1",
23
23
  "@vueuse/motion": "^2.0.0-beta.26",
24
24
  "codemirror": "^5.65.5",
25
- "defu": "^6.1.1",
25
+ "defu": "^6.1.2",
26
26
  "drauu": "^0.3.2",
27
27
  "file-saver": "^2.0.5",
28
- "js-base64": "^3.7.3",
28
+ "js-base64": "^3.7.4",
29
29
  "js-yaml": "^4.1.0",
30
30
  "katex": "^0.16.4",
31
31
  "mermaid": "^9.3.0",
32
32
  "monaco-editor": "^0.33.0",
33
33
  "nanoid": "^4.0.0",
34
- "prettier": "^2.8.1",
34
+ "prettier": "^2.8.3",
35
35
  "recordrtc": "^5.6.2",
36
36
  "resolve": "^1.22.1",
37
- "unocss": "^0.47.6",
37
+ "unocss": "^0.48.4",
38
38
  "vite-plugin-windicss": "^1.8.10",
39
39
  "vue": "^3.2.45",
40
40
  "vue-router": "^4.1.6",
41
41
  "vue-starport": "^0.3.0",
42
42
  "windicss": "^3.5.6",
43
- "@slidev/parser": "0.38.3",
44
- "@slidev/types": "0.38.3"
43
+ "@slidev/parser": "0.38.5",
44
+ "@slidev/types": "0.38.5"
45
45
  },
46
46
  "devDependencies": {
47
- "vite": "^4.0.2"
47
+ "vite": "^4.0.4"
48
48
  }
49
49
  }
package/routes.ts CHANGED
@@ -20,8 +20,11 @@ export const routes: RouteRecordRaw[] = [
20
20
  { name: 'print', path: '/print', component: Print },
21
21
  { path: '', redirect: { path: '/1' } },
22
22
  { path: '/:pathMatch(.*)', redirect: { path: '/1' } },
23
- { path: '/presenter/print', component: () => import('./internals/PresenterPrint.vue') },
24
- {
23
+ ]
24
+
25
+ if (__SLIDEV_FEATURE_PRESENTER__) {
26
+ routes.push({ path: '/presenter/print', component: () => import('./internals/PresenterPrint.vue') })
27
+ routes.push({
25
28
  name: 'presenter',
26
29
  path: '/presenter/:no',
27
30
  component: () => import('./internals/Presenter.vue'),
@@ -38,12 +41,12 @@ export const routes: RouteRecordRaw[] = [
38
41
  return { path: `/${to.params.no}` }
39
42
  return { path: '' }
40
43
  },
41
- },
42
- {
44
+ })
45
+ routes.push({
43
46
  path: '/presenter',
44
47
  redirect: { path: '/presenter/1' },
45
- },
46
- ]
48
+ })
49
+ }
47
50
 
48
51
  export const router = createRouter({
49
52
  history: __SLIDEV_HASH_ROUTE__ ? createWebHashHistory(import.meta.env.BASE_URL) : createWebHistory(import.meta.env.BASE_URL),
package/setup/root.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /* __imports__ */
2
2
  import { watch } from 'vue'
3
- import { useHead } from '@vueuse/head'
3
+ import { useHead, useHtmlAttrs } from '@vueuse/head'
4
4
  import { configs } from '../env'
5
5
  import { initSharedState, onPatch, patch } from '../state/shared'
6
6
  import { initDrawingState } from '../state/drawings'
@@ -16,6 +16,7 @@ export default function setupRoot() {
16
16
 
17
17
  const title = configs.titleTemplate.replace('%s', configs.title || 'Slidev')
18
18
  useHead({ title })
19
+ useHtmlAttrs(configs.htmlAttrs)
19
20
  initSharedState(`${title} - shared`)
20
21
  initDrawingState(`${title} - drawings`)
21
22
 
@@ -7,7 +7,7 @@ export function createSyncState<State extends object>(serverState: State, defaul
7
7
  let patchingTimeout: NodeJS.Timeout
8
8
  let updatingTimeout: NodeJS.Timeout
9
9
 
10
- const state = __DEV__
10
+ const state = __USE_SERVER__
11
11
  ? reactive<State>(serverState) as State
12
12
  : reactive<State>(defaultState) as State
13
13
 
@@ -35,11 +35,11 @@ export function createSyncState<State extends object>(serverState: State, defaul
35
35
 
36
36
  function init(channelKey: string) {
37
37
  let stateChannel: BroadcastChannel
38
- if (!__DEV__ && !persist) {
38
+ if (!__USE_SERVER__ && !persist) {
39
39
  stateChannel = new BroadcastChannel(channelKey)
40
40
  stateChannel.addEventListener('message', (event: MessageEvent<Partial<State>>) => onUpdate(event.data))
41
41
  }
42
- else if (!__DEV__ && persist) {
42
+ else if (!__USE_SERVER__ && persist) {
43
43
  window.addEventListener('storage', (event) => {
44
44
  if (event && event.key === channelKey && event.newValue)
45
45
  onUpdate(JSON.parse(event.newValue) as Partial<State>)
@@ -56,7 +56,7 @@ export function createSyncState<State extends object>(serverState: State, defaul
56
56
  }
57
57
 
58
58
  watch(state, onDrawingStateChanged, { deep: true })
59
- if (!__DEV__ && persist) {
59
+ if (!__USE_SERVER__ && persist) {
60
60
  const serialzedState = window.localStorage.getItem(channelKey)
61
61
  if (serialzedState)
62
62
  onUpdate(JSON.parse(serialzedState) as Partial<State>)
@@ -6,7 +6,7 @@
6
6
  }
7
7
 
8
8
  h1 {
9
- @apply text-4xl mb-4 -ml-[0.05em];
9
+ @apply text-4xl mb-4;
10
10
  }
11
11
 
12
12
  h2 {
@@ -26,7 +26,7 @@
26
26
  }
27
27
 
28
28
  h6 {
29
- @apply text-sm pt-1 uppercase tracking-widest font-500 -ml-[0.05em];
29
+ @apply text-sm pt-1 uppercase tracking-widest font-500;
30
30
  }
31
31
 
32
32
  h6:not(.opacity-100) {
@@ -46,7 +46,7 @@
46
46
  }
47
47
 
48
48
  li {
49
- @apply ml-1.1em pl-0.2em leading-1.8em;
49
+ @apply leading-1.8em;
50
50
  }
51
51
 
52
52
  blockquote {
@@ -86,3 +86,34 @@
86
86
  @apply bg-gray-400 bg-opacity-5 py-0.5 px-1 text-xs font-mono;
87
87
  }
88
88
  }
89
+
90
+ .slidev-layout,
91
+ [dir=ltr],
92
+ .slidev-layout [dir=ltr] {
93
+ h1 {
94
+ @apply -ml-[0.05em] mr-0;
95
+ }
96
+
97
+ h6 {
98
+ @apply -ml-[0.05em] mr-0;
99
+ }
100
+
101
+ li {
102
+ @apply ml-1.1em pl-0.2em mr-0 pr-0;
103
+ }
104
+ }
105
+
106
+ [dir=rtl],
107
+ .slidev-layout [dir=rtl] {
108
+ h1 {
109
+ @apply -mr-[0.05em] ml-0;
110
+ }
111
+
112
+ h6 {
113
+ @apply -mr-[0.05em] ml-0;
114
+ }
115
+
116
+ li {
117
+ @apply mr-1.1em pr-0.2em ml-0 pl-0;
118
+ }
119
+ }