@ -3,6 +3,7 @@ import Backbone from 'backbone';
import $ from 'utils/cash-dom' ;
import $ from 'utils/cash-dom' ;
import Extender from 'utils/extender' ;
import Extender from 'utils/extender' ;
import { getModel , hasWin } from 'utils/mixins' ;
import { getModel , hasWin } from 'utils/mixins' ;
import { Model } from 'common' ;
import Selected from './Selected' ;
import Selected from './Selected' ;
Backbone . $ = $ ;
Backbone . $ = $ ;
@ -47,7 +48,7 @@ const logs = {
error : console . error ,
error : console . error ,
} ;
} ;
export default Backbone . Model . extend ( {
export default class EditorModel extends Model {
defaults ( ) {
defaults ( ) {
return {
return {
editing : 0 ,
editing : 0 ,
@ -63,7 +64,7 @@ export default Backbone.Model.extend({
opened : { } ,
opened : { } ,
device : '' ,
device : '' ,
} ;
} ;
} ,
}
initialize ( c = { } ) {
initialize ( c = { } ) {
this . config = c ;
this . config = c ;
@ -103,21 +104,21 @@ export default Backbone.Model.extend({
this . logWarning ( ` The event ' ${ eventFrom } ' is deprecated, replace it with ' ${ eventTo } ' ` ) ;
this . logWarning ( ` The event ' ${ eventFrom } ' is deprecated, replace it with ' ${ eventTo } ' ` ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ,
}
_ checkReady ( ) {
_ checkReady ( ) {
if ( this . get ( 'readyLoad' ) && this . get ( 'readyCanvas' ) && ! this . get ( 'ready' ) ) {
if ( this . get ( 'readyLoad' ) && this . get ( 'readyCanvas' ) && ! this . get ( 'ready' ) ) {
this . set ( 'ready' , true ) ;
this . set ( 'ready' , true ) ;
}
}
} ,
}
getContainer ( ) {
getContainer ( ) {
return this . config . el ;
return this . config . el ;
} ,
}
listenLog ( event ) {
listenLog ( event ) {
this . listenTo ( this , ` log: ${ event } ` , logs [ event ] ) ;
this . listenTo ( this , ` log: ${ event } ` , logs [ event ] ) ;
} ,
}
/ * *
/ * *
* Get configurations
* Get configurations
@ -128,26 +129,23 @@ export default Backbone.Model.extend({
getConfig ( prop ) {
getConfig ( prop ) {
const config = this . config ;
const config = this . config ;
return isUndefined ( prop ) ? config : config [ prop ] ;
return isUndefined ( prop ) ? config : config [ prop ] ;
} ,
}
/ * *
/ * *
* Should be called after all modules and plugins are loaded
* Should be called once all modules and plugins are loaded
* @ param { Function } clb
* @ param { Function } clb
* @ private
* @ private
* /
* /
loadOnStart ( clb = null ) {
loadOnStart ( clb = null ) {
const sm = this . get ( 'StorageManager' ) ;
const sm = this . get ( 'StorageManager' ) ;
// Generally, with `onLoad`, the module will try to load the data from
// In `onLoad`, the module will try to load the data from its configurations.
// its configurations
this . get ( 'toLoad' ) . forEach ( mdl => mdl . onLoad ( ) ) ;
this . get ( 'toLoad' ) . forEach ( module => {
module . onLoad ( ) ;
} ) ;
// Stuff to do post load
// Stuff to do post load
const postLoad = ( ) => {
const postLoad = ( ) => {
const modules = this . get ( 'modules' ) ;
const modules = this . get ( 'modules' ) ;
modules . forEach ( mo du le => mo du le . postLoad && mo du le . postLoad ( this ) ) ;
modules . forEach ( mdl => mdl . postLoad && mdl . postLoad ( this ) ) ;
this . set ( 'readyLoad' , 1 ) ;
this . set ( 'readyLoad' , 1 ) ;
clb && clb ( ) ;
clb && clb ( ) ;
} ;
} ;
@ -157,7 +155,18 @@ export default Backbone.Model.extend({
} else {
} else {
setTimeout ( postLoad ) ;
setTimeout ( postLoad ) ;
}
}
} ,
// Create shallow editor.
// Here we can create components/styles without altering/triggering the main EditorModel
const shallow = new EditorModel ( {
noticeOnUnload : false ,
storageManager : false ,
undoManager : false ,
} ) ;
// We only need to load a few modules
[ 'PageManager' , 'Canvas' ] . forEach ( key => shallow . get ( key ) . onLoad ( ) ) ;
this . set ( 'shallow' , shallow ) ;
}
/ * *
/ * *
* Set the alert before unload in case it ' s requested
* Set the alert before unload in case it ' s requested
@ -177,7 +186,7 @@ export default Backbone.Model.extend({
if ( stm . isAutosave ( ) && changes >= stm . getStepsBeforeSave ( ) ) {
if ( stm . isAutosave ( ) && changes >= stm . getStepsBeforeSave ( ) ) {
this . store ( ) ;
this . store ( ) ;
}
}
} ,
}
/ * *
/ * *
* Load generic module
* Load generic module
@ -214,7 +223,7 @@ export default Backbone.Model.extend({
Mod . onLoad && this . get ( 'toLoad' ) . push ( Mod ) ;
Mod . onLoad && this . get ( 'toLoad' ) . push ( Mod ) ;
this . get ( 'modules' ) . push ( Mod ) ;
this . get ( 'modules' ) . push ( Mod ) ;
return this ;
return this ;
} ,
}
/ * *
/ * *
* Initialize editor model and set editor instance
* Initialize editor model and set editor instance
@ -228,11 +237,11 @@ export default Backbone.Model.extend({
this . destroyed = 0 ;
this . destroyed = 0 ;
}
}
this . set ( 'Editor' , editor ) ;
this . set ( 'Editor' , editor ) ;
} ,
}
getEditor ( ) {
getEditor ( ) {
return this . get ( 'Editor' ) ;
return this . get ( 'Editor' ) ;
} ,
}
/ * *
/ * *
* This method handles updates on the editor and tries to store them
* This method handles updates on the editor and tries to store them
@ -254,11 +263,11 @@ export default Backbone.Model.extend({
const { unset , ... opts } = opt ;
const { unset , ... opts } = opt ;
this . set ( 'changesCount' , curr + 1 , opts ) ;
this . set ( 'changesCount' , curr + 1 , opts ) ;
} , 0 ) ;
} , 0 ) ;
} ,
}
changesUp ( opts ) {
changesUp ( opts ) {
this . handleUpdates ( 0 , 0 , opts ) ;
this . handleUpdates ( 0 , 0 , opts ) ;
} ,
}
/ * *
/ * *
* Callback on component hover
* Callback on component hover
@ -271,7 +280,7 @@ export default Backbone.Model.extend({
const prev = this . previous ( 'componentHovered' ) ;
const prev = this . previous ( 'componentHovered' ) ;
prev && this . trigger ( 'component:unhovered' , prev , options ) ;
prev && this . trigger ( 'component:unhovered' , prev , options ) ;
component && this . trigger ( 'component:hovered' , component , options ) ;
component && this . trigger ( 'component:hovered' , component , options ) ;
} ,
}
/ * *
/ * *
* Returns model of the selected component
* Returns model of the selected component
@ -280,7 +289,7 @@ export default Backbone.Model.extend({
* /
* /
getSelected ( ) {
getSelected ( ) {
return this . get ( 'selected' ) . lastComponent ( ) ;
return this . get ( 'selected' ) . lastComponent ( ) ;
} ,
}
/ * *
/ * *
* Returns an array of all selected components
* Returns an array of all selected components
@ -289,7 +298,7 @@ export default Backbone.Model.extend({
* /
* /
getSelectedAll ( ) {
getSelectedAll ( ) {
return this . get ( 'selected' ) . allComponents ( ) ;
return this . get ( 'selected' ) . allComponents ( ) ;
} ,
}
/ * *
/ * *
* Select a component
* Select a component
@ -312,8 +321,22 @@ export default Backbone.Model.extend({
multiple && this . removeSelected ( selected . filter ( s => ! contains ( els , s ) ) ) ;
multiple && this . removeSelected ( selected . filter ( s => ! contains ( els , s ) ) ) ;
els . forEach ( el => {
els . forEach ( el => {
const model = getModel ( el , $ ) ;
let model = getModel ( el ) ;
if ( model && ! model . get ( 'selectable' ) ) return ;
if ( model ) {
this . trigger ( 'component:select:before' , model , opts ) ;
// Check for valid selectable
if ( ! model . get ( 'selectable' ) || opts . abort ) {
if ( opts . useValid ) {
let parent = model . parent ( ) ;
while ( parent && ! parent . get ( 'selectable' ) ) parent = parent . parent ( ) ;
model = parent ;
} else {
return ;
}
}
}
// Hanlde multiple selection
// Hanlde multiple selection
if ( ctrlKey && mltSel ) {
if ( ctrlKey && mltSel ) {
@ -360,7 +383,7 @@ export default Backbone.Model.extend({
this . addSelected ( model , opts ) ;
this . addSelected ( model , opts ) ;
added = model ;
added = model ;
} ) ;
} ) ;
} ,
}
/ * *
/ * *
* Add component to selection
* Add component to selection
@ -377,8 +400,9 @@ export default Backbone.Model.extend({
const selected = this . get ( 'selected' ) ;
const selected = this . get ( 'selected' ) ;
opts . forceChange && this . removeSelected ( model , opts ) ;
opts . forceChange && this . removeSelected ( model , opts ) ;
selected . addComponent ( model , opts ) ;
selected . addComponent ( model , opts ) ;
model && this . trigger ( 'component:select' , model , opts ) ;
} ) ;
} ) ;
} ,
}
/ * *
/ * *
* Remove component from selection
* Remove component from selection
@ -388,7 +412,7 @@ export default Backbone.Model.extend({
* /
* /
removeSelected ( el , opts = { } ) {
removeSelected ( el , opts = { } ) {
this . get ( 'selected' ) . removeComponent ( getModel ( el , $ ) , opts ) ;
this . get ( 'selected' ) . removeComponent ( getModel ( el , $ ) , opts ) ;
} ,
}
/ * *
/ * *
* Toggle component selection
* Toggle component selection
@ -407,7 +431,7 @@ export default Backbone.Model.extend({
this . addSelected ( model , opts ) ;
this . addSelected ( model , opts ) ;
}
}
} ) ;
} ) ;
} ,
}
/ * *
/ * *
* Hover a component
* Hover a component
@ -416,15 +440,36 @@ export default Backbone.Model.extend({
* @ private
* @ private
* /
* /
setHovered ( el , opts = { } ) {
setHovered ( el , opts = { } ) {
const model = getModel ( el , $ ) ;
if ( ! el ) return this . set ( 'componentHovered' , '' ) ;
if ( model && ! model . get ( 'hoverable' ) ) return ;
const ev = 'component:hover' ;
let model = getModel ( el ) ;
if ( ! model ) return ;
opts . forceChange && this . set ( 'componentHovered' , '' ) ;
opts . forceChange && this . set ( 'componentHovered' , '' ) ;
this . set ( 'componentHovered' , model , opts ) ;
this . trigger ( ` ${ ev } :before ` , model , opts ) ;
} ,
// Check for valid hoverable
if ( ! model . get ( 'hoverable' ) ) {
if ( opts . useValid && ! opts . abort ) {
let parent = model && model . parent ( ) ;
while ( parent && ! parent . get ( 'hoverable' ) ) parent = parent . parent ( ) ;
model = parent ;
} else {
return ;
}
}
if ( ! opts . abort ) {
this . set ( 'componentHovered' , model , opts ) ;
this . trigger ( ev , model , opts ) ;
}
}
getHovered ( ) {
getHovered ( ) {
return this . get ( 'componentHovered' ) ;
return this . get ( 'componentHovered' ) ;
} ,
}
/ * *
/ * *
* Set components inside editor ' s canvas . This method overrides actual components
* Set components inside editor ' s canvas . This method overrides actual components
@ -435,7 +480,7 @@ export default Backbone.Model.extend({
* /
* /
setComponents ( components , opt = { } ) {
setComponents ( components , opt = { } ) {
return this . get ( 'DomComponents' ) . setComponents ( components , opt ) ;
return this . get ( 'DomComponents' ) . setComponents ( components , opt ) ;
} ,
}
/ * *
/ * *
* Returns components model from the editor ' s canvas
* Returns components model from the editor ' s canvas
@ -450,7 +495,7 @@ export default Backbone.Model.extend({
var wrp = cmp . getComponents ( ) ;
var wrp = cmp . getComponents ( ) ;
return cm . getCode ( wrp , 'json' ) ;
return cm . getCode ( wrp , 'json' ) ;
} ,
}
/ * *
/ * *
* Set style inside editor ' s canvas . This method overrides actual style
* Set style inside editor ' s canvas . This method overrides actual style
@ -464,7 +509,7 @@ export default Backbone.Model.extend({
cssc . clear ( opt ) ;
cssc . clear ( opt ) ;
cssc . getAll ( ) . add ( style , opt ) ;
cssc . getAll ( ) . add ( style , opt ) ;
return this ;
return this ;
} ,
}
/ * *
/ * *
* Add styles to the editor
* Add styles to the editor
@ -475,7 +520,7 @@ export default Backbone.Model.extend({
addStyle ( style , opts = { } ) {
addStyle ( style , opts = { } ) {
const res = this . getStyle ( ) . add ( style , opts ) ;
const res = this . getStyle ( ) . add ( style , opts ) ;
return isArray ( res ) ? res : [ res ] ;
return isArray ( res ) ? res : [ res ] ;
} ,
}
/ * *
/ * *
* Returns rules / style model from the editor ' s canvas
* Returns rules / style model from the editor ' s canvas
@ -484,7 +529,7 @@ export default Backbone.Model.extend({
* /
* /
getStyle ( ) {
getStyle ( ) {
return this . get ( 'CssComposer' ) . getAll ( ) ;
return this . get ( 'CssComposer' ) . getAll ( ) ;
} ,
}
/ * *
/ * *
* Change the selector state
* Change the selector state
@ -494,7 +539,7 @@ export default Backbone.Model.extend({
setState ( value ) {
setState ( value ) {
this . set ( 'state' , value ) ;
this . set ( 'state' , value ) ;
return this ;
return this ;
} ,
}
/ * *
/ * *
* Get the current selector state
* Get the current selector state
@ -502,7 +547,7 @@ export default Backbone.Model.extend({
* /
* /
getState ( ) {
getState ( ) {
return this . get ( 'state' ) || '' ;
return this . get ( 'state' ) || '' ;
} ,
}
/ * *
/ * *
* Returns HTML built inside canvas
* Returns HTML built inside canvas
@ -525,7 +570,7 @@ export default Backbone.Model.extend({
: '' ;
: '' ;
html += js ? ` <script> ${ js } </script> ` : '' ;
html += js ? ` <script> ${ js } </script> ` : '' ;
return html ;
return html ;
} ,
}
/ * *
/ * *
* Returns CSS built inside canvas
* Returns CSS built inside canvas
@ -551,7 +596,7 @@ export default Backbone.Model.extend({
... opts ,
... opts ,
} ) ;
} ) ;
return wrp ? ( opts . json ? css : protCss + css ) : '' ;
return wrp ? ( opts . json ? css : protCss + css ) : '' ;
} ,
}
/ * *
/ * *
* Returns JS of all components
* Returns JS of all components
@ -561,7 +606,7 @@ export default Backbone.Model.extend({
getJs ( opts = { } ) {
getJs ( opts = { } ) {
var wrp = opts . component || this . get ( 'DomComponents' ) . getWrapper ( ) ;
var wrp = opts . component || this . get ( 'DomComponents' ) . getWrapper ( ) ;
return wrp ? this . get ( 'CodeManager' ) . getCode ( wrp , 'js' ) . trim ( ) : '' ;
return wrp ? this . get ( 'CodeManager' ) . getCode ( wrp , 'js' ) . trim ( ) : '' ;
} ,
}
/ * *
/ * *
* Store data to the current storage
* Store data to the current storage
@ -581,7 +626,7 @@ export default Backbone.Model.extend({
} ) ;
} ) ;
return store ;
return store ;
} ,
}
storeData ( ) {
storeData ( ) {
let result = { } ;
let result = { } ;
@ -593,7 +638,7 @@ export default Backbone.Model.extend({
result = { ... result , ... m . store ( 1 ) } ;
result = { ... result , ... m . store ( 1 ) } ;
} ) ;
} ) ;
return result ;
return result ;
} ,
}
/ * *
/ * *
* Load data from the current storage
* Load data from the current storage
@ -605,7 +650,7 @@ export default Backbone.Model.extend({
this . loadData ( res ) ;
this . loadData ( res ) ;
clb && clb ( res ) ;
clb && clb ( res ) ;
} ) ;
} ) ;
} ,
}
loadData ( data = { } ) {
loadData ( data = { } ) {
const sm = this . get ( 'StorageManager' ) ;
const sm = this . get ( 'StorageManager' ) ;
@ -617,7 +662,7 @@ export default Backbone.Model.extend({
} ) ;
} ) ;
return result ;
return result ;
} ,
}
/ * *
/ * *
* Returns cached load
* Returns cached load
@ -645,7 +690,7 @@ export default Backbone.Model.extend({
clb && clb ( res ) ;
clb && clb ( res ) ;
setTimeout ( ( ) => this . trigger ( 'storage:load' , res ) ) ;
setTimeout ( ( ) => this . trigger ( 'storage:load' , res ) ) ;
} ) ;
} ) ;
} ,
}
/ * *
/ * *
* Returns device model by name
* Returns device model by name
@ -655,7 +700,7 @@ export default Backbone.Model.extend({
getDeviceModel ( ) {
getDeviceModel ( ) {
var name = this . get ( 'device' ) ;
var name = this . get ( 'device' ) ;
return this . get ( 'DeviceManager' ) . get ( name ) ;
return this . get ( 'DeviceManager' ) . get ( name ) ;
} ,
}
/ * *
/ * *
* Run default command if setted
* Run default command if setted
@ -668,7 +713,7 @@ export default Backbone.Model.extend({
command . stop ( this , this , opts ) ;
command . stop ( this , this , opts ) ;
command . run ( this , this , opts ) ;
command . run ( this , this , opts ) ;
this . defaultRunning = 1 ;
this . defaultRunning = 1 ;
} ,
}
/ * *
/ * *
* Stop default command
* Stop default command
@ -681,7 +726,7 @@ export default Backbone.Model.extend({
if ( ! command || ! this . defaultRunning ) return ;
if ( ! command || ! this . defaultRunning ) return ;
command . stop ( this , this , opts ) ;
command . stop ( this , this , opts ) ;
this . defaultRunning = 0 ;
this . defaultRunning = 0 ;
} ,
}
/ * *
/ * *
* Update canvas dimensions and refresh data useful for tools positioning
* Update canvas dimensions and refresh data useful for tools positioning
@ -691,7 +736,7 @@ export default Backbone.Model.extend({
this . set ( 'canvasOffset' , null ) ;
this . set ( 'canvasOffset' , null ) ;
this . set ( 'canvasOffset' , this . get ( 'Canvas' ) . getOffset ( ) ) ;
this . set ( 'canvasOffset' , this . get ( 'Canvas' ) . getOffset ( ) ) ;
opts . tools && this . trigger ( 'canvas:updateTools' ) ;
opts . tools && this . trigger ( 'canvas:updateTools' ) ;
} ,
}
/ * *
/ * *
* Clear all selected stuf inside the window , sometimes is useful to call before
* Clear all selected stuf inside the window , sometimes is useful to call before
@ -702,7 +747,7 @@ export default Backbone.Model.extend({
clearSelection ( win ) {
clearSelection ( win ) {
var w = win || window ;
var w = win || window ;
w . getSelection ( ) . removeAllRanges ( ) ;
w . getSelection ( ) . removeAllRanges ( ) ;
} ,
}
/ * *
/ * *
* Get the current media text
* Get the current media text
@ -715,7 +760,7 @@ export default Backbone.Model.extend({
const preview = config . devicePreviewMode ;
const preview = config . devicePreviewMode ;
const width = device && device . get ( 'widthMedia' ) ;
const width = device && device . get ( 'widthMedia' ) ;
return device && width && ! preview ? ` ( ${ condition } : ${ width } ) ` : '' ;
return device && width && ! preview ? ` ( ${ condition } : ${ width } ) ` : '' ;
} ,
}
/ * *
/ * *
* Return the component wrapper
* Return the component wrapper
@ -723,19 +768,19 @@ export default Backbone.Model.extend({
* /
* /
getWrapper ( ) {
getWrapper ( ) {
return this . get ( 'DomComponents' ) . getWrapper ( ) ;
return this . get ( 'DomComponents' ) . getWrapper ( ) ;
} ,
}
setCurrentFrame ( frameView ) {
setCurrentFrame ( frameView ) {
return this . set ( 'currentFrame' , frameView ) ;
return this . set ( 'currentFrame' , frameView ) ;
} ,
}
getCurrentFrame ( ) {
getCurrentFrame ( ) {
return this . get ( 'currentFrame' ) ;
return this . get ( 'currentFrame' ) ;
} ,
}
getCurrentFrameModel ( ) {
getCurrentFrameModel ( ) {
return ( this . getCurrentFrame ( ) || { } ) . model ;
return ( this . getCurrentFrame ( ) || { } ) . model ;
} ,
}
/ * *
/ * *
* Return the count of changes made to the content and not yet stored .
* Return the count of changes made to the content and not yet stored .
@ -744,24 +789,24 @@ export default Backbone.Model.extend({
* /
* /
getDirtyCount ( ) {
getDirtyCount ( ) {
return this . get ( 'changesCount' ) ;
return this . get ( 'changesCount' ) ;
} ,
}
getZoomDecimal ( ) {
getZoomDecimal ( ) {
return this . get ( 'Canvas' ) . getZoomDecimal ( ) ;
return this . get ( 'Canvas' ) . getZoomDecimal ( ) ;
} ,
}
getZoomMultiplier ( ) {
getZoomMultiplier ( ) {
return this . get ( 'Canvas' ) . getZoomMultiplier ( ) ;
return this . get ( 'Canvas' ) . getZoomMultiplier ( ) ;
} ,
}
setDragMode ( value ) {
setDragMode ( value ) {
return this . set ( 'dmode' , value ) ;
return this . set ( 'dmode' , value ) ;
} ,
}
t ( ... args ) {
t ( ... args ) {
const i18n = this . get ( 'I18n' ) ;
const i18n = this . get ( 'I18n' ) ;
return i18n ? . t ( ... args ) ;
return i18n ? . t ( ... args ) ;
} ,
}
/ * *
/ * *
* Returns true if the editor is in absolute mode
* Returns true if the editor is in absolute mode
@ -769,7 +814,7 @@ export default Backbone.Model.extend({
* /
* /
inAbsoluteMode ( ) {
inAbsoluteMode ( ) {
return this . get ( 'dmode' ) === 'absolute' ;
return this . get ( 'dmode' ) === 'absolute' ;
} ,
}
/ * *
/ * *
* Destroy editor
* Destroy editor
@ -778,6 +823,8 @@ export default Backbone.Model.extend({
const { config , view } = this ;
const { config , view } = this ;
const editor = this . getEditor ( ) ;
const editor = this . getEditor ( ) ;
const { editors = [ ] } = config . grapesjs || { } ;
const { editors = [ ] } = config . grapesjs || { } ;
const shallow = this . get ( 'shallow' ) ;
shallow ? . destroyAll ( ) ;
this . stopListening ( ) ;
this . stopListening ( ) ;
this . stopDefault ( ) ;
this . stopDefault ( ) ;
this . get ( 'modules' )
this . get ( 'modules' )
@ -790,21 +837,21 @@ export default Backbone.Model.extend({
[ 'config' , 'view' , '_previousAttributes' , '_events' , '_listeners' ] . forEach ( i => ( this [ i ] = { } ) ) ;
[ 'config' , 'view' , '_previousAttributes' , '_events' , '_listeners' ] . forEach ( i => ( this [ i ] = { } ) ) ;
editors . splice ( editors . indexOf ( editor ) , 1 ) ;
editors . splice ( editors . indexOf ( editor ) , 1 ) ;
hasWin ( ) && $ ( config . el ) . empty ( ) . attr ( this . attrsOrig ) ;
hasWin ( ) && $ ( config . el ) . empty ( ) . attr ( this . attrsOrig ) ;
} ,
}
getEditing ( ) {
getEditing ( ) {
const res = this . get ( 'editing' ) ;
const res = this . get ( 'editing' ) ;
return ( res && res . model ) || null ;
return ( res && res . model ) || null ;
} ,
}
setEditing ( value ) {
setEditing ( value ) {
this . set ( 'editing' , value ) ;
this . set ( 'editing' , value ) ;
return this ;
return this ;
} ,
}
isEditing ( ) {
isEditing ( ) {
return ! ! this . get ( 'editing' ) ;
return ! ! this . get ( 'editing' ) ;
} ,
}
log ( msg , opts = { } ) {
log ( msg , opts = { } ) {
const { ns , level = 'debug' } = opts ;
const { ns , level = 'debug' } = opts ;
@ -816,19 +863,19 @@ export default Backbone.Model.extend({
this . trigger ( logNs , msg , opts ) ;
this . trigger ( logNs , msg , opts ) ;
level && this . trigger ( ` ${ logNs } : ${ level } ` , msg , opts ) ;
level && this . trigger ( ` ${ logNs } : ${ level } ` , msg , opts ) ;
}
}
} ,
}
logInfo ( msg , opts ) {
logInfo ( msg , opts ) {
this . log ( msg , { ... opts , level : 'info' } ) ;
this . log ( msg , { ... opts , level : 'info' } ) ;
} ,
}
logWarning ( msg , opts ) {
logWarning ( msg , opts ) {
this . log ( msg , { ... opts , level : 'warning' } ) ;
this . log ( msg , { ... opts , level : 'warning' } ) ;
} ,
}
logError ( msg , opts ) {
logError ( msg , opts ) {
this . log ( msg , { ... opts , level : 'error' } ) ;
this . log ( msg , { ... opts , level : 'error' } ) ;
} ,
}
initBaseColorPicker ( el , opts = { } ) {
initBaseColorPicker ( el , opts = { } ) {
const config = this . getConfig ( ) ;
const config = this . getConfig ( ) ;
@ -848,7 +895,7 @@ export default Backbone.Model.extend({
... opts ,
... opts ,
... colorPicker ,
... colorPicker ,
} ) ;
} ) ;
} ,
}
/ * *
/ * *
* Execute actions without triggering the storage and undo manager .
* Execute actions without triggering the storage and undo manager .
@ -860,7 +907,7 @@ export default Backbone.Model.extend({
const um = this . get ( 'UndoManager' ) ;
const um = this . get ( 'UndoManager' ) ;
um ? um . skip ( clb ) : clb ( ) ;
um ? um . skip ( clb ) : clb ( ) ;
this . __ skip = false ;
this . __ skip = false ;
} ,
}
/ * *
/ * *
* Set / get data from the HTMLElement
* Set / get data from the HTMLElement
@ -882,5 +929,5 @@ export default Backbone.Model.extend({
} else {
} else {
el [ varName ] [ name ] = value ;
el [ varName ] [ name ] = value ;
}
}
} ,
}
} ) ;
}