Commit f76ec0d4 authored by Christos's avatar Christos

Merge branch 'configurable-menus' into 'master'

Configurable menus

See merge request !240
parents 55bd22d2 77db86f0
......@@ -10,8 +10,8 @@ import {
//setup
import MainNode from './setup/MainNode'
import MainConverter from './setup/MainConverter'
import toolPanels from './setup/ToolPanels'
import defaultToolPanels from './setup/defaultToolPanels'
import ucpToolPanels from './setup/ucpToolPanels'
// My Elements
import BibliographyEntryPackage from './elements/bibliographyEntry/BibliographyEntryPackage'
import PersistencePackage from './elements/persistence/PersistencePackage'
......@@ -71,7 +71,8 @@ const config = {
noBaseStyles: options.noBaseStyles,
})
config.import(toolPanels)
config.import(defaultToolPanels)
config.import(ucpToolPanels)
// Packages
config.import(TablePackage)
......
......@@ -41,7 +41,7 @@ class ChangeCaseTool extends Tool {
$$('div')
.addClass('choose-case')
.attr('title', `Change Case Action`)
.append('Choose Action')
.append('Transform Cases')
.append(dropDownCarret)
.on('click', this.toggleDropdown),
)
......
......@@ -11,7 +11,7 @@ export default {
config.addComponent('code', AnnotationComponent)
config.addCommand('code', WaxAnnotationCommand, {
nodeType: Code.type,
commandGroup: 'annotations',
commandGroup: 'insert-inline-code',
})
config.addIcon('code', { fontawesome: 'fa-code' })
config.addLabel('code', {
......
......@@ -15,7 +15,7 @@ export default {
config.addConverter('html', ImageHTMLConverter)
config.addCommand('insert-image', InsertImageCommand, {
nodeType: ImageNode.type,
commandGroup: 'annotations',
commandGroup: 'insert-image',
})
config.addCommand('edit-caption', EditCaptionCommand, {
nodeType: 'image',
......
......@@ -11,7 +11,7 @@ export default {
config.addComponent('strong', StrongComponent)
config.addCommand('strong', WaxAnnotationCommand, {
nodeType: 'strong',
commandGroup: 'annotations',
commandGroup: 'insert-strong',
})
config.addIcon('strong', { fontawesome: 'fa-bold' })
config.addLabel('strong', {
......
export default {
configure: config => {
name: 'toolPanels',
config.addToolPanel('side-toolbar', [
{
name: 'text-display',
type: 'tool-group',
showDisabled: true,
style: 'descriptive',
commandGroups: ['text-display'],
},
{
name: 'text-types',
type: 'tool-group',
showDisabled: true,
style: 'descriptive',
commandGroups: ['text-types'],
},
])
config.addToolPanel('toolbar', [
{
name: 'undo-redo',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['undo-redo'],
},
{
name: 'persistence',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['persistence'],
},
{
name: 'change-case',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['change-case'],
},
{
name: 'annotations',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['annotations'],
},
{
name: 'note',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['note'],
},
{
name: 'list',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['list'],
},
{
name: 'diacritics-tool',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['diacritics-tool'],
},
{
name: 'find-and-replace-tool',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['find-and-replace-tool'],
},
{
name: 'highlighter',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['highlighter'],
},
{
name: 'ornament',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['ornament'],
},
{
name: 'spell-check-toggle',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['spell-check-toggle'],
},
{
name: 'insert-script',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['insert-script'],
},
{
name: 'full-screen-control',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['full-screen-control'],
},
{
name: 'shortcuts-modal',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['shortcuts-modal'],
},
{
name: 'track-change-controls',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['track-change-controls'],
},
{
name: 'table',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['table'],
},
// {
// name: 'quote-marks',
// type: 'tool-group',
// showDisabled: true,
// style: 'minimal',
// commandGroups: ['text-macros'],
// },
])
config.addToolPanel('main-overlay', [
{
name: 'comment',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['comment'],
},
{
name: 'prompt',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['prompt'],
},
{
name: 'spell-check',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['spell-check'],
},
{
name: 'caption',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['caption'],
},
])
},
}
export default {
configure: config => {
name: 'defaultToolPanels',
config.addToolPanel('topDefault', [
{
name: 'undo-redo',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['undo-redo'],
},
{
name: 'persistence',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['persistence'],
},
{
name: 'change-case',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['change-case'],
},
{
name: 'insert-strong',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['insert-strong'],
},
{
name: 'annotations',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['annotations'],
},
{
name: 'insert-inline-code',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['insert-inline-code'],
},
{
name: 'insert-image',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['insert-image'],
},
{
name: 'note',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['note'],
},
{
name: 'list',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['list'],
},
{
name: 'diacritics-tool',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['diacritics-tool'],
},
{
name: 'find-and-replace-tool',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['find-and-replace-tool'],
},
{
name: 'highlighter',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['highlighter'],
},
{
name: 'ornament',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['ornament'],
},
{
name: 'spell-check-toggle',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['spell-check-toggle'],
},
{
name: 'insert-script',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['insert-script'],
},
{
name: 'full-screen-control',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['full-screen-control'],
},
{
name: 'shortcuts-modal',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['shortcuts-modal'],
},
{
name: 'track-change-controls',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['track-change-controls'],
},
{
name: 'table',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['table'],
},
])
config.addToolPanel('sideDefault', [
{
name: 'text-display',
type: 'tool-group',
showDisabled: true,
style: 'descriptive',
commandGroups: ['text-display'],
},
{
name: 'text-types',
type: 'tool-group',
showDisabled: true,
style: 'descriptive',
commandGroups: ['text-types'],
},
])
config.addToolPanel('main-overlay', [
{
name: 'comment',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['comment'],
},
{
name: 'prompt',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['prompt'],
},
{
name: 'spell-check',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['spell-check'],
},
{
name: 'caption',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['caption'],
},
])
},
}
export default {
configure: config => {
name: 'ucpToolPanels',
config.addToolPanel('ucpTopToolBar', [
{
name: 'undo-redo',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['undo-redo'],
},
{
name: 'persistence',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['persistence'],
},
{
name: 'change-case',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['change-case'],
},
{
name: 'annotations',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['annotations'],
},
{
name: 'insert-image',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['insert-image'],
},
{
name: 'note',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['note'],
},
{
name: 'list',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['list'],
},
{
name: 'diacritics-tool',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['diacritics-tool'],
},
{
name: 'find-and-replace-tool',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['find-and-replace-tool'],
},
{
name: 'highlighter',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['highlighter'],
},
{
name: 'ornament',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['ornament'],
},
{
name: 'spell-check-toggle',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['spell-check-toggle'],
},
{
name: 'full-screen-control',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['full-screen-control'],
},
{
name: 'shortcuts-modal',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['shortcuts-modal'],
},
{
name: 'track-change-controls',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['track-change-controls'],
},
{
name: 'table',
type: 'tool-group',
showDisabled: true,
style: 'minimal',
commandGroups: ['table'],
},
])
config.addToolPanel('ucpSideToolBar', [
{
name: 'text-display',
type: 'tool-group',
showDisabled: true,
style: 'descriptive',
commandGroups: ['text-display'],
},
{
name: 'text-types',
type: 'tool-group',
showDisabled: true,
style: 'descriptive',
commandGroups: ['text-types'],
},
])
config.addToolPanel('main-overlay', [
{
name: 'comment',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['comment'],
},
{
name: 'prompt',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['prompt'],
},
{
name: 'spell-check',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['spell-check'],
},
{
name: 'caption',
type: 'tool-prompt',
showDisabled: false,
commandGroups: ['caption'],
},
])
},
}
......@@ -3,13 +3,13 @@ import { Component, Toolbar } from 'substance'
class SideToolbar extends Component {
render($$) {
const { configurator } = this.props
const menu = configurator.menus.sideToolBar
const wrapper = $$('div').addClass('sidenav')
const sideNav = $$('div')
.addClass('se-toolbar-wrapper')
.append(
$$(Toolbar, {
toolPanel: configurator.getToolPanel('side-toolbar'),
toolPanel: configurator.getToolPanel(menu),
}),
)
return wrapper.append(sideNav)
......
......@@ -17,7 +17,7 @@ class Toolbar extends Component {
.addClass('view-mode')
.append('Read-Only')
: ''
const menu = configurator.menus.topToolBar
return $$('div')
.addClass('se-toolbar-wrapper')
.append(
......@@ -25,7 +25,7 @@ class Toolbar extends Component {
commandStates,
trackChanges,
trackChangesView,
toolPanel: configurator.getToolPanel('toolbar'),
toolPanel: configurator.getToolPanel(menu),
}),
// .ref('toolbar')
)
......
......@@ -113,14 +113,18 @@ class Wax extends React.Component {
user,
autoSave,
mode,
tools,
menus,
theme,
} = this.props
this.configurator = new Configurator().import(config)
this.configurator.addImporter('html', Importer)
const editorSession = this.createSession(content)
// add to Editoria
this.configurator.menus = {
topToolBar: 'topDefault',
sideToolBar: 'sideDefault',
}
const onClose = this.onClose
// TODO -- make this configurable
......@@ -145,7 +149,6 @@ class Wax extends React.Component {
user,
mode,
autoSave: false,
tools,
theme: 'editoria',
},
el,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment