1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

update cursor position after expanding the link

This commit is contained in:
yosmoc
2018-05-21 22:56:52 +02:00
parent 0ca4e6ca4f
commit 2bd78cd47f

View File

@@ -322,8 +322,9 @@ export default class CodeEditor extends React.Component {
const cursor = editor.getCursor() const cursor = editor.getCursor()
const LinkWithTitle = `[${parsedResponse.title}](${pastedTxt})` const LinkWithTitle = `[${parsedResponse.title}](${pastedTxt})`
const newValue = value.replace(taggedUrl, LinkWithTitle) const newValue = value.replace(taggedUrl, LinkWithTitle)
const newCursor = Object.assign({}, cursor, { ch: cursor.ch + newValue.length - value.length })
editor.setValue(newValue) editor.setValue(newValue)
editor.setCursor(cursor) editor.setCursor(newCursor)
}).catch((e) => { }).catch((e) => {
const value = editor.getValue() const value = editor.getValue()
const newValue = value.replace(taggedUrl, pastedTxt) const newValue = value.replace(taggedUrl, pastedTxt)