Skip to content
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

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

Merged
merged 4 commits into from
Jul 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion build/codex-editor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/codex-editor.js.map

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/components/modules/blockManager.js
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/components/modules/caret.js
Original file line number Diff line number Diff line change
@@ -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();
}
}