Set caret at the end if clicked outsite the block (#305)

* Set caret at last block or create new block at end

* update comment

* fix comments
This commit is contained in:
Murod Khaydarov 2018-07-18 20:23:26 +03:00 committed by GitHub
commit 4b1d9335b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 3 deletions

View file

@ -3788,6 +3788,24 @@ var BlockManager = function (_Module) {
return block;
}
/**
* Always inserts at the end
*/
}, {
key: 'insertAtEnd',
value: function insertAtEnd() {
/**
* Define new value for current block index
*/
this.currentBlockIndex = this.blocks.length - 1;
/**
* Insert initial typed block
*/
this.insert();
}
/**
* Merge two blocks
* @param {Block} targetBlock - previous block will be append to this block
@ -4522,7 +4540,7 @@ var Caret = function (_Module) {
if (lastBlock.isEmpty) {
this.setToBlock(lastBlock);
} else {
this.Editor.BlockManager.insert(this.config.initialBlock);
this.Editor.BlockManager.insertAtEnd();
}
}

File diff suppressed because one or more lines are too long

View file

@ -122,6 +122,21 @@ export default class BlockManager extends Module {
return block;
}
/**
* Always inserts at the end
*/
insertAtEnd() {
/**
* Define new value for current block index
*/
this.currentBlockIndex = this.blocks.length - 1;
/**
* Insert initial typed block
*/
this.insert();
}
/**
* Merge two blocks
* @param {Block} targetBlock - previous block will be append to this block

View file

@ -104,7 +104,7 @@ export default class Caret extends Module {
if (lastBlock.isEmpty) {
this.setToBlock(lastBlock);
} else {
this.Editor.BlockManager.insert(this.config.initialBlock);
this.Editor.BlockManager.insertAtEnd();
}
}