fix: fix RangeError bug when selecting all text, fix #2490

This commit is contained in:
Philipp Kühn
2022-02-07 09:07:17 +01:00
parent 54b6c395cd
commit 70422dd107
2 changed files with 3 additions and 3 deletions

View File

@@ -145,7 +145,7 @@ export default {
<tr> <tr>
<td>Hans Pagel</td> <td>Hans Pagel</td>
<td>wrote this</td> <td>wrote this</td>
<td colspan="2">thats it</td> <td colspan="2"></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@@ -19,8 +19,8 @@ export const setTextSelection: RawCommands['setTextSelection'] = position => ({
const { from, to } = typeof position === 'number' const { from, to } = typeof position === 'number'
? { from: position, to: position } ? { from: position, to: position }
: position : position
const minPos = 0 const minPos = TextSelection.atStart(doc).from
const maxPos = tr.doc.content.size const maxPos = doc.content.size
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)