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

Переход курсора на следующий и предыдущий блоки при нажатии на кнопки вверх/вниз #32

Merged
merged 16 commits into from
Jun 10, 2016
Prev Previous commit
Next Next commit
ce_block to constant
  • Loading branch information
khaydarov committed Jun 10, 2016
commit 0ace81d20fc8c215d8a6c0c26e83b9390cc392e7
17 changes: 7 additions & 10 deletions codex-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ cEditor.core = {

cEditor.ui = {

/** Blocks name. */
BLOCK_CLASSNAME : 'ce_block',

/**
* Making main interface
*/
Expand Down Expand Up @@ -401,7 +404,7 @@ cEditor.callback = {
return false;
}

while (focusedNode.className != 'ce_block') {
while (focusedNode.className != cEditor.ui.BLOCK_CLASSNAME) {

focusedNodeHolder = focusedNode.parentNode;
focusedNode = focusedNodeHolder;
Expand Down Expand Up @@ -455,7 +458,7 @@ cEditor.callback = {


/** Looking for parent contentEditable block */
while (focusedNode.className != 'ce_block') {
while (focusedNode.className != cEditor.ui.BLOCK_CLASSNAME) {
focusedNodeHolder = focusedNode.parentNode;
focusedNode = focusedNodeHolder;
}
Expand Down Expand Up @@ -573,7 +576,7 @@ cEditor.content = {

/** Mark node as redactor block */
nodeCreated.contentEditable = "true";
nodeCreated.classList.add('ce_block');
nodeCreated.classList.add(cEditor.ui.BLOCK_CLASSNAME);

/**
* If it is a first-level node, replace as-is.
Expand Down Expand Up @@ -749,7 +752,7 @@ cEditor.caret = {
if ( childs.length === 0 ) {

nodeToSet = el;

} else {

nodeToSet = childs[index];
Expand Down Expand Up @@ -819,10 +822,6 @@ cEditor.caret = {
cEditor.caret.offset = theEndOfPreviousBlockLastNode;
cEditor.caret.focusedNodeIndex = lastChildOfPreiviousBlockIndex;

console.log('block %o', previousBlock);
console.log('offset %o', theEndOfPreviousBlockLastNode);
console.log('node %o', lastChildOfPreiviousBlockIndex);

cEditor.caret.set(previousBlock , lastChildOfPreiviousBlockIndex, theEndOfPreviousBlockLastNode);
},
};
Expand Down Expand Up @@ -1056,8 +1055,6 @@ cEditor.parser = {
/** Save block to the cEditor.state array */
cEditor.state.blocks.push(block);

cEditor.ui.addBlockHandlers(block);

return block;

};
Expand Down