|
|
@ -1,8 +1,26 @@ |
|
|
import { $ } from '../../common'; |
|
|
import { $ } from '../../common'; |
|
|
import { CommandObject } from './CommandAbstract'; |
|
|
import Editor from '../../editor'; |
|
|
|
|
|
import type { CommandPublicFnFromHandler } from '../registryHelpers'; |
|
|
|
|
|
import CommandAbstract from './CommandAbstract'; |
|
|
|
|
|
|
|
|
export default { |
|
|
export interface OpenStyleManagerCommandRegistryRun { |
|
|
run(editor, sender) { |
|
|
'core:open-styles': CommandPublicFnFromHandler<CommandOpenStyleManager['run']>; |
|
|
|
|
|
'open-sm': CommandPublicFnFromHandler<CommandOpenStyleManager['run']>; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export interface OpenStyleManagerCommandRegistryStop { |
|
|
|
|
|
'core:open-styles': CommandPublicFnFromHandler<CommandOpenStyleManager['stop']>; |
|
|
|
|
|
'open-sm': CommandPublicFnFromHandler<CommandOpenStyleManager['stop']>; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default class CommandOpenStyleManager extends CommandAbstract { |
|
|
|
|
|
sender?: any; |
|
|
|
|
|
sm?: any; |
|
|
|
|
|
$cnt?: any; |
|
|
|
|
|
$cntInner?: any; |
|
|
|
|
|
$header?: any; |
|
|
|
|
|
|
|
|
|
|
|
run(editor: Editor, sender: any) { |
|
|
this.sender = sender; |
|
|
this.sender = sender; |
|
|
|
|
|
|
|
|
if (!this.$cnt) { |
|
|
if (!this.$cnt) { |
|
|
@ -19,14 +37,12 @@ export default { |
|
|
$cntInner.append($cntSm); |
|
|
$cntInner.append($cntSm); |
|
|
$cnt.append($cntInner); |
|
|
$cnt.append($cntInner); |
|
|
|
|
|
|
|
|
// Device Manager
|
|
|
|
|
|
if (DeviceManager && config.showDevices) { |
|
|
if (DeviceManager && config.showDevices) { |
|
|
const devicePanel = Panels.addPanel({ id: 'devices-c' }); |
|
|
const devicePanel = Panels.addPanel({ id: 'devices-c' }); |
|
|
const dvEl = DeviceManager.render(); |
|
|
const dvEl = DeviceManager.render(); |
|
|
devicePanel.set('appendContent', dvEl).trigger(trgEvCnt); |
|
|
devicePanel.set('appendContent', dvEl).trigger(trgEvCnt); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Selector Manager container
|
|
|
|
|
|
const slmConfig = SelectorManager.getConfig(); |
|
|
const slmConfig = SelectorManager.getConfig(); |
|
|
if (slmConfig.custom) { |
|
|
if (slmConfig.custom) { |
|
|
SelectorManager.__trgCustom({ container: $cntSlm.get(0) }); |
|
|
SelectorManager.__trgCustom({ container: $cntSlm.get(0) }); |
|
|
@ -34,7 +50,6 @@ export default { |
|
|
$cntSlm.append(SelectorManager.render([])); |
|
|
$cntSlm.append(SelectorManager.render([])); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Style Manager
|
|
|
|
|
|
this.sm = StyleManager; |
|
|
this.sm = StyleManager; |
|
|
const smConfig = StyleManager.getConfig(); |
|
|
const smConfig = StyleManager.getConfig(); |
|
|
const pfx = smConfig.stylePrefix; |
|
|
const pfx = smConfig.stylePrefix; |
|
|
@ -47,20 +62,16 @@ export default { |
|
|
$cntSm.append(StyleManager.render()); |
|
|
$cntSm.append(StyleManager.render()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Create panel if not exists
|
|
|
|
|
|
const pnCnt = 'views-container'; |
|
|
const pnCnt = 'views-container'; |
|
|
const pnl = Panels.getPanel(pnCnt) || Panels.addPanel({ id: pnCnt }); |
|
|
const pnl = Panels.getPanel(pnCnt) || Panels.addPanel({ id: pnCnt }); |
|
|
|
|
|
|
|
|
// Add all containers to the panel
|
|
|
|
|
|
pnl.set('appendContent', $cnt).trigger(trgEvCnt); |
|
|
pnl.set('appendContent', $cnt).trigger(trgEvCnt); |
|
|
|
|
|
|
|
|
// Toggle Style Manager on target selection
|
|
|
|
|
|
const em = editor.getModel(); |
|
|
const em = editor.getModel(); |
|
|
this.listenTo(em, StyleManager.events.target, this.toggleSm); |
|
|
this.listenTo(em, StyleManager.events.target, this.toggleSm); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.toggleSm(); |
|
|
this.toggleSm(); |
|
|
}, |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Toggle Style Manager visibility |
|
|
* Toggle Style Manager visibility |
|
|
@ -77,10 +88,10 @@ export default { |
|
|
$cntInner?.hide(); |
|
|
$cntInner?.hide(); |
|
|
$header?.show(); |
|
|
$header?.show(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
} |
|
|
|
|
|
|
|
|
stop() { |
|
|
stop() { |
|
|
this.$cntInner?.hide(); |
|
|
this.$cntInner?.hide(); |
|
|
this.$header?.hide(); |
|
|
this.$header?.hide(); |
|
|
}, |
|
|
} |
|
|
} as CommandObject<{}, { [k: string]: any }>; |
|
|
} |
|
|
|