fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Setting caret after removing list completely
[fnpeditor.git]
/
modules
/
documentCanvas
/
canvas
/
canvas.js
diff --git
a/modules/documentCanvas/canvas/canvas.js
b/modules/documentCanvas/canvas/canvas.js
index
88a8839
..
7143b79
100644
(file)
--- a/
modules/documentCanvas/canvas/canvas.js
+++ b/
modules/documentCanvas/canvas/canvas.js
@@
-23,9
+23,18
@@
$.extend(Canvas.prototype, {
var currentTag = $(this);
if(currentTag.attr('wlxml-tag'))
return;
var currentTag = $(this);
if(currentTag.attr('wlxml-tag'))
return;
+
+ var meta = {};
+ for(var i = 0; i < this.attributes.length; i++) {
+ var attr = this.attributes[i];
+ if(attr.name.substr(0, 5) === 'meta-')
+ meta[attr.name.substr(5)] = attr.value;
+ }
+
var element = documentElement.DocumentNodeElement.createDOM({
tag: currentTag.prop('tagName').toLowerCase(),
var element = documentElement.DocumentNodeElement.createDOM({
tag: currentTag.prop('tagName').toLowerCase(),
- klass: currentTag.attr('class')
+ klass: currentTag.attr('class'),
+ meta: meta
});
element.append(currentTag.contents());
});
element.append(currentTag.contents());
@@
-425,6
+434,9
@@
$.extend(Cursor.prototype, {
getSelectionAnchor: function() {
return this.getSelectionBoundry('anchor');
},
getSelectionAnchor: function() {
return this.getSelectionBoundry('anchor');
},
+ getSelectionFocus: function() {
+ return this.getSelectionBoundry('focus');
+ },
getSelectionBoundry: function(which) {
var selection = window.getSelection(),
anchorElement = this.canvas.getDocumentElement(selection.anchorNode),
getSelectionBoundry: function(which) {
var selection = window.getSelection(),
anchorElement = this.canvas.getDocumentElement(selection.anchorNode),
@@
-441,6
+453,14
@@
$.extend(Cursor.prototype, {
offsetAtEnd: anchorElement && anchorElement.getText().length === selection.anchorOffset
};
}
offsetAtEnd: anchorElement && anchorElement.getText().length === selection.anchorOffset
};
}
+ if(which === 'focus') {
+ return {
+ element: focusElement,
+ offset: selection.focusOffset,
+ offsetAtBeginning: selection.focusOffset === 0,
+ offsetAtEnd: focusElement && focusElement.getText().length === selection.focusOffset
+ };
+ }
var element,
offset;
var element,
offset;
@@
-468,7
+488,7
@@
$.extend(Cursor.prototype, {
}
}
} else {
}
}
} else {
- // TODO: Handle order
+ // TODO: Handle order
via https://developer.mozilla.org/en-US/docs/Web/API/Node.compareDocumentPosition
if(which === 'start') {
element = anchorElement;
offset = selection.anchorOffset
if(which === 'start') {
element = anchorElement;
offset = selection.anchorOffset