Added ability to prevent from rendering any desired toolbar button from yaml declaration

This commit is contained in:
Djamil Legato
2016-03-01 22:14:21 -08:00
parent 44a96230ee
commit d34081db92
7 changed files with 45 additions and 36 deletions

View File

@@ -148,32 +148,36 @@ export class Toolbar {
this.ui.navigation.find('.grav-editor-actions').empty().append('<ul />');
Buttons.navigation.forEach((button) => {
Object.keys(button).forEach((key) => {
let obj = button[key];
let element = $(`<li class="grav-editor-button-${key}"><a class="hint--top" data-hint="${obj.title}" title="${obj.title}">${obj.label}</a></li>`);
this.ui.navigation.find('.grav-editor-actions ul').append(element);
if (!~this.codemirror.options.ignore.indexOf(key)) {
let obj = button[key];
let element = $(`<li class="grav-editor-button-${key}"><a class="hint--top" data-hint="${obj.title}" title="${obj.title}">${obj.label}</a></li>`);
this.ui.navigation.find('.grav-editor-actions ul').append(element);
obj.action && obj.action.call(obj.action, {
codemirror: this.codemirror,
button: element,
textarea: this.editor,
ui: this.ui
});
obj.action && obj.action.call(obj.action, {
codemirror: this.codemirror,
button: element,
textarea: this.editor,
ui: this.ui
});
}
});
});
this.ui.navigation.find('.grav-editor-modes').empty().append('<ul />');
Buttons.states.forEach((button) => {
Object.keys(button).forEach((key) => {
let obj = button[key];
let element = $(`<li class="grav-editor-button-${key}"><a class="hint--top" data-hint="${obj.title}" title="${obj.title}">${obj.label}</a></li>`);
this.ui.navigation.find('.grav-editor-modes ul').append(element);
if (!~this.codemirror.options.ignore.indexOf(key)) {
let obj = button[key];
let element = $(`<li class="grav-editor-button-${key}"><a class="hint--top" data-hint="${obj.title}" title="${obj.title}">${obj.label}</a></li>`);
this.ui.navigation.find('.grav-editor-modes ul').append(element);
obj.action && obj.action.call(obj.action, {
codemirror: this.codemirror,
button: element,
textarea: this.editor,
ui: this.ui
});
obj.action && obj.action.call(obj.action, {
codemirror: this.codemirror,
button: element,
textarea: this.editor,
ui: this.ui
});
}
});
});
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -36,10 +36,10 @@
@include flex-direction(row);
.grav-editor-actions {
@include flex(80% 0 0);
@include flex(1);
}
.grav-editor-modes {
@include flex(1);
@include flex(150px 0 0);
ul {
float: right;
}

View File

@@ -413,7 +413,7 @@ form {
margin: 0;
padding: 0;
li {
> li {
cursor: move;
padding: 1rem;
border-radius: $form-border-radius;

View File

@@ -1,5 +1,11 @@
{% set value = (value is null ? field.default : value) %}
{% set codemirrorOptions = {'mode': 'gfm'}|merge(field.codemirror|default({})) %}
{% set codemirrorOptions = {'mode': 'gfm', 'ignore': ['code', 'preview']}|merge(field.codemirror|default({})) %}
{# backward compatibility #}
{% if field.showPreview %}
{% set codemirrorOptions = codemirrorOptions|merge({'ignore': []}) %}
{% endif %}
{# end backward compatibility #}
{% block label %}
{% if field.label %}
@@ -16,7 +22,6 @@
data-grav-editor-mode="editor"
name="{{ (scope ~ field.name)|fieldName }}"
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if field.showPreview %}data-grav-preview-enabled="true"{% endif %}
data-grav-urlpreview="{{ base_url }}/media/{{ admin.route|trim('/') }}.json">{{ value|join("\n")|e('html') }}</textarea>
</div>
</div>