@prosekit/core
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -896,2 +896,4 @@ import { AllSelection } from '@prosekit/pm/state'; | ||
export declare function setSelectionAround(tr: Transaction, pos: number): void; | ||
/** | ||
@@ -898,0 +900,0 @@ * @internal |
@@ -40,3 +40,3 @@ // src/commands/add-mark.ts | ||
// src/commands/insert-node.ts | ||
import { TextSelection } from "@prosekit/pm/state"; | ||
import "@prosekit/pm/state"; | ||
import { insertPoint } from "@prosekit/pm/transform"; | ||
@@ -57,2 +57,11 @@ | ||
// src/utils/set-selection-around.ts | ||
import { TextSelection } from "@prosekit/pm/state"; | ||
function setSelectionAround(tr, pos) { | ||
const docSize = tr.doc.content.size; | ||
const $pos = tr.doc.resolve(pos > docSize ? docSize : pos < 0 ? 0 : pos); | ||
const selection = TextSelection.between($pos, $pos); | ||
tr.setSelection(selection); | ||
} | ||
// src/commands/insert-node.ts | ||
@@ -75,3 +84,3 @@ function insertNode(options) { | ||
const tr = state.tr.insert(insertPos, node); | ||
tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos))); | ||
setSelectionAround(tr, insertPos + node.nodeSize); | ||
dispatch(tr); | ||
@@ -78,0 +87,0 @@ } |
{ | ||
"name": "@prosekit/core", | ||
"type": "module", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77760
2490