Skip to content

Commit

Permalink
Fixing caret behaviour. (#282)
Browse files Browse the repository at this point in the history
Plugins can change their state so that affect on Block's pluginsContent property which is in memory.
  • Loading branch information
khaydarov authored Jul 16, 2018
1 parent e7777d5 commit f96b2ad
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions 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.

6 changes: 3 additions & 3 deletions src/components/modules/blockManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ export default class BlockManager extends Module {
* @param {Object} block
*/
bindEvents(block) {
this.Editor.Listeners.on(block.pluginsContent, 'keydown', (event) => this.Editor.BlockEvents.keydown(event));
this.Editor.Listeners.on(block.pluginsContent, 'mouseup', (event) => this.Editor.BlockEvents.mouseUp(event));
this.Editor.Listeners.on(block.pluginsContent, 'keyup', (event) => this.Editor.BlockEvents.keyup(event));
this.Editor.Listeners.on(block.html, 'keydown', (event) => this.Editor.BlockEvents.keydown(event));
this.Editor.Listeners.on(block.html, 'mouseup', (event) => this.Editor.BlockEvents.mouseUp(event));
this.Editor.Listeners.on(block.html, 'keyup', (event) => this.Editor.BlockEvents.keyup(event));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/components/modules/caret.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class Caret extends Module {
* @param {Boolean} atEnd - put caret at the end of the text node or not
*/
setToBlock(block, offset = 0, atEnd = false) {
let element = block.pluginsContent;
let element = block.html;

/** If Element is INPUT */
if ($.isNativeInput(element)) {
Expand Down Expand Up @@ -224,7 +224,7 @@ export default class Caret extends Module {

let selection = Selection.get(),
anchorNode = selection.anchorNode,
firstNode = $.getDeepestNode(this.Editor.BlockManager.currentBlock.pluginsContent);
firstNode = $.getDeepestNode(this.Editor.BlockManager.currentBlock.html);

/**
* Workaround case when caret in the text like " |Hello!"
Expand Down Expand Up @@ -276,7 +276,7 @@ export default class Caret extends Module {

let selection = Selection.get(),
anchorNode = selection.anchorNode,
lastNode = $.getDeepestNode(this.Editor.BlockManager.currentBlock.pluginsContent, true);
lastNode = $.getDeepestNode(this.Editor.BlockManager.currentBlock.html, true);

/**
* In case of
Expand Down

0 comments on commit f96b2ad

Please sign in to comment.