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.
@@ -5,21 +5,17 @@
5
5
  [{{ citationNumber }}]
6
6
  </sup>
7
7
 
8
- <!-- 引用情報表示エリア(画面下部に常時表示) -->
8
+ <!-- 指定されたidの引用情報のみ表示(画面下部に表示) -->
9
9
  <div
10
- v-if="hasCurrentPageCitations"
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
- v-for="citation in sortedCurrentPageCitations"
18
- :key="citation.id"
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
- pageActiveCitations: new Map(), // pageNumber -> Set(citationIds)
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 hasCurrentPageCitations = computed(() => {
84
- forceUpdate.value // 依存関係を強制的に更新
85
- const pageSet = window.citationManager.pageActiveCitations.get(currentPage.value)
86
- return pageSet && pageSet.size > 0
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 sortedCurrentPageCitations = computed(() => {
90
+ // この引用を表示すべきかどうか
91
+ const shouldShowCitation = computed(() => {
91
92
  forceUpdate.value // 依存関係を強制的に更新
92
- const pageSet = window.citationManager.pageActiveCitations.get(currentPage.value)
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 addToCurrentPage = () => {
179
- if (!citationData.value) return
180
-
181
- const page = currentPage.value
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 removeFromCurrentPage = () => {
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
- }
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
- 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()
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
- if (citationData.value) {
221
- addToCurrentPage()
222
- window.citationManager.components.add({ updateForceUpdate })
223
- triggerGlobalUpdate()
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
- triggerGlobalUpdate()
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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slidev-theme-gtlabo",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A Slidev theme for laboratory presentations with customizable components",
5
5
  "author": "mksmkss",
6
6
  "license": "MIT",