starlight-annotations 0.8.0 → 0.9.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # starlight-annotations
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 61b2bef: Notes can have a kind (question, problem, proposal or decision), shown as a label and filtered on the overview page. **+ Note on this page** writes a note about the whole page rather than a passage. In the file, a thread has an optional `kind`, and a page note has a `target` without a `selector`. Slack and Teams titles name the kind ("Ada added a question on …").
8
+
3
9
  ## 0.8.0
4
10
 
5
11
  ### Minor Changes
package/index.d.ts CHANGED
@@ -68,6 +68,15 @@ export type AnnotationStrings = {
68
68
  fresh: string;
69
69
  freshCount: string;
70
70
  mentions: string;
71
+ kind: string;
72
+ noKind: string;
73
+ allKinds: string;
74
+ kindQuestion: string;
75
+ kindIssue: string;
76
+ kindProposal: string;
77
+ kindDecision: string;
78
+ wholePage: string;
79
+ pageNote: string;
71
80
  };
72
81
 
73
82
  export interface StarlightAnnotationsOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-annotations",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "🖍️ Let readers highlight text and leave notes on Starlight docs. Notes are committed to your Git repository on GitHub, GitLab, Gitea or Forgejo.",
5
5
  "license": "MIT",
6
6
  "author": "Alessandro Rosa",
@@ -12,7 +12,7 @@ import { anchor, buildIndex as indexText, skipSelector } from './anchoring.js';
12
12
  import { strings } from './i18n.js';
13
13
  import { isNew, knownPeople, markSeen, rememberPeople, seenTimes } from './memory.js';
14
14
  import { attachMentions } from './mentions.js';
15
- import { h, loadMarkdown, quoteText, renderMarkdown } from './shared.js';
15
+ import { h, kindLabel, KINDS, loadMarkdown, quoteText, renderMarkdown } from './shared.js';
16
16
 
17
17
  const BASE = import.meta.env.BASE_URL.replace(/\/$/, '');
18
18
  const SKIP = skipSelector(config.exclude);
@@ -253,6 +253,7 @@ async function start(root) {
253
253
  state.index = buildIndex(root);
254
254
  state.anchors.clear();
255
255
  for (const thread of threads()) {
256
+ if (!thread.target?.selector) continue;
256
257
  const found = anchor(state.index, thread.target.selector);
257
258
  if (found) state.anchors.set(thread.id, { start: found[0], end: found[1], range: rangeFor(state.index, ...found) });
258
259
  }
@@ -320,9 +321,20 @@ async function start(root) {
320
321
  );
321
322
  }
322
323
 
