@slidev/client 0.48.0-beta.1 → 0.48.0-beta.11
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/CodeBlockWrapper.vue +4 -3
- package/builtin/KaTexBlockWrapper.vue +4 -3
- package/builtin/RenderWhen.vue +3 -3
- package/builtin/SlideCurrentNo.vue +2 -3
- package/builtin/SlidesTotal.vue +3 -4
- package/builtin/SlidevVideo.vue +8 -6
- package/builtin/Toc.vue +3 -3
- package/builtin/TocList.vue +3 -2
- package/builtin/Tweet.vue +4 -15
- package/builtin/VClickGap.vue +3 -5
- package/builtin/VClicks.ts +1 -1
- package/composables/useClicks.ts +19 -13
- package/composables/useTweetScript.ts +17 -0
- package/constants.ts +56 -8
- package/context.ts +70 -0
- package/env.ts +3 -12
- package/internals/DrawingControls.vue +39 -9
- package/internals/DrawingLayer.vue +3 -2
- package/internals/Editor.vue +7 -3
- package/internals/Goto.vue +5 -4
- package/internals/IconButton.vue +4 -3
- package/internals/InfoDialog.vue +1 -1
- package/internals/Modal.vue +1 -1
- package/internals/NavControls.vue +2 -3
- package/internals/NoteDisplay.vue +1 -1
- package/internals/NoteEditor.vue +36 -8
- package/internals/NoteStatic.vue +5 -6
- package/internals/PrintContainer.vue +3 -2
- package/internals/PrintSlideClick.vue +5 -7
- package/internals/RecordingDialog.vue +5 -6
- package/internals/SlideContainer.vue +12 -9
- package/internals/SlideWrapper.ts +28 -12
- package/internals/SlidesOverview.vue +18 -7
- package/internals/SlidesShow.vue +7 -8
- package/layouts/two-cols-header.vue +9 -3
- package/logic/drawings.ts +6 -3
- package/logic/nav.ts +6 -1
- package/logic/note.ts +7 -7
- package/main.ts +8 -4
- package/modules/context.ts +4 -3
- package/modules/{directives.ts → v-click.ts} +15 -15
- package/modules/v-mark.ts +159 -0
- package/package.json +21 -13
- package/{internals/EntrySelect.vue → pages/entry.vue} +7 -0
- package/{internals/NotesView.vue → pages/notes.vue} +3 -3
- package/pages/overview.vue +201 -0
- package/{internals/Play.vue → pages/play.vue} +7 -7
- package/{internals/PresenterPrint.vue → pages/presenter/print.vue} +7 -5
- package/{internals/Presenter.vue → pages/presenter.vue} +64 -58
- package/{internals/Print.vue → pages/print.vue} +2 -2
- package/routes.ts +27 -51
- package/setup/codemirror.ts +7 -0
- package/shim-vue.d.ts +35 -0
- package/shim.d.ts +0 -12
- package/state/index.ts +10 -10
- package/styles/code.css +7 -3
- package/styles/index.css +18 -6
- package/styles/katex.css +1 -1
- package/styles/layouts-base.css +17 -12
- package/styles/vars.css +1 -0
- package/uno.config.ts +14 -2
|
@@ -14,11 +14,12 @@ Learn more: https://sli.dev/guide/syntax.html#line-highlighting
|
|
|
14
14
|
<script setup lang="ts">
|
|
15
15
|
import { parseRangeString } from '@slidev/parser/core'
|
|
16
16
|
import { useClipboard } from '@vueuse/core'
|
|
17
|
-
import { computed,
|
|
17
|
+
import { computed, onMounted, onUnmounted, ref, watchEffect } from 'vue'
|
|
18
18
|
import type { PropType } from 'vue'
|
|
19
19
|
import { configs } from '../env'
|
|
20
20
|
import { makeId } from '../logic/utils'
|
|
21
|
-
import { CLASS_VCLICK_HIDDEN, CLASS_VCLICK_TARGET
|
|
21
|
+
import { CLASS_VCLICK_HIDDEN, CLASS_VCLICK_TARGET } from '../constants'
|
|
22
|
+
import { useSlideContext } from '../context'
|
|
22
23
|
|
|
23
24
|
const props = defineProps({
|
|
24
25
|
ranges: {
|
|
@@ -47,7 +48,7 @@ const props = defineProps({
|
|
|
47
48
|
},
|
|
48
49
|
})
|
|
49
50
|
|
|
50
|
-
const clicks =
|
|
51
|
+
const { $clicksContext: clicks } = useSlideContext()
|
|
51
52
|
const el = ref<HTMLDivElement>()
|
|
52
53
|
const id = makeId()
|
|
53
54
|
|
|
@@ -20,11 +20,12 @@ Learn more: https://sli.dev/guide/syntax.html#latex-line-highlighting
|
|
|
20
20
|
-->
|
|
21
21
|
|
|
22
22
|
<script setup lang="ts">
|
|
23
|
-
import { computed,
|
|
23
|
+
import { computed, onMounted, onUnmounted, ref, watchEffect } from 'vue'
|
|
24
24
|
import type { PropType } from 'vue'
|
|
25
25
|
import { parseRangeString } from '@slidev/parser'
|
|
26
|
-
import { CLASS_VCLICK_HIDDEN, CLASS_VCLICK_TARGET
|
|
26
|
+
import { CLASS_VCLICK_HIDDEN, CLASS_VCLICK_TARGET } from '../constants'
|
|
27
27
|
import { makeId } from '../logic/utils'
|
|
28
|
+
import { useSlideContext } from '../context'
|
|
28
29
|
|
|
29
30
|
const props = defineProps({
|
|
30
31
|
ranges: {
|
|
@@ -45,7 +46,7 @@ const props = defineProps({
|
|
|
45
46
|
},
|
|
46
47
|
})
|
|
47
48
|
|
|
48
|
-
const clicks =
|
|
49
|
+
const { $clicksContext: clicks } = useSlideContext()
|
|
49
50
|
const el = ref<HTMLDivElement>()
|
|
50
51
|
const id = makeId()
|
|
51
52
|
|
package/builtin/RenderWhen.vue
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { RenderContext } from '@slidev/types'
|
|
3
|
-
import { computed,
|
|
3
|
+
import { computed, ref } from 'vue'
|
|
4
4
|
import { useElementVisibility } from '@vueuse/core'
|
|
5
|
-
import {
|
|
5
|
+
import { useSlideContext } from '../context'
|
|
6
6
|
|
|
7
7
|
type Context = 'main' | 'visible' | RenderContext
|
|
8
8
|
|
|
@@ -16,7 +16,7 @@ const targetVisible = useElementVisibility(target)
|
|
|
16
16
|
// When context has `visible`, we need to wrap the content with a div to track the visibility
|
|
17
17
|
const needsDomWrapper = Array.isArray(context) ? context.includes('visible') : context === 'visible'
|
|
18
18
|
|
|
19
|
-
const currentContext =
|
|
19
|
+
const { $renderContext: currentContext } = useSlideContext()
|
|
20
20
|
const shouldRender = computed(() => {
|
|
21
21
|
const anyContext = Array.isArray(context) ? context.some(contextMatch) : contextMatch(context)
|
|
22
22
|
const allConditions = Array.isArray(context) ? context.every(conditionsMatch) : conditionsMatch(context)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import { injectionCurrentPage } from '../constants'
|
|
2
|
+
import { useSlideContext } from '../context'
|
|
4
3
|
|
|
5
|
-
const $page =
|
|
4
|
+
const { $page } = useSlideContext()
|
|
6
5
|
</script>
|
|
7
6
|
|
|
8
7
|
<template>
|
package/builtin/SlidesTotal.vue
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import { injectionSlidevContext } from '../constants'
|
|
2
|
+
import { useSlideContext } from '../context'
|
|
4
3
|
|
|
5
|
-
const $
|
|
4
|
+
const { $nav } = useSlideContext()
|
|
6
5
|
</script>
|
|
7
6
|
|
|
8
7
|
<template>
|
|
9
|
-
<span>{{ $
|
|
8
|
+
<span>{{ $nav.total }}</span>
|
|
10
9
|
</template>
|
package/builtin/SlidevVideo.vue
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
3
|
-
import {
|
|
2
|
+
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
3
|
+
import { useSlideContext } from '../context'
|
|
4
4
|
|
|
5
5
|
const props = defineProps<{
|
|
6
6
|
autoPlay?: boolean | 'once' | 'resume' | 'resumeOnce'
|
|
@@ -8,10 +8,12 @@ const props = defineProps<{
|
|
|
8
8
|
autoReset?: 'slide' | 'click'
|
|
9
9
|
}>()
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const {
|
|
12
|
+
$slidev,
|
|
13
|
+
$clicksContext: clicks,
|
|
14
|
+
$renderContext: currentContext,
|
|
15
|
+
$route: route,
|
|
16
|
+
} = useSlideContext()
|
|
15
17
|
|
|
16
18
|
const video = ref<HTMLMediaElement>()
|
|
17
19
|
const played = ref(false)
|
package/builtin/Toc.vue
CHANGED
|
@@ -8,9 +8,9 @@ Usage:
|
|
|
8
8
|
<Toc columns='2' maxDepth='3' mode='onlySiblings'/>
|
|
9
9
|
-->
|
|
10
10
|
<script setup lang='ts'>
|
|
11
|
-
import { computed
|
|
11
|
+
import { computed } from 'vue'
|
|
12
12
|
import type { TocItem } from '@slidev/types'
|
|
13
|
-
import {
|
|
13
|
+
import { useSlideContext } from '../context'
|
|
14
14
|
|
|
15
15
|
const props = withDefaults(
|
|
16
16
|
defineProps<{
|
|
@@ -33,7 +33,7 @@ const props = withDefaults(
|
|
|
33
33
|
},
|
|
34
34
|
)
|
|
35
35
|
|
|
36
|
-
const $slidev =
|
|
36
|
+
const { $slidev } = useSlideContext()
|
|
37
37
|
|
|
38
38
|
function filterTreeDepth(tree: TocItem[], level = 1): TocItem[] {
|
|
39
39
|
if (level > Number(props.maxDepth)) {
|
package/builtin/TocList.vue
CHANGED
|
@@ -10,7 +10,7 @@ Usage:
|
|
|
10
10
|
import { computed } from 'vue'
|
|
11
11
|
import { toArray } from '@antfu/utils'
|
|
12
12
|
import type { TocItem } from '@slidev/types'
|
|
13
|
-
import Titles from '
|
|
13
|
+
import Titles from '#slidev/titles.md'
|
|
14
14
|
|
|
15
15
|
const props = withDefaults(defineProps<{
|
|
16
16
|
level: number
|
|
@@ -65,7 +65,8 @@ const styles = computed(() => {
|
|
|
65
65
|
.slidev-layout .slidev-toc-item p {
|
|
66
66
|
margin: 0;
|
|
67
67
|
}
|
|
68
|
-
.slidev-layout .slidev-toc-item div,
|
|
68
|
+
.slidev-layout .slidev-toc-item div,
|
|
69
|
+
.slidev-layout .slidev-toc-item div p {
|
|
69
70
|
display: initial;
|
|
70
71
|
}
|
|
71
72
|
</style>
|
package/builtin/Tweet.vue
CHANGED
|
@@ -7,9 +7,9 @@ Usage:
|
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
<script setup lang="ts">
|
|
10
|
-
import { useScriptTag } from '@vueuse/core'
|
|
11
10
|
import { getCurrentInstance, onMounted, ref } from 'vue'
|
|
12
11
|
import { isDark } from '../logic/dark'
|
|
12
|
+
import { useTweetScript } from '../composables/useTweetScript'
|
|
13
13
|
|
|
14
14
|
const props = defineProps<{
|
|
15
15
|
id: string | number
|
|
@@ -41,21 +41,10 @@ async function create() {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// @ts-expect-error global
|
|
44
|
-
if (window?.twttr?.widgets)
|
|
44
|
+
if (window?.twttr?.widgets)
|
|
45
45
|
onMounted(create)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
useScriptTag(
|
|
49
|
-
'https://platform.twitter.com/widgets.js',
|
|
50
|
-
() => {
|
|
51
|
-
if (vm.isMounted)
|
|
52
|
-
create()
|
|
53
|
-
else
|
|
54
|
-
onMounted(create, vm)
|
|
55
|
-
},
|
|
56
|
-
{ async: true },
|
|
57
|
-
)
|
|
58
|
-
}
|
|
46
|
+
else
|
|
47
|
+
useTweetScript(vm, create)
|
|
59
48
|
</script>
|
|
60
49
|
|
|
61
50
|
<template>
|
package/builtin/VClickGap.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { Fragment,
|
|
3
|
-
import { injectionClicksContext } from '../constants'
|
|
2
|
+
import { Fragment, onMounted, watchEffect } from 'vue'
|
|
4
3
|
import { makeId } from '../logic/utils'
|
|
4
|
+
import { useSlideContext } from '../context'
|
|
5
5
|
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
size: {
|
|
@@ -10,12 +10,10 @@ const props = defineProps({
|
|
|
10
10
|
},
|
|
11
11
|
})
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const { $clicksContext: clicks } = useSlideContext()
|
|
14
14
|
|
|
15
15
|
onMounted(() => {
|
|
16
16
|
watchEffect((onCleanup) => {
|
|
17
|
-
const clicks = clicksRef?.value
|
|
18
|
-
|
|
19
17
|
if (!clicks || clicks.disabled)
|
|
20
18
|
return
|
|
21
19
|
|
package/builtin/VClicks.ts
CHANGED
package/composables/useClicks.ts
CHANGED
|
@@ -6,7 +6,10 @@ import type { RouteRecordRaw } from 'vue-router'
|
|
|
6
6
|
import { currentRoute, isPrintMode, isPrintWithClicks, queryClicks, routeForceRefresh } from '../logic/nav'
|
|
7
7
|
import { normalizeAtProp } from '../logic/utils'
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export function useClicksContextBase(getCurrent: () => number, clicksOverrides?: number): ClicksContext {
|
|
10
13
|
const relativeOffsets: ClicksContext['relativeOffsets'] = new Map()
|
|
11
14
|
const map: ClicksContext['map'] = shallowReactive(new Map())
|
|
12
15
|
|
|
@@ -53,7 +56,7 @@ function useClicksContextBase(route: RouteRecordRaw | undefined, getCurrent: ()
|
|
|
53
56
|
get total() {
|
|
54
57
|
// eslint-disable-next-line no-unused-expressions
|
|
55
58
|
routeForceRefresh.value
|
|
56
|
-
return
|
|
59
|
+
return clicksOverrides
|
|
57
60
|
?? Math.max(0, ...[...map.values()].map(v => v.max || 0))
|
|
58
61
|
},
|
|
59
62
|
}
|
|
@@ -63,21 +66,24 @@ export function usePrimaryClicks(route: RouteRecordRaw | undefined): ClicksConte
|
|
|
63
66
|
if (route?.meta?.__clicksContext)
|
|
64
67
|
return route.meta.__clicksContext
|
|
65
68
|
const thisPath = +(route?.path ?? 99999)
|
|
66
|
-
const context = useClicksContextBase(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const context = useClicksContextBase(
|
|
70
|
+
() => {
|
|
71
|
+
const currentPath = +(currentRoute.value?.path ?? 99999)
|
|
72
|
+
if (currentPath === thisPath)
|
|
73
|
+
return queryClicks.value
|
|
74
|
+
else if (currentPath > thisPath)
|
|
75
|
+
return 99999
|
|
76
|
+
else
|
|
77
|
+
return 0
|
|
78
|
+
},
|
|
79
|
+
route?.meta?.clicks,
|
|
80
|
+
)
|
|
75
81
|
if (route?.meta)
|
|
76
82
|
route.meta.__clicksContext = context
|
|
77
83
|
return context
|
|
78
84
|
}
|
|
79
85
|
|
|
80
|
-
export function useFixedClicks(route
|
|
86
|
+
export function useFixedClicks(route?: RouteRecordRaw | undefined, currentInit = 0): [Ref<number>, ClicksContext] {
|
|
81
87
|
const current = ref(currentInit)
|
|
82
|
-
return [current, useClicksContextBase(
|
|
88
|
+
return [current, useClicksContextBase(() => current.value, route?.meta?.clicks)]
|
|
83
89
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createSharedComposable, useScriptTag } from '@vueuse/core'
|
|
2
|
+
import type { ComponentInternalInstance } from 'vue'
|
|
3
|
+
import { onMounted } from 'vue'
|
|
4
|
+
|
|
5
|
+
export const useTweetScript = createSharedComposable(
|
|
6
|
+
(vm: ComponentInternalInstance, create: () => void) =>
|
|
7
|
+
useScriptTag(
|
|
8
|
+
'https://platform.twitter.com/widgets.js',
|
|
9
|
+
() => {
|
|
10
|
+
if (vm.isMounted)
|
|
11
|
+
create()
|
|
12
|
+
else
|
|
13
|
+
onMounted(create, vm)
|
|
14
|
+
},
|
|
15
|
+
{ async: true },
|
|
16
|
+
),
|
|
17
|
+
)
|
package/constants.ts
CHANGED
|
@@ -3,14 +3,16 @@ import type { RouteRecordRaw } from 'vue-router'
|
|
|
3
3
|
import type { ClicksContext, RenderContext } from '@slidev/types'
|
|
4
4
|
import type { SlidevContext } from './modules/context'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const
|
|
9
|
-
export const
|
|
10
|
-
export const
|
|
11
|
-
export const
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
6
|
+
// Here we use string literal instead of symbols to make HMR more stable
|
|
7
|
+
// The value of the injections keys are implementation details, you should always use them with the reference to the constant instead of the value
|
|
8
|
+
export const injectionClicksContext = '$$slidev-clicks-context' as unknown as InjectionKey<Ref<ClicksContext>>
|
|
9
|
+
export const injectionCurrentPage = '$$slidev-page' as unknown as InjectionKey<Ref<number>>
|
|
10
|
+
export const injectionSlideScale = '$$slidev-slide-scale' as unknown as InjectionKey<ComputedRef<number>>
|
|
11
|
+
export const injectionSlidevContext = '$$slidev-context' as unknown as InjectionKey<UnwrapNestedRefs<SlidevContext>>
|
|
12
|
+
export const injectionRoute = '$$slidev-route' as unknown as InjectionKey<RouteRecordRaw>
|
|
13
|
+
export const injectionRenderContext = '$$slidev-render-context' as unknown as InjectionKey<Ref<RenderContext>>
|
|
14
|
+
export const injectionActive = '$$slidev-active' as unknown as InjectionKey<Ref<boolean>>
|
|
15
|
+
export const injectionFrontmatter = '$$slidev-fontmatter' as unknown as InjectionKey<Record<string, any>>
|
|
14
16
|
|
|
15
17
|
export const CLASS_VCLICK_TARGET = 'slidev-vclick-target'
|
|
16
18
|
export const CLASS_VCLICK_HIDDEN = 'slidev-vclick-hidden'
|
|
@@ -24,3 +26,49 @@ export const TRUST_ORIGINS = [
|
|
|
24
26
|
'localhost',
|
|
25
27
|
'127.0.0.1',
|
|
26
28
|
]
|
|
29
|
+
|
|
30
|
+
export const FRONTMATTER_FIELDS = [
|
|
31
|
+
'clicks',
|
|
32
|
+
'disabled',
|
|
33
|
+
'hide',
|
|
34
|
+
'hideInToc',
|
|
35
|
+
'layout',
|
|
36
|
+
'level',
|
|
37
|
+
'preload',
|
|
38
|
+
'routeAlias',
|
|
39
|
+
'src',
|
|
40
|
+
'title',
|
|
41
|
+
'transition',
|
|
42
|
+
'zoom',
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
export const HEADMATTER_FIELDS = [
|
|
46
|
+
...FRONTMATTER_FIELDS,
|
|
47
|
+
'theme',
|
|
48
|
+
'titleTemplate',
|
|
49
|
+
'info',
|
|
50
|
+
'author',
|
|
51
|
+
'keywords',
|
|
52
|
+
'presenter',
|
|
53
|
+
'download',
|
|
54
|
+
'exportFilename',
|
|
55
|
+
'export',
|
|
56
|
+
'highlighter',
|
|
57
|
+
'lineNumbers',
|
|
58
|
+
'monaco',
|
|
59
|
+
'remoteAssets',
|
|
60
|
+
'selectable',
|
|
61
|
+
'record',
|
|
62
|
+
'colorSchema',
|
|
63
|
+
'routerMode',
|
|
64
|
+
'aspectRatio',
|
|
65
|
+
'canvasWidth',
|
|
66
|
+
'themeConfig',
|
|
67
|
+
'favicon',
|
|
68
|
+
'plantUmlServer',
|
|
69
|
+
'fonts',
|
|
70
|
+
'defaults',
|
|
71
|
+
'drawings',
|
|
72
|
+
'htmlAttrs',
|
|
73
|
+
'mdc',
|
|
74
|
+
]
|
package/context.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { shallowRef, toRef } from 'vue'
|
|
2
|
+
import { injectLocal, objectOmit, provideLocal } from '@vueuse/core'
|
|
3
|
+
import { useFixedClicks } from './composables/useClicks'
|
|
4
|
+
import {
|
|
5
|
+
FRONTMATTER_FIELDS,
|
|
6
|
+
HEADMATTER_FIELDS,
|
|
7
|
+
injectionClicksContext,
|
|
8
|
+
injectionCurrentPage,
|
|
9
|
+
injectionFrontmatter,
|
|
10
|
+
injectionRenderContext,
|
|
11
|
+
injectionRoute,
|
|
12
|
+
injectionSlidevContext,
|
|
13
|
+
} from './constants'
|
|
14
|
+
|
|
15
|
+
const clicksContextFallback = shallowRef(useFixedClicks()[1])
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get the current slide context, should be called inside the setup function of a component inside slide
|
|
19
|
+
*/
|
|
20
|
+
export function useSlideContext() {
|
|
21
|
+
const $slidev = injectLocal(injectionSlidevContext)!
|
|
22
|
+
const $nav = toRef($slidev, 'nav')
|
|
23
|
+
const $clicksContext = injectLocal(injectionClicksContext, clicksContextFallback)!.value
|
|
24
|
+
const $clicks = toRef($clicksContext, 'current')
|
|
25
|
+
const $page = injectLocal(injectionCurrentPage)!
|
|
26
|
+
const $renderContext = injectLocal(injectionRenderContext)!
|
|
27
|
+
const $frontmatter = injectLocal(injectionFrontmatter, {})
|
|
28
|
+
const $route = injectLocal(injectionRoute, undefined)
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
$slidev,
|
|
32
|
+
$nav,
|
|
33
|
+
$clicksContext,
|
|
34
|
+
$clicks,
|
|
35
|
+
$page,
|
|
36
|
+
$route,
|
|
37
|
+
$renderContext,
|
|
38
|
+
$frontmatter,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function provideFrontmatter(frontmatter: Record<string, any>) {
|
|
43
|
+
provideLocal(injectionFrontmatter, frontmatter)
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
$slidev,
|
|
47
|
+
$page,
|
|
48
|
+
} = useSlideContext()
|
|
49
|
+
|
|
50
|
+
// update frontmatter in router to make HMR work better
|
|
51
|
+
const route = $slidev.nav.rawRoutes.find(i => i.path === String($page.value))
|
|
52
|
+
if (route?.meta?.slide?.frontmatter) {
|
|
53
|
+
for (const key of Object.keys(route.meta.slide.frontmatter)) {
|
|
54
|
+
if (!(key in frontmatter))
|
|
55
|
+
delete route.meta.slide.frontmatter[key]
|
|
56
|
+
}
|
|
57
|
+
Object.assign(route.meta.slide.frontmatter, frontmatter)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Convert frontmatter options to props for v-bind
|
|
63
|
+
* It removes known options fields, and expose an extra `frontmatter` field that contains full frontmatter
|
|
64
|
+
*/
|
|
65
|
+
export function frontmatterToProps(frontmatter: Record<string, any>, pageNo: number) {
|
|
66
|
+
return {
|
|
67
|
+
...objectOmit(frontmatter, pageNo === 0 ? HEADMATTER_FIELDS : FRONTMATTER_FIELDS),
|
|
68
|
+
frontmatter,
|
|
69
|
+
}
|
|
70
|
+
}
|
package/env.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import type { SlidevConfig } from '@slidev/types'
|
|
2
|
-
import type { UnwrapNestedRefs } from 'vue'
|
|
3
1
|
import { computed } from 'vue'
|
|
4
2
|
import { objectMap } from '@antfu/utils'
|
|
3
|
+
import configs from '#slidev/configs'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
import _configs from '/@slidev/configs'
|
|
8
|
-
import type { SlidevContext } from './modules/context'
|
|
5
|
+
export { configs }
|
|
9
6
|
|
|
10
|
-
export const configs = _configs as SlidevConfig
|
|
11
7
|
export const slideAspect = configs.aspectRatio ?? (16 / 9)
|
|
12
8
|
export const slideWidth = configs.canvasWidth ?? 980
|
|
9
|
+
|
|
13
10
|
// To honor the aspect ratio more as possible, we need to approximate the height to the next integer.
|
|
14
11
|
// Doing this, we will prevent on print, to create an additional empty white page after each page.
|
|
15
12
|
export const slideHeight = Math.ceil(slideWidth / slideAspect)
|
|
@@ -17,9 +14,3 @@ export const slideHeight = Math.ceil(slideWidth / slideAspect)
|
|
|
17
14
|
export const themeVars = computed(() => {
|
|
18
15
|
return objectMap(configs.themeConfig || {}, (k, v) => [`--slidev-theme-${k}`, v])
|
|
19
16
|
})
|
|
20
|
-
|
|
21
|
-
declare module 'vue' {
|
|
22
|
-
interface ComponentCustomProperties {
|
|
23
|
-
$slidev: UnwrapNestedRefs<SlidevContext>
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { Menu } from 'floating-vue'
|
|
3
|
+
import 'floating-vue/dist/style.css'
|
|
2
4
|
import {
|
|
3
5
|
brush,
|
|
4
6
|
brushColors,
|
|
@@ -21,20 +23,24 @@ function undo() {
|
|
|
21
23
|
function redo() {
|
|
22
24
|
drauu.redo()
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
let lastDrawingMode: typeof drawingMode.value = 'stylus'
|
|
24
28
|
function setDrawingMode(mode: typeof drawingMode.value) {
|
|
25
29
|
drawingMode.value = mode
|
|
26
30
|
drawingEnabled.value = true
|
|
31
|
+
if (mode !== 'eraseLine')
|
|
32
|
+
lastDrawingMode = mode
|
|
27
33
|
}
|
|
28
34
|
function setBrushColor(color: typeof brush.color) {
|
|
29
35
|
brush.color = color
|
|
30
36
|
drawingEnabled.value = true
|
|
37
|
+
drawingMode.value = lastDrawingMode
|
|
31
38
|
}
|
|
32
39
|
</script>
|
|
33
40
|
|
|
34
41
|
<template>
|
|
35
42
|
<Draggable
|
|
36
|
-
class="flex flex-wrap text-xl p-2 gap-1 rounded-md bg-main shadow transition-opacity duration-200"
|
|
37
|
-
dark="border border-gray-400 border-opacity-10"
|
|
43
|
+
class="flex flex-wrap text-xl p-2 gap-1 rounded-md bg-main shadow transition-opacity duration-200 z-20 border border-main"
|
|
38
44
|
:class="drawingEnabled ? '' : drawingPinned ? 'opacity-40 hover:opacity-90' : 'opacity-0 pointer-events-none'"
|
|
39
45
|
storage-key="slidev-drawing-pos"
|
|
40
46
|
:initial-x="10"
|
|
@@ -57,23 +63,41 @@ function setBrushColor(color: typeof brush.color) {
|
|
|
57
63
|
<IconButton title="Draw a rectangle" :class="{ shallow: drawingMode !== 'rectangle' }" @click="setDrawingMode('rectangle')">
|
|
58
64
|
<carbon:checkbox />
|
|
59
65
|
</IconButton>
|
|
60
|
-
|
|
61
|
-
<!-- <IconButton title="Erase" :class="{ shallow: drawingMode != 'eraseLine' }" @click="setDrawingMode('eraseLine')">
|
|
66
|
+
<IconButton title="Erase" :class="{ shallow: drawingMode !== 'eraseLine' }" @click="setDrawingMode('eraseLine')">
|
|
62
67
|
<carbon:erase />
|
|
63
|
-
</IconButton>
|
|
68
|
+
</IconButton>
|
|
64
69
|
|
|
65
70
|
<VerticalDivider />
|
|
66
71
|
|
|
72
|
+
<Menu>
|
|
73
|
+
<IconButton title="Adjust stroke width" :class="{ shallow: drawingMode === 'eraseLine' }">
|
|
74
|
+
<svg viewBox="0 0 32 32" width="1.2em" height="1.2em">
|
|
75
|
+
<line x1="2" y1="15" x2="22" y2="4" stroke="currentColor" stroke-width="1" stroke-linecap="round" />
|
|
76
|
+
<line x1="2" y1="24" x2="28" y2="10" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
|
77
|
+
<line x1="7" y1="31" x2="29" y2="19" stroke="currentColor" stroke-width="3" stroke-linecap="round" />
|
|
78
|
+
</svg>
|
|
79
|
+
</IconButton>
|
|
80
|
+
<template #popper>
|
|
81
|
+
<div class="flex bg-main p-2">
|
|
82
|
+
<div class="inline-block w-7 text-center">
|
|
83
|
+
{{ brush.size }}
|
|
84
|
+
</div>
|
|
85
|
+
<div class="pt-.5">
|
|
86
|
+
<input v-model="brush.size" type="range" min="1" max="15" @change="drawingMode = lastDrawingMode">
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</template>
|
|
90
|
+
</Menu>
|
|
67
91
|
<IconButton
|
|
68
92
|
v-for="color of brushColors"
|
|
69
93
|
:key="color"
|
|
70
94
|
title="Set brush color"
|
|
71
|
-
:class="brush.color === color ? 'active' : 'shallow'"
|
|
95
|
+
:class="brush.color === color && drawingMode !== 'eraseLine' ? 'active' : 'shallow'"
|
|
72
96
|
@click="setBrushColor(color)"
|
|
73
97
|
>
|
|
74
98
|
<div
|
|
75
|
-
class="w-6 h-6 transition-all transform border
|
|
76
|
-
:class="brush.color !== color ? 'rounded-1/2 scale-85' : 'rounded-md'"
|
|
99
|
+
class="w-6 h-6 transition-all transform border"
|
|
100
|
+
:class="brush.color !== color ? 'rounded-1/2 scale-85 border-white' : 'rounded-md border-gray-300/50'"
|
|
77
101
|
:style="drawingEnabled ? { background: color } : { borderColor: color }"
|
|
78
102
|
/>
|
|
79
103
|
</IconButton>
|
|
@@ -87,7 +111,7 @@ function setBrushColor(color: typeof brush.color) {
|
|
|
87
111
|
<carbon:redo />
|
|
88
112
|
</IconButton>
|
|
89
113
|
<IconButton title="Delete" :class="{ disabled: !canClear }" @click="clearDrauu()">
|
|
90
|
-
<carbon:
|
|
114
|
+
<carbon:trash-can />
|
|
91
115
|
</IconButton>
|
|
92
116
|
|
|
93
117
|
<VerticalDivider />
|
|
@@ -106,3 +130,9 @@ function setBrushColor(color: typeof brush.color) {
|
|
|
106
130
|
</IconButton>
|
|
107
131
|
</Draggable>
|
|
108
132
|
</template>
|
|
133
|
+
|
|
134
|
+
<style>
|
|
135
|
+
.v-popper--theme-menu .v-popper__arrow-inner {
|
|
136
|
+
--uno: border-main;
|
|
137
|
+
}
|
|
138
|
+
</style>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
3
|
+
import { injectLocal } from '@vueuse/core'
|
|
3
4
|
import { drauu, drawingEnabled, loadCanvas } from '../logic/drawings'
|
|
4
5
|
import { injectionSlideScale } from '../constants'
|
|
5
6
|
|
|
6
|
-
const scale =
|
|
7
|
+
const scale = injectLocal(injectionSlideScale)!
|
|
7
8
|
const svg = ref<SVGSVGElement>()
|
|
8
9
|
|
|
9
10
|
onMounted(() => {
|
package/internals/Editor.vue
CHANGED
|
@@ -38,7 +38,6 @@ watch(
|
|
|
38
38
|
async function save() {
|
|
39
39
|
dirty.value = false
|
|
40
40
|
await update({
|
|
41
|
-
raw: null!,
|
|
42
41
|
note: note.value || undefined,
|
|
43
42
|
content: content.value,
|
|
44
43
|
// frontmatter: frontmatter.value,
|
|
@@ -103,6 +102,11 @@ onMounted(async () => {
|
|
|
103
102
|
noteEditor.refresh()
|
|
104
103
|
})
|
|
105
104
|
})
|
|
105
|
+
|
|
106
|
+
watch(currentSlideId, () => {
|
|
107
|
+
contentEditor.clearHistory()
|
|
108
|
+
noteEditor.clearHistory()
|
|
109
|
+
}, { flush: 'post' })
|
|
106
110
|
})
|
|
107
111
|
|
|
108
112
|
const handlerDown = ref(false)
|
|
@@ -168,13 +172,13 @@ throttledWatch(
|
|
|
168
172
|
<div class="flex pb-2 text-xl -mt-1">
|
|
169
173
|
<div class="mr-4 rounded flex">
|
|
170
174
|
<IconButton
|
|
171
|
-
title="Switch to content tab" :class="tab === 'content' ? 'text
|
|
175
|
+
title="Switch to content tab" :class="tab === 'content' ? 'text-primary' : ''"
|
|
172
176
|
@click="switchTab('content')"
|
|
173
177
|
>
|
|
174
178
|
<carbon:account />
|
|
175
179
|
</IconButton>
|
|
176
180
|
<IconButton
|
|
177
|
-
title="Switch to notes tab" :class="tab === 'note' ? 'text
|
|
181
|
+
title="Switch to notes tab" :class="tab === 'note' ? 'text-primary' : ''"
|
|
178
182
|
@click="switchTab('note')"
|
|
179
183
|
>
|
|
180
184
|
<carbon:align-box-bottom-right />
|
package/internals/Goto.vue
CHANGED
|
@@ -3,7 +3,7 @@ import { computed, ref, watch } from 'vue'
|
|
|
3
3
|
import Fuse from 'fuse.js'
|
|
4
4
|
import { go, rawRoutes } from '../logic/nav'
|
|
5
5
|
import { activeElement, showGotoDialog } from '../state'
|
|
6
|
-
import Titles from '
|
|
6
|
+
import Titles from '#slidev/titles.md'
|
|
7
7
|
|
|
8
8
|
const container = ref<HTMLDivElement>()
|
|
9
9
|
const input = ref<HTMLInputElement>()
|
|
@@ -165,10 +165,11 @@ watch(activeElement, () => {
|
|
|
165
165
|
</div>
|
|
166
166
|
</template>
|
|
167
167
|
|
|
168
|
-
<style scoped
|
|
168
|
+
<style scoped>
|
|
169
169
|
.autocomplete-list {
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
--uno: bg-main mt-1;
|
|
171
|
+
overflow: auto;
|
|
172
|
+
max-height: calc(100vh - 100px);
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
.autocomplete {
|