Browse Source

Add refresh method to the editor API

pull/72/head
Artur Arseniev 9 years ago
parent
commit
e1ec85db1f
  1. 5
      src/block_manager/view/BlockView.js
  2. 6
      src/demo.js
  3. 18
      src/editor/main.js
  4. 8
      src/editor/model/Editor.js

5
src/block_manager/view/BlockView.js

@ -19,9 +19,10 @@ function(Backbone) {
* Start block dragging
* @private
*/
onDrag: function(){
onDrag: function() {
if(!this.config.getSorter)
return;
this.config.em.refreshCanvas();
var sorter = this.config.getSorter();
//this.config.dragHelper(this.el.cloneNode(1));
sorter.startSort(this.el);
@ -33,7 +34,7 @@ function(Backbone) {
* Drop block
* @private
*/
onDrop: function(){
onDrop: function() {
this.doc.off('mouseup', this.onDrop);
this.config.getSorter().endMove();
},

6
src/demo.js

@ -329,6 +329,12 @@ require(['config/require-config'], function() {
window.editor = editor;
$(document).ready(function(){
console.log('doc ready4');
});
$('.gjs-cv-canvas').css('padding-left', '200px');
/*
// Test toolbar commands
var cmd = editor.Commands;

18
src/editor/main.js

@ -15,6 +15,7 @@
* * [store](#store)
* * [load](#load)
* * [getContainer](#getcontainer)
* * [refresh](#refresh)
* * [on](#on)
* * [trigger](#trigger)
* * [render](#render)
@ -348,13 +349,28 @@ define(function (require){
},
/**
* Returns container element. The one which was indicated as 'container' on init method
* Returns container element. The one which was indicated as 'container'
* on init method
* @return {HTMLElement}
*/
getContainer: function(){
return c.el;
},
/**
* Update editor dimensions and refresh data useful for positioning of tools
*
* This method could be useful when you update, for example, some position
* of the editor element (eg. canvas, panels, etc.) with CSS, where without
* refresh you'll get misleading position of tools (eg. rich text editor,
* component highlighter, etc.)
*
* @private
*/
refresh: function () {
em.refreshCanvas();
},
/**
* Attach event
* @param {string} event Event name

8
src/editor/model/Editor.js

@ -470,5 +470,13 @@ define(['backbone', 'backboneUndo', 'keymaster', 'Utils', 'StorageManager', 'Dev
this.defaultRunning = 0;
},
/**
* Update canvas dimensions and refresh data useful for tools positioning
* @private
*/
refreshCanvas: function () {
this.set('canvasOffset', this.get('Canvas').getOffset());
},
});
});

Loading…
Cancel
Save