vuepress-theme-uniapp-official 1.4.15 → 1.4.16

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.
@@ -0,0 +1,12 @@
1
+ interface Header {
2
+ title: string
3
+ width?: number
4
+ align?: 'left' | 'center' | 'right'
5
+ }
6
+
7
+ type Row = string[]
8
+
9
+ export interface MdTableOptions {
10
+ rows: Row[]
11
+ headers: Header[]
12
+ }
@@ -0,0 +1,47 @@
1
+ <script setup>
2
+ import { ref, defineProps } from 'vue'
3
+ import Popover from './Popover.vue'
4
+
5
+ const props = defineProps({
6
+ table: String
7
+ })
8
+
9
+ /** @type {MdTableOptions} */
10
+ const TABLE_OPTIONS = JSON.parse(props.table.replace(/\\/g, ''))
11
+
12
+ const resolveTableCelContent = (content) => {
13
+ if (/~~.+~~/.test(content)) {
14
+ return `<s>${content}</s>`
15
+ }
16
+ return content
17
+ }
18
+ </script>
19
+
20
+ <template>
21
+ <Popover>
22
+ <table>
23
+ <thead>
24
+ <tr>
25
+ <th v-for="header in TABLE_OPTIONS.headers" :style="header.align ? { textAlign: header.align } : ''"
26
+ :key="header.title">
27
+ {{ header.title }}
28
+ </th>
29
+ </tr>
30
+ </thead>
31
+ <tbody>
32
+ <tr v-for="(row, rowIndex) in TABLE_OPTIONS.rows">
33
+ <td v-for="(cel, celIndex) in row" :key="celIndex"
34
+ :style="TABLE_OPTIONS.headers[rowIndex].align ? { textAlign: TABLE_OPTIONS.headers[rowIndex].align } : ''">
35
+ <span v-html="resolveTableCelContent(cel)" />
36
+ </td>
37
+ </tr>
38
+ </tbody>
39
+ </table>
40
+ </Popover>
41
+ </template>
42
+
43
+ <style lang="stylus" scoped>
44
+ table {
45
+ margin: 0;
46
+ }
47
+ </style>
@@ -0,0 +1,143 @@
1
+ <script setup>
2
+ import { ref } from 'vue'
3
+ import { getNavbarHeight } from '../helper'
4
+
5
+ const props = defineProps({
6
+ table: String
7
+ })
8
+
9
+ const infoHover = ref(false)
10
+ let iconMouseOptions = {}
11
+
12
+ const iconMouseEnter = (e) => {
13
+ const { top, left, bottom, right, height, width } = e.target.getBoundingClientRect()
14
+ iconMouseOptions = {
15
+ top,
16
+ left,
17
+ bottom,
18
+ right,
19
+ height,
20
+ width
21
+ }
22
+ infoHover.value = true
23
+ }
24
+
25
+ const iconMouseLeave = (e) => {
26
+ infoHover.value = false
27
+ }
28
+
29
+ const vPopover = {
30
+ inserted(el, binding, vnode, prevVnode) {
31
+ const ThemeDefaultContent = document.querySelector('.theme-default-content')
32
+ if (ThemeDefaultContent) {
33
+ ThemeDefaultContent.appendChild(el)
34
+ }
35
+ },
36
+ componentUpdated(el, binding, vnode, prevVnode) {
37
+ const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
38
+ const scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
39
+ const screenWidth = document.documentElement.clientWidth
40
+
41
+ const { width, height } = el.getBoundingClientRect()
42
+ const { left: targetLeft, top: targetTop, bottom: targetBottom, right: targetRight, height: targetHeight, width: targetWidth } = iconMouseOptions
43
+ const OFFSET = 10
44
+ const NAVBAR_HEIGHT = getNavbarHeight()
45
+
46
+ // 默认 icon 正中间位置
47
+ const HALF_WIDTH = width / 2
48
+ const HALF_TARGET_WIDTH = targetWidth / 2
49
+ const TOP = height // + OFFSET
50
+ const LEFT = HALF_TARGET_WIDTH - HALF_WIDTH
51
+
52
+ const DEFAULT_TOP = targetTop + scrollTop
53
+ const DEFAULT_LEFT = targetLeft + scrollLeft
54
+
55
+ let currentTop = DEFAULT_TOP - TOP
56
+ let currentLeft = DEFAULT_LEFT + LEFT
57
+
58
+ if (targetTop - NAVBAR_HEIGHT - TOP - OFFSET > 0) {
59
+ // 上方空间够
60
+ currentTop = currentTop - OFFSET
61
+ } else {
62
+ // 上方空间不够
63
+ currentTop = currentTop + (height + targetHeight) + OFFSET
64
+ }
65
+
66
+ const RIGHT_OFFSET = (screenWidth - (targetLeft + HALF_TARGET_WIDTH)) - HALF_WIDTH
67
+ // const LEFT_OFFSET = (screenWidth - targetLeft - HALF_TARGET_WIDTH) - HALF_WIDTH
68
+
69
+ if (RIGHT_OFFSET < 0) {
70
+ // 右侧空间不够
71
+ currentLeft = screenWidth - width
72
+ }
73
+ el.style.top = `${currentTop < 0 ? 0 : currentTop}px`
74
+ el.style.left = `${currentLeft < 0 ? 0 : currentLeft}px`
75
+ }
76
+ }
77
+ </script>
78
+
79
+ <template>
80
+ <div class="popover-container">
81
+ <i class="info" :class="{ 'info-hover': infoHover }" @mouseenter="iconMouseEnter" @mouseleave="iconMouseLeave">
82
+ <svg t="1715917545486" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
83
+ p-id="10306">
84
+ <path
85
+ d="M512 958.016C266.08 958.016 65.984 757.952 65.984 512 65.984 266.08 266.08 65.984 512 65.984c245.952 0 446.016 200.064 446.016 446.016 0 245.952-200.064 446.016-446.016 446.016z m0-828.032c-210.656 0-382.016 171.36-382.016 382.016 0 210.624 171.36 382.016 382.016 382.016 210.624 0 382.016-171.36 382.016-382.016S722.624 129.984 512 129.984z"
86
+ p-id="10307" fill="#2c3e50"></path>
87
+ <path
88
+ d="M464 304a1.5 1.5 0 1 0 96 0 1.5 1.5 0 1 0-96 0zM512 768c-17.664 0-32-14.304-32-32V448c0-17.664 14.336-32 32-32s32 14.336 32 32v288c0 17.696-14.336 32-32 32z"
89
+ p-id="10308" fill="#2c3e50"></path>
90
+ </svg>
91
+ </i>
92
+ <transition name="fade-in">
93
+ <div class="popover-content-container" v-show="infoHover" v-popover>
94
+ <slot></slot>
95
+ </div>
96
+ </transition>
97
+ </div>
98
+
99
+ </template>
100
+
101
+ <style lang="stylus" scoped>
102
+ .popover-container {
103
+ position: relative;
104
+
105
+ .info {
106
+ user-select: none;
107
+ display: inline-block;
108
+ cursor: pointer;
109
+ width: 20px;
110
+ height: 20px;
111
+ padding: 5px;
112
+ border-radius: 5px;
113
+ }
114
+
115
+ .info-hover {
116
+ background-color: #f0f0f0;
117
+ }
118
+ }
119
+
120
+ .popover-content-container {
121
+ position: absolute;
122
+ background-color: #fff;
123
+ z-index: 1;
124
+ border-radius: 5px;
125
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
126
+ transition: opacity .1s cubic-bezier(0.57, 0.85, 0.85, 0.57);
127
+ box-sizing: border-box;
128
+ padding: 10px;
129
+
130
+ &.show {
131
+ opacity: 1;
132
+ }
133
+ }
134
+
135
+ .fade-in-enter-active,.fade-in-leave-active {
136
+ transition: all .1s cubic-bezier(.55,0,.1,1)
137
+ }
138
+
139
+ .fade-in-enter,.fade-in-leave-active {
140
+ opacity: 0
141
+ }
142
+
143
+ </style>
package/index.js CHANGED
@@ -41,6 +41,7 @@ module.exports = (themeConfig, ctx, pluginAPI) => {
41
41
  })
42
42
 
43
43
  pluginAPI.options.extendMarkdown.add('vuepress-theme-uni-app-md-plugins', (md) =>{
44
+ md.core.ruler.disable('emoji', true)
44
45
  md.use(require('markdown-it-attrs'), {
45
46
  leftDelimiter: '#{',
46
47
  rightDelimiter: '}',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vuepress-theme-uniapp-official",
3
- "version": "1.4.15",
3
+ "version": "1.4.16",
4
4
  "description": "uni-app official website theme for vuepress",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -39,7 +39,7 @@
39
39
  "algoliasearch": "^4.13.1",
40
40
  "clipboard": "^2.0.11",
41
41
  "vuepress-plugin-check-md2": "^1.0.5",
42
- "vuepress-plugin-expandable-row": "^1.0.6",
42
+ "vuepress-plugin-expandable-row": "^1.0.7",
43
43
  "vuepress-plugin-juejin-style-copy": "^1.0.4",
44
44
  "vuepress-plugin-mermaidjs": "1.9.1",
45
45
  "vuepress-plugin-named-chunks": "^1.1.4",