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

Merge pull request #1951 from yosmoc/update_cursor_position_after_link_extend

update cursor position after expanding the link
This commit is contained in:
Sosuke Suzuki
2018-05-28 14:25:42 +09:00
committed by GitHub

View File

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