prosemirror-transform 1.12.1 → 1.12.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,3 +1,9 @@
1
+ ## 1.12.2 (2026-09-25)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a bug that caused `StepMap.mapResult` to set deletion flags for insertions adjacent to the mapped position.
6
+
1
7
  ## 1.12.1 (2026-09-02)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -107,8 +107,11 @@ var StepMap = function () {
107
107
  var result = start + diff + (side < 0 ? 0 : newSize);
108
108
  if (simple) return result;
109
109
  var recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
110
- var del = pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
111
- if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE;
110
+ var del = 0;
111
+ if (oldSize) {
112
+ del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
113
+ if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE;
114
+ }
112
115
  return new MapResult(result, del, recover);
113
116
  }
114
117
  diff += newSize - oldSize;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Node, Schema, Slice, Fragment, NodeRange, NodeType, Attrs, Mark, MarkType, ContentMatch } from 'prosemirror-model';
1
+ import { Node, Slice, Schema, Fragment, NodeRange, NodeType, Attrs, Mark, MarkType, ContentMatch } from 'prosemirror-model';
2
2
 
3
3
  /**
4
4
  There are several things that positions can be mapped through.
@@ -853,4 +853,5 @@ would be a no-op (an empty slice over an empty range).
853
853
  */
854
854
  declare function replaceStep(doc: Node, from: number, to?: number, slice?: Slice): Step | null;
855
855
 
856
- export { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, MapResult, type Mappable, Mapping, RemoveMarkStep, RemoveNodeMarkStep, ReplaceAroundStep, ReplaceStep, Step, StepMap, StepResult, Transform, canJoin, canSplit, dropPoint, findWrapping, insertPoint, joinPoint, liftTarget, replaceStep };
856
+ export { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, MapResult, Mapping, RemoveMarkStep, RemoveNodeMarkStep, ReplaceAroundStep, ReplaceStep, Step, StepMap, StepResult, Transform, canJoin, canSplit, dropPoint, findWrapping, insertPoint, joinPoint, liftTarget, replaceStep };
857
+ export type { Mappable };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Node, Schema, Slice, Fragment, NodeRange, NodeType, Attrs, Mark, MarkType, ContentMatch } from 'prosemirror-model';
1
+ import { Node, Slice, Schema, Fragment, NodeRange, NodeType, Attrs, Mark, MarkType, ContentMatch } from 'prosemirror-model';
2
2
 
3
3
  /**
4
4
  There are several things that positions can be mapped through.
@@ -853,4 +853,5 @@ would be a no-op (an empty slice over an empty range).
853
853
  */
854
854
  declare function replaceStep(doc: Node, from: number, to?: number, slice?: Slice): Step | null;
855
855
 
856
- export { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, MapResult, type Mappable, Mapping, RemoveMarkStep, RemoveNodeMarkStep, ReplaceAroundStep, ReplaceStep, Step, StepMap, StepResult, Transform, canJoin, canSplit, dropPoint, findWrapping, insertPoint, joinPoint, liftTarget, replaceStep };
856
+ export { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, MapResult, Mapping, RemoveMarkStep, RemoveNodeMarkStep, ReplaceAroundStep, ReplaceStep, Step, StepMap, StepResult, Transform, canJoin, canSplit, dropPoint, findWrapping, insertPoint, joinPoint, liftTarget, replaceStep };
857
+ export type { Mappable };
package/dist/index.js CHANGED
@@ -115,9 +115,12 @@ class StepMap {
115
115
  if (simple)
116
116
  return result;
117
117
  let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
118
- let del = pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
119
- if (assoc < 0 ? pos != start : pos != end)
120
- del |= DEL_SIDE;
118
+ let del = 0;
119
+ if (oldSize) {
120
+ del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
121
+ if (assoc < 0 ? pos != start : pos != end)
122
+ del |= DEL_SIDE;
123
+ }
121
124
  return new MapResult(result, del, recover);
122
125
  }
123
126
  diff += newSize - oldSize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-transform",
3
- "version": "1.12.1",
3
+ "version": "1.12.2",
4
4
  "description": "ProseMirror document transformations",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/attr_step.ts CHANGED
@@ -95,4 +95,4 @@ export class DocAttrStep extends Step {
95
95
  }
96
96
  }
97
97
 
98
- Step.jsonID("docAttr", DocAttrStep)
98
+ Step.jsonID("docAttr", DocAttrStep)
package/src/map.ts CHANGED
@@ -106,8 +106,11 @@ export class StepMap implements Mappable {
106
106
  let result = start + diff + (side < 0 ? 0 : newSize)
107
107
  if (simple) return result
108
108
  let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start)
109
- let del = pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS
110
- if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE
109
+ let del = 0
110
+ if (oldSize) {
111
+ del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS
112
+ if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE
113
+ }
111
114
  return new MapResult(result, del, recover)
112
115
  }
113
116
  diff += newSize - oldSize