@nerd-bible/wordgard 0.6.2-beta2 → 0.6.2-beta4

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/command.js CHANGED
@@ -740,7 +740,7 @@ const insertText = ({ state }, { from, to, insert, userEvent }) => {
740
740
  let marks = (from == selection.from && to == selection.to && state.sel.activeMarks) ||
741
741
  state.doc.resolve(from).marks(state.doc.resolve(to));
742
742
  return {
743
- changes: { from, to, insert: [Leaf.Text.of(insert, marks)], fit: true },
743
+ changes: { from, to, insert: insert ? [Leaf.text(insert, marks)] : undefined, fit: true },
744
744
  scrollIntoView: true,
745
745
  selection: (cx, changes) => GardSelection.near(cx, changes.mapPos(to, 1), -1),
746
746
  userEvent
package/dist/doc.js CHANGED
@@ -1207,6 +1207,8 @@ class Leaf extends BaseTag {
1207
1207
  return Leaf.Text.of(this.param.slice(Math.max(from, 0), Math.max(0, to)), this.marks);
1208
1208
  }
1209
1209
  static text(text, marks = Mark.none) {
1210
+ if (!text)
1211
+ throw new Error("Cannot create empty text nodes");
1210
1212
  return Leaf.Text.of(text, marks);
1211
1213
  }
1212
1214
  toString() {
package/dist/editor.js CHANGED
@@ -3912,7 +3912,7 @@ class InputState {
3912
3912
  return;
3913
3913
  if (slice) {
3914
3914
  wg.dispatch({
3915
- changes: { from, to, insert: slice, fit: true },
3915
+ changes: { correct: { from, to, insert: slice, fit: true }, local: true },
3916
3916
  selection: isSel ? (cx, changes) => GardSelection.near(cx, changes.mapPos(to, 1), -1) : undefined,
3917
3917
  userEvent: "input.paste",
3918
3918
  scrollIntoView: isSel
@@ -4448,10 +4448,10 @@ const baseHandlers = {
4448
4448
  let dropPos = wg.posAtCoords({ x: event.clientX, y: event.clientY }).pos;
4449
4449
  let { draggedContent } = wg.inputState;
4450
4450
  let del = draggedContent && dragMovesSelection(wg, event)
4451
- ? { from: draggedContent.from, to: draggedContent.to } : null;
4452
- if (wg.state.facet(dropHandler).some(f => f(wg, event, dropPos, del, slice)))
4451
+ ? { correct: { from: draggedContent.from, to: draggedContent.to }, local: true } : null;
4452
+ if (wg.state.facet(dropHandler).some(f => f(wg, event, dropPos, del ? del.correct : null, slice)))
4453
4453
  return true;
4454
- let ins = { from: dropPos, insert: slice, fit: true };
4454
+ let ins = { correct: { from: dropPos, insert: slice, fit: true }, local: true };
4455
4455
  let changes = ChangeSet.create(wg.state.doc, del ? [del, ins] : ins);
4456
4456
  wg.focus();
4457
4457
  wg.dispatch({
@@ -4494,7 +4494,8 @@ const baseHandlers = {
4494
4494
  wg.inputState.pendingInputEvent = null;
4495
4495
  let change;
4496
4496
  if (compositionInputTypes.has(event.inputType) || event.inputType == "insertText") {
4497
- change = { from: pending.domRange.from, to: pending.domRange.to, insert: [Leaf.text(pending.data || "")] };
4497
+ let text = pending.data || "";
4498
+ change = { from: pending.domRange.from, to: pending.domRange.to, insert: text ? [Leaf.text(text)] : undefined };
4498
4499
  }
4499
4500
  else if (isDeletionInputEvent(event.inputType)) {
4500
4501
  change = { from: pending.domRange.from, to: pending.domRange.to };
@@ -7407,7 +7408,7 @@ function ensureAnchor(regexp) {
7407
7408
  }
7408
7409
  function applyString(text) {
7409
7410
  return (state, match) => ({
7410
- changes: { from: match[0].from.pos, to: match[0].to.pos, insert: [Leaf.text(text)] },
7411
+ changes: { from: match[0].from.pos, to: match[0].to.pos, insert: text ? [Leaf.text(text)] : undefined },
7411
7412
  annotations: history.isolate.of(true)
7412
7413
  });
7413
7414
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nerd-bible/wordgard",
3
- "version": "0.6.2-beta2",
3
+ "version": "0.6.2-beta4",
4
4
  "description": "Semantic rich text editor system",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",