diff --git a/src/panels/config/config.js b/src/panels/config/config.ts similarity index 76% rename from src/panels/config/config.js rename to src/panels/config/config.ts index 1bb62e16e..191053793 100644 --- a/src/panels/config/config.js +++ b/src/panels/config/config.ts @@ -7,10 +7,32 @@ const obl = 'open-blocks'; const ful = 'fullscreen'; const prv = 'preview'; -export default { - stylePrefix: 'pn-', +interface ButtonProps { + id?: string; + active?: boolean; + togglable?: boolean; + className?: string; + command?: string | (() => any); + context?: string; + attributes?: Record; +} + +interface PanelProps { + id?: string; + buttons?: ButtonProps[]; +} + +export interface PanelsConfig { + stylePrefix?: string; + + /** + * Default panels. + */ + defaults?: PanelProps[]; +} - // Default panels fa-sliders for features +const config: PanelsConfig = { + stylePrefix: 'pn-', defaults: [ { id: 'commands', @@ -57,37 +79,33 @@ export default { className: 'fa fa-paint-brush', command: osm, active: true, - togglable: 0, + togglable: false, attributes: { title: 'Open Style Manager' }, }, { id: otm, className: 'fa fa-cog', command: otm, - togglable: 0, + togglable: false, attributes: { title: 'Settings' }, }, { id: ola, className: 'fa fa-bars', command: ola, - togglable: 0, + togglable: false, attributes: { title: 'Open Layer Manager' }, }, { id: obl, className: 'fa fa-th-large', command: obl, - togglable: 0, + togglable: false, attributes: { title: 'Open Blocks' }, }, ], }, ], - - // Editor model - em: null, - - // Delay before show children buttons (in milliseconds) - delayBtnsShow: 300, }; + +export default config; diff --git a/src/panels/index.ts b/src/panels/index.ts index 6875d241d..581bdc807 100644 --- a/src/panels/index.ts +++ b/src/panels/index.ts @@ -1,5 +1,5 @@ /** - * You can customize the initial state of the module from the editor initialization, by passing the following [Configuration Object](https://github.com/artf/grapesjs/blob/master/src/panels/config/config.js) + * You can customize the initial state of the module from the editor initialization, by passing the following [Configuration Object](https://github.com/artf/grapesjs/blob/master/src/panels/config/config.ts) * ```js * const editor = grapesjs.init({ * panels: { @@ -27,13 +27,12 @@ */ import { Module } from '../abstract'; import EditorModel from '../editor/model/Editor'; -import defaults from './config/config'; -import Button from './model/Button'; +import defaults, { PanelsConfig } from './config/config'; import Panel from './model/Panel'; import Panels from './model/Panels'; import PanelsView from './view/PanelsView'; -export default class PanelManager extends Module { +export default class PanelManager extends Module { //config = {}; panels: Panels; PanelsViewObj?: PanelsView; @@ -45,7 +44,7 @@ export default class PanelManager extends Module { */ constructor(em: EditorModel) { super(em, 'Panels', defaults); - this.panels = new Panels(this, this.config.defaults); + this.panels = new Panels(this, this.config.defaults!); for (var name in defaults) { //@ts-ignore if (!(name in this.config)) this.config[name] = defaults[name];