slidev-theme-gtlabo 1.0.1 → 1.0.3
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 +59 -99
- package/package.json +1 -1
package/components/Citation.vue
CHANGED
|
@@ -5,21 +5,17 @@
|
|
|
5
5
|
[{{ citationNumber }}]
|
|
6
6
|
</sup>
|
|
7
7
|
|
|
8
|
-
<!--
|
|
8
|
+
<!-- このコンポーネント専用の引用情報表示エリア -->
|
|
9
9
|
<div
|
|
10
|
-
v-if="
|
|
10
|
+
v-if="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>
|
|
@@ -28,7 +24,7 @@
|
|
|
28
24
|
</template>
|
|
29
25
|
|
|
30
26
|
<script setup>
|
|
31
|
-
import { computed, onMounted, onUnmounted, ref
|
|
27
|
+
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
|
32
28
|
import { useSlideContext } from '@slidev/client'
|
|
33
29
|
|
|
34
30
|
const { $slidev } = useSlideContext()
|
|
@@ -41,70 +37,74 @@ const props = defineProps({
|
|
|
41
37
|
}
|
|
42
38
|
})
|
|
43
39
|
|
|
44
|
-
//
|
|
40
|
+
// グローバル引用管理の初期化(引用番号のみ管理)
|
|
45
41
|
if (!window.citationManager) {
|
|
46
42
|
window.citationManager = {
|
|
47
43
|
counter: 1,
|
|
48
|
-
citations: new Map()
|
|
49
|
-
pageActiveCitations: new Map(), // pageNumber -> Set(citationIds)
|
|
50
|
-
components: new Set()
|
|
44
|
+
citations: new Map() // id -> { number, data, formatted }
|
|
51
45
|
}
|
|
52
46
|
}
|
|
53
47
|
|
|
54
|
-
const
|
|
48
|
+
const isMounted = ref(false)
|
|
55
49
|
|
|
56
50
|
// 現在のページ番号を取得
|
|
57
51
|
const currentPage = computed(() => {
|
|
58
|
-
|
|
52
|
+
const page = $slidev.nav.currentPage
|
|
53
|
+
return page
|
|
59
54
|
})
|
|
60
55
|
|
|
61
56
|
// 引用データを取得
|
|
62
57
|
const citationData = computed(() => {
|
|
63
|
-
|
|
58
|
+
const data = citations[props.id] || null
|
|
59
|
+
return data
|
|
64
60
|
})
|
|
65
61
|
|
|
66
62
|
// 引用番号を取得または生成
|
|
67
63
|
const citationNumber = computed(() => {
|
|
68
|
-
if (!citationData.value)
|
|
64
|
+
if (!citationData.value) {
|
|
65
|
+
return '?'
|
|
66
|
+
}
|
|
69
67
|
|
|
70
68
|
if (!window.citationManager.citations.has(props.id)) {
|
|
71
|
-
|
|
69
|
+
const newCitation = {
|
|
72
70
|
number: window.citationManager.counter,
|
|
73
71
|
data: citationData.value,
|
|
74
72
|
formatted: formatCitation(citationData.value)
|
|
75
|
-
}
|
|
73
|
+
}
|
|
74
|
+
window.citationManager.citations.set(props.id, newCitation)
|
|
76
75
|
window.citationManager.counter++
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
|
|
78
|
+
const citation = window.citationManager.citations.get(props.id)
|
|
79
|
+
return citation.number
|
|
80
80
|
})
|
|
81
81
|
|
|
82
|
-
//
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
// フォーマットされた引用テキスト
|
|
83
|
+
const formattedCitation = computed(() => {
|
|
84
|
+
if (!citationData.value) {
|
|
85
|
+
return '引用情報が見つかりません'
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const citation = window.citationManager.citations.get(props.id)
|
|
89
|
+
if (citation && citation.formatted) {
|
|
90
|
+
return citation.formatted
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return formatCitation(citationData.value)
|
|
87
94
|
})
|
|
88
95
|
|
|
89
|
-
//
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const pageSet = window.citationManager.pageActiveCitations.get(currentPage.value)
|
|
93
|
-
|
|
94
|
-
if (!pageSet) return []
|
|
96
|
+
// 引用を表示すべきかどうか
|
|
97
|
+
const shouldShowCitation = computed(() => {
|
|
98
|
+
const shouldShow = isMounted.value && citationData.value !== null
|
|
95
99
|
|
|
96
|
-
return
|
|
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)
|
|
100
|
+
return shouldShow
|
|
103
101
|
})
|
|
104
102
|
|
|
105
103
|
// 引用をフォーマット
|
|
106
104
|
const formatCitation = (data) => {
|
|
107
|
-
if (!data)
|
|
105
|
+
if (!data) {
|
|
106
|
+
return '引用情報が見つかりません'
|
|
107
|
+
}
|
|
108
108
|
|
|
109
109
|
let citation = ''
|
|
110
110
|
|
|
@@ -157,79 +157,39 @@ const formatCitation = (data) => {
|
|
|
157
157
|
citation += `, ISSN: ${data.issn}`
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// 全コンポーネントの再描画をトリガー
|
|
164
|
-
const triggerGlobalUpdate = () => {
|
|
165
|
-
window.citationManager.components.forEach(component => {
|
|
166
|
-
if (component.updateForceUpdate) {
|
|
167
|
-
component.updateForceUpdate()
|
|
168
|
-
}
|
|
169
|
-
})
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// 強制更新関数
|
|
173
|
-
const updateForceUpdate = () => {
|
|
174
|
-
forceUpdate.value++
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// 現在のページに引用を追加
|
|
178
|
-
const addToCurrentPage = () => {
|
|
179
|
-
if (!citationData.value) return
|
|
160
|
+
const formatted = citation || '引用情報が不完全です'
|
|
180
161
|
|
|
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)
|
|
162
|
+
return formatted
|
|
186
163
|
}
|
|
187
164
|
|
|
188
|
-
//
|
|
189
|
-
const
|
|
190
|
-
const page = currentPage.value
|
|
191
|
-
const pageSet = window.citationManager.pageActiveCitations.get(page)
|
|
192
|
-
if (pageSet) {
|
|
193
|
-
pageSet.delete(props.id)
|
|
194
|
-
if (pageSet.size === 0) {
|
|
195
|
-
window.citationManager.pageActiveCitations.delete(page)
|
|
196
|
-
}
|
|
197
|
-
}
|
|
165
|
+
// 全体のグローバル状態をデバッグ出力
|
|
166
|
+
const debugGlobalState = () => {
|
|
198
167
|
}
|
|
199
168
|
|
|
200
|
-
// ページ変更を監視
|
|
201
|
-
watch(currentPage, (newPage, oldPage) => {
|
|
202
|
-
if (oldPage !== undefined) {
|
|
203
|
-
// 前のページから削除
|
|
204
|
-
const oldPageSet = window.citationManager.pageActiveCitations.get(oldPage)
|
|
205
|
-
if (oldPageSet) {
|
|
206
|
-
oldPageSet.delete(props.id)
|
|
207
|
-
if (oldPageSet.size === 0) {
|
|
208
|
-
window.citationManager.pageActiveCitations.delete(oldPage)
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// 新しいページに追加
|
|
214
|
-
addToCurrentPage()
|
|
215
|
-
triggerGlobalUpdate()
|
|
216
|
-
})
|
|
217
|
-
|
|
218
169
|
// コンポーネントのマウント時
|
|
219
170
|
onMounted(() => {
|
|
171
|
+
|
|
172
|
+
isMounted.value = true
|
|
173
|
+
|
|
220
174
|
if (citationData.value) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
175
|
+
// 引用番号を生成(副作用でglobal stateに保存される)
|
|
176
|
+
const _ = citationNumber.value
|
|
177
|
+
debugGlobalState()
|
|
178
|
+
} else {
|
|
224
179
|
}
|
|
225
180
|
})
|
|
226
181
|
|
|
227
182
|
// コンポーネントのアンマウント時
|
|
228
183
|
onUnmounted(() => {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
184
|
+
|
|
185
|
+
isMounted.value = false
|
|
186
|
+
debugGlobalState()
|
|
232
187
|
})
|
|
188
|
+
|
|
189
|
+
// 開発用:グローバル状態確認用の関数をwindowに追加
|
|
190
|
+
if (typeof window !== 'undefined') {
|
|
191
|
+
window.debugCitationState = debugGlobalState
|
|
192
|
+
}
|
|
233
193
|
</script>
|
|
234
194
|
|
|
235
195
|
<style scoped>
|