Skip to content

Commit 9f4c8c0

Browse files
authored
Merge branch 'main' into fix/1650
2 parents 0b011a8 + a328fa5 commit 9f4c8c0

File tree

17 files changed

+77
-31
lines changed

17 files changed

+77
-31
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"type": "module",
3-
"version": "0.49.9",
3+
"version": "0.49.10",
44
"private": true,
55
"packageManager": "pnpm@9.1.4",
66
"engines": {

packages/client/internals/ClicksSlider.vue

+13-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ import { clamp, range } from '@antfu/utils'
44
import { computed } from 'vue'
55
import { CLICKS_MAX } from '../constants'
66
7-
const props = defineProps<{
7+
const props = withDefaults(defineProps<{
88
clicksContext: ClicksContext
9-
}>()
9+
readonly?: boolean
10+
active?: boolean
11+
}>(), {
12+
active: true,
13+
})
1014
1115
const total = computed(() => props.clicksContext.total)
1216
const start = computed(() => clamp(0, props.clicksContext.clicksStart, total.value))
@@ -24,6 +28,8 @@ const current = computed({
2428
const clicksRange = computed(() => range(start.value, total.value + 1))
2529
2630
function onMousedown() {
31+
if (props.readonly)
32+
return
2733
if (current.value < 0 || current.value > total.value)
2834
current.value = 0
2935
}
@@ -38,15 +44,14 @@ function onMousedown() {
3844
<div class="flex gap-0.5 items-center min-w-16 font-mono mr1">
3945
<carbon:cursor-1 text-sm op50 />
4046
<div flex-auto />
41-
<template v-if="current >= 0 && current !== CLICKS_MAX">
47+
<template v-if="current >= 0 && current !== CLICKS_MAX && active">
4248
<span text-primary>{{ current }}</span>
4349
<span op25>/</span>
4450
</template>
4551
<span op50>{{ total }}</span>
4652
</div>
4753
<div
4854
relative flex-auto h5 font-mono flex="~"
49-
@dblclick="current = clicksContext.total"
5055
>
5156
<div
5257
v-for="i of clicksRange" :key="i"
@@ -71,8 +76,10 @@ function onMousedown() {
7176
</div>
7277
<input
7378
v-model="current"
74-
class="range" absolute inset-0
75-
type="range" :min="start" :max="total" :step="1" z-10 op0
79+
class="range"
80+
type="range" :min="start" :max="total" :step="1"
81+
absolute inset-0 z-10 op0
82+
:class="readonly ? 'pointer-events-none' : ''"
7683
:style="{ '--thumb-width': `${1 / (length + 1) * 100}%` }"
7784
@mousedown="onMousedown"
7885
@focus="event => (event.currentTarget as HTMLElement)?.blur()"

packages/client/internals/NoteDisplay.vue

+16-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ import { computed, nextTick, onMounted, ref, watch } from 'vue'
33
import type { ClicksContext } from '@slidev/types'
44
import { CLICKS_MAX } from '../constants'
55
6-
const props = defineProps<{
7-
class?: string | string[]
8-
noteHtml?: string
9-
note?: string
10-
placeholder?: string
11-
clicksContext?: ClicksContext
12-
autoScroll?: boolean
13-
}>()
6+
const props = withDefaults(
7+
defineProps<{
8+
class?: string | string[]
9+
noteHtml?: string
10+
note?: string
11+
highlight?: boolean
12+
placeholder?: string
13+
clicksContext?: ClicksContext
14+
autoScroll?: boolean
15+
}>(),
16+
{
17+
highlight: true,
18+
},
19+
)
1420
1521
const emit = defineEmits<{
1622
(type: 'markerDblclick', e: MouseEvent, clicks: number): void
@@ -30,7 +36,7 @@ function highlightNote() {
3036
const markers = Array.from(noteDisplay.value.querySelectorAll(`.${CLASS_MARKER}`)) as HTMLElement[]
3137
3238
const current = +(props.clicksContext?.current ?? CLICKS_MAX)
33-
const disabled = current < 0 || current >= CLICKS_MAX
39+
const disabled = current < 0 || current >= CLICKS_MAX || !props.highlight
3440
3541
const nodeToIgnores = new Set<Element>()
3642
function ignoreParent(node: Element) {
@@ -114,7 +120,7 @@ function highlightNote() {
114120
}
115121
116122
watch(
117-
() => [props.noteHtml, props.clicksContext?.current],
123+
() => [props.noteHtml, props.clicksContext?.current, props.highlight],
118124
() => {
119125
nextTick(() => {
120126
highlightNote()

packages/client/internals/NoteEditable.vue

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ const props = defineProps({
2626
clicksContext: {
2727
type: Object as PropType<ClicksContext>,
2828
},
29+
highlight: {
30+
default: true,
31+
},
2932
autoHeight: {
3033
default: false,
3134
},
@@ -112,6 +115,7 @@ watch(
112115
:note-html="info?.noteHTML"
113116
:clicks-context="clicksContext"
114117
:auto-scroll="!autoHeight"
118+
:highlight="props.highlight"
115119
@marker-click="(e, clicks) => emit('markerClick', e, clicks)"
116120
@marker-dblclick="(e, clicks) => emit('markerDblclick', e, clicks)"
117121
/>

packages/client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@slidev/client",
33
"type": "module",
4-
"version": "0.49.9",
4+
"version": "0.49.10",
55
"description": "Presentation slides for developers",
66
"author": "antfu <anthonyfu117@hotmail.com>",
77
"license": "MIT",

packages/client/pages/notes.vue

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import { fullscreen } from '../state'
88
99
import NoteDisplay from '../internals/NoteDisplay.vue'
1010
import IconButton from '../internals/IconButton.vue'
11+
import ClicksSlider from '../internals/ClicksSlider.vue'
1112
import { useNav } from '../composables/useNav'
13+
import { createClicksContextBase } from '../composables/useClicks'
1214
1315
useHead({ title: `Notes - ${slidesTitle}` })
1416
@@ -32,6 +34,12 @@ function increaseFontSize() {
3234
function decreaseFontSize() {
3335
fontSize.value = fontSize.value - 1
3436
}
37+
38+
const clicksContext = computed(() => {
39+
const clicks = sharedState.lastUpdate?.type === 'viewer' ? sharedState.viewerClicks : sharedState.clicks
40+
const total = sharedState.lastUpdate?.type === 'viewer' ? sharedState.viewerClicksTotal : sharedState.clicksTotal
41+
return createClicksContextBase(ref(clicks), undefined, total)
42+
})
3543
</script>
3644

3745
<template>
@@ -49,10 +57,13 @@ function decreaseFontSize() {
4957
:note="currentRoute?.meta.slide.note"
5058
:note-html="currentRoute?.meta.slide.noteHTML"
5159
:placeholder="`No notes for Slide ${pageNo}.`"
52-
:clicks-context="currentRoute?.meta.__clicksContext"
60+
:clicks-context="clicksContext"
5361
:auto-scroll="true"
5462
/>
5563
</div>
64+
<div class="flex-none border-t border-main" px3 py2>
65+
<ClicksSlider :clicks-context="clicksContext" readonly />
66+
</div>
5667
<div class="flex-none border-t border-main">
5768
<div class="flex gap-1 items-center px-6 py-3">
5869
<IconButton :title="isFullscreen ? 'Close fullscreen' : 'Enter fullscreen'" @click="toggleFullscreen">

packages/client/pages/overview.vue

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { computed, nextTick, onMounted, reactive, ref } from 'vue'
2+
import { computed, nextTick, onMounted, reactive, ref, shallowRef } from 'vue'
33
import { useHead } from '@unhead/vue'
44
import type { ClicksContext, SlideRoute } from '@slidev/types'
55
import { pathPrefix, slidesTitle } from '../env'
@@ -28,6 +28,7 @@ const wordCounts = computed(() => slides.value.map(route => wordCount(route.meta
2828
const totalWords = computed(() => wordCounts.value.reduce((a, b) => a + b, 0))
2929
const totalClicks = computed(() => slides.value.map(route => getSlideClicks(route)).reduce((a, b) => a + b, 0))
3030
31+
const activeSlide = shallowRef<SlideRoute>()
3132
const clicksContextMap = new WeakMap<SlideRoute, ClicksContext>()
3233
function getClicksContext(route: SlideRoute) {
3334
// We create a local clicks context to calculate the total clicks of the slide
@@ -40,8 +41,15 @@ function getSlideClicks(route: SlideRoute) {
4041
return route.meta?.clicks || getClicksContext(route)?.total
4142
}
4243
44+
function toggleRoute(route: SlideRoute) {
45+
if (activeSlide.value === route)
46+
activeSlide.value = undefined
47+
else
48+
activeSlide.value = route
49+
}
50+
4351
function wordCount(str: string) {
44-
return str.match(/[\w’'-]+/g)?.length || 0
52+
return str.match(/[\w`'\-]+/g)?.length || 0
4553
}
4654
4755
function isElementInViewport(el: HTMLElement) {
@@ -185,9 +193,11 @@ onMounted(() => {
185193
</div>
186194
<ClicksSlider
187195
v-if="getSlideClicks(route)"
196+
:active="activeSlide === route"
188197
:clicks-context="getClicksContext(route)"
189198
class="w-full mt-2"
190-
@dblclick="getClicksContext(route).current = CLICKS_MAX"
199+
@dblclick="toggleRoute(route)"
200+
@click="activeSlide = route"
191201
/>
192202
</div>
193203
<div class="py3 mt-0.5 mr--8 ml--4 op0 transition group-hover:op100">
@@ -204,6 +214,7 @@ onMounted(() => {
204214
:no="route.no"
205215
class="max-w-250 w-250 text-lg rounded p3"
206216
:auto-height="true"
217+
:highlight="activeSlide === route"
207218
:editing="edittingNote === route.no"
208219
:clicks-context="getClicksContext(route)"
209220
@dblclick="edittingNote !== route.no ? edittingNote = route.no : null"

packages/client/setup/root.ts

+2
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ export default function setupRoot() {
6767
if (isPresenter.value) {
6868
patch('page', +currentSlideNo.value)
6969
patch('clicks', clicksContext.value.current)
70+
patch('clicksTotal', clicksContext.value.total)
7071
}
7172
else {
7273
patch('viewerPage', +currentSlideNo.value)
7374
patch('viewerClicks', clicksContext.value.current)
75+
patch('viewerClicksTotal', clicksContext.value.total)
7476
}
7577

7678
patch('lastUpdate', {

packages/client/state/shared.ts

+5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import { createSyncState } from './syncState'
44
export interface SharedState {
55
page: number
66
clicks: number
7+
clicksTotal: number
8+
79
cursor?: {
810
x: number
911
y: number
1012
}
1113

1214
viewerPage: number
1315
viewerClicks: number
16+
viewerClicksTotal: number
1417

1518
lastUpdate?: {
1619
id: string
@@ -22,8 +25,10 @@ export interface SharedState {
2225
const { init, onPatch, patch, state } = createSyncState<SharedState>(serverState, {
2326
page: 1,
2427
clicks: 0,
28+
clicksTotal: 0,
2529
viewerPage: 1,
2630
viewerClicks: 0,
31+
viewerClicksTotal: 0,
2732
})
2833

2934
export {

packages/create-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "create-slidev",
33
"type": "module",
4-
"version": "0.49.9",
4+
"version": "0.49.10",
55
"description": "Create starter template for Slidev",
66
"author": "antfu <anthonyfu117@hotmail.com>",
77
"license": "MIT",

packages/create-app/template/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"export": "slidev export"
99
},
1010
"dependencies": {
11-
"@slidev/cli": "^0.49.9",
11+
"@slidev/cli": "^0.49.10",
1212
"@slidev/theme-default": "latest",
1313
"@slidev/theme-seriph": "latest",
1414
"vue": "^3.4.27"

packages/create-theme/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "create-slidev-theme",
33
"type": "module",
4-
"version": "0.49.9",
4+
"version": "0.49.10",
55
"description": "Create starter theme template for Slidev",
66
"author": "antfu <anthonyfu117@hotmail.com>",
77
"license": "MIT",

packages/create-theme/template/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
"screenshot": "slidev export example.md --format png"
1616
},
1717
"dependencies": {
18-
"@slidev/types": "^0.49.9",
18+
"@slidev/types": "^0.49.10",
1919
"codemirror-theme-vars": "^0.1.2",
2020
"prism-theme-vars": "^0.2.5"
2121
},
2222
"devDependencies": {
23-
"@slidev/cli": "^0.49.9"
23+
"@slidev/cli": "^0.49.10"
2424
},
2525
"//": "Learn more: https://sli.dev/themes/write-a-theme.html",
2626
"slidev": {

packages/parser/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slidev/parser",
3-
"version": "0.49.9",
3+
"version": "0.49.10",
44
"description": "Markdown parser for Slidev",
55
"author": "antfu <anthonyfu117@hotmail.com>",
66
"license": "MIT",

packages/slidev/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slidev/cli",
3-
"version": "0.49.9",
3+
"version": "0.49.10",
44
"description": "Presentation slides for developers",
55
"author": "antfu <anthonyfu117@hotmail.com>",
66
"license": "MIT",

packages/types/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slidev/types",
3-
"version": "0.49.9",
3+
"version": "0.49.10",
44
"description": "Shared types declarations for Slidev",
55
"author": "antfu <anthonyfu117@hotmail.com>",
66
"license": "MIT",

packages/vscode/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "Slidev",
55
"type": "module",
66
"preview": true,
7-
"version": "0.49.9",
7+
"version": "0.49.10",
88
"private": true,
99
"description": "Slidev support for VS Code",
1010
"license": "MIT",

0 commit comments

Comments
 (0)