├── .gitignore
├── CHANGELOG.md
├── README.md
├── admin
└── buttons
│ ├── code-button
│ └── js
│ │ └── code.js
│ ├── insert-headings
│ ├── css
│ │ └── headings.css
│ └── js
│ │ └── headings.js
│ ├── insert-notice
│ ├── css
│ │ └── notice.css
│ └── js
│ │ └── notice.js
│ ├── insert-shortcodes
│ └── js
│ │ ├── shortcodes-core.js
│ │ └── shortcodes-ui.js
│ └── insert-table
│ ├── css
│ └── table.css
│ └── js
│ └── table.js
├── blueprints.yaml
├── editor-buttons.php
├── editor-buttons.yaml
└── languages.yaml
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # v1.2.1
2 | ## 06/29/2017
3 |
4 | 1. [](#bugfix)
5 | * Fix release number
6 |
7 | # v1.2.0
8 | ## 06/29/2017
9 |
10 | 1. [](#new)
11 | * 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)
12 |
13 | # v1.1.3
14 | ## 11/03/2016
15 |
16 | 1. [](#bugfix)
17 | * 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)
18 |
19 | # v1.1.2
20 | ## 08/09/2016
21 |
22 | 1. [](#bugfix)
23 | * Old notices markdown syntax (>>>) replaced with new (!) [#16](https://github.com/getgrav/grav-plugin-editor-buttons/pull/16)
24 | 1. [](#improved)
25 | * Added german and romanian translations
26 |
27 | # v1.1.1
28 | ## 07/14/2016
29 |
30 | 1. [](#bugfix)
31 | * Fixed event to load the assets to work properly
32 | 1. [](#improved)
33 | * Renamed the css/js files for consistency
34 |
35 | # v1.1.0
36 | ## 07/13/2016
37 |
38 | 1. [](#improved)
39 | * Only shows the notices button if the Markdown Notices plugin is installed
40 | 1. [](#bugfix)
41 | * Fixed ES6 syntax to ES5 compatibility [#10](https://github.com/getgrav/grav-plugin-editor-buttons/issues/10)
42 | * Added feature dependency check for markdown-notices [#9](https://github.com/getgrav/grav-plugin-editor-buttons/issues/9)
43 | * Changed asset URL to relative URL from absolute URL
44 |
45 | # v1.1.0-beta.1
46 | ## 06/05/2016
47 |
48 | 1. [](#new)
49 | * Compatibility with Admin 1.1
50 | * Multilanguage support with russian, french and english
51 | 1. [](#improved)
52 | * Moved notices under a grouped button
53 |
54 | # v1.0.0
55 | ## 10/07/2015
56 |
57 | 1. [](#new)
58 | * First release
59 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Grav Editor Buttons Plugin
2 |
3 | The **Editor Buttons Plugin** for [Grav](http://github.com/getgrav/grav) adds additional buttons to the Grav Admin Editor.
4 |
5 | # Installation
6 |
7 | The Data plugin is easy to install with GPM.
8 |
9 | ```
10 | $ bin/gpm install editor-buttons
11 | ```
12 |
13 | Or clone from GitHub and put in the `user/plugins/editor-buttons` folder.
14 |
15 | # Configuration
16 |
17 | In the Admin Panel, Plugins list, clicking **Editor Buttons** will show you some options. You can independently activate one or more editor buttons.
18 |
19 | Currently available buttons are
20 |
21 | - Insert Table
22 | - Insert Headings
23 |
24 | If the "Markdown Notices" plugin is installed, these will also be available:
25 |
26 | - Insert Info Notice
27 | - Insert Note Notice
28 | - Insert Tip Notice
29 | - Insert Warning Notice
30 |
31 | If the "Shortcodes Core" plugin is installed, these will also be available:
32 |
33 | - Align Left | Center | Right
34 | - Insert Column
35 | - Create Safe Email
36 | - Insert Notice
37 | - Insert Underline
38 | - Insert Size
39 |
40 | If the "Shortcodes UI" plugin is installed, these will also be available:
41 |
42 | - Insert Tabs
43 | - Insert Accordion
44 | - Insert Browser
45 | - Insert Polaroid
46 | - Insert Image Compare
47 |
48 | # Usage
49 |
50 | Open a page, and along the editor default buttons you'll see the newly activated buttons.
51 |
52 | # Future improvements
53 |
54 | This is a first revision of the plugin.
55 |
56 | Ideas for the near future:
57 |
58 | - Allow to remove any of the default editor buttons
59 | - Add additional editor buttons
60 | - Allow stacking the buttons in vertical lists, to improve the usage of the space
61 |
--------------------------------------------------------------------------------
/admin/buttons/code-button/js/code.js:
--------------------------------------------------------------------------------
1 | (function($){
2 | $(function(){
3 | $('body').on('grav-editor-ready', function() {
4 | var Instance = Grav.default.Forms.Fields.EditorField.Instance;
5 | Instance.addButton({
6 | notices: {
7 | identifier: 'code',
8 | title: 'code',
9 | label: '',
10 | modes: ['gfm', 'markdown'],
11 | action: function(_ref) {
12 | var codemirror = _ref.codemirror, button = _ref.button;
13 |
14 | button.on('click.editor.code', function() {
15 | Instance.buttonStrategies.replaceSelections({ token: '$1', template: '``` \n$1\n```', codemirror: codemirror });
16 | codemirror.focus();
17 | });
18 | }
19 | }
20 | });
21 | });
22 | });
23 | })(jQuery);
24 |
--------------------------------------------------------------------------------
/admin/buttons/insert-headings/css/headings.css:
--------------------------------------------------------------------------------
1 | #heading-dropdown {
2 | background: #f3f3f3;
3 | position: absolute;
4 | display: block;
5 | z-index: 100;
6 | text-align: center;
7 | }
8 |
9 | .heading-dropdown-h2 {
10 | font-size: 0.9rem;
11 | }
12 | .heading-dropdown-h3 {
13 | font-size: 0.8rem;
14 | }
15 | .heading-dropdown-h4 {
16 | font-size: 0.7rem;
17 | }
18 | .heading-dropdown-h5 {
19 | font-size: 0.6rem;
20 | }
21 | .heading-dropdown-h6 {
22 | font-size: 0.5rem;
23 | }
24 |
25 | .grav-mdeditor-navbar ul #heading-dropdown a {
26 | padding: 0 0.9rem;
27 | }
28 | .grav-mdeditor-navbar ul #heading-dropdown a:hover {
29 | background: #fbfbfb;
30 | }
--------------------------------------------------------------------------------
/admin/buttons/insert-headings/js/headings.js:
--------------------------------------------------------------------------------
1 | (function(){
2 |
3 | if (typeof window.customToolbarElements === 'undefined') { window.customToolbarElements = []; }
4 | window.customToolbarElements.push({
5 | identifier: 'content-headings',
6 | button: {
7 | title : 'Headings',
8 | label : '',
9 | class : 'heading-icon',
10 | },
11 | processAction: function(editor) {
12 |
13 | if ($('#heading-dropdown').is(':visible')) {
14 | $('#heading-dropdown').remove();
15 | return;
16 | }
17 |
18 | var dropdown = '
';
19 | dropdown += '
H1';
20 | dropdown += '
H2';
21 | dropdown += '
H3';
22 | dropdown += '
H4';
23 | dropdown += '
H5';
24 | dropdown += '
H6';
25 | dropdown += '
';
26 |
27 | var $headingDropdown = $('.heading-icon');
28 | var $dropdown = $(dropdown)
29 | .insertAfter($headingDropdown);
30 |
31 |
32 | $dropdown.on('click', 'a', function () {
33 | $('#heading-dropdown').remove();
34 |
35 | var text = $(this).data('heading');
36 |
37 | //Add text to the editor
38 | var cm = editor.editor,
39 | pos = cm.getDoc().getCursor(true),
40 | posend = cm.getDoc().getCursor(false);
41 |
42 | for (var i=pos.line; i<(posend.line+1);i++) {
43 | cm.replaceRange(text+cm.getLine(i), { line: i, ch: 0 }, { line: i, ch: cm.getLine(i).length });
44 | }
45 |
46 | cm.setCursor({ line: posend.line, ch: cm.getLine(posend.line).length });
47 | cm.focus();
48 | });
49 |
50 | }
51 | });
52 |
53 | })();
54 |
--------------------------------------------------------------------------------
/admin/buttons/insert-notice/css/notice.css:
--------------------------------------------------------------------------------
1 | .fa-exclamation-circle.notice-info {
2 | color: #f0b383;
3 | }
4 | .fa-exclamation-circle.notice-warning {
5 | color: rgba(217,83,79,.8);
6 | }
7 | .fa-exclamation-circle.notice-note {
8 | color: #6ab0de;
9 | }
10 | .fa-exclamation-circle.notice-tip {
11 | color: rgba(92,184,92,.8);
12 | }
13 |
--------------------------------------------------------------------------------
/admin/buttons/insert-notice/js/notice.js:
--------------------------------------------------------------------------------
1 | (function($){
2 | $(function(){
3 | $('body').on('grav-editor-ready', function() {
4 | var Instance = Grav.default.Forms.Fields.EditorField.Instance;
5 | Instance.addButton({
6 | notices: {
7 | identifier: 'notices',
8 | title: 'Notices',
9 | label: '',
10 | modes: ['gfm', 'markdown'],
11 | children: [
12 | {
13 | 'notice-info': {
14 | identifier: 'notice-info',
15 | title: 'Info Notice',
16 | label: '',
17 | modes: ['gfm', 'markdown'],
18 | action: function(_ref) {
19 | var codemirror = _ref.codemirror, button = _ref.button;
20 |
21 | button.on('click.editor.notice-info', function() {
22 | Instance.buttonStrategies.replaceLine({ token: '$1', template: '! $1', codemirror: codemirror });
23 | codemirror.focus();
24 | });
25 | }
26 | }
27 | },
28 | {
29 | 'notice-warning': {
30 | identifier: 'notice-warning',
31 | title: 'Warning Notice',
32 | label: '',
33 | modes: ['gfm', 'markdown'],
34 | action: function(_ref) {
35 | var codemirror = _ref.codemirror, button = _ref.button;
36 |
37 | button.on('click.editor.notice-warning', function() {
38 | Instance.buttonStrategies.replaceLine({ token: '$1', template: '!! $1', codemirror: codemirror });
39 | codemirror.focus();
40 | });
41 | }
42 | }
43 | },
44 | {
45 | 'notice-note': {
46 | identifier: 'notice-note',
47 | title: 'Note Notice',
48 | label: '',
49 | modes: ['gfm', 'markdown'],
50 | action: function(_ref) {
51 | var codemirror = _ref.codemirror, button = _ref.button;
52 |
53 | button.on('click.editor.notice-note', function() {
54 | Instance.buttonStrategies.replaceLine({ token: '$1', template: '!!! $1', codemirror: codemirror });
55 | codemirror.focus();
56 | });
57 | }
58 | }
59 | },
60 | {
61 | 'notice-tip': {
62 | identifier: 'notice-tip',
63 | title: 'Tip Notice',
64 | label: '',
65 | modes: ['gfm', 'markdown'],
66 | action: function(_ref) {
67 | var codemirror = _ref.codemirror, button = _ref.button;
68 |
69 | button.on('click.editor.notice-tip', function() {
70 | Instance.buttonStrategies.replaceLine({ token: '$1', template: '!!!! $1', codemirror: codemirror });
71 | codemirror.focus();
72 | });
73 | }
74 | }
75 | }
76 | ]
77 | }
78 | });
79 | });
80 | });
81 | })(jQuery);
82 |
83 |
--------------------------------------------------------------------------------
/admin/buttons/insert-shortcodes/js/shortcodes-core.js:
--------------------------------------------------------------------------------
1 | (function($){
2 | $(function(){
3 | $('body').on('grav-editor-ready', function() {
4 | var Instance = Grav.default.Forms.Fields.EditorField.Instance;
5 | Instance.addButton({
6 | shortcodes: {
7 | identifier: 'shortcodes',
8 | title: 'Shortcodes Core',
9 | label: '',
10 | modes: ['gfm', 'markdown'],
11 | children: [
12 | {
13 | 'shortcodes-alignleft': {
14 | identifier: 'shortcodes-alignleft',
15 | title: 'AlignLeft',
16 | label: '',
17 | modes: ['gfm', 'markdown'],
18 | action: function(_ref) {
19 | var codemirror = _ref.codemirror, button = _ref.button;
20 | button.on('click.editor.shortcodes-alignleft', function() {
21 | Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[left]$1[/left]', codemirror: codemirror});
22 | codemirror.focus();
23 | });
24 | }
25 | }
26 | },
27 | {
28 | 'shortcodes-aligncenter': {
29 | identifier: 'shortcodes-aligncenter',
30 | title: 'AlignCenter',
31 | label: '',
32 | modes: ['gfm', 'markdown'],
33 | action: function(_ref) {
34 | var codemirror = _ref.codemirror, button = _ref.button;
35 | button.on('click.editor.shortcodes-aligncenter', function() {
36 | Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[center]$1[/center]', codemirror: codemirror});
37 | codemirror.focus();
38 | });
39 | }
40 | }
41 | },
42 | {
43 | 'shortcodes-alignright': {
44 | identifier: 'shortcodes-alignright',
45 | title: 'AlignRight',
46 | label: '',
47 | modes: ['gfm', 'markdown'],
48 | action: function(_ref) {
49 | var codemirror = _ref.codemirror, button = _ref.button;
50 | button.on('click.editor.shortcodes-alignright', function() {
51 | Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[right]$1[/right]', codemirror: codemirror});
52 | codemirror.focus();
53 | });
54 | }
55 | }
56 | },
57 | {
58 | 'shortcodes-column': {
59 | identifier: 'shortcodes-column',
60 | title: 'Column',
61 | label: '',
62 | modes: ['gfm', 'markdown'],
63 | action: function(_ref) {
64 | var codemirror = _ref.codemirror, button = _ref.button;
65 | button.on('click.editor.shortcodes-column', function() {
66 | Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[columns count=3]$1[/columns]', codemirror: codemirror});
67 | codemirror.focus();
68 | });
69 | }
70 | }
71 | },
72 | {
73 | 'shortcodes-safeemail': {
74 | identifier: 'shortcodes-safeemail',
75 | title: 'SafeEmail',
76 | label: '',
77 | modes: ['gfm', 'markdown'],
78 | action: function(_ref) {
79 | var codemirror = _ref.codemirror, button = _ref.button;
80 | button.on('click.editor.shortcodes-safeemail', function() {
81 | Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[safe-email autolink="true" icon="envelope-o"]$1[/safe-email]', codemirror: codemirror});
82 | codemirror.focus();
83 | });
84 | }
85 | }
86 | },
87 | {
88 | 'shortcodes-notice': {
89 | identifier: 'shortcodes-notice',
90 | title: 'Notice',
91 | label: '',
92 | modes: ['gfm', 'markdown'],
93 | action: function(_ref) {
94 | var codemirror = _ref.codemirror, button = _ref.button;
95 | button.on('click.editor.shortcodes-notice', function() {
96 | Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[notice]$1[/notice]', codemirror: codemirror});
97 | codemirror.focus();
98 | });
99 | }
100 | }
101 | },
102 | {
103 | 'shortcodes-underline': {
104 | identifier: 'shortcodes-underline',
105 | title: 'Underline',
106 | label: '',
107 | modes: ['gfm', 'markdown'],
108 | action: function(_ref) {
109 | var codemirror = _ref.codemirror, button = _ref.button;
110 | button.on('click.editor.shortcodes-underline', function() {
111 | Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[u]$1[/u]', codemirror: codemirror});
112 | codemirror.focus();
113 | });
114 | }
115 | }
116 | },
117 | {
118 | 'shortcodes-size': {
119 | identifier: 'shortcodes-size',
120 | title: 'Text Size',
121 | label: '',
122 | modes: ['gfm', 'markdown'],
123 | action: function(_ref) {
124 | var codemirror = _ref.codemirror, button = _ref.button;
125 | button.on('click.editor.shortcodes-size', function() {
126 | Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[size=30]$1[/size]', codemirror: codemirror});
127 | codemirror.focus();
128 | });
129 | }
130 | }
131 | }
132 | ]
133 | }
134 | });
135 | });
136 | });
137 | })(jQuery);
--------------------------------------------------------------------------------
/admin/buttons/insert-shortcodes/js/shortcodes-ui.js:
--------------------------------------------------------------------------------
1 | (function($){
2 | $(function(){
3 | $('body').on('grav-editor-ready', function() {
4 | var Instance = Grav.default.Forms.Fields.EditorField.Instance;
5 | Instance.addButton({
6 | shortcodes: {
7 | identifier: 'shortcodes',
8 | title: 'Shortcodes UI',
9 | label: '',
10 | modes: ['gfm', 'markdown'],
11 | children: [
12 | {
13 | 'shortcodes-tab': {
14 | identifier: 'shortcodes-tab',
15 | title: 'Tab',
16 | label: '',
17 | modes: ['gfm', 'markdown'],
18 | action: function(_ref) {
19 | var codemirror = _ref.codemirror, button = _ref.button;
20 | button.on('click.editor.shortcodes-tab', function() {
21 | 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});
22 | codemirror.focus();
23 | });
24 | }
25 | }
26 | },
27 | {
28 | 'shortcodes-accordion': {
29 | identifier: 'shortcodes-accordion',
30 | title: 'Accordion',
31 | label: '',
32 | modes: ['gfm', 'markdown'],
33 | action: function(_ref) {
34 | var codemirror = _ref.codemirror, button = _ref.button;
35 | button.on('click.editor.shortcodes-accordion', function() {
36 | 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});
37 | codemirror.focus();
38 | });
39 | }
40 | }
41 | },
42 | {
43 | 'shortcodes-callout': {
44 | identifier: 'shortcodes-callout',
45 | title: 'Callout',
46 | label: '',
47 | modes: ['gfm', 'markdown'],
48 | action: function(_ref) {
49 | var codemirror = _ref.codemirror, button = _ref.button;
50 | button.on('click.editor.shortcodes-callout', function() {
51 | 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});
52 | codemirror.focus();
53 | });
54 | }
55 | }
56 | },
57 | {
58 | 'shortcodes-imagecompare': {
59 | identifier: 'shortcodes-imagecompare',
60 | title: 'ImageCompare',
61 | label: '',
62 | modes: ['gfm', 'markdown'],
63 | action: function(_ref) {
64 | var codemirror = _ref.codemirror, button = _ref.button;
65 | button.on('click.editor.shortcodes-imagecompre', function() {
66 | Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[ui-image-compare]$1[/ui-image-compare]', codemirror: codemirror});
67 | codemirror.focus();
68 | });
69 | }
70 | }
71 | },
72 | {
73 | 'shortcodes-browser': {
74 | identifier: 'shortcodes-browser',
75 | title: 'Browser',
76 | label: '',
77 | modes: ['gfm', 'markdown'],
78 | action: function(_ref) {
79 | var codemirror = _ref.codemirror, button = _ref.button;
80 | button.on('click.editor.shortcodes-browser', function() {
81 | Instance.buttonStrategies.replaceSelections({ token: '$1', template: '[ui-browser address="http://yoururl.org"]$1[/browser]', codemirror: codemirror});
82 | codemirror.focus();
83 | });
84 | }
85 | }
86 | },
87 | {
88 | 'shortcodes-polaroid': {
89 | identifier: 'shortcodes-polaroid',
90 | title: 'Polaroid',
91 | label: '',
92 | modes: ['gfm', 'markdown'],
93 | action: function(_ref) {
94 | var codemirror = _ref.codemirror, button = _ref.button;
95 | button.on('click.editor.polaroid', function() {
96 | 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});
97 | codemirror.focus();
98 | });
99 | }
100 | }
101 | }
102 | ]
103 | }
104 | });
105 | });
106 | });
107 | })(jQuery);
--------------------------------------------------------------------------------
/admin/buttons/insert-table/css/table.css:
--------------------------------------------------------------------------------
1 | #grid-chooser {
2 | width: 120px;
3 | height: 120px;
4 | background: lightgray;
5 | position: absolute;
6 | padding: 2px;
7 | display: block;
8 | z-index: 100;
9 | }
10 |
11 | #grid-chooser .row:first-child .square:first-child .inner {
12 | background: rgba(0,0,0,0.4);
13 | }
14 |
15 | #grid-chooser .square:first-child {
16 | margin-top: 0;
17 | }
18 |
19 | #grid-chooser .row {
20 | height: calc(100%/5);
21 | }
22 | #grid-chooser .square {
23 | height: 100%;
24 | width: calc(100%/5);
25 |
26 | display: inline-block;
27 | margin: -2px 0;
28 | padding: 1px;
29 | }
30 | #grid-chooser .square:hover .inner, #grid-chooser .square.highlight .inner {
31 | background: rgba(0,0,0,0.4)
32 | }
33 |
34 | #grid-chooser .inner {
35 | height: 100%;
36 | width: 100%;
37 | border-radius: 3px;
38 | background: rgba(0,0,0,0.2);
39 | }
40 |
--------------------------------------------------------------------------------
/admin/buttons/insert-table/js/table.js:
--------------------------------------------------------------------------------
1 | (function($){
2 | $(function(){
3 | $('body').on('grav-editor-ready', function() {
4 | var Instance = Grav.default.Forms.Fields.EditorField.Instance;
5 | Instance.addButton({
6 | table: {
7 | identifier: 'table',
8 | title: 'Table',
9 | label: '',
10 | modes: ['gfm', 'markdown'],
11 | action: function(_ref) {
12 | var codemirror = _ref.codemirror, button = _ref.button, textarea = _ref.textarea, $allSquares;
13 |
14 | button.on('click.editor.table', function() {
15 | if ($('#grid-chooser').is(':visible')) {
16 | $('#grid-chooser').remove();
17 | return;
18 | }
19 |
20 | // Credit: http://jsfiddle.net/tnn3qgvj/8/
21 | var rows = 5;
22 | var cols = 5;
23 |
24 | var grid = '';
25 | for (var i = 0; i < rows; i++) {
26 | grid += '
';
27 | for (var c = 0; c < cols; c++) {
28 | grid += '
';
29 | }
30 | grid += '
';
31 | }
32 | grid += '
';
33 |
34 | var $grid = button.append($(grid));
35 |
36 | $allSquares = $('.square');
37 |
38 | });
39 |
40 | button.on('mouseover', '.square', function () {
41 | var $this = $(this);
42 | var col = $this.index() + 1;
43 | var row = $this.parent().index() + 1;
44 | $allSquares.removeClass('highlight');
45 | $('.row:nth-child(-n+'+row+') .square:nth-child(-n+'+col+')')
46 | .addClass('highlight');
47 | });
48 |
49 | button.on('click', '.square', function () {
50 | var $this = $(this);
51 | var cols = $this.index() + 1;
52 | var rows = $this.parent().index() + 1;
53 | $('#grid-chooser').remove();
54 |
55 | //Generate the markdown text to insert
56 | var text = '';
57 |
58 | var i = 0;
59 | var j = 0;
60 |
61 | while (i < cols) {
62 | text += '| Column ' + (i + 1) + ' Title ';
63 | i++;
64 | }
65 |
66 | text += '|' + '\n';
67 |
68 | i = 0;
69 | while (i < cols) {
70 | text += '| :----- ';
71 | i++;
72 | }
73 |
74 | text += '|' + '\n';
75 |
76 | i = 0;
77 | while (i < rows) {
78 | j = 0;
79 | while (j < cols) {
80 | text += '| Column ' + (j + 1) + ' Item ' + (i + 1) + ' ';
81 | j++;
82 | }
83 | i++;
84 |
85 | text += '|' + '\n';
86 | }
87 | Instance.buttonStrategies.replaceLine({ token: '$1', template: text, codemirror: codemirror });
88 | button.trigger('click.editor.table');
89 | codemirror.focus();
90 | });
91 | }
92 | }
93 | });
94 | });
95 | });
96 |
97 | })(jQuery);
98 |
--------------------------------------------------------------------------------
/blueprints.yaml:
--------------------------------------------------------------------------------
1 | name: Editor Buttons
2 | version: 1.2.1
3 | description: Adds additional editor button options
4 | icon: edit
5 | author:
6 | name: Team Grav
7 | email: devs@getgrav.org
8 | url: http://getgrav.org
9 | homepage: https://github.com/getgrav/grav-plugin-editor-buttons
10 | keywords: admin, plugin, editor, buttons
11 | bugs: https://github.com/getgrav/grav-plugin-editor-buttons/issues
12 | license: MIT
13 |
14 | dependencies:
15 | - { name: admin, version: '~1.1' }
16 |
17 | form:
18 | validation: loose
19 | fields:
20 | enabled:
21 | type: toggle
22 | label: PLUGIN_ADMIN.PLUGIN_STATUS
23 | highlight: 1
24 | default: 0
25 | options:
26 | 1: PLUGIN_ADMIN.ENABLED
27 | 0: PLUGIN_ADMIN.DISABLED
28 | validate:
29 | type: bool
30 |
31 | buttons:
32 | type: section
33 | title: PLUGIN_EDITOR_BUTTONS.ENABLE_BUTTONS
34 | underline: true
35 |
36 | fields:
37 |
38 | insert_table:
39 | type: toggle
40 | label: PLUGIN_EDITOR_BUTTONS.INSERT_TABLE_BUTTON
41 | highlight: 1
42 | default: 0
43 | options:
44 | 1: PLUGIN_ADMIN.ENABLED
45 | 0: PLUGIN_ADMIN.DISABLED
46 | validate:
47 | type: bool
48 |
49 | insert_notice:
50 | type: toggle
51 | label: PLUGIN_EDITOR_BUTTONS.INSERT_NOTICES
52 | highlight: 1
53 | default: 0
54 | options:
55 | 1: PLUGIN_ADMIN.ENABLED
56 | 0: PLUGIN_ADMIN.DISABLED
57 | validate:
58 | type: bool
59 |
60 | insert_shortcodes:
61 | type: toggle
62 | label: PLUGIN_EDITOR_BUTTONS.INSERT_SHORTCODES
63 | highlight: 1
64 | default: 0
65 | options:
66 | 1: PLUGIN_ADMIN.ENABLED
67 | 0: PLUGIN_ADMIN.DISABLED
68 | validate:
69 | type: bool
70 |
--------------------------------------------------------------------------------
/editor-buttons.php:
--------------------------------------------------------------------------------
1 | ['onTwigSiteVariables', 0]
19 | ];
20 | }
21 |
22 | /**
23 | *
24 | */
25 | public function onTwigSiteVariables()
26 | {
27 | if ($this->isAdmin()) {
28 | $this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-headings/js/headings.js');
29 | $this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-headings/css/headings.css');
30 | $this->grav['assets']->add('plugin://editor-buttons/admin/buttons/code-button/js/code.js');
31 |
32 | if ($this->config->get('plugins.editor-buttons.insert_table')) {
33 | $this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-table/js/table.js');
34 | $this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-table/css/table.css');
35 | }
36 |
37 | $noticesBC = $this->config->get('plugins.editor-buttons.insert_notice.info')
38 | || $this->config->get('plugins.editor-buttons.insert_notice.warning')
39 | || $this->config->get('plugins.editor-buttons.insert_notice.note')
40 | || $this->config->get('plugins.editor-buttons.insert_notice.tip');
41 |
42 | if ($this->config->get('plugins.markdown-notices.enabled') && $this->config->get('plugins.editor-buttons.insert_notice') || $noticesBC) {
43 | $this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-notice/js/notice.js');
44 | $this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-notice/css/notice.css');
45 | }
46 |
47 | if ($this->config->get('plugins.shortcode-core.enabled') && $this->config->get('plugins.editor-buttons.insert_shortcodes')) {
48 | $this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-core.js');
49 | //$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-shortcodes/css/shortcodes-core.css');
50 | }
51 |
52 | if ($this->config->get('plugins.shortcode-ui.enabled') && $this->config->get('plugins.editor-buttons.insert_shortcodes')) {
53 | $this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-shortcodes/js/shortcodes-ui.js');
54 | //$this->grav['assets']->add('plugin://editor-buttons/admin/buttons/insert-shortcodes/css/shortcodes-ui.css');
55 | }
56 |
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/editor-buttons.yaml:
--------------------------------------------------------------------------------
1 | enabled: true
2 | insert_table: true
3 | insert_notice: true
4 | insert_shortcodes: true
5 |
--------------------------------------------------------------------------------
/languages.yaml:
--------------------------------------------------------------------------------
1 | en:
2 | PLUGIN_EDITOR_BUTTONS:
3 | ENABLE_BUTTONS: 'Enable buttons'
4 | INSERT_TABLE_BUTTON: 'Insert Table Button'
5 | INSERT_NOTICES: 'Insert Notices'
6 | INSERT_SHORTCODES: 'Insert Shortcodes'
7 |
8 | de:
9 | PLUGIN_EDITOR_BUTTONS:
10 | ENABLE_BUTTONS: 'Aktiviere Buttons'
11 | INSERT_TABLE_BUTTON: 'Tabellen Button einfügen'
12 | INSERT_NOTICES: 'Notizen einfügen'
13 | INSERT_SHORTCODES: 'Shortcodes einfügen'
14 |
15 | it:
16 | PLUGIN_EDITOR_BUTTONS:
17 | ENABLE_BUTTONS: 'Abilita bottoni'
18 | INSERT_TABLE_BUTTON: 'Inserisci Tabella'
19 | INSERT_NOTICES: 'Inserisci Notifiche'
20 | INSERT_SHORTCODES: 'Inserisci Shortcodes'
21 |
22 | ru:
23 | PLUGIN_EDITOR_BUTTONS:
24 | ENABLE_BUTTONS: 'Добавить кнопки'
25 | INSERT_TABLE_BUTTON: 'Вставить таблицу'
26 | INSERT_NOTICES: 'Вставить уведомление'
27 | INSERT_SHORTCODES: 'Вставить Shortcodes'
28 |
29 | fr:
30 | PLUGIN_EDITOR_BUTTONS:
31 | ENABLE_BUTTONS: 'Activer les boutons'
32 | INSERT_TABLE_BUTTON: 'Insérer un bouton de tableau'
33 | INSERT_NOTICES: 'Insérer indications'
34 | INSERT_SHORTCODES: 'Insérer shortcodes'
35 | ro:
36 | PLUGIN_EDITOR_BUTTONS:
37 | ENABLE_BUTTONS: 'Activați butoanele'
38 | INSERT_TABLE_BUTTON: 'Inserați Button'
39 | INSERT_NOTICES: 'Inserați Notificări'
40 | INSERT_SHORTCODES: 'Inserați Shortcodes'
41 | es:
42 | PLUGIN_EDITOR_BUTTONS:
43 | ENABLE_BUTTONS: 'Activar botones'
44 | INSERT_TABLE_BUTTON: 'Insertar tabla'
45 | INSERT_NOTICES: 'Insertar nofificaciones'
46 | INSERT_SHORTCODES: 'Insertar shortcodes'
47 |
--------------------------------------------------------------------------------