Răsfoiți Sursa

fix: resolve TypeScript errors from noUncheckedIndexedAccess

- Add non-null assertion on array index in mergePrevious handler
- Guard against undefined array access in onZoneActivate paste loop
Zander Hawke 4 zile în urmă
părinte
comite
3da1576ff3
1 a modificat fișierele cu 2 adăugiri și 1 ștergeri
  1. 2 1
      packages/editor/src/components/Editor.vue

+ 2 - 1
packages/editor/src/components/Editor.vue

@@ -377,7 +377,7 @@ function onMergePrevious(index: number) {
   // block objects in result.blocks might have stale content, causing the
   // debounced watch in Block.vue to re-apply the old value and lose state.
   const prevIndex = result.blocks.findIndex((b) => b.id === prev.id)
-  if (prevIndex !== -1) result.blocks[prevIndex].content = result.mergedContent
+  if (prevIndex !== -1) result.blocks[prevIndex]!.content = result.mergedContent
 
   blocks.value = result.blocks
   onBlockContentChange()
@@ -533,6 +533,7 @@ function onZoneActivate(index: number, content: string) {
     let firstInsertRecorded = false
     for (let i = 0; i < lines.length; i++) {
       const line = lines[i]
+      if (line === undefined) continue
       if (line === "" && i < lines.length - 1) continue
       const result = opInsertBlock(
         blocks.value,