@prosekit/core 0.1.5 → 0.1.7
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/_tsup-dts-rollup.d.ts +12 -1
- package/dist/prosekit-core.js +15 -4
- package/package.json +1 -1
@@ -211,9 +211,18 @@ export { defineBaseCommands }
|
|
211
211
|
export { defineBaseCommands as defineBaseCommands_alias_1 }
|
212
212
|
|
213
213
|
/**
|
214
|
+
* Defines some basic key bindings.
|
215
|
+
*
|
214
216
|
* @public
|
215
217
|
*/
|
216
|
-
declare function defineBaseKeymap(
|
218
|
+
declare function defineBaseKeymap(options?: {
|
219
|
+
/**
|
220
|
+
* The priority of the keymap.
|
221
|
+
*
|
222
|
+
* @default Priority.low
|
223
|
+
*/
|
224
|
+
priority?: Priority;
|
225
|
+
}): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
217
226
|
export { defineBaseKeymap }
|
218
227
|
export { defineBaseKeymap as defineBaseKeymap_alias_1 }
|
219
228
|
|
@@ -893,6 +902,8 @@ declare function setBlockType(options: {
|
|
893
902
|
export { setBlockType }
|
894
903
|
export { setBlockType as setBlockType_alias_1 }
|
895
904
|
|
905
|
+
export declare function setSelectionAround(tr: Transaction, pos: number): void;
|
906
|
+
|
896
907
|
/**
|
897
908
|
* @internal
|
898
909
|
*/
|
package/dist/prosekit-core.js
CHANGED
@@ -37,7 +37,7 @@ function addMark(options) {
|
|
37
37
|
}
|
38
38
|
|
39
39
|
// src/commands/insert-node.ts
|
40
|
-
import
|
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
|
-
|
82
|
+
setSelectionAround(tr, insertPos + node.nodeSize);
|
74
83
|
dispatch(tr);
|
75
84
|
}
|
76
85
|
return true;
|
@@ -1182,8 +1191,10 @@ var pluginFacet = Facet.define({
|
|
1182
1191
|
function defineKeymap(keymap) {
|
1183
1192
|
return keymapFacet.extension([keymap]);
|
1184
1193
|
}
|
1185
|
-
function defineBaseKeymap() {
|
1186
|
-
|
1194
|
+
function defineBaseKeymap(options) {
|
1195
|
+
var _a;
|
1196
|
+
const priority = (_a = options == null ? void 0 : options.priority) != null ? _a : 3 /* low */;
|
1197
|
+
return withPriority(defineKeymap(baseKeymap), priority);
|
1187
1198
|
}
|
1188
1199
|
var keymapFacet = Facet.define({
|
1189
1200
|
converter: () => {
|