mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-01 05:16:10 +01:00
fix(example/links): a few fixes for the links example (#2175)
* Correctly use the selection * check whether the user cancelled the prompt * use `moveFocusBackward`
This commit is contained in:
parent
222f746e85
commit
462244600d
@ -133,16 +133,30 @@ class Links extends React.Component {
|
||||
|
||||
if (hasLinks) {
|
||||
change.call(unwrapLink)
|
||||
} else if (value.isExpanded) {
|
||||
} else if (value.selection.isExpanded) {
|
||||
const href = window.prompt('Enter the URL of the link:')
|
||||
|
||||
if (href === null) {
|
||||
return
|
||||
}
|
||||
|
||||
change.call(wrapLink, href)
|
||||
} else {
|
||||
const href = window.prompt('Enter the URL of the link:')
|
||||
|
||||
if (href === null) {
|
||||
return
|
||||
}
|
||||
|
||||
const text = window.prompt('Enter the text for the link:')
|
||||
|
||||
if (text === null) {
|
||||
return
|
||||
}
|
||||
|
||||
change
|
||||
.insertText(text)
|
||||
.extend(0 - text.length)
|
||||
.moveFocusBackward(text.length)
|
||||
.call(wrapLink, href)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user