@gbti/ryker 0.2.4 → 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.4`, 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.4';
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.4
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:
@@ -22,8 +22,8 @@
22
22
  * ui/menu.js (104 lines)
23
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.4", 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 ---------------------------------------------- */
@@ -3709,7 +3709,11 @@
3709
3709
  var clean = Ryker.sanitize.fromClipboard(e);
3710
3710
  if (clean == null) return;
3711
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);
3712
3715
  insertHtml(clean);
3716
+ Ryker.history.flush();
3713
3717
  mark(n, id);
3714
3718
  },
3715
3719
  drop: function (e) {
@@ -3748,7 +3752,9 @@
3748
3752
  // an edit.
3749
3753
  if (n.tagName === 'TD' || n.tagName === 'TH') {
3750
3754
  e.preventDefault();
3755
+ Ryker.history.textBefore(n);
3751
3756
  try { document.execCommand('insertLineBreak'); } catch (err) {}
3757
+ Ryker.history.flush();
3752
3758
  return;
3753
3759
  }
3754
3760
  e.preventDefault();
@@ -4112,10 +4118,14 @@
4112
4118
  var block = node.closest ? node.closest('[contenteditable="true"]') : null;
4113
4119
  if (!block) return false;
4114
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);
4115
4124
  try { document.execCommand('styleWithCSS', false, false); } catch (e) {}
4116
4125
  try { document.execCommand(cmd, false, value); } catch (e) { return false; }
4117
4126
 
4118
4127
  Ryker.sanitize.element(block);
4128
+ Ryker.history.flush();
4119
4129
  mark(block, Ryker.blocks.blockId(block));
4120
4130
  return true;
4121
4131
  }
@@ -4127,12 +4137,6 @@
4127
4137
  return Ryker.links.open();
4128
4138
  }
4129
4139
 
4130
- function restore(range) {
4131
- var sel = window.getSelection();
4132
- sel.removeAllRanges();
4133
- sel.addRange(range);
4134
- }
4135
-
4136
4140
  function insertHtml(html) {
4137
4141
  var sel = window.getSelection();
4138
4142
  if (!sel || !sel.rangeCount) return;
@@ -4303,10 +4307,28 @@
4303
4307
  // Typing is collected into one entry per block per pause, so undo steps back
4304
4308
  // by a phrase rather than by a character. Finer granularity is not worth
4305
4309
  // eighty entries for one sentence.
4306
- function text(node) {
4307
- 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;
4308
4321
  if (pending && pending.node !== node) flushText();
4309
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);
4310
4332
  clearTimeout(timer);
4311
4333
  timer = setTimeout(flushText, DEBOUNCE);
4312
4334
  }
@@ -4475,6 +4497,15 @@
4475
4497
  // sometimes defers is worse than one that always does, because nobody can
4476
4498
  // predict what a second press will do.
4477
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
+
4478
4509
  document.addEventListener('keydown', function (e) {
4479
4510
  if (!(e.ctrlKey || e.metaKey) || e.altKey) return;
4480
4511
  var k = (e.key || '').toLowerCase();
@@ -4497,7 +4528,8 @@
4497
4528
  }
4498
4529
 
4499
4530
  return {
4500
- record: record, text: text, flush: flushText, undo: undo, redo: redo,
4531
+ record: record, text: text, textBefore: textBefore, flush: flushText,
4532
+ undo: undo, redo: redo,
4501
4533
  clear: clear, canUndo: canUndo, canRedo: canRedo, depth: depth,
4502
4534
  isApplying: isApplying, bind: bind, onChange: onChange,
4503
4535
  captureBaseline: captureBaseline, restoreBaseline: restoreBaseline
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gbti/ryker",
3
- "version": "0.2.4",
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": {