@hanology/cham-browser 0.4.72 → 0.4.74

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.72",
3
+ "version": "0.4.74",
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",
@@ -2,6 +2,8 @@
2
2
  import { computed } from 'vue'
3
3
  import type { Annotation, VerseLine, PieceSource } from '../types'
4
4
  import { buildVerseAnnotations, renderAnnotatedText, resolveHoveredAnnotations } from '../composables/useAnnotationRenderer'
5
+ import { parseAnnotationBlock } from '../utils/annotationParser'
6
+ import PronunciationGroup from './PronunciationGroup.vue'
5
7
 
6
8
  const props = defineProps<{
7
9
  num: number
@@ -54,12 +56,17 @@ const sourceLabel = (() => {
54
56
  const r = props.source?.range as Record<string, string> | undefined
55
57
  return r?.chapter || ''
56
58
  })()
59
+
60
+ const annotationEntries = computed(() =>
61
+ props.annotationText ? parseAnnotationBlock(props.annotationText) : []
62
+ )
57
63
  </script>
58
64
 
59
65
  <template>
60
66
  <div class="part-block" :class="{ 'part-block--vertical': vertical }">
61
- <div v-if="sourceLabel" class="part-source">
62
- {{ sourceLabel }}
67
+ <div v-if="sourceLabel" class="part-header">
68
+ <span class="part-header-num">{{ num }}</span>
69
+ <h3>{{ sourceLabel }}</h3>
63
70
  </div>
64
71
  <div class="part-text" @mouseover="onHover" @mouseleave="onLeave" @click="onTap">
65
72
  <span
@@ -69,7 +76,22 @@ const sourceLabel = (() => {
69
76
  v-html="verseHtml(i)"
70
77
  />
71
78
  </div>
72
- <div v-if="annotationText" class="part-annotations">
79
+ <div v-if="annotationText && annotationEntries.length > 0" class="part-annotations">
80
+ <div v-for="entry in annotationEntries" :key="entry.num" class="part-ann-entry">
81
+ <div class="part-ann-head">
82
+ <span class="part-ann-num">{{ entry.numDisplay }}</span>
83
+ <span class="part-ann-term">{{ entry.term }}</span>
84
+ <PronunciationGroup
85
+ v-for="seg in entry.pronSegments"
86
+ :key="seg.lang"
87
+ :segment="seg"
88
+ class="part-ann-pron"
89
+ />
90
+ </div>
91
+ <div v-if="entry.definition" class="part-ann-def">{{ entry.definition }}</div>
92
+ </div>
93
+ </div>
94
+ <div v-else-if="annotationText" class="part-annotations">
73
95
  <div v-for="line in annotationText.split('\n')" :key="line" class="part-ann-line">{{ line }}</div>
74
96
  </div>
75
97
  </div>
@@ -93,17 +115,22 @@ const sourceLabel = (() => {
93
115
  border-left: 1px dashed var(--border-light);
94
116
  }
95
117
 
96
- .part-source {
97
- font-family: var(--sans);
98
- font-size: 12px;
99
- letter-spacing: 1px;
100
- color: var(--ink-faint);
101
- background: var(--surface);
102
- display: inline-block;
103
- padding: 3px 10px;
104
- border-radius: 3px;
105
- margin-bottom: 12px;
106
- border: 1px solid var(--border-light);
118
+ .part-header {
119
+ display: flex; align-items: center; gap: 12px;
120
+ margin-bottom: 20px; padding-bottom: 12px;
121
+ border-bottom: 1px solid var(--border);
122
+ }
123
+
124
+ .part-header-num {
125
+ display: inline-flex; align-items: center; justify-content: center;
126
+ width: 28px; height: 28px; border-radius: 50%;
127
+ background: var(--vermillion); color: var(--paper);
128
+ font-family: var(--sans); font-size: 13px; font-weight: 700;
129
+ flex-shrink: 0;
130
+ }
131
+
132
+ .part-header h3 {
133
+ font-size: 18px; font-weight: 700; letter-spacing: 3px; color: var(--ink);
107
134
  }
108
135
 
109
136
  .part-text {
@@ -114,6 +141,59 @@ const sourceLabel = (() => {
114
141
  margin-top: 16px;
115
142
  padding-top: 12px;
116
143
  border-top: 1px dashed var(--border-light);
144
+ text-align: start;
145
+ }
146
+
147
+ .part-ann-entry {
148
+ padding: 12px 0;
149
+ border-bottom: 1px solid var(--border-light);
150
+ }
151
+ .part-ann-entry:last-child {
152
+ border-bottom: none;
153
+ padding-bottom: 0;
154
+ }
155
+
156
+ .part-ann-head {
157
+ display: flex;
158
+ flex-wrap: wrap;
159
+ align-items: baseline;
160
+ gap: 6px 10px;
161
+ margin-bottom: 4px;
162
+ }
163
+
164
+ .part-ann-num {
165
+ display: inline-flex;
166
+ align-items: center;
167
+ justify-content: center;
168
+ width: 22px;
169
+ height: 22px;
170
+ border-radius: 4px;
171
+ background: var(--vermillion);
172
+ color: var(--paper);
173
+ font-family: var(--sans);
174
+ font-size: 12px;
175
+ font-weight: 700;
176
+ flex-shrink: 0;
177
+ }
178
+
179
+ .part-ann-term {
180
+ font-weight: 700;
181
+ font-size: 1.05em;
182
+ color: var(--ink);
183
+ padding: 2px 8px;
184
+ background: var(--surface-warm);
185
+ border-radius: 3px;
186
+ }
187
+
188
+ .part-ann-pron {
189
+ margin-left: 2px;
190
+ }
191
+
192
+ .part-ann-def {
193
+ color: var(--ink-mid);
194
+ line-height: 2;
195
+ white-space: pre-line;
196
+ padding-left: 32px;
117
197
  }
118
198
 
119
199
  .part-ann-line {
@@ -175,9 +255,28 @@ const sourceLabel = (() => {
175
255
  font-size: 0.38em;
176
256
  }
177
257
 
178
- .part-block--vertical .part-source {
258
+ .part-block--vertical .part-header {
259
+ flex-direction: column;
260
+ align-items: flex-start;
179
261
  margin-bottom: 0;
180
- margin-left: 8px;
262
+ margin-left: 20px;
263
+ padding-bottom: 0;
264
+ border-bottom: none;
265
+ padding-left: 16px;
266
+ border-left: 2px solid var(--vermillion);
267
+ }
268
+
269
+ .part-block--vertical .part-header-num {
270
+ width: auto; height: auto;
271
+ border-radius: 0;
272
+ background: none;
273
+ color: var(--vermillion);
274
+ font-size: 16px;
275
+ }
276
+
277
+ .part-block--vertical .part-header h3 {
278
+ font-size: 20px;
279
+ letter-spacing: 6px;
181
280
  }
182
281
 
183
282
  .part-block--vertical .part-annotations {
@@ -188,4 +287,36 @@ const sourceLabel = (() => {
188
287
  border-top: none;
189
288
  border-left: 1px dashed var(--border-light);
190
289
  }
290
+
291
+ .part-block--vertical .part-ann-entry {
292
+ margin-bottom: 0;
293
+ margin-left: 16px;
294
+ padding: 0;
295
+ border-bottom: none;
296
+ }
297
+
298
+ .part-block--vertical .part-ann-head {
299
+ align-items: flex-start;
300
+ gap: 4px;
301
+ }
302
+
303
+ .part-block--vertical .part-ann-num {
304
+ width: auto;
305
+ height: auto;
306
+ border-radius: 0;
307
+ background: none;
308
+ color: var(--vermillion);
309
+ font-size: inherit;
310
+ }
311
+
312
+ .part-block--vertical .part-ann-term {
313
+ background: none;
314
+ padding: 0;
315
+ font-size: inherit;
316
+ }
317
+
318
+ .part-block--vertical .part-ann-def {
319
+ padding-left: 0;
320
+ margin-left: 12px;
321
+ }
191
322
  </style>