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 }
|
||||
: position
|
||||
const minPos = TextSelection.atStart(doc).from
|
||||
const maxPos = doc.content.size
|
||||
const maxPos = TextSelection.atEnd(doc).to
|
||||
const resolvedFrom = minMax(from, minPos, maxPos)
|
||||
const resolvedEnd = minMax(to, minPos, maxPos)
|
||||
const selection = TextSelection.create(doc, resolvedFrom, resolvedEnd)
|
||||
|
||||
@@ -12,23 +12,31 @@ export function resolveFocusPosition(
|
||||
return null
|
||||
}
|
||||
|
||||
const selectionAtStart = Selection.atStart(doc)
|
||||
const selectionAtEnd = Selection.atEnd(doc)
|
||||
|
||||
if (position === 'start' || position === true) {
|
||||
return Selection.atStart(doc)
|
||||
return selectionAtStart
|
||||
}
|
||||
|
||||
if (position === 'end') {
|
||||
return Selection.atEnd(doc)
|
||||
return selectionAtEnd
|
||||
}
|
||||
|
||||
const minPos = selectionAtStart.from
|
||||
const maxPos = selectionAtEnd.to
|
||||
|
||||
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.
|
||||
const minPos = Selection.atStart(doc).from
|
||||
const maxPos = Selection.atEnd(doc).to
|
||||
const resolvedFrom = minMax(position, minPos, maxPos)
|
||||
const resolvedEnd = minMax(position, minPos, maxPos)
|
||||
|
||||
return TextSelection.create(doc, resolvedFrom, resolvedEnd)
|
||||
return TextSelection.create(
|
||||
doc,
|
||||
minMax(position, minPos, maxPos),
|
||||
minMax(position, minPos, maxPos),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user