Skip to content

Commit 950c329

Browse files
rainkehep4
andauthored
fix(plugin-block): add dragend event listener to block handle element (#2199)
Co-authored-by: hep4 <hep4@chinatelecom.cn>
1 parent 6e90c43 commit 950c329

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/plugins/plugin-block/src/block-service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,15 @@ export class BlockService {
108108
dom.addEventListener('mousedown', this.#handleMouseDown)
109109
dom.addEventListener('mouseup', this.#handleMouseUp)
110110
dom.addEventListener('dragstart', this.#handleDragStart)
111+
dom.addEventListener('dragend', this.#handleDragEnd)
111112
}
112113

113114
/// Remove mouse event to the dom.
114115
removeEvent = (dom: HTMLElement) => {
115116
dom.removeEventListener('mousedown', this.#handleMouseDown)
116117
dom.removeEventListener('mouseup', this.#handleMouseUp)
117118
dom.removeEventListener('dragstart', this.#handleDragStart)
119+
dom.removeEventListener('dragend', this.#handleDragEnd)
118120
}
119121

120122
/// Unbind the notify function.
@@ -171,6 +173,13 @@ export class BlockService {
171173
}
172174
}
173175

176+
/// @internal
177+
#handleDragEnd = () => {
178+
if (this.#view) {
179+
this.#dragEnd(this.#view)
180+
}
181+
}
182+
174183
/// @internal
175184
keydownCallback = (view: EditorView) => {
176185
this.#hide()

0 commit comments

Comments
 (0)