@nerd-bible/wordgard 0.5.2-beta → 0.5.2-beta2

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/dist/editor.js CHANGED
@@ -2020,10 +2020,10 @@ class DocTile extends CompositeTile {
2020
2020
  let len = changes[i++], ins = changes[i++];
2021
2021
  if (composition && posB == composition.fromB && ins >= 0) {
2022
2022
  if (!startCovered)
2023
- builder.update(0, false);
2023
+ builder.update(0, true);
2024
2024
  builder.composition(composition, len);
2025
2025
  if (ins && (startCovered = i == changes.length || changes[i + 1] == -1))
2026
- builder.update(0, false);
2026
+ builder.update(0, true);
2027
2027
  }
2028
2028
  else if (ins == -1) {
2029
2029
  builder.keep(len, !startCovered, i == changes.length);
@@ -4190,11 +4190,13 @@ class InputState {
4190
4190
  this.domChanges = null;
4191
4191
  }
4192
4192
  getDOMPos(node, offset) {
4193
+ if (!this.domChanges)
4194
+ return this.wg.docTile.posFromDOM(node, offset);
4193
4195
  if (node.nodeType == 1 && offset && node.childNodes[offset - 1].nodeType == 3) {
4194
4196
  node = node.childNodes[offset - 1];
4195
4197
  offset = node.nodeValue.length;
4196
4198
  }
4197
- let inText = node.nodeType == 3;
4199
+ let inText = node.nodeType == 3 && !this.wg.docTile.nearest(node)?.isPoint;
4198
4200
  let ref = this.wg.docTile.posFromDOM(node, inText ? 0 : offset);
4199
4201
  let dir = -1;
4200
4202
  let textBefore = node.parentNode && textNodeBefore(node.parentNode, domIndex(node));
@@ -4310,9 +4312,11 @@ class InputState {
4310
4312
  }
4311
4313
  else {
4312
4314
  let tileBefore = Tile.get(before), tileAfter = Tile.get(after);
4313
- return !tileBefore || tileBefore.text != before.nodeValue ? before
4314
- : !tileAfter || tileAfter.text != after.nodeValue ? after
4315
- : prev == after ? after : before;
4315
+ if (tileBefore instanceof TextTile && tileBefore.text != before.nodeValue)
4316
+ return before;
4317
+ if (tileAfter instanceof TextTile && tileAfter.text != after.nodeValue)
4318
+ return after;
4319
+ return !tileBefore ? before : !tileAfter ? after : prev == after ? after : before;
4316
4320
  }
4317
4321
  }
4318
4322
  recordTouch(e) {
package/dist/history.js CHANGED
@@ -3,7 +3,15 @@ import { ChangeSet } from 'wordgard/doc';
3
3
  import { Command, undo as undo$1, redo as redo$1, Menu } from 'wordgard/command';
4
4
  import { phrases } from 'wordgard/phrases';
5
5
 
6
- const fromHistory = /*@__PURE__*/Transaction.Annotation.define();
6
+ const fromHistory = /*@__PURE__*/Transaction.Effect.define({
7
+ map(value, change) {
8
+ return {
9
+ side: value.side,
10
+ startDoc: change.apply(value.startDoc),
11
+ rest: !value.rest ? null : value.rest.addMapping(change, value.startDoc)
12
+ };
13
+ }
14
+ });
7
15
  const historyConfig = /*@__PURE__*/GardState.Facet.define({
8
16
  combine(configs) {
9
17
  return GardState.Facet.combineConfig(configs, {
@@ -23,13 +31,13 @@ const historyField_ = /*@__PURE__*/GardState.Field.define({
23
31
  },
24
32
  update(state, tr) {
25
33
  let config = tr.state.facet(historyConfig);
26
- let fromHist = tr.annotation(fromHistory);
34
+ let fromHist = tr.effects.find(e => e.is(fromHistory));
27
35
  if (fromHist) {
28
- let from = fromHist.side, event = eventFromTransaction(tr);
29
- let other = from == 0 ? state.undone : state.done;
36
+ let { side, rest } = fromHist.value, event = eventFromTransaction(tr);
37
+ let other = side == 0 ? state.undone : state.done;
30
38
  if (event)
31
39
  other = new Branch(event.changes, event.effects, null, tr.startState.selection, other);
32
- return new HistoryState(from == 0 ? fromHist.rest : other, from == 0 ? other : fromHist.rest);
40
+ return new HistoryState(side == 0 ? rest : other, side == 0 ? other : rest);
33
41
  }
34
42
  let isolate = tr.annotation(history.isolate);
35
43
  if (isolate == true || isolate == "before")
@@ -239,8 +247,7 @@ class HistoryState {
239
247
  return {
240
248
  changes: branch.changes,
241
249
  selection: branch.startSelection,
242
- effects: branch.effects,
243
- annotations: fromHistory.of({ side, rest: branch.next }),
250
+ effects: branch.effects.concat(fromHistory.of({ side, startDoc: branch.changes.apply(state.doc), rest: branch.next })),
244
251
  userEvent: side == 0 ? "undo" : "redo",
245
252
  scrollIntoView: true
246
253
  };
package/dist/state.js CHANGED
@@ -854,14 +854,14 @@ function findNormalAt(cx, pos, bias) {
854
854
  parent = parent.parent;
855
855
  }
856
856
  else {
857
- let next = parent.node.content[index + (dir > 0 ? 0 : -1)];
857
+ let nextIndex = index + (dir > 0 ? 0 : -1), next = parent.node.content[nextIndex];
858
858
  if (next.isLeaf || isBarrier(cx, next))
859
859
  break;
860
860
  if (!parent.node.inlineContent && next.inlineContent && cx.config.visualCursorMotion) {
861
861
  let startPos = curPos - (dir > 0 ? 0 : next.length) + 1;
862
862
  return TextblockMap.get(cx, startPos, next).visualSide(dir > 0);
863
863
  }
864
- parent = Pos.Plot.create(parent, next, curPos, index);
864
+ parent = Pos.Plot.create(parent, next, curPos, nextIndex);
865
865
  index = dir > 0 ? 0 : next.content.length;
866
866
  curPos += dir;
867
867
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nerd-bible/wordgard",
3
- "version": "0.5.2-beta",
3
+ "version": "0.5.2-beta2",
4
4
  "description": "Semantic rich text editor system",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",