fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
canvas manager wip - setting cursor at the beginning of a new node
[fnpeditor.git]
/
modules
/
documentCanvas
/
canvas.js
diff --git
a/modules/documentCanvas/canvas.js
b/modules/documentCanvas/canvas.js
index
44f88a9
..
20c286a
100644
(file)
--- a/
modules/documentCanvas/canvas.js
+++ b/
modules/documentCanvas/canvas.js
@@
-9,13
+9,14
@@
define([
'use strict';
\r
\r
var Canvas = function(xml) {
\r
'use strict';
\r
\r
var Canvas = function(xml) {
\r
- this.xml = xml;
\r
this.dom = $(template);
\r
this.dom = $(template);
\r
-
\r
- this.content = this.dom.find('#rng-module-documentCanvas-content')
\r
-
\r
-
\r
- this.content.html(transformations.fromXML.getHTMLTree(xml));
\r
+ this.content = this.dom.find('#rng-module-documentCanvas-content');
\r
+ this.setXML(xml);
\r
+}
\r
+
\r
+Canvas.prototype.setXML = function(xml) {
\r
+ this.xml = xml;
\r
+ this.content.html(transformations.fromXML.getHTMLTree(xml));
\r
}
\r
\r
Canvas.prototype.toXML = function() {
\r
}
\r
\r
Canvas.prototype.toXML = function() {
\r
@@
-70,38
+71,39
@@
Canvas.prototype.insertNode = function(options) {
Canvas.prototype.splitNode = function(options) {
\r
options = _.extend({textNodeIdx: 0}, options);
\r
\r
Canvas.prototype.splitNode = function(options) {
\r
options = _.extend({textNodeIdx: 0}, options);
\r
\r
- var
elemen
t = $(this.content.find('#' + options.node.id).get(0));
\r
+ var
nodeToSpli
t = $(this.content.find('#' + options.node.id).get(0));
\r
\r
\r
- var
elementContents = elemen
t.contents();
\r
- if(
element
Contents.length === 0 ||
\r
-
element
Contents.length - 1 < options.textNodeIdx ||
\r
-
element
Contents.get(options.textNodeIdx).nodeType != 3)
\r
+ var
nodeContents = nodeToSpli
t.contents();
\r
+ if(
node
Contents.length === 0 ||
\r
+
node
Contents.length - 1 < options.textNodeIdx ||
\r
+
node
Contents.get(options.textNodeIdx).nodeType != 3)
\r
return false;
\r
\r
return false;
\r
\r
- var text
Element = elementContents.get(options.textNodeIdx
);
\r
+ var text
Node = $(nodeContents.get(options.textNodeIdx)
);
\r
\r
var succeedingNodes = [];
\r
var passed = false;
\r
\r
var succeedingNodes = [];
\r
var passed = false;
\r
-
element
Contents.each(function() {
\r
+
node
Contents.each(function() {
\r
var node = this;
\r
if(passed)
\r
succeedingNodes.push(node);
\r
var node = this;
\r
if(passed)
\r
succeedingNodes.push(node);
\r
- if(node.isSameNode(text
Element
))
\r
+ if(node.isSameNode(text
Node.get(0)
))
\r
passed = true;
\r
});
\r
\r
passed = true;
\r
});
\r
\r
- var prefix = textElement.data.substr(0, options.offset);
\r
- var suffix = textElement.data.substr(options.offset);
\r
+ var prefix = textNode.text().substr(0, options.offset);
\r
+ var suffix = textNode.text().substr(options.offset);
\r
+
\r
+ textNode.before(prefix);
\r
+ textNode.remove();
\r
\r
\r
- var $textElement = $(textElement);
\r
- $textElement.before(prefix);
\r
- $textElement.remove();
\r
- var newNode = this._createNode(element.attr('wlxml-tag'), element.attr('wlxml-class'));
\r
+ var newNode = this._createNode(nodeToSplit.attr('wlxml-tag'), nodeToSplit.attr('wlxml-class'));
\r
newNode.append(suffix);
\r
succeedingNodes.forEach(function(node) {
\r
newNode.append(node)
\r
});
\r
newNode.append(suffix);
\r
succeedingNodes.forEach(function(node) {
\r
newNode.append(node)
\r
});
\r
- element.after(newNode);
\r
+ nodeToSplit.after(newNode);
\r
+ return newNode;
\r
}
\r
\r
Canvas.prototype.createList = function(options) {
\r
}
\r
\r
Canvas.prototype.createList = function(options) {
\r