vuepress-plugin-md-power 1.0.0-rc.136 → 1.0.0-rc.138
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/lib/client/components/Abbreviation.vue +33 -4
- package/lib/client/components/Annotation.vue +12 -5
- package/lib/client/components/CodeEditor.vue +1 -0
- package/lib/client/components/VPCollapse.vue +31 -0
- package/lib/client/components/VPCollapseItem.vue +120 -0
- package/lib/client/components/VPDemoBasic.vue +55 -7
- package/lib/client/components/VPDemoNormal.vue +13 -5
- package/lib/client/components/VPTimeline.vue +52 -0
- package/lib/client/components/VPTimelineItem.vue +330 -0
- package/lib/client/options.d.ts +3 -1
- package/lib/client/options.js +8 -0
- package/lib/client/shim.d.ts +7 -0
- package/lib/client/styles/chat.css +129 -0
- package/lib/client/styles/demo.css +11 -0
- package/lib/node/index.d.ts +50 -0
- package/lib/node/index.js +330 -29
- package/lib/shared/index.d.ts +50 -0
- package/package.json +12 -11
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { CSSProperties } from 'vue'
|
|
3
|
+
import { onClickOutside, useMediaQuery, useToggle } from '@vueuse/core'
|
|
3
4
|
import { nextTick, ref, useTemplateRef, watch } from 'vue'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
import '@vuepress/helper/transition/fade-in.css'
|
|
7
|
+
|
|
8
|
+
const [show, toggle] = useToggle(false)
|
|
9
|
+
|
|
10
|
+
const el = useTemplateRef<HTMLSpanElement>('el')
|
|
6
11
|
const tooltip = useTemplateRef<HTMLSpanElement>('tooltip')
|
|
7
12
|
const styles = ref<CSSProperties>()
|
|
8
13
|
|
|
14
|
+
const isMobile = useMediaQuery('(max-width: 768px)')
|
|
15
|
+
const showTooltip = () => toggle(true)
|
|
16
|
+
const hiddenTooltip = () => toggle(false)
|
|
17
|
+
|
|
18
|
+
onClickOutside(el, () => {
|
|
19
|
+
if (isMobile.value)
|
|
20
|
+
hiddenTooltip()
|
|
21
|
+
}, {
|
|
22
|
+
ignore: [tooltip],
|
|
23
|
+
})
|
|
24
|
+
|
|
9
25
|
watch(show, () => nextTick(() => {
|
|
10
26
|
if (__VUEPRESS_SSR__)
|
|
11
27
|
return
|
|
@@ -32,11 +48,24 @@ watch(show, () => nextTick(() => {
|
|
|
32
48
|
</script>
|
|
33
49
|
|
|
34
50
|
<template>
|
|
35
|
-
<span
|
|
51
|
+
<span
|
|
52
|
+
ref="el"
|
|
53
|
+
class="vp-abbr"
|
|
54
|
+
role="tooltip"
|
|
55
|
+
tabindex="0"
|
|
56
|
+
v-bind="isMobile ? {
|
|
57
|
+
onClick: showTooltip,
|
|
58
|
+
} : {
|
|
59
|
+
onMouseenter: showTooltip,
|
|
60
|
+
onMouseleave: hiddenTooltip,
|
|
61
|
+
onFocus: showTooltip,
|
|
62
|
+
onBlur: hiddenTooltip,
|
|
63
|
+
}"
|
|
64
|
+
>
|
|
36
65
|
<slot />
|
|
37
66
|
<ClientOnly>
|
|
38
|
-
<Transition name="fade">
|
|
39
|
-
<span v-show="show" ref="tooltip" class="vp-abbr-tooltip ignore-header" :style="styles">
|
|
67
|
+
<Transition name="fade-in">
|
|
68
|
+
<span v-show="show" ref="tooltip" class="vp-abbr-tooltip ignore-header" :style="styles" aria-hidden="true">
|
|
40
69
|
<slot name="tooltip" />
|
|
41
70
|
</span>
|
|
42
71
|
</Transition>
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { onClickOutside, useEventListener } from '@vueuse/core'
|
|
3
3
|
import { computed, nextTick, ref, useTemplateRef, watch } from 'vue'
|
|
4
4
|
|
|
5
|
+
import '@vuepress/helper/transition/fade-in.css'
|
|
6
|
+
|
|
5
7
|
const props = defineProps<{
|
|
6
8
|
label: string
|
|
7
9
|
total: number
|
|
@@ -44,10 +46,15 @@ useEventListener('scroll', updatePosition, { passive: true })
|
|
|
44
46
|
</script>
|
|
45
47
|
|
|
46
48
|
<template>
|
|
47
|
-
<span class="vp-annotation ignore-header" :class="{ active, [label]: true }"
|
|
48
|
-
<span
|
|
49
|
+
<span class="vp-annotation ignore-header" :class="{ active, [label]: true }">
|
|
50
|
+
<span
|
|
51
|
+
ref="button"
|
|
52
|
+
:aria-label="label"
|
|
53
|
+
class="vpi-annotation"
|
|
54
|
+
@click="active = !active"
|
|
55
|
+
/>
|
|
49
56
|
<ClientOnly>
|
|
50
|
-
<Transition name="fade">
|
|
57
|
+
<Transition name="fade-in">
|
|
51
58
|
<div
|
|
52
59
|
v-show="active" ref="popover"
|
|
53
60
|
class="annotations-popover" :class="{ list: list.length > 1 }"
|
|
@@ -73,8 +80,8 @@ useEventListener('scroll', updatePosition, { passive: true })
|
|
|
73
80
|
position: relative;
|
|
74
81
|
top: -2px;
|
|
75
82
|
z-index: 2;
|
|
76
|
-
width: 1.
|
|
77
|
-
height: 1.
|
|
83
|
+
width: 1.5em;
|
|
84
|
+
height: 1.5em;
|
|
78
85
|
color: currentcolor;
|
|
79
86
|
cursor: pointer;
|
|
80
87
|
opacity: 0.5;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { provide, ref } from 'vue'
|
|
3
|
+
import { INJECT_COLLAPSE_KEY } from '../options.js'
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
accordion?: boolean
|
|
7
|
+
index?: number
|
|
8
|
+
}>()
|
|
9
|
+
|
|
10
|
+
const currentIndex = ref<number | undefined>(props.index)
|
|
11
|
+
|
|
12
|
+
provide(INJECT_COLLAPSE_KEY, {
|
|
13
|
+
accordion: props.accordion ?? false,
|
|
14
|
+
index: currentIndex,
|
|
15
|
+
})
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<div class="vp-collapse">
|
|
20
|
+
<slot />
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
.vp-collapse {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
gap: 16px;
|
|
29
|
+
margin: 16px 0;
|
|
30
|
+
}
|
|
31
|
+
</style>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Ref } from 'vue'
|
|
3
|
+
import { FadeInExpandTransition } from '@vuepress/helper/client'
|
|
4
|
+
import { inject, ref, watch } from 'vue'
|
|
5
|
+
import { INJECT_COLLAPSE_KEY } from '../options.js'
|
|
6
|
+
|
|
7
|
+
import '@vuepress/helper/transition/fade-in-height-expand.css'
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{
|
|
10
|
+
expand?: boolean
|
|
11
|
+
index: number
|
|
12
|
+
}>()
|
|
13
|
+
|
|
14
|
+
const collapse = inject<{
|
|
15
|
+
accordion: boolean
|
|
16
|
+
index: Ref<number | undefined>
|
|
17
|
+
}>(INJECT_COLLAPSE_KEY)
|
|
18
|
+
|
|
19
|
+
if (__VUEPRESS_DEV__ && !collapse) {
|
|
20
|
+
throw new Error('<VPCollapseItem /> must be used inside <VPCollapse />')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const expand = ref(
|
|
24
|
+
collapse?.accordion && typeof collapse.index.value !== 'undefined'
|
|
25
|
+
? props.index === collapse.index.value
|
|
26
|
+
: props.expand,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
if (collapse?.accordion) {
|
|
30
|
+
watch(collapse?.index, () => {
|
|
31
|
+
expand.value = collapse?.index.value === props.index
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function toggle() {
|
|
36
|
+
if (collapse?.accordion) {
|
|
37
|
+
if (collapse.index.value === props.index && expand.value) {
|
|
38
|
+
expand.value = false
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
collapse!.index.value = props.index!
|
|
42
|
+
expand.value = true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
expand.value = !expand.value
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<div class="vp-collapse-item" :class="{ expand }">
|
|
53
|
+
<div class="vp-collapse-header" @click="toggle">
|
|
54
|
+
<span class="vpi-chevron-right" />
|
|
55
|
+
<p class="vp-collapse-title">
|
|
56
|
+
<slot name="title" />
|
|
57
|
+
</p>
|
|
58
|
+
</div>
|
|
59
|
+
<FadeInExpandTransition>
|
|
60
|
+
<div v-show="expand" class="vp-collapse-content">
|
|
61
|
+
<div class="vp-collapse-content-inner">
|
|
62
|
+
<slot />
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</FadeInExpandTransition>
|
|
66
|
+
</div>
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<style>
|
|
70
|
+
.vp-collapse-item {
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
padding-top: 16px;
|
|
74
|
+
border-top: solid 1px var(--vp-c-divider);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.vp-collapse-item:first-child {
|
|
78
|
+
border-top: none;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.vp-collapse-header {
|
|
82
|
+
display: flex;
|
|
83
|
+
gap: 6px;
|
|
84
|
+
align-items: center;
|
|
85
|
+
font-size: 16px;
|
|
86
|
+
font-weight: 600;
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.vp-collapse-header .vpi-chevron-right {
|
|
91
|
+
align-self: baseline;
|
|
92
|
+
width: 20px;
|
|
93
|
+
height: 20px;
|
|
94
|
+
transition: transform var(--vp-t-color);
|
|
95
|
+
transform: rotate(0deg);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.vp-collapse-item.expand .vpi-chevron-right {
|
|
99
|
+
transform: rotate(90deg);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.vp-collapse-header .vp-collapse-title {
|
|
103
|
+
flex: 1 2;
|
|
104
|
+
margin: 0;
|
|
105
|
+
line-height: 1;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.vp-collapse-content-inner {
|
|
109
|
+
padding-top: 12px;
|
|
110
|
+
padding-left: 24px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.vp-collapse-content-inner > *:first-child {
|
|
114
|
+
margin-top: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.vp-collapse-content-inner > *:last-child {
|
|
118
|
+
margin-bottom: 0;
|
|
119
|
+
}
|
|
120
|
+
</style>
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { FadeInExpandTransition } from '@vuepress/helper/client'
|
|
3
|
+
import { useResizeObserver } from '@vueuse/core'
|
|
4
|
+
import { useTemplateRef, watch } from 'vue'
|
|
5
|
+
import { ClientOnly, onContentUpdated } from 'vuepress/client'
|
|
2
6
|
import { useExpand } from '../composables/demo.js'
|
|
3
7
|
|
|
8
|
+
import '@vuepress/helper/transition/fade-in-height-expand.css'
|
|
4
9
|
import '../styles/demo.css'
|
|
5
10
|
|
|
6
11
|
const props = defineProps<{
|
|
@@ -11,12 +16,51 @@ const props = defineProps<{
|
|
|
11
16
|
}>()
|
|
12
17
|
|
|
13
18
|
const [showCode, toggleCode] = useExpand(props.expanded)
|
|
19
|
+
|
|
20
|
+
const draw = useTemplateRef<HTMLIFrameElement>('draw')
|
|
21
|
+
const vueDraw = useTemplateRef<HTMLIFrameElement>('draw-vue')
|
|
22
|
+
|
|
23
|
+
function resizeAndPositionVueDraw() {
|
|
24
|
+
if (!draw.value || !vueDraw.value)
|
|
25
|
+
return
|
|
26
|
+
const rect = draw.value.getBoundingClientRect()
|
|
27
|
+
const { scrollLeft, scrollTop } = document.documentElement
|
|
28
|
+
vueDraw.value.style.width = `${draw.value.offsetWidth - 48}px`
|
|
29
|
+
vueDraw.value.style.top = `${rect.top + scrollTop}px`
|
|
30
|
+
vueDraw.value.style.left = `${rect.x + scrollLeft}px`
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (props.type === 'vue' && !__VUEPRESS_SSR__) {
|
|
34
|
+
watch([draw, vueDraw], () => {
|
|
35
|
+
resizeAndPositionVueDraw()
|
|
36
|
+
if (draw.value && vueDraw.value) {
|
|
37
|
+
requestAnimationFrame(() => {
|
|
38
|
+
draw.value!.style.height = `${vueDraw.value!.offsetHeight}px`
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
}, { immediate: true })
|
|
42
|
+
useResizeObserver(draw, resizeAndPositionVueDraw)
|
|
43
|
+
useResizeObserver(() => document.body, resizeAndPositionVueDraw)
|
|
44
|
+
onContentUpdated(resizeAndPositionVueDraw)
|
|
45
|
+
|
|
46
|
+
useResizeObserver(vueDraw, () => {
|
|
47
|
+
if (draw.value && vueDraw.value)
|
|
48
|
+
draw.value.style.height = `${vueDraw.value.offsetHeight}px`
|
|
49
|
+
})
|
|
50
|
+
}
|
|
14
51
|
</script>
|
|
15
52
|
|
|
16
53
|
<template>
|
|
17
|
-
<div class="vp-demo-wrapper">
|
|
18
|
-
<div class="demo-draw">
|
|
19
|
-
<slot />
|
|
54
|
+
<div class="vp-demo-wrapper" :class="{ type }">
|
|
55
|
+
<div ref="draw" class="demo-draw">
|
|
56
|
+
<slot v-if="type !== 'vue'" />
|
|
57
|
+
<ClientOnly v-else>
|
|
58
|
+
<Teleport to="body">
|
|
59
|
+
<div ref="draw-vue" class="demo-draw-vue">
|
|
60
|
+
<slot />
|
|
61
|
+
</div>
|
|
62
|
+
</Teleport>
|
|
63
|
+
</ClientOnly>
|
|
20
64
|
</div>
|
|
21
65
|
<div v-if="title || desc" class="demo-info">
|
|
22
66
|
<p v-if="title" class="title">
|
|
@@ -27,10 +71,14 @@ const [showCode, toggleCode] = useExpand(props.expanded)
|
|
|
27
71
|
</p>
|
|
28
72
|
</div>
|
|
29
73
|
<div class="demo-ctrl">
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<slot name="code" />
|
|
74
|
+
<button type="button" aria-label="Toggle Code" @click="toggleCode">
|
|
75
|
+
<span class="vpi-demo-code" />
|
|
76
|
+
</button>
|
|
34
77
|
</div>
|
|
78
|
+
<FadeInExpandTransition>
|
|
79
|
+
<div v-show="showCode" class="demo-code">
|
|
80
|
+
<slot name="code" />
|
|
81
|
+
</div>
|
|
82
|
+
</FadeInExpandTransition>
|
|
35
83
|
</div>
|
|
36
84
|
</template>
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { DemoConfig } from '../composables/demo.js'
|
|
3
|
+
import { FadeInExpandTransition } from '@vuepress/helper/client'
|
|
3
4
|
import { useTemplateRef } from 'vue'
|
|
4
5
|
import { useExpand, useFence, useNormalDemo, useResources } from '../composables/demo.js'
|
|
5
6
|
|
|
7
|
+
import '@vuepress/helper/transition/fade-in.css'
|
|
8
|
+
import '@vuepress/helper/transition/fade-in-height-expand.css'
|
|
6
9
|
import '../styles/demo.css'
|
|
7
10
|
|
|
8
11
|
const props = defineProps<{
|
|
@@ -37,6 +40,7 @@ const data = useFence(
|
|
|
37
40
|
<iframe
|
|
38
41
|
:id="`VPDemoNormalDraw${id}`"
|
|
39
42
|
ref="draw"
|
|
43
|
+
:title="title || 'Demo'"
|
|
40
44
|
class="draw-iframe"
|
|
41
45
|
allow="accelerometer *; bluetooth *; camera *; encrypted-media *; display-capture *; geolocation *; gyroscope *; microphone *; midi *; clipboard-read *; clipboard-write *; web-share *; serial *; xr-spatial-tracking *"
|
|
42
46
|
allowfullscreen="true"
|
|
@@ -90,7 +94,7 @@ const data = useFence(
|
|
|
90
94
|
</div>
|
|
91
95
|
<div v-if="resources.length" class="demo-resources">
|
|
92
96
|
<span ref="resourcesEl" class="vpi-demo-resources" title="Resources" aria-label="Resources" @click="toggleResources" />
|
|
93
|
-
<Transition name="fade">
|
|
97
|
+
<Transition name="fade-in">
|
|
94
98
|
<div v-show="showResources" class="demo-resources-container">
|
|
95
99
|
<div v-for="{ name, items } in resources" :key="name" class="demo-resources-list">
|
|
96
100
|
<p>{{ name }}</p>
|
|
@@ -103,10 +107,14 @@ const data = useFence(
|
|
|
103
107
|
</div>
|
|
104
108
|
</Transition>
|
|
105
109
|
</div>
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
<slot />
|
|
110
|
+
<button type="button" aria-label="Toggle Code" @click="toggleCode">
|
|
111
|
+
<span class="vpi-demo-code" />
|
|
112
|
+
</button>
|
|
110
113
|
</div>
|
|
114
|
+
<FadeInExpandTransition>
|
|
115
|
+
<div v-show="showCode" ref="fence" class="demo-code">
|
|
116
|
+
<slot />
|
|
117
|
+
</div>
|
|
118
|
+
</FadeInExpandTransition>
|
|
111
119
|
</div>
|
|
112
120
|
</template>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, provide } from 'vue'
|
|
3
|
+
import { INJECT_TIMELINE_KEY } from '../options.js'
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
horizontal?: boolean
|
|
7
|
+
card?: boolean
|
|
8
|
+
placement?: 'left' | 'right' | 'between'
|
|
9
|
+
line?: 'solid' | 'dashed' | 'dotted'
|
|
10
|
+
}>()
|
|
11
|
+
|
|
12
|
+
provide(INJECT_TIMELINE_KEY, computed(() => ({
|
|
13
|
+
line: props.line || 'solid',
|
|
14
|
+
card: props.card ?? false,
|
|
15
|
+
horizontal: props.horizontal ?? false,
|
|
16
|
+
placement: props.placement || 'left',
|
|
17
|
+
})))
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div class="vp-timeline" :class="{ horizontal }">
|
|
22
|
+
<div class="vp-timeline-box">
|
|
23
|
+
<slot />
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<style>
|
|
29
|
+
.vp-timeline {
|
|
30
|
+
position: relative;
|
|
31
|
+
margin: 32px 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.vp-timeline.horizontal {
|
|
35
|
+
padding-bottom: 7px;
|
|
36
|
+
overflow-x: auto;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.vp-timeline-box {
|
|
40
|
+
display: flex;
|
|
41
|
+
gap: 24px 36px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.vp-timeline:not(.horizontal) .vp-timeline-box {
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.vp-timeline.horizontal .vp-timeline-box {
|
|
49
|
+
flex-direction: row;
|
|
50
|
+
width: max-content;
|
|
51
|
+
}
|
|
52
|
+
</style>
|