fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
integration wip: restoring document
[fnpeditor.git]
/
src
/
editor
/
modules
/
documentCanvas
/
canvas
/
documentElement.js
diff --git
a/src/editor/modules/documentCanvas/canvas/documentElement.js
b/src/editor/modules/documentCanvas/canvas/documentElement.js
index
4378e73
..
89ffce9
100644
(file)
--- a/
src/editor/modules/documentCanvas/canvas/documentElement.js
+++ b/
src/editor/modules/documentCanvas/canvas/documentElement.js
@@
-52,6
+52,13
@@
$.extend(DocumentElement.prototype, {
dom: function() {
return this.$element;
},
dom: function() {
return this.$element;
},
+ data: function() {
+ var dom = this.dom(),
+ args = Array.prototype.slice.call(arguments, 0);
+ if(args.length === 2 && args[1] === undefined)
+ return dom.removeData(args[0]);
+ return dom.data.apply(dom, arguments);
+ },
parent: function() {
var parents = this.$element.parents('[document-node-element]');
if(parents.length)
parent: function() {
var parents = this.$element.parents('[document-node-element]');
if(parents.length)
@@
-162,6
+169,9
@@
$.extend(DocumentNodeElement, {
var element = this.fromHTMLElement(dom[0], canvas);
var element = this.fromHTMLElement(dom[0], canvas);
+ element.data('wlxmlNode', wlxmlNode);
+ wlxmlNode.setData('canvasElement', element);
+
element.setWlxml({tag: wlxmlNode.getTagName(), klass: wlxmlNode.getClass()});
_.keys(wlxmlNode.getMetaAttributes()).forEach(function(key) {
element.setWlxml({tag: wlxmlNode.getTagName(), klass: wlxmlNode.getClass()});
_.keys(wlxmlNode.getMetaAttributes()).forEach(function(key) {
@@
-257,13
+267,6
@@
$.extend(DocumentNodeElement.prototype, {
element2: parent.children()[myIdx + childrenLength-1 + (moveRightRange ? 1 : 0)]
};
},
element2: parent.children()[myIdx + childrenLength-1 + (moveRightRange ? 1 : 0)]
};
},
- data: function() {
- var dom = this.dom(),
- args = Array.prototype.slice.call(arguments, 0);
- if(args.length === 2 && args[1] === undefined)
- return dom.removeData(args[0]);
- return dom.data.apply(dom, arguments);
- },
toXML: function(level) {
var node = $('<' + this.getWlxmlTag() + '>');
toXML: function(level) {
var node = $('<' + this.getWlxmlTag() + '>');
@@
-477,9
+480,12
@@
var DocumentTextElement = function(htmlElement, canvas) {
$.extend(DocumentTextElement, {
createDOM: function(wlxmlTextNode) {
$.extend(DocumentTextElement, {
createDOM: function(wlxmlTextNode) {
-
return
$('<div>')
+
var dom =
$('<div>')
.attr('document-text-element', '')
.attr('document-text-element', '')
- .text(wlxmlTextNode.getText() || utils.unicode.ZWS);
+ .text(wlxmlTextNode.getText() || utils.unicode.ZWS),
+ element = this.fromHTMLElement(dom[0], this);
+ element.data('wlxmlNode', wlxmlTextNode);
+ return dom;
},
create: function(wlxmlTextNode, canvas) {
},
create: function(wlxmlTextNode, canvas) {
@@
-521,8
+527,13
@@
$.extend(DocumentTextElement.prototype, {
prependText: function(text) {
this.dom().contents()[0].data = text + this.dom().contents()[0].data;
},
prependText: function(text) {
this.dom().contents()[0].data = text + this.dom().contents()[0].data;
},
- getText: function() {
- return this.dom().text().replace(utils.unicode.ZWS, '');
+ getText: function(options) {
+ options = _.extend({raw: false}, options || {});
+ var toret = this.dom().text();
+ if(!options.raw) {
+ toret = toret.replace(utils.unicode.ZWS, '');
+ }
+ return toret;
},
isEmpty: function() {
// Having at least Zero Width Space is guaranteed be Content Observer
},
isEmpty: function() {
// Having at least Zero Width Space is guaranteed be Content Observer