'libs/jquery',
'libs/underscore',
'libs/backbone',
+'fnpjs/logging/logging',
'modules/documentCanvas/canvas/documentElement',
'modules/documentCanvas/canvas/keyboard',
'modules/documentCanvas/canvas/utils',
'modules/documentCanvas/canvas/wlxmlListener'
-], function($, _, Backbone, documentElement, keyboard, utils, wlxmlListener) {
+], function($, _, Backbone, logging, documentElement, keyboard, utils, wlxmlListener) {
'use strict';
/* global document:false, window:false, Node:false */
+var logger = logging.getLogger('canvas');
var TextHandler = function(canvas) {this.canvas = canvas; this.buffer = null;};
$.extend(TextHandler.prototype, {
canvas._moveCaretToTextElement(canvas.getDocumentElement(mutation.target), 'end');
}
observer.observe(canvas.wrapper[0], config);
- canvas.publisher('contentChanged');
var textElement = canvas.getDocumentElement(mutation.target),
toSet = mutation.target.data !== utils.unicode.ZWS ? mutation.target.data : '';
return this.getDocumentElement(this.wrapper.find('.current-text-element')[0]);
},
-
+ contains: function(element) {
+ return element.dom().parents().index(this.wrapper) !== -1;
+ },
setCurrentElement: function(element, params) {
if(!(element instanceof documentElement.DocumentElement)) {
element = utils.findCanvasElement(element);
}
+ if(!element || !this.contains(element)) {
+ logger.warning('Cannot set current element: element doesn\'t exist on canvas');
+ return;
+ }
+
params = _.extend({caretTo: 'end'}, params);
var findFirstDirectTextChild = function(e, nodeToLand) {
var byBrowser = this.getCursor().getPosition().element;
} else {
this.wrapper.find('.current-node-element').removeClass('current-node-element');
element._container().addClass('current-node-element');
- this.publisher('currentElementChanged', element);
}
}.bind(this);