docblocks-core 0.2.0 → 0.2.2

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,34 @@
1
1
  # docblocks-core
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 745f1d7: The redo of a remounting step (a type change) restores the pre-change
8
+ selection seat: the redo's stack item carries the pre-undo snapshot,
9
+ which over a remount is the lost-caret residue (none/blocks) rather
10
+ than the pre-change seat. The redo falls back to the seat the matching
11
+ undo restored when the item's own snapshot is not a text selection and
12
+ the undo itself restored a text seat (the remount's case); a non-text
13
+ undo restoration (the canvas' blocks selection) is a legitimate
14
+ pre-undo selection and the redo restores its own snapshot. The view's
15
+ history reseat window suppresses the remount's transient selection loss
16
+ over the undo/redo, and the reseat re-runs when the restoration's
17
+ emission lands.
18
+
19
+ ## 0.2.1
20
+
21
+ ### Patch Changes
22
+
23
+ - c0559db: The mark commands stand the Y.Text format's length contract: `setMark`
24
+ (the exclusive path) and `unsetMark` passed the range's end offset as
25
+ the format's length argument (the Yjs `format(start, length)` signature).
26
+ Over a range whose `from + to` exceeds the text's length the command
27
+ extended the block's text with line breaks (the overhang's characters
28
+ got the mark or the drop) — the ghost empty lines over the mark's
29
+ toggle. The mark now stands the exact `[from, to)` bounds (the length is
30
+ `to - from`); the text is byte-stable over the toggle.
31
+
3
32
  ## 0.2.0
4
33
 
5
34
  ### Minor Changes
package/dist/index.mjs CHANGED
@@ -4465,7 +4465,7 @@ function setMark(ydoc, blockId, from, to, mark) {
4465
4465
  if (exclusive) {
4466
4466
  const clear = {};
4467
4467
  for (const other of MARK_NAMES) if (other !== name) clear[other] = null;
4468
- content.format(from, to, {
4468
+ content.format(from, to - from, {
4469
4469
  ...clear,
4470
4470
  [name]: value
4471
4471
  });
@@ -4480,7 +4480,7 @@ function unsetMark(ydoc, blockId, from, to, name) {
4480
4480
  if (!Number.isInteger(from) || !Number.isInteger(to) || from < 0 || from > to || to > total) throw new InvalidRangeError(`Range must satisfy 0 <= from < to <= ${total} (got from=${from}, to=${to}).`);
4481
4481
  if (from === to) return;
4482
4482
  localTransact(ydoc, () => {
4483
- content.format(from, to, { [name]: null });
4483
+ content.format(from, to - from, { [name]: null });
4484
4484
  });
4485
4485
  }
4486
4486
  //#endregion
@@ -5428,6 +5428,14 @@ var SelectionView = class {
5428
5428
  #pendingChange = null;
5429
5429
  /** The selection before the in-flight local/undo-transaction (undo-caret snapshot). */
5430
5430
  #pendingBefore = null;
5431
+ /**
5432
+ * The selection the most recent undo restored. The matching redo (popped
5433
+ * from the redo stack) restores it when the redo item's own snapshot is
5434
+ * the remount residue (a type change's forward remount loses the DOM
5435
+ * caret, so the redo item captured the residue's none/blocks, not the
5436
+ * pre-change seat).
5437
+ */
5438
+ #lastUndoRestored = null;
5431
5439
  /** Document subscriptions, all released by destroy(). */
5432
5440
  #unsubDocChange;
5433
5441
  #onBeforeTransaction;
@@ -5452,13 +5460,15 @@ var SelectionView = class {
5452
5460
  event.stackItem.meta.set(this.#metaKey, snapshot);
5453
5461
  };
5454
5462
  this.#onStackItemPopped = (event) => {
5455
- const saved = event.stackItem.meta.get(this.#metaKey);
5463
+ let saved = event.stackItem.meta.get(this.#metaKey);
5456
5464
  if (saved === void 0) return;
5465
+ if (event.type === "redo" && this.#lastUndoRestored !== null && this.#lastUndoRestored.kind === "text" && saved.kind !== "text") saved = this.#lastUndoRestored;
5457
5466
  const restored = this.#restoreableSelection(saved);
5458
5467
  if (restored === null) return;
5459
5468
  this.#state = restored;
5460
5469
  this.#emit();
5461
5470
  this.#reconcileTracking();
5471
+ if (event.type === "undo") this.#lastUndoRestored = restored;
5462
5472
  };
5463
5473
  ydoc.on("beforeTransaction", this.#onBeforeTransaction);
5464
5474
  ydoc.on("afterTransaction", this.#onAfterTransaction);
@@ -5500,6 +5510,7 @@ var SelectionView = class {
5500
5510
  this.#pendingChange = null;
5501
5511
  this.#pendingDeltas = /* @__PURE__ */ new Map();
5502
5512
  this.#pendingBefore = null;
5513
+ this.#lastUndoRestored = null;
5503
5514
  }
5504
5515
  /** Subscribe to selection changes (set, rebase, undo/redo restore). Returns unsubscribe. */
5505
5516
  onChange(handler) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docblocks-core",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Headless CRDT document engine: schema v1, Doc (commands/transactions/undo), sync providers. Yjs-based, zero UI dependencies.",
5
5
  "type": "module",
6
6
  "license": "MIT",