@gbti/ryker 0.2.3 → 0.2.5

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 CHANGED
@@ -10,6 +10,10 @@ first, or that a summary buries its own conclusion. Those corrections are
10
10
  structural and they are yours, and the usual place to make them is back in the
11
11
  prompt, describing a document you are looking at but cannot touch.
12
12
 
13
+ [![Ryker: edit an authored HTML page inline and export the corrections as agent-ready instructions](https://img.youtube.com/vi/o0HQG7Ie5zY/maxresdefault.jpg)](https://youtu.be/o0HQG7Ie5zY)
14
+
15
+ **[Watch the three minute walkthrough](https://youtu.be/o0HQG7Ie5zY).**
16
+
13
17
  ## Why inline
14
18
 
15
19
  HTML has become a useful format for delivering rich content when working with
@@ -30,8 +34,9 @@ that document in place. Or open the Ryker workspace and load a Markdown or HTML
30
34
  file from your own disk. On a tab Chrome will not let it touch, a new tab or a
31
35
  `chrome://` page, the button opens the workspace instead of failing.
32
36
 
33
- Ryker is not on the Chrome Web Store yet. Until it is listed, load it unpacked
34
- from [`extension/`](extension/README.md).
37
+ [Add Ryker to Chrome](https://chromewebstore.google.com/detail/ryker/gohpdgonoaihfjfhhjioaejhnhhjmkkp)
38
+ from the Chrome Web Store, or load it unpacked from
39
+ [`extension/`](extension/README.md).
35
40
 
36
41
  **As a drop-in.** Add Ryker to an HTML document with npx and it travels with the
37
42
  file. A reader or reviewer can then edit the page and produce a change request
@@ -78,7 +83,7 @@ it.
78
83
  Ryker requires Node.js 20 or newer for installation. The resulting HTML and
79
84
  classic browser script work offline and from `file://` without Node.js.
80
85
 
81
- This repository is at version `0.2.3`, and the npm `latest` tag serves it, so
86
+ This repository is at version `0.2.5`, and the npm `latest` tag serves it, so
82
87
  every `npx` command above installs this code.
83
88
 
84
89
  ## Privacy
package/bin/ryker.js CHANGED
@@ -4,7 +4,7 @@ import { copyFileSync, existsSync, mkdirSync, readFileSync, realpathSync, writeF
4
4
  import { basename, dirname, extname, isAbsolute, relative, resolve, sep } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
 
7
- const VERSION = '0.2.3';
7
+ const VERSION = '0.2.5';
8
8
  const BEGIN = '<!-- ryker:begin -->';
9
9
  const END = '<!-- ryker:end -->';
10
10
  const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Ryker 0.2.3
2
+ * Ryker 0.2.5
3
3
  * A drop-in editing layer for authored HTML reports.
4
4
  *
5
5
  * Generated bundle. Do not edit. Sources, in load order:
@@ -20,10 +20,10 @@
20
20
  * ui/tooltip.js (82 lines)
21
21
  * ui/dialog.js (138 lines)
22
22
  * ui/menu.js (104 lines)
23
- * ui/about.js (77 lines)
23
+ * ui/about.js (80 lines)
24
24
  * export/dialog.js (213 lines)
25
- * editor/editable.js (596 lines)
26
- * editor/history.js (248 lines)
25
+ * editor/editable.js (600 lines)
26
+ * editor/history.js (276 lines)
27
27
  * editor/formatbar.js (252 lines)
28
28
  * editor/links.js (173 lines)
29
29
  * editor/pick.js (228 lines)
@@ -50,7 +50,7 @@
50
50
  (function () {
51
51
  'use strict';
52
52
  if (window.Ryker && window.Ryker.VERSION) return;
53
- var Ryker = { VERSION: "0.2.3", BUILD: "Ryker", SURFACE: "drop-in" };
53
+ var Ryker = { VERSION: "0.2.5", BUILD: "Ryker", SURFACE: "drop-in" };
54
54
  window.Ryker = Ryker;
55
55
 
56
56
  /* ---- utils/dom.js ---------------------------------------------- */
@@ -3427,8 +3427,11 @@
3427
3427
  // The only break point is before the ampersand, so the label reads
3428
3428
  // "Contributions" then "& Gratuity" rather than stranding the & at the
3429
3429
  // end of the first line.
3430
+ // The verb belongs inside the link. "Join our professional network" is
3431
+ // the action; a link that starts at "our" asks the reader to work out
3432
+ // what clicking it does.
3430
3433
  row('Contributions &amp;\u00a0Gratuity',
3431
- 'Join ' + link(LINKS.membership, 'our professional network') +
3434
+ link(LINKS.membership, 'Join our professional network') +
3432
3435
  ' to support Ryker and other projects developed and maintained by ' +
3433
3436
  'GBTI Network.', 'cta') +
3434
3437
  '</dl>'
@@ -3706,7 +3709,11 @@
3706
3709
  var clean = Ryker.sanitize.fromClipboard(e);
3707
3710
  if (clean == null) return;
3708
3711
  e.preventDefault();
3712
+ // A cancelled paste fires no beforeinput, and insertHtml moves nodes
3713
+ // with Range, which fires nothing either, so the stack has to be told.
3714
+ Ryker.history.textBefore(n);
3709
3715
  insertHtml(clean);
3716
+ Ryker.history.flush();
3710
3717
  mark(n, id);
3711
3718
  },
3712
3719
  drop: function (e) {
@@ -3745,7 +3752,9 @@
3745
3752
  // an edit.
3746
3753
  if (n.tagName === 'TD' || n.tagName === 'TH') {
3747
3754
  e.preventDefault();
3755
+ Ryker.history.textBefore(n);
3748
3756
  try { document.execCommand('insertLineBreak'); } catch (err) {}
3757
+ Ryker.history.flush();
3749
3758
  return;
3750
3759
  }
3751
3760
  e.preventDefault();
@@ -4109,10 +4118,14 @@
4109
4118
  var block = node.closest ? node.closest('[contenteditable="true"]') : null;
4110
4119
  if (!block) return false;
4111
4120
 
4121
+ // execCommand fires input but never beforeinput, so without this the stack
4122
+ // measured a bold against a document that already held it, and saw no change.
4123
+ Ryker.history.textBefore(block);
4112
4124
  try { document.execCommand('styleWithCSS', false, false); } catch (e) {}
4113
4125
  try { document.execCommand(cmd, false, value); } catch (e) { return false; }
4114
4126
 
4115
4127
  Ryker.sanitize.element(block);
4128
+ Ryker.history.flush();
4116
4129
  mark(block, Ryker.blocks.blockId(block));
4117
4130
  return true;
4118
4131
  }
@@ -4124,12 +4137,6 @@
4124
4137
  return Ryker.links.open();
4125
4138
  }
4126
4139
 
4127
- function restore(range) {
4128
- var sel = window.getSelection();
4129
- sel.removeAllRanges();
4130
- sel.addRange(range);
4131
- }
4132
-
4133
4140
  function insertHtml(html) {
4134
4141
  var sel = window.getSelection();
4135
4142
  if (!sel || !sel.rangeCount) return;
@@ -4300,10 +4307,28 @@
4300
4307
  // Typing is collected into one entry per block per pause, so undo steps back
4301
4308
  // by a phrase rather than by a character. Finer granularity is not worth
4302
4309
  // eighty entries for one sentence.
4303
- function text(node) {
4304
- if (applying) return;
4310
+ //
4311
+ // The baseline is read here, from beforeinput, while the block still holds
4312
+ // the content the edit is about to replace. That is the only moment it is
4313
+ // truthful. It used to be read in the input handler instead, which fires
4314
+ // after the browser has already applied the character, and the feature came
4315
+ // apart on the off-by-one: a one-keystroke edit produced before === after and
4316
+ // was dropped entirely, so Ctrl+Z did nothing, and a longer burst undid to a
4317
+ // state that still held its first character. Formatting fared worst, because
4318
+ // a bold toggle is a single input event and so was never undoable at all.
4319
+ function textBefore(node) {
4320
+ if (applying || !node) return;
4305
4321
  if (pending && pending.node !== node) flushText();
4306
4322
  if (!pending) pending = { node: node, before: node.innerHTML };
4323
+ }
4324
+
4325
+ // Called from input, once the edit has landed. Only the idle timer moves; the
4326
+ // baseline is whatever beforeinput already captured. The delegation covers an
4327
+ // input with no beforeinput ahead of it, which yields a late baseline rather
4328
+ // than none, and a late one is still better than dropping the entry.
4329
+ function text(node) {
4330
+ if (applying) return;
4331
+ textBefore(node);
4307
4332
  clearTimeout(timer);
4308
4333
  timer = setTimeout(flushText, DEBOUNCE);
4309
4334
  }
@@ -4472,6 +4497,15 @@
4472
4497
  // sometimes defers is worse than one that always does, because nobody can
4473
4498
  // predict what a second press will do.
4474
4499
  function bind() {
4500
+ // One capture listener on the document rather than one per block: it sees
4501
+ // every armed block, including blocks armed after this ran, and it keeps
4502
+ // the reasoning above next to the code it explains.
4503
+ document.addEventListener('beforeinput', function (e) {
4504
+ var node = e.target;
4505
+ var block = node && node.closest ? node.closest('.ryker-editing') : null;
4506
+ if (block) textBefore(block);
4507
+ }, true);
4508
+
4475
4509
  document.addEventListener('keydown', function (e) {
4476
4510
  if (!(e.ctrlKey || e.metaKey) || e.altKey) return;
4477
4511
  var k = (e.key || '').toLowerCase();
@@ -4494,7 +4528,8 @@
4494
4528
  }
4495
4529
 
4496
4530
  return {
4497
- record: record, text: text, flush: flushText, undo: undo, redo: redo,
4531
+ record: record, text: text, textBefore: textBefore, flush: flushText,
4532
+ undo: undo, redo: redo,
4498
4533
  clear: clear, canUndo: canUndo, canRedo: canRedo, depth: depth,
4499
4534
  isApplying: isApplying, bind: bind, onChange: onChange,
4500
4535
  captureBaseline: captureBaseline, restoreBaseline: restoreBaseline
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gbti/ryker",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Add Ryker inline editing and prompt-ready change requests to authored HTML documents.",
5
5
  "type": "module",
6
6
  "bin": {