@hanology/cham-browser 0.4.82 → 0.4.83

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanology/cham-browser",
3
- "version": "0.4.82",
3
+ "version": "0.4.83",
4
4
  "description": "CHAM — browser-compatible parser, serializer, and site generator for Classical Han Annotated Markdown",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -110,22 +110,24 @@ onBeforeUnmount(() => {
110
110
  @mouseenter="emit('tooltipEnter')"
111
111
  @mouseleave="emit('tooltipLeave')"
112
112
  >
113
- <div v-if="headword" class="ann-card-head" :class="dominantKind()">
114
- <div class="ann-headword">{{ headword }}</div>
115
- <div class="ann-badge-count" v-if="annotations.length > 1">{{ t('annotation.noteCount', { count: toChineseNumber(annotations.length) }) }}</div>
116
- </div>
117
- <button class="ann-card-close" @click="dismiss" :aria-label="t('action.close')">
118
- <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"><path d="M18 6L6 18M6 6l12 12"/></svg>
119
- </button>
120
- <div class="ann-card-scroll">
121
- <div v-for="ann in annotations" :key="ann.id" class="ann-entry">
122
- <div class="ann-entry-header">
123
- <span class="ann-kind" :class="ann.kind">{{ kindLabel(ann) }}</span>
124
- </div>
125
- <div class="ann-entry-body">
126
- <span v-if="layerLabel(ann)" class="ann-layer">{{ layerLabel(ann) }}</span>
127
- <div v-if="getSegment(ann)" class="ann-pron-h"><PronunciationGroup :segment="getSegment(ann)!" /></div>
128
- <span v-if="ann.text && ann.kind !== 'pronunciation'" class="ann-text">{{ ann.text }}</span>
113
+ <div class="ann-card-inner">
114
+ <div v-if="headword" class="ann-card-head" :class="dominantKind()">
115
+ <div class="ann-headword">{{ headword }}</div>
116
+ <div class="ann-badge-count" v-if="annotations.length > 1">{{ t('annotation.noteCount', { count: toChineseNumber(annotations.length) }) }}</div>
117
+ </div>
118
+ <button class="ann-card-close" @click="dismiss" :aria-label="t('action.close')">
119
+ <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"><path d="M18 6L6 18M6 6l12 12"/></svg>
120
+ </button>
121
+ <div class="ann-card-scroll">
122
+ <div v-for="ann in annotations" :key="ann.id" class="ann-entry">
123
+ <div class="ann-entry-header">
124
+ <span class="ann-kind" :class="ann.kind">{{ kindLabel(ann) }}</span>
125
+ </div>
126
+ <div class="ann-entry-body">
127
+ <span v-if="layerLabel(ann)" class="ann-layer">{{ layerLabel(ann) }}</span>
128
+ <div v-if="getSegment(ann)" class="ann-pron-h"><PronunciationGroup :segment="getSegment(ann)!" /></div>
129
+ <span v-if="ann.text && ann.kind !== 'pronunciation'" class="ann-text">{{ ann.text }}</span>
130
+ </div>
129
131
  </div>
130
132
  </div>
131
133
  </div>
@@ -139,12 +139,17 @@ export function useAnnotationTooltip() {
139
139
  const el = (event.target as HTMLElement).closest('.ann-target') as HTMLElement | null
140
140
  const rect = (el ?? event.target as HTMLElement).getBoundingClientRect()
141
141
 
142
- // Extract headword text (strip the annotation number)
142
+ // Extract headword text from all .ann-target elements sharing the same data-ann-ids
143
143
  if (el) {
144
- const clone = el.cloneNode(true) as HTMLElement
145
- const nums = clone.querySelectorAll('.ann-num, sup')
146
- nums.forEach(n => n.remove())
147
- headword.value = clone.textContent?.trim() || ''
144
+ const ids = el.getAttribute('data-ann-ids') || ''
145
+ const container = el.closest('.v-scroll-line, .v-scroll-body, .sb-text, .part-block, [class*="section"]') || el.parentElement
146
+ const allTargets = container ? container.querySelectorAll(`.ann-target[data-ann-ids="${ids}"]`) : [el]
147
+ const text = [...allTargets].map(t => {
148
+ const clone = t.cloneNode(true) as HTMLElement
149
+ clone.querySelectorAll('.ann-num, sup, rt, rp').forEach(n => n.remove())
150
+ return clone.textContent?.trim() || ''
151
+ }).join('')
152
+ headword.value = text || el.textContent?.trim() || ''
148
153
  } else {
149
154
  headword.value = ''
150
155
  }