slidev-theme-gtlabo 2.1.1 → 2.1.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.
@@ -8,7 +8,7 @@
8
8
  </template>
9
9
 
10
10
  <script setup>
11
- import { computed, onMounted, onUnmounted, inject } from 'vue'
11
+ import { computed, inject, onMounted, onUnmounted } from 'vue'
12
12
  import { useSlideContext } from '@slidev/client'
13
13
 
14
14
  const { $slidev, $page } = useSlideContext()
@@ -32,65 +32,37 @@ const props = defineProps({
32
32
  }
33
33
  })
34
34
 
35
- // グローバル引用管理の初期化
36
- if (!window.citationManager) {
37
- window.citationManager = {
38
- citations: new Map(), // id -> { number, data, formatted }
39
- citationKeys: [], // frontmatterのキーの順番
40
- pageCitations: new Map(), // pageNumber -> Set of citation ids
41
- initialized: false,
42
- listeners: new Set() // 更新通知用リスナー
35
+ // ページごとの引用管理(slide-bottom.vue用)
36
+ if (!window.pageCitations) {
37
+ window.pageCitations = {
38
+ data: new Map(), // pageNumber -> Set of citation ids
39
+ listeners: new Set()
43
40
  }
44
41
  }
45
42
 
46
- // 更新を通知する関数
47
43
  const notifyListeners = () => {
48
- window.citationManager.listeners.forEach(listener => {
49
- try {
50
- listener()
51
- } catch (e) {
52
- // リスナーエラーを無視
53
- }
44
+ window.pageCitations.listeners.forEach(listener => {
45
+ try { listener() } catch (e) { /* ignore */ }
54
46
  })
55
47
  }
56
48
 
57
- // frontmatterの順番でcitation番号を事前に割り当て
58
- const initializeCitations = () => {
59
- if (!window.citationManager.initialized) {
60
- window.citationManager.citationKeys = Object.keys(citations)
61
-
62
- window.citationManager.citationKeys.forEach((key, index) => {
63
- if (!window.citationManager.citations.has(key)) {
64
- const data = citations[key]
65
- const newCitation = {
66
- number: index + 1,
67
- data: data,
68
- formatted: formatCitation(data)
69
- }
70
- window.citationManager.citations.set(key, newCitation)
71
- }
72
- })
73
-
74
- window.citationManager.initialized = true
75
- }
76
- }
77
-
78
49
  // 引用データを取得
79
50
  const citationData = computed(() => {
80
- return citations[props.id] || null
51
+ return citations.value[props.id] || null
81
52
  })
82
53
 
83
- // 引用番号を取得
54
+ // 引用番号を取得(シンプル版:毎回計算)
84
55
  const citationNumber = computed(() => {
85
- if (!citationData.value) {
56
+ const citationsData = citations.value
57
+ if (!citationsData || !citationData.value) {
86
58
  return '?'
87
59
  }
88
60
 
89
- initializeCitations()
61
+ const keys = Object.keys(citationsData)
62
+ const index = keys.indexOf(props.id)
90
63
 
91
- const citation = window.citationManager.citations.get(props.id)
92
- if (citation) {
93
- return citation.number
64
+ if (index >= 0) {
65
+ return index + 1
94
66
  }
95
67
 
96
68
  return '?'
@@ -101,12 +73,6 @@ const formattedCitation = computed(() => {
101
73
  if (!citationData.value) {
102
74
  return '引用情報が見つかりません'
103
75
  }
104
-
105
- const citation = window.citationManager.citations.get(props.id)
106
- if (citation && citation.formatted) {
107
- return citation.formatted
108
- }
109
-
110
76
  return formatCitation(citationData.value)
111
77
  })
112
78
 
@@ -161,21 +127,29 @@ const formatCitation = (data) => {
161
127
  return citation || '引用情報が不完全です'
162
128
  }
163
129
 
164
- // 現在のページに引用を登録
130
+ // 現在のページに引用を登録(slide-bottom.vue用)
165
131
  const registerCitation = () => {
166
- // $page はこのコンポーネントが配置されているスライドの番号(静的)
167
132
  const page = $page
168
- if (!page) return
133
+ console.log('=== Citation registerCitation ===')
134
+ console.log('$page:', page)
135
+ console.log('props.id:', props.id)
136
+
137
+ if (!page) {
138
+ console.log('→ page が null')
139
+ return
140
+ }
169
141
 
170
- if (!window.citationManager.pageCitations.has(page)) {
171
- window.citationManager.pageCitations.set(page, new Set())
142
+ if (!window.pageCitations.data.has(page)) {
143
+ window.pageCitations.data.set(page, new Set())
172
144
  }
173
145
 
174
- const pageSet = window.citationManager.pageCitations.get(page)
146
+ const pageSet = window.pageCitations.data.get(page)
175
147
  if (!pageSet.has(props.id)) {
176
148
  pageSet.add(props.id)
177
149
  notifyListeners()
178
150
  }
151
+ console.log('→ 登録完了')
152
+ console.log('window.pageCitations.data:', [...window.pageCitations.data.entries()])
179
153
  }
180
154
 
181
155
  // 現在のページから引用を解除
@@ -183,18 +157,17 @@ const unregisterCitation = () => {
183
157
  const page = $page
184
158
  if (!page) return
185
159
 
186
- const pageSet = window.citationManager.pageCitations.get(page)
160
+ const pageSet = window.pageCitations.data.get(page)
187
161
  if (pageSet) {
188
162
  pageSet.delete(props.id)
189
163
  if (pageSet.size === 0) {
190
- window.citationManager.pageCitations.delete(page)
164
+ window.pageCitations.data.delete(page)
191
165
  }
192
166
  notifyListeners()
193
167
  }
194
168
  }
195
169
 
196
170
  onMounted(() => {
197
- initializeCitations()
198
171
  registerCitation()
199
172
  })
200
173
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slidev-theme-gtlabo",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "A Slidev theme for laboratory presentations with customizable components",
5
5
  "author": "mksmkss",
6
6
  "license": "MIT",