|
|
@ -1,22 +1,31 @@ |
|
|
|
|
|
import CanvasModule from '../../canvas'; |
|
|
import { Model } from '../../common'; |
|
|
import { Model } from '../../common'; |
|
|
|
|
|
import Editor from '../../editor'; |
|
|
|
|
|
import EditorModel from '../../editor/model/Editor'; |
|
|
|
|
|
|
|
|
export default class CommandAbstract extends Model { |
|
|
export default class CommandAbstract extends Model { |
|
|
/** |
|
|
config: any; |
|
|
* Initialize method that can't be removed |
|
|
em: EditorModel; |
|
|
* @param {Object} o Options |
|
|
pfx: string; |
|
|
* @private |
|
|
ppfx: string; |
|
|
* */ |
|
|
hoverClass: string; |
|
|
initialize(o) { |
|
|
badgeClass: string; |
|
|
|
|
|
plhClass: string; |
|
|
|
|
|
freezClass: string; |
|
|
|
|
|
canvas: CanvasModule; |
|
|
|
|
|
|
|
|
|
|
|
constructor(o: any) { |
|
|
|
|
|
super(0); |
|
|
this.config = o || {}; |
|
|
this.config = o || {}; |
|
|
this.editorModel = this.em = this.config.em || {}; |
|
|
this.em = this.config.em || {}; |
|
|
this.pfx = this.config.stylePrefix; |
|
|
const pfx = this.config.stylePrefix; |
|
|
|
|
|
this.pfx = pfx; |
|
|
this.ppfx = this.config.pStylePrefix; |
|
|
this.ppfx = this.config.pStylePrefix; |
|
|
this.hoverClass = this.pfx + 'hover'; |
|
|
this.hoverClass = `${pfx}hover`; |
|
|
this.badgeClass = this.pfx + 'badge'; |
|
|
this.badgeClass = `${pfx}badge`; |
|
|
this.plhClass = this.pfx + 'placeholder'; |
|
|
this.plhClass = `${pfx}placeholder`; |
|
|
this.freezClass = this.ppfx + 'freezed'; |
|
|
this.freezClass = `${this.ppfx}freezed`; |
|
|
|
|
|
this.canvas = this.em.Canvas; |
|
|
this.canvas = this.em.get && this.em.get('Canvas'); |
|
|
|
|
|
this.init(this.config); |
|
|
this.init(this.config); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -25,7 +34,7 @@ export default class CommandAbstract extends Model { |
|
|
* @param {[type]} e [description] |
|
|
* @param {[type]} e [description] |
|
|
* @return {[type]} [description] |
|
|
* @return {[type]} [description] |
|
|
*/ |
|
|
*/ |
|
|
onFrameScroll(e) {} |
|
|
onFrameScroll(e: any) {} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Returns canval element |
|
|
* Returns canval element |
|
|
@ -56,7 +65,7 @@ export default class CommandAbstract extends Model { |
|
|
* @param {HTMLElement} el |
|
|
* @param {HTMLElement} el |
|
|
* @return {Object} |
|
|
* @return {Object} |
|
|
*/ |
|
|
*/ |
|
|
offset(el) { |
|
|
offset(el: HTMLElement) { |
|
|
var rect = el.getBoundingClientRect(); |
|
|
var rect = el.getBoundingClientRect(); |
|
|
return { |
|
|
return { |
|
|
top: rect.top + el.ownerDocument.body.scrollTop, |
|
|
top: rect.top + el.ownerDocument.body.scrollTop, |
|
|
@ -69,7 +78,7 @@ export default class CommandAbstract extends Model { |
|
|
* @param {Object} o Options |
|
|
* @param {Object} o Options |
|
|
* @private |
|
|
* @private |
|
|
* */ |
|
|
* */ |
|
|
init(o) {} |
|
|
init(o: any) {} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Method that run command |
|
|
* Method that run command |
|
|
@ -77,7 +86,7 @@ export default class CommandAbstract extends Model { |
|
|
* @param {Object} [options={}] Options |
|
|
* @param {Object} [options={}] Options |
|
|
* @private |
|
|
* @private |
|
|
* */ |
|
|
* */ |
|
|
callRun(editor, options = {}) { |
|
|
callRun(editor: Editor, options: any = {}) { |
|
|
const id = this.id; |
|
|
const id = this.id; |
|
|
editor.trigger(`run:${id}:before`, options); |
|
|
editor.trigger(`run:${id}:before`, options); |
|
|
|
|
|
|
|
|
@ -99,7 +108,7 @@ export default class CommandAbstract extends Model { |
|
|
* @param {Object} [options={}] Options |
|
|
* @param {Object} [options={}] Options |
|
|
* @private |
|
|
* @private |
|
|
* */ |
|
|
* */ |
|
|
callStop(editor, options = {}) { |
|
|
callStop(editor: Editor, options: any = {}) { |
|
|
const id = this.id; |
|
|
const id = this.id; |
|
|
const sender = options.sender || editor; |
|
|
const sender = options.sender || editor; |
|
|
editor.trigger(`stop:${id}:before`, options); |
|
|
editor.trigger(`stop:${id}:before`, options); |
|
|
@ -112,7 +121,7 @@ export default class CommandAbstract extends Model { |
|
|
/** |
|
|
/** |
|
|
* Stop current command |
|
|
* Stop current command |
|
|
*/ |
|
|
*/ |
|
|
stopCommand(opts) { |
|
|
stopCommand(opts: any) { |
|
|
this.em.get('Commands').stop(this.id, opts); |
|
|
this.em.get('Commands').stop(this.id, opts); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -122,7 +131,7 @@ export default class CommandAbstract extends Model { |
|
|
* @param {Object} sender Button sender |
|
|
* @param {Object} sender Button sender |
|
|
* @private |
|
|
* @private |
|
|
* */ |
|
|
* */ |
|
|
run(em, sender) {} |
|
|
run(em: Editor, sender: any, options: any) {} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Method that stop command |
|
|
* Method that stop command |
|
|
@ -130,5 +139,5 @@ export default class CommandAbstract extends Model { |
|
|
* @param {Object} sender Button sender |
|
|
* @param {Object} sender Button sender |
|
|
* @private |
|
|
* @private |
|
|
* */ |
|
|
* */ |
|
|
stop(em, sender) {} |
|
|
stop(em: Editor, sender: any, options: any) {} |
|
|
} |
|
|
} |