slidev-theme-gtlabo 1.0.1 → 1.0.2
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/components/Citation.vue +72 -68
- package/package.json +1 -1
package/components/Citation.vue
CHANGED
|
@@ -5,21 +5,17 @@
|
|
|
5
5
|
[{{ citationNumber }}]
|
|
6
6
|
</sup>
|
|
7
7
|
|
|
8
|
-
<!--
|
|
8
|
+
<!-- 指定されたidの引用情報のみ表示(画面下部に表示) -->
|
|
9
9
|
<div
|
|
10
|
-
v-if="
|
|
10
|
+
v-if="citationData && shouldShowCitation"
|
|
11
11
|
class="fixed bottom-0 left-0 right-0 bg-white border-t-2 border-gray-300 shadow-lg z-40 max-h-32 overflow-y-auto"
|
|
12
12
|
style="pointer-events: none;"
|
|
13
13
|
>
|
|
14
14
|
<div class="max-w-7xl mx-auto px-4 py-2">
|
|
15
15
|
<div class="space-y-1">
|
|
16
|
-
<div
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class="text-xs text-gray-800"
|
|
20
|
-
>
|
|
21
|
-
<span class="font-semibold">[{{ citation.number }}]</span>
|
|
22
|
-
{{ citation.formatted }}
|
|
16
|
+
<div class="text-xs text-gray-800">
|
|
17
|
+
<span class="font-semibold">[{{ citationNumber }}]</span>
|
|
18
|
+
{{ formattedCitation }}
|
|
23
19
|
</div>
|
|
24
20
|
</div>
|
|
25
21
|
</div>
|
|
@@ -46,12 +42,13 @@ if (!window.citationManager) {
|
|
|
46
42
|
window.citationManager = {
|
|
47
43
|
counter: 1,
|
|
48
44
|
citations: new Map(), // id -> { number, data, formatted }
|
|
49
|
-
|
|
45
|
+
activeCitation: null, // 現在表示中の引用id
|
|
50
46
|
components: new Set()
|
|
51
47
|
}
|
|
52
48
|
}
|
|
53
49
|
|
|
54
50
|
const forceUpdate = ref(0)
|
|
51
|
+
const isVisible = ref(false)
|
|
55
52
|
|
|
56
53
|
// 現在のページ番号を取得
|
|
57
54
|
const currentPage = computed(() => {
|
|
@@ -79,27 +76,21 @@ const citationNumber = computed(() => {
|
|
|
79
76
|
return window.citationManager.citations.get(props.id).number
|
|
80
77
|
})
|
|
81
78
|
|
|
82
|
-
//
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
// フォーマットされた引用情報
|
|
80
|
+
const formattedCitation = computed(() => {
|
|
81
|
+
if (!citationData.value) return '引用情報が見つかりません'
|
|
82
|
+
|
|
83
|
+
if (window.citationManager.citations.has(props.id)) {
|
|
84
|
+
return window.citationManager.citations.get(props.id).formatted
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return formatCitation(citationData.value)
|
|
87
88
|
})
|
|
88
89
|
|
|
89
|
-
//
|
|
90
|
-
const
|
|
90
|
+
// この引用を表示すべきかどうか
|
|
91
|
+
const shouldShowCitation = computed(() => {
|
|
91
92
|
forceUpdate.value // 依存関係を強制的に更新
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (!pageSet) return []
|
|
95
|
-
|
|
96
|
-
return Array.from(pageSet)
|
|
97
|
-
.map(id => ({
|
|
98
|
-
id,
|
|
99
|
-
...window.citationManager.citations.get(id)
|
|
100
|
-
}))
|
|
101
|
-
.filter(citation => citation.data) // dataが存在するもののみ
|
|
102
|
-
.sort((a, b) => a.number - b.number)
|
|
93
|
+
return window.citationManager.activeCitation === props.id && isVisible.value
|
|
103
94
|
})
|
|
104
95
|
|
|
105
96
|
// 引用をフォーマット
|
|
@@ -174,61 +165,62 @@ const updateForceUpdate = () => {
|
|
|
174
165
|
forceUpdate.value++
|
|
175
166
|
}
|
|
176
167
|
|
|
177
|
-
//
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (!window.citationManager.pageActiveCitations.has(page)) {
|
|
183
|
-
window.citationManager.pageActiveCitations.set(page, new Set())
|
|
184
|
-
}
|
|
185
|
-
window.citationManager.pageActiveCitations.get(page).add(props.id)
|
|
168
|
+
// この引用をアクティブにする
|
|
169
|
+
const setActiveCitation = () => {
|
|
170
|
+
window.citationManager.activeCitation = props.id
|
|
171
|
+
isVisible.value = true
|
|
172
|
+
triggerGlobalUpdate()
|
|
186
173
|
}
|
|
187
174
|
|
|
188
|
-
//
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (pageSet.size === 0) {
|
|
195
|
-
window.citationManager.pageActiveCitations.delete(page)
|
|
196
|
-
}
|
|
175
|
+
// この引用を非アクティブにする
|
|
176
|
+
const clearActiveCitation = () => {
|
|
177
|
+
if (window.citationManager.activeCitation === props.id) {
|
|
178
|
+
window.citationManager.activeCitation = null
|
|
179
|
+
isVisible.value = false
|
|
180
|
+
triggerGlobalUpdate()
|
|
197
181
|
}
|
|
198
182
|
}
|
|
199
183
|
|
|
200
|
-
//
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
triggerGlobalUpdate()
|
|
184
|
+
// マウスイベントハンドラー
|
|
185
|
+
const handleMouseEnter = () => {
|
|
186
|
+
setActiveCitation()
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const handleMouseLeave = () => {
|
|
190
|
+
// 少し遅延を入れて、マウスが引用情報エリアに移動する時間を確保
|
|
191
|
+
setTimeout(() => {
|
|
192
|
+
clearActiveCitation()
|
|
193
|
+
}, 100)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ページ変更を監視(ページが変わったら引用を非表示)
|
|
197
|
+
watch(currentPage, () => {
|
|
198
|
+
clearActiveCitation()
|
|
216
199
|
})
|
|
217
200
|
|
|
218
201
|
// コンポーネントのマウント時
|
|
219
202
|
onMounted(() => {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
203
|
+
window.citationManager.components.add({ updateForceUpdate })
|
|
204
|
+
|
|
205
|
+
// インライン引用番号にマウスイベントを追加
|
|
206
|
+
const supElement = document.querySelector(`sup:has([data-citation-id="${props.id}"])`)
|
|
207
|
+
if (supElement) {
|
|
208
|
+
supElement.addEventListener('mouseenter', handleMouseEnter)
|
|
209
|
+
supElement.addEventListener('mouseleave', handleMouseLeave)
|
|
224
210
|
}
|
|
225
211
|
})
|
|
226
212
|
|
|
227
213
|
// コンポーネントのアンマウント時
|
|
228
214
|
onUnmounted(() => {
|
|
229
|
-
removeFromCurrentPage()
|
|
230
215
|
window.citationManager.components.delete({ updateForceUpdate })
|
|
231
|
-
|
|
216
|
+
clearActiveCitation()
|
|
217
|
+
|
|
218
|
+
// イベントリスナーを削除
|
|
219
|
+
const supElement = document.querySelector(`sup:has([data-citation-id="${props.id}"])`)
|
|
220
|
+
if (supElement) {
|
|
221
|
+
supElement.removeEventListener('mouseenter', handleMouseEnter)
|
|
222
|
+
supElement.removeEventListener('mouseleave', handleMouseLeave)
|
|
223
|
+
}
|
|
232
224
|
})
|
|
233
225
|
</script>
|
|
234
226
|
|
|
@@ -250,4 +242,16 @@ onUnmounted(() => {
|
|
|
250
242
|
::-webkit-scrollbar-thumb:hover {
|
|
251
243
|
background: #a8a8a8;
|
|
252
244
|
}
|
|
245
|
+
|
|
246
|
+
/* インライン引用番号のホバー効果 */
|
|
247
|
+
sup {
|
|
248
|
+
cursor: pointer;
|
|
249
|
+
transition: all 0.2s ease;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
sup:hover {
|
|
253
|
+
background-color: rgba(37, 99, 235, 0.1);
|
|
254
|
+
border-radius: 2px;
|
|
255
|
+
padding: 1px 2px;
|
|
256
|
+
}
|
|
253
257
|
</style>
|