diff --git a/editors/js/ckeditor-3.0.js b/editors/js/ckeditor-3.0.js index d2cf300..f380d6a 100644 --- a/editors/js/ckeditor-3.0.js +++ b/editors/js/ckeditor-3.0.js @@ -208,9 +208,19 @@ 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) { + content = this.prepareContent(content); + CKEDITOR.instances[this.field].setData(content); + }, + + getContent: function() { + return CKEDITOR.instances[this.field].getData(); } }; diff --git a/editors/js/fckeditor-2.6.js b/editors/js/fckeditor-2.6.js index 4ee2cff..d795565 100644 --- a/editors/js/fckeditor-2.6.js +++ b/editors/js/fckeditor-2.6.js @@ -175,6 +175,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); } }; diff --git a/editors/js/jwysiwyg.js b/editors/js/jwysiwyg.js index ae47853..71f0e4a 100644 --- a/editors/js/jwysiwyg.js +++ b/editors/js/jwysiwyg.js @@ -22,4 +22,18 @@ Drupal.wysiwyg.editor.detach.jwysiwyg = function(context, params) { $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').val(); + } +}; + })(jQuery); diff --git a/editors/js/markitup.js b/editors/js/markitup.js index 6691811..240fd0c 100644 --- a/editors/js/markitup.js +++ b/editors/js/markitup.js @@ -26,4 +26,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); diff --git a/editors/js/nicedit.js b/editors/js/nicedit.js index d5d9795..e026885 100644 --- a/editors/js/nicedit.js +++ b/editors/js/nicedit.js @@ -89,6 +89,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(); } }; diff --git a/editors/js/none.js b/editors/js/none.js index 3402024..486b78d 100644 --- a/editors/js/none.js +++ b/editors/js/none.js @@ -65,6 +65,14 @@ Drupal.wysiwyg.editor.instance.none = { else { editor.value += content; } + }, + + setContent: function(content) { + $(this.field).val(content); + }, + + getContent: function() { + $(this.field).val(); } }; diff --git a/editors/js/openwysiwyg.js b/editors/js/openwysiwyg.js index 89a5337..63dfd8b 100644 --- a/editors/js/openwysiwyg.js +++ b/editors/js/openwysiwyg.js @@ -65,4 +65,22 @@ Drupal.wysiwyg.editor.detach.openwysiwyg = function(context, params) { } }; +/** + * Instance methods for openWYSIWYG. + */ +Drupal.wysiwyg.editor.instance.openwysiwyg = { + insert: function (content) { + alert(Drupal.t('Sorry, inserting content is not supported on openWYSIWYG.')); + }, + + setContent: function(content) { + alert(Drupal.t('Sorry, replacing the editor content is not supported on openWYSIWYG.')); + }, + + getContent: function() { + alert(Drupal.t('Sorry, retrieving the editor contents is not supported on openWYSIWYG.')); + return ''; + } +}; + })(jQuery); diff --git a/editors/js/tinymce-3.js b/editors/js/tinymce-3.js index b38f523..7f9fc29 100644 --- a/editors/js/tinymce-3.js +++ b/editors/js/tinymce-3.js @@ -175,7 +175,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 +186,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 +221,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; } }; diff --git a/editors/js/whizzywig-60.js b/editors/js/whizzywig-60.js index dc995f6..150614b 100644 --- a/editors/js/whizzywig-60.js +++ b/editors/js/whizzywig-60.js @@ -82,4 +82,24 @@ Drupal.wysiwyg.editor.detach.whizzywig = function(context, params) { } }; +/** + * Instance methods for Whizzywig. + */ +Drupal.wysiwyg.editor.instance.whizzywig = { + insert: function (content) { + insHTML(content); + }, + + setContent: function(content) { + alert(Drupal.t('WARNING: Your editor doesn\'t support replacing it\'s ' + + 'content, so we\'ll have to insert instead. Consider clearing the ' + + 'contents of the editor manually and retrying your action.')); + insHTML(content); + }, + + getContent: function() { + return $('#' + this.field).val(); + } +}; + })(jQuery); diff --git a/editors/js/whizzywig.js b/editors/js/whizzywig.js index e98bc4d..5a49efc 100644 --- a/editors/js/whizzywig.js +++ b/editors/js/whizzywig.js @@ -123,4 +123,23 @@ Drupal.wysiwyg.editor.detach.whizzywig = function(context, params) { } }; +/** + * Instance methods for Whizzywig. + */ +Drupal.wysiwyg.editor.instance.whizzywig = { + insert: function (content) { + insHTML(content); + }, + + setContent: function(content) { + $('#' + this.field).val(''); + insHTML(content); + }, + + getContent: function() { + alert(Drupal.t('Sorry, retrieving the editor contents is not supported on openWYSIWYG.')); + return ''; + } +}; + })(jQuery); diff --git a/editors/js/wymeditor.js b/editors/js/wymeditor.js index ed66784..eeb298b 100644 --- a/editors/js/wymeditor.js +++ b/editors/js/wymeditor.js @@ -44,12 +44,24 @@ Drupal.wysiwyg.editor.detach.wymeditor = function (context, params) { Drupal.wysiwyg.editor.instance.wymeditor = { insert: function (content) { + this.getInstance().insert(content); + }, + + setContent: function (content) { + this.getInstance().html(content); + }, + + getContent: function (content) { + return this.getInstance().html(); + }, + + 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; } }; diff --git a/editors/js/yui.js b/editors/js/yui.js index ad8be36..5d4b1ba 100644 --- a/editors/js/yui.js +++ b/editors/js/yui.js @@ -32,4 +32,19 @@ Drupal.wysiwyg.editor.detach.yui = function(context, params) { } }; +Drupal.wysiwyg.editor.instance.yui = { + 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);