How to Insert text to current cursor position using custom toolbar
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- markdown, react, typescript
- Domain
- frontend
Research direction
Start at the custom toolbar's execute callback and inspect the CodeMirror view.state selection and dispatch change handling shown in the issue. Confirm how the current cursor position is represented and verify that the requested image-markdown string is inserted there with the selection updated afterward.
Written by the indexing model from the issue text.
Description
How can i insert a specific string at the current cursor position using the custom toolbar feature?
Is theme a method to get current cursor position and insert text? thank you!
this is my code, and it doesn't work properly.
please give me some advice, Thank you!
execute: (mirror: ReactCodeMirrorRef) => {
const { view, state, editor } = mirror
if (!view || !state || !editor) {
return
}
// NOTE: how to get current position of cursor?
const lineInfo = view.state.doc.lineAt(view.state.selection.main.from)
console.log(lineInfo)
const insert = ``
view.dispatch({
changes: {
from: lineInfo.from,
to: lineInfo.from + insert.length,
insert,
},
selection: { anchor: lineInfo.from },
})
},
- Dominant language
- TypeScript
- Stars
- 382
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from uiwjs/react-markdown-editor
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
uiwjs/react-markdown-editor#241 · 5 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
uiwjs/react-markdown-editor#240 ·
-
Add Typing for Slots Open
Difficulty 3/5 1-2 days Newbie friendliness 42/100
uiwjs/react-markdown-editor#239 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
uiwjs/react-markdown-editor#238 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
uiwjs/react-markdown-editor#234 ·
All issues in uiwjs/react-markdown-editor
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
0xMiden/bridge-portal#132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:tools bug good first issue help wanted priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
TaewoooPark/Motifcode#14 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
newrelic-experimental/preflight#793 · 1 comment ·