@slidev/client 0.48.0-beta.24 → 0.48.0-beta.25
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/Link.vue +3 -1
- package/builtin/TocList.vue +2 -2
- package/composables/useClicks.ts +13 -50
- package/composables/useDrawings.ts +181 -0
- package/composables/useNav.ts +167 -7
- package/composables/useSwipeControls.ts +5 -2
- package/composables/useTocTree.ts +25 -7
- package/composables/useViewTransition.ts +1 -1
- package/internals/CodeRunner.vue +4 -1
- package/internals/DrawingControls.vue +11 -10
- package/internals/DrawingLayer.vue +4 -2
- package/internals/DrawingPreview.vue +4 -2
- package/internals/Goto.vue +4 -2
- package/internals/NavControls.vue +21 -3
- package/internals/PrintContainer.vue +3 -1
- package/internals/PrintSlide.vue +3 -3
- package/internals/QuickOverview.vue +5 -4
- package/internals/SideEditor.vue +4 -2
- package/internals/SlideContainer.vue +3 -1
- package/internals/SlidesShow.vue +16 -4
- package/logic/overview.ts +1 -1
- package/logic/route.ts +6 -9
- package/logic/slides.ts +5 -4
- package/main.ts +1 -16
- package/modules/context.ts +0 -40
- package/package.json +3 -3
- package/pages/notes.vue +3 -1
- package/pages/overview.vue +6 -3
- package/pages/play.vue +6 -3
- package/pages/presenter/print.vue +3 -1
- package/pages/presenter.vue +19 -6
- package/pages/print.vue +3 -1
- package/routes.ts +0 -8
- package/setup/code-runners.ts +6 -11
- package/setup/main.ts +39 -9
- package/setup/mermaid.ts +5 -6
- package/setup/monaco.ts +7 -9
- package/setup/root.ts +56 -11
- package/setup/shortcuts.ts +14 -12
- package/styles/shiki-twoslash.css +1 -1
- package/composables/useContext.ts +0 -12
- package/logic/drawings.ts +0 -161
- package/logic/nav-state.ts +0 -20
- package/logic/nav.ts +0 -71
- package/setup/prettier.ts +0 -43
- /package/{composables → logic}/hmr.ts +0 -0
- /package/{setup → modules}/codemirror.ts +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
3
|
-
import { drauu, drawingEnabled, loadCanvas } from '../logic/drawings'
|
|
4
3
|
import { useSlideContext } from '../context'
|
|
4
|
+
import { useDrawings } from '../composables/useDrawings'
|
|
5
|
+
|
|
6
|
+
const { drauu, drawingEnabled, loadCanvas } = useDrawings()
|
|
5
7
|
|
|
6
8
|
const scale = useSlideContext().$scale
|
|
7
9
|
const svg = ref<SVGSVGElement>()
|
|
@@ -23,4 +25,4 @@ onBeforeUnmount(() => {
|
|
|
23
25
|
class="w-full h-full absolute top-0"
|
|
24
26
|
:class="{ 'pointer-events-none': !drawingEnabled, 'touch-none': drawingEnabled }"
|
|
25
27
|
/>
|
|
26
|
-
</template
|
|
28
|
+
</template>../composables/drawings
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { useDrawings } from '../composables/useDrawings'
|
|
3
3
|
|
|
4
4
|
defineProps<{ page: number }>()
|
|
5
|
+
|
|
6
|
+
const { drawingState } = useDrawings()
|
|
5
7
|
</script>
|
|
6
8
|
|
|
7
9
|
<template>
|
|
@@ -10,4 +12,4 @@ defineProps<{ page: number }>()
|
|
|
10
12
|
class="w-full h-full absolute top-0 pointer-events-none"
|
|
11
13
|
v-html="drawingState[page]"
|
|
12
14
|
/>
|
|
13
|
-
</template
|
|
15
|
+
</template>../composables/drawings
|
package/internals/Goto.vue
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, ref, watch } from 'vue'
|
|
3
3
|
import Fuse from 'fuse.js'
|
|
4
|
-
import { go, slides } from '../logic/nav'
|
|
5
4
|
import { activeElement, showGotoDialog } from '../state'
|
|
6
|
-
import
|
|
5
|
+
import { useNav } from '../composables/useNav'
|
|
6
|
+
import Titles from '#slidev/title-renderer'
|
|
7
7
|
|
|
8
8
|
const container = ref<HTMLDivElement>()
|
|
9
9
|
const input = ref<HTMLInputElement>()
|
|
@@ -12,6 +12,8 @@ const items = ref<HTMLLIElement[]>()
|
|
|
12
12
|
const text = ref('')
|
|
13
13
|
const selectedIndex = ref(0)
|
|
14
14
|
|
|
15
|
+
const { go, slides } = useNav()
|
|
16
|
+
|
|
15
17
|
function notNull<T>(value: T | null | undefined): value is T {
|
|
16
18
|
return value !== null && value !== undefined
|
|
17
19
|
}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
import { computed, ref, shallowRef } from 'vue'
|
|
3
3
|
import { isColorSchemaConfigured, isDark, toggleDark } from '../logic/dark'
|
|
4
4
|
import { downloadPDF } from '../utils'
|
|
5
|
-
import { currentRoute, currentSlideNo, getSlidePath, hasNext, hasPrev, isEmbedded, isPresenter, isPresenterAvailable, next, prev, total } from '../logic/nav'
|
|
6
5
|
import { activeElement, breakpoints, fullscreen, presenterLayout, showEditor, showInfoDialog, showPresenterCursor, toggleOverview, togglePresenterLayout } from '../state'
|
|
7
|
-
import { brush, drawingEnabled } from '../logic/drawings'
|
|
8
6
|
import { configs } from '../env'
|
|
7
|
+
import { useNav } from '../composables/useNav'
|
|
8
|
+
import { getSlidePath } from '../logic/slides'
|
|
9
|
+
import { useDrawings } from '../composables/useDrawings'
|
|
9
10
|
import Settings from './Settings.vue'
|
|
10
11
|
import MenuButton from './MenuButton.vue'
|
|
11
12
|
import VerticalDivider from './VerticalDivider.vue'
|
|
@@ -19,6 +20,23 @@ const props = defineProps({
|
|
|
19
20
|
},
|
|
20
21
|
})
|
|
21
22
|
|
|
23
|
+
const {
|
|
24
|
+
currentRoute,
|
|
25
|
+
currentSlideNo,
|
|
26
|
+
hasNext,
|
|
27
|
+
hasPrev,
|
|
28
|
+
isEmbedded,
|
|
29
|
+
isPresenter,
|
|
30
|
+
isPresenterAvailable,
|
|
31
|
+
next,
|
|
32
|
+
prev,
|
|
33
|
+
total,
|
|
34
|
+
} = useNav()
|
|
35
|
+
const {
|
|
36
|
+
brush,
|
|
37
|
+
drawingEnabled,
|
|
38
|
+
} = useDrawings()
|
|
39
|
+
|
|
22
40
|
const md = breakpoints.smaller('md')
|
|
23
41
|
const { isFullscreen, toggle: toggleFullscreen } = fullscreen
|
|
24
42
|
|
|
@@ -166,4 +184,4 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
|
|
|
166
184
|
<CustomNavControls />
|
|
167
185
|
</div>
|
|
168
186
|
</nav>
|
|
169
|
-
</template
|
|
187
|
+
</template>../composables/drawings
|
|
@@ -4,13 +4,15 @@ import { computed } from 'vue'
|
|
|
4
4
|
import { provideLocal } from '@vueuse/core'
|
|
5
5
|
import { configs, slideAspect, slideWidth } from '../env'
|
|
6
6
|
import { injectionSlideScale } from '../constants'
|
|
7
|
-
import {
|
|
7
|
+
import { useNav } from '../composables/useNav'
|
|
8
8
|
import PrintSlide from './PrintSlide.vue'
|
|
9
9
|
|
|
10
10
|
const props = defineProps<{
|
|
11
11
|
width: number
|
|
12
12
|
}>()
|
|
13
13
|
|
|
14
|
+
const { slides, currentRoute } = useNav()
|
|
15
|
+
|
|
14
16
|
const width = computed(() => props.width)
|
|
15
17
|
const height = computed(() => props.width / slideAspect.value)
|
|
16
18
|
|
package/internals/PrintSlide.vue
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { SlideRoute } from '@slidev/types'
|
|
3
3
|
import { useFixedNav } from '../composables/useNav'
|
|
4
|
-
import {
|
|
4
|
+
import { createFixedClicks } from '../composables/useClicks'
|
|
5
5
|
import PrintSlideClick from './PrintSlideClick.vue'
|
|
6
6
|
|
|
7
7
|
const { route } = defineProps<{ route: SlideRoute }>()
|
|
8
|
-
const clicks0 =
|
|
8
|
+
const clicks0 = createFixedClicks(route, 0)
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
11
|
<template>
|
|
@@ -17,7 +17,7 @@ const clicks0 = useFixedClicks(route, 0)
|
|
|
17
17
|
<PrintSlideClick
|
|
18
18
|
v-for="i of clicks0.total"
|
|
19
19
|
:key="i"
|
|
20
|
-
:nav="useFixedNav(route,
|
|
20
|
+
:nav="useFixedNav(route, createFixedClicks(route, i))"
|
|
21
21
|
/>
|
|
22
22
|
</template>
|
|
23
23
|
</template>
|
|
@@ -2,21 +2,22 @@
|
|
|
2
2
|
import { useEventListener, useVModel } from '@vueuse/core'
|
|
3
3
|
import { computed, ref, watchEffect } from 'vue'
|
|
4
4
|
import { breakpoints, showOverview, windowSize } from '../state'
|
|
5
|
-
import { currentSlideNo, go as goSlide, slides } from '../logic/nav'
|
|
6
5
|
import { currentOverviewPage, overviewRowCount } from '../logic/overview'
|
|
7
|
-
import {
|
|
6
|
+
import { createFixedClicks } from '../composables/useClicks'
|
|
8
7
|
import { getSlideClass } from '../utils'
|
|
9
8
|
import { CLICKS_MAX } from '../constants'
|
|
9
|
+
import { useNav } from '../composables/useNav'
|
|
10
10
|
import SlideContainer from './SlideContainer.vue'
|
|
11
11
|
import SlideWrapper from './SlideWrapper.vue'
|
|
12
12
|
import DrawingPreview from './DrawingPreview.vue'
|
|
13
13
|
import IconButton from './IconButton.vue'
|
|
14
14
|
|
|
15
15
|
const props = defineProps<{ modelValue: boolean }>()
|
|
16
|
-
|
|
17
16
|
const emit = defineEmits(['update:modelValue'])
|
|
18
17
|
const value = useVModel(props, 'modelValue', emit)
|
|
19
18
|
|
|
19
|
+
const { currentSlideNo, go: goSlide, slides } = useNav()
|
|
20
|
+
|
|
20
21
|
function close() {
|
|
21
22
|
value.value = false
|
|
22
23
|
}
|
|
@@ -138,7 +139,7 @@ watchEffect(() => {
|
|
|
138
139
|
<SlideWrapper
|
|
139
140
|
:is="route.component"
|
|
140
141
|
v-if="route?.component"
|
|
141
|
-
:clicks-context="
|
|
142
|
+
:clicks-context="createFixedClicks(route, CLICKS_MAX)"
|
|
142
143
|
:class="getSlideClass(route)"
|
|
143
144
|
:route="route"
|
|
144
145
|
render-context="overview"
|
package/internals/SideEditor.vue
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { throttledWatch, useEventListener } from '@vueuse/core'
|
|
3
3
|
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
|
4
4
|
import { activeElement, editorHeight, editorWidth, isInputting, showEditor, isEditorVertical as vertical } from '../state'
|
|
5
|
-
import { useCodeMirror } from '../
|
|
6
|
-
import {
|
|
5
|
+
import { useCodeMirror } from '../modules/codemirror'
|
|
6
|
+
import { useNav } from '../composables/useNav'
|
|
7
7
|
import { useDynamicSlideInfo } from '../composables/useSlideInfo'
|
|
8
8
|
import IconButton from './IconButton.vue'
|
|
9
9
|
|
|
@@ -11,6 +11,8 @@ const props = defineProps<{
|
|
|
11
11
|
resize?: boolean
|
|
12
12
|
}>()
|
|
13
13
|
|
|
14
|
+
const { currentSlideNo, openInEditor } = useNav()
|
|
15
|
+
|
|
14
16
|
const tab = ref<'content' | 'note'>('content')
|
|
15
17
|
const content = ref('')
|
|
16
18
|
const note = ref('')
|
|
@@ -3,7 +3,7 @@ import { provideLocal, useElementSize, useStyleTag } from '@vueuse/core'
|
|
|
3
3
|
import { computed, ref, watchEffect } from 'vue'
|
|
4
4
|
import { configs, slideAspect, slideHeight, slideWidth } from '../env'
|
|
5
5
|
import { injectionSlideScale } from '../constants'
|
|
6
|
-
import {
|
|
6
|
+
import { useNav } from '../composables/useNav'
|
|
7
7
|
|
|
8
8
|
const props = defineProps({
|
|
9
9
|
width: {
|
|
@@ -21,6 +21,8 @@ const props = defineProps({
|
|
|
21
21
|
},
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
+
const { clicksDirection, isPrintMode } = useNav()
|
|
25
|
+
|
|
24
26
|
const root = ref<HTMLDivElement>()
|
|
25
27
|
const element = useElementSize(root)
|
|
26
28
|
|
package/internals/SlidesShow.vue
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { TransitionGroup, computed, shallowRef, watch } from 'vue'
|
|
3
|
-
import {
|
|
3
|
+
import { recomputeAllPoppers } from 'floating-vue'
|
|
4
|
+
import { useNav } from '../composables/useNav'
|
|
4
5
|
import { getSlideClass } from '../utils'
|
|
5
6
|
import { useViewTransition } from '../composables/useViewTransition'
|
|
6
|
-
import { skipTransition } from '../
|
|
7
|
-
import { usePrimaryClicks } from '../composables/useClicks'
|
|
7
|
+
import { skipTransition } from '../logic/hmr'
|
|
8
8
|
import SlideWrapper from './SlideWrapper.vue'
|
|
9
9
|
import PresenterMouse from './PresenterMouse.vue'
|
|
10
10
|
|
|
@@ -15,6 +15,15 @@ defineProps<{
|
|
|
15
15
|
renderContext: 'slide' | 'presenter'
|
|
16
16
|
}>()
|
|
17
17
|
|
|
18
|
+
const {
|
|
19
|
+
currentSlideRoute,
|
|
20
|
+
currentTransition,
|
|
21
|
+
getPrimaryClicks,
|
|
22
|
+
isPresenter,
|
|
23
|
+
nextRoute,
|
|
24
|
+
slides,
|
|
25
|
+
} = useNav()
|
|
26
|
+
|
|
18
27
|
// preload next route
|
|
19
28
|
watch(currentSlideRoute, () => {
|
|
20
29
|
if (currentSlideRoute.value?.meta && currentSlideRoute.value.meta.preload !== false)
|
|
@@ -35,6 +44,8 @@ function onAfterLeave() {
|
|
|
35
44
|
// After transition, we disable it so HMR won't trigger it again
|
|
36
45
|
// We will turn it back on `nav.go` so the normal navigation would still work
|
|
37
46
|
skipTransition.value = true
|
|
47
|
+
// recompute poppers after transition
|
|
48
|
+
recomputeAllPoppers()
|
|
38
49
|
}
|
|
39
50
|
</script>
|
|
40
51
|
|
|
@@ -57,7 +68,7 @@ function onAfterLeave() {
|
|
|
57
68
|
>
|
|
58
69
|
<SlideWrapper
|
|
59
70
|
:is="route.component!"
|
|
60
|
-
:clicks-context="
|
|
71
|
+
:clicks-context="getPrimaryClicks(route)"
|
|
61
72
|
:class="getSlideClass(route)"
|
|
62
73
|
:route="route"
|
|
63
74
|
:render-context="renderContext"
|
|
@@ -86,3 +97,4 @@ function onAfterLeave() {
|
|
|
86
97
|
width: 100%;
|
|
87
98
|
}
|
|
88
99
|
</style>
|
|
100
|
+
../logic/hmr
|
package/logic/overview.ts
CHANGED
package/logic/route.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { WritableComputedRef } from 'vue'
|
|
1
2
|
import { computed, nextTick, ref, unref } from 'vue'
|
|
2
|
-
import {
|
|
3
|
+
import { useRouter } from 'vue-router'
|
|
3
4
|
|
|
4
5
|
export function useRouteQuery<T extends string | string[]>(
|
|
5
6
|
name: string,
|
|
@@ -7,7 +8,9 @@ export function useRouteQuery<T extends string | string[]>(
|
|
|
7
8
|
{
|
|
8
9
|
mode = 'replace',
|
|
9
10
|
} = {},
|
|
10
|
-
) {
|
|
11
|
+
): WritableComputedRef<T> {
|
|
12
|
+
const router = useRouter()
|
|
13
|
+
|
|
11
14
|
return computed<any>({
|
|
12
15
|
get() {
|
|
13
16
|
const data = router.currentRoute.value.query[name]
|
|
@@ -27,14 +30,8 @@ export function useRouteQuery<T extends string | string[]>(
|
|
|
27
30
|
})
|
|
28
31
|
})
|
|
29
32
|
},
|
|
30
|
-
})
|
|
33
|
+
}) as any
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
// force update collected elements when the route is fully resolved
|
|
34
37
|
export const routeForceRefresh = ref(0)
|
|
35
|
-
nextTick(() => {
|
|
36
|
-
router.afterEach(async () => {
|
|
37
|
-
await nextTick()
|
|
38
|
-
routeForceRefresh.value += 1
|
|
39
|
-
})
|
|
40
|
-
})
|
package/logic/slides.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { SlideRoute } from '@slidev/types'
|
|
2
|
-
import { router } from '../routes'
|
|
3
|
-
import { isPresenter } from './nav-state'
|
|
4
2
|
import { slides } from '#slidev/slides'
|
|
5
3
|
|
|
6
|
-
export { slides
|
|
4
|
+
export { slides }
|
|
7
5
|
|
|
8
6
|
export function getSlide(no: number | string) {
|
|
9
7
|
return slides.value.find(
|
|
@@ -11,7 +9,10 @@ export function getSlide(no: number | string) {
|
|
|
11
9
|
)
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
export function getSlidePath(
|
|
12
|
+
export function getSlidePath(
|
|
13
|
+
route: SlideRoute | number | string,
|
|
14
|
+
presenter: boolean,
|
|
15
|
+
) {
|
|
15
16
|
if (typeof route === 'number' || typeof route === 'string')
|
|
16
17
|
route = getSlide(route)!
|
|
17
18
|
const no = route.meta.slide?.frontmatter.routeAlias ?? route.no
|
package/main.ts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
/// <reference types="@slidev/types/client" />
|
|
2
2
|
|
|
3
3
|
import { createApp } from 'vue'
|
|
4
|
-
import { createHead } from '@unhead/vue'
|
|
5
4
|
import App from './App.vue'
|
|
6
5
|
import setupMain from './setup/main'
|
|
7
|
-
import { router } from './routes'
|
|
8
|
-
import { createVClickDirectives } from './modules/v-click'
|
|
9
|
-
import { createVMarkDirective } from './modules/v-mark'
|
|
10
|
-
import { createSlidevContext } from './modules/context'
|
|
11
|
-
|
|
12
|
-
import '#slidev/styles'
|
|
13
|
-
import 'shiki-magic-move/style.css'
|
|
14
6
|
|
|
15
7
|
const app = createApp(App)
|
|
16
|
-
app
|
|
17
|
-
app.use(createHead())
|
|
18
|
-
app.use(createVClickDirectives())
|
|
19
|
-
app.use(createVMarkDirective())
|
|
20
|
-
app.use(createSlidevContext())
|
|
21
|
-
|
|
22
|
-
setupMain({ app, router })
|
|
23
|
-
|
|
8
|
+
setupMain(app)
|
|
24
9
|
app.mount('#app')
|
package/modules/context.ts
CHANGED
|
@@ -1,49 +1,9 @@
|
|
|
1
|
-
import type { App } from 'vue'
|
|
2
|
-
import { computed, reactive, ref, shallowRef } from 'vue'
|
|
3
1
|
import type { ComputedRef } from '@vue/reactivity'
|
|
4
2
|
import type { configs } from '../env'
|
|
5
|
-
import * as nav from '../logic/nav'
|
|
6
|
-
import { isDark } from '../logic/dark'
|
|
7
|
-
import { injectionClicksContext, injectionCurrentPage, injectionRenderContext, injectionSlidevContext } from '../constants'
|
|
8
|
-
import { useContext } from '../composables/useContext'
|
|
9
3
|
import type { SlidevContextNav } from '../composables/useNav'
|
|
10
|
-
import { useFixedClicks } from '../composables/useClicks'
|
|
11
4
|
|
|
12
5
|
export interface SlidevContext {
|
|
13
6
|
nav: SlidevContextNav
|
|
14
7
|
configs: typeof configs
|
|
15
8
|
themeConfigs: ComputedRef<typeof configs['themeConfig']>
|
|
16
9
|
}
|
|
17
|
-
|
|
18
|
-
export function createSlidevContext() {
|
|
19
|
-
return {
|
|
20
|
-
install(app: App) {
|
|
21
|
-
const context = reactive(useContext())
|
|
22
|
-
app.provide(injectionRenderContext, ref('none'))
|
|
23
|
-
app.provide(injectionSlidevContext, context)
|
|
24
|
-
app.provide(injectionCurrentPage, computed(() => context.nav.currentSlideNo))
|
|
25
|
-
app.provide(injectionClicksContext, shallowRef(useFixedClicks()))
|
|
26
|
-
|
|
27
|
-
// allows controls from postMessages
|
|
28
|
-
if (__DEV__) {
|
|
29
|
-
// @ts-expect-error expose global
|
|
30
|
-
window.__slidev__ = context
|
|
31
|
-
window.addEventListener('message', ({ data }) => {
|
|
32
|
-
if (data && data.target === 'slidev') {
|
|
33
|
-
if (data.type === 'navigate') {
|
|
34
|
-
nav.go(+data.no, +data.clicks || 0)
|
|
35
|
-
}
|
|
36
|
-
else if (data.type === 'css-vars') {
|
|
37
|
-
const root = document.documentElement
|
|
38
|
-
for (const [key, value] of Object.entries(data.vars || {}))
|
|
39
|
-
root.style.setProperty(key, value as any)
|
|
40
|
-
}
|
|
41
|
-
else if (data.type === 'color-schema') {
|
|
42
|
-
isDark.value = data.color === 'dark'
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
}
|
|
49
|
-
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.48.0-beta.
|
|
4
|
+
"version": "0.48.0-beta.25",
|
|
5
5
|
"description": "Presentation slides for developers",
|
|
6
6
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"vue": "^3.4.21",
|
|
59
59
|
"vue-demi": "^0.14.7",
|
|
60
60
|
"vue-router": "^4.3.0",
|
|
61
|
-
"@slidev/parser": "0.48.0-beta.
|
|
62
|
-
"@slidev/types": "0.48.0-beta.
|
|
61
|
+
"@slidev/parser": "0.48.0-beta.25",
|
|
62
|
+
"@slidev/types": "0.48.0-beta.25"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"vite": "^5.1.5"
|
package/pages/notes.vue
CHANGED
|
@@ -5,15 +5,17 @@ import { useLocalStorage } from '@vueuse/core'
|
|
|
5
5
|
import { configs } from '../env'
|
|
6
6
|
import { sharedState } from '../state/shared'
|
|
7
7
|
import { fullscreen } from '../state'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
import NoteDisplay from '../internals/NoteDisplay.vue'
|
|
10
10
|
import IconButton from '../internals/IconButton.vue'
|
|
11
|
+
import { useNav } from '../composables/useNav'
|
|
11
12
|
|
|
12
13
|
const slideTitle = configs.titleTemplate.replace('%s', configs.title || 'Slidev')
|
|
13
14
|
useHead({
|
|
14
15
|
title: `Notes - ${slideTitle}`,
|
|
15
16
|
})
|
|
16
17
|
|
|
18
|
+
const { slides, total } = useNav()
|
|
17
19
|
const { isFullscreen, toggle: toggleFullscreen } = fullscreen
|
|
18
20
|
|
|
19
21
|
const scroller = ref<HTMLDivElement>()
|
package/pages/overview.vue
CHANGED
|
@@ -3,8 +3,8 @@ import { computed, nextTick, onMounted, reactive, ref } from 'vue'
|
|
|
3
3
|
import { useHead } from '@unhead/vue'
|
|
4
4
|
import type { ClicksContext, SlideRoute } from '@slidev/types'
|
|
5
5
|
import { configs } from '../env'
|
|
6
|
-
import { getSlidePath
|
|
7
|
-
import {
|
|
6
|
+
import { getSlidePath } from '../logic/slides'
|
|
7
|
+
import { createFixedClicks } from '../composables/useClicks'
|
|
8
8
|
import { isColorSchemaConfigured, isDark, toggleDark } from '../logic/dark'
|
|
9
9
|
import { getSlideClass } from '../utils'
|
|
10
10
|
import SlideContainer from '../internals/SlideContainer.vue'
|
|
@@ -14,6 +14,7 @@ import IconButton from '../internals/IconButton.vue'
|
|
|
14
14
|
import NoteEditable from '../internals/NoteEditable.vue'
|
|
15
15
|
import ClicksSlider from '../internals/ClicksSlider.vue'
|
|
16
16
|
import { CLICKS_MAX } from '../constants'
|
|
17
|
+
import { useNav } from '../composables/useNav'
|
|
17
18
|
|
|
18
19
|
const cardWidth = 450
|
|
19
20
|
|
|
@@ -22,6 +23,8 @@ useHead({
|
|
|
22
23
|
title: `Overview - ${slideTitle}`,
|
|
23
24
|
})
|
|
24
25
|
|
|
26
|
+
const { openInEditor, slides } = useNav()
|
|
27
|
+
|
|
25
28
|
const blocks: Map<number, HTMLElement> = reactive(new Map())
|
|
26
29
|
const activeBlocks = ref<number[]>([])
|
|
27
30
|
const edittingNote = ref<number | null>(null)
|
|
@@ -33,7 +36,7 @@ const clicksContextMap = new WeakMap<SlideRoute, ClicksContext>()
|
|
|
33
36
|
function getClicksContext(route: SlideRoute) {
|
|
34
37
|
// We create a local clicks context to calculate the total clicks of the slide
|
|
35
38
|
if (!clicksContextMap.has(route))
|
|
36
|
-
clicksContextMap.set(route,
|
|
39
|
+
clicksContextMap.set(route, createFixedClicks(route, CLICKS_MAX))
|
|
37
40
|
return clicksContextMap.get(route)!
|
|
38
41
|
}
|
|
39
42
|
|
package/pages/play.vue
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, ref, shallowRef } from 'vue'
|
|
3
3
|
import { isEditorVertical, isScreenVertical, showEditor, slideScale, windowSize } from '../state'
|
|
4
|
-
import { isEmbedded, isPrintMode, next, prev } from '../logic/nav'
|
|
5
4
|
import { useSwipeControls } from '../composables/useSwipeControls'
|
|
6
|
-
import { isDrawing } from '../logic/drawings'
|
|
7
5
|
import { registerShortcuts } from '../logic/shortcuts'
|
|
8
6
|
import { configs } from '../env'
|
|
9
7
|
import Controls from '../internals/Controls.vue'
|
|
@@ -11,9 +9,14 @@ import SlideContainer from '../internals/SlideContainer.vue'
|
|
|
11
9
|
import NavControls from '../internals/NavControls.vue'
|
|
12
10
|
import SlidesShow from '../internals/SlidesShow.vue'
|
|
13
11
|
import PrintStyle from '../internals/PrintStyle.vue'
|
|
12
|
+
import { useNav } from '../composables/useNav'
|
|
13
|
+
import { useDrawings } from '../composables/useDrawings'
|
|
14
14
|
|
|
15
15
|
registerShortcuts()
|
|
16
16
|
|
|
17
|
+
const { next, prev, isEmbedded, isPrintMode } = useNav()
|
|
18
|
+
const { isDrawing } = useDrawings()
|
|
19
|
+
|
|
17
20
|
const root = ref<HTMLDivElement>()
|
|
18
21
|
function onClick(e: MouseEvent) {
|
|
19
22
|
if (showEditor.value)
|
|
@@ -79,4 +82,4 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
|
|
|
79
82
|
</template>
|
|
80
83
|
</div>
|
|
81
84
|
<Controls />
|
|
82
|
-
</template
|
|
85
|
+
</template>../composables/drawings
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { computed } from 'vue'
|
|
3
3
|
import { useStyleTag } from '@vueuse/core'
|
|
4
4
|
import { useHead } from '@unhead/vue'
|
|
5
|
+
import { useNav } from '../../composables/useNav'
|
|
5
6
|
import { configs } from '../../env'
|
|
6
|
-
import { slides, total } from '../../logic/nav'
|
|
7
7
|
import NoteDisplay from '../../internals/NoteDisplay.vue'
|
|
8
8
|
|
|
9
|
+
const { slides, total } = useNav()
|
|
10
|
+
|
|
9
11
|
useStyleTag(`
|
|
10
12
|
@page {
|
|
11
13
|
size: A4;
|
package/pages/presenter.vue
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { useHead } from '@unhead/vue'
|
|
3
3
|
import { computed, onMounted, reactive, ref, shallowRef, watch } from 'vue'
|
|
4
4
|
import { useMouse, useWindowFocus } from '@vueuse/core'
|
|
5
|
-
import { clicksContext, currentSlideNo, currentSlideRoute, hasNext, nextRoute, queryClicks, slides, total } from '../logic/nav'
|
|
6
5
|
import { useSwipeControls } from '../composables/useSwipeControls'
|
|
7
6
|
import { decreasePresenterFontSize, increasePresenterFontSize, presenterLayout, presenterNotesFontSize, showEditor, showOverview, showPresenterCursor } from '../state'
|
|
8
7
|
import { configs } from '../env'
|
|
@@ -10,8 +9,7 @@ import { sharedState } from '../state/shared'
|
|
|
10
9
|
import { registerShortcuts } from '../logic/shortcuts'
|
|
11
10
|
import { getSlideClass } from '../utils'
|
|
12
11
|
import { useTimer } from '../logic/utils'
|
|
13
|
-
import {
|
|
14
|
-
import { useFixedClicks, usePrimaryClicks } from '../composables/useClicks'
|
|
12
|
+
import { createFixedClicks } from '../composables/useClicks'
|
|
15
13
|
import SlideWrapper from '../internals/SlideWrapper.vue'
|
|
16
14
|
import SlideContainer from '../internals/SlideContainer.vue'
|
|
17
15
|
import NavControls from '../internals/NavControls.vue'
|
|
@@ -23,12 +21,27 @@ import SlidesShow from '../internals/SlidesShow.vue'
|
|
|
23
21
|
import DrawingControls from '../internals/DrawingControls.vue'
|
|
24
22
|
import IconButton from '../internals/IconButton.vue'
|
|
25
23
|
import ClicksSlider from '../internals/ClicksSlider.vue'
|
|
24
|
+
import { useNav } from '../composables/useNav'
|
|
25
|
+
import { useDrawings } from '../composables/useDrawings'
|
|
26
26
|
|
|
27
27
|
const main = ref<HTMLDivElement>()
|
|
28
28
|
|
|
29
29
|
registerShortcuts()
|
|
30
30
|
useSwipeControls(main)
|
|
31
31
|
|
|
32
|
+
const {
|
|
33
|
+
clicksContext,
|
|
34
|
+
currentSlideNo,
|
|
35
|
+
currentSlideRoute,
|
|
36
|
+
hasNext,
|
|
37
|
+
nextRoute,
|
|
38
|
+
slides,
|
|
39
|
+
queryClicks,
|
|
40
|
+
getPrimaryClicks,
|
|
41
|
+
total,
|
|
42
|
+
} = useNav()
|
|
43
|
+
const { isDrawing } = useDrawings()
|
|
44
|
+
|
|
32
45
|
const slideTitle = configs.titleTemplate.replace('%s', configs.title || 'Slidev')
|
|
33
46
|
useHead({
|
|
34
47
|
title: `Presenter - ${slideTitle}`,
|
|
@@ -38,7 +51,7 @@ const notesEditing = ref(false)
|
|
|
38
51
|
|
|
39
52
|
const { timer, resetTimer } = useTimer()
|
|
40
53
|
|
|
41
|
-
const clicksCtxMap = computed(() => slides.value.map(route =>
|
|
54
|
+
const clicksCtxMap = computed(() => slides.value.map(route => createFixedClicks(route)))
|
|
42
55
|
const nextFrame = computed(() => {
|
|
43
56
|
if (clicksContext.value.current < clicksContext.value.total)
|
|
44
57
|
return [currentSlideRoute.value!, clicksContext.value.current + 1] as const
|
|
@@ -106,7 +119,7 @@ onMounted(() => {
|
|
|
106
119
|
</SlideContainer>
|
|
107
120
|
<ClicksSlider
|
|
108
121
|
:key="currentSlideRoute?.no"
|
|
109
|
-
:clicks-context="
|
|
122
|
+
:clicks-context="getPrimaryClicks(currentSlideRoute)"
|
|
110
123
|
class="w-full pb2 px4 flex-none"
|
|
111
124
|
/>
|
|
112
125
|
<div class="absolute left-0 top-0 bg-main border-b border-r border-main px2 py1 op50 text-sm">
|
|
@@ -286,4 +299,4 @@ onMounted(() => {
|
|
|
286
299
|
.grid-section.bottom {
|
|
287
300
|
grid-area: bottom;
|
|
288
301
|
}
|
|
289
|
-
</style
|
|
302
|
+
</style>../composables/drawings
|
package/pages/print.vue
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { watchEffect } from 'vue'
|
|
3
3
|
import { windowSize } from '../state'
|
|
4
|
-
import { isPrintMode } from '../logic/nav'
|
|
5
4
|
import PrintContainer from '../internals/PrintContainer.vue'
|
|
6
5
|
import PrintStyle from '../internals/PrintStyle.vue'
|
|
6
|
+
import { useNav } from '../composables/useNav'
|
|
7
|
+
|
|
8
|
+
const { isPrintMode } = useNav()
|
|
7
9
|
|
|
8
10
|
watchEffect(() => {
|
|
9
11
|
if (isPrintMode)
|
package/routes.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router'
|
|
2
|
-
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
|
|
3
2
|
import configs from '#slidev/configs'
|
|
4
3
|
|
|
5
4
|
export const routes: RouteRecordRaw[] = [
|
|
@@ -67,10 +66,3 @@ routes.push({
|
|
|
67
66
|
path: '/:no',
|
|
68
67
|
component: () => import('./pages/play.vue'),
|
|
69
68
|
})
|
|
70
|
-
|
|
71
|
-
export const router = createRouter({
|
|
72
|
-
history: __SLIDEV_HASH_ROUTE__
|
|
73
|
-
? createWebHashHistory(import.meta.env.BASE_URL)
|
|
74
|
-
: createWebHistory(import.meta.env.BASE_URL),
|
|
75
|
-
routes,
|
|
76
|
-
})
|