slidev-theme-gtlabo 2.1.1 → 2.1.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.
@@ -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,17 +127,16 @@ 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
133
  if (!page) return
169
134
 
170
- if (!window.citationManager.pageCitations.has(page)) {
171
- window.citationManager.pageCitations.set(page, new Set())
135
+ if (!window.pageCitations.data.has(page)) {
136
+ window.pageCitations.data.set(page, new Set())
172
137
  }
173
138
 
174
- const pageSet = window.citationManager.pageCitations.get(page)
139
+ const pageSet = window.pageCitations.data.get(page)
175
140
  if (!pageSet.has(props.id)) {
176
141
  pageSet.add(props.id)
177
142
  notifyListeners()
@@ -183,18 +148,17 @@ const unregisterCitation = () => {
183
148
  const page = $page
184
149
  if (!page) return
185
150
 
186
- const pageSet = window.citationManager.pageCitations.get(page)
151
+ const pageSet = window.pageCitations.data.get(page)
187
152
  if (pageSet) {
188
153
  pageSet.delete(props.id)
189
154
  if (pageSet.size === 0) {
190
- window.citationManager.pageCitations.delete(page)
155
+ window.pageCitations.data.delete(page)
191
156
  }
192
157
  notifyListeners()
193
158
  }
194
159
  }
195
160
 
196
161
  onMounted(() => {
197
- initializeCitations()
198
162
  registerCitation()
199
163
  })
200
164
 
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.2",
4
4
  "description": "A Slidev theme for laboratory presentations with customizable components",
5
5
  "author": "mksmkss",
6
6
  "license": "MIT",