quill: copy paste error : Failed to execute 'setStart' on 'Range': The offset 4294967295 is larger than the node's length (0).
When selecting multiline text with cmd+A and then pasting new text with cmd+V I get this error.
polyfills.js:6527 Uncaught DOMException: Failed to execute 'setStart' on 'Range': The offset 4294967295 is larger than the node's length (0). at Selection.getBounds (file:///Library/Application%20Support/Adobe/CEP/extensions/individeo_dev/main/main.js:106585:19) at Selection.scrollIntoView (file:///Library/Application%20Support/Adobe/CEP/extensions/individeo_dev/main/main.js:106719:25) at Quill.scrollIntoView (file:///Library/Application%20Support/Adobe/CEP/extensions/individeo_dev/main/main.js:105074:22) at Quill.focus (file:///Library/Application%20Support/Adobe/CEP/extensions/individeo_dev/main/main.js:104819:12) at Timeout.<anonymous> (file:///Library/Application%20Support/Adobe/CEP/extensions/individeo_dev/main/main.js:112577:22) at ZoneDelegate.push.../../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (file:///Library/Application%20Support/Adobe/CEP/extensions/individeo_dev/main/polyfills.js:6756:35) at Zone.push.../../node_modules/zone.js/dist/zone.js.Zone.runTask (file:///Library/Application%20Support/Adobe/CEP/extensions/individeo_dev/main/polyfills.js:6523:51) at push.../../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask (file:///Library/Application%20Support/Adobe/CEP/extensions/individeo_dev/main/polyfills.js:6838:38) at Timeout.ZoneTask.invoke (file:///Library/Application%20Support/Adobe/CEP/extensions/individeo_dev/main/polyfills.js:6827:52) at Timeout.timer [as _onTimeout] (file:///Library/Application%20Support/Adobe/CEP/extensions/individeo_dev/main/polyfills.js:9369:33) at ontimeout (timers.js:469:11) at tryOnTimeout (timers.js:304:5) at Timer.listOnTimeout (timers.js:264:5)
Expected behavior:
text should replace actual text selection
Actual behavior:
I get error message
Platforms:
chrome “61.0.3163.91” Mac 10.14.6
Version:
"ngx-quill": "^11.0.0",
"@types/quill": "^1.3.10",
"quill": "^1.3.7",
"quill-mention": "^2.2.7",
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 20
Thank you so much, you just saved me a lot of time trying to solve this problem. We also encountered this error using Quill with Vue 3 (Options API) and storing the Quill Instance in a reactive variable for various content modifications. The error only occured after pasting content into the editor (no matter how long after it was initialized).
For anyone also having this problem, this is how I solved it: I removed everything where Vue might interfere and handled everything manually by
Everything is working flawlessly now.
I have the same problem after instantiated a new editor and call setContents() with previous delta stored in database. When I want to add new line or edit the document start doing weird stuff and finally raise the error: Uncaught DOMException: Failed to execute ‘setStart’ on ‘Range’: The offset 4294967295 is larger than the node’s length.
I think I’ve found the problem. The quill should not be a reactive or ref but a simple variable.
When I
quill.setContents([]), then input some text, finnally ⌫ one by one, I got it.I was having the same problem whith Vue3 Composition API. The way I solved it is avoiding using Vue refs for handling the editor and instead catching the quill instance via id (as quill docs specify).
`<script setup lang="ts" > import { onMounted } from “vue”; import Quill from “quill”;
type Props = { payload: Delta }; const props = defineProps<Props>();
onMounted(() => { const options = your options
const container = document.getElementById(“container”); const editor = new Quill(container, options);
editor.setContents(props.payload, “api”);
}); </script> <template>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet" /> <div id="container"></div> </template>`The con is you have to insert logic inside onMounted hook but this way you can avoid using the quill instance via a ref
found the problem
core/selection.js
need to check if offset if > 0 like this
pull request here https://github.com/quilljs/quill/pull/3081