@slidev/client 0.48.0-beta.9 → 0.48.0

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.
Files changed (97) hide show
  1. package/App.vue +7 -0
  2. package/builtin/Arrow.vue +2 -4
  3. package/builtin/CodeBlockWrapper.vue +33 -28
  4. package/builtin/KaTexBlockWrapper.vue +1 -1
  5. package/builtin/Link.vue +3 -1
  6. package/builtin/Mermaid.vue +4 -3
  7. package/builtin/Monaco.vue +166 -93
  8. package/builtin/ShikiMagicMove.vue +103 -0
  9. package/builtin/SlidevVideo.vue +1 -1
  10. package/builtin/Toc.vue +1 -1
  11. package/builtin/TocList.vue +4 -3
  12. package/builtin/Tweet.vue +12 -9
  13. package/builtin/VClick.ts +2 -1
  14. package/composables/useClicks.ts +19 -32
  15. package/composables/useDarkMode.ts +9 -0
  16. package/composables/useDrawings.ts +181 -0
  17. package/composables/useNav.ts +346 -44
  18. package/{logic/note.ts → composables/useSlideInfo.ts} +13 -16
  19. package/composables/useSwipeControls.ts +43 -0
  20. package/composables/useTocTree.ts +81 -0
  21. package/composables/useViewTransition.ts +7 -4
  22. package/constants.ts +4 -3
  23. package/context.ts +13 -6
  24. package/env.ts +7 -16
  25. package/index.html +1 -0
  26. package/index.ts +12 -0
  27. package/internals/ClicksSlider.vue +93 -0
  28. package/internals/CodeRunner.vue +142 -0
  29. package/internals/Controls.vue +2 -2
  30. package/internals/DomElement.vue +18 -0
  31. package/internals/DrawingControls.vue +14 -15
  32. package/internals/DrawingLayer.vue +6 -5
  33. package/internals/DrawingPreview.vue +4 -2
  34. package/internals/Goto.vue +9 -6
  35. package/internals/IconButton.vue +3 -2
  36. package/internals/NavControls.vue +30 -11
  37. package/internals/NoteDisplay.vue +131 -8
  38. package/internals/NoteEditable.vue +129 -0
  39. package/internals/NoteStatic.vue +5 -2
  40. package/internals/PrintContainer.vue +11 -8
  41. package/internals/PrintSlide.vue +11 -12
  42. package/internals/PrintSlideClick.vue +14 -19
  43. package/internals/{SlidesOverview.vue → QuickOverview.vue} +27 -24
  44. package/internals/RecordingControls.vue +1 -1
  45. package/internals/RecordingDialog.vue +3 -3
  46. package/internals/{Editor.vue → SideEditor.vue} +24 -15
  47. package/internals/SlideContainer.vue +13 -9
  48. package/internals/SlideLoading.vue +19 -0
  49. package/internals/SlideWrapper.vue +79 -0
  50. package/internals/SlidesShow.vue +36 -22
  51. package/layouts/error.vue +5 -0
  52. package/layouts/two-cols-header.vue +9 -3
  53. package/logic/overview.ts +2 -2
  54. package/logic/route.ts +16 -5
  55. package/logic/slides.ts +20 -0
  56. package/logic/transition.ts +50 -0
  57. package/logic/utils.ts +24 -1
  58. package/main.ts +3 -15
  59. package/{setup → modules}/codemirror.ts +1 -3
  60. package/modules/context.ts +1 -46
  61. package/modules/mermaid.ts +9 -8
  62. package/package.json +21 -15
  63. package/pages/notes.vue +6 -3
  64. package/pages/overview.vue +138 -51
  65. package/pages/play.vue +16 -9
  66. package/pages/presenter/print.vue +10 -5
  67. package/pages/presenter.vue +122 -104
  68. package/pages/print.vue +4 -3
  69. package/routes.ts +8 -54
  70. package/setup/code-runners.ts +164 -0
  71. package/setup/main.ts +39 -9
  72. package/setup/mermaid.ts +5 -6
  73. package/setup/monaco.ts +114 -51
  74. package/setup/root.ts +62 -18
  75. package/setup/shortcuts.ts +15 -12
  76. package/shim-vue.d.ts +34 -0
  77. package/shim.d.ts +1 -13
  78. package/state/index.ts +2 -2
  79. package/styles/code.css +9 -5
  80. package/styles/index.css +63 -7
  81. package/styles/katex.css +1 -1
  82. package/styles/layouts-base.css +11 -8
  83. package/styles/shiki-twoslash.css +1 -1
  84. package/styles/vars.css +1 -1
  85. package/uno.config.ts +10 -1
  86. package/utils.ts +15 -2
  87. package/composables/useContext.ts +0 -17
  88. package/composables/useTweetScript.ts +0 -17
  89. package/iframes/monaco/index.css +0 -28
  90. package/iframes/monaco/index.html +0 -7
  91. package/iframes/monaco/index.ts +0 -260
  92. package/internals/NoteEditor.vue +0 -92
  93. package/internals/SlideWrapper.ts +0 -58
  94. package/logic/drawings.ts +0 -161
  95. package/logic/nav.ts +0 -278
  96. package/setup/prettier.ts +0 -43
  97. /package/{composables → logic}/hmr.ts +0 -0
