@prosekit/core 0.1.2 → 0.1.4

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.
@@ -171,9 +171,16 @@ declare function defineBaseCommands(): Extension<{
171
171
  from?: number | undefined;
172
172
  to?: number | undefined;
173
173
  }];
174
- insertNode: [{
174
+ insertNode: [options: {
175
175
  node: Node_2;
176
176
  pos?: number | undefined;
177
+ type?: undefined;
178
+ attrs?: undefined;
179
+ } | {
180
+ node?: undefined;
181
+ pos?: number | undefined;
182
+ type: string;
183
+ attrs?: Attrs_2 | undefined;
177
184
  }];
178
185
  wrap: [{
179
186
  nodeType: NodeType_2;
@@ -579,17 +586,18 @@ export { getNodeType as getNodeType_alias_1 }
579
586
  declare function insertNode(options: {
580
587
  node: ProseMirrorNode;
581
588
  pos?: number;
582
- }): Command;
583
-
584
- declare function insertNode(options: {
585
- attrs?: Attrs;
586
- type: string;
589
+ type?: undefined;
590
+ attrs?: undefined;
591
+ } | {
592
+ node?: undefined;
587
593
  pos?: number;
594
+ type: string;
595
+ attrs?: Attrs;
588
596
  }): Command;
589
597
  export { insertNode }
590
598
  export { insertNode as insertNode_alias_1 }
591
599
 
592
- export declare function insertNode_alias_2({ node, pos, }: {
600
+ export declare function insertNodeAction({ node, pos, }: {
593
601
  node: ProseMirrorNode;
594
602
  pos?: number;
595
603
  }): Action;
@@ -1,3 +1,4 @@
1
+ export { ProseKitError } from './_tsup-dts-rollup';
1
2
  export { addMark } from './_tsup-dts-rollup';
2
3
  export { insertNode } from './_tsup-dts-rollup';
3
4
  export { removeMark } from './_tsup-dts-rollup';
@@ -9,7 +10,6 @@ export { createEditor } from './_tsup-dts-rollup';
9
10
  export { EditorOptions } from './_tsup-dts-rollup';
10
11
  export { union } from './_tsup-dts-rollup';
11
12
  export { withPriority } from './_tsup-dts-rollup';
12
- export { ProseKitError_alias_1 as ProseKitError } from './_tsup-dts-rollup';
13
13
  export { defineBaseCommands } from './_tsup-dts-rollup';
14
14
  export { defineCommands } from './_tsup-dts-rollup';
15
15
  export { defineDefaultState } from './_tsup-dts-rollup';
@@ -64,3 +64,61 @@ export { isMark } from './_tsup-dts-rollup';
64
64
  export { isNodeSelection } from './_tsup-dts-rollup';
65
65
  export { isProseMirrorNode } from './_tsup-dts-rollup';
66
66
  export { isTextSelection } from './_tsup-dts-rollup';
67
+ export { insertText } from './_tsup-dts-rollup';
68
+ export { selectAll } from './_tsup-dts-rollup';
69
+ export { wrap } from './_tsup-dts-rollup';
70
+ export { createNodeBuilder } from './_tsup-dts-rollup';
71
+ export { createMarkBuilder } from './_tsup-dts-rollup';
72
+ export { NodeChild } from './_tsup-dts-rollup';
73
+ export { NodeBuilder } from './_tsup-dts-rollup';
74
+ export { MarkBuilder } from './_tsup-dts-rollup';
75
+ export { applyAction } from './_tsup-dts-rollup';
76
+ export { insertNodeAction } from './_tsup-dts-rollup';
77
+ export { defineParagraphSpec } from './_tsup-dts-rollup';
78
+ export { UpdateHandler } from './_tsup-dts-rollup';
79
+ export { BaseExtension } from './_tsup-dts-rollup';
80
+ export { CommandPayload } from './_tsup-dts-rollup';
81
+ export { commandFacet } from './_tsup-dts-rollup';
82
+ export { getFacetCount } from './_tsup-dts-rollup';
83
+ export { FacetConverter } from './_tsup-dts-rollup';
84
+ export { FacetExtensionImpl } from './_tsup-dts-rollup';
85
+ export { updateExtension } from './_tsup-dts-rollup';
86
+ export { Payloads } from './_tsup-dts-rollup';
87
+ export { Converters } from './_tsup-dts-rollup';
88
+ export { SchemaPayload } from './_tsup-dts-rollup';
89
+ export { schemaFacet } from './_tsup-dts-rollup';
90
+ export { StatePayload } from './_tsup-dts-rollup';
91
+ export { stateFacet } from './_tsup-dts-rollup';
92
+ export { UnionExtensionImpl } from './_tsup-dts-rollup';
93
+ export { ViewPayload } from './_tsup-dts-rollup';
94
+ export { viewFacet } from './_tsup-dts-rollup';
95
+ export { assertTypeEqual } from './_tsup-dts-rollup';
96
+ export { CommandApplier } from './_tsup-dts-rollup';
97
+ export { CommandCreator } from './_tsup-dts-rollup';
98
+ export { CommandCreators } from './_tsup-dts-rollup';
99
+ export { ToCommandArgs } from './_tsup-dts-rollup';
100
+ export { ToCommandCreators } from './_tsup-dts-rollup';
101
+ export { ToCommandApplier } from './_tsup-dts-rollup';
102
+ export { ExceptEmptyValue } from './_tsup-dts-rollup';
103
+ export { ExtractNodesFromTyping } from './_tsup-dts-rollup';
104
+ export { ExtractMarksFromTyping } from './_tsup-dts-rollup';
105
+ export { ExtractCommandArgsFromTyping } from './_tsup-dts-rollup';
106
+ export { ExtractTyping } from './_tsup-dts-rollup';
107
+ export { ExtractCommandArgs } from './_tsup-dts-rollup';
108
+ export { ExtractKey } from './_tsup-dts-rollup';
109
+ export { voidFunction } from './_tsup-dts-rollup';
110
+ export { attrsMatch } from './_tsup-dts-rollup';
111
+ export { collectNodes } from './_tsup-dts-rollup';
112
+ export { NodeContent } from './_tsup-dts-rollup';
113
+ export { isMac } from './_tsup-dts-rollup';
114
+ export { getCustomSelection } from './_tsup-dts-rollup';
115
+ export { getBrowserDocument } from './_tsup-dts-rollup';
116
+ export { getBrowserWindow } from './_tsup-dts-rollup';
117
+ export { isMarkActive } from './_tsup-dts-rollup';
118
+ export { isNodeActive } from './_tsup-dts-rollup';
119
+ export { isNotNull } from './_tsup-dts-rollup';
120
+ export { objectEqual } from './_tsup-dts-rollup';
121
+ export { elementFromHTML } from './_tsup-dts-rollup';
122
+ export { uniqPush } from './_tsup-dts-rollup';
123
+ export { uniqRemove } from './_tsup-dts-rollup';
124
+ export { default_alias as default } from './_tsup-dts-rollup';
@@ -37,6 +37,7 @@ function addMark(options) {
37
37
  }
38
38
 
39
39
  // src/commands/insert-node.ts
40
+ import { TextSelection } from "@prosekit/pm/state";
40
41
  import { insertPoint } from "@prosekit/pm/transform";
41
42
 
42
43
  // src/utils/get-node-type.ts
@@ -69,6 +70,7 @@ function insertNode(options) {
69
70
  return false;
70
71
  if (dispatch) {
71
72
  const tr = state.tr.insert(insertPos, node);
73
+ tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos)));
72
74
  dispatch(tr);
73
75
  }
74
76
  return true;
@@ -97,13 +99,13 @@ function removeMark(options) {
97
99
  import "@prosekit/pm/state";
98
100
 
99
101
  // src/utils/get-custom-selection.ts
100
- import { TextSelection } from "@prosekit/pm/state";
102
+ import { TextSelection as TextSelection2 } from "@prosekit/pm/state";
101
103
  function getCustomSelection(state, from, to) {
102
104
  const pos = from != null ? from : to;
103
105
  if (pos != null) {
104
106
  const $from = state.doc.resolve(from != null ? from : pos);
105
107
  const $to = state.doc.resolve(to != null ? to : pos);
106
- return TextSelection.between($from, $to);
108
+ return TextSelection2.between($from, $to);
107
109
  }
108
110
  return state.selection;
109
111
  }
@@ -657,7 +659,7 @@ import { Mark, ProseMirrorNode } from "@prosekit/pm/model";
657
659
  import {
658
660
  AllSelection,
659
661
  NodeSelection,
660
- TextSelection as TextSelection2
662
+ TextSelection as TextSelection3
661
663
  } from "@prosekit/pm/state";
662
664
  function isProseMirrorNode(node) {
663
665
  return node instanceof ProseMirrorNode;
@@ -666,7 +668,7 @@ function isMark(mark) {
666
668
  return mark instanceof Mark;
667
669
  }
668
670
  function isTextSelection(sel) {
669
- return sel instanceof TextSelection2;
671
+ return sel instanceof TextSelection3;
670
672
  }
671
673
  function isNodeSelection(sel) {
672
674
  return sel instanceof NodeSelection;
@@ -746,8 +748,8 @@ function flattenChildren(schema, children, mark) {
746
748
  }
747
749
  function normalizeArgs(args) {
748
750
  const [attrs, ...children] = args;
749
- if (isNodeChild(args)) {
750
- children.unshift(args);
751
+ if (isNodeChild(attrs)) {
752
+ children.unshift(attrs);
751
753
  return [null, children];
752
754
  } else if (typeof attrs === "object") {
753
755
  return [attrs, children];
@@ -1082,26 +1084,6 @@ function wrap({
1082
1084
  };
1083
1085
  }
1084
1086
 
1085
- // src/extensions/actions.ts
1086
- import "@prosekit/pm/model";
1087
- import { Selection as Selection2 } from "@prosekit/pm/state";
1088
- import { insertPoint as insertPoint2 } from "@prosekit/pm/transform";
1089
- function insertNode2({
1090
- node,
1091
- pos
1092
- }) {
1093
- return ({ tr }) => {
1094
- const insertPos = insertPoint2(tr.doc, pos != null ? pos : tr.selection.to, node.type);
1095
- if (insertPos == null) {
1096
- return false;
1097
- }
1098
- tr.insert(insertPos, node);
1099
- const $pos = tr.doc.resolve(insertPos);
1100
- tr.setSelection(Selection2.near($pos));
1101
- return true;
1102
- };
1103
- }
1104
-
1105
1087
  // src/extensions/command.ts
1106
1088
  function defineCommands(commands) {
1107
1089
  return commandFacet.extension([commands]);
@@ -1109,7 +1091,7 @@ function defineCommands(commands) {
1109
1091
  function defineBaseCommands() {
1110
1092
  return defineCommands({
1111
1093
  insertText,
1112
- insertNode: insertNode2,
1094
+ insertNode,
1113
1095
  wrap,
1114
1096
  setBlockType,
1115
1097
  selectAll,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/core",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",