@hanology/cham-browser 0.4.11 → 0.4.12

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.11",
3
+ "version": "0.4.12",
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,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { computed } from 'vue'
2
3
  import type { AnnotationLayer } from '../types'
3
4
 
4
5
  const props = defineProps<{
@@ -13,7 +14,12 @@ const emit = defineEmits<{
13
14
  'update:annotationsVisible': [visible: boolean]
14
15
  }>()
15
16
 
16
- const hasLayers = () => props.layers.length > 1
17
+ // Only named layers (skip 'default' base annotations are always shown)
18
+ const toggleableLayers = computed(() =>
19
+ props.layers.filter(l => l.id !== 'default')
20
+ )
21
+
22
+ const hasLayers = () => toggleableLayers.value.length > 0
17
23
 
18
24
  function toggleAnnotations() {
19
25
  if (props.annotationsVisible) {
@@ -21,7 +27,7 @@ function toggleAnnotations() {
21
27
  if (hasLayers()) emit('update:activeIds', [])
22
28
  } else {
23
29
  emit('update:annotationsVisible', true)
24
- if (hasLayers()) emit('update:activeIds', props.layers.map(l => l.id))
30
+ if (hasLayers()) emit('update:activeIds', toggleableLayers.value.map(l => l.id))
25
31
  }
26
32
  }
27
33
 
@@ -47,16 +53,15 @@ function toggleLayer(id: string) {
47
53
  @click="toggleAnnotations"
48
54
  :title="annotationsVisible ? '隱藏注釋' : '顯示注釋'"
49
55
  >注</button>
50
- <div v-if="hasLayers() && annotationsVisible" class="ann-layers">
51
- <button
52
- v-for="layer in layers"
53
- :key="layer.id"
54
- class="ann-layer-btn"
55
- :class="{ active: activeIds.includes(layer.id) }"
56
- @click="toggleLayer(layer.id)"
57
- :title="layer.label"
58
- >{{ layer.shortLabel }}</button>
59
- </div>
56
+ <button
57
+ v-for="layer in toggleableLayers"
58
+ :key="layer.id"
59
+ v-show="annotationsVisible"
60
+ class="ann-layer-btn"
61
+ :class="{ active: activeIds.includes(layer.id) }"
62
+ @click="toggleLayer(layer.id)"
63
+ :title="layer.label"
64
+ >{{ layer.shortLabel }}</button>
60
65
  </div>
61
66
  </template>
62
67
 
@@ -65,8 +70,7 @@ function toggleLayer(id: string) {
65
70
  display: flex;
66
71
  flex-direction: column;
67
72
  gap: 6px;
68
- align-items: flex-start;
69
- width: fit-content;
73
+ align-items: center;
70
74
  }
71
75
 
72
76
  .ann-toggle {
@@ -82,9 +86,6 @@ function toggleLayer(id: string) {
82
86
  letter-spacing: 0;
83
87
  cursor: pointer;
84
88
  transition: all 0.2s;
85
- display: flex;
86
- align-items: center;
87
- justify-content: center;
88
89
  }
89
90
 
90
91
  .ann-toggle:hover {
@@ -100,15 +101,9 @@ function toggleLayer(id: string) {
100
101
  color: #fff;
101
102
  }
102
103
 
103
- .ann-layers {
104
- display: flex;
105
- flex-direction: column;
106
- gap: 4px;
107
- align-items: flex-start;
108
- }
109
-
110
104
  .ann-layer-btn {
111
- padding: 5px 10px;
105
+ width: 36px;
106
+ padding: 5px 0;
112
107
  border: 1px solid var(--border);
113
108
  border-radius: 4px;
114
109
  background: none;
@@ -119,6 +114,7 @@ function toggleLayer(id: string) {
119
114
  cursor: pointer;
120
115
  transition: all 0.15s;
121
116
  white-space: nowrap;
117
+ text-align: center;
122
118
  }
123
119
 
124
120
  .ann-layer-btn:hover {
@@ -143,7 +139,7 @@ function toggleLayer(id: string) {
143
139
  font-size: 17px;
144
140
  }
145
141
  .ann-layer-btn {
146
- padding: 6px 12px;
142
+ width: 40px;
147
143
  font-size: 12px;
148
144
  }
149
145
  }