@@ -0,0 +1,50 @@
1
+ import type { SlideRoute } from '@slidev/types'
2
+ import type { TransitionGroupProps } from 'vue'
3
+ import { configs } from '../env'
4
+
5
+ const transitionResolveMap: Record<string, string | undefined> = {
6
+ 'slide-left': 'slide-left | slide-right',
7
+ 'slide-right': 'slide-right | slide-left',
8
+ 'slide-up': 'slide-up | slide-down',
9
+ 'slide-down': 'slide-down | slide-up',
10
+ }
11
+
12
+ export function resolveTransition(transition?: string | TransitionGroupProps, isBackward = false): TransitionGroupProps | undefined {
13
+ if (!transition)
14
+ return undefined
15
+ if (typeof transition === 'string') {
16
+ transition = {
17
+ name: transition,
18
+ }
19
+ }
20
+
21
+ if (!transition.name)
22
+ return undefined
23
+
24
+ let name = transition.name.includes('|')
25
+ ? transition.name
26
+ : (transitionResolveMap[transition.name] || transition.name)
27
+
28
+ if (name.includes('|')) {
29
+ const [forward, backward] = name.split('|').map(i => i.trim())
30
+ name = isBackward ? backward : forward
31
+ }
32
+
33
+ if (!name)
34
+ return undefined
35
+
36
+ return {
37
+ ...transition,
38
+ name,
39
+ }
40
+ }
41
+
42
+ export function getCurrentTransition(direction: number, currentRoute?: SlideRoute, prevRoute?: SlideRoute) {
43
+ let transition = direction > 0
44
+ ? prevRoute?.meta?.transition
45
+ : currentRoute?.meta?.transition
46
+ if (!transition)
47
+ transition = configs.transition
48
+
49
+ return resolveTransition(transition, direction < 0)
50
+ }
package/logic/utils.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { parseRangeString } from '@slidev/parser/core'
1
2
  import { useTimestamp } from '@vueuse/core'
2
3
  import { computed, ref } from 'vue'
3
4
 
