commit d7ce38920127d8caf794d834dd5a5fd23e1d3709
parent 87d90e59d91ad2a0f4f76d15bcb597d3195fc825
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 30 Oct 2012 04:10:29 -0400
Compatibility updates for TinyMCE 3.5.7
3.5.7 seems to init before the DOMContentLoaded we were relying on
previously to add the init function gets called, so instead call a
fixed init function from the HTML that we insert before the load
from chrome.
Diffstat:
7 files changed, 93 insertions(+), 58 deletions(-)
diff --git a/chrome/content/zotero/bindings/styled-textbox.xml b/chrome/content/zotero/bindings/styled-textbox.xml
@@ -362,7 +362,7 @@
var matchTo = null;
var listener = function(e) {
var win = self._iframe.contentWindow;
- var SJOW = self._iframe.contentWindow.wrappedJSObject;
+ var SJOW = win.wrappedJSObject;
// only fire if the target matches, or _zoteroMatchTo, which we set last
// time the target matched, matches
@@ -386,6 +386,49 @@
return;
}
+ if (!SJOW.zoteroInit) {
+ SJOW.zoteroInit = function(editor) {
+ self._editor = editor;
+ if (self._value) {
+ self.value = self._value;
+ }
+ if (self._focus) {
+ self._iframe.focus();
+ self._editor.focus();
+ self._focus = false;
+ }
+
+ // Add CSS rules to notes
+ if (self.mode == 'note') {
+ var css = "body#zotero-tinymce-note.mceContentBody, "
+ + "body#zotero-tinymce-note.mceContentBody p, "
+ + "body#zotero-tinymce-note.mceContentBody th, "
+ + "body#zotero-tinymce-note.mceContentBody td, "
+ + "body#zotero-tinymce-note.mceContentBody pre { "
+ + "font-size: "
+ + Zotero.Prefs.get('note.fontSize') + "px; "
+ + "} "
+ + "body#zotero-tinymce-note.mceContentBody, "
+ + "body#zotero-tinymce-note.mceContentBody p { "
+ + "font-family: "
+ + Zotero.Prefs.get('note.fontFamily') + "; "
+ + "}"
+ + Zotero.Prefs.get('note.css');
+
+ var doc = editor.contentDocument;
+ var head = doc.getElementsByTagName("head")[0];
+ var style = doc.createElement("style");
+ style.innerHTML = css;
+ head.appendChild(style);
+ }
+
+ // Dispatch a tinymceInitialized event
+ var ev = document.createEvent('HTMLEvents');
+ ev.initEvent('tinymceInitialized', true, true);
+ self.dispatchEvent(ev);
+ };
+ }
+
var editor = SJOW.tinyMCE.get("tinymce");
if (!editor) {
Zotero.debug("editor not ready");
@@ -405,59 +448,16 @@
self._iframe.removeEventListener("DOMContentLoaded", listener, false);
}
- var onInitFunction = function() {
- self._editor = editor;
- if (self._value) {
- self.value = self._value;
- }
- if (self._focus) {
- self._iframe.focus();
- self._editor.focus();
- self._focus = false;
- }
-
- // Add CSS rules to notes
- if (self.mode == 'note') {
- var css = "body#zotero-tinymce-note.mceContentBody, "
- + "body#zotero-tinymce-note.mceContentBody p, "
- + "body#zotero-tinymce-note.mceContentBody th, "
- + "body#zotero-tinymce-note.mceContentBody td, "
- + "body#zotero-tinymce-note.mceContentBody pre { "
- + "font-size: "
- + Zotero.Prefs.get('note.fontSize') + "px; "
- + "} "
- + "body#zotero-tinymce-note.mceContentBody, "
- + "body#zotero-tinymce-note.mceContentBody p { "
- + "font-family: "
- + Zotero.Prefs.get('note.fontFamily') + "; "
- + "}"
- + Zotero.Prefs.get('note.css');
-
- var doc = editor.contentDocument;
- var head = doc.getElementsByTagName("head")[0];
- var style = doc.createElement("style");
- style.innerHTML = css;
- head.appendChild(style);
- }
-
- // Dispatch a tinymceInitialized event
- var ev = document.createEvent('HTMLEvents');
- ev.initEvent('tinymceInitialized', true, true);
- self.dispatchEvent(ev);
- };
- onInitFunction.__exposedProps__ = {"apply":"r"};
- editor.onInit.add(onInitFunction);
-
if (self._eventHandler) {
- self._iframe.contentWindow.wrappedJSObject.zoteroHandleEvent = self._eventHandler;
+ win.wrappedJSObject.zoteroHandleEvent = self._eventHandler;
}
// Run Cut/Copy/Paste with chrome privileges
- self._iframe.contentWindow.wrappedJSObject.zoteroExecCommand = function (doc, command, ui, value) {
+ win.wrappedJSObject.zoteroExecCommand = function (doc, command, ui, value) {
return doc.execCommand(command, ui, value);
}
- self._iframe.contentWindow.wrappedJSObject.zoteroFixWindow = function (win) {
+ win.wrappedJSObject.zoteroFixWindow = function (win) {
win.locationbar.visible = false;
win.statusbar.visible = false;
}
diff --git a/chrome/content/zotero/tinymce/note.html b/chrome/content/zotero/tinymce/note.html
@@ -1,6 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link type="text/css" rel="stylesheet" href="css/note-ui.css"/>
<script type="text/javascript;version=1.8" src="tiny_mce.js"></script>
<script type="text/javascript;version=1.8">
@@ -20,11 +21,14 @@
},
onchange_callback : function () {
- var event = { type: 'change' };
- zoteroHandleEvent(event);
+ zoteroHandleEvent({ type: 'change' });
},
setup : function (ed) {
+ ed.onInit.add(function (ed) {
+ zoteroInit(ed);
+ });
+
var commands = ["Cut", "Copy", "Paste"];
for each(var command in commands) {
let cmd = command;
@@ -44,6 +48,7 @@
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
+ theme_advanced_statusbar_location : "none",
// More restrictive version of default set, with JS/etc. removed
valid_elements : "@[id|class|style|title|dir<ltr?rtl|lang|xml::lang],"
diff --git a/chrome/content/zotero/tinymce/noteview.html b/chrome/content/zotero/tinymce/noteview.html
@@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
-<title>TinyMCE</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link type="text/css" rel="stylesheet" href="css/note-ui.css"/>
<style>
table.mceLayout {
@@ -28,7 +28,12 @@ table.mceLayout > tbody > tr.mceLast {
fix_list_elements : true,
fix_table_elements : true,
- /*plugins : "xhtmlxtras",*/
+
+ setup : function (ed) {
+ ed.onInit.add(function (ed) {
+ zoteroInit(ed);
+ });
+ },
// Theme options
theme_advanced_buttons1 : "",
@@ -36,6 +41,7 @@ table.mceLayout > tbody > tr.mceLast {
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
+ theme_advanced_statusbar_location : "none",
// More restrictive version of default set, with JS/etc. removed
valid_elements : "@[id|class|style|title|dir<ltr?rtl|lang|xml::lang],"
diff --git a/chrome/content/zotero/tinymce/themes/advanced/color_picker.htm b/chrome/content/zotero/tinymce/themes/advanced/color_picker.htm
@@ -1,6 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- Added by Dan S./Zotero -->
<title>{#advanced_dlg.colorpicker_title}</title>
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script type="text/javascript" src="../../utils/mctabs.js"></script>
diff --git a/chrome/content/zotero/tinymce/themes/advanced/link.htm b/chrome/content/zotero/tinymce/themes/advanced/link.htm
@@ -1,6 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- Added by Dan S./Zotero -->
<title>{#advanced_dlg.link_title}</title>
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script type="text/javascript" src="../../utils/mctabs.js"></script>
diff --git a/chrome/content/zotero/tinymce/themes/advanced/source_editor.htm b/chrome/content/zotero/tinymce/themes/advanced/source_editor.htm
@@ -1,5 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- Added by Dan S./Zotero -->
<title>{#advanced_dlg.code_title}</title>
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script type="text/javascript" src="js/source_editor.js"></script>
diff --git a/chrome/content/zotero/tinymce/tiny_mce.js b/chrome/content/zotero/tinymce/tiny_mce.js
@@ -1,4 +1,5 @@
-// FILE IS GENERATED BY COMBINING THE SOURCES IN THE "classes" DIRECTORY SO DON'T MODIFY THIS FILE DIRECTLY
+// Contains modifications by Dan S./Zotero
+
(function(win) {
var whiteSpaceRe = /^\s*|\s*$/g,
undef, isRegExpBroken = 'B'.replace(/A(.)|B/, '$1') === '$1';
@@ -591,7 +592,11 @@ tinymce.create('tinymce.util.Dispatcher', {
t.source = u;
return;
}
-
+
+ // Added by Dan S./Zotero
+ u = u.replace("jar:file", "jarfile");
+ u = u.replace("zotero@chnm.gmu.edu", "zotero.chnm.gmu.edu");
+
// Absolute path with no host, fake host and protocol
if (u.indexOf('/') === 0 && u.indexOf('//') !== 0)
u = (s.base_uri ? s.base_uri.protocol || 'http' : 'http') + '://mce_host' + u;
@@ -599,9 +604,15 @@ tinymce.create('tinymce.util.Dispatcher', {
// Relative path http:// or protocol relative //path
if (!/^[\w\-]*:?\/\//.test(u)) {
base_url = s.base_uri ? s.base_uri.path : new tinymce.util.URI(location.href).directory;
- u = ((s.base_uri && s.base_uri.protocol) || 'http') + '://mce_host' + t.toAbsPath(base_url, u);
+ // Modified by Dan S./Zotero
+ //u = ((s.base_uri && s.base_uri.protocol) || 'http') + '://mce_host' + t.toAbsPath(base_url, u);
+ u = s.base_uri.protocol + '://' + s.base_uri.path + '/' + u;
}
-
+
+ // Added by Dan S./Zotero
+ u = u.replace("jar:file", "jarfile");
+ u = u.replace("zotero@chnm.gmu.edu", "zotero.chnm.gmu.edu");
+
// Parse URL (Credits goes to Steave, http://blog.stevenlevithan.com/archives/parseuri)
u = u.replace(/@@/g, '(mce_at)'); // Zope 3 workaround, they use @@something
u = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(u);
@@ -609,8 +620,13 @@ tinymce.create('tinymce.util.Dispatcher', {
var s = u[i];
// Zope 3 workaround, they use @@something
- if (s)
+ if (s) {
s = s.replace(/\(mce_at\)/g, '@@');
+
+ // Modified by Dan S./Zotero
+ s = s.replace("jarfile", "jar:file");
+ s = s.replace("zotero.chnm.gmu.edu", "zotero@chnm.gmu.edu");
+ }
t[v] = s;
});
@@ -966,7 +982,9 @@ tinymce.create('static tinymce.util.XHR', {
function ready() {
if (!o.async || x.readyState == 4 || c++ > 10000) {
- if (o.success && c < 10000 && x.status == 200)
+ // Modified by Dan S./Zotero
+ //if (o.success && c < 10000 && x.status == 200)
+ if (o.success && c < 10000 && (x.status == 200 || x.status == 0))
o.success.call(o.success_scope, '' + x.responseText, x, o);
else if (o.error)
o.error.call(o.error_scope, c > 10000 ? 'TIMED_OUT' : 'GENERAL', x, o);
@@ -16309,7 +16327,10 @@ tinymce.ForceBlocks = function(editor) {
} catch (ex) {
// Ignore
}
-
+
+ // Added by Dan S./Zotero
+ zoteroFixWindow(w);
+
if (!w)
alert(t.editor.getLang('popup_blocked'));
},