added Span node, but need to move cursor? inside the new Span node #2452
Replies: 3 comments 1 reply
-
Don’t use Instead of this: setSpan: () => ({ chain }) => {
return chain().insertContentAt(this.editor.state.selection.anchor + 1, [
{
type: "span",
},
])
// .setTextSelection(this.editor.state.selection.anchor + 1)
.run();
} do this: setSpan: () => ({ chain, state }) => {
return chain().insertContentAt(state.selection.anchor + 1, [
{
type: "span",
},
])
// .setTextSelection(state.selection.anchor + 1)
.run();
} |
Beta Was this translation helpful? Give feedback.
-
Here's what worked for me, building on @philippkuehn's answer:
|
Beta Was this translation helpful? Give feedback.
-
Hello, Impossible to have the cursor directly inside after the creation. And also impossible to move the cursor inside it, nor with mouse click, nor with arrow keys. When there is already a content inside, not with input rule but after first importation with content for ex, I can perfectly enter inside with mouse and keys. So how to have the cursor inside the node (= inside the span) just after creation by input rule ? |
Beta Was this translation helpful? Give feedback.
-
How my implementation currently works.
User types "sentence 1" =>
<p><span>"sentence 1"</span></p>
On hotkey "." a new span node is created at end =>
<p><span>"sentence 1"</span><span></span></p>
works fine.After new span is created, "sentence 2" should be in the new span, but it remains in the original span. Maybe cursor hasn't moved.
<p><span>"sentence 1""sentence 2"</span><span>..should be here..</span></p>
I tried chaining
setTextSelection(this.editor.state.selection.anchor + 1)
andfocus(this.editor.state.selection.anchor + 1)
but first way is just appending to sentence 1 andfocus()
is throwingSelection passed to setSelection must point at the current document
Chaining in my custom command works without the addition of
setTextSelection()
orfocus()
Thank you for any help or pointers you can offer. I appreciate it very much!
Beta Was this translation helpful? Give feedback.
All reactions