ebt-vue3 2.6.11 → 2.8.1

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": "ebt-vue3",
3
- "version": "2.6.11",
3
+ "version": "2.8.1",
4
4
  "description": "Vue3 Library for SuttaCentral Voice EBT-Sites",
5
5
  "author": "Karl Lew",
6
6
  "scripts": {
@@ -30,14 +30,14 @@
30
30
  "module": "index.mjs",
31
31
  "dependencies": {
32
32
  "@mdi/font": "7.0.96",
33
- "@sc-voice/ms-dpd": "^2.41.0",
33
+ "@sc-voice/ms-dpd": "^2.43.0",
34
34
  "compression": "^1.7.4",
35
35
  "idb-keyval": "^6.2.0",
36
36
  "log-instance": "^1.6.0",
37
37
  "merkle-json": "^2.7.0",
38
38
  "pinia": "^2.0.16",
39
39
  "roboto-fontface": "*",
40
- "scv-esm": "^1.110.386",
40
+ "scv-esm": "^1.110.388",
41
41
  "serve-favicon": "^2.5.0",
42
42
  "uuid": "^9.0.0",
43
43
  "vite-plugin-vuetify": "^2.0.3",
package/src/App.vue CHANGED
@@ -58,8 +58,7 @@
58
58
  </div>
59
59
  </div><!-- ebt-title -->
60
60
  <div :class="startupClass('sc-voice')">
61
- SUTTACENTRAL
62
- VOICE/{{docLang}}
61
+ sc-voice.net/{{docLang.toLowerCase()}}
63
62
  </div>
64
63
  </v-app-bar-title>
65
64
  <div :class="startupClass('app-btns')">
@@ -87,8 +86,8 @@
87
86
  </v-btn>
88
87
  </div>
89
88
  </template>
90
- <template v-if="!collapsed" v-slot:extension >
91
- <ebt-chips />
89
+ <template v-slot:extension >
90
+ <ebt-chips v-if="!collapsed" />
92
91
  </template> <!-- !collapsed -->
93
92
  <template v-if="settings.loaded">
94
93
  <audio id="audio-click"
@@ -299,6 +299,10 @@ code {
299
299
  color: rgba(var(--v-theme-debug), 1);
300
300
  width: 100%;
301
301
  }
302
+ .card-title {
303
+ overflow: hidden;
304
+ text-overflow: ellipsis;
305
+ }
302
306
  .card-title-anchor {
303
307
  position: relative;
304
308
  }
@@ -359,35 +363,54 @@ code {
359
363
  outline: 1pt solid green;
360
364
  }
361
365
 
362
- .pali-meaning {
363
- max-width: 30em;
366
+ .pali-panel-title {
367
+ max-height: 48px;
368
+ background: linear-gradient(160deg,
369
+ rgb(var(--v-theme-currentbg)),
370
+ rgb(var(--v-theme-toolbar))
371
+ ) !important;
372
+ }
373
+ .pali-panel-title-text {
374
+ max-width: 100%;
364
375
  }
365
376
  .pali-group {
366
377
  margin-top: 0.4em;
367
- display: flex;
368
- }
369
- .pali-cartouche {
370
- text-wrap: nowrap;
371
- min-width: 7em;
372
- margin-left: 0.5em;
378
+ max-width: 35em;
373
379
  }
374
380
 
375
- .dpd-grammar {
381
+ .tooltip-button {
382
+ padding: 0px;
383
+ }
384
+ .dpd-tooltip {
385
+ color: white !important;
386
+ background-color: black !important;
387
+ border: 1pt solid rgba(255,255,255,0.4);
388
+ }
389
+ .dpd-cartouche {
390
+ display: inline-block;
376
391
  color: white;
392
+ max-width: 23em;
393
+ hyphens: manual;
377
394
  border-left: solid 1px gray;
378
395
  border-top: solid 1px gray;
379
396
  background: linear-gradient(1600deg,
380
397
  rgba(255,255,255,0.3),
381
398
  rgba(255,255,255,0.1)
382
399
  ) !important;
383
- border-radius: 4px;
384
- margin-left: 5px;
385
- padding-top: 1px;
400
+ border-radius: 6px;
401
+ padding-top: 0px;
386
402
  padding-left: 3px;
387
- padding-right: 4px;
403
+ padding-right: 6px;
388
404
  margin-right: 2px;
389
405
  }
390
406
 
407
+ .dpd-grammar {
408
+ display: inline-block;
409
+ opacity: 0.8;
410
+ font-style: italic;
411
+ margin-left: 0.2em;
412
+ }
413
+
391
414
  div[title]:hover::before {
392
415
  content: attr(title);
393
416
  background-color: #000000;
@@ -693,7 +716,15 @@ div[title]:hover::before {
693
716
  background-color: rgb(var(--v-theme-currentbg));
694
717
  border-bottom-left-radius: 1em;
695
718
  border-bottom-right-radius: 1em;
696
- border-bottom: 1px solid rgba(var(--v-theme-focus), 0.8);
719
+ border-left: 1px solid rgba(var(--v-theme-focus), 0.8);
720
+ }
721
+ .pli-summary-link {
722
+ display: inline-block;
723
+ margin-right: 1em;
724
+ }
725
+ .pli-summary-item {
726
+ display: inline-block;
727
+ margin-right: 0.3em;
697
728
  }
698
729
 
699
730
  /************** SegmentView (END) ***************/
@@ -10,20 +10,24 @@
10
10
  <div :class="cardClass">
11
11
  <v-card :id="card.id" variant="flat" >
12
12
  <template v-slot:title>
13
- <div v-if="card.titleHref">
13
+ <div v-if="card.titleHref" class="card-title">
14
14
  <v-icon class="card-icon" :title="`${card.iconTitle}`">
15
15
  {{card.icon}}
16
16
  </v-icon>
17
17
  <a :href="card.titleHref" target="_blank"
18
18
  :title="card.titleHref">
19
- <span :id="card.titleAnchor">{{card.chipTitle($t)}}</span>
19
+ <span :id="card.titleAnchor">
20
+ {{card.chipTitle($t)}}
21
+ </span>
20
22
  </a>
21
23
  </div>
22
- <div v-if="!card.titleHref">
24
+ <div v-if="!card.titleHref" class="card-title">
23
25
  <v-icon class="card-icon" :title="`${card.iconTitle}`">
24
26
  {{card.icon}}
25
27
  </v-icon>
26
- <span :id="card.titleAnchor">{{card.chipTitle($t)}}</span>
28
+ <span :id="card.titleAnchor">
29
+ {{card.chipTitle($t)}}
30
+ </span>
27
31
  </div>
28
32
  </template>
29
33
  <template v-slot:append>
@@ -21,42 +21,53 @@
21
21
  @keyup.enter="onEnter"
22
22
  />
23
23
  </v-expand-x-transition>
24
- <div v-if="findResult" class="dict" >
25
- <div v-for="(group,ig) in defGroups">
26
- <div class="dict-group">
27
- <div class="dict-group-title">
28
- {{ig+1}}
29
- <a :href="`#/pali/${group.word}`" tabindex=-1>
30
- {{group.word}}
31
- </a>
32
- <span v-if="group.construction" class="dict-construction">
33
- {{group.construction}}
34
- </span>
35
- </div>
36
- <div class="dict-menu">
37
- <v-btn icon="mdi-play"
38
- @click="clickPlay(group)"
39
- ></v-btn>
40
- </div>
41
- </div><!-- dict-group -->
42
- <audio v-if="showAudio(group)"
43
- :id="`${group}-audio`"
44
- controls :src="urlPaliAudio"
45
- autoplay
46
- ></audio>
47
- <div v-if="volatile.dictionary" >
48
- <div v-for="(def,i) in groupDefinitions(group)"
49
- class="pali-group">
50
- <div v-html="dpdCartoucheHtml(def,i)"
51
- class="pali-cartouche">
24
+ <div v-if="dictResult && groups" class="dict" >
25
+ <v-expansion-panels v-model="panels"
26
+ variant="popout"
27
+ @update:modelValue="onPanelUpdate"
28
+ >
29
+ <v-expansion-panel v-for="(group,ig) in groups" key="ig"
30
+ :value="ig"
31
+ collapse-icon="mdi-format-list-bulleted"
32
+ expand-icon="mdi-format-list-bulleted"
33
+ >
34
+ <v-expansion-panel-title class="pali-panel-title">
35
+ <div class="pali-panel-title-text"
36
+ :title="group.construction"
37
+ >
38
+ <a :href="`#/pali/${group.word}`" tabindex=-1>
39
+ {{group.lemma}}
40
+ </a>
52
41
  </div>
53
- <div>&nbsp;</div>
54
- <div class="pali-meaning"
55
- v-html="meaningHtml(def)"
56
- ></div>
57
- </div>
58
- </div>
59
- </div><!-- group -->
42
+ </v-expansion-panel-title>
43
+ <v-expansion-panel-text>
44
+ <audio v-if="group.audioUrl"
45
+ :id="`${card.id}-${ig}-audio`"
46
+ controls :src="group.audioUrl"
47
+ ></audio>
48
+ <template v-if="volatile.dictionary"
49
+ v-for="(def,i) in groupDefinitions(group)">
50
+ <div class="pali-group">
51
+ <v-tooltip location="top"
52
+ :text="dpdCartoucheTitle(def)"
53
+ content-class="dpd-tooltip"
54
+ max-width="350px"
55
+ open-on-click
56
+ >
57
+ <template v-slot:activator="{ props }">
58
+ <v-btn v-bind="props" density="compact"
59
+ class="tooltip-button"
60
+ >
61
+ <span v-html="dpdCartoucheHtml(def,i)"></span>
62
+ </v-btn>
63
+ </template>
64
+ </v-tooltip>
65
+ <span v-html="meaningHtml(def)" class="ml-1"></span>
66
+ </div>
67
+ </template>
68
+ </v-expansion-panel-text>
69
+ </v-expansion-panel>
70
+ </v-expansion-panels>
60
71
  </div><!-- dict -->
61
72
  <div class="dpd-link">
62
73
  <a :id="idDpdLink" :href="dpdUrl()" target="_blank">
@@ -82,6 +93,7 @@
82
93
  const MAX_DEFINITIONS = 100;
83
94
  const history = [];
84
95
  const items = ref();
96
+ const panels = ref();
85
97
 
86
98
  export default {
87
99
  inject: ['config'],
@@ -93,26 +105,73 @@
93
105
  setup() {
94
106
  const settings = useSettingsStore();
95
107
  const volatile = useVolatileStore();
108
+
96
109
  return {
97
110
  settings,
98
111
  volatile,
99
112
  }
100
113
  },
101
114
  data: () => {
102
- const findResult = ref();
115
+ const dictResult = ref();
116
+ const groups = ref();
103
117
  return {
104
- findResult,
118
+ dictResult,
119
+ panels,
105
120
  search: undefined,
106
121
  showInNewCard: false,
107
122
  history,
108
123
  items,
109
- urlPaliAudio: undefined,
110
- playGroup: undefined,
124
+ groups,
111
125
  }
112
126
  },
113
127
  components: {
114
128
  },
115
129
  methods: {
130
+ async onPanelUpdate(iPanel) {
131
+ const msg = "PaliView.onPanelUpdate:";
132
+ let { groups } = this;
133
+ let group = groups[iPanel];
134
+ if (group) {
135
+ if (!group.audioUrl) {
136
+ group.audioUrl = await this.groupAudioUrl(group);
137
+ console.log(msg, '[1]audioUrl', group.audioUrl);
138
+ } else {
139
+ console.log(msg, '[2]audioUrl', group.audioUrl);
140
+ }
141
+ } else {
142
+ console.warn(msg, '[3]group?', iPanel);
143
+ }
144
+ },
145
+ async lemmaGroups() {
146
+ const msg = "PaliView.lemmaGroups()";
147
+ let { definition, dictResult } = this;
148
+ let { data } = dictResult;
149
+ let dPrev = null;
150
+
151
+ let groups = data.reduce((a,d) => {
152
+ let { word, construction, lemma_1 } = d;
153
+ let [ lemma, ...lemmaTail ] = lemma_1.split(' ');
154
+ word = word.toLowerCase();
155
+ construction = construction && construction.toLowerCase();
156
+ if (word !== dPrev?.word || lemma !== dPrev?.lemma) {
157
+ let group = {
158
+ word,
159
+ lemma,
160
+ construction,
161
+ audioUrl:ref(),
162
+ };
163
+ if (lemmaTail.length) {
164
+ group.lemmaTail = lemmaTail.join(' ');
165
+ }
166
+ a.push(group);
167
+ }
168
+ d.lemma = lemma;
169
+ dPrev = d;
170
+ return a;
171
+ }, []);
172
+
173
+ return groups;
174
+ },
116
175
  dpdLink(word) {
117
176
  let link = Dictionary.dpdLink(word);
118
177
  return link;
@@ -146,36 +205,24 @@
146
205
 
147
206
  return false;
148
207
  },
149
- showAudio(group) {
150
- const msg = "PaliView.showAudio";
151
- const dbg = DBG.PALI_VIEW;
152
- const dbgv = dbg && DBG.VERBOSE;
153
- let { playGroup } = this;
154
- dbgv && console.log(msg, group, playGroup);
155
- return playGroup &&
156
- group.word===playGroup.word &&
157
- group.construction===playGroup.construction;
158
- },
159
- async clickPlay(group) {
160
- const msg = "PaliView.clickPlay()";
208
+ async groupAudioUrl(group) {
209
+ const msg = "PaliView.groupAudioUrl()";
161
210
  const dbg = DBG.PALI_VIEW;
162
211
  let { settings } = this;
163
- let { word } = group;
212
+ let { word, lemma } = group;
164
213
  let urlPlay = [
165
214
  settings.serverUrl,
166
215
  'dictionary',
167
216
  'en',
168
217
  'dpd',
169
- word,
218
+ lemma,
170
219
  'Aditi',
171
220
  'Amy',
172
221
  ].join('/');
173
- this.urlPaliAudio = null;
174
- this.playGroup = null;
175
222
  let res = await fetch(urlPlay);
176
223
  if (!res.ok) {
177
224
  console.err(msg, res);
178
- return;
225
+ return undefined;
179
226
  }
180
227
  let json = await res.json();
181
228
  let { paliGuid } = json;
@@ -188,22 +235,27 @@
188
235
  'Aditi',
189
236
  paliGuid,
190
237
  ].join('/')
191
- this.urlPaliAudio = urlPaliAudio;
192
- this.playGroup = group;
238
+ group.audioUrl = urlPaliAudio;
239
+ console.log(msg, group);
193
240
  dbg && console.log(msg, word, urlPlay, paliGuid, urlPaliAudio);
241
+ return urlPaliAudio;
242
+ },
243
+ dpdCartoucheTitle(def) {
244
+ let { volatile } = this;
245
+ return volatile.dpdCartoucheTitle(def);
194
246
  },
195
247
  dpdCartoucheHtml(def, i) {
196
248
  let { volatile } = this;
197
- return volatile.dpdCartoucheHtml(def,i, {showLemma:true});
249
+ return volatile.dpdCartoucheHtml(def,i, {showLemma:false});
198
250
  },
199
251
  meaningHtml(def) {
200
252
  const msg = "PaliView.meaningHtml()";
201
253
  const dbg = 0;
202
254
  let { literal, meaning } = def;
203
- let { findResult } = this;
204
- if (findResult) {
205
- let { method, pattern } = findResult;
206
- if (method === 'definition') {
255
+ let { dictResult } = this;
256
+ if (dictResult) {
257
+ let { method, pattern } = dictResult;
258
+ if (method === 'entry') {
207
259
  let re = new RegExp(pattern, 'ig');
208
260
  meaning = meaning && meaning.replace(re,
209
261
  `<span class="dict-pat">${pattern}</span>`
@@ -252,7 +304,7 @@
252
304
  });
253
305
  }
254
306
  if (!openNew) {
255
- this.findResult = res;
307
+ this.dictResult = res;
256
308
  this.search = search;
257
309
  this.card.location[0] = search;
258
310
  for (let i=settings.cards.length; i-->0;) {
@@ -329,7 +381,7 @@
329
381
  let res = search && dictionary && dictionary.find(search);
330
382
  if (!res) {
331
383
  dbg && console.log(msg, '[1]search?', search, evt);
332
- this.findResult = undefined;
384
+ this.dictResult = undefined;
333
385
  nextTick(()=>{
334
386
  let id = this.idDpdLink;
335
387
  console.log(msg, '[1.1]id', id);
@@ -345,12 +397,11 @@
345
397
  },
346
398
  groupDefinitions(group) {
347
399
  const msg = "PaliView.groupDefinitions()";
348
- let { word, construction } = group;
349
- let { findResult } = this;
350
- let { method, pattern, data } = findResult;
400
+ let { word, construction, lemma } = group;
401
+ let { dictResult } = this;
402
+ let { method, pattern, data } = dictResult;
351
403
  return data.filter(d=>{
352
- return d.word === group.word &&
353
- d.construction===group.construction;
404
+ return d.lemma === group.lemma;
354
405
  });
355
406
  },
356
407
  },
@@ -366,7 +417,7 @@
366
417
  word = word.toLowerCase();
367
418
  let res = dictionary.find(word);
368
419
  dbg && console.log(msg, '[3]find', word);
369
- this.findResult = res;
420
+ this.dictResult = res;
370
421
  } else {
371
422
  dbg && console.log(msg, '[4]search');
372
423
  volatile.paliSearchCard = card;
@@ -386,6 +437,7 @@
386
437
  dbg && console.log(msg, '[6]history!!!', history);
387
438
  }
388
439
 
440
+ this.groups = await this.lemmaGroups();
389
441
  card.onAfterMounted({settings, volatile});
390
442
  },
391
443
  computed: {
@@ -400,25 +452,6 @@
400
452
  word() {
401
453
  return this.card.location[0];
402
454
  },
403
- defGroups() {
404
- const msg = "PaliView.defGroups()";
405
- let { definition, findResult } = this;
406
- let { data } = findResult;
407
- let dPrev = null;
408
-
409
- return data.reduce((a,d) => {
410
- let { word, construction } = d;
411
- word = word.toLowerCase();
412
- construction = construction && construction.toLowerCase();
413
- if (word !== dPrev?.word ||
414
- construction !== dPrev?.construction)
415
- {
416
- a.push({word, construction});
417
- }
418
- dPrev = d;
419
- return a;
420
- }, []);
421
- },
422
455
  async definition() {
423
456
  const msg = "PaliView.definition";
424
457
  let { card, volatile } = this;
@@ -483,6 +516,7 @@
483
516
  justify-content: space-between;
484
517
  align-items: center;
485
518
  margin-top: 0.7em;
519
+ max-width: 40em;
486
520
  }
487
521
  .dict-group-title {
488
522
  }
@@ -367,13 +367,16 @@
367
367
  ? `<a href="#/pali/${entry.word}">${entry.word}</a>`
368
368
  : `<b>${entry.word}</b>`;
369
369
  return [
370
+ '<div class="pli-summary-link">',
370
371
  paliLink,
372
+ '</div>',
371
373
  ...definition.map((d,i)=>{
372
374
  let def = dictionary.parseDefinition(d);
373
375
  let { type, meaning, literal, construction } = def;
374
376
  literal = literal ? `; <i>lit. ${literal}</i>` : '';
375
377
  let cartouche = volatile.dpdCartoucheHtml(def,i);
376
378
  return [
379
+ '<div class="pli-summary-item">&nbsp;</div>',
377
380
  cartouche,
378
381
  meaning,
379
382
  literal,
@@ -704,19 +704,24 @@ export const useVolatileStore = defineStore('volatile', {
704
704
 
705
705
  return segment;
706
706
  },
707
- dpdCartoucheHtml(def, i, opts={}) {
707
+ dpdCartoucheHtml(def, iList, opts={}) {
708
708
  let { showLemma=false } = opts;
709
- let bullet = this.dpdBullet(i);
709
+ let { lemma_1, word } = def;
710
+ let [ lemmaHead, ...lemmaTail ] = lemma_1.split(' ');
711
+ let prefix = showLemma ? lemmaHead+' ' : '';
712
+ if (lemmaTail && lemmaTail.length) {
713
+ prefix += lemmaTail.join('&nbsp;');
714
+ } else {
715
+ prefix += iList+1;
716
+ }
710
717
  let grammar = this.dpdGrammarHtml(def);
711
- let lemma = showLemma
712
- ? `${this.dpdLemmaHtml(def)}&nbsp;`
713
- : bullet;
714
- let title = this.dpdCartoucheTitle(def);
715
718
  return [
716
- `<span title="${title}" class="dpd-grammar">`,
717
- lemma,
719
+ `<div class="dpd-cartouche">`,
720
+ prefix,
721
+ '<div class="dpd-grammar">',
718
722
  grammar,
719
- '</span>',
723
+ '</div>',
724
+ '</div>',
720
725
  ].join('');
721
726
  },
722
727
  dpdBullet(i) {
@@ -725,7 +730,8 @@ export const useVolatileStore = defineStore('volatile', {
725
730
  dpdCartoucheTitle(def) {
726
731
  const msg = "volatile.dpdCartoucheTitle";
727
732
  let { dictionary } = this;
728
- let info = dictionary.abbreviationInfo(def.pos) || {};
733
+ let { pos } = def;
734
+ let info = dictionary.abbreviationInfo(pos) || {};
729
735
  let { meaning=pos, explanation='' } = info;
730
736
  return explanation.length
731
737
  ? `${meaning}: ${explanation}`
@@ -745,10 +751,17 @@ export const useVolatileStore = defineStore('volatile', {
745
751
  if (dictionary == null) {
746
752
  return "(loading)";
747
753
  }
748
- let {
749
- lemma_1='<span style="opacity:0.5">lemma_1?</span>'
750
- } = def; // part of speech
751
- return lemma_1;
754
+ let { lemma_1 } = def;
755
+ let lemma = lemma_1
756
+ ? lemma_1.split(' ')
757
+ : '<span style="opacity:0.5">lemma_1?</span>'
758
+ let result = lemma_1.split(' ');
759
+ let parts = dictionary.hyphenate(result[0]);
760
+ if (parts) {
761
+ result[0] = parts.join('-');
762
+ }
763
+
764
+ return result.join(' ');
752
765
  },
753
766
  },
754
767
  })