From 28781ebb081ab8d99b30a33f5cd911b3b050bcc9 Mon Sep 17 00:00:00 2001 From: donncha Date: Tue, 26 Sep 2006 15:45:20 +0000 Subject: WP Merge to rev 4254 git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@770 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- .../tinymce/plugins/autosave/editor_plugin_src.js | 30 +++++ wp-includes/js/tinymce/plugins/autosave/readme.txt | 1 + .../plugins/inlinepopups/editor_plugin_src.js | 0 .../js/tinymce/plugins/inlinepopups/readme.txt | 0 .../js/tinymce/plugins/wordpress/editor_plugin.js | 142 +++++++++++++++++++-- 5 files changed, 163 insertions(+), 10 deletions(-) create mode 100644 wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js create mode 100644 wp-includes/js/tinymce/plugins/autosave/readme.txt create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/readme.txt (limited to 'wp-includes/js/tinymce/plugins') diff --git a/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js new file mode 100644 index 0000000..102d69b --- /dev/null +++ b/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js @@ -0,0 +1,30 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('autosave', 'en,sv,cs,he,no,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,fi,cy,es,is,pl'); + +function TinyMCE_autosave_getInfo() { + return { + longname : 'Auto save', + author : 'Moxiecode Systems', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html', + version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion + }; +}; + +function TinyMCE_autosave_beforeUnloadHandler() { + var msg = tinyMCE.getLang("lang_autosave_unload_msg"); + + var anyDirty = false; + for (var n in tinyMCE.instances) { + var inst = tinyMCE.instances[n]; + if (!tinyMCE.isInstance(inst)) + continue; + + if (inst.isDirty()) + return msg; + } + + return; +} + +window.onbeforeunload = TinyMCE_autosave_beforeUnloadHandler; diff --git a/wp-includes/js/tinymce/plugins/autosave/readme.txt b/wp-includes/js/tinymce/plugins/autosave/readme.txt new file mode 100644 index 0000000..4fdb78a --- /dev/null +++ b/wp-includes/js/tinymce/plugins/autosave/readme.txt @@ -0,0 +1 @@ +Check the TinyMCE documentation for details on this plugin. diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js new file mode 100644 index 0000000..e69de29 diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/readme.txt b/wp-includes/js/tinymce/plugins/inlinepopups/readme.txt new file mode 100644 index 0000000..e69de29 diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js index 9a118f9..a596b83 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js @@ -38,9 +38,9 @@ var TinyMCE_wordpressPlugin = { + '' + '' + '' - + '' + '' - + '' + + '' + + '' + ''; return buttons+hiddenControls; case "wp_adv": @@ -241,18 +241,18 @@ var TinyMCE_wordpressPlugin = { // Remove anonymous, empty paragraphs. content = content.replace(new RegExp('

(\\s| )*

', 'mg'), ''); - + // Handle table badness. content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>'); content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>'); content = content.replace(new RegExp('.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '<$2>'); content = content.replace(new RegExp('.*?<(tr|/table)>', 'mg'), '<$1>'); content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(
)*)*', 'g'), '<$1>'); - + // Pretty it up for the source editor. var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p'; content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); - content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>\\s*', 'mg'), '\n<$1>'); + content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>', 'mg'), '\n<$1>'); content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>'); content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>'); content = content.replace(new RegExp('\\s*
\\s*', 'mg'), '
\n'); @@ -294,9 +294,9 @@ var TinyMCE_wordpressPlugin = { // content = content.replace(new RegExp('&', 'g'), '&'); // Get it ready for wpautop. - content = content.replace(new RegExp('[\\s]*

[\\s]*', 'mgi'), ''); - content = content.replace(new RegExp('[\\s]*

[\\s]*', 'mgi'), '\n\n'); - content = content.replace(new RegExp('\\n\\s*\\n\\s*\\n*', 'mgi'), '\n\n'); + content = content.replace(new RegExp('\\s*

', 'mgi'), ''); + content = content.replace(new RegExp('\\s*

\\s*', 'mgi'), '\n\n'); + content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n'); content = content.replace(new RegExp('\\s*
\\s*', 'gi'), '\n'); // Fix some block element newline issues @@ -309,8 +309,7 @@ var TinyMCE_wordpressPlugin = { content = content.replace(new RegExp('', 'g'), '

\n'); content = content.replace(new RegExp('\\s*(]+>.*

)', 'mg'), '\n$1'); - // Trim any whitespace - content = content.replace(new RegExp('^\\s*', ''), ''); + // Trim trailing whitespace content = content.replace(new RegExp('\\s*$', ''), ''); // Hope. @@ -468,3 +467,126 @@ tinyMCE.wpTriggerSave = function () { inst.wpTriggerSave(false, false); } } + +function switchEditors(id) { + var inst = tinyMCE.getInstanceById(id); + var qt = document.getElementById('quicktags'); + var H = document.getElementById('edButtonHTML'); + var P = document.getElementById('edButtonPreview'); + var ta = document.getElementById(id); + var pdr = ta.parentNode; + + if ( inst ) { + edToggle(H, P); + + if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) { + // IE rejects the later overflow assignment so we skip this step. + // Alternate code might be nice. Until then, IE reflows. + } else { + // Lock the fieldset's height to prevent reflow/flicker + pdr.style.height = pdr.clientHeight + 'px'; + pdr.style.overflow = 'hidden'; + } + + // Save the coords of the bottom right corner of the rich editor + var table = document.getElementById(inst.editorId + '_parent').getElementsByTagName('table')[0]; + var y1 = table.offsetTop + table.offsetHeight; + + if ( TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_height") == null ) { + var expires = new Date(); + expires.setTime(expires.getTime() + 3600000 * 24 * 30); + var offset = tinyMCE.isMSIE ? 1 : 2; + TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + inst.editorId + "_height", "" + (table.offsetHeight - offset), expires); + } + + // Unload the rich editor + inst.triggerSave(false, false); + htm = inst.formElement.value; + tinyMCE.removeMCEControl(id); + document.getElementById(id).value = htm; + --tinyMCE.idCounter; + + // Reveal Quicktags and textarea + qt.style.display = 'block'; + ta.style.display = 'inline'; + + // Set the textarea height to match the rich editor + y2 = ta.offsetTop + ta.offsetHeight; + ta.style.height = (ta.clientHeight + y1 - y2) + 'px'; + + // Tweak the widths + ta.parentNode.style.paddingRight = '2px'; + + if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) { + } else { + // Unlock the fieldset's height + pdr.style.height = 'auto'; + pdr.style.overflow = 'display'; + } + } else { + edToggle(P, H); + edCloseAllTags(); // :-( + + if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) { + } else { + // Lock the fieldset's height + pdr.style.height = pdr.clientHeight + 'px'; + pdr.style.overflow = 'hidden'; + } + + // Hide Quicktags and textarea + qt.style.display = 'none'; + ta.style.display = 'none'; + + // Tweak the widths + ta.parentNode.style.paddingRight = '0px'; + + // Load the rich editor with formatted html + if ( tinyMCE.isMSIE ) { + ta.value = wpautop(ta.value); + tinyMCE.addMCEControl(ta, id); + } else { + htm = wpautop(ta.value); + tinyMCE.addMCEControl(ta, id); + tinyMCE.getInstanceById(id).execCommand('mceSetContent', null, htm); + } + + if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) { + } else { + // Unlock the fieldset's height + pdr.style.height = 'auto'; + pdr.style.overflow = 'display'; + } + } +} + +function edToggle(A, B) { + A.className = 'edButtonFore'; + B.className = 'edButtonBack'; + + B.onclick = A.onclick; + A.onclick = null; +} + +function wpautop(pee) { + pee = pee + "\n\n"; + pee = pee.replace(new RegExp('
\\s*
', 'gi'), "\n\n"); + pee = pee.replace(new RegExp('(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)', 'gi'), "\n$1"); + pee = pee.replace(new RegExp('()', 'gi'), "$1\n\n"); + pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n"); + pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n"); + pee = pee.replace(new RegExp('\n*([^\Z]+?)\\n{2}', 'mg'), "

$1

\n"); + pee = pee.replace(new RegExp('

\\s*?

', 'gi'), ''); + pee = pee.replace(new RegExp('

\\s*(]*>)\\s*

', 'gi'), "$1"); + pee = pee.replace(new RegExp("

(", 'gi'), "$1"); + pee = pee.replace(new RegExp('

]*)>', 'gi'), "

"); + pee = pee.replace(new RegExp('

', 'gi'), '

'); + pee = pee.replace(new RegExp('

\\s*(]*>)', 'gi'), "$1"); + pee = pee.replace(new RegExp('(]*>)\\s*

', 'gi'), "$1"); + pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "
\n"); + pee = pee.replace(new RegExp('(]*>)\\s*
', 'gi'), "$1"); + pee = pee.replace(new RegExp('
(\\s*)', 'gi'), '$1'); + pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 '); + //pee = pee.replace(new RegExp('()(.*?)!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '' "); // Hmm... + return pee; +} -- cgit