mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-16 10:16:07 +01:00
Merge branch 'develop' into feature/admin-gpm-dependencies
This commit is contained in:
@@ -178,50 +178,42 @@ export class Toolbar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderButtons() {
|
renderButtons() {
|
||||||
this.ui.navigation.find('.grav-editor-actions').empty().append('<ul />');
|
let map = { 'actions': 'navigation', 'modes': 'states'};
|
||||||
Buttons.navigation.forEach((button) => {
|
|
||||||
Object.keys(button).forEach((key) => {
|
|
||||||
let obj = button[key];
|
|
||||||
if (!obj.modes) { obj.modes = []; }
|
|
||||||
if (!~this.codemirror.options.ignore.indexOf(key) && (!obj.modes.length || obj.modes.indexOf(this.codemirror.options.mode) > -1)) {
|
|
||||||
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 (obj.shortcut) {
|
['actions', 'modes'].forEach((type) => {
|
||||||
this.addShortcut(obj.identifier, obj.shortcut, element);
|
this.ui.navigation.find(`.grav-editor-${type}`).empty().append('<ul />');
|
||||||
}
|
Buttons[map[type]].forEach((button) => this.renderButton(button, type));
|
||||||
|
|
||||||
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 />');
|
renderButton(button, type, location = null) {
|
||||||
Buttons.states.forEach((button) => {
|
Object.keys(button).forEach((key) => {
|
||||||
Object.keys(button).forEach((key) => {
|
let obj = button[key];
|
||||||
let obj = button[key];
|
if (!obj.modes) { obj.modes = []; }
|
||||||
if (!obj.modes) { obj.modes = []; }
|
if (!~this.codemirror.options.ignore.indexOf(key) && (!obj.modes.length || obj.modes.indexOf(this.codemirror.options.mode) > -1)) {
|
||||||
if (!~this.codemirror.options.ignore.indexOf(key) && (!obj.modes.length || obj.modes.indexOf(this.codemirror.options.mode) > -1)) {
|
let hint = obj.title ? `data-hint="${obj.title}" title="${obj.title}"` : '';
|
||||||
let element = $(`<li class="grav-editor-button-${key}"><a class="hint--top" data-hint="${obj.title}" title="${obj.title}">${obj.label}</a></li>`);
|
let element = $(`<li class="grav-editor-button-${key}"><a class="hint--top" ${hint}>${obj.label}</a></li>`);
|
||||||
this.ui.navigation.find('.grav-editor-modes ul').append(element);
|
(location || this.ui.navigation.find(`.grav-editor-${type} ul:not(.dropdown-menu)`)).append(element);
|
||||||
|
|
||||||
if (obj.shortcut) {
|
if (obj.shortcut) {
|
||||||
this.addShortcut(obj.identifier, obj.shortcut, element);
|
this.addShortcut(obj.identifier, obj.shortcut, 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
|
||||||
|
});
|
||||||
|
|
||||||
|
if (obj.children) {
|
||||||
|
let childrenContainer = $('<ul class="dropdown-menu" />');
|
||||||
|
element.addClass('button-group').find('a').wrap('<div class="dropdown-toggle" data-toggle="dropdown"></div>');
|
||||||
|
element.find('a').append(' <i class="fa fa-caret-down"></i>');
|
||||||
|
element.append(childrenContainer);
|
||||||
|
obj.children.forEach((child) => this.renderButton(child, type, childrenContainer));
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,76 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
identifier: 'headers',
|
||||||
|
title: 'Headers',
|
||||||
|
label: '<i class="fa fa-fw fa-header"></i>',
|
||||||
|
modes: ['gfm', 'markdown'],
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
h1: {
|
||||||
|
identifier: 'h1',
|
||||||
|
label: '<i class="fa fa-fw fa-header"></i>1',
|
||||||
|
modes: ['gfm', 'markdown'],
|
||||||
|
action({ codemirror, button, textarea }) {
|
||||||
|
replacer({ name: 'h1', replace: '# $1', codemirror, button, mode: 'replaceLine' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
h2: {
|
||||||
|
identifier: 'h2',
|
||||||
|
label: '<i class="fa fa-fw fa-header"></i>2',
|
||||||
|
modes: ['gfm', 'markdown'],
|
||||||
|
action({ codemirror, button, textarea }) {
|
||||||
|
replacer({ name: 'h2', replace: '## $1', codemirror, button, mode: 'replaceLine' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
h3: {
|
||||||
|
identifier: 'h3',
|
||||||
|
label: '<i class="fa fa-fw fa-header"></i>3',
|
||||||
|
modes: ['gfm', 'markdown'],
|
||||||
|
action({ codemirror, button, textarea }) {
|
||||||
|
replacer({ name: 'h3', replace: '### $1', codemirror, button, mode: 'replaceLine' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
h4: {
|
||||||
|
identifier: 'h4',
|
||||||
|
label: '<i class="fa fa-fw fa-header"></i>4',
|
||||||
|
modes: ['gfm', 'markdown'],
|
||||||
|
action({ codemirror, button, textarea }) {
|
||||||
|
replacer({ name: 'h4', replace: '#### $1', codemirror, button, mode: 'replaceLine' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
h5: {
|
||||||
|
identifier: 'h5',
|
||||||
|
label: '<i class="fa fa-fw fa-header"></i>5',
|
||||||
|
modes: ['gfm', 'markdown'],
|
||||||
|
action({ codemirror, button, textarea }) {
|
||||||
|
replacer({ name: 'h5', replace: '##### $1', codemirror, button, mode: 'replaceLine' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
h6: {
|
||||||
|
identifier: 'h6',
|
||||||
|
label: '<i class="fa fa-fw fa-header"></i>6',
|
||||||
|
modes: ['gfm', 'markdown'],
|
||||||
|
action({ codemirror, button, textarea }) {
|
||||||
|
replacer({ name: 'h6', replace: '###### $1', codemirror, button, mode: 'replaceLine' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
bold: {
|
bold: {
|
||||||
identifier: 'bold',
|
identifier: 'bold',
|
||||||
|
|||||||
@@ -97,9 +97,12 @@ export default class FormState {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
case 'radio':
|
|
||||||
value = field.is(':checked');
|
value = field.is(':checked');
|
||||||
break;
|
break;
|
||||||
|
case 'radio':
|
||||||
|
if (!field.is(':checked')) { return; }
|
||||||
|
value = field.val();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
value = field.val();
|
value = field.val();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import Cookies from 'cookies-js';
|
import Cookies from 'cookies-js';
|
||||||
|
import { Instance as Editors } from '../forms/fields/editor';
|
||||||
|
|
||||||
let Data = JSON.parse(Cookies.get('grav-tabs-state') || '{}');
|
let Data = JSON.parse(Cookies.get('grav-tabs-state') || '{}');
|
||||||
|
|
||||||
@@ -9,4 +10,12 @@ $('body').on('touchstart click', '[name^="tab-"]', (event) => {
|
|||||||
|
|
||||||
Data[target.attr('name')] = target.val();
|
Data[target.attr('name')] = target.val();
|
||||||
Cookies.set('grav-tabs-state', JSON.stringify(Data), { expires: Infinity });
|
Cookies.set('grav-tabs-state', JSON.stringify(Data), { expires: Infinity });
|
||||||
|
|
||||||
|
Editors.editors.each((index, editor) => {
|
||||||
|
let codemirror = $(editor).data('codemirror');
|
||||||
|
if (!codemirror) { return; }
|
||||||
|
if (codemirror.display.lastWrapWidth === 0) {
|
||||||
|
codemirror.refresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
2
themes/grav/css-compiled/preset.css
vendored
2
themes/grav/css-compiled/preset.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
themes/grav/css-compiled/template.css
vendored
2
themes/grav/css-compiled/template.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
20
themes/grav/js/admin.min.js
vendored
20
themes/grav/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -784,6 +784,12 @@ form {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#admin-main .grav-editor-toolbar .dropdown-menu {
|
||||||
|
box-shadow: 0 3px 6px rgba(0, 0, 0, .075);
|
||||||
|
border: 1px solid $form-border;
|
||||||
|
background: lighten($content-bg, 5%);
|
||||||
|
}
|
||||||
|
|
||||||
#admin-main .grav-editor-toolbar {
|
#admin-main .grav-editor-toolbar {
|
||||||
border: 1px solid $form-border;
|
border: 1px solid $form-border;
|
||||||
border-top-right-radius: $border-radius;
|
border-top-right-radius: $border-radius;
|
||||||
|
|||||||
@@ -87,6 +87,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown-menu li {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.grav-editor-hide-toolbar {
|
.grav-editor-hide-toolbar {
|
||||||
|
|||||||
Reference in New Issue
Block a user