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