From f97f55bccaab7ccdcbf27a7387645c8fcb18d3da Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Wed, 7 Apr 2021 16:15:21 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B03896=20-=20CKeditor=20icon=20for=20enhan?= =?UTF-8?q?ce=20WikiText=20URLs=20syntax?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/utils.inc.php | 2 +- .../objectshortcut/dialogs/objectshortcut.js | 46 ++++++++++++++++++ .../objectshortcut/icons/objectshortcut.png | Bin 0 -> 643 bytes js/ckeditor/plugins/objectshortcut/plugin.js | 29 +++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 js/ckeditor/plugins/objectshortcut/dialogs/objectshortcut.js create mode 100644 js/ckeditor/plugins/objectshortcut/icons/objectshortcut.png create mode 100644 js/ckeditor/plugins/objectshortcut/plugin.js diff --git a/application/utils.inc.php b/application/utils.inc.php index 32743cab6..21226de12 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -2567,7 +2567,7 @@ class utils $aDefaultConf = array( 'language'=> $sLanguage, 'contentsLanguage' => $sLanguage, - 'extraPlugins' => 'disabler,codesnippet,mentions', + 'extraPlugins' => 'disabler,codesnippet,mentions,objectshortcut', ); // Mentions diff --git a/js/ckeditor/plugins/objectshortcut/dialogs/objectshortcut.js b/js/ckeditor/plugins/objectshortcut/dialogs/objectshortcut.js new file mode 100644 index 000000000..084fb92eb --- /dev/null +++ b/js/ckeditor/plugins/objectshortcut/dialogs/objectshortcut.js @@ -0,0 +1,46 @@ +CKEDITOR.dialog.add( 'objectshortcutDialog', function( editor ) { + return { + + // Basic properties of the dialog window: title, minimum size. + title: 'Object shortcut', + minWidth: 300, + minHeight: 200, + + // Dialog window content definition. + contents: [ + { + id: 'tab-basic', + label: 'Basic Settings', + + elements: [ + { + type: 'text', + id: 'class', + label: 'Class', + + validate: CKEDITOR.dialog.validate.notEmpty( "Class field cannot be empty." ) + }, + { + type: 'text', + id: 'id', + label: 'Id', + validate: CKEDITOR.dialog.validate.notEmpty( "Id field cannot be empty." ) + }, + { + type: 'text', + id: 'label', + label: 'Label', + }, + ] + }, + ], + + // This method is invoked once a user clicks the OK button, confirming the dialog. + onOk: function() { + editor.insertHtml( '[[' + this.getValueOf( 'tab-basic', 'class' ) + ':' + + this.getValueOf( 'tab-basic', 'id' ) + + ( this.getValueOf( 'tab-basic', 'label' ) ? '|' + this.getValueOf( 'tab-basic', 'label' ) : '') + + ']]' ); + } + }; +}); diff --git a/js/ckeditor/plugins/objectshortcut/icons/objectshortcut.png b/js/ckeditor/plugins/objectshortcut/icons/objectshortcut.png new file mode 100644 index 0000000000000000000000000000000000000000..b54f4e16bca81cd4a3d24cb7ad481030dab0573f GIT binary patch literal 643 zcmV-}0(||6P)d&;t`Jyb6q05(KqPnXmh!1+7>x1iOM zWMH!dA-NEd>$+T$fwHGf7PMND4Ag?!8@QVDxfe>QeIj~9M6Z60H=E5jzV9!xH1j;K z5r*NDSg%y%+JX6eeh>t~nQhw#@pxA80O0%nBHk-4xeVC0z1!(@)|boWZanUJUL$Ki z&+{7bUTM*u#E#=go`z+?%$I7d{YPAT17-@v<7NtF#7v>8sl5R+h2n8Dg)(BMP}Tg? z2BJTvVl`SVNd~@^AS5p*xB)W&>0bVqtR$o^jf7D0075vZUGqJ{5^lb%pc2I d%V7AQ`2qL_0DO#O@~Qv;002ovPDHLkV1henDxLrU literal 0 HcmV?d00001 diff --git a/js/ckeditor/plugins/objectshortcut/plugin.js b/js/ckeditor/plugins/objectshortcut/plugin.js new file mode 100644 index 000000000..f0ee55a1b --- /dev/null +++ b/js/ckeditor/plugins/objectshortcut/plugin.js @@ -0,0 +1,29 @@ +// Register the plugin within the editor. +CKEDITOR.plugins.add( 'objectshortcut', { + + // Register the icons. + icons: 'objectshortcut', + + // The plugin initialization logic goes inside this method. + init: function( editor ) { + + // Define an editor command that opens our dialog window. + editor.addCommand( 'objectshortcut', new CKEDITOR.dialogCommand( 'objectshortcutDialog' ) ); + + // Create a toolbar button that executes the above command. + editor.ui.addButton( 'Objectshortcut', { + + // The text part of the button (if available) and the tooltip. + label: 'Object Shortcut', + + // The command to execute on click. + command: 'objectshortcut', + + // The button placement in the toolbar (toolbar group name). + toolbar: 'insert' + }); + + // Register our dialog file -- this.path is the plugin folder path. + CKEDITOR.dialog.add( 'objectshortcutDialog', this.path + 'dialogs/objectshortcut.js' ); + } +});