Quellcode durchsuchen

fix: 撤销已删除的区域要重新渲染

wzl vor 4 Monaten
Ursprung
Commit
350afc7827

+ 3 - 0
packages/core/src/editor/image_editor.js

@@ -1162,6 +1162,8 @@ export class ImageEditor {
 
   // 删除区域
   async handleDelete () {
+    await this.handleOutside()
+    
     this.removed = true
     this.outerLineContainer.remove()
     this.frameContainer.remove()
@@ -1492,5 +1494,6 @@ export class ImageEditor {
     this.imageArray = imageArray
 
     this.drawCanvas()
+    this.saveEdit()
   }
 }

+ 11 - 3
packages/core/src/editor/text_editor.js

@@ -804,15 +804,15 @@ export class TextEditor {
     
     this.state = this.state === 2 ? 1 : this.state === 1 ? 0 : this.state
 
-    this.frameContainer.classList.remove('editing')
+    this.frameContainer?.classList.remove('editing')
 
     this.clearSelectText()
     this.cursor?.remove()
     this.cursor = null
 
     if (this.state === 0) {
-      this.frameContainer.classList.remove('selected')
-      this.outerLine.remove()
+      this.frameContainer?.classList.remove('selected')
+      this.outerLine?.remove()
 
       if (!this.removed) this.contentContainer.selectedFrameIndex = -1
 
@@ -1685,8 +1685,12 @@ export class TextEditor {
 
   // 删除区域
   async remove () {
+    this.state = 0
+    await this.handleOutside()
+
     await this.outerLine.remove()
     this.frameContainer.remove()
+    this.frameContainer = null
     this.contentContainer.selectedFrameIndex = -1
     this.removed = true
 
@@ -1764,6 +1768,9 @@ export class TextEditor {
         width: this.rect.width + 'px',
         height: this.rect.height + 'px'
       })
+    } else {
+      this.removed = false
+      this.render()
     }
 
     const wholeAreaRect = this.getEntireArea(this.oldRect, this.rect)
@@ -1792,5 +1799,6 @@ export class TextEditor {
     this.imageArray = imageArray
 
     this.drawCanvas()
+    this.saveEdit()
   }
 }

+ 2 - 8
packages/core/src/index.js

@@ -4186,9 +4186,6 @@ class ComPDFKitViewer {
       const canRedo = await this.messageHandler.sendWithPromise('CanRedo', lastUndo.editPagePtr)
       canRedo && this.redoList.push(lastUndo)
       
-      // const editor = this.pdfViewer._pages[lastUndo.pageIndex].contentContainer.frameEditorList.find(item => item.editAreaPtr === lastUndo.editAreaPtr)
-      // editor.updateCanvasAfterUndoRedo(false, true)
-      // editor.updateCursorLine(res.editCharPlace)
       this.pdfViewer._pages[lastUndo.pageIndex].contentContainer.updateFrameEditor(res)
 
     } else if (op === 'redo') {
@@ -4196,14 +4193,11 @@ class ComPDFKitViewer {
       const res = await this.messageHandler.sendWithPromise('Redo', lastRedo.editPagePtr)
       this.undoList.push(lastRedo)
 
-      // const editor = this.pdfViewer._pages[lastRedo.pageIndex].contentContainer.frameEditorList.find(item => item.editAreaPtr === lastRedo.editAreaPtr)
-      // editor.updateCanvasAfterUndoRedo(false, true)
-      // editor.updateCursorLine(res.editCharPlace)
       this.pdfViewer._pages[lastRedo.pageIndex].contentContainer.updateFrameEditor(res)
     }
 
-    console.log('undoList: ', this.undoList)
-    console.log('redoList: ', this.redoList)
+    // console.log('undoList: ', this.undoList)
+    // console.log('redoList: ', this.redoList)
     this.eventBus.dispatch('changeOperateList', {
       undoListLength: this.undoList.length,
       redoListLength: this.redoList.length