wiki-plugin-rcntimeline 0.3.7 → 0.3.8
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 +30 -3
- 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)"/>` : '')
|
|
@@ -718,6 +718,7 @@
|
|
|
718
718
|
: 'Collected from ' + collect($item).length + ' timeline(s) to the left.'}</p>` : ''
|
|
719
719
|
$item.append(`<div style="background:#f5f5f5;padding:8px;">
|
|
720
720
|
<div class="rcnt-canvas" style="background:#fff;border:1px solid #ddd;overflow-x:auto"></div>
|
|
721
|
+
<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
722
|
${rowsBar($item, item)}${walkBar(item)}
|
|
722
723
|
<p class="caption" style="margin:4px 0 0;">${cap}</p>${note}
|
|
723
724
|
<div style="padding:6px 0 0;text-align:center;">${controls}<button class="rcnt-open" style="cursor:pointer;">Open in RCN Timeline ↗</button></div></div>`)
|
|
@@ -874,6 +875,30 @@
|
|
|
874
875
|
new MutationObserver(add).observe(el, { childList: true })
|
|
875
876
|
}
|
|
876
877
|
|
|
878
|
+
// A bar's `props` {name: value} from the tool's Properties, one line each for the hover tip.
|
|
879
|
+
function propLines (v) {
|
|
880
|
+
return Object.entries(v.props || {}).map(([k, p]) => k + (p == null || p === '' ? '' : ': ' + p))
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
// A bar's card: what the hover tip says, but with its note's addresses and its
|
|
884
|
+
// `sources` [{label,url}] as links you can click. Click the bar again to close.
|
|
885
|
+
function showCard ($item, id) {
|
|
886
|
+
const $c = $item.find('.rcnt-card'), m = $item.get(0).rcntModel
|
|
887
|
+
const v = m && m.intervals.find(w => w.id === id)
|
|
888
|
+
if (!v || $c.data('iv') === id) { $c.hide().data('iv', null); return }
|
|
889
|
+
const link = (u, t) => `<a href="${esc(u)}" target="_blank" rel="noopener">${esc(t)}</a>`
|
|
890
|
+
const note = esc(v.note || '').replace(/https?:\/\/[^\s<>"')]+/g, u => link(u.replace(/&/g, '&'), u.replace(/^https?:\/\//, '').replace(/&/g, '&')))
|
|
891
|
+
const srcs = (v.sources || []).filter(s => s && /^https?:\/\//i.test(s.url || ''))
|
|
892
|
+
const props = Object.entries(v.props || {}).map(([k, p]) => [k, String(p == null ? '' : p).trim()])
|
|
893
|
+
$c.html(`<a class="rcnt-card-x" href="#" title="Close" style="position:absolute;right:8px;top:4px;color:#64748b;text-decoration:none">✕</a>`
|
|
894
|
+
+ `<b>${esc(v.label)}</b> <span style="color:#64748b">${esc(fmt(v.s) + (v.e - v.s > 1 / 365 ? ' – ' + fmt(v.e) : ''))}</span>`
|
|
895
|
+
+ (v.who ? `<div style="color:#475569;font-size:12px">Source: ${esc(v.who)}</div>` : '')
|
|
896
|
+
+ (note ? `<div style="margin-top:3px">${note}</div>` : '')
|
|
897
|
+
+ (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>` : '')
|
|
898
|
+
+ (srcs.length ? `<div style="margin-top:4px;font-size:12px">${srcs.map(s => '↗ ' + link(s.url, s.label || s.url)).join('<br>')}</div>` : ''))
|
|
899
|
+
.show().data('iv', id)
|
|
900
|
+
}
|
|
901
|
+
|
|
877
902
|
function bind ($item, item) {
|
|
878
903
|
aboutMark($item, 'rcntimeline')
|
|
879
904
|
// Stepping a walk is quick clicking — never let it open the editor.
|
|
@@ -892,10 +917,12 @@
|
|
|
892
917
|
})
|
|
893
918
|
$item.on('click', '.rcnt-bar', function (e) {
|
|
894
919
|
const page = this.getAttribute('data-page')
|
|
895
|
-
if (!page) return
|
|
896
920
|
e.stopPropagation()
|
|
897
|
-
wiki.doInternalLink(page, e.shiftKey ? null : $item.parents('.page:first'))
|
|
921
|
+
if (page) { wiki.doInternalLink(page, e.shiftKey ? null : $item.parents('.page:first')); return }
|
|
922
|
+
showCard($item, this.getAttribute('data-iv'))
|
|
898
923
|
})
|
|
924
|
+
$item.on('click', '.rcnt-card-x', e => { e.stopPropagation(); $item.find('.rcnt-card').hide().data('iv', null) })
|
|
925
|
+
$item.on('dblclick', '.rcnt-card', e => e.stopPropagation())
|
|
899
926
|
}
|
|
900
927
|
|
|
901
928
|
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.8",
|
|
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",
|