(Grav GitSync) Automatic Commit from RealStickman
This commit is contained in:
parent
bf51e50339
commit
fae79d849c
1
plugins/editor-buttons/.gitignore
vendored
Normal file
1
plugins/editor-buttons/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.DS_Store
|
58
plugins/editor-buttons/CHANGELOG.md
Normal file
58
plugins/editor-buttons/CHANGELOG.md
Normal file
@ -0,0 +1,58 @@
|
||||
# v1.2.1
|
||||
## 06/29/2017
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fix release number
|
||||
|
||||
# v1.2.0
|
||||
## 06/29/2017
|
||||
|
||||
1. [](#new)
|
||||
* Added Shortcode Core + Shortcode UI Button Dropdown. PR by [@dennemark](https://github.com/dennemark) [#23](https://github.com/getgrav/grav-plugin-editor-buttons/pull/23)
|
||||
|
||||
# v1.1.3
|
||||
## 11/03/2016
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fixed an issue with the Insert Table button. Prevents the `click` and `mouseover` events from being attached more than once in order to prevent tables from spawning erratically. [#20](https://github.com/getgrav/grav-plugin-editor-buttons/pull/20)
|
||||
|
||||
# v1.1.2
|
||||
## 08/09/2016
|
||||
|
||||
1. [](#bugfix)
|
||||
* Old notices markdown syntax (>>>) replaced with new (!) [#16](https://github.com/getgrav/grav-plugin-editor-buttons/pull/16)
|
||||
1. [](#improved)
|
||||
* Added german and romanian translations
|
||||
|
||||
# v1.1.1
|
||||
## 07/14/2016
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fixed event to load the assets to work properly
|
||||
1. [](#improved)
|
||||
* Renamed the css/js files for consistency
|
||||
|
||||
# v1.1.0
|
||||
## 07/13/2016
|
||||
|
||||
1. [](#improved)
|
||||
* Only shows the notices button if the Markdown Notices plugin is installed
|
||||
1. [](#bugfix)
|
||||
* Fixed ES6 syntax to ES5 compatibility [#10](https://github.com/getgrav/grav-plugin-editor-buttons/issues/10)
|
||||
* Added feature dependency check for markdown-notices [#9](https://github.com/getgrav/grav-plugin-editor-buttons/issues/9)
|
||||
* Changed asset URL to relative URL from absolute URL
|
||||
|
||||
# v1.1.0-beta.1
|
||||
## 06/05/2016
|
||||
|
||||
1. [](#new)
|
||||
* Compatibility with Admin 1.1
|
||||
* Multilanguage support with russian, french and english
|
||||
1. [](#improved)
|
||||
* Moved notices under a grouped button
|
||||
|
||||
# v1.0.0
|
||||
## 10/07/2015
|
||||
|
||||
1. [](#new)
|
||||
* First release
|
60
plugins/editor-buttons/README.md
Normal file
60
plugins/editor-buttons/README.md
Normal file
@ -0,0 +1,60 @@
|
||||
# Grav Editor Buttons Plugin
|
||||
|
||||
The **Editor Buttons Plugin** for [Grav](http://github.com/getgrav/grav) adds additional buttons to the Grav Admin Editor.
|
||||
|
||||
# Installation
|
||||
|
||||
The Data plugin is easy to install with GPM.
|
||||
|
||||
```
|
||||
$ bin/gpm install editor-buttons
|
||||
```
|
||||
|
||||
Or clone from GitHub and put in the `user/plugins/editor-buttons` folder.
|
||||
|
||||
# Configuration
|
||||
|
||||
In the Admin Panel, Plugins list, clicking **Editor Buttons** will show you some options. You can independently activate one or more editor buttons.
|
||||
|
||||
Currently available buttons are
|
||||
|
||||
- Insert Table
|
||||
- Insert Headings
|
||||
|
||||
If the "Markdown Notices" plugin is installed, these will also be available:
|
||||
|
||||
- Insert Info Notice
|
||||
- Insert Note Notice
|
||||
- Insert Tip Notice
|
||||
- Insert Warning Notice
|
||||
|
||||
If the "Shortcodes Core" plugin is installed, these will also be available:
|
||||
|
||||
- Align Left | Center | Right
|
||||
- Insert Column
|
||||
- Create Safe Email
|
||||
- Insert Notice
|
||||
- Insert Underline
|
||||
- Insert Size
|
||||
|
||||
If the "Shortcodes UI" plugin is installed, these will also be available:
|
||||
|
||||
- Insert Tabs
|
||||
- Insert Accordion
|
||||
- Insert Browser
|
||||
- Insert Polaroid
|
||||
- Insert Image Compare
|
||||
|
||||
# Usage
|
||||
|
||||
Open a page, and along the editor default buttons you'll see the newly activated buttons.
|
||||
|
||||
# Future improvements
|
||||
|
||||
This is a first revision of the plugin.
|
||||
|
||||
Ideas for the near future:
|
||||
|
||||
- Allow to remove any of the default editor buttons
|
||||
- Add additional editor buttons
|
||||
- Allow stacking the buttons in vertical lists, to improve the usage of the space
|
@ -0,0 +1,30 @@
|
||||
#heading-dropdown {
|
||||
background: #f3f3f3;
|
||||
position: absolute;
|
||||
display: block;
|
||||
z-index: 100;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.heading-dropdown-h2 {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.heading-dropdown-h3 {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
.heading-dropdown-h4 {
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
.heading-dropdown-h5 {
|
||||
font-size: 0.6rem;
|
||||
}
|
||||
.heading-dropdown-h6 {
|
||||
font-size: 0.5rem;
|
||||
}
|
||||
|
||||
.grav-mdeditor-navbar ul #heading-dropdown a {
|
||||
padding: 0 0.9rem;
|
||||
}
|
||||
.grav-mdeditor-navbar ul #heading-dropdown a:hover {
|
||||
background: #fbfbfb;
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
(function(){
|
||||
|
||||
if (typeof window.customToolbarElements === 'undefined') { window.customToolbarElements = []; }
|
||||
window.customToolbarElements.push({
|
||||
identifier: 'content-headings',
|
||||
button: {
|
||||
title : 'Headings',
|
||||
label : '<i class="fa fa-header content-headings"></i>',
|
||||
class : 'heading-icon',
|
||||
},
|
||||
processAction: function(editor) {
|
||||
|
||||
if ($('#heading-dropdown').is(':visible')) {
|
||||
$('#heading-dropdown').remove();
|
||||
return;
|
||||
}
|
||||
|
||||
var dropdown = '<div id="heading-dropdown">';
|
||||
dropdown += '<a href="javascript:void(0);" data-heading="# " class="heading-dropdown-h1">H1</a>';
|
||||
dropdown += '<a href="javascript:void(0);" data-heading="## " class="heading-dropdown-h2">H2</a>';
|
||||
dropdown += '<a href="javascript:void(0);" data-heading="### " class="heading-dropdown-h3">H3</a>';
|
||||
dropdown += '<a href="javascript:void(0);" data-heading="#### " class="heading-dropdown-h4">H4</a>';
|
||||
dropdown += '<a href="javascript:void(0);" data-heading="##### " class="heading-dropdown-h5">H5</a>';
|
||||
dropdown += '<a href="javascript:void(0);" data-heading="###### " class="heading-dropdown-h6">H6</a>';
|
||||
dropdown += '</div>';
|
||||
|
||||
var $headingDropdown = $('.heading-icon');
|
||||
var $dropdown = $(dropdown)
|
||||
.insertAfter($headingDropdown);
|
||||
|
||||
|
||||
$dropdown.on('click', 'a', function () {
|
||||
$('#heading-dropdown').remove();
|
||||
|
||||
var text = $(this).data('heading');
|
||||
|
||||
//Add text to the editor
|
||||
var cm = editor.editor,
|
||||
pos = cm.getDoc().getCursor(true),
|
||||
posend = cm.getDoc().getCursor(false);
|
||||
|
||||
for (var i=pos.line; i<(posend.line+1);i++) {
|
||||
cm.replaceRange(text+cm.getLine(i), { line: i, ch: 0 }, { line: i, ch: cm.getLine(i).length });
|
||||
}
|
||||
|
||||
cm.setCursor({ line: posend.line, ch: cm.getLine(posend.line).length });
|
||||
cm.focus();
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
@ -0,0 +1,12 @@
|
||||
.fa-exclamation-circle.notice-info {
|
||||
color: #f0b383;
|
||||
}
|
||||
.fa-exclamation-circle.notice-warning {
|
||||
color: rgba(217,83,79,.8);
|
||||
}
|
||||
.fa-exclamation-circle.notice-note {
|
||||
color: #6ab0de;
|
||||
}
|
||||
.fa-exclamation-circle.notice-tip {
|
||||
color: rgba(92,184,92,.8);
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
(function($){
|
||||
$(function(){
|
||||
$('body').on('grav-editor-ready', function() {
|
||||
var Instance = Grav.default.Forms.Fields.EditorField.Instance;
|
||||
Instance.addButton({
|
||||
notices: {
|
||||
identifier: 'notices',
|
||||
title: 'Notices',
|
||||
label: '<i class="fa fa-fw fa-exclamation-circle"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
children: [
|
||||
{
|
||||
'notice-info': {
|
||||
identifier: 'notice-info',
|
||||
title: 'Info Notice',
|
||||
label: '<i class="fa fa-fw fa-exclamation-circle notice-info"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
|
||||
button.on('click.editor.notice-info', function() {
|
||||
Instance.buttonStrategies.replaceLine({ token: '$1', template: '! $1', codemirror: codemirror });
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'notice-warning': {
|
||||
identifier: 'notice-warning',
|
||||
title: 'Warning Notice',
|
||||
label: '<i class="fa fa-fw fa-exclamation-circle notice-warning"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
|
||||
button.on('click.editor.notice-warning', function() {
|
||||
Instance.buttonStrategies.replaceLine({ token: '$1', template: '!! $1', codemirror: codemirror });
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'notice-note': {
|
||||
identifier: 'notice-note',
|
||||
title: 'Note Notice',
|
||||
label: '<i class="fa fa-fw fa-exclamation-circle notice-note"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
|
||||
button.on('click.editor.notice-note', function() {
|
||||
Instance.buttonStrategies.replaceLine({ token: '$1', template: '!!! $1', codemirror: codemirror });
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'notice-tip': {
|
||||
identifier: 'notice-tip',
|
||||
title: 'Tip Notice',
|
||||
label: '<i class="fa fa-fw fa-exclamation-circle notice-tip"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
|
||||
button.on('click.editor.notice-tip', function() {
|
||||
Instance.buttonStrategies.replaceLine({ token: '$1', template: '!!!! $1', codemirror: codemirror });
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
|
@ -0,0 +1,137 @@
|
||||
(function($){
|
||||
$(function(){
|
||||
$('body').on('grav-editor-ready', function() {
|
||||
var Instance = Grav.default.Forms.Fields.EditorField.Instance;
|
||||
Instance.addButton({
|
||||
shortcodes: {
|
||||
identifier: 'shortcodes',
|
||||
title: 'Shortcodes Core',
|
||||
label: '<i class="fa fa-fw fa-th"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
children: [
|
||||
{
|
||||
'shortcodes-alignleft': {
|
||||
identifier: 'shortcodes-alignleft',
|
||||
title: 'AlignLeft',
|
||||
label: '<i class="fa fa-fw fa-align-left"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-alignleft', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[left]$1[/left]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-aligncenter': {
|
||||
identifier: 'shortcodes-aligncenter',
|
||||
title: 'AlignCenter',
|
||||
label: '<i class="fa fa-fw fa-align-center"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-aligncenter', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[center]$1[/center]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-alignright': {
|
||||
identifier: 'shortcodes-alignright',
|
||||
title: 'AlignRight',
|
||||
label: '<i class="fa fa-fw fa-align-right"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-alignright', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[right]$1[/right]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-column': {
|
||||
identifier: 'shortcodes-column',
|
||||
title: 'Column',
|
||||
label: '<i class="fa fa-fw fa-columns"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-column', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[columns count=3]$1[/columns]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-safeemail': {
|
||||
identifier: 'shortcodes-safeemail',
|
||||
title: 'SafeEmail',
|
||||
label: '<i class="fa fa-fw fa-envelope"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-safeemail', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[safe-email autolink="true" icon="envelope-o"]$1[/safe-email]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-notice': {
|
||||
identifier: 'shortcodes-notice',
|
||||
title: 'Notice',
|
||||
label: '<i class="fa fa-fw fa-lightbulb-o"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-notice', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[notice]$1[/notice]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-underline': {
|
||||
identifier: 'shortcodes-underline',
|
||||
title: 'Underline',
|
||||
label: '<i class="fa fa-fw fa-underline"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-underline', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[u]$1[/u]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-size': {
|
||||
identifier: 'shortcodes-size',
|
||||
title: 'Text Size',
|
||||
label: '<i class="fa fa-fw fa-text-height"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-size', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[size=30]$1[/size]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
@ -0,0 +1,107 @@
|
||||
(function($){
|
||||
$(function(){
|
||||
$('body').on('grav-editor-ready', function() {
|
||||
var Instance = Grav.default.Forms.Fields.EditorField.Instance;
|
||||
Instance.addButton({
|
||||
shortcodes: {
|
||||
identifier: 'shortcodes',
|
||||
title: 'Shortcodes UI',
|
||||
label: '<i class="fa fa-fw fa-th-large"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
children: [
|
||||
{
|
||||
'shortcodes-tab': {
|
||||
identifier: 'shortcodes-tab',
|
||||
title: 'Tab',
|
||||
label: '<i class="fa fa-fw fa-folder"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-tab', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[ui-tabs position="top-left" active="0" theme="lite"][ui-tab title="First Tab"]$1[/ui-tab][/ui-tabs]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-accordion': {
|
||||
identifier: 'shortcodes-accordion',
|
||||
title: 'Accordion',
|
||||
label: '<i class="fa fa-fw fa-toggle-down"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-accordion', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[ui-accordion independent=true open=none][ui-accordion-item title="Section 1"]$1[/ui-accordion-item][/ui-accordion]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-callout': {
|
||||
identifier: 'shortcodes-callout',
|
||||
title: 'Callout',
|
||||
label: '<i class="fa fa-fw fa-comment-o"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-callout', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[ui-callout][ui-callout-item title="Outlines" position="50%, 50%, se"][/ui-callout-item]$1[/ui-callout]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-imagecompare': {
|
||||
identifier: 'shortcodes-imagecompare',
|
||||
title: 'ImageCompare',
|
||||
label: '<i class="fa fa-fw fa-arrows-h"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-imagecompre', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[ui-image-compare]$1![Image to Compare](url-to-image.jpg)[/ui-image-compare]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-browser': {
|
||||
identifier: 'shortcodes-browser',
|
||||
title: 'Browser',
|
||||
label: '<i class="fa fa-fw fa-window-maximize"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.shortcodes-browser', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[ui-browser address="http://yoururl.org"]$1[/browser]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'shortcodes-polaroid': {
|
||||
identifier: 'shortcodes-polaroid',
|
||||
title: 'Polaroid',
|
||||
label: '<i class="fa fa-fw fa-camera"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button;
|
||||
button.on('click.editor.polaroid', function() {
|
||||
Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[ui-polaroid angle="-3" margin="30px 50px 20px 0" position="left" title="This is a polaroid"]$1[/ui-polaroid]', codemirror: codemirror});
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
@ -0,0 +1,39 @@
|
||||
#grid-chooser {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background: lightgray;
|
||||
position: absolute;
|
||||
padding: 2px;
|
||||
display: block;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
#grid-chooser .row:first-child .square:first-child .inner {
|
||||
background: rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
#grid-chooser .square:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
#grid-chooser .row {
|
||||
height: calc(100%/5);
|
||||
}
|
||||
#grid-chooser .square {
|
||||
height: 100%;
|
||||
width: calc(100%/5);
|
||||
|
||||
display: inline-block;
|
||||
margin: -2px 0;
|
||||
padding: 1px;
|
||||
}
|
||||
#grid-chooser .square:hover .inner, #grid-chooser .square.highlight .inner {
|
||||
background: rgba(0,0,0,0.4)
|
||||
}
|
||||
|
||||
#grid-chooser .inner {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
border-radius: 3px;
|
||||
background: rgba(0,0,0,0.2);
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
(function($){
|
||||
$(function(){
|
||||
$('body').on('grav-editor-ready', function() {
|
||||
var Instance = Grav.default.Forms.Fields.EditorField.Instance;
|
||||
Instance.addButton({
|
||||
table: {
|
||||
identifier: 'table',
|
||||
title: 'Table',
|
||||
label: '<i class="fa fa-fw fa-table"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(_ref) {
|
||||
var codemirror = _ref.codemirror, button = _ref.button, textarea = _ref.textarea, $allSquares;
|
||||
|
||||
button.on('click.editor.table', function() {
|
||||
if ($('#grid-chooser').is(':visible')) {
|
||||
$('#grid-chooser').remove();
|
||||
return;
|
||||
}
|
||||
|
||||
// Credit: http://jsfiddle.net/tnn3qgvj/8/
|
||||
var rows = 5;
|
||||
var cols = 5;
|
||||
|
||||
var grid = '<div class="grid" id="grid-chooser">';
|
||||
for (var i = 0; i < rows; i++) {
|
||||
grid += '<div class="row">';
|
||||
for (var c = 0; c < cols; c++) {
|
||||
grid += '<div class="square"><div class="inner"></div></div>';
|
||||
}
|
||||
grid += '</div>';
|
||||
}
|
||||
grid += '</div>';
|
||||
|
||||
var $grid = button.append($(grid));
|
||||
|
||||
$allSquares = $('.square');
|
||||
|
||||
});
|
||||
|
||||
button.on('mouseover', '.square', function () {
|
||||
var $this = $(this);
|
||||
var col = $this.index() + 1;
|
||||
var row = $this.parent().index() + 1;
|
||||
$allSquares.removeClass('highlight');
|
||||
$('.row:nth-child(-n+'+row+') .square:nth-child(-n+'+col+')')
|
||||
.addClass('highlight');
|
||||
});
|
||||
|
||||
button.on('click', '.square', function () {
|
||||
var $this = $(this);
|
||||
var cols = $this.index() + 1;
|
||||
var rows = $this.parent().index() + 1;
|
||||
$('#grid-chooser').remove();
|
||||
|
||||
//Generate the markdown text to insert
|
||||
var text = '';
|
||||
|
||||
var i = 0;
|
||||
var j = 0;
|
||||
|
||||
while (i < cols) {
|
||||
text += '| Column ' + (i + 1) + ' Title ';
|
||||
i++;
|
||||
}
|
||||
|
||||
text += '|' + '\n';
|
||||
|
||||
i = 0;
|
||||
while (i < cols) {
|
||||
text += '| :----- ';
|
||||
i++;
|
||||
}
|
||||
|
||||
text += '|' + '\n';
|
||||
|
||||
i = 0;
|
||||
while (i < rows) {
|
||||
j = 0;
|
||||
while (j < cols) {
|
||||
text += '| Column ' + (j + 1) + ' Item ' + (i + 1) + ' ';
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
|
||||
text += '|' + '\n';
|
||||
}
|
||||
Instance.buttonStrategies.replaceLine({ token: '$1', template: text, codemirror: codemirror });
|
||||
button.trigger('click.editor.table');
|
||||
codemirror.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery);
|
69
plugins/editor-buttons/blueprints.yaml
Normal file
69
plugins/editor-buttons/blueprints.yaml
Normal file
@ -0,0 +1,69 @@
|
||||
name: Editor Buttons
|
||||
version: 1.2.1
|
||||
description: Adds additional editor button options
|
||||
icon: edit
|
||||
author:
|
||||
name: Team Grav
|
||||
email: devs@getgrav.org
|
||||
url: http://getgrav.org
|
||||
homepage: https://github.com/getgrav/grav-plugin-editor-buttons
|
||||
keywords: admin, plugin, editor, buttons
|
||||
bugs: https://github.com/getgrav/grav-plugin-editor-buttons/issues
|
||||
license: MIT
|
||||
|
||||
dependencies:
|
||||
- { name: admin, version: '~1.1' }
|
||||
|
||||
form:
|
||||
validation: loose
|
||||
fields:
|
||||
enabled:
|
||||
type: toggle
|
||||
label: PLUGIN_ADMIN.PLUGIN_STATUS
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: PLUGIN_ADMIN.ENABLED
|
||||
0: PLUGIN_ADMIN.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
buttons:
|
||||
type: section
|
||||
title: PLUGIN_EDITOR_BUTTONS.ENABLE_BUTTONS
|
||||
underline: true
|
||||
|
||||
fields:
|
||||
|
||||
insert_table:
|
||||
type: toggle
|
||||
label: PLUGIN_EDITOR_BUTTONS.INSERT_TABLE_BUTTON
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: PLUGIN_ADMIN.ENABLED
|
||||
0: PLUGIN_ADMIN.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
insert_notice:
|
||||
type: toggle
|
||||
label: PLUGIN_EDITOR_BUTTONS.INSERT_NOTICES
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: PLUGIN_ADMIN.ENABLED
|
||||
0: PLUGIN_ADMIN.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
insert_shortcodes:
|
||||
type: toggle
|
||||
label: PLUGIN_EDITOR_BUTTONS.INSERT_SHORTCODES
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: PLUGIN_ADMIN.ENABLED
|
||||
0: PLUGIN_ADMIN.DISABLED
|
||||
validate:
|
||||
type: bool
|
58
plugins/editor-buttons/editor-buttons.php
Normal file
58
plugins/editor-buttons/editor-buttons.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace Grav\Plugin;
|
||||
|
||||
use Grav\Common\GPM\GPM;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Page\Page;
|
||||
use Grav\Common\Page\Pages;
|
||||
use Grav\Common\Plugin;
|
||||
|
||||
class EditorButtonsPlugin extends Plugin
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
'onTwigSiteVariables' => ['onTwigSiteVariables', 0]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function onTwigSiteVariables()
|
||||
{
|
||||
if ($this->isAdmin()) {
|
||||
$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-headings/js/headings.js');
|
||||
$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-headings/css/headings.css');
|
||||
|
||||
if ($this->config->get('plugins.editor-buttons.insert_table')) {
|
||||
$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-table/js/table.js');
|
||||
$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-table/css/table.css');
|
||||
}
|
||||
|
||||
$noticesBC = $this->config->get('plugins.editor-buttons.insert_notice.info')
|
||||
|| $this->config->get('plugins.editor-buttons.insert_notice.warning')
|
||||
|| $this->config->get('plugins.editor-buttons.insert_notice.note')
|
||||
|| $this->config->get('plugins.editor-buttons.insert_notice.tip');
|
||||
|
||||
if ($this->config->get('plugins.markdown-notices.enabled') && $this->config->get('plugins.editor-buttons.insert_notice') || $noticesBC) {
|
||||
$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-notice/js/notice.js');
|
||||
$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-notice/css/notice.css');
|
||||
}
|
||||
|
||||
if ($this->config->get('plugins.shortcode-core.enabled') && $this->config->get('plugins.editor-buttons.insert_shortcodes')) {
|
||||
$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-core.js');
|
||||
//$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-shortcodes/css/shortcodes-core.css');
|
||||
}
|
||||
|
||||
if ($this->config->get('plugins.shortcode-ui.enabled') && $this->config->get('plugins.editor-buttons.insert_shortcodes')) {
|
||||
$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-ui.js');
|
||||
//$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-shortcodes/css/shortcodes-ui.css');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
4
plugins/editor-buttons/editor-buttons.yaml
Normal file
4
plugins/editor-buttons/editor-buttons.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
enabled: true
|
||||
insert_table: true
|
||||
insert_notice: true
|
||||
insert_shortcodes: true
|
44
plugins/editor-buttons/languages.yaml
Normal file
44
plugins/editor-buttons/languages.yaml
Normal file
@ -0,0 +1,44 @@
|
||||
en:
|
||||
PLUGIN_EDITOR_BUTTONS:
|
||||
ENABLE_BUTTONS: 'Enable buttons'
|
||||
INSERT_TABLE_BUTTON: 'Insert Table Button'
|
||||
INSERT_NOTICES: 'Insert Notices'
|
||||
INSERT_SHORTCODES: 'Insert Shortcodes'
|
||||
|
||||
de:
|
||||
PLUGIN_EDITOR_BUTTONS:
|
||||
ENABLE_BUTTONS: 'Aktiviere Buttons'
|
||||
INSERT_TABLE_BUTTON: 'Tabellen Button einfügen'
|
||||
INSERT_NOTICES: 'Notizen einfügen'
|
||||
INSERT_SHORTCODES: 'Shortcodes einfügen'
|
||||
|
||||
it:
|
||||
PLUGIN_EDITOR_BUTTONS:
|
||||
ENABLE_BUTTONS: 'Abilita bottoni'
|
||||
INSERT_TABLE_BUTTON: 'Inserisci Tabella'
|
||||
INSERT_NOTICES: 'Inserisci Notifiche'
|
||||
INSERT_SHORTCODES: 'Inserisci Shortcodes'
|
||||
|
||||
ru:
|
||||
PLUGIN_EDITOR_BUTTONS:
|
||||
ENABLE_BUTTONS: 'Добавить кнопки'
|
||||
INSERT_TABLE_BUTTON: 'Вставить таблицу'
|
||||
INSERT_NOTICES: 'Вставить уведомление'
|
||||
INSERT_SHORTCODES: 'Вставить Shortcodes'
|
||||
|
||||
fr:
|
||||
PLUGIN_EDITOR_BUTTONS:
|
||||
ENABLE_BUTTONS: 'Activer les boutons'
|
||||
INSERT_TABLE_BUTTON: 'Insérer un bouton de tableau'
|
||||
INSERT_NOTICES: 'Insérer indications'
|
||||
INSERT_SHORTCODES: 'Insérer shortcodes'
|
||||
ro:
|
||||
PLUGIN_EDITOR_BUTTONS:
|
||||
ENABLE_BUTTONS: 'Activați butoanele'
|
||||
INSERT_TABLE_BUTTON: 'Inserați Button'
|
||||
INSERT_NOTICES: 'Inserați Notificări'
|
||||
es:
|
||||
PLUGIN_EDITOR_BUTTONS:
|
||||
ENABLE_BUTTONS: 'Activar botones'
|
||||
INSERT_TABLE_BUTTON: 'Insertar tabla'
|
||||
INSERT_NOTICES: 'Insertar nofificaciones'
|
Loading…
Reference in New Issue
Block a user