update 2.2 + precedent custom commits
Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
@@ -27,8 +27,11 @@ function wysiwyg_ckeditor_editor() {
|
||||
),
|
||||
),
|
||||
),
|
||||
'install note callback' => 'wysiwyg_ckeditor_install_note',
|
||||
'version callback' => 'wysiwyg_ckeditor_version',
|
||||
'themes callback' => 'wysiwyg_ckeditor_themes',
|
||||
'settings form callback' => 'wysiwyg_ckeditor_settings_form',
|
||||
'init callback' => 'wysiwyg_ckeditor_init',
|
||||
'settings callback' => 'wysiwyg_ckeditor_settings',
|
||||
'plugin callback' => 'wysiwyg_ckeditor_plugins',
|
||||
'plugin settings callback' => 'wysiwyg_ckeditor_plugin_settings',
|
||||
@@ -48,6 +51,13 @@ function wysiwyg_ckeditor_editor() {
|
||||
return $editor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an install note.
|
||||
*/
|
||||
function wysiwyg_ckeditor_install_note() {
|
||||
return '<p class="warning">' . t('Do NOT download the "CKEditor for Drupal" edition.') . '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect editor version.
|
||||
*
|
||||
@@ -111,6 +121,69 @@ function wysiwyg_ckeditor_themes($editor, $profile) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enhances the editor profile settings form for CKEditor.
|
||||
*
|
||||
* Adds support for CKEditor's advanced stylesSets, which are a more advanced
|
||||
* implementation and combination of block formats and font styles that allow
|
||||
* to adjust the HTML element, attributes, and CSS styles at once.
|
||||
*
|
||||
* @see http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Styles
|
||||
* @see http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.stylesSet
|
||||
*/
|
||||
function wysiwyg_ckeditor_settings_form(&$form, &$form_state) {
|
||||
if (version_compare($form_state['wysiwyg']['editor']['installed version'], '3.2.1', '>=')) {
|
||||
// Replace CSS classes element description to explain the advanced syntax.
|
||||
$form['css']['css_classes']['#description'] = t('Optionally define CSS classes for the "Font style" dropdown list.<br />Enter one class on each line in the format: !format. Example: !example<br />If left blank, CSS classes are automatically imported from loaded stylesheet(s).', array(
|
||||
'!format' => '<code>[label]=[element].[class]</code>',
|
||||
'!example' => '<code>Title=h1.title</code>',
|
||||
));
|
||||
$form['css']['css_classes']['#element_validate'][] = 'wysiwyg_ckeditor_settings_form_validate_css_classes';
|
||||
}
|
||||
else {
|
||||
// Versions below 3.2.1 do not support Font styles at all.
|
||||
$form['css']['css_classes']['#access'] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* #element_validate handler for CSS classes element altered by wysiwyg_ckeditor_settings_form().
|
||||
*/
|
||||
function wysiwyg_ckeditor_settings_form_validate_css_classes($element, &$form_state) {
|
||||
if (wysiwyg_ckeditor_settings_parse_styles($element['#value']) === FALSE) {
|
||||
form_error($element, t('The specified CSS classes are syntactically incorrect.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an initialization JavaScript for this editor library.
|
||||
*
|
||||
* @param array $editor
|
||||
* The editor library definition.
|
||||
* @param string $library
|
||||
* The library variant key from $editor['libraries'].
|
||||
* @param object $profile
|
||||
* The (first) wysiwyg editor profile.
|
||||
*
|
||||
* @return string
|
||||
* A string containing inline JavaScript to execute before the editor library
|
||||
* script is loaded.
|
||||
*/
|
||||
function wysiwyg_ckeditor_init($editor) {
|
||||
// CKEditor unconditionally searches for its library filename in SCRIPT tags
|
||||
// on the page upon loading the library in order to determine the base path to
|
||||
// itself. When JavaScript aggregation is enabled, this search fails and all
|
||||
// relative constructed paths within CKEditor are broken. The library has a
|
||||
// CKEditor.basePath property, but it is not publicly documented and thus not
|
||||
// reliable. The official documentation suggests to solve the issue through
|
||||
// the global window variable.
|
||||
// @see http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Specifying_the_Editor_Path
|
||||
$library_path = base_path() . $editor['library path'] . '/';
|
||||
return <<<EOL
|
||||
window.CKEDITOR_BASEPATH = '$library_path';
|
||||
EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return runtime editor settings for a given wysiwyg profile.
|
||||
*
|
||||
@@ -127,8 +200,7 @@ function wysiwyg_ckeditor_themes($editor, $profile) {
|
||||
*/
|
||||
function wysiwyg_ckeditor_settings($editor, $config, $theme) {
|
||||
$settings = array(
|
||||
'baseHref' => $GLOBALS['base_url'] . '/',
|
||||
'width' => '100%',
|
||||
'width' => 'auto',
|
||||
// For better compatibility with smaller textareas.
|
||||
'resize_minWidth' => 450,
|
||||
'height' => 420,
|
||||
@@ -167,7 +239,7 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) {
|
||||
$settings['contentsCss'] = reset(wysiwyg_get_css());
|
||||
}
|
||||
elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['contentsCss'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
|
||||
$settings['contentsCss'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => drupal_get_path('theme', variable_get('theme_default', NULL))));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -175,16 +247,25 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) {
|
||||
$settings['contentsCss'] = wysiwyg_get_css();
|
||||
}
|
||||
elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['contentsCss'] = explode(',', strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())));
|
||||
$settings['contentsCss'] = explode(',', strtr($config['css_path'], array('%b' => base_path(), '%t' => drupal_get_path('theme', variable_get('theme_default', NULL)))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse and define the styles set for the Styles plugin (3.2.1+).
|
||||
// @todo This should be a plugin setting, but Wysiwyg does not support
|
||||
// plugin-specific settings yet.
|
||||
if (!empty($config['buttons']['default']['Styles']) && version_compare($editor['installed version'], '3.2.1', '>=')) {
|
||||
if ($styles = wysiwyg_ckeditor_settings_parse_styles($config['css_classes'])) {
|
||||
$settings['stylesSet'] = $styles;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['language'])) {
|
||||
$settings['language'] = $config['language'];
|
||||
}
|
||||
if (isset($config['resizing'])) {
|
||||
// CKEditor tests "!== false", so ensure it is a Boolean.
|
||||
// CKEditor performs a type-agnostic comparison on this particular setting.
|
||||
$settings['resize_enabled'] = (bool) $config['resizing'];
|
||||
}
|
||||
if (isset($config['toolbar_loc'])) {
|
||||
@@ -240,6 +321,51 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) {
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses CSS classes settings string into a stylesSet JavaScript settings array.
|
||||
*
|
||||
* @param string $css_classes
|
||||
* A string containing CSS class definitions to add to the Style dropdown
|
||||
* list, separated by newlines.
|
||||
*
|
||||
* @return array|false
|
||||
* An array containing the parsed stylesSet definition, or FALSE on parse
|
||||
* error.
|
||||
*
|
||||
* @see wysiwyg_ckeditor_settings_form()
|
||||
* @see wysiwyg_ckeditor_settings_form_validate_css_classes()
|
||||
*
|
||||
* @todo This should be a plugin setting, but Wysiwyg does not support
|
||||
* plugin-specific settings yet.
|
||||
*/
|
||||
function wysiwyg_ckeditor_settings_parse_styles($css_classes) {
|
||||
$set = array();
|
||||
$input = trim($css_classes);
|
||||
if (empty($input)) {
|
||||
return $set;
|
||||
}
|
||||
// Handle both Unix and Windows line-endings.
|
||||
foreach (explode("\n", str_replace("\r", '', $input)) as $line) {
|
||||
$line = trim($line);
|
||||
// [label]=[element].[class][.[class]][...] pattern expected.
|
||||
if (!preg_match('@^.+= *[a-zA-Z0-9]+(\.[a-zA-Z0-9_ -]+)*$@', $line)) {
|
||||
return FALSE;
|
||||
}
|
||||
list($label, $selector) = explode('=', $line, 2);
|
||||
$classes = explode('.', $selector);
|
||||
$element = array_shift($classes);
|
||||
|
||||
$style = array();
|
||||
$style['name'] = trim($label);
|
||||
$style['element'] = trim($element);
|
||||
if (!empty($classes)) {
|
||||
$style['attributes']['class'] = implode(' ', array_map('trim', $classes));
|
||||
}
|
||||
$set[] = $style;
|
||||
}
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a JS settings array of native external plugins that need to be loaded separately.
|
||||
*/
|
||||
@@ -294,6 +420,7 @@ function wysiwyg_ckeditor_plugins($editor) {
|
||||
'Bold' => t('Bold'), 'Italic' => t('Italic'), 'Underline' => t('Underline'),
|
||||
'Strike' => t('Strike-through'),
|
||||
'JustifyLeft' => t('Align left'), 'JustifyCenter' => t('Align center'), 'JustifyRight' => t('Align right'), 'JustifyBlock' => t('Justify'),
|
||||
'BidiLtr' => t('Left-to-right'), 'BidiRtl' => t('Right-to-left'),
|
||||
'BulletedList' => t('Bullet list'), 'NumberedList' => t('Numbered list'),
|
||||
'Outdent' => t('Outdent'), 'Indent' => t('Indent'),
|
||||
'Undo' => t('Undo'), 'Redo' => t('Redo'),
|
||||
@@ -325,6 +452,10 @@ function wysiwyg_ckeditor_plugins($editor) {
|
||||
if (version_compare($editor['installed version'], '3.1.0.4885', '<')) {
|
||||
unset($plugins['default']['buttons']['CreateDiv']);
|
||||
}
|
||||
if (version_compare($editor['installed version'], '3.4.0.5808', '<')) {
|
||||
unset($plugins['default']['buttons']['BidiLtr']);
|
||||
unset($plugins['default']['buttons']['BidiRtl']);
|
||||
}
|
||||
if (version_compare($editor['installed version'], '3.5.0.6260', '<')) {
|
||||
unset($plugins['default']['buttons']['Iframe']);
|
||||
}
|
||||
|
102
editors/epiceditor.inc
Normal file
102
editors/epiceditor.inc
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Editor integration functions for EpicEditor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugin implementation of hook_editor().
|
||||
*/
|
||||
function wysiwyg_epiceditor_editor() {
|
||||
$editor['epiceditor'] = array(
|
||||
'title' => 'EpicEditor',
|
||||
'vendor url' => 'http://oscargodson.github.com/EpicEditor',
|
||||
'download url' => 'http://oscargodson.github.com/EpicEditor/docs/downloads/EpicEditor-v0.1.1.zip',
|
||||
'libraries' => array(
|
||||
'' => array(
|
||||
'title' => 'Minified',
|
||||
'files' => array('js/epiceditor.min.js'),
|
||||
),
|
||||
'src' => array(
|
||||
'title' => 'Source',
|
||||
'files' => array('js/epiceditor.js'),
|
||||
),
|
||||
),
|
||||
'version callback' => 'wysiwyg_epiceditor_version',
|
||||
'themes callback' => 'wysiwyg_epiceditor_themes',
|
||||
'settings callback' => 'wysiwyg_epiceditor_settings',
|
||||
'versions' => array(
|
||||
'0.1.1' => array(
|
||||
'js files' => array('epiceditor.js'),
|
||||
),
|
||||
),
|
||||
);
|
||||
return $editor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect editor version.
|
||||
*
|
||||
* @param $editor
|
||||
* An array containing editor properties as returned from hook_editor().
|
||||
*
|
||||
* @return
|
||||
* The installed editor version.
|
||||
*/
|
||||
function wysiwyg_epiceditor_version($editor) {
|
||||
$library = $editor['library path'] . '/js/epiceditor.js';
|
||||
if (!file_exists($library)) {
|
||||
return;
|
||||
}
|
||||
// @todo Do not load the entire file; use fgets() instead.
|
||||
$library = file_get_contents($library, 'r');
|
||||
$version = preg_match('%EpicEditor\.version = \'(.*)\'\;%', $library, $matches);
|
||||
if (!isset($matches[1])) {
|
||||
return;
|
||||
}
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine available editor themes or check/reset a given one.
|
||||
*
|
||||
* @param $editor
|
||||
* A processed hook_editor() array of editor properties.
|
||||
* @param $profile
|
||||
* A wysiwyg editor profile.
|
||||
*
|
||||
* @return
|
||||
* An array of theme names. The first returned name should be the default
|
||||
* theme name.
|
||||
*/
|
||||
function wysiwyg_epiceditor_themes($editor, $profile) {
|
||||
return array('epic-dark', 'epic-light');
|
||||
// @todo Use the preview themes somewhere.
|
||||
//return array('preview-dark', 'github');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return runtime editor settings for a given wysiwyg profile.
|
||||
*
|
||||
* @param $editor
|
||||
* A processed hook_editor() array of editor properties.
|
||||
* @param $config
|
||||
* An array containing wysiwyg editor profile settings.
|
||||
* @param $theme
|
||||
* The name of a theme/GUI/skin to use.
|
||||
*
|
||||
* @return
|
||||
* A settings array to be populated in
|
||||
* Drupal.settings.wysiwyg.configs.{editor}
|
||||
*/
|
||||
function wysiwyg_epiceditor_settings($editor, $config, $theme) {
|
||||
$settings = array(
|
||||
'basePath' => base_path() . $editor['library path'],
|
||||
'clientSideStorage' => FALSE,
|
||||
'theme' => $theme,
|
||||
//'preview_theme' => '',
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
|
@@ -131,8 +131,8 @@ function wysiwyg_fckeditor_settings($editor, $config, $theme) {
|
||||
if ($config['css_setting'] == 'theme') {
|
||||
$settings['EditorAreaCSS'] = implode(',', wysiwyg_get_css());
|
||||
}
|
||||
else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['EditorAreaCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
|
||||
elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['EditorAreaCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => drupal_get_path('theme', variable_get('theme_default', NULL))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,10 @@ Drupal.wysiwyg.editor.init.ckeditor = function(settings) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Register Font styles (versions 3.2.1 and above).
|
||||
if (Drupal.settings.wysiwyg.configs.ckeditor[format].stylesSet) {
|
||||
CKEDITOR.stylesSet.add(format, Drupal.settings.wysiwyg.configs.ckeditor[format].stylesSet);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,6 +38,8 @@ Drupal.wysiwyg.editor.attach.ckeditor = function(context, params, settings) {
|
||||
// Apply editor instance settings.
|
||||
CKEDITOR.config.customConfig = '';
|
||||
|
||||
var $drupalToolbar = $('#toolbar', Drupal.overlayChild ? window.parent.document : document);
|
||||
|
||||
settings.on = {
|
||||
instanceReady: function(ev) {
|
||||
var editor = ev.editor;
|
||||
@@ -125,6 +131,19 @@ Drupal.wysiwyg.editor.attach.ckeditor = function(context, params, settings) {
|
||||
|
||||
focus: function(ev) {
|
||||
Drupal.wysiwyg.activeId = ev.editor.name;
|
||||
},
|
||||
|
||||
afterCommandExec: function(ev) {
|
||||
// Fix Drupal toolbar obscuring editor toolbar in fullscreen mode.
|
||||
if (ev.data.name != 'maximize') {
|
||||
return;
|
||||
}
|
||||
if (ev.data.command.state == CKEDITOR.TRISTATE_ON) {
|
||||
$drupalToolbar.hide();
|
||||
}
|
||||
else {
|
||||
$drupalToolbar.show();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -139,16 +158,19 @@ Drupal.wysiwyg.editor.attach.ckeditor = function(context, params, settings) {
|
||||
* containing all instances or the passed in params.field instance, but
|
||||
* always return an array to simplify all detach functions.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.ckeditor = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.ckeditor = function (context, params, trigger) {
|
||||
var method = (trigger == 'serialize') ? 'updateElement' : 'destroy';
|
||||
if (typeof params != 'undefined') {
|
||||
var instance = CKEDITOR.instances[params.field];
|
||||
if (instance) {
|
||||
instance.destroy();
|
||||
instance[method]();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var instanceName in CKEDITOR.instances) {
|
||||
CKEDITOR.instances[instanceName].destroy();
|
||||
if (CKEDITOR.instances.hasOwnProperty(instanceName)) {
|
||||
CKEDITOR.instances[instanceName][method]();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -208,9 +230,18 @@ Drupal.wysiwyg.editor.instance.ckeditor = {
|
||||
// @todo Don't know if we need this yet.
|
||||
return content;
|
||||
},
|
||||
|
||||
insert: function(content) {
|
||||
content = this.prepareContent(content);
|
||||
CKEDITOR.instances[this.field].insertHtml(content);
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
CKEDITOR.instances[this.field].setData(content);
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
return CKEDITOR.instances[this.field].getData();
|
||||
}
|
||||
};
|
||||
|
||||
|
38
editors/js/epiceditor.js
Normal file
38
editors/js/epiceditor.js
Normal file
@@ -0,0 +1,38 @@
|
||||
(function($) {
|
||||
|
||||
/**
|
||||
* Attach this editor to a target element.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.attach.epiceditor = function (context, params, settings) {
|
||||
var $target = $('#' + params.field);
|
||||
var containerId = params.field + '-epiceditor';
|
||||
var defaultContent = $target.val();
|
||||
$target.hide().after('<div id="' + containerId + '" />');
|
||||
|
||||
settings.container = containerId;
|
||||
settings.file = {
|
||||
defaultContent: defaultContent
|
||||
};
|
||||
settings.theme = {
|
||||
preview: '/themes/preview/preview-dark.css',
|
||||
editor: '/themes/editor/' + settings.theme + '.css'
|
||||
}
|
||||
var editor = new EpicEditor(settings).load();
|
||||
$target.data('epiceditor', editor);
|
||||
};
|
||||
|
||||
/**
|
||||
* Detach a single or all editors.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.epiceditor = function (context, params, trigger) {
|
||||
var $target = $('#' + params.field);
|
||||
var editor = $target.data('epiceditor');
|
||||
|
||||
$target.val(editor.exportFile());
|
||||
|
||||
editor.unload(function () {
|
||||
$target.show();
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
@@ -21,7 +21,7 @@ Drupal.wysiwyg.editor.attach.fckeditor = function(context, params, settings) {
|
||||
/**
|
||||
* Detach a single or all editors.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.fckeditor = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.fckeditor = function (context, params, trigger) {
|
||||
var instances = [];
|
||||
if (typeof params != 'undefined' && typeof FCKeditorAPI != 'undefined') {
|
||||
var instance = FCKeditorAPI.GetInstance(params.field);
|
||||
@@ -36,6 +36,11 @@ Drupal.wysiwyg.editor.detach.fckeditor = function(context, params) {
|
||||
for (var instanceName in instances) {
|
||||
var instance = instances[instanceName];
|
||||
instance.UpdateLinkedField();
|
||||
if (trigger == 'serialize') {
|
||||
// The editor is not being removed from the DOM, so updating the linked
|
||||
// field is the only action necessary.
|
||||
continue;
|
||||
}
|
||||
// Since we already detach the editor and update the textarea, the submit
|
||||
// event handler needs to be removed to prevent data loss (in IE).
|
||||
// FCKeditor uses 2 nested iFrames; instance.EditingArea.Window is the
|
||||
@@ -175,6 +180,16 @@ Drupal.wysiwyg.editor.instance.fckeditor = {
|
||||
var instance = FCKeditorAPI.GetInstance(this.field);
|
||||
// @see FCK.InsertHtml(), FCK.InsertElement()
|
||||
instance.InsertHtml(content);
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
var instance = FCKeditorAPI.GetInstance(this.field);
|
||||
return instance.GetData();
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
var instance = FCKeditorAPI.GetInstance(this.field);
|
||||
instance.SetHTML(content);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -40,6 +40,19 @@ for (var setting in wysiwygSettings) {
|
||||
}
|
||||
}
|
||||
|
||||
// Fix Drupal toolbar obscuring editor toolbar in fullscreen mode.
|
||||
var oldFitWindowExecute = FCKFitWindow.prototype.Execute;
|
||||
var $drupalToolbar = window.parent.jQuery('#toolbar', Drupal.overlayChild ? window.parent.window.parent.document : window.parent.document);
|
||||
FCKFitWindow.prototype.Execute = function() {
|
||||
oldFitWindowExecute.apply(this, arguments);
|
||||
if (this.IsMaximized) {
|
||||
$drupalToolbar.hide();
|
||||
}
|
||||
else {
|
||||
$drupalToolbar.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize this editor instance.
|
||||
*/
|
||||
|
@@ -11,15 +11,33 @@ Drupal.wysiwyg.editor.attach.jwysiwyg = function(context, params, settings) {
|
||||
/**
|
||||
* Detach a single or all editors.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.jwysiwyg = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.jwysiwyg = function (context, params, trigger) {
|
||||
var $field = $('#' + params.field);
|
||||
var editor = $field.data('wysiwyg');
|
||||
if (typeof editor != 'undefined') {
|
||||
editor.saveContent();
|
||||
editor.element.remove();
|
||||
if (trigger != 'serialize') {
|
||||
editor.element.remove();
|
||||
}
|
||||
}
|
||||
$field.removeData('wysiwyg');
|
||||
$field.show();
|
||||
if (trigger != 'serialize') {
|
||||
$field.show();
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.wysiwyg.editor.instance.jwysiwyg = {
|
||||
insert: function (content) {
|
||||
$('#' + this.field).wysiwyg('insertHtml', content);
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
$('#' + this.field).wysiwyg('setContent', content);
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
return $('#' + this.field).wysiwyg('getContent');
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -17,7 +17,10 @@ Drupal.wysiwyg.editor.attach.markitup = function(context, params, settings) {
|
||||
/**
|
||||
* Detach a single or all editors.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.markitup = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.markitup = function (context, params, trigger) {
|
||||
if (trigger == 'serialize') {
|
||||
return;
|
||||
}
|
||||
if (typeof params != 'undefined') {
|
||||
$('#' + params.field, context).markItUpRemove();
|
||||
}
|
||||
@@ -26,4 +29,18 @@ Drupal.wysiwyg.editor.detach.markitup = function(context, params) {
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.wysiwyg.editor.instance.markitup = {
|
||||
insert: function (content) {
|
||||
$.markItUp({ replaceWith: content });
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
$('#' + this.field).val(content);
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
return $('#' + this.field).val();
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -30,12 +30,17 @@ Drupal.wysiwyg.editor.attach.nicedit = function(context, params, settings) {
|
||||
*
|
||||
* See Drupal.wysiwyg.editor.detach.none() for a full description of this hook.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.nicedit = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.nicedit = function (context, params, trigger) {
|
||||
if (typeof params != 'undefined') {
|
||||
var instance = nicEditors.findEditor(params.field);
|
||||
if (instance) {
|
||||
instance.ne.removeInstance(params.field);
|
||||
instance.ne.removePanel();
|
||||
if (trigger == 'serialize') {
|
||||
instance.saveContent();
|
||||
}
|
||||
else {
|
||||
instance.ne.removeInstance(params.field);
|
||||
instance.ne.removePanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -43,10 +48,17 @@ Drupal.wysiwyg.editor.detach.nicedit = function(context, params) {
|
||||
// Save contents of all editors back into textareas.
|
||||
var instances = nicEditors.editors[e].nicInstances;
|
||||
for (var i = 0; i < instances.length; i++) {
|
||||
instances[i].remove();
|
||||
if (trigger == 'serialize') {
|
||||
instances[i].saveContent();
|
||||
}
|
||||
else {
|
||||
instances[i].remove();
|
||||
}
|
||||
}
|
||||
// Remove all editor instances.
|
||||
nicEditors.editors[e].nicInstances = [];
|
||||
if (trigger != 'serialize') {
|
||||
nicEditors.editors[e].nicInstances = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -62,7 +74,7 @@ Drupal.wysiwyg.editor.instance.nicedit = {
|
||||
// IE.
|
||||
if (document.selection) {
|
||||
editingArea.focus();
|
||||
sel.createRange().text = content;
|
||||
sel.createRange().pasteHTML(content);
|
||||
}
|
||||
else {
|
||||
// Convert selection to a range.
|
||||
@@ -89,6 +101,14 @@ Drupal.wysiwyg.editor.instance.nicedit = {
|
||||
// Only fragment children are inserted.
|
||||
range.insertNode(fragment);
|
||||
}
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
nicEditors.findEditor(this.field).setContent(content);
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
return nicEditors.findEditor(this.field).getContent();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -17,7 +17,7 @@ Drupal.wysiwyg.editor.attach.none = function(context, params, settings) {
|
||||
if (params.resizable) {
|
||||
var $wrapper = $('#' + params.field).parents('.form-textarea-wrapper:first');
|
||||
$wrapper.addClass('resizable');
|
||||
if (Drupal.behaviors.textarea.attach) {
|
||||
if (Drupal.behaviors.textarea) {
|
||||
Drupal.behaviors.textarea.attach();
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,9 @@ Drupal.wysiwyg.editor.attach.none = function(context, params, settings) {
|
||||
/**
|
||||
* Detach a single or all editors.
|
||||
*
|
||||
* The editor syncs its contents back to the original field before its instance
|
||||
* is removed.
|
||||
*
|
||||
* @param context
|
||||
* A DOM element, supplied by Drupal.attachBehaviors().
|
||||
* @param params
|
||||
@@ -33,9 +36,18 @@ Drupal.wysiwyg.editor.attach.none = function(context, params, settings) {
|
||||
* only the editor instance in params.field should be detached. Otherwise,
|
||||
* all editors should be detached and saved, so they can be submitted in
|
||||
* AJAX/AHAH applications.
|
||||
* @param trigger
|
||||
* A string describing why the editor is being detached.
|
||||
* Possible triggers are:
|
||||
* - unload: (default) Another or no editor is about to take its place.
|
||||
* - move: Currently expected to produce the same result as unload.
|
||||
* - serialize: The form is about to be serialized before an AJAX request or
|
||||
* a normal form submission. If possible, perform a quick detach and leave
|
||||
* the editor's GUI elements in place to avoid flashes or scrolling issues.
|
||||
* @see Drupal.detachBehaviors
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.none = function(context, params) {
|
||||
if (typeof params != 'undefined') {
|
||||
Drupal.wysiwyg.editor.detach.none = function (context, params, trigger) {
|
||||
if (typeof params != 'undefined' && (trigger != 'serialize')) {
|
||||
var $wrapper = $('#' + params.field).parents('.form-textarea-wrapper:first');
|
||||
$wrapper.removeOnce('textarea').removeClass('.resizable-textarea')
|
||||
.find('.grippie').remove();
|
||||
@@ -65,6 +77,14 @@ Drupal.wysiwyg.editor.instance.none = {
|
||||
else {
|
||||
editor.value += content;
|
||||
}
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
$('#' + this.field).val(content);
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
return $('#' + this.field).val();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -23,6 +23,19 @@ WYSIWYG.getEditor = function (n) {
|
||||
|
||||
(function($) {
|
||||
|
||||
// Fix Drupal toolbar obscuring editor toolbar in fullscreen mode.
|
||||
var oldMaximize = WYSIWYG.maximize;
|
||||
WYSIWYG.maximize = function (n) {
|
||||
var $drupalToolbar = $('#toolbar', Drupal.overlayChild ? window.parent.document : document);
|
||||
oldMaximize.apply(this, arguments);
|
||||
if (this.maximized[n]) {
|
||||
$drupalToolbar.hide();
|
||||
}
|
||||
else {
|
||||
$drupalToolbar.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach this editor to a target element.
|
||||
*/
|
||||
@@ -45,24 +58,84 @@ Drupal.wysiwyg.editor.attach.openwysiwyg = function(context, params, settings) {
|
||||
/**
|
||||
* Detach a single or all editors.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.openwysiwyg = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.openwysiwyg = function (context, params, trigger) {
|
||||
if (typeof params != 'undefined') {
|
||||
var instance = WYSIWYG.config[params.field];
|
||||
if (typeof instance != 'undefined') {
|
||||
WYSIWYG.updateTextArea(params.field);
|
||||
jQuery('#wysiwyg_div_' + params.field).remove();
|
||||
delete instance;
|
||||
if (trigger != 'serialize') {
|
||||
jQuery('#wysiwyg_div_' + params.field).remove();
|
||||
delete instance;
|
||||
}
|
||||
}
|
||||
if (trigger != 'serialize') {
|
||||
jQuery('#' + params.field).show();
|
||||
}
|
||||
jQuery('#' + params.field).show();
|
||||
}
|
||||
else {
|
||||
jQuery.each(WYSIWYG.config, function(field) {
|
||||
WYSIWYG.updateTextArea(field);
|
||||
jQuery('#wysiwyg_div_' + field).remove();
|
||||
delete this;
|
||||
jQuery('#' + field).show();
|
||||
if (trigger != 'serialize') {
|
||||
jQuery('#wysiwyg_div_' + field).remove();
|
||||
delete this;
|
||||
jQuery('#' + field).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Instance methods for openWYSIWYG.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.instance.openwysiwyg = {
|
||||
insert: function (content) {
|
||||
// If IE has dropped focus content will be inserted at the top of the page.
|
||||
$('#wysiwyg' + this.field).contents().find('body').focus();
|
||||
WYSIWYG.insertHTML(content, this.field);
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
// Based on openWYSIWYG's _generate() method.
|
||||
var doc = WYSIWYG.getEditorWindow(this.field).document;
|
||||
if (WYSIWYG.config[this.field].ReplaceLineBreaks) {
|
||||
content = content.replace(/\n\r|\n/ig, '<br />');
|
||||
}
|
||||
if (WYSIWYG.viewTextMode[this.field]) {
|
||||
var html = document.createTextNode(content);
|
||||
doc.body.innerHTML = '';
|
||||
doc.body.appendChild(html);
|
||||
}
|
||||
else {
|
||||
doc.open();
|
||||
doc.write(content);
|
||||
doc.close();
|
||||
}
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
// Based on openWYSIWYG's updateTextarea() method.
|
||||
var content = '';
|
||||
var doc = WYSIWYG.getEditorWindow(this.field).document;
|
||||
if (WYSIWYG.viewTextMode[this.field]) {
|
||||
if (WYSIWYG_Core.isMSIE) {
|
||||
content = doc.body.innerText;
|
||||
}
|
||||
else {
|
||||
var range = doc.body.ownerDocument.createRange();
|
||||
range.selectNodeContents(doc.body);
|
||||
content = range.toString();
|
||||
}
|
||||
}
|
||||
else {
|
||||
content = doc.body.innerHTML;
|
||||
}
|
||||
content = WYSIWYG.stripURLPath(this.field, content);
|
||||
content = WYSIWYG_Core.replaceRGBWithHexColor(content);
|
||||
if (WYSIWYG.config[this.field].ReplaceLineBreaks) {
|
||||
content = content.replace(/(\r\n)|(\n)/ig, '');
|
||||
}
|
||||
return content;
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -10,18 +10,8 @@
|
||||
* An object containing editor settings for each input format.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.init.tinymce = function(settings) {
|
||||
// If JS compression is enabled, TinyMCE is unable to autodetect its global
|
||||
// settinge, hence we need to define them manually.
|
||||
// @todo Move global library settings somewhere else.
|
||||
tinyMCE.baseURL = settings.global.editorBasePath;
|
||||
tinyMCE.srcMode = (settings.global.execMode == 'src' ? '_src' : '');
|
||||
tinyMCE.gzipMode = (settings.global.execMode == 'gzip');
|
||||
|
||||
// Initialize editor configurations.
|
||||
for (var format in settings) {
|
||||
if (format == 'global') {
|
||||
continue;
|
||||
}
|
||||
tinyMCE.init(settings[format]);
|
||||
if (Drupal.settings.wysiwyg.plugins[format]) {
|
||||
// Load native external plugins.
|
||||
@@ -67,7 +57,7 @@ Drupal.wysiwyg.editor.attach.tinymce = function(context, params, settings) {
|
||||
*
|
||||
* See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.tinymce = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.tinymce = function (context, params, trigger) {
|
||||
if (typeof params != 'undefined') {
|
||||
tinyMCE.removeMCEControl(tinyMCE.getEditorId(params.field));
|
||||
$('#' + params.field).removeAttr('style');
|
||||
|
@@ -11,19 +11,21 @@
|
||||
* An object containing editor settings for each input format.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.init.tinymce = function(settings) {
|
||||
// If JS compression is enabled, TinyMCE is unable to autodetect its global
|
||||
// settinge, hence we need to define them manually.
|
||||
// @todo Move global library settings somewhere else.
|
||||
tinyMCE.baseURL = settings.global.editorBasePath;
|
||||
tinyMCE.srcMode = (settings.global.execMode == 'src' ? '_src' : '');
|
||||
tinyMCE.gzipMode = (settings.global.execMode == 'gzip');
|
||||
// Fix Drupal toolbar obscuring editor toolbar in fullscreen mode.
|
||||
var $drupalToolbar = $('#toolbar', Drupal.overlayChild ? window.parent.document : document);
|
||||
tinyMCE.onAddEditor.add(function (mgr, ed) {
|
||||
if (ed.id == 'mce_fullscreen') {
|
||||
$drupalToolbar.hide();
|
||||
}
|
||||
});
|
||||
tinyMCE.onRemoveEditor.add(function (mgr, ed) {
|
||||
if (ed.id == 'mce_fullscreen') {
|
||||
$drupalToolbar.show();
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize editor configurations.
|
||||
for (var format in settings) {
|
||||
if (format == 'global') {
|
||||
continue;
|
||||
};
|
||||
tinyMCE.init(settings[format]);
|
||||
if (Drupal.settings.wysiwyg.plugins[format]) {
|
||||
// Load native external plugins.
|
||||
// Array syntax required; 'native' is a predefined token in JavaScript.
|
||||
@@ -50,6 +52,8 @@ Drupal.wysiwyg.editor.attach.tinymce = function(context, params, settings) {
|
||||
ed.onEvent.add(function(ed, e) {
|
||||
Drupal.wysiwyg.activeId = ed.id;
|
||||
});
|
||||
// Indicate that the DOM has been loaded (in case of Ajax).
|
||||
tinymce.dom.Event.domLoaded = true;
|
||||
// Make toolbar buttons wrappable (required for IE).
|
||||
ed.onPostRender.add(function (ed) {
|
||||
var $toolbar = $('<div class="wysiwygToolbar"></div>');
|
||||
@@ -79,20 +83,24 @@ Drupal.wysiwyg.editor.attach.tinymce = function(context, params, settings) {
|
||||
*
|
||||
* See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.tinymce = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.tinymce = function (context, params, trigger) {
|
||||
if (typeof params != 'undefined') {
|
||||
var instance = tinyMCE.get(params.field);
|
||||
if (instance) {
|
||||
instance.save();
|
||||
instance.remove();
|
||||
if (trigger != 'serialize') {
|
||||
instance.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Save contents of all editors back into textareas.
|
||||
tinyMCE.triggerSave();
|
||||
// Remove all editor instances.
|
||||
for (var instance in tinyMCE.editors) {
|
||||
tinyMCE.editors[instance].remove();
|
||||
if (trigger != 'serialize') {
|
||||
// Remove all editor instances.
|
||||
for (var instance in tinyMCE.editors) {
|
||||
tinyMCE.editors[instance].remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -138,16 +146,18 @@ Drupal.wysiwyg.editor.instance.tinymce = {
|
||||
|
||||
// Attach: Replace plain text with HTML representations.
|
||||
ed.onBeforeSetContent.add(function(ed, data) {
|
||||
var editorId = (ed.id == 'mce_fullscreen' ? ed.getParam('fullscreen_editor_id') : ed.id);
|
||||
if (typeof Drupal.wysiwyg.plugins[plugin].attach == 'function') {
|
||||
data.content = Drupal.wysiwyg.plugins[plugin].attach(data.content, pluginSettings, ed.id);
|
||||
data.content = Drupal.wysiwyg.plugins[plugin].attach(data.content, pluginSettings, editorId);
|
||||
data.content = Drupal.wysiwyg.editor.instance.tinymce.prepareContent(data.content);
|
||||
}
|
||||
});
|
||||
|
||||
// Detach: Replace HTML representations with plain text.
|
||||
ed.onGetContent.add(function(ed, data) {
|
||||
var editorId = (ed.id == 'mce_fullscreen' ? ed.getParam('fullscreen_editor_id') : ed.id);
|
||||
if (typeof Drupal.wysiwyg.plugins[plugin].detach == 'function') {
|
||||
data.content = Drupal.wysiwyg.plugins[plugin].detach(data.content, pluginSettings, ed.id);
|
||||
data.content = Drupal.wysiwyg.plugins[plugin].detach(data.content, pluginSettings, editorId);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -175,7 +185,7 @@ Drupal.wysiwyg.editor.instance.tinymce = {
|
||||
},
|
||||
|
||||
openDialog: function(dialog, params) {
|
||||
var instanceId = this.isFullscreen() ? 'mce_fullscreen' : this.field;
|
||||
var instanceId = this.getInstanceId();
|
||||
var editor = tinyMCE.get(instanceId);
|
||||
editor.windowManager.open({
|
||||
file: dialog.url + '/' + instanceId,
|
||||
@@ -186,8 +196,7 @@ Drupal.wysiwyg.editor.instance.tinymce = {
|
||||
},
|
||||
|
||||
closeDialog: function(dialog) {
|
||||
var instanceId = this.isFullscreen() ? 'mce_fullscreen' : this.field;
|
||||
var editor = tinyMCE.get(instanceId);
|
||||
var editor = tinyMCE.get(this.getInstanceId());
|
||||
editor.windowManager.close(dialog);
|
||||
},
|
||||
|
||||
@@ -222,13 +231,25 @@ Drupal.wysiwyg.editor.instance.tinymce = {
|
||||
|
||||
insert: function(content) {
|
||||
content = this.prepareContent(content);
|
||||
var instanceId = this.isFullscreen() ? 'mce_fullscreen' : this.field;
|
||||
tinyMCE.execInstanceCommand(instanceId, 'mceInsertContent', false, content);
|
||||
tinyMCE.execInstanceCommand(this.getInstanceId(), 'mceInsertContent', false, content);
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
content = this.prepareContent(content);
|
||||
tinyMCE.execInstanceCommand(this.getInstanceId(), 'mceSetContent', false, content);
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
return tinyMCE.get(this.getInstanceId()).getContent();
|
||||
},
|
||||
|
||||
isFullscreen: function() {
|
||||
// TinyMCE creates a completely new instance for fullscreen mode.
|
||||
return tinyMCE.activeEditor.id == 'mce_fullscreen' && tinyMCE.activeEditor.getParam('fullscreen_editor_id') == this.field;
|
||||
},
|
||||
|
||||
getInstanceId: function () {
|
||||
return this.isFullscreen() ? 'mce_fullscreen' : this.field;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -80,39 +80,28 @@ Drupal.wysiwyg.editor.attach.whizzywig = function(context, params, settings) {
|
||||
// Attach editor.
|
||||
makeWhizzyWig(params.field, (settings.buttons ? settings.buttons : 'all'));
|
||||
// Whizzywig fails to detect and set initial textarea contents.
|
||||
var instance = $('#whizzy' + params.field).get(0);
|
||||
if (instance) {
|
||||
instance.contentWindow.document.body.innerHTML = tidyD($field.val());
|
||||
}
|
||||
$('#whizzy' + params.field).contents().find('body').html(tidyD($field.val()));
|
||||
};
|
||||
|
||||
/**
|
||||
* Detach a single or all editors.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.whizzywig = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.whizzywig = function (context, params, trigger) {
|
||||
var detach = function (index) {
|
||||
var id = whizzies[index];
|
||||
var instance = $('#whizzy' + id).get(0);
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
var editingArea = instance.contentWindow.document;
|
||||
var $field = $('#' + id);
|
||||
// Whizzywig shows the original textarea in source mode.
|
||||
if ($field.css('display') == 'block') {
|
||||
editingArea.body.innerHTML = $field.val();
|
||||
}
|
||||
var id = whizzies[index], $field = $('#' + id), instance = Drupal.wysiwyg.instances[id];
|
||||
|
||||
// Save contents of editor back into textarea.
|
||||
$field.val(tidyH(editingArea));
|
||||
$field.val(instance.getContent());
|
||||
// If the editor is just being serialized (not detached), our work is done.
|
||||
if (trigger == 'serialize') {
|
||||
return;
|
||||
}
|
||||
// Remove editor instance.
|
||||
$('#' + id + '-whizzywig').remove();
|
||||
whizzies.splice(index, 1);
|
||||
|
||||
// Restore original textarea styling.
|
||||
var originalValues = Drupal.wysiwyg.instances[id];
|
||||
$field.removeAttr('style');
|
||||
$field.attr('style', originalValues.originalStyle);
|
||||
$field.removeAttr('style').attr('style', instance.originalStyle);
|
||||
};
|
||||
|
||||
if (typeof params != 'undefined') {
|
||||
@@ -130,4 +119,37 @@ Drupal.wysiwyg.editor.detach.whizzywig = function(context, params) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Instance methods for Whizzywig.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.instance.whizzywig = {
|
||||
insert: function (content) {
|
||||
// Whizzywig executes any string beginning with 'js:'.
|
||||
insHTML(content.replace(/^js:/, 'js:'));
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
// Whizzywig shows the original textarea in source mode.
|
||||
if ($field.css('display') == 'block') {
|
||||
$('#' + this.field).val(content);
|
||||
}
|
||||
else {
|
||||
var doc = $('#whizzy' + this.field).contents()[0];
|
||||
doc.open();
|
||||
doc.write(content);
|
||||
doc.close();
|
||||
}
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
// Whizzywig's tidyH() expects a document node. Clone the editing iframe's
|
||||
// document so tidyH() won't mess with it if this gets called while editing.
|
||||
var clone = $($('#whizzy' + this.field).contents()[0].documentElement).clone()[0].ownerDocument;
|
||||
// Whizzywig shows the original textarea in source mode so update the body.
|
||||
if ($field.css('display') == 'block') {
|
||||
clone.body.innerHTML = $('#' + this.field).val();
|
||||
}
|
||||
return tidyH(clone);
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
|
@@ -29,42 +29,31 @@ Drupal.wysiwyg.editor.attach.whizzywig = function(context, params, settings) {
|
||||
// Attach editor.
|
||||
makeWhizzyWig(params.field, (settings.buttons ? settings.buttons : 'all'));
|
||||
// Whizzywig fails to detect and set initial textarea contents.
|
||||
var instance = $('#whizzy' + params.field).get(0);
|
||||
if (instance) {
|
||||
instance.contentWindow.document.body.innerHTML = tidyD($field.val());
|
||||
}
|
||||
$('#whizzy' + params.field).contents().find('body').html(tidyD($field.val()));
|
||||
};
|
||||
|
||||
/**
|
||||
* Detach a single or all editors.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.whizzywig = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.whizzywig = function (context, params, trigger) {
|
||||
var detach = function (index) {
|
||||
var id = whizzies[index];
|
||||
var instance = $('#whizzy' + id).get(0);
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
var editingArea = instance.contentWindow.document;
|
||||
var $field = $('#' + id);
|
||||
// Whizzywig shows the original textarea in source mode.
|
||||
if ($field.css('display') == 'block') {
|
||||
editingArea.body.innerHTML = $field.val();
|
||||
}
|
||||
var id = whizzies[index], $field = $('#' + id), instance = Drupal.wysiwyg.instances[id];
|
||||
|
||||
// Save contents of editor back into textarea.
|
||||
$field.val(tidyH(editingArea));
|
||||
$field.val(instance.getContent());
|
||||
// If the editor is just being serialized (not detached), our work is done.
|
||||
if (trigger == 'serialize') {
|
||||
return;
|
||||
}
|
||||
// Move original textarea back to its previous location.
|
||||
$container = $('#CONTAINER' + id);
|
||||
var $container = $('#CONTAINER' + id);
|
||||
$field.insertBefore($container);
|
||||
// Remove editor instance.
|
||||
$container.remove();
|
||||
whizzies.splice(index, 1);
|
||||
|
||||
// Restore original textarea styling.
|
||||
var originalValues = Drupal.wysiwyg.instances[id];
|
||||
$field.removeAttr('style');
|
||||
$field.attr('style', originalValues.originalStyle);
|
||||
$field.removeAttr('style').attr('style', instance.originalStyle);
|
||||
}
|
||||
|
||||
if (typeof params != 'undefined') {
|
||||
@@ -82,4 +71,37 @@ Drupal.wysiwyg.editor.detach.whizzywig = function(context, params) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Instance methods for Whizzywig.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.instance.whizzywig = {
|
||||
insert: function (content) {
|
||||
// Whizzywig executes any string beginning with 'js:'.
|
||||
insHTML(content.replace(/^js:/, 'js:'));
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
// Whizzywig shows the original textarea in source mode.
|
||||
if ($field.css('display') == 'block') {
|
||||
$('#' + this.field).val(content);
|
||||
}
|
||||
else {
|
||||
var doc = $('#whizzy' + this.field).contents()[0];
|
||||
doc.open();
|
||||
doc.write(content);
|
||||
doc.close();
|
||||
}
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
// Whizzywig's tidyH() expects a document node. Clone the editing iframe's
|
||||
// document so tidyH() won't mess with it if this gets called while editing.
|
||||
var clone = $($('#whizzy' + this.field).contents()[0].documentElement).clone()[0].ownerDocument;
|
||||
// Whizzywig shows the original textarea in source mode so update the body.
|
||||
if ($field.css('display') == 'block') {
|
||||
clone.body.innerHTML = $('#' + this.field).val();
|
||||
}
|
||||
return tidyH(clone);
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
|
@@ -71,41 +71,28 @@ Drupal.wysiwyg.editor.attach.whizzywig = function(context, params, settings) {
|
||||
// Attach editor.
|
||||
makeWhizzyWig(params.field, (settings.buttons ? settings.buttons : 'all'));
|
||||
// Whizzywig fails to detect and set initial textarea contents.
|
||||
var instance = $('#whizzy' + params.field).get(0);
|
||||
if (instance) {
|
||||
instance.contentWindow.document.body.innerHTML = tidyD($field.val());
|
||||
}
|
||||
$('#whizzy' + params.field).contents().find('body').html(tidyD($field.val()));
|
||||
};
|
||||
|
||||
/**
|
||||
* Detach a single or all editors.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.whizzywig = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.whizzywig = function (context, params, trigger) {
|
||||
var detach = function (index) {
|
||||
var id = whizzies[index];
|
||||
var instance = $('#whizzy' + id).get(0);
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
var body = instance.contentWindow.document.body;
|
||||
var $field = $('#' + id);
|
||||
// Whizzywig shows the original textarea in source mode.
|
||||
if ($field.css('display') == 'block') {
|
||||
body.innerHTML = $field.val();
|
||||
}
|
||||
body.innerHTML = tidyH(body.innerHTML);
|
||||
var id = whizzies[index], $field = $('#' + id), instance = Drupal.wysiwyg.instances[id];
|
||||
|
||||
// Save contents of editor back into textarea.
|
||||
$field.val(window.get_xhtml ? get_xhtml(body) : body.innerHTML);
|
||||
$field.val($field.val().replace(location.href + '#', '#'));
|
||||
$field.val(instance.getContent());
|
||||
// If the editor is just being serialized (not detached), our work is done.
|
||||
if (trigger == 'serialize') {
|
||||
return;
|
||||
}
|
||||
// Remove editor instance.
|
||||
$('#' + id + '-whizzywig').remove();
|
||||
whizzies.splice(index, 1);
|
||||
|
||||
// Restore original textarea styling.
|
||||
var originalValues = Drupal.wysiwyg.instances[id];
|
||||
$field.removeAttr('style');
|
||||
$field.attr('style', originalValues.originalStyle);
|
||||
$field.removeAttr('style').attr('style', instance.originalStyle);
|
||||
};
|
||||
|
||||
if (typeof params != 'undefined') {
|
||||
@@ -123,4 +110,45 @@ Drupal.wysiwyg.editor.detach.whizzywig = function(context, params) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Instance methods for Whizzywig.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.instance.whizzywig = {
|
||||
insert: function (content) {
|
||||
// Whizzywig executes any string beginning with 'js:'.
|
||||
insHTML(content.replace(/^js:/, 'js:'));
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
var $field = $('#' + this.field);
|
||||
// Whizzywig shows the original textarea in source mode.
|
||||
if ($field.css('display') == 'block') {
|
||||
$field.val(content);
|
||||
}
|
||||
else {
|
||||
var doc = $('#whizzy' + this.field).contents()[0];
|
||||
doc.open();
|
||||
doc.write(content);
|
||||
doc.close();
|
||||
}
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
var $field = $('#' + this.field),
|
||||
// Whizzywig shows the original textarea in source mode.
|
||||
content = ($field.css('display') == 'block' ?
|
||||
$field.val() : $('#whizzy' + this.field).contents().find('body').html()
|
||||
);
|
||||
|
||||
content = tidyH(content);
|
||||
// Whizzywig's get_xhtml() addon, if defined, expects a DOM node.
|
||||
if ($.isFunction(window.get_xhtml)) {
|
||||
var pre = document.createElement('pre');
|
||||
pre.innerHTML = content;
|
||||
content = get_xhtml(pre);
|
||||
}
|
||||
return content.replace(location.href + '#', '#');
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -19,37 +19,55 @@ Drupal.wysiwyg.editor.attach.wymeditor = function (context, params, settings) {
|
||||
/**
|
||||
* Detach a single or all editors.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.wymeditor = function (context, params) {
|
||||
Drupal.wysiwyg.editor.detach.wymeditor = function (context, params, trigger) {
|
||||
if (typeof params != 'undefined') {
|
||||
var $field = $('#' + params.field);
|
||||
var index = $field.data(WYMeditor.WYM_INDEX);
|
||||
if (typeof index != 'undefined') {
|
||||
var instance = WYMeditor.INSTANCES[index];
|
||||
instance.update();
|
||||
$(instance._box).remove();
|
||||
$(instance._element).show();
|
||||
delete instance;
|
||||
if (trigger != 'serialize') {
|
||||
$(instance._box).remove();
|
||||
$(instance._element).show();
|
||||
delete instance;
|
||||
}
|
||||
}
|
||||
if (trigger != 'serialize') {
|
||||
$field.show();
|
||||
}
|
||||
$field.show();
|
||||
}
|
||||
else {
|
||||
jQuery.each(WYMeditor.INSTANCES, function () {
|
||||
this.update();
|
||||
$(this._box).remove();
|
||||
$(this._element).show();
|
||||
delete this;
|
||||
if (trigger != 'serialize') {
|
||||
$(this._box).remove();
|
||||
$(this._element).show();
|
||||
delete this;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.wysiwyg.editor.instance.wymeditor = {
|
||||
insert: function (content) {
|
||||
this.getInstance().insert(content);
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
this.getInstance().html(content);
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
return this.getInstance().xhtml();
|
||||
},
|
||||
|
||||
getInstance: function () {
|
||||
var $field = $('#' + this.field);
|
||||
var index = $field.data(WYMeditor.WYM_INDEX);
|
||||
if (typeof index != 'undefined') {
|
||||
var instance = WYMeditor.INSTANCES[index];
|
||||
instance.insert(content);
|
||||
return WYMeditor.INSTANCES[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
118
editors/js/yui.js
vendored
118
editors/js/yui.js
vendored
@@ -2,12 +2,70 @@
|
||||
|
||||
/**
|
||||
* Attach this editor to a target element.
|
||||
*
|
||||
* Since buttons must be added before the editor is rendered, we add plugins
|
||||
* buttons on attach event rather than in init.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.attach.yui = function(context, params, settings) {
|
||||
// Apply theme.
|
||||
$('#' + params.field).parent().addClass('yui-skin-' + settings.theme);
|
||||
|
||||
// Load plugins stylesheet.
|
||||
for (var plugin in Drupal.settings.wysiwyg.plugins[params.format].drupal) {
|
||||
settings.extracss += settings.extracss+' @import "'+Drupal.settings.wysiwyg.plugins[params.format].drupal[plugin].css+'"; ';
|
||||
}
|
||||
|
||||
// Attach editor.
|
||||
var editor = new YAHOO.widget.Editor(params.field, settings);
|
||||
|
||||
editor.on('toolbarLoaded', function() {
|
||||
// Load Drupal plugins.
|
||||
for (var plugin in Drupal.settings.wysiwyg.plugins[params.format].drupal) {
|
||||
Drupal.wysiwyg.instances[params.field].addPlugin(plugin, Drupal.settings.wysiwyg.plugins[params.format].drupal[plugin], Drupal.settings.wysiwyg.plugins.drupal[plugin]);
|
||||
}
|
||||
});
|
||||
|
||||
// Allow plugins to act on setEditorHTML.
|
||||
var oldSetEditorHTML = editor.setEditorHTML;
|
||||
editor.setEditorHTML = function (content) {
|
||||
for (var plugin in Drupal.settings.wysiwyg.plugins[params.format].drupal) {
|
||||
var pluginSettings = Drupal.settings.wysiwyg.plugins.drupal[plugin];
|
||||
if (typeof Drupal.wysiwyg.plugins[plugin].attach == 'function') {
|
||||
content = Drupal.wysiwyg.plugins[plugin].attach(content, pluginSettings, params.field);
|
||||
content = Drupal.wysiwyg.instances[params.field].prepareContent(content);
|
||||
}
|
||||
}
|
||||
oldSetEditorHTML.call(this, content);
|
||||
};
|
||||
|
||||
// Allow plugins to act on getEditorHTML.
|
||||
var oldGetEditorHTML = editor.getEditorHTML;
|
||||
editor.getEditorHTML = function () {
|
||||
var content = oldGetEditorHTML.call(this);
|
||||
for (var plugin in Drupal.settings.wysiwyg.plugins[params.format].drupal) {
|
||||
var pluginSettings = Drupal.settings.wysiwyg.plugins.drupal[plugin];
|
||||
if (typeof Drupal.wysiwyg.plugins[plugin].detach == 'function') {
|
||||
content = Drupal.wysiwyg.plugins[plugin].detach(content, pluginSettings, params.field);
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
// Reload the editor contents to give Drupal plugins a chance to act.
|
||||
editor.on('editorContentLoaded', function (e) {
|
||||
e.target.setEditorHTML(oldGetEditorHTML.call(e.target));
|
||||
});
|
||||
|
||||
editor.on('afterNodeChange', function (e) {
|
||||
for (var plugin in Drupal.settings.wysiwyg.plugins[params.format].drupal) {
|
||||
if (typeof Drupal.wysiwyg.plugins[plugin].isNode == 'function') {
|
||||
if (Drupal.wysiwyg.plugins[plugin].isNode(e.target._getSelectedElement())) {
|
||||
this.toolbar.selectButton(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.render();
|
||||
};
|
||||
|
||||
@@ -16,20 +74,72 @@ Drupal.wysiwyg.editor.attach.yui = function(context, params, settings) {
|
||||
*
|
||||
* See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.detach.yui = function(context, params) {
|
||||
Drupal.wysiwyg.editor.detach.yui = function (context, params, trigger) {
|
||||
var method = (trigger && trigger == 'serialize') ? 'saveHTML' : 'destroy';
|
||||
if (typeof params != 'undefined') {
|
||||
var instance = YAHOO.widget.EditorInfo.getEditorById(params.field);
|
||||
var instance = YAHOO.widget.EditorInfo._instances[params.field];
|
||||
if (instance) {
|
||||
instance.destroy();
|
||||
instance[method]();
|
||||
if (method == 'destroy') {
|
||||
delete YAHOO.widget.EditorInfo._instances[params.field];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var e in YAHOO.widget.EditorInfo._instances) {
|
||||
// Save contents of all editors back into textareas.
|
||||
var instance = YAHOO.widget.EditorInfo._instances[e];
|
||||
instance.destroy();
|
||||
instance[method]();
|
||||
if (method == 'destroy') {
|
||||
delete YAHOO.widget.EditorInfo._instances[e];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Instance methods for YUI Editor.
|
||||
*/
|
||||
Drupal.wysiwyg.editor.instance.yui = {
|
||||
addPlugin: function (plugin, settings, pluginSettings) {
|
||||
if (typeof Drupal.wysiwyg.plugins[plugin] != 'object') {
|
||||
return;
|
||||
}
|
||||
var editor = YAHOO.widget.EditorInfo.getEditorById(this.field);
|
||||
var button = editor.toolbar.getButtonByValue(plugin);
|
||||
$(button._button).parent().css('background', 'transparent url(' + settings.icon + ') no-repeat center');
|
||||
// 'this' will reference the toolbar while inside the event handler.
|
||||
var instanceId = this.field;
|
||||
editor.toolbar.on(plugin + 'Click', function (e) {
|
||||
var selectedElement = editor._getSelectedElement();
|
||||
// @todo Using .html() will cause XTHML vs HTML conflicts.
|
||||
var data = {
|
||||
format: 'html',
|
||||
node: selectedElement,
|
||||
content: $(selectedElement).html()
|
||||
};
|
||||
Drupal.wysiwyg.plugins[plugin].invoke(data, pluginSettings, instanceId);
|
||||
});
|
||||
},
|
||||
|
||||
prepareContent: function (content) {
|
||||
var editor = YAHOO.widget.EditorInfo.getEditorById(this.field);
|
||||
content = editor.cleanHTML(content);
|
||||
return content;
|
||||
},
|
||||
|
||||
insert: function (content) {
|
||||
YAHOO.widget.EditorInfo.getEditorById(this.field).cmd_inserthtml(content);
|
||||
},
|
||||
|
||||
setContent: function (content) {
|
||||
YAHOO.widget.EditorInfo.getEditorById(this.field).setEditorHTML(content);
|
||||
},
|
||||
|
||||
getContent: function () {
|
||||
var instance = YAHOO.widget.EditorInfo.getEditorById(this.field);
|
||||
return instance.cleanHTML(instance.getEditorHTML(content));
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -77,13 +77,13 @@ function wysiwyg_nicedit_settings($editor, $config, $theme) {
|
||||
// Add editor content stylesheet.
|
||||
if (isset($config['css_setting'])) {
|
||||
if ($config['css_setting'] == 'theme') {
|
||||
$css = path_to_theme() . '/style.css';
|
||||
$css = drupal_get_path('theme', variable_get('theme_default', NULL)) . '/style.css';
|
||||
if (file_exists($css)) {
|
||||
$settings['externalCSS'] = base_path() . $css;
|
||||
}
|
||||
}
|
||||
else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['externalCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
|
||||
elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['externalCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => drupal_get_path('theme', variable_get('theme_default', NULL))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -102,8 +102,8 @@ function wysiwyg_openwysiwyg_settings($editor, $config, $theme) {
|
||||
if ($config['css_setting'] == 'theme') {
|
||||
$settings['CSSFile'] = reset(wysiwyg_get_css());
|
||||
}
|
||||
else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['CSSFile'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
|
||||
elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['CSSFile'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => drupal_get_path('theme', variable_get('theme_default', NULL))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,7 @@ function wysiwyg_tinymce_editor() {
|
||||
),
|
||||
'version callback' => 'wysiwyg_tinymce_version',
|
||||
'themes callback' => 'wysiwyg_tinymce_themes',
|
||||
'init callback' => 'wysiwyg_tinymce_init',
|
||||
'settings callback' => 'wysiwyg_tinymce_settings',
|
||||
'plugin callback' => 'wysiwyg_tinymce_plugins',
|
||||
'plugin settings callback' => 'wysiwyg_tinymce_plugin_settings',
|
||||
@@ -125,6 +126,40 @@ function wysiwyg_tinymce_themes($editor, $profile) {
|
||||
return array('advanced', 'simple');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an initialization JavaScript for this editor library.
|
||||
*
|
||||
* @param array $editor
|
||||
* The editor library definition.
|
||||
* @param string $library
|
||||
* The library variant key from $editor['libraries'].
|
||||
* @param object $profile
|
||||
* The (first) wysiwyg editor profile.
|
||||
*
|
||||
* @return string
|
||||
* A string containing inline JavaScript to execute before the editor library
|
||||
* script is loaded.
|
||||
*/
|
||||
function wysiwyg_tinymce_init($editor, $library) {
|
||||
// TinyMCE unconditionally searches for its library filename in SCRIPT tags on
|
||||
// on the page upon loading the library in order to determine the base path to
|
||||
// itself. When JavaScript aggregation is enabled, this search fails and all
|
||||
// relative constructed paths within TinyMCE are broken. The library has a
|
||||
// tinyMCE.baseURL property, but it is not publicly documented and thus not
|
||||
// reliable. The official support forum suggests to solve the issue through
|
||||
// the global window.tinyMCEPreInit variable also used by various serverside
|
||||
// compressor scrips available from the official website.
|
||||
// @see http://www.tinymce.com/forum/viewtopic.php?id=23286
|
||||
$settings = drupal_json_encode(array(
|
||||
'base' => base_path() . $editor['library path'],
|
||||
'suffix' => (strpos($library, 'src') !== FALSE || strpos($library, 'dev') !== FALSE ? '_src' : ''),
|
||||
'query' => '',
|
||||
));
|
||||
return <<<EOL
|
||||
window.tinyMCEPreInit = $settings;
|
||||
EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return runtime editor settings for a given wysiwyg profile.
|
||||
*
|
||||
@@ -181,6 +216,7 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) {
|
||||
$settings['remove_linebreaks'] = $config['remove_linebreaks'];
|
||||
}
|
||||
if (isset($config['verify_html'])) {
|
||||
// TinyMCE performs a type-agnostic comparison on this particular setting.
|
||||
$settings['verify_html'] = (bool) $config['verify_html'];
|
||||
}
|
||||
|
||||
@@ -192,8 +228,8 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) {
|
||||
if ($config['css_setting'] == 'theme') {
|
||||
$settings['content_css'] = implode(',', wysiwyg_get_css());
|
||||
}
|
||||
else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['content_css'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
|
||||
elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['content_css'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => drupal_get_path('theme', variable_get('theme_default', NULL))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,15 +268,15 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) {
|
||||
$settings['extensions'][_wysiwyg_tinymce_plugin_name('add', $button)] = 1;
|
||||
}
|
||||
// Add external plugins to the list of extensions.
|
||||
else if ($type == 'buttons' && empty($plugins[$plugin]['internal'])) {
|
||||
elseif ($type == 'buttons' && empty($plugins[$plugin]['internal'])) {
|
||||
$settings['extensions'][_wysiwyg_tinymce_plugin_name('add', $plugin)] = 1;
|
||||
}
|
||||
// Add internal buttons that also need to be loaded as extension.
|
||||
else if ($type == 'buttons' && !empty($plugins[$plugin]['load'])) {
|
||||
elseif ($type == 'buttons' && !empty($plugins[$plugin]['load'])) {
|
||||
$settings['extensions'][$plugin] = 1;
|
||||
}
|
||||
// Add plain extensions.
|
||||
else if ($type == 'extensions' && !empty($plugins[$plugin]['load'])) {
|
||||
elseif ($type == 'extensions' && !empty($plugins[$plugin]['load'])) {
|
||||
$settings['extensions'][$plugin] = 1;
|
||||
}
|
||||
// Allow plugins to add valid HTML elements.
|
||||
@@ -268,7 +304,7 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) {
|
||||
$settings += array(
|
||||
'theme_advanced_resize_horizontal' => FALSE,
|
||||
'theme_advanced_resizing_use_cookie' => FALSE,
|
||||
'theme_advanced_path_location' => isset($config['path_loc']) ? $config['path_loc'] : 'bottom',
|
||||
'theme_advanced_statusbar_location' => isset($config['path_loc']) ? $config['path_loc'] : 'bottom',
|
||||
'theme_advanced_resizing' => isset($config['resizing']) ? $config['resizing'] : 1,
|
||||
'theme_advanced_toolbar_location' => isset($config['toolbar_loc']) ? $config['toolbar_loc'] : 'top',
|
||||
'theme_advanced_toolbar_align' => isset($config['toolbar_align']) ? $config['toolbar_align'] : 'left',
|
||||
@@ -361,7 +397,7 @@ function _wysiwyg_tinymce_plugin_name($op, $name) {
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
else if ($op == 'remove') {
|
||||
elseif ($op == 'remove') {
|
||||
if (strpos($name, '-') === 0) {
|
||||
return substr($name, 1);
|
||||
}
|
||||
@@ -386,6 +422,8 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
'link' => t('Link'), 'unlink' => t('Unlink'), 'anchor' => t('Anchor'),
|
||||
'image' => t('Image'),
|
||||
'cleanup' => t('Clean-up'),
|
||||
'formatselect' => t('Block format'), 'styleselect' => t('Styles'),
|
||||
'fontselect' => t('Font'), 'fontsizeselect' => t('Font size'),
|
||||
'forecolor' => t('Forecolor'), 'backcolor' => t('Backcolor'),
|
||||
'sup' => t('Superscript'), 'sub' => t('Subscript'),
|
||||
'blockquote' => t('Blockquote'), 'code' => t('Source code'),
|
||||
@@ -402,15 +440,15 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
'path' => $editor['library path'] . '/plugins/advhr',
|
||||
'buttons' => array('advhr' => t('Advanced horizontal rule')),
|
||||
'extended_valid_elements' => array('hr[class|width|size|noshade]'),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advhr',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:advhr',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'advimage' => array(
|
||||
'path' => $editor['library path'] . '/plugins/advimage',
|
||||
'extensions' => array('advimage' => t('Advanced image')),
|
||||
'extended_valid_elements' => array('img[src|alt|title|align|width|height|usemap|hspace|vspace|border|style|class|onmouseover|onmouseout|id|name]'),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advimage',
|
||||
'extended_valid_elements' => array('img[src|alt|title|align|width|height|usemap|hspace|vspace|border|style|class|onmouseover|onmouseout|id|name|longdesc]'),
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:advimage',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
@@ -418,49 +456,42 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
'path' => $editor['library path'] . '/plugins/advlink',
|
||||
'extensions' => array('advlink' => t('Advanced link')),
|
||||
'extended_valid_elements' => array('a[name|href|target|title|class|onfocus|onblur|onclick|ondlbclick|onmousedown|onmouseup|onmouseover|onmouseout|onkeypress|onkeydown|onkeyup|id|style|rel]'),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlink',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:advlink',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'autosave' => array(
|
||||
'path' => $editor['library path'] . '/plugins/autosave',
|
||||
'extensions' => array('autosave' => t('Auto save')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:autosave',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'contextmenu' => array(
|
||||
'path' => $editor['library path'] . '/plugins/contextmenu',
|
||||
'extensions' => array('contextmenu' => t('Context menu')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/contextmenu',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:contextmenu',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'directionality' => array(
|
||||
'path' => $editor['library path'] . '/plugins/directionality',
|
||||
'buttons' => array('ltr' => t('Left-to-right'), 'rtl' => t('Right-to-left')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:directionality',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'emotions' => array(
|
||||
'path' => $editor['library path'] . '/plugins/emotions',
|
||||
'buttons' => array('emotions' => t('Emotions')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/emotions',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:emotions',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'font' => array(
|
||||
'path' => $editor['library path'] . '/plugins/font',
|
||||
'buttons' => array('formatselect' => t('HTML block format'), 'fontselect' => t('Font'), 'fontsizeselect' => t('Font size'), 'styleselect' => t('Font style')),
|
||||
'extended_valid_elements' => array('font[face|size|color|style],span[class|align|style]'),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/font',
|
||||
'internal' => TRUE,
|
||||
),
|
||||
'fullscreen' => array(
|
||||
'path' => $editor['library path'] . '/plugins/fullscreen',
|
||||
'buttons' => array('fullscreen' => t('Fullscreen')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:fullscreen',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
@@ -470,7 +501,7 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
'options' => array(
|
||||
'dialog_type' => array('modal'),
|
||||
),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:inlinepopups',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
@@ -481,56 +512,56 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
'plugin_insertdate_dateFormat' => '%Y-%m-%d',
|
||||
'plugin_insertdate_timeFormat' => '%H:%M:%S',
|
||||
),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/insertdatetime',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:insertdatetime',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'layer' => array(
|
||||
'path' => $editor['library path'] . '/plugins/layer',
|
||||
'buttons' => array('insertlayer' => t('Insert layer'), 'moveforward' => t('Move forward'), 'movebackward' => t('Move backward'), 'absolute' => t('Absolute')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/layer',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:layer',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'paste' => array(
|
||||
'path' => $editor['library path'] . '/plugins/paste',
|
||||
'buttons' => array('pastetext' => t('Paste text'), 'pasteword' => t('Paste from Word'), 'selectall' => t('Select all')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:paste',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'preview' => array(
|
||||
'path' => $editor['library path'] . '/plugins/preview',
|
||||
'buttons' => array('preview' => t('Preview')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/preview',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:preview',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'print' => array(
|
||||
'path' => $editor['library path'] . '/plugins/print',
|
||||
'buttons' => array('print' => t('Print')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/print',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:print',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'searchreplace' => array(
|
||||
'path' => $editor['library path'] . '/plugins/searchreplace',
|
||||
'buttons' => array('search' => t('Search'), 'replace' => t('Replace')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/searchreplace',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:searchreplace',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'style' => array(
|
||||
'path' => $editor['library path'] . '/plugins/style',
|
||||
'buttons' => array('styleprops' => t('Style properties')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/style',
|
||||
'buttons' => array('styleprops' => t('Advanced CSS styles')),
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:style',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
'table' => array(
|
||||
'path' => $editor['library path'] . '/plugins/table',
|
||||
'buttons' => array('tablecontrols' => t('Table')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/table',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:table',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
),
|
||||
@@ -540,7 +571,6 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
'path' => $editor['library path'] . '/plugins/flash',
|
||||
'buttons' => array('flash' => t('Flash')),
|
||||
'extended_valid_elements' => array('img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|obj|param|embed]'),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/flash',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
);
|
||||
@@ -549,14 +579,14 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
$plugins['media'] = array(
|
||||
'path' => $editor['library path'] . '/plugins/media',
|
||||
'buttons' => array('media' => t('Media')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/media',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:media',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
);
|
||||
$plugins['xhtmlxtras'] = array(
|
||||
'path' => $editor['library path'] . '/plugins/xhtmlxtras',
|
||||
'buttons' => array('cite' => t('Citation'), 'del' => t('Deleted'), 'abbr' => t('Abbreviation'), 'acronym' => t('Acronym'), 'ins' => t('Inserted'), 'attribs' => t('HTML attributes')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:xhtmlxtras',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
);
|
||||
@@ -565,7 +595,7 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
$plugins['bbcode'] = array(
|
||||
'path' => $editor['library path'] . '/plugins/bbcode',
|
||||
'extensions' => array('bbcode' => t('BBCode')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:bbcode',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
);
|
||||
@@ -573,7 +603,6 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
$plugins['safari'] = array(
|
||||
'path' => $editor['library path'] . '/plugins/safari',
|
||||
'extensions' => array('safari' => t('Safari compatibility')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/safari',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
);
|
||||
@@ -583,7 +612,7 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
$plugins['autoresize'] = array(
|
||||
'path' => $editor['library path'] . '/plugins/autoresize',
|
||||
'extensions' => array('autoresize' => t('Auto resize')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autoresize',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:autoresize',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
);
|
||||
@@ -592,7 +621,7 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
$plugins['advlist'] = array(
|
||||
'path' => $editor['library path'] . '/plugins/advlist',
|
||||
'extensions' => array('advlist' => t('Advanced list')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlist',
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:advlist',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
);
|
||||
@@ -601,11 +630,24 @@ function wysiwyg_tinymce_plugins($editor) {
|
||||
$plugins['wordcount'] = array(
|
||||
'path' => $editor['library path'] . '/plugins/wordcount',
|
||||
'extensions' => array('wordcount' => t('Word count')),
|
||||
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/wordcount',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
);
|
||||
}
|
||||
if (version_compare($editor['installed version'], '3.4.1', '>=')) {
|
||||
$plugins['lists'] = array(
|
||||
'path' => $editor['library path'] . 'plugins/lists',
|
||||
'extensions' => array('lists' => t('List normalizer')),
|
||||
'url' => 'http://www.tinymce.com/wiki.php/Plugin:lists',
|
||||
'internal' => TRUE,
|
||||
'load' => TRUE,
|
||||
'extended_valid_elements' => array(
|
||||
'li[class|dir|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type|value]',
|
||||
'ol[class|compact|dir|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|start|style|title|type]',
|
||||
'ul[class|compact|dir|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type]',
|
||||
),
|
||||
);
|
||||
}
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
|
@@ -104,13 +104,13 @@ function wysiwyg_whizzywig_settings($editor, $config, $theme) {
|
||||
// Add editor content stylesheet.
|
||||
if (isset($config['css_setting'])) {
|
||||
if ($config['css_setting'] == 'theme') {
|
||||
$css = path_to_theme() . '/style.css';
|
||||
$css = drupal_get_path('theme', variable_get('theme_default', NULL)) . '/style.css';
|
||||
if (file_exists($css)) {
|
||||
$settings['externalCSS'] = base_path() . $css;
|
||||
}
|
||||
}
|
||||
else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['externalCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
|
||||
elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['externalCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => drupal_get_path('theme', variable_get('theme_default', NULL))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -172,10 +172,11 @@ function wysiwyg_wymeditor_settings($editor, $config, $theme) {
|
||||
if (isset($config['css_setting'])) {
|
||||
if ($config['css_setting'] == 'theme') {
|
||||
// WYMeditor only supports one CSS file currently.
|
||||
$settings['stylesheet'] = reset(wysiwyg_get_css());
|
||||
$css = wysiwyg_get_css();
|
||||
$settings['stylesheet'] = reset($css);
|
||||
}
|
||||
else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['stylesheet'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
|
||||
elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['stylesheet'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => drupal_get_path('theme', variable_get('theme_default', NULL))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +191,7 @@ function wysiwyg_wymeditor_plugins($editor) {
|
||||
'default' => array(
|
||||
'buttons' => array(
|
||||
'Bold' => t('Bold'), 'Italic' => t('Italic'),
|
||||
'InsertOrderedList' => t('Bullet list'), 'InsertUnorderedList' => t('Numbered list'),
|
||||
'InsertOrderedList' => t('Numbered list'), 'InsertUnorderedList' => t('Bullet list'),
|
||||
'Outdent' => t('Outdent'), 'Indent' => t('Indent'),
|
||||
'Undo' => t('Undo'), 'Redo' => t('Redo'),
|
||||
'CreateLink' => t('Link'), 'Unlink' => t('Unlink'),
|
||||
@@ -212,22 +213,22 @@ function wysiwyg_wymeditor_plugins($editor) {
|
||||
*/
|
||||
function _wysiwyg_wymeditor_button_info() {
|
||||
return array(
|
||||
'Bold' => array('title'=> 'Strong', 'css'=> 'wym_tools_strong'),
|
||||
'Italic' => array('title'=> 'Emphasis', 'css'=> 'wym_tools_emphasis'),
|
||||
'Superscript' => array('title'=> 'Superscript', 'css'=> 'wym_tools_superscript'),
|
||||
'Subscript' => array('title'=> 'Subscript', 'css'=> 'wym_tools_subscript'),
|
||||
'InsertOrderedList' => array('title'=> 'Ordered_List', 'css'=> 'wym_tools_ordered_list'),
|
||||
'InsertUnorderedList' => array('title'=> 'Unordered_List', 'css'=> 'wym_tools_unordered_list'),
|
||||
'Indent' => array('title'=> 'Indent', 'css'=> 'wym_tools_indent'),
|
||||
'Outdent' => array('title'=> 'Outdent', 'css'=> 'wym_tools_outdent'),
|
||||
'Undo' => array('title'=> 'Undo', 'css'=> 'wym_tools_undo'),
|
||||
'Redo' => array('title'=> 'Redo', 'css'=> 'wym_tools_redo'),
|
||||
'CreateLink' => array('title'=> 'Link', 'css'=> 'wym_tools_link'),
|
||||
'Unlink' => array('title'=> 'Unlink', 'css'=> 'wym_tools_unlink'),
|
||||
'InsertImage' => array('title'=> 'Image', 'css'=> 'wym_tools_image'),
|
||||
'InsertTable' => array('title'=> 'Table', 'css'=> 'wym_tools_table'),
|
||||
'Paste' => array('title'=> 'Paste_From_Word', 'css'=> 'wym_tools_paste'),
|
||||
'ToggleHtml' => array('title'=> 'HTML', 'css'=> 'wym_tools_html'),
|
||||
'Preview' => array('title'=> 'Preview', 'css'=> 'wym_tools_preview'),
|
||||
'Bold' => array('title' => 'Strong', 'css' => 'wym_tools_strong'),
|
||||
'Italic' => array('title' => 'Emphasis', 'css' => 'wym_tools_emphasis'),
|
||||
'Superscript' => array('title' => 'Superscript', 'css' => 'wym_tools_superscript'),
|
||||
'Subscript' => array('title' => 'Subscript', 'css' => 'wym_tools_subscript'),
|
||||
'InsertOrderedList' => array('title' => 'Ordered_List', 'css' => 'wym_tools_ordered_list'),
|
||||
'InsertUnorderedList' => array('title' => 'Unordered_List', 'css' => 'wym_tools_unordered_list'),
|
||||
'Indent' => array('title' => 'Indent', 'css' => 'wym_tools_indent'),
|
||||
'Outdent' => array('title' => 'Outdent', 'css' => 'wym_tools_outdent'),
|
||||
'Undo' => array('title' => 'Undo', 'css' => 'wym_tools_undo'),
|
||||
'Redo' => array('title' => 'Redo', 'css' => 'wym_tools_redo'),
|
||||
'CreateLink' => array('title' => 'Link', 'css' => 'wym_tools_link'),
|
||||
'Unlink' => array('title' => 'Unlink', 'css' => 'wym_tools_unlink'),
|
||||
'InsertImage' => array('title' => 'Image', 'css' => 'wym_tools_image'),
|
||||
'InsertTable' => array('title' => 'Table', 'css' => 'wym_tools_table'),
|
||||
'Paste' => array('title' => 'Paste_From_Word', 'css' => 'wym_tools_paste'),
|
||||
'ToggleHtml' => array('title' => 'HTML', 'css' => 'wym_tools_html'),
|
||||
'Preview' => array('title' => 'Preview', 'css' => 'wym_tools_preview'),
|
||||
);
|
||||
}
|
||||
|
@@ -45,6 +45,14 @@ function wysiwyg_yui_editor() {
|
||||
'load callback' => 'wysiwyg_yui_load',
|
||||
'settings callback' => 'wysiwyg_yui_settings',
|
||||
'plugin callback' => 'wysiwyg_yui_plugins',
|
||||
'plugin settings callback' => 'wysiwyg_yui_plugin_settings',
|
||||
'proxy plugin' => array(
|
||||
'drupal' => array(
|
||||
'load' => TRUE,
|
||||
'proxy' => TRUE,
|
||||
),
|
||||
),
|
||||
'proxy plugin settings callback' => 'wysiwyg_yui_proxy_plugin_settings',
|
||||
'versions' => array(
|
||||
'2.7.0' => array(
|
||||
'js files' => array('yui.js'),
|
||||
@@ -177,7 +185,7 @@ function wysiwyg_yui_settings($editor, $config, $theme) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($button == 'fontname') {
|
||||
elseif ($button == 'fontname') {
|
||||
$extra = array('menu' => array(
|
||||
array('text' => 'Arial', 'checked' => TRUE),
|
||||
array('text' => 'Arial Black'),
|
||||
@@ -202,8 +210,8 @@ function wysiwyg_yui_settings($editor, $config, $theme) {
|
||||
if ($config['css_setting'] == 'theme') {
|
||||
$settings['extracss'] = wysiwyg_get_css();
|
||||
}
|
||||
else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['extracss'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
|
||||
elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
|
||||
$settings['extracss'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => drupal_get_path('theme', variable_get('theme_default', NULL))));
|
||||
$settings['extracss'] = explode(',', $settings['extracss']);
|
||||
}
|
||||
// YUI only supports inline CSS, so we need to use @import directives.
|
||||
@@ -233,8 +241,7 @@ function wysiwyg_yui_button_setting($editor, $plugin, $button, $extra = array())
|
||||
static $plugins;
|
||||
|
||||
if (!isset($plugins)) {
|
||||
// @todo Invoke all enabled plugins, not just internals.
|
||||
$plugins = wysiwyg_yui_plugins($editor);
|
||||
$plugins = wysiwyg_get_plugins($editor['name']);
|
||||
}
|
||||
|
||||
// Return a simple separator.
|
||||
@@ -269,6 +276,41 @@ function wysiwyg_yui_button_setting($editor, $plugin, $button, $extra = array())
|
||||
return $button;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a JS settings array of native external plugins that need to be loaded separately.
|
||||
*/
|
||||
function wysiwyg_yui_plugin_settings($editor, $profile, $plugins) {
|
||||
$settings = array();
|
||||
foreach ($plugins as $name => $plugin) {
|
||||
if (!empty($plugin['load'])) {
|
||||
// Add path for native external plugins; internal ones are loaded
|
||||
// automatically.
|
||||
if (empty($plugin['internal']) && isset($plugin['path'])) {
|
||||
$settings[$name] = base_path() . $plugin['path'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a JS settings array for Drupal plugins loaded via the proxy plugin.
|
||||
*/
|
||||
function wysiwyg_yui_proxy_plugin_settings($editor, $profile, $plugins) {
|
||||
$settings = array();
|
||||
foreach ($plugins as $name => $plugin) {
|
||||
// Populate required plugin settings.
|
||||
$settings[$name] = $plugin['dialog settings'] + array(
|
||||
'title' => $plugin['title'],
|
||||
'icon' => base_path() . $plugin['icon path'] . '/' . $plugin['icon file'],
|
||||
'iconTitle' => $plugin['icon title'],
|
||||
// @todo These should only be set if the plugin defined them.
|
||||
'css' => base_path() . $plugin['css path'] . '/' . $plugin['css file'],
|
||||
);
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin().
|
||||
*/
|
||||
|
Reference in New Issue
Block a user