Skip to content

Commit

Permalink
Dynamic Editor-Buttons TinyMCE
Browse files Browse the repository at this point in the history
This PR makes it easier to expand the functionality of TinyMCE and
allows to install/uninstall (as Joomla-Plugins) or enable/disable
Buttons. For that there is a new plugin category "editors_buttons" which
must be used. Also jdragdrop is fitted for this changes. (based on
  • Loading branch information
alimpam committed Aug 28, 2016
1 parent d776fa9 commit e5b9b84
Show file tree
Hide file tree
Showing 14 changed files with 379 additions and 447 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`)
VALUES (458, 'PLG_EDITORS_BUTTONS_JDRAGDROP_NAME', 'plugin', 'jdragdrop', 'editors_buttons', 0, 1, 1, 1, '{"name":"PLG_EDITORS_BUTTONS_JDRAGDROP_NAME","type":"plugin","creationDate":"August 2016","author":"Joomla! Project","copyright":"Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved.","authorEmail":"admin@joomla.org","authorUrl":"www.joomla.org","version":"3.7.0","description":"PLG_EDITORS_BUTTONS_JDRAGDROP_DESC","group":"","filename":"jdragdrop"}', '', '', '', 0, '0000-00-00 00:00:00', 0, 0);

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state")
VALUES (458, 'PLG_EDITORS_BUTTONS_JDRAGDROP_NAME', 'plugin', 'jdragdrop', 'editors_buttons', 0, 1, 1, 1, '{"name":"PLG_EDITORS_BUTTONS_JDRAGDROP_NAME","type":"plugin","creationDate":"August 2016","author":"Joomla! Project","copyright":"Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved.","authorEmail":"admin@joomla.org","authorUrl":"www.joomla.org","version":"3.7.0","description":"PLG_EDITORS_BUTTONS_JDRAGDROP_DESC","group":"","filename":"jdragdrop"}', '', '', '', 0, '0000-00-00 00:00:00', 0, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SET IDENTITY_INSERT [#__extensions] ON;

INSERT [#__extensions] ([extension_id], [name], [type], [element], [folder], [client_id], [enabled], [access], [protected], [manifest_cache], [params], [custom_data], [system_data], [checked_out], [checked_out_time], [ordering], [state])
SELECT 458, 'PLG_EDITORS_BUTTONS_JDRAGDROP_NAME', 'plugin', 'jdragdrop', 'editors_buttons', 0, 1, 1, 1, '{"name":"PLG_EDITORS_BUTTONS_JDRAGDROP_NAME","type":"plugin","creationDate":"August 2016","author":"Joomla! Project","copyright":"Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved.","authorEmail":"admin@joomla.org","authorUrl":"www.joomla.org","version":"3.7.0","description":"PLG_EDITORS_BUTTONS_JDRAGDROP_DESC","group":"","filename":"jdragdrop"}', '', '', '', 0, '0000-00-00 00:00:00', 0, 0;

SET IDENTITY_INSERT [#__extensions] OFF;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Joomla! Project
; Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

PLG_EDITORS_BUTTONS_JDRAGDROP_NAME="JDragDrop"
PLG_EDITORS_BUTTONS_JDRAGDROP_DESC="Drag and Drop Plugin for TinyMCE"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; Joomla! Project
; Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

PLG_EDITORS_BUTTONS_JDRAGDROP_NAME="JDragDrop"
PLG_EDITORS_BUTTONS_JDRAGDROP_DESC="Drag and Drop Plugin for TinyMCE"

1 change: 1 addition & 0 deletions installation/sql/mysql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`
(455, 'plg_installer_packageinstaller', 'plugin', 'packageinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 1, 0),
(456, 'plg_installer_folderinstaller', 'plugin', 'folderinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 2, 0),
(457, 'plg_installer_urlinstaller', 'plugin', 'urlinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 3, 0),
(458, 'PLG_EDITORS_BUTTONS_JDRAGDROP_NAME', 'plugin', 'jdragdrop', 'editors_buttons', 0, 1, 1, 1, '{"name":"PLG_EDITORS_BUTTONS_JDRAGDROP_NAME","type":"plugin","creationDate":"August 2016","author":"Joomla! Project","copyright":"Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved.","authorEmail":"admin@joomla.org","authorUrl":"www.joomla.org","version":"3.7.0","description":"PLG_EDITORS_BUTTONS_JDRAGDROP_DESC","group":"","filename":"jdragdrop"}', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(503, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(504, 'hathor', 'template', 'hathor', '', 1, 1, 1, 0, '', '{"showSiteName":"0","colourChoice":"0","boldText":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(506, 'protostar', 'template', 'protostar', '', 0, 1, 1, 0, '', '{"templateColor":"","logoFile":"","googleFont":"1","googleFontName":"Open+Sans","fluidContainer":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
Expand Down
3 changes: 2 additions & 1 deletion installation/sql/postgresql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder"
(454, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0),
(455, 'plg_installer_packageinstaller', 'plugin', 'packageinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 1, 0),
(456, 'plg_installer_folderinstaller', 'plugin', 'folderinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 2, 0),
(457, 'plg_installer_urlinstaller', 'plugin', 'urlinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 3, 0);
(457, 'plg_installer_urlinstaller', 'plugin', 'urlinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 3, 0),
(458, 'PLG_EDITORS_BUTTONS_JDRAGDROP_NAME', 'plugin', 'jdragdrop', 'editors_buttons', 0, 1, 1, 1, '{"name":"PLG_EDITORS_BUTTONS_JDRAGDROP_NAME","type":"plugin","creationDate":"August 2016","author":"Joomla! Project","copyright":"Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved.","authorEmail":"admin@joomla.org","authorUrl":"www.joomla.org","version":"3.7.0","description":"PLG_EDITORS_BUTTONS_JDRAGDROP_DESC","group":"","filename":"jdragdrop"}', '', '', '', 0, '0000-00-00 00:00:00', 0, 0);

-- Templates
INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES
Expand Down
4 changes: 3 additions & 1 deletion installation/sql/sqlazure/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,9 @@ SELECT 455, 'plg_installer_packageinstaller', 'plugin', 'packageinstaller', 'ins
UNION ALL
SELECT 456, 'plg_installer_folderinstaller', 'plugin', 'folderinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 2, 0
UNION ALL
SELECT 457, 'plg_installer_urlinstaller', 'plugin', 'urlinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 3, 0;
SELECT 457, 'plg_installer_urlinstaller', 'plugin', 'urlinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 3, 0
UNION ALL
SELECT 458, 'PLG_EDITORS_BUTTONS_JDRAGDROP_NAME', 'plugin', 'jdragdrop', 'editors_buttons', 0, 1, 1, 1, '{"name":"PLG_EDITORS_BUTTONS_JDRAGDROP_NAME","type":"plugin","creationDate":"August 2016","author":"Joomla! Project","copyright":"Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved.","authorEmail":"admin@joomla.org","authorUrl":"www.joomla.org","version":"3.7.0","description":"PLG_EDITORS_BUTTONS_JDRAGDROP_DESC","group":"","filename":"jdragdrop"}', '', '', '', 0, '0000-00-00 00:00:00', 0, 0);

-- Templates
INSERT INTO [#__extensions] ([extension_id], [name], [type], [element], [folder], [client_id], [enabled], [access], [protected], [manifest_cache], [params], [custom_data], [system_data], [checked_out], [checked_out_time], [ordering], [state])
Expand Down
5 changes: 1 addition & 4 deletions layouts/joomla/tinymce/textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('JPATH_BASE') or die;

$data = $displayData;

?>
<textarea
name="<?php echo $data->name; ?>"
id="<?php echo $data->id; ?>"
cols="<?php echo $data->cols; ?>"
rows="<?php echo $data->rows; ?>"
style="width: <?php echo $data->width; ?>; height: <?php echo $data->height; ?>;"
class="mce_editable"
class="<?php echo empty($data->class) ? 'mce_editable' : $data->class; ?>"
>
<?php echo $data->content; ?>
</textarea>
80 changes: 80 additions & 0 deletions media/editors/tinymce/js/tinymce-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

;(function(tinyMCE, Joomla, $, window, document){
"use strict";

// This line is for Mootools b/c
window.getSize = window.getSize || function(){return {x: $(window).width(), y: $(window).height()};};

window.jInsertEditorText = function ( text, editor ) {
tinyMCE.activeEditor.execCommand('mceInsertContent', false, text);
}

var JoomlaTinyMCE = {

/**
* Find all TinyMCE elements and initialize TinyMCE instance for each
*
* @param {HTMLElement} target Target Element where to search for the editor element
*
* @since __DEPLOY_VERSION__
*/
setupEditors: function ( target ) {
target = target || document;
var pluginOptions = Joomla.getOptions ? Joomla.getOptions('plg_editor_tinymce', {})
: (Joomla.optionsStorage.plg_editor_tinymce || {}),
$editors = $(target).find('.joomla-editor-tinymce');

for(var i = 0, l = $editors.length; i < l; i++) {
this.setupEditor($editors[i], pluginOptions);
}
},

/**
* Initialize TinyMCE editor instance
*
* @param {HTMLElement} element
* @param {Object} pluginOptions
*
* @since __DEPLOY_VERSION__
*/
setupEditor: function ( element, pluginOptions ) {
var name = element ? $(element).attr('name').replace(/\[\]|\]/g, '').split('[').pop() : 'default', // Get Editor name
tinyMCEOptions = pluginOptions ? pluginOptions.tinyMCE || {} : {},
defaultOptions = tinyMCEOptions['default'] || {},
options = tinyMCEOptions[name] ? tinyMCEOptions[name] : defaultOptions; // Check specific options by the name

// Avoid unexpected changes
options = jQuery.extend({}, options);

if (element) {
// We already have the Target, so reset the selector and assign given element as target
options.selector = null;
options.target = element;
}

if (options.setupCallbacString && !options.setup) {
options.setup = new Function('editor', options.setupCallbacString);
}

tinyMCE.init(options);
}

};

Joomla.JoomlaTinyMCE = JoomlaTinyMCE;

// Init on doomready
$(document).ready(function(){
Joomla.JoomlaTinyMCE.setupEditors();

// Init in subform field
$(document).on('subform-row-add', function(event, row){
Joomla.JoomlaTinyMCE.setupEditors(row);
})
});

}(tinyMCE, Joomla, jQuery, window, document));
1 change: 1 addition & 0 deletions media/editors/tinymce/js/tinymce-init.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e5b9b84

Please sign in to comment.