@prosekit/core 0.1.5 → 0.1.6

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.
@@ -893,6 +893,8 @@ declare function setBlockType(options: {
893
893
  export { setBlockType }
894
894
  export { setBlockType as setBlockType_alias_1 }
895
895
 
896
+ export declare function setSelectionAround(tr: Transaction, pos: number): void;
897
+
896
898
  /**
897
899
  * @internal
898
900
  */
@@ -37,7 +37,7 @@ function addMark(options) {
37
37
  }
38
38
 
39
39
  // src/commands/insert-node.ts
40
- import { TextSelection } from "@prosekit/pm/state";
40
+ import "@prosekit/pm/state";
41
41
  import { insertPoint } from "@prosekit/pm/transform";
42
42
 
43
43
  // src/utils/get-node-type.ts
@@ -53,6 +53,15 @@ function getNodeType(schema, type) {
53
53
  return type;
54
54
  }
55
55
 
56
+ // src/utils/set-selection-around.ts
57
+ import { TextSelection } from "@prosekit/pm/state";
58
+ function setSelectionAround(tr, pos) {
59
+ const docSize = tr.doc.content.size;
60
+ const $pos = tr.doc.resolve(pos > docSize ? docSize : pos < 0 ? 0 : pos);
61
+ const selection = TextSelection.between($pos, $pos);
62
+ tr.setSelection(selection);
63
+ }
64
+
56
65
  // src/commands/insert-node.ts
57
66
  function insertNode(options) {
58
67
  return (state, dispatch) => {
@@ -70,7 +79,7 @@ function insertNode(options) {
70
79
  return false;
71
80
  if (dispatch) {
72
81
  const tr = state.tr.insert(insertPos, node);
73
- tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos)));
82
+ setSelectionAround(tr, insertPos + node.nodeSize);
74
83
  dispatch(tr);
75
84
  }
76
85
  return true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/core",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",