323
- function editor(placeholder, onSave, onCancel, initial = '') {
324
+ // `kind` is given for the first note of a thread (null when it has none):
325
+ // the editor then lets the writer pick one. onSave gets (text, kind).
326
+ function editor(placeholder, onSave, onCancel, { initial = '', kind } = {}) {
324
327
  const area = h('textarea', { rows: 4, placeholder, maxlength: 5000, 'aria-label': placeholder });
325
328
  area.value = initial;
329
+ const kindSelect =
330
+ kind === undefined
331
+ ? null
332
+ : h(
333
+ 'select',
334
+ { class: 'annot-kind-select', 'aria-label': T.kind },
335
+ h('option', { value: '' }, T.noKind),
336
+ KINDS.map((value) => h('option', { value, selected: kind === value }, kindLabel(value, T))),
337
+ );
326
338
  const mentions = attachMentions(
327
339
  area,
328
340
  () =>
@@ -376,7 +388,7 @@ async function start(root) {
376
388
  save.addEventListener('click', async () => {
377
389
  if (!area.value.trim()) return area.focus();
378
390
  busy(true);
379
- const ok = await onSave(area.value);
391
+ const ok = await onSave(area.value, kindSelect ? kindSelect.value || null : undefined);
380
392
  if (!ok) busy(false);
381
393
  });
382
394
  area.addEventListener('keydown', (event) => {
@@ -405,13 +417,16 @@ async function start(root) {
405
417
  'div',
406
418
  { class: 'annot-actions' },
407
419
  save,
420
+ kindSelect,
408
421
  h('button', { type: 'button', onclick: onCancel }, T.cancel),
409
422
  h('a', { class: 'annot-hint', href: 'https://www.markdownguide.org/basic-syntax/', target: '_blank', rel: 'noopener noreferrer' }, T.markdown),
410
423
  ),
411
424
  );
412
425
  }
413
426
 
427
+ // The quoted passage, or "Whole page" for a note about the page.
414
428
  function quote(selector) {
429
+ if (!selector) return h('div', { class: 'annot-quote annot-whole-page' }, T.wholePage);
415
430
  return h('blockquote', { class: 'annot-quote' }, quoteText(selector));
416
431
  }
417
432
 
@@ -437,6 +452,7 @@ async function start(root) {
437
452
  }
438
453
 
439
454
  function threadCard(thread, anchored) {
455
+ const whole = !thread.target?.selector;
440
456
  const card = h('article', {
441
457
  class: `annot-thread${thread.resolved ? ' resolved' : ''}${state.active === thread.id ? ' active' : ''}`,
442
458
  'data-id': thread.id,
@@ -485,24 +501,25 @@ async function start(root) {
485
501
  if (state.editing !== item.id || !own(item)) return renderMarkdown(h('div', { class: 'annot-text annot-md' }), item.body);
486
502
  return editor(
487
503
  item.replyTo ? T.replyPlaceholder : T.placeholder,
488
- async (value) => {
489
- if (value.trim() === item.body) {
504
+ async (value, kind) => {
505
+ const sameKind = kind === undefined || kind === (item.kind ?? null);
506
+ if (value.trim() === item.body && sameKind) {
490
507
  stopEditing();
491
508
  return true;
492
509
  }
493
- const saved = await send({ action: 'edit', id: item.id, body: value });
510
+ const saved = await send({ action: 'edit', id: item.id, body: value, ...(kind === undefined ? {} : { kind }) });
494
511
  if (!saved) return false;
495
512
  stopEditing();
496
513
  return true;
497
514
  },
498
515
  stopEditing,
499
- item.body,
516
+ { initial: item.body, kind: item.replyTo ? undefined : (item.kind ?? null) },
500
517
  );
501
518
  }
502
519
 
503
520
  // A thread whose text is gone: attach it to the passage it is about now.
504
521
  function moveBox() {
505
- if (anchored || !state.user) return [];
522
+ if (anchored || whole || !state.user) return [];
506
523
  if (state.moving !== thread.id)
507
524
  return [h('div', { class: 'annot-actions' }, h('button', { type: 'button', onclick: () => startMoving(thread.id) }, T.move))];
508
525
  return [
@@ -519,8 +536,9 @@ async function start(root) {
519
536
  h(
520
537
  'button',
521
538
  { type: 'button', class: 'annot-quote-button', disabled: !anchored, onclick: () => focusThread(thread.id, true) },
522
- quote(thread.target.selector),
539
+ quote(thread.target?.selector),
523
540
  ),
541
+ ...(thread.kind ? [h('span', { class: `annot-kind annot-kind-${thread.kind}` }, kindLabel(thread.kind, T))] : []),
524
542
  ...(thread.resolved ? [h('span', { class: 'annot-badge' }, T.resolved)] : []),
525
543
  ...moveBox(),
526
544
  h('div', { class: `annot-message${fresh(thread) ? ' annot-fresh' : ''}`, 'data-msg': thread.id }, meta(thread), text(thread)),
@@ -566,8 +584,11 @@ async function start(root) {
566
584
  freshCount.hidden = news === 0;
567
585
  freshCount.textContent = T.freshCount.replace('{n}', String(news));
568
586
  const parts = [];
569
- if (state.user) parts.push(userLine());
570
- else parts.push(loginLink());
587
+ if (state.user) {
588
+ parts.push(userLine());
589
+ if (!state.pending && !state.moving)
590
+ parts.push(h('button', { type: 'button', class: 'annot-page-note', onclick: () => composePageNote() }, `+ ${T.pageNote}`));
591
+ } else parts.push(loginLink());
571
592
  if (state.error) parts.push(h('p', { class: 'annot-error', role: 'alert' }, state.error));
572
593
  if (state.pending) {
573
594
  parts.push(
@@ -575,12 +596,12 @@ async function start(root) {
575
596
  'section',
576
597
  { class: 'annot-new' },
577
598
  h('strong', {}, T.newNote),
578
- quote(state.pending),
599
+ quote(state.pending.type === 'Page' ? null : state.pending),
579
600
  state.user
580
601
  ? editor(
581
602
  T.placeholder,
582
- async (text) => {
583
- const created = await send({ action: 'create', target: state.pending, body: text });
603
+ async (text, kind) => {
604
+ const created = await send({ action: 'create', target: state.pending, body: text, ...(kind ? { kind } : {}) });
584
605
  if (!created) return false;
585
606
  state.pending = null;
586
607
  focusThread(created.id, false);
@@ -590,6 +611,7 @@ async function start(root) {
590
611
  state.pending = null;
591
612
  render();
592
613
  },
614
+ { kind: null },
593
615
  )
594
616
  : loginLink(),
595
617
  ),
@@ -598,9 +620,12 @@ async function start(root) {
598
620
  const anchored = all
599
621
  .filter((thread) => visible(thread) && state.anchors.has(thread.id))
600
622
  .sort((a, b) => state.anchors.get(a.id).start - state.anchors.get(b.id).start);
601
- const orphans = all.filter((thread) => visible(thread) && !state.anchors.has(thread.id));
623
+ // Notes about the whole page come first; they have no passage to lose.
624
+ const whole = all.filter((thread) => visible(thread) && !thread.target?.selector);
625
+ const orphans = all.filter((thread) => visible(thread) && thread.target?.selector && !state.anchors.has(thread.id));
602
626
  if (all.length === 0 && !state.pending)
603
627
  parts.push(h('p', { class: 'annot-empty' }, T.empty, overviewUrl ? [' ', h('a', { href: overviewUrl }, T.seeAll)] : null));
628
+ parts.push(...whole.map((thread) => threadCard(thread, false)));
604
629
  parts.push(...anchored.map((thread) => threadCard(thread, true)));
605
630
  if (orphans.length) parts.push(h('h3', { class: 'annot-orphans' }, T.orphans), ...orphans.map((thread) => threadCard(thread, false)));
606
631
  body.replaceChildren(...parts.filter(Boolean));
@@ -668,6 +693,13 @@ async function start(root) {
668
693
  selectButton.style.left = `${Math.min(window.scrollX + rect.right - selectButton.offsetWidth, window.scrollX + document.documentElement.clientWidth - selectButton.offsetWidth - 8)}px`;
669
694
  }
670
695
 
696
+ function composePageNote() {
697
+ loadMarkdown();
698
+ state.pending = { type: 'Page' };
699
+ render();
700
+ setOpen(true);
701
+ }
702
+
671
703
  async function compose() {
672
704
  if (!selected) return;
673
705
  if (state.moving) {
@@ -69,6 +69,15 @@ const en = {
69
69
  fresh: 'New',
70
70
  freshCount: '{n} new',
71
71
  mentions: 'People',
72
+ kind: 'Type',
73
+ noKind: 'No type',
74
+ allKinds: 'All types',
75
+ kindQuestion: 'Question',
76
+ kindIssue: 'Problem',
77
+ kindProposal: 'Proposal',
78
+ kindDecision: 'Decision',
79
+ wholePage: 'Whole page',
80
+ pageNote: 'Note on this page',
72
81
  };
73
82
 
74
83
  const it = {
@@ -139,6 +148,15 @@ const it = {
139
148
  fresh: 'Nuova',
140
149
  freshCount: '{n} nuove',
141
150
  mentions: 'Persone',
151
+ kind: 'Tipo',
152
+ noKind: 'Nessun tipo',
153
+ allKinds: 'Tutti i tipi',
154
+ kindQuestion: 'Domanda',
155
+ kindIssue: 'Problema',
156
+ kindProposal: 'Proposta',
157
+ kindDecision: 'Decisione',
158
+ wholePage: 'Tutta la pagina',
159
+ pageNote: 'Nota sulla pagina',
142
160
  };
143
161
 
144
162
  const de = {
@@ -209,6 +227,15 @@ const de = {
209
227
  fresh: 'Neu',
210
228
  freshCount: '{n} neu',
211
229
  mentions: 'Personen',
230
+ kind: 'Art',
231
+ noKind: 'Ohne Art',
232
+ allKinds: 'Alle Arten',
233
+ kindQuestion: 'Frage',
234
+ kindIssue: 'Problem',
235
+ kindProposal: 'Vorschlag',
236
+ kindDecision: 'Entscheidung',
237
+ wholePage: 'Ganze Seite',
238
+ pageNote: 'Notiz zur Seite',
212
239
  };
213
240
 
214
241
  const fr = {
@@ -279,6 +306,15 @@ const fr = {
279
306
  fresh: 'Nouveau',
280
307
  freshCount: '{n} nouveaux',
281
308
  mentions: 'Personnes',
309
+ kind: 'Type',
310
+ noKind: 'Sans type',
311
+ allKinds: 'Tous les types',
312
+ kindQuestion: 'Question',
313
+ kindIssue: 'Problème',
314
+ kindProposal: 'Proposition',
315
+ kindDecision: 'Décision',
316
+ wholePage: 'Toute la page',
317
+ pageNote: 'Note sur la page',
282
318
  };
283
319
 
284
320
  const es = {
@@ -349,6 +385,15 @@ const es = {
349
385
  fresh: 'Nueva',
350
386
  freshCount: '{n} nuevas',
351
387
  mentions: 'Personas',
388
+ kind: 'Tipo',
389
+ noKind: 'Sin tipo',
390
+ allKinds: 'Todos los tipos',
391
+ kindQuestion: 'Pregunta',
392
+ kindIssue: 'Problema',
393
+ kindProposal: 'Propuesta',
394
+ kindDecision: 'Decisión',
395
+ wholePage: 'Toda la página',
396
+ pageNote: 'Nota sobre la página',
352
397
  };
353
398
 
354
399
  export const builtIn = { en, it, de, fr, es };
@@ -5,7 +5,7 @@ import { anchor, buildIndex, skipSelector } from './anchoring.js';
5
5
  import { createBackend } from './backend.js';
6
6
  import { strings } from './i18n.js';
7
7
  import { isNew, rememberPeople, seenTimes } from './memory.js';
8
- import { h, quoteText, renderMarkdown } from './shared.js';
8
+ import { h, kindLabel, KINDS, quoteText, renderMarkdown } from './shared.js';
9
9
 
10
10
  const BASE = import.meta.env.BASE_URL.replace(/\/$/, '');
11
11
  const T = strings(document.documentElement.lang, config.translations);
@@ -53,6 +53,7 @@ async function start(container) {
53
53
  status: ['open', 'new', 'changed', 'resolved', 'all'].includes(params.get('status')) ? params.get('status') : 'open',
54
54
  author: params.get('author') ?? '',
55
55
  text: params.get('q') ?? '',
56
+ kind: KINDS.includes(params.get('kind')) || params.get('kind') === 'none' ? params.get('kind') : '',
56
57
  };
57
58
 
58
59
  const changed = new Set(); // ids of open threads whose text is gone
@@ -82,6 +83,18 @@ async function start(container) {
82
83
  .sort((a, b) => a[1].localeCompare(b[1]))
83
84
  .map(([login, name]) => h('option', { value: login, selected: state.author === login }, name)),
84
85
  );
86
+ const kind = h(
87
+ 'select',
88
+ { onchange: (event) => update({ kind: event.target.value }) },
89
+ h('option', { value: '' }, T.allKinds),
90
+ [...KINDS, 'none'].map((value) =>
91
+ h(
92
+ 'option',
93
+ { value, selected: state.kind === value },
94
+ `${value === 'none' ? T.noKind : kindLabel(value, T)} (${threads.filter((entry) => (entry.thread.kind ?? 'none') === value).length})`,
95
+ ),
96
+ ),
97
+ );
85
98
  const search = h('input', {
86
99
  type: 'search',
87
100
  value: state.text,
@@ -96,6 +109,7 @@ async function start(container) {
96
109
  { class: 'annot-overview-filters not-content' },
97
110
  h('label', {}, T.showing, status),
98
111
  h('label', {}, T.author, author),
112
+ h('label', {}, T.kind, kind),
99
113
  search,
100
114
  ),
101
115
  list,
@@ -106,6 +120,7 @@ async function start(container) {
106
120
  const query = new URLSearchParams();
107
121
  if (state.status !== 'open') query.set('status', state.status);
108
122
  if (state.author) query.set('author', state.author);
123
+ if (state.kind) query.set('kind', state.kind);
109
124
  if (state.text) query.set('q', state.text);
110
125
  const qs = String(query);
111
126
  history.replaceState(null, '', `${location.pathname}${qs ? `?${qs}` : ''}`);
@@ -118,10 +133,12 @@ async function start(container) {
118
133
  if (state.status === 'resolved' && !thread.resolved) return false;
119
134
  if (state.status === 'changed' && (thread.resolved || !changed.has(thread.id))) return false;
120
135
  const messages = [thread, ...replies];
136
+ if (state.kind && (thread.kind ?? 'none') !== state.kind) return false;
121
137
  if (state.author && !messages.some((item) => item.author.login === state.author)) return false;
122
138
  const text = state.text.trim().toLowerCase();
123
139
  if (!text) return true;
124
- return [quoteText(thread.target.selector), ...messages.map((item) => item.body)].some((value) => value.toLowerCase().includes(text));
140
+ const quoted = thread.target?.selector ? quoteText(thread.target.selector) : '';
141
+ return [quoted, ...messages.map((item) => item.body)].some((value) => value.toLowerCase().includes(text));
125
142
  }
126
143
 
127
144
  function card({ page, thread, replies, fresh }) {
@@ -130,7 +147,10 @@ async function start(container) {
130
147
  return h(
131
148
  'article',
132
149
  { class: `annot-thread annot-overview-card${thread.resolved ? ' resolved' : ''}` },
133
- h('blockquote', { class: 'annot-quote' }, quoteText(thread.target.selector)),
150
+ thread.target?.selector
151
+ ? h('blockquote', { class: 'annot-quote' }, quoteText(thread.target.selector))
152
+ : h('div', { class: 'annot-quote annot-whole-page' }, T.wholePage),
153
+ thread.kind ? h('span', { class: `annot-kind annot-kind-${thread.kind}` }, kindLabel(thread.kind, T)) : null,
134
154
  h(
135
155
  'div',
136
156
  { class: 'annot-meta' },
@@ -189,7 +209,7 @@ async function start(container) {
189
209
  if (!root) return; // Not a page we can read: say nothing.
190
210
  const index = buildIndex(root, skip);
191
211
  for (const entry of threads)
192
- if (entry.page === page && !entry.thread.resolved && !anchor(index, entry.thread.target.selector)) changed.add(entry.thread.id);
212
+ if (entry.page === page && !entry.thread.resolved && entry.thread.target?.selector && !anchor(index, entry.thread.target.selector)) changed.add(entry.thread.id);
193
213
  });
194
214
  counts.changed = changed.size;
195
215
  status.querySelector('option[value="changed"]').textContent = option('changed');
@@ -71,3 +71,10 @@ export function quoteText(selector) {
71
71
  const exact = squash(selector.exact);
72
72
  return exact.length > 220 ? `${exact.slice(0, 130).trimEnd()} … ${exact.slice(-70).trimStart()}` : exact;
73
73
  }
74
+
75
+ export { KINDS } from '../core.js';
76
+
77
+ // "question" -> T.kindQuestion
78
+ export function kindLabel(kind, T) {
79
+ return T[`kind${kind[0].toUpperCase()}${kind.slice(1)}`] ?? kind;
80
+ }
@@ -201,6 +201,39 @@
201
201
  .annot-mentions li span {
202
202
  color: var(--sl-color-gray-3);
203
203
  }
204
+ .annot-kind {
205
+ align-self: flex-start;
206
+ padding: 0 0.4rem;
207
+ border-radius: 0.25rem;
208
+ font-size: var(--sl-text-xs);
209
+ font-weight: 600;
210
+ }
211
+ .annot-kind-question {
212
+ background: var(--sl-color-blue-low);
213
+ color: var(--sl-color-blue-high);
214
+ }
215
+ .annot-kind-issue {
216
+ background: var(--sl-color-red-low);
217
+ color: var(--sl-color-red-high);
218
+ }
219
+ .annot-kind-proposal {
220
+ background: var(--sl-color-green-low);
221
+ color: var(--sl-color-green-high);
222
+ }
223
+ .annot-kind-decision {
224
+ background: var(--sl-color-purple-low);
225
+ color: var(--sl-color-purple-high);
226
+ }
227
+ .annot-whole-page {
228
+ border-left-style: dashed;
229
+ font-style: normal;
230
+ }
231
+ .annot-page-note {
232
+ align-self: flex-start;
233
+ }
234
+ .annot-kind-select {
235
+ margin-left: auto;
236
+ }
204
237
  .annot-badge.annot-changed {
205
238
  margin-left: 0.4rem;
206
239
  background: var(--sl-color-orange-low);
package/src/core.js CHANGED
@@ -15,6 +15,9 @@ const MAX_EXACT = 2000;
15
15
  const MAX_EDGE = 200;
16
16
  const MAX_CONTEXT = 64;
17
17
 
18
+ // What a thread is, when its writer says: shown as a label, used as a filter.
19
+ export const KINDS = ['question', 'issue', 'proposal', 'decision'];
20
+
18
21
  export class AnnotationError extends Error {
19
22
  constructor(status, message) {
20
23
  super(message);
@@ -102,11 +105,24 @@ function selector(target) {
102
105
  };
103
106
  }
104
107
 
108
+ // A thread is about a passage (a selector), or about the whole page:
109
+ // `target: { type: 'Page' }` in the change, stored as a target without a
110
+ // selector.
111
+ function targetOf(target) {
112
+ return target?.type === 'Page' ? {} : { selector: selector(target) };
113
+ }
114
+
115
+ function kindOf(value) {
116
+ if (value === undefined || value === null || value === '') return undefined;
117
+ if (!KINDS.includes(value)) throw new AnnotationError(400, 'Unknown kind.');
118
+ return value;
119
+ }
120
+
105
121
  // A change is one of:
106
- // { action: 'create', target: { exact, prefix, suffix }, body }
122
+ // { action: 'create', target: { exact, prefix, suffix } | { type: 'Page' }, body, kind? }
107
123
  // { action: 'reply', replyTo, body }
108
124
  // { action: 'resolve', id, resolved }
109
- // { action: 'edit', id, body } the author changes their message
125
+ // { action: 'edit', id, body, kind? } the author changes their message
110
126
  // { action: 'anchor', id, target } a thread moves to another passage
111
127
  // { action: 'delete', id }
112
128
  // It returns the annotation it touched, and a commit message.
@@ -127,10 +143,12 @@ export function applyChange(doc, change, user, now = new Date()) {
127
143
  id: crypto.randomUUID(),
128
144
  created,
129
145
  author: writer,
130
- target: { selector: selector(change.target) },
146
+ target: targetOf(change.target),
131
147
  body: text(change.body, MAX_BODY, 'note'),
132
148
  resolved: false,
133
149
  };
150
+ const kind = kindOf(change.kind);
151
+ if (kind) annotation.kind = kind;
134
152
  doc.annotations.push(annotation);
135
153
  return { annotation, message: `docs(annotations): note on ${doc.page}` };
136
154
  }
@@ -161,6 +179,12 @@ export function applyChange(doc, change, user, now = new Date()) {
161
179
  const annotation = find(change.id);
162
180
  if (annotation.author?.login !== user.login) throw new AnnotationError(403, 'Only the author can edit a note.');
163
181
  annotation.body = text(change.body, MAX_BODY, annotation.replyTo ? 'reply' : 'note');
182
+ // A thread's kind changes with it; leaving `kind` out keeps it.
183
+ if (!annotation.replyTo && 'kind' in change) {
184
+ const kind = kindOf(change.kind);
185
+ if (kind) annotation.kind = kind;
186
+ else delete annotation.kind;
187
+ }
164
188
  annotation.edited = created;
165
189
  return { annotation, message: `docs(annotations): edit note on ${doc.page}` };
166
190
  }
@@ -169,7 +193,7 @@ export function applyChange(doc, change, user, now = new Date()) {
169
193
  // attaches the thread to the passage it is now about.
170
194
  const annotation = find(change.id);
171
195
  if (annotation.replyTo) throw new AnnotationError(400, 'Only a thread can be moved.');
172
- annotation.target = { selector: selector(change.target) };
196
+ annotation.target = targetOf(change.target);
173
197
  annotation.movedBy = author;
174
198
  annotation.movedAt = created;
175
199
  return { annotation, message: `docs(annotations): move note on ${doc.page}` };
@@ -57,8 +57,10 @@ export function quoteOf(thread) {
57
57
  */
58
58
  export function describeChange(event) {
59
59
  const who = event.user.name;
60
+ // "Ada added a question on …" when the note has a kind.
61
+ const what = { question: 'a question', issue: 'a problem', proposal: 'a proposal', decision: 'a decision' }[event.annotation?.kind] ?? 'a note';
60
62
  const title = {
61
- create: `${who} added a note on ${event.page}`,
63
+ create: `${who} added ${what} on ${event.page}`,
62
64
  reply: `${who} replied on ${event.page}`,
63
65
  resolve: `${who} resolved a note on ${event.page}`,
64
66
  reopen: `${who} reopened a note on ${event.page}`,