X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/11be8dc178e77d0b46189bbd8e33a216a9b90942..HEAD:/wp-admin/js/editor.js
diff --git a/wp-admin/js/editor.js b/wp-admin/js/editor.js
index 935267a2..e3fbaab9 100644
--- a/wp-admin/js/editor.js
+++ b/wp-admin/js/editor.js
@@ -1,172 +1,386 @@
-var switchEditors = {
-
- mode : '',
-
- I : function(e) {
- return document.getElementById(e);
- },
-
- edInit : function() {
- var h = tinymce.util.Cookie.getHash("TinyMCE_content_size"), H = this.I('edButtonHTML'), P = this.I('edButtonPreview');
-
- // Activate TinyMCE if it's the user's default editor
- if ( getUserSetting( 'editor' ) == 'html' ) {
- if ( h )
- try { this.I('content').style.height = h.ch - 30 + 'px'; } catch(e){};
- } else {
- try {
- this.I("quicktags").style.display = "none";
- } catch(e){};
- tinyMCE.execCommand("mceAddControl", false, "content");
+( function( $ ) {
+ function SwitchEditors() {
+ var tinymce, $$,
+ exports = {};
+
+ function init() {
+ if ( ! tinymce && window.tinymce ) {
+ tinymce = window.tinymce;
+ $$ = tinymce.$;
+
+ $$( document ).on( 'click', function( event ) {
+ var id, mode,
+ target = $$( event.target );
+
+ if ( target.hasClass( 'wp-switch-editor' ) ) {
+ id = target.attr( 'data-wp-editor-id' );
+ mode = target.hasClass( 'switch-tmce' ) ? 'tmce' : 'html';
+ switchEditor( id, mode );
+ }
+ });
+ }
}
- },
-
- saveCallback : function(el, content, body) {
-
- if ( tinyMCE.activeEditor.isHidden() )
- content = this.I(el).value;
- else
- content = this.pre_wpautop(content);
-
- return content;
- },
-
- pre_wpautop : function(content) {
- // We have a TON of cleanup to do. Line breaks are already stripped.
-
- // Protect pre|script tags
- content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
- a = a.replace(/
[\r\n]*/g, '
]+>.*?)
', 'mg'), '$1'); - - // Sepatate- content = content.replace(new RegExp('
', 'mgi'), '
and
- 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*