update 2.2 + precedent custom commits
Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user