mirror of
https://github.com/codex-team/editor.js
synced 2024-05-17 22:06:49 +02:00
Handle paste only on initial Blocks (#623)
This commit is contained in:
parent
8d6ac74b57
commit
712256e23d
File diff suppressed because one or more lines are too long
6
dist/codex-editor.js
vendored
6
dist/codex-editor.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
### 2.9.3
|
||||
|
||||
- `Fix` Handle paste only on initial Block
|
||||
|
||||
### 2.9.2
|
||||
|
||||
- `New` Blocks selected with RectangleSelection can be also removed, copied or cut
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "codex.editor",
|
||||
"version": "2.9.2",
|
||||
"version": "2.9.3",
|
||||
"description": "CodeX Editor. Native JS, based on API and Open Source",
|
||||
"main": "dist/codex-editor.js",
|
||||
"types": "./types/index.d.ts",
|
||||
|
|
|
@ -177,9 +177,9 @@ export default class Paste extends Module {
|
|||
* Set onPaste callback handler
|
||||
*/
|
||||
private setCallback(): void {
|
||||
const {Listeners, UI} = this.Editor;
|
||||
const {Listeners} = this.Editor;
|
||||
|
||||
Listeners.on(document, 'paste', this.handlePasteEvent);
|
||||
Listeners.on(document, 'paste', this.handlePasteEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -336,11 +336,13 @@ export default class Paste extends Module {
|
|||
* @param {ClipboardEvent} event
|
||||
*/
|
||||
private handlePasteEvent = async (event: ClipboardEvent): Promise<void> => {
|
||||
const {BlockManager, Toolbar} = this.Editor;
|
||||
const {BlockManager, Tools, Toolbar} = this.Editor;
|
||||
|
||||
const isInitialTool = BlockManager.currentBlock && Tools.isInitial(BlockManager.currentBlock.tool);
|
||||
|
||||
/** If target is native input or is not Block, use browser behaviour */
|
||||
if (
|
||||
!BlockManager.currentBlock || this.isNativeBehaviour(event.target) && !event.clipboardData.types.includes('Files')
|
||||
!isInitialTool
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue