Handle paste only on initial Blocks (#623)

This commit is contained in:
George Berezhnoy 2019-02-26 00:38:45 +03:00 committed by GitHub
parent 8d6ac74b57
commit 712256e23d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 9 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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

View file

@ -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",

View file

@ -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;
}