-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent duplicated event dispatching #1381
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,7 +155,7 @@ export default class BlockSelection extends Module { | |
Shortcuts.add({ | ||
name: 'CMD+A', | ||
handler: (event) => { | ||
const { BlockManager, ReadOnly } = this.Editor; | ||
const { ReadOnly } = this.Editor; | ||
|
||
/** | ||
* We use Editor's Block selection on CMD+A ShortCut instead of Browsers | ||
|
@@ -175,7 +175,7 @@ export default class BlockSelection extends Module { | |
* | ||
* Prevent such actions if focus is not inside the Editor | ||
*/ | ||
if (!BlockManager.currentBlock) { | ||
if (!event.target.closest(`.${this.Editor.UI.CSS.editorWrapper}`)?.isEqualNode(this.Editor.UI.nodes.wrapper)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When multiple Editor.js instances are launched, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe it makes sense to create a function inside UI module that gets event and checks if event's target is under editor's instance wrapper? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly, this method seems DOM hacking! |
||
return; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -439,6 +439,13 @@ export default class Paste extends Module { | |
private handlePasteEvent = async (event: ClipboardEvent): Promise<void> => { | ||
const { BlockManager, Toolbar } = this.Editor; | ||
|
||
if ( | ||
!(event.target instanceof Element) || | ||
!event.target.closest(`.${this.Editor.UI.CSS.editorWrapper}`)?.isEqualNode(this.Editor.UI.nodes.wrapper) | ||
) { | ||
return; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And... This fix is also already resolved in |
||
/** If target is native input or is not Block, use browser behaviour */ | ||
if ( | ||
!BlockManager.currentBlock || (this.isNativeBehaviour(event.target) && !event.clipboardData.types.includes('Files')) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn lint:fix