Index: wysiwyg.init.js =================================================================== RCS file: wysiwyg.init.js diff -N wysiwyg.init.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ wysiwyg.init.js 11 Oct 2008 01:07:42 -0000 @@ -0,0 +1,10 @@ +// $Id: wysiwyg_editor.js,v 1.1.2.8 2008/10/05 21:01:47 sun Exp $ + +Drupal.behaviors = Drupal.behaviors || {}; // D5 only. + +Drupal.wysiwyg = Drupal.wysiwyg || { 'invoke': {} }; + +Drupal.wysiwyg.editor = Drupal.wysiwyg.editor || { 'init': {}, 'attach': {}, 'detach': {}, 'invoke': {} }; + +Drupal.wysiwyg.plugins = Drupal.wysiwyg.plugins || {}; + Index: wysiwyg_editor.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg_editor.js,v retrieving revision 1.1.2.9 diff -u -p -r1.1.2.9 wysiwyg_editor.js --- wysiwyg_editor.js 10 Oct 2008 21:25:33 -0000 1.1.2.9 +++ wysiwyg_editor.js 11 Oct 2008 01:12:49 -0000 @@ -1,8 +1,5 @@ // $Id: wysiwyg_editor.js,v 1.1.2.9 2008/10/10 21:25:33 sun Exp $ -Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} }; -Drupal.behaviors = Drupal.behaviors || {}; // D5 only. - /** * Initialize editor libraries. * @@ -10,7 +7,7 @@ Drupal.behaviors = Drupal.behaviors || { * init hook gives them a chance to do so. */ Drupal.wysiwygInit = function() { - jQuery.each(Drupal.wysiwyg.init, function(editor) { + jQuery.each(Drupal.wysiwyg.editor.init, function(editor) { this(Drupal.settings.wysiwygEditor.configs[editor]); }); } @@ -81,10 +78,17 @@ Drupal.behaviors.attachWysiwyg = functio * An object containing input format parameters. */ Drupal.wysiwygAttach = function(context, params) { - if (typeof Drupal.wysiwyg.attach[params.editor] == 'function') { - Drupal.wysiwyg.attach[params.editor](context, params, Drupal.wysiwyg.clone(Drupal.settings.wysiwygEditor.configs[params.editor])); + if (typeof Drupal.wysiwyg.editor.attach[params.editor] == 'function') { + // Attach editor. + Drupal.wysiwyg.editor.attach[params.editor](context, params, Drupal.wysiwyg.clone(Drupal.settings.wysiwygEditor.configs[params.editor])); + // Provide editor callbacks for plugins. + if (typeof Drupal.wysiwyg.editor.invoke[params.editor] == 'object') { + Drupal.wysiwyg.invoke = Drupal.wysiwyg.editor.invoke[params.editor]; + } + // Display toggle link. $('#wysiwyg-toggle-' + params.field).show(); } + // Hide toggle link in case no editor is attached. if (params.editor == 'none') { $('#wysiwyg-toggle-' + params.field).hide(); } @@ -103,7 +107,7 @@ Drupal.wysiwygAttach = function(context, * An object containing input format parameters. */ Drupal.wysiwygDetach = function(context, params) { - jQuery.each(Drupal.wysiwyg.detach, function(editor) { + jQuery.each(Drupal.wysiwyg.editor.detach, function(editor) { this(context, params); }); } @@ -124,11 +128,11 @@ Drupal.wysiwygEditorAttachToggleLink = f Drupal.wysiwygDetach(context, params); $('#wysiwyg-toggle-' + params.field).html(Drupal.settings.wysiwygEditor.enable).blur(); // After disabling the editor, re-attach default behaviors. - Drupal.wysiwyg.attach.none(context, params); + Drupal.wysiwyg.editor.attach.none(context, params); }, function() { // Before enabling the editor, detach default behaviors. - Drupal.wysiwyg.detach.none(context, params); + Drupal.wysiwyg.editor.detach.none(context, params); Drupal.wysiwygAttach(context, params); $('#wysiwyg-toggle-' + params.field).html(Drupal.settings.wysiwygEditor.disable).blur(); }) Index: wysiwyg_editor.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg_editor.module,v retrieving revision 1.1.2.28 diff -u -p -r1.1.2.28 wysiwyg_editor.module --- wysiwyg_editor.module 10 Oct 2008 21:57:40 -0000 1.1.2.28 +++ wysiwyg_editor.module 10 Oct 2008 23:50:44 -0000 @@ -163,10 +163,10 @@ function wysiwyg_process_form(&$form) { // Check editor theme (and reset it if not/no longer available). $theme = wysiwyg_editor_get_themes($profile, $field['#wysiwyg_style']); + // Add plugin settings (first) for this input format. + wysiwyg_editor_add_plugin_settings($profile); // Add profile settings for this input format. wysiwyg_editor_add_settings($profile, $theme); - // Add plugin settings for this input format. - wysiwyg_editor_add_plugin_settings($profile); $theme = ' wysiwyg-theme-'. $theme; } @@ -311,6 +311,7 @@ function wysiwyg_editor_load_editor($pro // @todo Separate into wysiwyg.init.js and wysiwyg.editor?.js, to ensure // this logic/ordering, and do not force editor integration scripts to // check and define Drupal.wysiwyg on its own. + drupal_add_js(wysiwyg_get_path('wysiwyg.init.js')); drupal_add_js(wysiwyg_get_path('wysiwyg_editor.js'), 'module', 'footer'); // Add our stylesheet to stack editor buttons into one row. @@ -360,6 +361,13 @@ function wysiwyg_editor_add_plugin_setti $plugins = array(); $editor = wysiwyg_get_editor($profile->settings['editor']); $info = module_invoke_all('wysiwyg_plugin', $editor['name'], $editor['installed version']); + if (isset($editor['proxy plugin'])) { + $info += $editor['proxy plugin']; + $contrib_plugins = wysiwyg_get_all_plugins(); + foreach ($contrib_plugins as $plugin_name => $meta) { + $info['drupal']['buttons'][$plugin_name] = $meta; + } + } // Only keep enabled plugins in this profile. foreach ($info as $plugin => $meta) { if (!isset($profile->settings['buttons'][$plugin])) { @@ -434,9 +442,16 @@ function wysiwyg_editor_get_plugins($edi $plugins = $editor['plugin callback']($editor); } // Load our own plugins. - include_once drupal_get_path('module', 'wysiwyg_editor') .'/wysiwyg_editor.plugins.inc'; + #include_once drupal_get_path('module', 'wysiwyg_editor') .'/wysiwyg_editor.plugins.inc'; - $plugins = array_merge($plugins, module_invoke_all('wysiwyg_plugin', $editor['name'], $editor['installed version'])); + #$plugins = array_merge($plugins, module_invoke_all('wysiwyg_plugin', $editor['name'], $editor['installed version'])); + if (isset($editor['proxy plugin'])) { + $plugins += $editor['proxy plugin']; + $contrib_plugins = wysiwyg_get_all_plugins(); + foreach ($contrib_plugins as $plugin_name => $info) { + $plugins['drupal']['buttons'][$plugin_name] = $info['title']; + } + } } return $plugins; } @@ -638,6 +653,42 @@ function wysiwyg_get_all_editors() { } /** + * Invoke hook_wysiwyg_plugin() in all modules. + */ +function wysiwyg_get_all_plugins() { + static $plugins; + + if (isset($plugins)) { + return $plugins; + } + + $plugins = wysiwyg_load_includes('plugins', 'plugin'); + foreach ($plugins as $name => $properties) { + $plugin = &$plugins[$name]; + // Fill in required properties. + $plugin += array( + 'title' => $plugin['name'], + 'vendor url' => '', + 'js path' => $plugin['path'] . '/' . $plugin['name'], + 'js file' => $plugin['name'] . '.js', + 'css path' => $plugin['path'] . '/' . $plugin['name'], + 'css file' => $plugin['name'] . '.css', + 'icon path' => $plugin['path'] . '/' . $plugin['name'] . '/images', + 'icon file' => $plugin['name'] . '.png', + 'dialog path' => $plugin['name'], + 'dialog settings' => array(), + 'settings callback' => NULL, + 'settings form callback' => NULL, + ); + // Check whether library is present. + if (!($plugin['installed'] = file_exists($plugin['js path'] . '/' . $plugin['js file']))) { + continue; + } + } + return $plugins; +} + +/** * Load include files for wysiwyg implemented by all modules. * * @param $type Index: editors/tinymce.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/tinymce.inc,v retrieving revision 1.1.2.2 diff -u -p -r1.1.2.2 tinymce.inc --- editors/tinymce.inc 5 Oct 2008 21:01:47 -0000 1.1.2.2 +++ editors/tinymce.inc 11 Oct 2008 03:13:17 -0000 @@ -37,6 +37,7 @@ function wysiwyg_tinymce_editor() { '2.1' => array( // 'include files' => array('tinymce-2.inc'), 'js files' => array('tinymce-2.js'), + 'download url' => 'http://sourceforge.net/project/showfiles.php?group_id=103281&package_id=111430&release_id=557383', ), '3.2' => array( // 'include files' => array('tinymce-3.inc'), @@ -56,6 +57,13 @@ function wysiwyg_tinymce_editor() { 'files' => array('tiny_mce_src.js'), ), ), + 'proxy plugin' => array( + 'drupal' => array( + 'path' => wysiwyg_get_path('editors/js') . '/tinymce-3.plugin.js', + 'load' => TRUE, + 'internal' => TRUE, + ), + ), ), ), // Optional properties @@ -171,7 +179,12 @@ function wysiwyg_tinymce_settings($edito } // Add internal buttons that also need to be loaded as extension. else if ($type == 'buttons' && isset($plugins[$plugin]['load'])) { - $init['extensions'][$plugin] = 1; + if ($plugin == 'drupal') { + $init['extensions'][$button] = 1; + } + else { + $init['extensions'][$plugin] = 1; + } } // Add plain extensions. else if ($type == 'extensions') { @@ -265,7 +278,20 @@ function wysiwyg_tinymce_themes($editor, function wysiwyg_tinymce_plugin_settings($editor, $profile, $info) { $plugins = array(); foreach ($info as $name => $plugin) { - if (!isset($plugin['internal'])) { + // New API plugins. + if ($name == 'drupal') { + foreach ($plugin['buttons'] as $plugin_name => $meta) { + drupal_add_js($meta['js path'] .'/'. $meta['js file']); + $plugins[$plugin_name] = $meta['dialog settings'] + array( + 'title' => $meta['title'], + 'path' => base_path() . $meta['js path'], + 'dialogPath' => base_path() . $meta['dialog path'], + 'icon' => base_path() . $meta['icon path'] .'/'. $meta['icon file'], + 'css' => base_path() . $meta['css path'] .'/'. $meta['css file'], + ); + } + } + else if (!isset($plugin['internal'])) { $plugins[$name] = base_path() . $plugin['path']; } } Index: editors/js/fckeditor-2.6.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/fckeditor-2.6.js,v retrieving revision 1.1.2.3 diff -u -p -r1.1.2.3 fckeditor-2.6.js --- editors/js/fckeditor-2.6.js 10 Oct 2008 21:25:33 -0000 1.1.2.3 +++ editors/js/fckeditor-2.6.js 11 Oct 2008 01:04:58 -0000 @@ -1,13 +1,11 @@ // $Id: fckeditor-2.6.js,v 1.1.2.3 2008/10/10 21:25:33 sun Exp $ -Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} }; - /** * Attach this editor to a target element. * - * See Drupal.wysiwyg.attach.none() for a full desciption of this hook. + * See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook. */ -Drupal.wysiwyg.attach.fckeditor = function(context, params, settings) { +Drupal.wysiwyg.editor.attach.fckeditor = function(context, params, settings) { // @todo Convert string into variable name w/o overwriting string? // workaround: build object via editors[this.id] = new ... var FCKinstance = new FCKeditor(params.field); @@ -25,9 +23,9 @@ Drupal.wysiwyg.attach.fckeditor = functi /** * Detach a single or all editors. * - * See Drupal.wysiwyg.detach.none() for a full desciption of this hook. + * See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook. */ -Drupal.wysiwyg.detach.fckeditor = function(context, params) { +Drupal.wysiwyg.editor.detach.fckeditor = function(context, params) { if (typeof params != 'undefined') { var editor = FCKeditorAPI.GetInstance(params.field); if (editor) { Index: editors/js/none.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/none.js,v retrieving revision 1.1.2.2 diff -u -p -r1.1.2.2 none.js --- editors/js/none.js 10 Oct 2008 21:25:33 -0000 1.1.2.2 +++ editors/js/none.js 11 Oct 2008 01:05:07 -0000 @@ -1,7 +1,5 @@ // $Id: none.js,v 1.1.2.2 2008/10/10 21:25:33 sun Exp $ -Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} }; - /** * Attach this editor to a target element. * @@ -15,7 +13,7 @@ Drupal.wysiwyg = Drupal.wysiwyg || { 'in * @param settings * An object containing editor settings for all enabled editor themes. */ -Drupal.wysiwyg.attach.none = function(context, params, settings) { +Drupal.wysiwyg.editor.attach.none = function(context, params, settings) { if (params.resizable) { $('#' + params.field).addClass('resizable'); Drupal.textareaAttach(); @@ -25,7 +23,7 @@ Drupal.wysiwyg.attach.none = function(co /** * Detach a single or all editors. * - * See Drupal.wysiwyg.attach.none() for a full desciption of arguments. + * See Drupal.wysiwyg.editor.attach.none() for a full desciption of arguments. * * @param context * A DOM element, supplied by Drupal.attachBehaviors(). @@ -35,7 +33,7 @@ Drupal.wysiwyg.attach.none = function(co * all editors should be detached and saved, so they can be submitted in * AJAX/AHAH applications. */ -Drupal.wysiwyg.detach.none = function(context, params) { +Drupal.wysiwyg.editor.detach.none = function(context, params) { if (typeof params != 'undefined') { var $textarea = $('#' + params.field, context).removeClass('processed'); var $div = $textarea.parents('div.resizable-textarea'); Index: editors/js/tinymce-2.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/tinymce-2.js,v retrieving revision 1.1.2.3 diff -u -p -r1.1.2.3 tinymce-2.js --- editors/js/tinymce-2.js 10 Oct 2008 21:25:33 -0000 1.1.2.3 +++ editors/js/tinymce-2.js 11 Oct 2008 01:05:44 -0000 @@ -1,7 +1,5 @@ // $Id: tinymce-2.js,v 1.1.2.3 2008/10/10 21:25:33 sun Exp $ -Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} }; - /** * Initialize editor instances. * @@ -11,7 +9,7 @@ Drupal.wysiwyg = Drupal.wysiwyg || { 'in * @param editorSettings * An object containing editor settings for each enabled editor theme. */ -Drupal.wysiwyg.init.tinymce = function(editorSettings) { +Drupal.wysiwyg.editor.init.tinymce = function(editorSettings) { // If JS compression is enabled, TinyMCE is unable to find its own base path // and exec mode, hence we need to define it manually. // @todo Move global library settings somewhere else. @@ -20,6 +18,7 @@ Drupal.wysiwyg.init.tinymce = function(e tinyMCE.gzipMode = (Drupal.settings.wysiwygEditor.execMode == 'gzip'); for (var theme in editorSettings) { + // @todo Remove; moved into wysiwygEditor.js. // Clone, so original settings are not overwritten. var config = Drupal.wysiwyg.clone(editorSettings[theme]); tinyMCE.init(config); @@ -33,9 +32,9 @@ Drupal.wysiwyg.init.tinymce = function(e /** * Attach this editor to a target element. * - * See Drupal.wysiwyg.attach.none() for a full desciption of this hook. + * See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook. */ -Drupal.wysiwyg.attach.tinymce = function(context, params, editorSettings) { +Drupal.wysiwyg.editor.attach.tinymce = function(context, params, editorSettings) { // Configure settings for this theme. for (var setting in editorSettings[params.theme]) { tinyMCE.settings[setting] = editorSettings[params.theme][setting]; @@ -49,9 +48,9 @@ Drupal.wysiwyg.attach.tinymce = function /** * Detach a single or all editors. * - * See Drupal.wysiwyg.detach.none() for a full desciption of this hook. + * See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook. */ -Drupal.wysiwyg.detach.tinymce = function(context, params) { +Drupal.wysiwyg.editor.detach.tinymce = function(context, params) { if (typeof params != 'undefined') { tinyMCE.removeMCEControl(tinyMCE.getEditorId(params.field)); $('#' + params.field).removeAttr('style'); Index: editors/js/tinymce-3.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/tinymce-3.js,v retrieving revision 1.1.2.4 diff -u -p -r1.1.2.4 tinymce-3.js --- editors/js/tinymce-3.js 10 Oct 2008 21:57:40 -0000 1.1.2.4 +++ editors/js/tinymce-3.js 11 Oct 2008 03:18:52 -0000 @@ -1,7 +1,5 @@ // $Id: tinymce-3.js,v 1.1.2.4 2008/10/10 21:57:40 sun Exp $ -Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} }; - /** * Initialize editor instances. * @@ -12,7 +10,7 @@ Drupal.wysiwyg = Drupal.wysiwyg || { 'in * @param editorSettings * An object containing editor settings for each enabled editor theme. */ -Drupal.wysiwyg.init.tinymce = function(editorSettings) { +Drupal.wysiwyg.editor.init.tinymce = function(editorSettings) { // If JS compression is enabled, TinyMCE is unable to find its own base path // and exec mode, hence we need to define it manually. // @todo Move global library settings somewhere else. @@ -20,23 +18,121 @@ Drupal.wysiwyg.init.tinymce = function(e tinyMCE.srcMode = (Drupal.settings.wysiwygEditor.execMode == 'src' ? '_src' : ''); tinyMCE.gzipMode = (Drupal.settings.wysiwygEditor.execMode == 'gzip'); + // @todo Move into global library settings. + for (var plugin in Drupal.settings.wysiwygEditor.plugins.tinymce) { + if (typeof Drupal.settings.wysiwygEditor.plugins.tinymce[plugin] == 'string') { + //tinymce.PluginManager.load(plugin, Drupal.settings.wysiwygEditor.plugins.tinymce[plugin] + '/editor_plugin.js'); + tinymce.PluginManager.load(plugin, Drupal.settings.wysiwygEditor.plugins.tinymce[plugin]); + } + else { + if (plugin == 'drupal') { + continue; + } + // Load plugin specific language pack. + // @todo + //tinymce.PluginManager.requireLangPack(plugin); + + var settings = Drupal.settings.wysiwygEditor.plugins.tinymce[plugin]; + + tinymce.create('tinymce.plugins.' + plugin, { + /** + * Initialize the plugin, executed after the plugin has been created. + * + * @param ed + * The tinymce.Editor instance the plugin is initialized in. + * @param url + * The absolute URL of the plugin location. + */ + init : function(ed, url) { + // Register the ImageAssist execCommand. + ed.addCommand(plugin, function() { + if (typeof Drupal.wysiwyg.plugins[plugin].invoke == 'function') { + Drupal.wysiwyg.plugins[plugin].invoke(ed.selection.getNode(), Drupal.settings.wysiwygEditor.plugins.tinymce[plugin], ed.id); + } + // @todo + if (0) { + ed.windowManager.open({ + // @todo Token replacement for passing parameters like editor + // instance id required? + file : BASE_URL + 'index.php?q=' + settings.dialogPath, + width : settings.width + parseInt(ed.getLang(plugin + '.delta_width', 0)), + height : settings.height + parseInt(ed.getLang(plugin + '.delta_height', 0)), + inline : settings.inline + }, data); + } + }); + + // Register Image Assist button. + ed.addButton(plugin, { + title : settings.title, + cmd : plugin, + image : settings.icon + }); + + // Load Image Assist's CSS for editor contents on startup. + ed.onInit.add(function() { + if (settings.css) { + ed.dom.loadCSS(settings.css); + } + }); + + // Attach: Replace inline tags in data.content with images. + ed.onBeforeSetContent.add(function(ed, data) { + if (typeof Drupal.wysiwyg.plugins[plugin].attach == 'function') { + data.content = Drupal.wysiwyg.plugins[plugin].attach(data.content, settings, ed.id); + } + }); + + // Detach: Replace images with inline tags in editor contents upon data.save. + ed.onBeforeGetContent.add(function(ed, data) { + if (!data.save) { + return; + } + console.log(typeof data, typeof data.content); + console.log(data, data.content); + for (var key in data) console.log(key); + if (data.content && typeof Drupal.wysiwyg.plugins[plugin].detach == 'function') { + console.log(data); + data.content = Drupal.wysiwyg.plugins[plugin].detach(data.content, settings, ed.id); + } + return data; + }); + + // Add a node change handler, selects the button in the UI when an image is selected. + ed.onNodeChange.add(function(ed, command, node) { + if (typeof Drupal.wysiwyg.plugins[plugin].isNode == 'function') { + command.setActive(plugin, Drupal.wysiwyg.plugins[plugin].isNode(node)); + } + }); + }, + + /** + * Return information about the plugin as a name/value array. + */ + getInfo : function() { + return { + longname : settings.title + }; + } + }); + + // Register plugin. + tinymce.PluginManager.add(plugin, tinymce.plugins[plugin]); + } + } for (var theme in editorSettings) { // Clone, so original settings are not overwritten. var config = Drupal.wysiwyg.clone(editorSettings[theme]); tinyMCE.init(config); } - // @todo Move into global library settings. - for (var plugin in Drupal.settings.wysiwygEditor.plugins.tinymce) { - tinymce.PluginManager.load(plugin, Drupal.settings.wysiwygEditor.plugins.tinymce[plugin] + '/editor_plugin.js'); - } -} +}; /** * Attach this editor to a target element. * - * See Drupal.wysiwyg.attach.none() for a full desciption of this hook. + * See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook. */ -Drupal.wysiwyg.attach.tinymce = function(context, params, editorSettings) { +Drupal.wysiwyg.editor.attach.tinymce = function(context, params, editorSettings) { // Configure settings for this theme. for (var setting in editorSettings[params.theme]) { tinyMCE.settings[setting] = editorSettings[params.theme][setting]; @@ -45,14 +141,14 @@ Drupal.wysiwyg.attach.tinymce = function if (Drupal.settings.wysiwygEditor.status) { tinyMCE.execCommand('mceAddControl', true, params.field); } -} +}; /** * Detach a single or all editors. * - * See Drupal.wysiwyg.detach.none() for a full desciption of this hook. + * See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook. */ -Drupal.wysiwyg.detach.tinymce = function(context, params) { +Drupal.wysiwyg.editor.detach.tinymce = function(context, params) { if (typeof params != 'undefined') { var editor = tinyMCE.get(params.field); if (editor) { @@ -64,5 +160,17 @@ Drupal.wysiwyg.detach.tinymce = function tinyMCE.triggerSave(); tinyMCE.activeEditor.remove(); } -} +}; + +Drupal.wysiwyg.editor.invoke.tinymce = { + open: function () { + }, + close: function () { + tinyMCEPopup.close(); + }, + insert: function (instanceId, content) { + var editor = tinyMCE.get(instanceId); + editor.execCommand('mceInsertContent', false, content); + } +}; Index: plugins/break.inc =================================================================== RCS file: plugins/break.inc diff -N plugins/break.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ plugins/break.inc 10 Oct 2008 17:42:05 -0000 @@ -0,0 +1,20 @@ + t('Teaser break') . ' NEW!', + 'vendor url' => 'http://drupal.org/project/wysiwyg', + 'icon file' => 'break.gif', + // TEMP 10/10/2008 sun + 'buttons' => array('break' => t('Teaser break') . ' NEW!'), + 'internal' => TRUE, + ); + return $plugins; +} + Index: plugins/break/break.js =================================================================== RCS file: plugins/break/break.js diff -N plugins/break/break.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ plugins/break/break.js 11 Oct 2008 03:43:19 -0000 @@ -0,0 +1,37 @@ +// $Id: editor_plugin.js 201 2008-02-12 15:56:56Z sun $ + +Drupal.wysiwyg.plugins.break = { + + // Return whether the passed node belongs to this plugin. + isNode: function(node) { + return ($(node).is('img') && $(node).attr('class') == 'wysiwyg-break'); + }, + + // Execute the button. + invoke: function(node, settings, instanceId) { + // Prevent duplicating a teaser break. + if ($(node).is('img') && $(node).attr('class') != 'wysiwyg-break') { + return; + } + var content = this._getPlaceholder(settings); + Drupal.wysiwyg.invoke.insert(instanceId, content); + }, + + // Replace all tags with images. + attach: function(content, settings, instanceId) { + content = content.replace(//g, this._getPlaceholder(settings)); + return content; + }, + + // Replace images with tags in editor contents upon data.save. + detach: function(content, settings, instanceId) { + console.log(arguments); + $(content).find('img.wysiwyg-break').replaceWith(''); + console.log(content); + return content; + }, + + _getPlaceholder: function (settings) { + return '<--break->'; + } +}; Index: plugins/break/images/spacer.gif =================================================================== RCS file: plugins/break/images/spacer.gif diff -N plugins/break/images/spacer.gif Binary files /dev/null and spacer.gif differ