Browse Source

fix: 不同时打开多个note

wzl 1 year ago
parent
commit
0e370fff79
1 changed files with 4 additions and 1 deletions
  1. 4 1
      packages/core/src/annotation/text.js

+ 4 - 1
packages/core/src/annotation/text.js

@@ -263,7 +263,8 @@ export default class Text extends Base {
     }
   }
 
-  handleClickOutside () {
+  handleClickOutside (element) {
+    if (element === this.annotationContainer || !this.popShow) return
     this.popShow = false
     this.textEditorContainer.remove()
     this.annotationContainer.style.zIndex = 6
@@ -285,6 +286,7 @@ export default class Text extends Base {
       event.stopPropagation()
     }
     if (this.moving) return
+    this.eventBus.dispatch('closeTextEditor', event.target.closest('.annotation.text'))
     if (this.popShow) return
     this.popShow = true
     this.annotationContainer.append(this.textEditorContainer)
@@ -426,5 +428,6 @@ export default class Text extends Base {
     this.deletetButton = deletetButton
     textEditorContainer.append(deletetButton)
     this.deletetButton.addEventListener('click', this.onDelete)
+    this.eventBus._on('closeTextEditor', this.handleClickOutside.bind(this))
   }
 }