@@ -24,7 +25,7 @@ export function useTimer() {
24
25
 
25
26
  export function makeId(length = 5) {
26
27
  const result = []
27
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
28
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
28
29
  const charactersLength = characters.length
29
30
  for (let i = 0; i < length; i++)
30
31
  result.push(characters.charAt(Math.floor(Math.random() * charactersLength)))
@@ -48,3 +49,25 @@ export function normalizeAtProp(at: string | number = '+1'): [isRelative: boolea
48
49
  n,
49
50
  ]
50
51
  }
52
+
53
+ export function updateCodeHighlightRange(
54
+ rangeStr: string,
55
+ linesCount: number,
56
+ startLine: number,
57
+ getTokenOfLine: (line: number) => Element[],
58
+ ) {
59
+ const highlights: number[] = parseRangeString(linesCount + startLine - 1, rangeStr)
60
+ for (let line = 0; line < linesCount; line++) {
61
+ const tokens = getTokenOfLine(line)
62
+ const isHighlighted = highlights.includes(line + startLine)
63
+ for (const token of tokens) {
64
+ // token.classList.toggle(CLASS_VCLICK_TARGET, true)
65
+ token.classList.toggle('slidev-code-highlighted', isHighlighted)
66
+ token.classList.toggle('slidev-code-dishonored', !isHighlighted)
67
+
68
+ // for backward compatibility
69
+ token.classList.toggle('highlighted', isHighlighted)
70
+ token.classList.toggle('dishonored', !isHighlighted)
71
+ }
72
+ }
73
+ }
package/main.ts CHANGED
@@ -1,21 +1,9 @@
1
+ /// <reference types="@slidev/types/client" />
2
+
1
3
  import { createApp } from 'vue'
2
- import { createHead } from '@unhead/vue'
3
4
  import App from './App.vue'
4
5
  import setupMain from './setup/main'
5
- import { router } from './routes'
6
- import { createVClickDirectives } from './modules/v-click'
7
- import { createVMarkDirective } from './modules/v-mark'
8
- import { createSlidevContext } from './modules/context'
9
-
10
- import '/@slidev/styles'
11
6
 
12
7
  const app = createApp(App)
13
- app.use(router)
14
- app.use(createHead())
15
- app.use(createVClickDirectives())
16
- app.use(createVMarkDirective())
17
- app.use(createSlidevContext())
18
-
19
- setupMain({ app, router })
20
-
8
+ setupMain(app)
21
9
  app.mount('#app')
@@ -1,7 +1,7 @@
1
1
  import type { Ref, WritableComputedRef } from 'vue'
2
2
  import { onClickOutside } from '@vueuse/core'
3
3
  import { watch } from 'vue'
4
- import * as _CodeMirror from 'codemirror'
4
+ import CodeMirror from 'codemirror'
5
5
  import 'codemirror/mode/javascript/javascript'
6
6
  import 'codemirror/mode/css/css'
7
7
  import 'codemirror/mode/markdown/markdown'
@@ -10,8 +10,6 @@ import 'codemirror/mode/htmlmixed/htmlmixed'
10
10
  import 'codemirror/addon/display/placeholder'
11
11
  import 'codemirror/lib/codemirror.css'
12
12
 
13
- const CodeMirror = _CodeMirror.default ?? ('fromTextArea' in _CodeMirror ? _CodeMirror : globalThis.CodeMirror)
14
-
15
13
  export async function useCodeMirror(
16
14
  textarea: Ref<HTMLTextAreaElement | null | undefined>,
17
15
  input: Ref<string> | WritableComputedRef<string>,
@@ -1,54 +1,9 @@
1
- import type { App } from 'vue'
2
- import { computed, reactive, ref } from 'vue'
3
- import type { RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router'
4
1
  import type { ComputedRef } from '@vue/reactivity'
5
2
  import type { configs } from '../env'
6
- import * as nav from '../logic/nav'
7
- import { route } from '../logic/nav'
8
- import { isDark } from '../logic/dark'
9
- import { injectionCurrentPage, injectionRenderContext, injectionSlidevContext } from '../constants'
10
- import { useContext } from '../composables/useContext'
11
-
12
- export type SlidevContextNavKey = 'path' | 'total' | 'clicksContext' | 'clicks' | 'clicksTotal' | 'currentPage' | 'currentPath' | 'currentRoute' | 'currentSlideId' | 'currentLayout' | 'nextRoute' | 'rawTree' | 'treeWithActiveStatuses' | 'tree' | 'downloadPDF' | 'next' | 'nextSlide' | 'openInEditor' | 'prev' | 'prevSlide' | 'rawRoutes' | 'go'
13
-
14
- export interface SlidevContextNav extends Pick<typeof nav, SlidevContextNavKey> {
15
- route: ComputedRef<RouteRecordRaw | RouteLocationNormalizedLoaded>
16
- }
3
+ import type { SlidevContextNav } from '../composables/useNav'
17
4
 
18
5
  export interface SlidevContext {
19
6
  nav: SlidevContextNav
20
7
  configs: typeof configs
21
8
  themeConfigs: ComputedRef<typeof configs['themeConfig']>
22
9
  }
23
-
24
- export function createSlidevContext() {
25
- return {
26
- install(app: App) {
27
- const context = reactive(useContext(route))
28
- app.provide(injectionRenderContext, ref('none'))
29
- app.provide(injectionSlidevContext, context)
30
- app.provide(injectionCurrentPage, computed(() => context.nav.currentPage))
31
-
32
- // allows controls from postMessages
33
- if (__DEV__) {
34
- // @ts-expect-error expose global
35
- window.__slidev__ = context
36
- window.addEventListener('message', ({ data }) => {
37
- if (data && data.target === 'slidev') {
38
- if (data.type === 'navigate') {
39
- nav.go(+data.no, +data.clicks || 0)
40
- }
41
- else if (data.type === 'css-vars') {
42
- const root = document.documentElement
43
- for (const [key, value] of Object.entries(data.vars || {}))
44
- root.style.setProperty(key, value as any)
45
- }
46
- else if (data.type === 'color-schema') {
47
- isDark.value = data.color === 'dark'
48
- }
49
- }
50
- })
51
- }
52
- },
53
- }
54
- }
@@ -1,17 +1,18 @@
1
1
  import mermaid from 'mermaid/dist/mermaid.esm.mjs'
2
- import { customAlphabet } from 'nanoid'
3
- import { decode } from 'js-base64'
2
+ import lz from 'lz-string'
4
3
  import { clearUndefined } from '@antfu/utils'
5
4
  import setupMermaid from '../setup/mermaid'
5
+ import { makeId } from '../logic/utils'
6
6
 
7
7
  mermaid.startOnLoad = false
8
8
  mermaid.initialize({ startOnLoad: false })
9
9
 
10
- const nanoid = customAlphabet('abcedfghicklmn', 10)
11
10
  const cache = new Map<string, string>()
11
+ let containerElement: Element | undefined
12
12
 
13
- export async function renderMermaid(encoded: string, options: any) {
14
- const key = encoded + JSON.stringify(options)
13
+ export async function renderMermaid(lzEncoded: string, options: any) {
14
+ containerElement ??= document.getElementById('mermaid-rendering-container')!
15
+ const key = lzEncoded + JSON.stringify(options)
15
16
  const _cache = cache.get(key)
16
17
  if (_cache)
17
18
  return _cache
@@ -21,9 +22,9 @@ export async function renderMermaid(encoded: string, options: any) {
21
22
  ...clearUndefined(setupMermaid() || {}),
22
23
  ...clearUndefined(options),
23
24
  })
24
- const code = decode(encoded)
25
- const id = nanoid()
26
- const { svg } = await mermaid.render(id, code)
25
+ const code = lz.decompressFromBase64(lzEncoded)
26
+ const id = makeId()
27
+ const { svg } = await mermaid.render(id, code, containerElement)
27
28
  cache.set(key, svg)
28
29
  return svg
29
30
  }
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.9",
4
+ "version": "0.48.0",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "bugs": "https://github.com/slidevjs/slidev/issues",
15
15
  "exports": {
16
+ ".": "./index.ts",
16
17
  "./package.json": "./package.json",
17
18
  "./constants": "./constants.ts",
18
19
  "./context": "./context.ts",
@@ -22,42 +23,47 @@
22
23
  "./utils": "./utils.ts",
23
24
  "./*": "./*"
24
25
  },
26
+ "main": "./public.ts",
25
27
  "engines": {
26
28
  "node": ">=18.0.0"
27
29
  },
28
30
  "dependencies": {
29
31
  "@antfu/utils": "^0.7.7",
30
- "@iconify-json/carbon": "^1.1.30",
32
+ "@iconify-json/carbon": "^1.1.31",
31
33
  "@iconify-json/ph": "^1.1.11",
34
+ "@iconify-json/svg-spinners": "^1.1.2",
35
+ "@shikijs/monaco": "^1.1.7",
32
36
  "@shikijs/vitepress-twoslash": "^1.1.7",
33
37
  "@slidev/rough-notation": "^0.1.0",
34
- "@unhead/vue": "^1.8.10",
38
+ "@typescript/ata": "^0.9.4",
39
+ "@unhead/vue": "^1.8.11",
35
40
  "@unocss/reset": "^0.58.5",
36
- "@vueuse/core": "^10.8.0",
37
- "@vueuse/math": "^10.8.0",
41
+ "@vueuse/core": "^10.9.0",
42
+ "@vueuse/math": "^10.9.0",
38
43
  "@vueuse/motion": "^2.1.0",
39
44
  "codemirror": "^5.65.16",
40
- "defu": "^6.1.4",
41
45
  "drauu": "^0.4.0",
42
46
  "file-saver": "^2.0.5",
43
47
  "floating-vue": "^5.2.2",
44
48
  "fuse.js": "^7.0.0",
45
- "js-base64": "^3.7.7",
46
49
  "js-yaml": "^4.1.0",
47
50
  "katex": "^0.16.9",
48
- "mermaid": "^10.8.0",
49
- "monaco-editor": "^0.37.1",
50
- "nanoid": "^5.0.6",
51
+ "lz-string": "^1.5.0",
52
+ "mermaid": "^10.9.0",
53
+ "monaco-editor": "^0.46.0",
51
54
  "prettier": "^3.2.5",
52
55
  "recordrtc": "^5.6.2",
53
- "resolve": "^1.22.8",
56
+ "shiki": "^1.1.7",
57
+ "shiki-magic-move": "^0.3.4",
58
+ "typescript": "^5.4.2",
54
59
  "unocss": "^0.58.5",
55
- "vue": "^3.4.19",
60
+ "vue": "^3.4.21",
61
+ "vue-demi": "^0.14.7",
56
62
  "vue-router": "^4.3.0",
57
- "@slidev/parser": "0.48.0-beta.9",
58
- "@slidev/types": "0.48.0-beta.9"
63
+ "@slidev/parser": "0.48.0",
64
+ "@slidev/types": "0.48.0"
59
65
  },
60
66
  "devDependencies": {
61
- "vite": "^5.1.4"
67
+ "vite": "^5.1.5"
62
68
  }
63
69
  }
package/pages/notes.vue CHANGED
@@ -5,22 +5,23 @@ 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
- import { total } from '../logic/nav'
9
- import { rawRoutes } from '../routes'
8
+
10
9
  import NoteDisplay from '../internals/NoteDisplay.vue'
11
10
  import IconButton from '../internals/IconButton.vue'
11
+ import { useNav } from '../composables/useNav'
12
12
 
13
13
  const slideTitle = configs.titleTemplate.replace('%s', configs.title || 'Slidev')
14
14
  useHead({
15
15
  title: `Notes - ${slideTitle}`,
16
16
  })
17
17
 
18
+ const { slides, total } = useNav()
18
19
  const { isFullscreen, toggle: toggleFullscreen } = fullscreen
19
20
 
20
21
  const scroller = ref<HTMLDivElement>()
21
22
  const fontSize = useLocalStorage('slidev-notes-font-size', 18)
22
23
  const pageNo = computed(() => sharedState.lastUpdate?.type === 'viewer' ? sharedState.viewerPage : sharedState.page)
23
- const currentRoute = computed(() => rawRoutes.find(i => i.path === `${pageNo.value}`))
24
+ const currentRoute = computed(() => slides.value.find(i => i.no === pageNo.value))
24
25
 
25
26
  watch(pageNo, () => {
26
27
  scroller.value?.scrollTo({ left: 0, top: 0, behavior: 'smooth' })
@@ -51,6 +52,8 @@ function decreaseFontSize() {
51
52
  :note="currentRoute?.meta?.slide?.note"
52
53
  :note-html="currentRoute?.meta?.slide?.noteHTML"
53
54
  :placeholder="`No notes for Slide ${pageNo}.`"
55
+ :clicks-context="currentRoute?.meta?.__clicksContext"
56
+ :auto-scroll="true"
54
57
  />
55
58
  </div>
56
59
  <div class="flex-none border-t border-main">
@@ -1,21 +1,52 @@
1
1
  <script setup lang="ts">
2
- import { nextTick, onMounted, reactive, ref } from 'vue'
3
- import { themeVars } from '../env'
4
- import { rawRoutes } from '../logic/nav'
5
- import { useFixedClicks } from '../composables/useClicks'
2
+ import { computed, nextTick, onMounted, reactive, ref } from 'vue'
3
+ import { useHead } from '@unhead/vue'
4
+ import type { ClicksContext, SlideRoute } from '@slidev/types'
5
+ import { configs } from '../env'
6
+ import { getSlidePath } from '../logic/slides'
7
+ import { createFixedClicks } from '../composables/useClicks'
6
8
  import { isColorSchemaConfigured, isDark, toggleDark } from '../logic/dark'
7
9
  import { getSlideClass } from '../utils'
8
10
  import SlideContainer from '../internals/SlideContainer.vue'
9
- import SlideWrapper from '../internals/SlideWrapper'
11
+ import SlideWrapper from '../internals/SlideWrapper.vue'
10
12
  import DrawingPreview from '../internals/DrawingPreview.vue'
11
13
  import IconButton from '../internals/IconButton.vue'
12
- import NoteEditor from '../internals/NoteEditor.vue'
14
+ import NoteEditable from '../internals/NoteEditable.vue'
15
+ import ClicksSlider from '../internals/ClicksSlider.vue'
16
+ import { CLICKS_MAX } from '../constants'
17
+ import { useNav } from '../composables/useNav'
13
18
 
14
19
  const cardWidth = 450
15
20
 
21
+ const slideTitle = configs.titleTemplate.replace('%s', configs.title || 'Slidev')
22
+ useHead({
23
+ title: `Overview - ${slideTitle}`,
24
+ })
25
+
26
+ const { openInEditor, slides } = useNav()
27
+
16
28
  const blocks: Map<number, HTMLElement> = reactive(new Map())
17
29
  const activeBlocks = ref<number[]>([])
18
- const edittingNote = ref<string | null>(null)
30
+ const edittingNote = ref<number | null>(null)
31
+ const wordCounts = computed(() => slides.value.map(route => wordCount(route.meta?.slide?.note || '')))
32
+ const totalWords = computed(() => wordCounts.value.reduce((a, b) => a + b, 0))
33
+ const totalClicks = computed(() => slides.value.map(route => getSlideClicks(route)).reduce((a, b) => a + b, 0))
34
+
35
+ const clicksContextMap = new WeakMap<SlideRoute, ClicksContext>()
36
+ function getClicksContext(route: SlideRoute) {
37
+ // We create a local clicks context to calculate the total clicks of the slide
38
+ if (!clicksContextMap.has(route))
39
+ clicksContextMap.set(route, createFixedClicks(route, CLICKS_MAX))
40
+ return clicksContextMap.get(route)!
41
+ }
42
+
43
+ function getSlideClicks(route: SlideRoute) {
44
+ return route.meta?.clicks || getClicksContext(route)?.total
45
+ }
46
+
47
+ function wordCount(str: string) {
48
+ return str.match(/[\w\d\’\'-]+/gi)?.length || 0
49
+ }
19
50
 
20
51
  function isElementInViewport(el: HTMLElement) {
21
52
  const rect = el.getBoundingClientRect()
@@ -51,6 +82,15 @@ function scrollToSlide(idx: number) {
51
82
  el.scrollIntoView({ behavior: 'smooth', block: 'start' })
52
83
  }
53
84
 
85
+ function onMarkerClick(e: MouseEvent, clicks: number, route: SlideRoute) {
86
+ const ctx = getClicksContext(route)
87
+ if (ctx.current === clicks)
88
+ ctx.current = CLICKS_MAX
89
+ else
90
+ ctx.current = clicks
91
+ e.preventDefault()
92
+ }
93
+
54
94
  onMounted(() => {
55
95
  nextTick(() => {
56
96
  checkActiveBlocks()
@@ -61,18 +101,27 @@ onMounted(() => {
61
101
  <template>
62
102
  <div class="h-screen w-screen of-hidden flex">
63
103
  <nav class="h-full flex flex-col border-r border-main p2 select-none">
64
- <div class="of-auto flex flex-col flex-auto items-center">
65
- <button
66
- v-for="(route, idx) of rawRoutes"
67
- :key="route.path"
68
- class="relative transition duration-300 w-8 h-8 rounded hover:bg-gray:10 hover:op100"
69
- :class="[
70
- activeBlocks.includes(idx) ? 'op100 text-primary' : 'op20',
71
- ]"
72
- @click="scrollToSlide(idx)"
104
+ <div class="flex flex-col flex-auto items-center justify-center group gap-1">
105
+ <div
106
+ v-for="(route, idx) of slides"
107
+ :key="route.no"
108
+ class="relative"
73
109
  >
74
- <div>{{ idx + 1 }}</div>
75
- </button>
110
+ <button
111
+ class="relative transition duration-300 w-8 h-8 rounded hover:bg-active hover:op100"
112
+ :class="activeBlocks.includes(idx) ? 'op100 text-primary bg-gray:5' : 'op20'"
113
+ @click="scrollToSlide(idx)"
114
+ >
115
+ <div>{{ idx + 1 }}</div>
116
+ </button>
117
+ <div
118
+ v-if="route.meta?.slide?.title"
119
+ class="pointer-events-none select-none absolute left-110% bg-main top-50% translate-y--50% ws-nowrap z-10 px2 shadow-xl rounded border border-main transition duration-400 op0 group-hover:op100"
120
+ :class="activeBlocks.includes(idx) ? 'text-primary' : 'text-main important-text-op-50'"
121
+ >
122
+ {{ route.meta?.slide?.title }}
123
+ </div>
124
+ </div>
76
125
  </div>
77
126
  <IconButton
78
127
  v-if="!isColorSchemaConfigured"
@@ -88,57 +137,95 @@ onMounted(() => {
88
137
  :style="`grid-template-columns: repeat(auto-fit,minmax(${cardWidth}px,1fr))`"
89
138
  @scroll="checkActiveBlocks"
90
139
  >
91
- <div class="px4 py2 text-orange bg-orange:5 select-none">
92
- <span font-bold>List Overview</span> is in beta, feedback is welcome!
93
- </div>
94
140
  <div
95
- v-for="(route, idx) of rawRoutes"
96
- :key="route.path"
97
- :ref="el => blocks.set(idx, el)"
141
+ v-for="(route, idx) of slides"
142
+ :key="route.no"
143
+ :ref="el => blocks.set(idx, el as any)"
98
144
  class="relative border-t border-main of-hidden flex gap-4 min-h-50 group"
145
+ :class="idx === 0 ? 'pt5' : ''"
99
146
  >
100
- <div class="select-none text-3xl op20 w-13 my4 text-right">
101
- {{ idx + 1 }}
147
+ <div class="select-none w-13 text-right my4 flex flex-col gap-1 items-end">
148
+ <div class="text-3xl op20 mb2">
149
+ {{ idx + 1 }}
150
+ </div>
151
+ <IconButton
152
+ class="mr--3 op0 group-hover:op80"
153
+ title="Play in new tab"
154
+ @click="openSlideInNewTab(getSlidePath(route, false))"
155
+ >
156
+ <carbon:presentation-file />
157
+ </IconButton>
158
+ <IconButton
159
+ v-if="route.meta?.slide"
160
+ class="mr--3 op0 group-hover:op80"
161
+ title="Open in editor"
162
+ @click="openInEditor(`${route.meta.slide.filepath}:${route.meta.slide.start}`)"
163
+ >
164
+ <carbon:cics-program />
165
+ </IconButton>
102
166
  </div>
103
- <div
104
- class="border rounded border-main overflow-hidden bg-main my5 select-none"
105
- :style="themeVars"
106
- @dblclick="openSlideInNewTab(route.path)"
107
- >
108
- <SlideContainer
109
- :key="route.path"
110
- :width="cardWidth"
111
- :clicks-disabled="true"
112
- class="pointer-events-none important:[&_*]:select-none"
167
+ <div class="flex flex-col gap-2 my5">
168
+ <div
169
+ class="border rounded border-main overflow-hidden bg-main select-none h-max"
170
+ @dblclick="openSlideInNewTab(getSlidePath(route, false))"
113
171
  >
114
- <SlideWrapper
115
- :is="route.component"
116
- v-if="route?.component"
117
- :clicks-context="useFixedClicks(route, 99999)[1]"
118
- :class="getSlideClass(route)"
119
- :route="route"
120
- render-context="overview"
121
- />
122
- <DrawingPreview :page="+route.path" />
123
- </SlideContainer>
172
+ <SlideContainer
173
+ :key="route.no"
174
+ :width="cardWidth"
175
+ :clicks-disabled="true"
176
+ class="pointer-events-none important:[&_*]:select-none"
177
+ >
178
+ <SlideWrapper
179
+ :is="route.component!"
180
+ :clicks-context="getClicksContext(route)"
181
+ :class="getSlideClass(route)"
182
+ :route="route"
183
+ render-context="overview"
184
+ />
185
+ <DrawingPreview :page="route.no" />
186
+ </SlideContainer>
187
+ </div>
188
+ <ClicksSlider
189
+ v-if="getSlideClicks(route)"
190
+ mt-2
191
+ :clicks-context="getClicksContext(route)"
192
+ class="w-full"
193
+ />
124
194
  </div>
125
195
  <div class="py3 mt-0.5 mr--8 ml--4 op0 transition group-hover:op100">
126
196
  <IconButton
127
197
  title="Edit Note"
128
198
  class="rounded-full w-9 h-9 text-sm"
129
- :class="edittingNote === idx ? 'important:op0' : ''"
130
- @click="edittingNote = idx"
199
+ :class="edittingNote === route.no ? 'important:op0' : ''"
200
+ @click="edittingNote = route.no"
131
201
  >
132
202
  <carbon:pen />
133
203
  </IconButton>
134
204
  </div>
135
- <NoteEditor
136
- :no="idx"
205
+ <NoteEditable
206
+ :no="route.no"
137
207
  class="max-w-250 w-250 text-lg rounded p3"
138
- :editing="edittingNote === idx"
208
+ :auto-height="true"
209
+ :editing="edittingNote === route.no"
210
+ :clicks-context="getClicksContext(route)"
211
+ @dblclick="edittingNote !== route.no ? edittingNote = route.no : null"
139
212
  @update:editing="edittingNote = null"
213
+ @marker-click="(e, clicks) => onMarkerClick(e, clicks, route)"
140
214
  />
215
+ <div
216
+ v-if="wordCounts[idx] > 0"
217
+ class="select-none absolute bottom-0 right-0 bg-main rounded-tl p2 op35 text-xs"
218
+ >
219
+ {{ wordCounts[idx] }} words
220
+ </div>
141
221
  </div>
142
222
  </main>
223
+ <div class="absolute top-0 right-0 px3 py1.5 border-b border-l rounded-lb bg-main border-main select-none">
224
+ <div class="text-xs op50">
225
+ {{ slides.length }} slides ·
226
+ {{ totalClicks + slides.length - 1 }} clicks ·
227
+ {{ totalWords }} words
228
+ </div>
229
+ </div>
143
230
  </div>
144
231
  </template>
package/pages/play.vue CHANGED
@@ -1,18 +1,22 @@
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, useSwipeControls } from '../logic/nav'
5
- import { isDrawing } from '../logic/drawings'
4
+ import { useSwipeControls } from '../composables/useSwipeControls'
6
5
  import { registerShortcuts } from '../logic/shortcuts'
7
- import { configs, themeVars } from '../env'
6
+ import { configs } from '../env'
8
7
  import Controls from '../internals/Controls.vue'
9
8
  import SlideContainer from '../internals/SlideContainer.vue'
10
9
  import NavControls from '../internals/NavControls.vue'
11
10
  import SlidesShow from '../internals/SlidesShow.vue'
12
11
  import PrintStyle from '../internals/PrintStyle.vue'
12
+ import { useNav } from '../composables/useNav'
13
+ import { useDrawings } from '../composables/useDrawings'
13
14
 
14
15
  registerShortcuts()
15
16
 
17
+ const { next, prev, isEmbedded, isPrintMode } = useNav()
18
+ const { isDrawing } = useDrawings()
19
+
16
20
  const root = ref<HTMLDivElement>()
17
21
  function onClick(e: MouseEvent) {
18
22
  if (showEditor.value)
@@ -31,9 +35,9 @@ useSwipeControls(root)
31
35
 
32
36
  const persistNav = computed(() => isScreenVertical.value || showEditor.value)
33
37
 
34
- const Editor = shallowRef<any>()
38
+ const SideEditor = shallowRef<any>()
35
39
  if (__DEV__ && __SLIDEV_FEATURE_EDITOR__)
36
- import('../internals/Editor.vue').then(v => Editor.value = v.default)
40
+ import('../internals/SideEditor.vue').then(v => SideEditor.value = v.default)
37
41
 
38
42
  const DrawingControls = shallowRef<any>()
39
43
  if (__SLIDEV_FEATURE_DRAWINGS__)
@@ -42,7 +46,10 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
42
46
 
43
47
  <template>
44
48
  <PrintStyle v-if="isPrintMode" />
45
- <div id="page-root" ref="root" class="grid" :class="isEditorVertical ? 'grid-rows-[1fr_max-content]' : 'grid-cols-[1fr_max-content]'" :style="themeVars">
49
+ <div
50
+ id="page-root" ref="root" class="grid"
51
+ :class="isEditorVertical ? 'grid-rows-[1fr_max-content]' : 'grid-cols-[1fr_max-content]'"
52
+ >
46
53
  <SlideContainer
47
54
  class="w-full h-full"
48
55
  :style="{ background: 'var(--slidev-slide-container-background, black)' }"
@@ -70,9 +77,9 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
70
77
  </template>
71
78
  </SlideContainer>
72
79
 
73
- <template v-if="__DEV__ && __SLIDEV_FEATURE_EDITOR__ && Editor && showEditor">
74
- <Editor :resize="true" />
80
+ <template v-if="__DEV__ && __SLIDEV_FEATURE_EDITOR__ && SideEditor && showEditor">
81
+ <SideEditor :resize="true" />
75
82
  </template>
76
83
  </div>
77
84
  <Controls />
78
- </template>
85
+ </template>../composables/drawings