wiki-plugin-rcntimeline 0.3.7 → 0.3.9
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/README.md +4 -1
- package/client/rcntimeline.js +97 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,10 @@ and restart the wiki. The Factory then offers **RCN Timeline**.
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
- `timeline` is the RCN Timeline's own export format, so a timeline saved from the tool drops straight in. Fields the plugin does not use (`coops`, say) are left alone.
|
|
32
|
-
- `page` names the wiki page a bar opens.
|
|
32
|
+
- `page` names the wiki page a bar opens. Clicking a bar without one opens a card under the drawing: its label, dates, source, note (addresses in it become links) and `sources`.
|
|
33
|
+
- `sources` (optional): `[{"label": "Wikipedia: Oak Flat (Arizona)", "url": "https://…"}]`, the pages a bar was read from. They show as links on the bar's card, and in the tool's panel.
|
|
34
|
+
- `props` (optional): `{"Funder": "County health fund", "Report": "https://…"}`, name and value pairs set under Properties in the tool. They show in the bar's hover text and on its card; a value that is a web address is a link.
|
|
35
|
+
- An item with no intervals shows **Open in RCN Timeline ↗**, so a new item can be drawn in the tool and saved back.
|
|
33
36
|
- `bands`, `band` and `sort` (optional): a timeline that names its story bands gets a **Rows: By band · By time** switch under the drawing. By band, each band's bars sit under its name; by time, one bar per row, earliest at the top. The file's `sort` is the default; the reader's choice is not saved.
|
|
34
37
|
- `rel` may be one relation (`meets`) or a list (`["before", "meets"]`, "one of"), drawn dashed. Lists are not built in the tool yet; the plugin accepts them so it will not break when they are.
|
|
35
38
|
- `text`: the first line is the caption; the rest lists the intervals and links in words, for search and for a wiki without this plugin.
|
package/client/rcntimeline.js
CHANGED
|
@@ -263,7 +263,7 @@
|
|
|
263
263
|
const tip = [v.label, fmt(v.s) + ' – ' + fmt(v.e),
|
|
264
264
|
(v.sf || v.ef) ? 'uncertain by ' + [v.sf ? v.sf + ' yr before' : '', v.ef ? v.ef + ' yr after' : ''].filter(Boolean).join(', ') : '',
|
|
265
265
|
v.who ? 'Source: ' + v.who : '', v.conf != null ? 'Confidence ' + Math.round(v.conf * 100) + '%' : '',
|
|
266
|
-
v.note || '', v.page ? '— click to open ' + v.page : ''].filter(Boolean).join('\n')
|
|
266
|
+
v.note || '', ...propLines(v), v.page ? '— click to open ' + v.page : ''].filter(Boolean).join('\n')
|
|
267
267
|
parts.push(`<g class="rcnt-bar" data-iv="${esc(v.id)}" data-page="${esc(v.page || '')}" style="cursor:${v.page ? 'pointer' : 'default'}"><title>${esc(tip)}</title>`
|
|
268
268
|
+ (v.sf ? `<rect x="${x(v.s - v.sf)}" y="${y}" width="${xs - x(v.s - v.sf)}" height="${BAR_H}" fill="url(#${gid}L)"/>` : '')
|
|
269
269
|
+ (v.ef ? `<rect x="${xe}" y="${y}" width="${x(v.e + v.ef) - xe}" height="${BAR_H}" fill="url(#${gid}R)"/>` : '')
|
|
@@ -478,6 +478,36 @@
|
|
|
478
478
|
try { on = localStorage.getItem('rcnWalkVoice') !== 'off' } catch (e) {}
|
|
479
479
|
return { voice: p.voice || '', rate: (+p.rate >= 0.6 && +p.rate <= 1.4) ? +p.rate : 0.95, on }
|
|
480
480
|
}
|
|
481
|
+
function walkSetPref (k, v) {
|
|
482
|
+
let p = {}
|
|
483
|
+
try { p = JSON.parse(localStorage.getItem('rcnWalkPrefs') || '{}') } catch (e) {}
|
|
484
|
+
p[k] = v
|
|
485
|
+
try { localStorage.setItem('rcnWalkPrefs', JSON.stringify(p)) } catch (e) {}
|
|
486
|
+
}
|
|
487
|
+
// The ⚙ Voice panel (Nov 8 2026): the Graph Tool's voice and speed controls, the
|
|
488
|
+
// same rcnWalkPrefs keys, so a choice made here holds in the tools and other plugins.
|
|
489
|
+
const goodVoice = v => /Enhanced|Premium|Natural|Neural/i.test(v.name)
|
|
490
|
+
function voiceOptions () {
|
|
491
|
+
const vs = window.speechSynthesis ? speechSynthesis.getVoices().filter(v => /^en/i.test(v.lang)) : []
|
|
492
|
+
if (!vs.length) return '<option value="">No voices found in this browser</option>'
|
|
493
|
+
const cur = walkVoice(walkPrefs().voice)
|
|
494
|
+
return vs.slice().sort((a, b) => (goodVoice(b) - goodVoice(a)) || a.name.localeCompare(b.name))
|
|
495
|
+
.map(v => `<option value="${esc(v.name)}"${cur && cur.name === v.name ? ' selected' : ''}>${goodVoice(v) ? '★ ' : ''}${esc(v.name)} (${esc(v.lang)})</option>`).join('')
|
|
496
|
+
}
|
|
497
|
+
function voiceHint () {
|
|
498
|
+
const vs = window.speechSynthesis ? speechSynthesis.getVoices().filter(v => /^en/i.test(v.lang)) : []
|
|
499
|
+
const mac = /Mac/i.test(navigator.platform || navigator.userAgent)
|
|
500
|
+
return vs.some(goodVoice) ? '★ marks the more natural voices. Speed is for the computer voice; a recording plays as it was recorded.'
|
|
501
|
+
: mac ? 'No natural-sounding voice is installed. On a Mac: System Settings → Accessibility → Spoken Content → System voice → Manage Voices… Download an English voice marked Enhanced or Premium, then quit the browser (⌘Q) and open it again: reloading the page is not enough.'
|
|
502
|
+
: 'No natural-sounding voice is installed. Your system’s speech settings can add more voices; reload this page after.'
|
|
503
|
+
}
|
|
504
|
+
function voiceSample () {
|
|
505
|
+
if (!window.speechSynthesis) return
|
|
506
|
+
const p = walkPrefs(), v = walkVoice(p.voice), u = new SpeechSynthesisUtterance('This is how a walk will sound.')
|
|
507
|
+
if (v) { u.voice = v; u.lang = v.lang }
|
|
508
|
+
u.rate = p.rate
|
|
509
|
+
speechSynthesis.speak(u)
|
|
510
|
+
}
|
|
481
511
|
function walkVoice (name) {
|
|
482
512
|
const vs = window.speechSynthesis ? speechSynthesis.getVoices().filter(v => /^en/i.test(v.lang)) : []
|
|
483
513
|
return vs.find(v => v.name === name) || vs.find(v => /Enhanced|Premium|Natural|Neural/i.test(v.name)) ||
|
|
@@ -585,8 +615,17 @@
|
|
|
585
615
|
<span class="walk-count" style="display:none;font-size:12px;color:#64748b;min-width:70px;text-align:center"></span>
|
|
586
616
|
<button class="walk-voice" style="${b}display:none" title="Read the words aloud, or show them only"></button>
|
|
587
617
|
<select class="walk-speaker" style="font-size:12px;max-width:170px;display:none" title="Whose voice reads the walk (kept in this browser)"></select>
|
|
618
|
+
<button class="walk-voiceset" style="${b}display:none" title="Choose the voice and how fast it speaks">⚙ Voice</button>
|
|
588
619
|
<button class="walk-close" style="${b}display:none" title="Stop the walk (Esc)">■ Stop</button>
|
|
589
620
|
</div>
|
|
621
|
+
<div class="walk-voicepanel" style="display:none;margin:6px 4px 0;padding:8px 10px;background:#eef2ff;border-radius:8px;font-size:12px;color:#374151">
|
|
622
|
+
<div style="display:flex;flex-wrap:wrap;gap:8px 14px;align-items:center;justify-content:center">
|
|
623
|
+
<label>Voice <select class="walk-voicesel" style="font-size:12px;max-width:260px" title="Which computer voice reads the walk (kept in this browser)"></select></label>
|
|
624
|
+
<label>Speed <input class="walk-rate" type="range" min="0.6" max="1.4" step="0.05" style="vertical-align:middle"> <span class="walk-rate-val"></span></label>
|
|
625
|
+
<button class="walk-sample" style="${b}" title="Hear the chosen voice at the chosen speed">Hear a sample</button>
|
|
626
|
+
</div>
|
|
627
|
+
<div class="walk-voicehint" style="font-size:11px;color:#6b7280;text-align:center;margin-top:4px"></div>
|
|
628
|
+
</div>
|
|
590
629
|
<div class="walk-say" aria-live="polite" style="display:none;margin:8px 4px 0;padding:10px 12px;background:#fff;border:1px solid #c7d2fe;border-radius:8px;font-size:17px;line-height:1.45;color:#1e1b4b"></div>
|
|
591
630
|
<div class="walk-note" style="font-size:11px;color:#64748b;text-align:center;margin-top:3px"></div>
|
|
592
631
|
</div>`
|
|
@@ -602,7 +641,9 @@
|
|
|
602
641
|
const ui = note => {
|
|
603
642
|
const walk = cur(), open = !!walk
|
|
604
643
|
const $bar = $item.find('.walk-bar')
|
|
605
|
-
$bar.find('.walk-prev, .walk-next, .walk-play, .walk-count, .walk-voice, .walk-close').toggle(open)
|
|
644
|
+
$bar.find('.walk-prev, .walk-next, .walk-play, .walk-count, .walk-voice, .walk-voiceset, .walk-close').toggle(open)
|
|
645
|
+
$bar.find('.walk-voicepanel').toggle(open && !!wk.vp)
|
|
646
|
+
$bar.find('.walk-voiceset').css('background', wk.vp ? '#eef2ff' : '')
|
|
606
647
|
$bar.find('.walk-start, .walk-pick').toggle(!open)
|
|
607
648
|
$bar.find('.walk-say').toggle(open)
|
|
608
649
|
$bar.find('.walk-play').text(wk.playing ? '❚❚' : '▶')
|
|
@@ -669,6 +710,29 @@
|
|
|
669
710
|
$item.on('click.rcntwalk', '.walk-next', () => show(wk.i + 1))
|
|
670
711
|
$item.on('click.rcntwalk', '.walk-close', () => end())
|
|
671
712
|
$item.on('change.rcntwalk', '.walk-speaker', e => { recSetSpeaker(e.target.value); if (wk.playing) speak() })
|
|
713
|
+
const fillVoices = () => {
|
|
714
|
+
const p = walkPrefs()
|
|
715
|
+
$item.find('.walk-voicesel').html(voiceOptions())
|
|
716
|
+
$item.find('.walk-rate').val(p.rate)
|
|
717
|
+
$item.find('.walk-rate-val').text(Math.round(p.rate * 100) + '%')
|
|
718
|
+
$item.find('.walk-voicehint').text(voiceHint())
|
|
719
|
+
}
|
|
720
|
+
const sample = () => { pause(); voiceSample() }
|
|
721
|
+
$item.on('click.rcntwalk', '.walk-voiceset', () => { wk.vp = !wk.vp; if (wk.vp) fillVoices(); ui() })
|
|
722
|
+
$item.on('change.rcntwalk', '.walk-voicesel', e => { walkSetPref('voice', e.target.value); sample() })
|
|
723
|
+
$item.on('input.rcntwalk', '.walk-rate', e => {
|
|
724
|
+
const r = Math.max(0.6, Math.min(1.4, +e.target.value || 0.95))
|
|
725
|
+
walkSetPref('rate', r)
|
|
726
|
+
$item.find('.walk-rate-val').text(Math.round(r * 100) + '%')
|
|
727
|
+
})
|
|
728
|
+
$item.on('click.rcntwalk', '.walk-sample', () => sample())
|
|
729
|
+
// Voices arrive late in Chrome; refresh an open panel when they do.
|
|
730
|
+
// One listener per item however often it redraws; it calls this binding's fillVoices.
|
|
731
|
+
el.rcntFillVoices = fillVoices
|
|
732
|
+
if (!el.rcntVoiceListen && window.speechSynthesis && speechSynthesis.addEventListener) {
|
|
733
|
+
el.rcntVoiceListen = true
|
|
734
|
+
speechSynthesis.addEventListener('voiceschanged', () => { if (wk.vp && document.body.contains(el) && el.rcntFillVoices) el.rcntFillVoices() })
|
|
735
|
+
}
|
|
672
736
|
$item.on('click.rcntwalk', '.walk-voice', () => {
|
|
673
737
|
const on = !walkPrefs().on
|
|
674
738
|
try { localStorage.setItem('rcnWalkVoice', on ? 'on' : 'off') } catch (e) {}
|
|
@@ -677,7 +741,7 @@
|
|
|
677
741
|
ui()
|
|
678
742
|
})
|
|
679
743
|
$item.on('keydown.rcntwalk', '.walk-bar', e => {
|
|
680
|
-
if (wk.w === null || $(e.target).is('select')) return
|
|
744
|
+
if (wk.w === null || $(e.target).is('select, input')) return
|
|
681
745
|
if (e.key === ' ') { e.preventDefault(); e.stopPropagation(); toggle() }
|
|
682
746
|
else if (e.key === 'ArrowRight') { e.preventDefault(); e.stopPropagation(); show(wk.i + 1) }
|
|
683
747
|
else if (e.key === 'ArrowLeft') { e.preventDefault(); e.stopPropagation(); show(wk.i - 1) }
|
|
@@ -718,6 +782,7 @@
|
|
|
718
782
|
: 'Collected from ' + collect($item).length + ' timeline(s) to the left.'}</p>` : ''
|
|
719
783
|
$item.append(`<div style="background:#f5f5f5;padding:8px;">
|
|
720
784
|
<div class="rcnt-canvas" style="background:#fff;border:1px solid #ddd;overflow-x:auto"></div>
|
|
785
|
+
<div class="rcnt-card" style="display:none;margin:6px 0 0;padding:8px 26px 8px 10px;background:#fff;border:1px solid #c7d2fe;border-radius:6px;font-size:13px;line-height:1.45;position:relative"></div>
|
|
721
786
|
${rowsBar($item, item)}${walkBar(item)}
|
|
722
787
|
<p class="caption" style="margin:4px 0 0;">${cap}</p>${note}
|
|
723
788
|
<div style="padding:6px 0 0;text-align:center;">${controls}<button class="rcnt-open" style="cursor:pointer;">Open in RCN Timeline ↗</button></div></div>`)
|
|
@@ -796,7 +861,7 @@
|
|
|
796
861
|
const blob = await (await fetch(dataUrl)).blob()
|
|
797
862
|
const sum = new Uint8Array(await crypto.subtle.digest('SHA-256', await blob.arrayBuffer()))
|
|
798
863
|
const hex = [...sum.slice(0, 12)].map(b => b.toString(16).padStart(2, '0')).join('')
|
|
799
|
-
const ext = /mp4|m4a|aac/.test(blob.type) ? 'm4a' : /wav/.test(blob.type) ? 'wav' : /ogg/.test(blob.type) ? 'ogg' : 'webm'
|
|
864
|
+
const ext = /mpeg|mp3/.test(blob.type) ? 'mp3' : /mp4|m4a|aac/.test(blob.type) ? 'm4a' : /wav/.test(blob.type) ? 'wav' : /ogg/.test(blob.type) ? 'ogg' : 'webm'
|
|
800
865
|
const name = hex + '.' + ext
|
|
801
866
|
const url = location.origin + '/assets/' + VOICE_FOLDER + '/' + name
|
|
802
867
|
const have = await fetch(url, { method: 'HEAD', cache: 'no-store' }).then(r => r.ok, () => false)
|
|
@@ -874,6 +939,30 @@
|
|
|
874
939
|
new MutationObserver(add).observe(el, { childList: true })
|
|
875
940
|
}
|
|
876
941
|
|
|
942
|
+
// A bar's `props` {name: value} from the tool's Properties, one line each for the hover tip.
|
|
943
|
+
function propLines (v) {
|
|
944
|
+
return Object.entries(v.props || {}).map(([k, p]) => k + (p == null || p === '' ? '' : ': ' + p))
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// A bar's card: what the hover tip says, but with its note's addresses and its
|
|
948
|
+
// `sources` [{label,url}] as links you can click. Click the bar again to close.
|
|
949
|
+
function showCard ($item, id) {
|
|
950
|
+
const $c = $item.find('.rcnt-card'), m = $item.get(0).rcntModel
|
|
951
|
+
const v = m && m.intervals.find(w => w.id === id)
|
|
952
|
+
if (!v || $c.data('iv') === id) { $c.hide().data('iv', null); return }
|
|
953
|
+
const link = (u, t) => `<a href="${esc(u)}" target="_blank" rel="noopener">${esc(t)}</a>`
|
|
954
|
+
const note = esc(v.note || '').replace(/https?:\/\/[^\s<>"')]+/g, u => link(u.replace(/&/g, '&'), u.replace(/^https?:\/\//, '').replace(/&/g, '&')))
|
|
955
|
+
const srcs = (v.sources || []).filter(s => s && /^https?:\/\//i.test(s.url || ''))
|
|
956
|
+
const props = Object.entries(v.props || {}).map(([k, p]) => [k, String(p == null ? '' : p).trim()])
|
|
957
|
+
$c.html(`<a class="rcnt-card-x" href="#" title="Close" style="position:absolute;right:8px;top:4px;color:#64748b;text-decoration:none">✕</a>`
|
|
958
|
+
+ `<b>${esc(v.label)}</b> <span style="color:#64748b">${esc(fmt(v.s) + (v.e - v.s > 1 / 365 ? ' – ' + fmt(v.e) : ''))}</span>`
|
|
959
|
+
+ (v.who ? `<div style="color:#475569;font-size:12px">Source: ${esc(v.who)}</div>` : '')
|
|
960
|
+
+ (note ? `<div style="margin-top:3px">${note}</div>` : '')
|
|
961
|
+
+ (props.length ? `<div style="margin-top:4px;font-size:12px">${props.map(([k, p]) => `<b>${esc(k)}</b>${p === '' ? '' : ': ' + (/^https?:\/\//i.test(p) ? '↗ ' + link(p, p.replace(/^https?:\/\//, '').replace(/\/+$/, '')) : esc(p))}`).join('<br>')}</div>` : '')
|
|
962
|
+
+ (srcs.length ? `<div style="margin-top:4px;font-size:12px">${srcs.map(s => '↗ ' + link(s.url, s.label || s.url)).join('<br>')}</div>` : ''))
|
|
963
|
+
.show().data('iv', id)
|
|
964
|
+
}
|
|
965
|
+
|
|
877
966
|
function bind ($item, item) {
|
|
878
967
|
aboutMark($item, 'rcntimeline')
|
|
879
968
|
// Stepping a walk is quick clicking — never let it open the editor.
|
|
@@ -892,10 +981,12 @@
|
|
|
892
981
|
})
|
|
893
982
|
$item.on('click', '.rcnt-bar', function (e) {
|
|
894
983
|
const page = this.getAttribute('data-page')
|
|
895
|
-
if (!page) return
|
|
896
984
|
e.stopPropagation()
|
|
897
|
-
wiki.doInternalLink(page, e.shiftKey ? null : $item.parents('.page:first'))
|
|
985
|
+
if (page) { wiki.doInternalLink(page, e.shiftKey ? null : $item.parents('.page:first')); return }
|
|
986
|
+
showCard($item, this.getAttribute('data-iv'))
|
|
898
987
|
})
|
|
988
|
+
$item.on('click', '.rcnt-card-x', e => { e.stopPropagation(); $item.find('.rcnt-card').hide().data('iv', null) })
|
|
989
|
+
$item.on('dblclick', '.rcnt-card', e => e.stopPropagation())
|
|
899
990
|
}
|
|
900
991
|
|
|
901
992
|
if (typeof window !== 'undefined') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-plugin-rcntimeline",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "Federated Wiki plugin: a small RCN timeline on a page — intervals with fuzzy edges, the links between them, a date axis; each bar opens its page",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wiki",
|