fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
editor: minor refactoring
[fnpeditor.git]
/
src
/
editor
/
modules
/
documentCanvas
/
canvas
/
canvas.js
diff --git
a/src/editor/modules/documentCanvas/canvas/canvas.js
b/src/editor/modules/documentCanvas/canvas/canvas.js
index
5bd5e85
..
d8090c8
100644
(file)
--- a/
src/editor/modules/documentCanvas/canvas/canvas.js
+++ b/
src/editor/modules/documentCanvas/canvas/canvas.js
@@
-200,7
+200,7
@@
$.extend(Canvas.prototype, Backbone.Events, {
/* globals MutationObserver */
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
/* globals MutationObserver */
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
- if(documentElement.DocumentTextElement.isContentContainer(mutation.target)) {
+ if(
canvas.dom[0].contains(mutation.target) &&
documentElement.DocumentTextElement.isContentContainer(mutation.target)) {
observer.disconnect();
if(mutation.target.data === '') {
mutation.target.data = utils.unicode.ZWS;
observer.disconnect();
if(mutation.target.data === '') {
mutation.target.data = utils.unicode.ZWS;
@@
-377,7
+377,7
@@
$.extend(Canvas.prototype, Backbone.Events, {
if(textElementToLand) {
_markAsCurrent(textElementToLand);
if(textElementToLand) {
_markAsCurrent(textElementToLand);
- if(
params.caretTo
|| !textElementToLand.sameNode(this.getCursor().getPosition().element)) {
+ if(
(params.caretTo || params.caretTo === 0)
|| !textElementToLand.sameNode(this.getCursor().getPosition().element)) {
this._moveCaretToTextElement(textElementToLand, params.caretTo); // as method on element?
}
} else {
this._moveCaretToTextElement(textElementToLand, params.caretTo); // as method on element?
}
} else {
@@
-418,14
+418,6
@@
$.extend(Canvas.prototype, Backbone.Events, {
if(position.element) {
this._moveCaretToTextElement(position.element, position.offset);
}
if(position.element) {
this._moveCaretToTextElement(position.element, position.offset);
}
- },
-
- toggleGrid: function() {
- this.rootWrapper.toggleClass('grid-on');
- this.trigger('changed');
- },
- isGridToggled: function() {
- return this.rootWrapper.hasClass('grid-on');
}
});
}
});
@@
-465,6
+457,9
@@
$.extend(Selection.prototype, {
return doc.createFragment(doc.CaretFragment, {node: anchorNode, offset: this.nativeSelection.anchorOffset});
}
if(this.type === 'textSelection') {
return doc.createFragment(doc.CaretFragment, {node: anchorNode, offset: this.nativeSelection.anchorOffset});
}
if(this.type === 'textSelection') {
+ if(!anchorNode || !focusNode) {
+ return;
+ }
if(anchorNode.isSiblingOf(focusNode)) {
return doc.createFragment(doc.TextRangeFragment, {
node1: anchorNode,
if(anchorNode.isSiblingOf(focusNode)) {
return doc.createFragment(doc.TextRangeFragment, {
node1: anchorNode,