+ defaultDisplayStyle: 'block',
+ init: function() {},
+ addWidget: function(widget) {
+ this.dom.children('.canvas-widgets').append(widget.DOM ? widget.DOM : widget);
+ },
+ clearWidgets: function() {
+ this.dom.children('.canvas-widgets').empty();
+ },
+ addToGutter: function(view) {
+ if(!this.gutterGroup) {
+ this.gutterGroup = this.canvas.gutter.createViewGroup({
+ offsetHint: function() {
+ return this.canvas.getElementOffset(this);
+ }.bind(this)
+ }, this);
+ }
+ this.gutterGroup.addView(view);
+ },
+ createContainer: function(nodes, params) {
+ var toret = container.create(nodes, params, this);
+ this.containers.push(toret);
+ return toret;
+ },
+ removeContainer: function(container) {
+ var idx;
+ if((idx = this.containers.indexOf(container)) !== -1) {
+ this.containers.splice(idx, 1);
+ }
+ },
+ createElement: function(wlxmlNode) {
+ var parent = this.wlxmlNode.parent() ? utils.getElementForNode(this.wlxmlNode.parent()) : null;
+ return this.canvas.createElement(wlxmlNode, this.elementsRegister, !parent) || parent.createElement(wlxmlNode);
+ },
+ addToContextMenu: function(actionFqName) {
+ this.contextMenuActions.push(this.canvas.createAction(actionFqName));
+ },
+ handle: function(event) {
+ var method = 'on' + event.type[0].toUpperCase() + event.type.substr(1),
+ target;
+ if(event.type === 'nodeAdded' || event.type === 'nodeDetached') {
+ this.containers.some(function(container) {
+ if(container.manages(event.meta.node, event.meta.parent)) {
+ target = container;
+ return true;
+ }
+ });
+ }
+
+ if(!target && this[method]) {
+ target = this;
+ }
+
+ if(target) {
+ target[method](event);
+ }
+ },
+ createDOM: function() {
+ var wrapper = $('<div>').attr('document-node-element', ''),
+ widgetsContainer = $('<div>')
+ .addClass('canvas-widgets'),
+ contentContainer = $('<div>')
+ .attr('document-element-content', '');
+
+ wrapper.append(contentContainer, widgetsContainer);
+ widgetsContainer.find('*').add(widgetsContainer).attr('tabindex', -1);
+ return wrapper;
+ },