wiki-plugin-rcngraph 0.1.19 → 0.1.21
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/client/rcngraph.js +349 -2
- package/package.json +1 -1
- package/pages/about-rcngraph-plugin +16 -0
package/client/rcngraph.js
CHANGED
|
@@ -1,5 +1,163 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
+
// BEGIN rcn-lineup-follow — pasted from tools/rcn-lineup-follow.js by tools/paste-lineup-follow.js. Edit that file, never this block.
|
|
4
|
+
/* rcn-lineup-follow — the timeline, map and drawing items on a wiki page follow
|
|
5
|
+
* each other, across the whole lineup and into the full tools open in other tabs.
|
|
6
|
+
*
|
|
7
|
+
* ONE SOURCE. tools/paste-lineup-follow.js pastes this file into the three
|
|
8
|
+
* plugins (rcntimeline, rcnmap, rcngraph) between the BEGIN/END marker lines,
|
|
9
|
+
* so each plugin stays one file. Edit this file, then run
|
|
10
|
+
* node tools/paste-lineup-follow.js
|
|
11
|
+
*
|
|
12
|
+
* WHY IT IS EASY ON A WIKI. A FedWiki lineup is one browser document: every
|
|
13
|
+
* page beside the others is a .page inside .main, even pages from other sites.
|
|
14
|
+
* So items on different pages can call each other directly. The first plugin
|
|
15
|
+
* to load makes window.rcnLineup; the others use it.
|
|
16
|
+
*
|
|
17
|
+
* WHAT GOES OUT. The same two messages the full tools send (tools/rcn-switch.js):
|
|
18
|
+
* { type:'rcn-walk', src, lead, k, all, label, ids, places, eips } a walk step
|
|
19
|
+
* { type:'rcn-walk', src, lead, k, end:true } the walk stopped
|
|
20
|
+
* { type:'rcn-follow', src, k, click:true, id, place, eip, ids, places, eips, clear? }
|
|
21
|
+
* ids are timeline bars, places map points, eips drawing nodes. The sender
|
|
22
|
+
* widens what it lights one hop through every timeline in the lineup: each bar
|
|
23
|
+
* names a place and a node, so a map step on the Magma mine lights the Magma
|
|
24
|
+
* bars and the Magma Copper box. x:1 marks a message already widened.
|
|
25
|
+
*
|
|
26
|
+
* HOW IT TRAVELS. As a bubbling DOM event 'rcnwalkStream' from the item (the
|
|
27
|
+
* naming FedWiki's Frame plugin uses for its LINEUP topics), heard once at the
|
|
28
|
+
* document and handed to every joined item but the sender; and over the
|
|
29
|
+
* BroadcastChannel 'rcn-follow', where the full tools of the same site listen.
|
|
30
|
+
*
|
|
31
|
+
* Marc Pierson with Claude Opus 5.5, Nov 2026. MIT licence.
|
|
32
|
+
*/
|
|
33
|
+
const RL = (function () {
|
|
34
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') return null
|
|
35
|
+
if (window.rcnLineup) return window.rcnLineup
|
|
36
|
+
const R = window.rcnLineup = { v: 1, members: [], heard: {} }
|
|
37
|
+
const CH = ('BroadcastChannel' in window) ? new BroadcastChannel('rcn-follow') : null
|
|
38
|
+
const none = () => ({ ids: [], places: [], eips: [] })
|
|
39
|
+
|
|
40
|
+
// The bridges: every bar of every timeline item in the lineup.
|
|
41
|
+
R.bars = function () {
|
|
42
|
+
const out = []
|
|
43
|
+
document.querySelectorAll('.rcntimeline-source').forEach(el => {
|
|
44
|
+
if (!el.timelineData) return
|
|
45
|
+
try {
|
|
46
|
+
(el.timelineData().intervals || []).forEach(iv => {
|
|
47
|
+
const x = iv.extra || {}
|
|
48
|
+
out.push({ id: String(iv.id), place: iv.place || x.place || null, eip: iv.eip || x.eip || null })
|
|
49
|
+
})
|
|
50
|
+
} catch (e) {}
|
|
51
|
+
})
|
|
52
|
+
return out
|
|
53
|
+
}
|
|
54
|
+
// One hop: a bar named, or at a lit place, or about a lit node, adds its bar, place and node.
|
|
55
|
+
R.expand = function (o) {
|
|
56
|
+
const I = {}, P = {}, E = {}, i0 = {}, p0 = {}, e0 = {}
|
|
57
|
+
;(o.ids || []).filter(Boolean).forEach(x => { I[x] = i0[x] = 1 })
|
|
58
|
+
;(o.places || []).filter(Boolean).forEach(x => { P[x] = p0[x] = 1 })
|
|
59
|
+
;(o.eips || []).filter(Boolean).forEach(x => { E[x] = e0[x] = 1 })
|
|
60
|
+
R.bars().forEach(b => {
|
|
61
|
+
if (i0[b.id] || (b.place && p0[b.place]) || (b.eip && e0[b.eip])) {
|
|
62
|
+
I[b.id] = 1; if (b.place) P[b.place] = 1; if (b.eip) E[b.eip] = 1
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
return { ids: Object.keys(I), places: Object.keys(P), eips: Object.keys(E) }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// An item joins: fn(m) hears the others and returns true when it lit something.
|
|
69
|
+
// Joining again (a redraw) replaces the item's old listener.
|
|
70
|
+
R.join = function (el, src, fn) {
|
|
71
|
+
R.members = R.members.filter(x => x.el !== el && document.contains(x.el))
|
|
72
|
+
R.members.push({ el, src, fn })
|
|
73
|
+
}
|
|
74
|
+
R.others = el => R.members.filter(x => x.el !== el && document.contains(x.el)).length
|
|
75
|
+
|
|
76
|
+
function deliver (m, fromEl) {
|
|
77
|
+
if (!m || !m.k || R.heard[m.k]) return 0
|
|
78
|
+
R.heard[m.k] = 1
|
|
79
|
+
R.members = R.members.filter(x => document.contains(x.el))
|
|
80
|
+
let n = 0
|
|
81
|
+
R.members.slice().forEach(x => {
|
|
82
|
+
if (x.el === fromEl) return
|
|
83
|
+
try { if (x.fn(m)) n++ } catch (e) { console.warn('rcn-lineup-follow:', e) }
|
|
84
|
+
})
|
|
85
|
+
return n
|
|
86
|
+
}
|
|
87
|
+
// Returns how many items in this lineup lit something.
|
|
88
|
+
function send (el, m) {
|
|
89
|
+
m.k = Date.now() + ':' + Math.random()
|
|
90
|
+
let n = 0
|
|
91
|
+
try {
|
|
92
|
+
const ev = new CustomEvent('rcnwalkStream', { bubbles: true, detail: m })
|
|
93
|
+
el.dispatchEvent(ev)
|
|
94
|
+
n = ev.rcnLit || 0
|
|
95
|
+
} catch (e) {}
|
|
96
|
+
try { if (CH) CH.postMessage(m) } catch (e) {}
|
|
97
|
+
return n
|
|
98
|
+
}
|
|
99
|
+
document.addEventListener('rcnwalkStream', e => { e.rcnLit = deliver(e.detail, e.target) })
|
|
100
|
+
// The full tools in other tabs: their walks come widened through their set;
|
|
101
|
+
// their clicks name one thing, so widen those here.
|
|
102
|
+
if (CH) CH.addEventListener('message', ev => {
|
|
103
|
+
const m = ev.data
|
|
104
|
+
if (!m || !m.k) return
|
|
105
|
+
if (m.type === 'rcn-walk') { deliver(m, null); return }
|
|
106
|
+
if (m.type !== 'rcn-follow' || !m.click) return
|
|
107
|
+
if (m.x) { deliver(m, null); return }
|
|
108
|
+
const x = m.id ? R.expand({ ids: m.src === 'timeline' ? [m.id] : [], places: [m.place], eips: [m.eip] }) : none()
|
|
109
|
+
deliver(Object.assign({}, m, x, { x: 1, clear: !m.id }), null)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
// A step of this item's walk. o: {ids|places|eips: [...], all, label}
|
|
113
|
+
R.step = function (el, src, o) {
|
|
114
|
+
if (!el.rcnLead) el.rcnLead = src + ':' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6)
|
|
115
|
+
const x = o.all ? none() : R.expand(o)
|
|
116
|
+
return send(el, Object.assign({ type: 'rcn-walk', src, lead: el.rcnLead, all: !!o.all, pointer: false, label: o.label || null, x: 1 }, x))
|
|
117
|
+
}
|
|
118
|
+
// This item's walk stopped. Sends nothing if it was not leading.
|
|
119
|
+
R.end = function (el, src) {
|
|
120
|
+
if (!el.rcnLead) return
|
|
121
|
+
const lead = el.rcnLead
|
|
122
|
+
el.rcnLead = null
|
|
123
|
+
send(el, { type: 'rcn-walk', src, lead, end: true })
|
|
124
|
+
}
|
|
125
|
+
// A click on one thing, or {clear:true} to let go. o: {id} for a bar (it
|
|
126
|
+
// lights the bar's own place and node), {place} for a map point (the bars there
|
|
127
|
+
// and their nodes), {eip} for a drawing box (the bars about it and their places).
|
|
128
|
+
// Returns how many items in this lineup lit something.
|
|
129
|
+
R.click = function (el, src, o) {
|
|
130
|
+
el.rcnClicked = !o.clear
|
|
131
|
+
const x = o.clear ? none() : R.expand({ ids: o.id ? [o.id] : [], places: [o.place], eips: [o.eip] })
|
|
132
|
+
const bar = o.id && R.bars().find(b => b.id === String(o.id))
|
|
133
|
+
return send(el, Object.assign({ type: 'rcn-follow', src, click: true, clear: !!o.clear,
|
|
134
|
+
id: o.clear ? null : (o.id || o.place || o.eip || null), label: o.label || null,
|
|
135
|
+
place: o.place || (bar && bar.place) || null, eip: o.eip || (bar && bar.eip) || null, x: 1 }, x))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// A follower's state after hearing m. f: {lead, lit:Set|null, seen:Set, click}
|
|
139
|
+
// or null. mine: the ids of this item that m names. Returns the new state; the
|
|
140
|
+
// same object means nothing changes (a step about nothing here leaves it be).
|
|
141
|
+
R.update = function (f, m, mine) {
|
|
142
|
+
if (m.type === 'rcn-walk' && m.end) return f && f.lead === m.lead ? null : f
|
|
143
|
+
if (m.type === 'rcn-follow' && m.clear) return f && f.click ? null : f
|
|
144
|
+
const same = f && m.lead && f.lead === m.lead
|
|
145
|
+
if (m.all) return { lead: m.lead || null, lit: null, seen: same ? f.seen : new Set(), click: false }
|
|
146
|
+
if (!mine.length) return f
|
|
147
|
+
const seen = same ? new Set([...f.seen, ...(f.lit || [])]) : new Set()
|
|
148
|
+
return { lead: m.lead || null, lit: new Set(mine), seen, click: m.type === 'rcn-follow' }
|
|
149
|
+
}
|
|
150
|
+
// How strongly to draw one thing: lit full, seen half, the rest faded
|
|
151
|
+
// (less faded after a click than in a walk).
|
|
152
|
+
R.op = function (f, id) {
|
|
153
|
+
if (!f || !f.lit || f.lit.has(id)) return 1
|
|
154
|
+
if (f.seen.has(id)) return 0.42
|
|
155
|
+
return f.click ? 0.3 : 0.13
|
|
156
|
+
}
|
|
157
|
+
return R
|
|
158
|
+
})()
|
|
159
|
+
// END rcn-lineup-follow
|
|
160
|
+
|
|
3
161
|
// Farm sites are alice.localhost, scp-experiment.localhost, … so match the suffix,
|
|
4
162
|
// not the bare hostname. Local wikis get the working copy off the sofi-proxy static
|
|
5
163
|
// server; everything else gets the deployed asset.
|
|
@@ -335,6 +493,20 @@
|
|
|
335
493
|
</div>`
|
|
336
494
|
}
|
|
337
495
|
|
|
496
|
+
// Following another item in the lineup (see rcn-lineup-follow): the boxes it
|
|
497
|
+
// lights here at full strength, an arrow between two of them too, what it lit
|
|
498
|
+
// before at half, the rest faded; the drawing zooms towards the lit boxes.
|
|
499
|
+
function showFollow($item, g, f) {
|
|
500
|
+
const svg = $item.find('svg').get(0)
|
|
501
|
+
if (!svg) return
|
|
502
|
+
svg.querySelectorAll('.rcn-walk-ring').forEach(el => el.remove())
|
|
503
|
+
$item.find('.graph-box').css('max-height', 'none')
|
|
504
|
+
const op = id => RL.op(f, String(id))
|
|
505
|
+
g.nodes.forEach(n => { const el = groupFor(svg, 'node', n.id); if (el) el.style.opacity = String(op(n.id)) })
|
|
506
|
+
g.edges.forEach(e => { const el = groupFor(svg, 'edge', e.id); if (el) el.style.opacity = String(Math.min(op(e.src), op(e.tgt))) })
|
|
507
|
+
walkZoom(svg, [...f.lit].map(id => groupFor(svg, 'node', id)).filter(Boolean))
|
|
508
|
+
}
|
|
509
|
+
|
|
338
510
|
function esc(s) { return String(s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])) }
|
|
339
511
|
|
|
340
512
|
function renderContent($item, item) {
|
|
@@ -410,8 +582,144 @@
|
|
|
410
582
|
new MutationObserver(add).observe(el, { childList: true })
|
|
411
583
|
}
|
|
412
584
|
|
|
585
|
+
// ── Notes you can edit from their popup (Nov 8 2026) ──────────────────────
|
|
586
|
+
// The drawing's hover text is the browser's own <title> tooltip, which cannot hold a
|
|
587
|
+
// button. So the plugin shows its own popup instead (the <title> text moves to
|
|
588
|
+
// data-note while the page is open, and stays in the saved picture), with
|
|
589
|
+
// "✎ Edit note". Saving writes the note into graphJSON — the same field the Graph
|
|
590
|
+
// Tool's side panel edits — and into that box's hover text in svgString, then saves
|
|
591
|
+
// the page. A box's label and the picture itself are not touched.
|
|
592
|
+
const NOTE_DOT = '#f59e0b'
|
|
593
|
+
function graphOf(item) {
|
|
594
|
+
const asText = typeof item.graphJSON === 'string'
|
|
595
|
+
let g = item.graphJSON
|
|
596
|
+
if (asText) { try { g = JSON.parse(g) } catch (e) { g = null } }
|
|
597
|
+
return { g, asText }
|
|
598
|
+
}
|
|
599
|
+
// "📌 note" leads the hover text when there is a note; properties follow it.
|
|
600
|
+
function retitle(title, oldNote, newNote) {
|
|
601
|
+
const t = String(title || '')
|
|
602
|
+
const pin = '\uD83D\uDCCC '
|
|
603
|
+
const rest = oldNote && t.indexOf(pin + oldNote) === 0 ? t.slice((pin + oldNote).length).replace(/^\n/, '')
|
|
604
|
+
: t.indexOf(pin) === 0 ? t.replace(/^[^\n]*\n?/, '') : t
|
|
605
|
+
return (newNote ? pin + newNote + (rest ? '\n' : '') : '') + rest
|
|
606
|
+
}
|
|
607
|
+
function svgWithNote(svgString, kind, id, oldNote, newNote) {
|
|
608
|
+
const doc = new DOMParser().parseFromString(svgString, 'image/svg+xml')
|
|
609
|
+
if (doc.getElementsByTagName('parsererror').length) return null
|
|
610
|
+
const g = doc.getElementById(kind + '-' + id)
|
|
611
|
+
if (!g) return null
|
|
612
|
+
const NS = 'http://www.w3.org/2000/svg'
|
|
613
|
+
let t = Array.from(g.children).find(c => c.localName === 'title')
|
|
614
|
+
const text = retitle(t ? t.textContent : '', oldNote, newNote)
|
|
615
|
+
if (text) {
|
|
616
|
+
if (!t) { t = doc.createElementNS(NS, 'title'); g.insertBefore(t, g.firstChild) }
|
|
617
|
+
t.textContent = text
|
|
618
|
+
} else if (t) t.remove()
|
|
619
|
+
if (kind === 'node') {
|
|
620
|
+
const dot = Array.from(g.children).find(c => c.localName === 'circle' && c.getAttribute('fill') === NOTE_DOT && c.getAttribute('r') === '4')
|
|
621
|
+
const rect = Array.from(g.children).find(c => c.localName === 'rect')
|
|
622
|
+
if (newNote && !dot && rect) {
|
|
623
|
+
const c = doc.createElementNS(NS, 'circle')
|
|
624
|
+
c.setAttribute('cx', (+rect.getAttribute('x') + +rect.getAttribute('width') - 4).toFixed(1))
|
|
625
|
+
c.setAttribute('cy', (+rect.getAttribute('y') + 4).toFixed(1))
|
|
626
|
+
c.setAttribute('r', '4'); c.setAttribute('fill', NOTE_DOT); c.setAttribute('stroke', '#fff'); c.setAttribute('stroke-width', '1')
|
|
627
|
+
rect.after(c)
|
|
628
|
+
} else if (!newNote && dot) dot.remove()
|
|
629
|
+
}
|
|
630
|
+
return new XMLSerializer().serializeToString(doc.documentElement)
|
|
631
|
+
}
|
|
632
|
+
function bindNotes($item, item) {
|
|
633
|
+
const box = $item.find('.graph-box').get(0)
|
|
634
|
+
if (!box || !graphOf(item).g) return
|
|
635
|
+
let card = null, hideT = 0, editing = false
|
|
636
|
+
const groups = box.querySelectorAll('g[id^="node-"], g[id^="edge-"]')
|
|
637
|
+
// Move each <title> into data-note so the browser's own tooltip does not double ours.
|
|
638
|
+
groups.forEach(gEl => {
|
|
639
|
+
const t = Array.from(gEl.children).find(c => c.localName === 'title')
|
|
640
|
+
if (t) { gEl.setAttribute('data-note', t.textContent); t.remove() }
|
|
641
|
+
})
|
|
642
|
+
const close = () => { editing = false; if (card) { card.remove(); card = null } }
|
|
643
|
+
const place = (ev) => {
|
|
644
|
+
if (!card || editing) return
|
|
645
|
+
const w = card.offsetWidth || 300, h = card.offsetHeight || 0
|
|
646
|
+
let x = ev.clientX + 14, y = ev.clientY - 10
|
|
647
|
+
if (x + w > window.innerWidth - 8) x = Math.max(8, ev.clientX - w - 14)
|
|
648
|
+
if (y + h > window.innerHeight - 8) y = Math.max(8, window.innerHeight - h - 8)
|
|
649
|
+
card.style.left = x + 'px'; card.style.top = y + 'px'
|
|
650
|
+
}
|
|
651
|
+
const show = (gEl, ev) => {
|
|
652
|
+
if (editing) return
|
|
653
|
+
clearTimeout(hideT)
|
|
654
|
+
const kind = gEl.id.startsWith('node-') ? 'node' : 'edge', id = gEl.id.slice(kind.length + 1)
|
|
655
|
+
const { g } = graphOf(item)
|
|
656
|
+
const obj = g && (kind === 'node' ? g.nodes : g.edges).find(o => String(o.id) === id)
|
|
657
|
+
const text = gEl.getAttribute('data-note') || ''
|
|
658
|
+
if (!obj || !text) { close(); return } // like the Graph Tool: a popup only where there is hover text
|
|
659
|
+
if (!card) {
|
|
660
|
+
card = document.createElement('div')
|
|
661
|
+
card.className = 'rcng-note-card'
|
|
662
|
+
card.style.cssText = 'position:fixed;z-index:3000;max-width:320px;background:rgba(255,255,255,.96);border:1px solid rgba(0,0,0,.1);border-radius:8px;box-shadow:0 2px 12px rgba(0,0,0,.18);padding:8px 12px;font:12px/1.55 system-ui,sans-serif;color:#0f172a;white-space:pre-wrap;word-break:break-word'
|
|
663
|
+
card.addEventListener('mouseenter', () => clearTimeout(hideT))
|
|
664
|
+
card.addEventListener('mouseleave', () => { if (!editing) hideT = setTimeout(close, 120) })
|
|
665
|
+
document.body.appendChild(card)
|
|
666
|
+
}
|
|
667
|
+
card.innerHTML = `<div>${esc(text)}</div>` +
|
|
668
|
+
`<div style="margin-top:6px;white-space:normal"><button class="rcng-note-edit" style="font:inherit;font-size:11px;padding:2px 8px;border:1px solid #c7d2fe;border-radius:5px;background:#fff;color:#3730a3;cursor:pointer" title="Change this note. It is saved into the drawing on this page.">✎ Edit note</button></div>`
|
|
669
|
+
card.querySelector('.rcng-note-edit').onclick = () => edit(gEl, kind, id, obj)
|
|
670
|
+
place(ev)
|
|
671
|
+
}
|
|
672
|
+
const edit = (gEl, kind, id, obj) => {
|
|
673
|
+
editing = true
|
|
674
|
+
const label = String(obj.label || '').replace(/\n/g, ' ')
|
|
675
|
+
card.style.width = '360px'; card.style.maxWidth = 'calc(100vw - 16px)'; card.style.whiteSpace = 'normal'
|
|
676
|
+
card.innerHTML = `<div style="font-weight:600;margin-bottom:4px">Note on “${esc(label || '(no label)')}”</div>
|
|
677
|
+
<textarea rows="6" style="width:100%;box-sizing:border-box;font:13px/1.4 system-ui,sans-serif;padding:5px 7px;border:1px solid #c7d2fe;border-radius:5px;resize:vertical" placeholder="What a reader should know about this: a quote, a source, a reason."></textarea>
|
|
678
|
+
<div style="display:flex;gap:6px;align-items:center;margin-top:6px">
|
|
679
|
+
<button class="rcng-note-save" style="font:inherit;font-size:11px;padding:2px 10px;border:1px solid #4f46e5;border-radius:5px;background:#4f46e5;color:#fff;font-weight:600;cursor:pointer">Save</button>
|
|
680
|
+
<button class="rcng-note-cancel" style="font:inherit;font-size:11px;padding:2px 8px;border:1px solid #c7d2fe;border-radius:5px;background:#fff;color:#3730a3;cursor:pointer">Cancel</button>
|
|
681
|
+
<span style="font-size:10px;color:#64748b;margin-left:auto">⌘/Ctrl-Enter saves · Esc cancels</span></div>`
|
|
682
|
+
const r = card.getBoundingClientRect()
|
|
683
|
+
if (r.right > window.innerWidth - 8) card.style.left = Math.max(8, window.innerWidth - r.width - 8) + 'px'
|
|
684
|
+
if (r.bottom > window.innerHeight - 8) card.style.top = Math.max(8, window.innerHeight - r.height - 8) + 'px'
|
|
685
|
+
const ta = card.querySelector('textarea')
|
|
686
|
+
ta.value = obj.note || ''
|
|
687
|
+
const save = () => {
|
|
688
|
+
const v = ta.value.replace(/\s+$/, '')
|
|
689
|
+
const old = obj.note || ''
|
|
690
|
+
close()
|
|
691
|
+
if (v === old) return
|
|
692
|
+
const { g, asText } = graphOf(item)
|
|
693
|
+
const o = g && (kind === 'node' ? g.nodes : g.edges).find(x => String(x.id) === id)
|
|
694
|
+
if (!o) return
|
|
695
|
+
o.note = v
|
|
696
|
+
const svg = item.svgString ? svgWithNote(item.svgString, kind, id, old, v) : null
|
|
697
|
+
item.graphJSON = asText ? JSON.stringify(g) : g
|
|
698
|
+
if (svg) item.svgString = svg
|
|
699
|
+
wiki.pageHandler.put($item.parents('.page:first'), { type: 'edit', id: item.id, item })
|
|
700
|
+
renderContent($item, item)
|
|
701
|
+
bind($item, item)
|
|
702
|
+
}
|
|
703
|
+
card.querySelector('.rcng-note-save').onclick = save
|
|
704
|
+
card.querySelector('.rcng-note-cancel').onclick = close
|
|
705
|
+
ta.addEventListener('keydown', e => {
|
|
706
|
+
e.stopPropagation()
|
|
707
|
+
if (e.key === 'Escape') { e.preventDefault(); close() }
|
|
708
|
+
else if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { e.preventDefault(); save() }
|
|
709
|
+
})
|
|
710
|
+
ta.addEventListener('dblclick', e => e.stopPropagation())
|
|
711
|
+
ta.focus()
|
|
712
|
+
}
|
|
713
|
+
groups.forEach(gEl => {
|
|
714
|
+
gEl.addEventListener('mouseenter', ev => show(gEl, ev))
|
|
715
|
+
gEl.addEventListener('mousemove', ev => place(ev))
|
|
716
|
+
gEl.addEventListener('mouseleave', () => { if (!editing) { clearTimeout(hideT); hideT = setTimeout(close, 150) } })
|
|
717
|
+
})
|
|
718
|
+
}
|
|
719
|
+
|
|
413
720
|
function bind($item, item) {
|
|
414
721
|
aboutMark($item, 'rcngraph')
|
|
722
|
+
bindNotes($item, item)
|
|
415
723
|
$item.on('click', '.open-graph, .edit-graph', () => {
|
|
416
724
|
pendingItem = item
|
|
417
725
|
pending$item = $item
|
|
@@ -452,6 +760,7 @@
|
|
|
452
760
|
// Walk playback. w === null: no walk open. token guards every voice callback,
|
|
453
761
|
// so a step that was skipped or stopped can never move the walk on.
|
|
454
762
|
const wk = { w: null, i: 0, playing: false, token: 0, heard: null }
|
|
763
|
+
const elG = $item.get(0)
|
|
455
764
|
const curWalk = () => { const g = graphModel(item); return g && wk.w !== null ? walkList(g)[wk.w] : null }
|
|
456
765
|
const stopVoice = () => { wk.token++; recHush(); try { if (window.speechSynthesis) speechSynthesis.cancel() } catch (e) {} }
|
|
457
766
|
const walkUI = note => {
|
|
@@ -476,8 +785,10 @@
|
|
|
476
785
|
if (!walk) return
|
|
477
786
|
wk.i = Math.max(0, Math.min(walk.steps.length - 1, i))
|
|
478
787
|
stopVoice()
|
|
788
|
+
elG.rcnFollow = null // leading now, not following
|
|
479
789
|
showWalkStep($item, g, walk, wk.i)
|
|
480
790
|
const st = walk.steps[wk.i]
|
|
791
|
+
if (RL) { const lit = stepLit(g, st); RL.step(elG, 'sketch', { eips: lit ? [...lit.nodes] : [], all: !lit, label: walk.name }) }
|
|
481
792
|
$item.find('.walk-say').text(st.say || '').css({ color: st.ask ? '#7c2d12' : '#1e1b4b', fontStyle: st.ask ? 'italic' : 'normal' })
|
|
482
793
|
walkUI()
|
|
483
794
|
if (wk.playing) walkSpeak()
|
|
@@ -509,9 +820,43 @@
|
|
|
509
820
|
if (g) showWalkStep($item, g, null, null)
|
|
510
821
|
wk.w = null
|
|
511
822
|
if (activeWalk === wk) activeWalk = null
|
|
823
|
+
if (RL) RL.end(elG, 'sketch')
|
|
512
824
|
walkUI()
|
|
513
825
|
}
|
|
514
826
|
wk.end = walkEnd
|
|
827
|
+
// Follow the other timeline, map and drawing items in the lineup, and the full
|
|
828
|
+
// tools in other tabs. A walk played elsewhere stops this one (and a build);
|
|
829
|
+
// a click elsewhere is ignored while either is open. A box is lit by its own
|
|
830
|
+
// id, as a drawing node or as a place (a sketch area and its map area share one id).
|
|
831
|
+
if (RL) RL.join(elG, 'sketch', msg => {
|
|
832
|
+
const g = graphModel(item)
|
|
833
|
+
if (!g || !$item.find('svg').length) return false
|
|
834
|
+
const walkStep = msg.type === 'rcn-walk' && !msg.end
|
|
835
|
+
if (wk.w !== null) { if (!walkStep) return false; walkEnd() }
|
|
836
|
+
if (buildIdx !== null) { if (!walkStep) return false; buildIdx = null; showBuildStep($item, g, null) }
|
|
837
|
+
const have = new Set(g.nodes.map(n => String(n.id)))
|
|
838
|
+
const mine = [...new Set([...(msg.eips || []), ...(msg.places || [])])].map(String).filter(id => have.has(id))
|
|
839
|
+
const was = elG.rcnFollow || null, f = RL.update(was, msg, mine)
|
|
840
|
+
if (f === was) return false
|
|
841
|
+
elG.rcnFollow = f
|
|
842
|
+
if (f && f.lit) showFollow($item, g, f); else showWalkStep($item, g, null, null)
|
|
843
|
+
return !!(f && f.lit)
|
|
844
|
+
})
|
|
845
|
+
// A click on a box lights it in the items beside it. Its label still opens its
|
|
846
|
+
// page when nothing beside it lights up; shift-click always opens the page, at
|
|
847
|
+
// the end of the lineup. A click on the empty drawing lets go.
|
|
848
|
+
const nodeOf = t => { const n = t && t.closest && t.closest('g[id^="node-"]'); return n ? n.id.slice(5) : null }
|
|
849
|
+
const followNode = (id, label) => {
|
|
850
|
+
if (!RL || wk.w !== null || buildIdx !== null) return 0
|
|
851
|
+
if (elG.rcnFollow) { elG.rcnFollow = null; showWalkStep($item, graphModel(item), null, null) }
|
|
852
|
+
return RL.click(elG, 'sketch', { eip: id, label })
|
|
853
|
+
}
|
|
854
|
+
$item.off('click.rcnfollow').on('click.rcnfollow', '.graph-box svg', e => {
|
|
855
|
+
if ($(e.target).closest('a.internal').length) return
|
|
856
|
+
const id = nodeOf(e.target)
|
|
857
|
+
if (id) followNode(id)
|
|
858
|
+
else if (RL && elG.rcnClicked) RL.click(elG, 'sketch', { clear: true })
|
|
859
|
+
})
|
|
515
860
|
$item.off('.rcnwalk')
|
|
516
861
|
$item.on('click.rcnwalk', '.walk-start', () => {
|
|
517
862
|
const g = graphModel(item)
|
|
@@ -577,8 +922,10 @@
|
|
|
577
922
|
$item.off('click.rcnlink').on('click.rcnlink', 'svg a.internal', e => {
|
|
578
923
|
e.preventDefault()
|
|
579
924
|
e.stopPropagation()
|
|
580
|
-
const title = e.currentTarget.getAttribute('data-title')
|
|
581
|
-
if (
|
|
925
|
+
const title = e.currentTarget.getAttribute('data-title'), id = nodeOf(e.currentTarget)
|
|
926
|
+
if (!e.shiftKey && id && followNode(id, title)) return
|
|
927
|
+
// beside items that follow, open it at the end so they stay open
|
|
928
|
+
if (title) wiki.doInternalLink(title, e.shiftKey || (RL && RL.others(elG)) ? null : $item.parents('.page:first'))
|
|
582
929
|
})
|
|
583
930
|
}
|
|
584
931
|
|
package/package.json
CHANGED
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
"id": "8e7e435485d56e9e",
|
|
32
32
|
"text": "Walks: a diagram can also carry walks, written in the Graph Tool (press Walk there to play, edit or record one). A walk is a list of steps, each with a sentence or two and the part of the diagram it is about. The item shows a ▶ Walk button: each step lights its part, fades the rest, zooms in so a narrow column can read it, and says the words aloud with the browser’s own voice while showing them as a caption. Space pauses, ◀ ▶ or the arrow keys step, Esc stops, and clicking the drawing pauses so you can look. A walk stops at its questions so a group can talk. Voice off shows the words only. The voice and its speed are chosen in the Graph Tool and remembered by your browser."
|
|
33
33
|
},
|
|
34
|
+
{
|
|
35
|
+
"type": "paragraph",
|
|
36
|
+
"id": "f2b474457cb3f7bd",
|
|
37
|
+
"text": "Following. Put this page in a lineup beside pages with an RCN timeline, map or drawing, and the items follow each other. Press ▶ Walk in any of them: each step lights what it is about there, and the others light what is related to it: full strength for this step, half for earlier steps, the rest faded. Click a box and the timeline lights the bars about it, and the map their places. The others light where it is for them. Click empty space to let go. The timeline's bars are the bridges: each bar names a place on the map (place) and a box in the drawing (eip). One walk plays at a time, and starting one stops the others. A click that lights nothing beside it opens its page as before; beside items that follow, the page opens at the end of the lineup so they stay open, and shift-click always opens it. The full Timeline, Map and Graph Tool, opened from this wiki's assets in another tab, follow too, and lead too."
|
|
38
|
+
},
|
|
34
39
|
{
|
|
35
40
|
"type": "rcngraph",
|
|
36
41
|
"id": "8d4e2a7f1c9b3065",
|
|
@@ -186,6 +191,17 @@
|
|
|
186
191
|
"text": "Developed by Marc Pierson with Claude Sonnet 4.6 (Anthropic) for the ReLocalize Creativity Network. Build playback and walks added October 2026 with Claude Opus 5.5. Source: [https://github.com/marpie1/wiki-plugin-rcngraph GitHub]. Published on npm as wiki-plugin-rcngraph."
|
|
187
192
|
},
|
|
188
193
|
"date": 1792602075758
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"type": "add",
|
|
197
|
+
"id": "f2b474457cb3f7bd",
|
|
198
|
+
"item": {
|
|
199
|
+
"type": "paragraph",
|
|
200
|
+
"id": "f2b474457cb3f7bd",
|
|
201
|
+
"text": "Following. Put this page in a lineup beside pages with an RCN timeline, map or drawing, and the items follow each other. Press ▶ Walk in any of them: each step lights what it is about there, and the others light what is related to it: full strength for this step, half for earlier steps, the rest faded. Click a box and the timeline lights the bars about it, and the map their places. The others light where it is for them. Click empty space to let go. The timeline's bars are the bridges: each bar names a place on the map (place) and a box in the drawing (eip). One walk plays at a time, and starting one stops the others. A click that lights nothing beside it opens its page as before; beside items that follow, the page opens at the end of the lineup so they stay open, and shift-click always opens it. The full Timeline, Map and Graph Tool, opened from this wiki's assets in another tab, follow too, and lead too."
|
|
202
|
+
},
|
|
203
|
+
"after": "8e7e435485d56e9e",
|
|
204
|
+
"date": 1794193621097
|
|
189
205
|
}
|
|
190
206
|
]
|
|
191
207
|
}
|