Skip to content

Commit

Permalink
Handle paste only on initial Blocks (codex-team#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
gohabereg authored Feb 25, 2019
1 parent 8d6ac74 commit 712256e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
1 change: 0 additions & 1 deletion build/codex-editor.js.map

This file was deleted.

6 changes: 3 additions & 3 deletions dist/codex-editor.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 6 additions & 4 deletions src/components/modules/paste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 712256e

Please sign in to comment.