Skip to content

Commit

Permalink
0.0.10 3rd build
Browse files Browse the repository at this point in the history
  • Loading branch information
shiren committed Dec 15, 2015
1 parent e630e7d commit 54189ca
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 24 deletions.
70 changes: 48 additions & 22 deletions dist/tui-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,12 @@ var getOffsetLength = function(node) {
return len;
};

/**
* getNodeOffsetOfParent
* get node offset between parent's childnodes
* @param {Node} node node
* @return {number} offset(index)
*/
var getNodeOffsetOfParent = function(node) {
var i, t,
childNodesOfParent = node.parentNode.childNodes;
Expand All @@ -1510,8 +1516,35 @@ var getNodeOffsetOfParent = function(node) {
}
};

/**
* getChildNodeByOffset
* get child node by offset
* @param {Node} node node
* @param {number} index offset index
* @return {Node} foudned node
*/
var getChildNodeByOffset = function(node, index) {
var currentNode;

if (isTextNode(node)) {
currentNode = node;
} else {
currentNode = node.childNodes[index];
}

return currentNode;
};

var _getNodeWithDirectionUntil = function(direction, node, untilNodeName) {
/**
* getNodeWithDirectionUntil
* find next node from passed node
* 노드의 다음 노드를 찾는다 sibling노드가 없으면 부모레벨까지 올라가서 찾는다.
* @param {strong} direction previous or next
* @param {Node} node node
* @param {string} untilNodeName parent node name to limit
* @return {Node} founded node
*/
var getNodeWithDirectionUntil = function(direction, node, untilNodeName) {
var directionKey = direction + 'Sibling',
nodeName, foundedNode;

Expand All @@ -1535,34 +1568,27 @@ var _getNodeWithDirectionUntil = function(direction, node, untilNodeName) {
return foundedNode;
};

/**
* getPrevOffsetNodeUntil
* get prev node of childnode pointed with index
* 인덱스에 해당하는 차일드 노드의 이전 노드를 찾는다.
* @param {Node} node node
* @param {number} index offset index
* @param {string} untilNodeName parent node name to limit
* @return {Node} founded node
*/
var getPrevOffsetNodeUntil = function(node, index, untilNodeName) {
var prevNode;

if (index > 0) {
if (isTextNode(node)) {
prevNode = node;
} else {
prevNode = node.childNodes[index - 1];
}
prevNode = getChildNodeByOffset(node, index - 1);
} else {
prevNode = _getNodeWithDirectionUntil('previous', node, untilNodeName);
prevNode = getNodeWithDirectionUntil('previous', node, untilNodeName);
}

return prevNode;
};

var getNodeByOffset = function(node, index) {
var currentNode;

if (isTextNode(node)) {
currentNode = node;
} else {
currentNode = node.childNodes[index];
}

return currentNode;
};

module.exports = {
getChildNodeAt: getChildNodeAt,
getNodeName: getNodeName,
Expand All @@ -1572,7 +1598,7 @@ module.exports = {
getOffsetLength: getOffsetLength,
getPrevOffsetNodeUntil: getPrevOffsetNodeUntil,
getNodeOffsetOfParent: getNodeOffsetOfParent,
getNodeByOffset: getNodeByOffset
getChildNodeByOffset: getChildNodeByOffset
};

},{}],9:[function(require,module,exports){
Expand Down Expand Up @@ -7910,7 +7936,7 @@ WysiwygEditor.prototype._initSquireEvent = function() {
var sel = self.editor.getSelection(),
eventObj;

if (!this._silentChange) {
if (!self._silentChange) {
eventObj = {
source: 'wysiwyg',
selection: sel,
Expand All @@ -7922,7 +7948,7 @@ WysiwygEditor.prototype._initSquireEvent = function() {
self.eventManager.emit('change', eventObj);
self.eventManager.emit('contentChangedFromWysiwyg', self);
} else {
this._silentChange = false;
self._silentChange = false;
}

self._autoResizeHeightIfNeed();
Expand Down
Loading

0 comments on commit 54189ca

Please sign in to comment.