@hanology/cham-browser 0.4.65 → 0.4.66

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.65",
3
+ "version": "0.4.66",
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",
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts">
2
+ import { computed } from 'vue'
2
3
  import type { Annotation, VerseLine, PieceSource } from '../types'
3
- import { buildVerseAnnotations, renderAnnotatedText, resolveHoveredAnnotations, countVerseSpans } from '../composables/useAnnotationRenderer'
4
+ import { buildVerseAnnotations, renderAnnotatedText, resolveHoveredAnnotations } from '../composables/useAnnotationRenderer'
4
5
 
5
6
  const props = defineProps<{
6
7
  num: number
@@ -17,12 +18,24 @@ const emit = defineEmits<{
17
18
  annotationTap: [event: MouseEvent, annotations: Annotation[]]
18
19
  }>()
19
20
 
21
+ const allVerseSpans = computed(() =>
22
+ props.verses.map((_, i) => buildVerseAnnotations(props.annotations, i))
23
+ )
24
+
25
+ const verseOffsets = computed(() => {
26
+ const offsets: number[] = []
27
+ let acc = 0
28
+ for (const spans of allVerseSpans.value) {
29
+ offsets.push(acc)
30
+ acc += spans.length
31
+ }
32
+ return offsets
33
+ })
34
+
20
35
  function verseHtml(index: number): string {
21
36
  const useRuby = props.vertical
22
- let offset = 0
23
- for (let i = 0; i < index; i++) offset += countVerseSpans(props.annotations, i)
24
- const spans = buildVerseAnnotations(props.annotations, index)
25
- return renderAnnotatedText(props.verses[index].text, spans, useRuby, offset)
37
+ const spans = allVerseSpans.value[index]
38
+ return renderAnnotatedText(props.verses[index].text, spans, useRuby, verseOffsets.value[index])
26
39
  }
27
40
 
28
41
  function onHover(event: MouseEvent) {
@@ -68,12 +68,12 @@ function close() { open.value = false }
68
68
  <div class="rt-label">{{ t('settings.theme') }}</div>
69
69
  <div class="rt-options">
70
70
  <button
71
- v-for="t in THEMES"
72
- :key="t"
71
+ v-for="th in THEMES"
72
+ :key="th"
73
73
  class="rt-opt rt-theme"
74
- :class="{ active: theme === t, ['theme-' + t]: true }"
75
- @click="setTheme(t)"
76
- >{{ t('theme.' + t) }}</button>
74
+ :class="{ active: theme === th, ['theme-' + th]: true }"
75
+ @click="setTheme(th)"
76
+ >{{ t('theme.' + th) }}</button>
77
77
  </div>
78
78
  </div>
79
79
  <div class="rt-group">
@@ -78,12 +78,12 @@ function toggleSettings() { settingsOpen.value = !settingsOpen.value }
78
78
  <div class="ss-label">{{ t('settings.theme') }}</div>
79
79
  <div class="ss-options">
80
80
  <button
81
- v-for="t in THEMES"
82
- :key="t"
81
+ v-for="th in THEMES"
82
+ :key="th"
83
83
  class="ss-opt"
84
- :class="{ active: theme === t }"
85
- @click="setTheme(t)"
86
- >{{ t('theme.' + t) }}</button>
84
+ :class="{ active: theme === th }"
85
+ @click="setTheme(th)"
86
+ >{{ t('theme.' + th) }}</button>
87
87
  </div>
88
88
  </div>
89
89
  <div class="ss-group">
@@ -321,7 +321,7 @@ button:focus-visible {
321
321
  /* ===== DARK MODE VERTICAL WARMTH ===== */
322
322
  [data-theme="dark"] .v-scroll,
323
323
  [data-theme="oled"] .v-scroll {
324
- box-shadow: 0 0 40px rgba(194, 58, 43, 0.03), 0 4px 16px rgba(0, 0, 0, 0.2);
324
+ box-shadow: 0 0 40px color-mix(in srgb, var(--vermillion) 3%, transparent), 0 4px 16px rgba(var(--shadow-rgb), 0.2);
325
325
  }
326
326
 
327
327
  [data-theme="dark"] .sb-vertical,
@@ -151,7 +151,7 @@ function goHome() { router.push('/') }
151
151
  flex-direction: row-reverse;
152
152
  overflow-x: auto;
153
153
  overflow-y: hidden;
154
- margin-right: var(--nav-width, 56px);
154
+ margin-right: calc(var(--nav-width, 56px) + env(safe-area-inset-right, 0px));
155
155
  padding: 0 32px;
156
156
  background: var(--paper);
157
157
  scrollbar-width: thin;
@@ -349,6 +349,6 @@ function goHome() { router.push('/') }
349
349
  .h-hero { flex-direction: column; text-align: center; padding: 24px; }
350
350
  .h-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
351
351
  .h-content { padding: 30px 20px; }
352
- .v-page { padding: 0 16px; }
352
+ .v-page { padding: 0 16px; margin-right: calc(var(--nav-width, 44px) + env(safe-area-inset-right, 0px)); }
353
353
  }
354
354
  </style>