From fae79d849ceb5f4fdb941bba671d4dd441064e36 Mon Sep 17 00:00:00 2001 From: RealStickman Date: Tue, 28 Jun 2022 13:30:01 +0200 Subject: [PATCH] (Grav GitSync) Automatic Commit from RealStickman --- plugins/editor-buttons/.gitignore | 1 + plugins/editor-buttons/CHANGELOG.md | 58 ++++++++ plugins/editor-buttons/README.md | 60 ++++++++ .../buttons/insert-headings/css/headings.css | 30 ++++ .../buttons/insert-headings/js/headings.js | 53 +++++++ .../buttons/insert-notice/css/notice.css | 12 ++ .../admin/buttons/insert-notice/js/notice.js | 82 +++++++++++ .../insert-shortcodes/js/shortcodes-core.js | 137 ++++++++++++++++++ .../insert-shortcodes/js/shortcodes-ui.js | 107 ++++++++++++++ .../admin/buttons/insert-table/css/table.css | 39 +++++ .../admin/buttons/insert-table/js/table.js | 97 +++++++++++++ plugins/editor-buttons/blueprints.yaml | 69 +++++++++ plugins/editor-buttons/editor-buttons.php | 58 ++++++++ plugins/editor-buttons/editor-buttons.yaml | 4 + plugins/editor-buttons/languages.yaml | 44 ++++++ 15 files changed, 851 insertions(+) create mode 100644 plugins/editor-buttons/.gitignore create mode 100644 plugins/editor-buttons/CHANGELOG.md create mode 100644 plugins/editor-buttons/README.md create mode 100644 plugins/editor-buttons/admin/buttons/insert-headings/css/headings.css create mode 100644 plugins/editor-buttons/admin/buttons/insert-headings/js/headings.js create mode 100644 plugins/editor-buttons/admin/buttons/insert-notice/css/notice.css create mode 100644 plugins/editor-buttons/admin/buttons/insert-notice/js/notice.js create mode 100644 plugins/editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-core.js create mode 100644 plugins/editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-ui.js create mode 100644 plugins/editor-buttons/admin/buttons/insert-table/css/table.css create mode 100644 plugins/editor-buttons/admin/buttons/insert-table/js/table.js create mode 100644 plugins/editor-buttons/blueprints.yaml create mode 100644 plugins/editor-buttons/editor-buttons.php create mode 100644 plugins/editor-buttons/editor-buttons.yaml create mode 100644 plugins/editor-buttons/languages.yaml diff --git a/plugins/editor-buttons/.gitignore b/plugins/editor-buttons/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/plugins/editor-buttons/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/plugins/editor-buttons/CHANGELOG.md b/plugins/editor-buttons/CHANGELOG.md new file mode 100644 index 0000000..7fd3c18 --- /dev/null +++ b/plugins/editor-buttons/CHANGELOG.md @@ -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 diff --git a/plugins/editor-buttons/README.md b/plugins/editor-buttons/README.md new file mode 100644 index 0000000..0d19f3c --- /dev/null +++ b/plugins/editor-buttons/README.md @@ -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 diff --git a/plugins/editor-buttons/admin/buttons/insert-headings/css/headings.css b/plugins/editor-buttons/admin/buttons/insert-headings/css/headings.css new file mode 100644 index 0000000..804a35d --- /dev/null +++ b/plugins/editor-buttons/admin/buttons/insert-headings/css/headings.css @@ -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; +} \ No newline at end of file diff --git a/plugins/editor-buttons/admin/buttons/insert-headings/js/headings.js b/plugins/editor-buttons/admin/buttons/insert-headings/js/headings.js new file mode 100644 index 0000000..1113260 --- /dev/null +++ b/plugins/editor-buttons/admin/buttons/insert-headings/js/headings.js @@ -0,0 +1,53 @@ +(function(){ + + if (typeof window.customToolbarElements === 'undefined') { window.customToolbarElements = []; } + window.customToolbarElements.push({ + identifier: 'content-headings', + button: { + title : 'Headings', + label : '', + class : 'heading-icon', + }, + processAction: function(editor) { + + if ($('#heading-dropdown').is(':visible')) { + $('#heading-dropdown').remove(); + return; + } + + var dropdown = '
'; + dropdown += 'H1'; + dropdown += 'H2'; + dropdown += 'H3'; + dropdown += 'H4'; + dropdown += 'H5'; + dropdown += 'H6'; + dropdown += '
'; + + 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(); + }); + + } + }); + +})(); diff --git a/plugins/editor-buttons/admin/buttons/insert-notice/css/notice.css b/plugins/editor-buttons/admin/buttons/insert-notice/css/notice.css new file mode 100644 index 0000000..7c62197 --- /dev/null +++ b/plugins/editor-buttons/admin/buttons/insert-notice/css/notice.css @@ -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); +} diff --git a/plugins/editor-buttons/admin/buttons/insert-notice/js/notice.js b/plugins/editor-buttons/admin/buttons/insert-notice/js/notice.js new file mode 100644 index 0000000..8b2c797 --- /dev/null +++ b/plugins/editor-buttons/admin/buttons/insert-notice/js/notice.js @@ -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: '', + modes: ['gfm', 'markdown'], + children: [ + { + 'notice-info': { + identifier: 'notice-info', + title: 'Info Notice', + label: '', + 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: '', + 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: '', + 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: '', + 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); + diff --git a/plugins/editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-core.js b/plugins/editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-core.js new file mode 100644 index 0000000..2df0df9 --- /dev/null +++ b/plugins/editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-core.js @@ -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: '', + modes: ['gfm', 'markdown'], + children: [ + { + 'shortcodes-alignleft': { + identifier: 'shortcodes-alignleft', + title: 'AlignLeft', + label: '', + 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: '', + 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: '', + 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: '', + 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: '', + 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: '', + 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: '', + 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: '', + 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); \ No newline at end of file diff --git a/plugins/editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-ui.js b/plugins/editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-ui.js new file mode 100644 index 0000000..de77d3c --- /dev/null +++ b/plugins/editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-ui.js @@ -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: '', + modes: ['gfm', 'markdown'], + children: [ + { + 'shortcodes-tab': { + identifier: 'shortcodes-tab', + title: 'Tab', + label: '', + 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: '', + 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: '', + 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: '', + 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: '', + 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: '', + 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); \ No newline at end of file diff --git a/plugins/editor-buttons/admin/buttons/insert-table/css/table.css b/plugins/editor-buttons/admin/buttons/insert-table/css/table.css new file mode 100644 index 0000000..7eaff56 --- /dev/null +++ b/plugins/editor-buttons/admin/buttons/insert-table/css/table.css @@ -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); +} diff --git a/plugins/editor-buttons/admin/buttons/insert-table/js/table.js b/plugins/editor-buttons/admin/buttons/insert-table/js/table.js new file mode 100644 index 0000000..91563f9 --- /dev/null +++ b/plugins/editor-buttons/admin/buttons/insert-table/js/table.js @@ -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: '', + 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 = '
'; + for (var i = 0; i < rows; i++) { + grid += '
'; + for (var c = 0; c < cols; c++) { + grid += '
'; + } + grid += '
'; + } + grid += '
'; + + 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); diff --git a/plugins/editor-buttons/blueprints.yaml b/plugins/editor-buttons/blueprints.yaml new file mode 100644 index 0000000..c53196c --- /dev/null +++ b/plugins/editor-buttons/blueprints.yaml @@ -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 diff --git a/plugins/editor-buttons/editor-buttons.php b/plugins/editor-buttons/editor-buttons.php new file mode 100644 index 0000000..f9b8563 --- /dev/null +++ b/plugins/editor-buttons/editor-buttons.php @@ -0,0 +1,58 @@ + ['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'); + } + + } + } +} diff --git a/plugins/editor-buttons/editor-buttons.yaml b/plugins/editor-buttons/editor-buttons.yaml new file mode 100644 index 0000000..11277fc --- /dev/null +++ b/plugins/editor-buttons/editor-buttons.yaml @@ -0,0 +1,4 @@ +enabled: true +insert_table: true +insert_notice: true +insert_shortcodes: true diff --git a/plugins/editor-buttons/languages.yaml b/plugins/editor-buttons/languages.yaml new file mode 100644 index 0000000..214f734 --- /dev/null +++ b/plugins/editor-buttons/languages.yaml @@ -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'