From d9c8d0818aad8d27c158203053d0198b1ff28caf Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 9 Dec 2005 19:24:14 +0000 Subject: [PATCH] MCE fix-em-ups from skeltoac. fixes #1962 git-svn-id: https://develop.svn.wordpress.org/trunk@3283 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/admin-functions.php | 48 +++++++++++++++++++--- wp-admin/admin-header.php | 11 +++-- wp-admin/edit-form-advanced.php | 18 +++------ wp-admin/edit-form-comment.php | 42 +++++++++++++++++--- wp-admin/edit-page-form.php | 43 ++++++++++++++++---- wp-admin/inline-uploading.php | 64 +++++++++++++++++++++--------- wp-admin/wp-admin.css | 4 +- wp-includes/js/quicktags.js | 2 +- wp-includes/js/tinymce/tiny_mce.js | 4 +- 9 files changed, 178 insertions(+), 58 deletions(-) diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index b587c4bbff..1981990803 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -1077,13 +1077,39 @@ function save_mod_rewrite_rules() { function the_quicktags() { // Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Safari')) - : echo ' -
+ echo ' +
- - '; - echo '
'; - endif; + +
+'; + else echo ' + +'; } function validate_current_theme() { @@ -1801,4 +1827,14 @@ function wp_import_handle_upload() { return array('file' => $file, 'id' => $id); } +function user_can_richedit() { + if ( 'true' != get_user_option('rich_editing') ) + return false; + + if ( preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) ) + return false; + + return true; // Best guess +} + ?> diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index f665b7d130..882f149d08 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -79,11 +79,13 @@ addLoadEvent(blurry); - - - - diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php index d9a301e82c..fb72058f49 100644 --- a/wp-admin/edit-form-comment.php +++ b/wp-admin/edit-form-comment.php @@ -4,7 +4,6 @@ $toprow_title = sprintf(__('Editing Comment # %s'), $comment->comment_ID); $form_action = 'editedcomment'; $form_extra = "' />\n\n
@@ -32,13 +31,13 @@ addLoadEvent(focusit);
- +
- + -
+
- -

diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php index ec625cab23..66e029ee95 100644 --- a/wp-admin/edit-page-form.php +++ b/wp-admin/edit-page-form.php @@ -20,8 +20,6 @@ $sendto = wp_specialchars( $sendto ); ?> - - -

+
- + -
+
- -

diff --git a/wp-admin/inline-uploading.php b/wp-admin/inline-uploading.php index 7da2498588..6262fa6319 100644 --- a/wp-admin/inline-uploading.php +++ b/wp-admin/inline-uploading.php @@ -150,6 +150,7 @@ if ( $start > 0 ) { $uwidth_sum = 0; $html = ''; +$popups = ''; $style = ''; $script = ''; if ( count($attachments) > 0 ) { @@ -162,6 +163,7 @@ if ( count($attachments) > 0 ) { $__using_thumbnail = __('Using Thumbnail'); $__using_original = __('Using Original'); $__no_thumbnail = ''.__('No Thumbnail').''; + $__send_to_editor = __('Send to editor'); $__close = __('Close Options'); $__confirmdelete = __('Delete this file from the server?'); $__nothumb = __('There is no thumbnail associated with this photo.'); @@ -190,7 +192,8 @@ var srcb = new Array(); add_post_meta($ID, '_wp_attachment_metadata', $meta); } $attachment = array_merge($attachment, $meta); - $delete_cancel = "$__delete + $send_delete_cancel = "$__send_to_editor +$__delete $__close "; $uwidth_sum += 128; @@ -219,30 +222,32 @@ imga[{$ID}] = '\"{$image['post_title']}\'; "; $html .= "

-
\"{$image['post_title']}\"
+"; + $popups .= " "; } else { - $script .= "a{$ID}a = '{$attachment['post_title']}'; -a{$ID}b = '{$attachment['post_title']}'; + $script .= "aa[{$ID}] = '{$attachment['post_title']}'; +ab[{$ID}] = '{$attachment['post_title']}'; "; $html .= "
-
+"; + $popups .= " "; } } @@ -278,13 +283,14 @@ function doPopup(i) { target = document.getElementById('target'+i); popup = document.getElementById('popup'+i); popup.style.left = (target.offsetLeft) + 'px'; + popup.style.top = (target.offsetTop) + 'px'; popup.style.display = 'block'; } -function init() { - popup = false; -} +popup = false; function selectLink(n) { o=document.getElementById('div'+n); + if ( typeof document.body.createTextRange == 'undefined' || typeof win.tinyMCE == 'undefined' || win.tinyMCE.configs.length < 1 ) + return; r = document.body.createTextRange(); if ( typeof r != 'undefined' ) { r.moveToElementText(o); @@ -333,6 +339,24 @@ function toggleImage(n) { oi.innerHTML = usingthumbnail; } } + +var win = window.opener ? window.opener : window.dialogArguments; +if (!win) win = top; +tinyMCE = win.tinyMCE; +richedit = ( typeof tinyMCE == 'object' && tinyMCE.configs.length > 0 ); +function sendToEditor(n) { + o = document.getElementById('div'+n); + h = o.innerHTML.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // Trim + h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)', 'g'), ' $1="$2"$3'); // Enclose attribs in quotes + h = h.replace(new RegExp(' on(click|mousedown)="[^"]*"', 'g'), ''); // Drop menu events + h = h.replace(new RegExp('<(/?)A', 'g'), '<$1a'); // Lowercase tagnames + h = h.replace(new RegExp('', 'g'), '$1 />'); // XHTML + if ( richedit ) + win.tinyMCE.execCommand('mceInsertContent', false, h); + else + win.edInsertContent(win.edCanvas, h); +} - +
    > get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post'") ) { ?> @@ -521,9 +546,10 @@ form {
-
+
+
diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index 06ac711136..88619565c5 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -1,7 +1,9 @@ * html #poststuff { height: 100%; /* kill peekaboo bug in IE */ } - +body { + border: none; +} a { border-bottom: 1px solid #69c; color: #00019b; diff --git a/wp-includes/js/quicktags.js b/wp-includes/js/quicktags.js index 7f4d7a3763..be628e0740 100644 --- a/wp-includes/js/quicktags.js +++ b/wp-includes/js/quicktags.js @@ -386,4 +386,4 @@ function edInsertImage(myField) { + '" />'; edInsertContent(myField, myValue); } -} \ No newline at end of file +} diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js index babc33533f..27ce403ef8 100644 --- a/wp-includes/js/tinymce/tiny_mce.js +++ b/wp-includes/js/tinymce/tiny_mce.js @@ -5526,7 +5526,7 @@ TinyMCEControl.prototype.execCommand = function(command, user_interface, value) case "mceInsertContent": var insertHTMLFailed = false; this.getWin().focus(); - +/* WP if (tinyMCE.isGecko || tinyMCE.isOpera) { try { // Is plain text or HTML @@ -5560,7 +5560,7 @@ TinyMCEControl.prototype.execCommand = function(command, user_interface, value) return; } } - +*/ // Ugly hack in Opera due to non working "inserthtml" if (tinyMCE.isOpera && insertHTMLFailed) { this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL);