fix: revert changes to selectAll command, fix #2491
This commit is contained in:
@@ -20,7 +20,7 @@ export const setTextSelection: RawCommands['setTextSelection'] = position => ({
|
|||||||
? { from: position, to: position }
|
? { from: position, to: position }
|
||||||
: position
|
: position
|
||||||
const minPos = TextSelection.atStart(doc).from
|
const minPos = TextSelection.atStart(doc).from
|
||||||
const maxPos = doc.content.size
|
const maxPos = TextSelection.atEnd(doc).to
|
||||||
const resolvedFrom = minMax(from, minPos, maxPos)
|
const resolvedFrom = minMax(from, minPos, maxPos)
|
||||||
const resolvedEnd = minMax(to, minPos, maxPos)
|
const resolvedEnd = minMax(to, minPos, maxPos)
|
||||||
const selection = TextSelection.create(doc, resolvedFrom, resolvedEnd)
|
const selection = TextSelection.create(doc, resolvedFrom, resolvedEnd)
|
||||||
|
|||||||
@@ -12,23 +12,31 @@ export function resolveFocusPosition(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectionAtStart = Selection.atStart(doc)
|
||||||
|
const selectionAtEnd = Selection.atEnd(doc)
|
||||||
|
|
||||||
if (position === 'start' || position === true) {
|
if (position === 'start' || position === true) {
|
||||||
return Selection.atStart(doc)
|
return selectionAtStart
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position === 'end') {
|
if (position === 'end') {
|
||||||
return Selection.atEnd(doc)
|
return selectionAtEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const minPos = selectionAtStart.from
|
||||||
|
const maxPos = selectionAtEnd.to
|
||||||
|
|
||||||
if (position === 'all') {
|
if (position === 'all') {
|
||||||
return TextSelection.create(doc, 0, doc.content.size)
|
return TextSelection.create(
|
||||||
|
doc,
|
||||||
|
minMax(0, minPos, maxPos),
|
||||||
|
minMax(doc.content.size, minPos, maxPos),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if `position` is in bounds of the doc if `position` is a number.
|
return TextSelection.create(
|
||||||
const minPos = Selection.atStart(doc).from
|
doc,
|
||||||
const maxPos = Selection.atEnd(doc).to
|
minMax(position, minPos, maxPos),
|
||||||
const resolvedFrom = minMax(position, minPos, maxPos)
|
minMax(position, minPos, maxPos),
|
||||||
const resolvedEnd = minMax(position, minPos, maxPos)
|
)
|
||||||
|
|
||||||
return TextSelection.create(doc, resolvedFrom, resolvedEnd)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user