Load TinyMCE as chrome to avoid NoScript blockage

This commit is contained in:
Dan Stillman 2008-10-27 16:39:18 +00:00
parent 11b05a5a41
commit 8070a22d08
5 changed files with 16 additions and 16 deletions

View file

@ -249,17 +249,14 @@
var ios = Components.classes["@mozilla.org/network/io-service;1"]. var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService); getService(Components.interfaces.nsIIOService);
var uri = ios.newURI("chrome://zotero/content/tinymce/" + htmlFile + ".html", null, null); var uri = ios.newURI("chrome://zotero/content/tinymce/" + htmlFile + ".html", null, null);
var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"].
getService(Components.interfaces.nsIChromeRegistry);
var fileURI = chromeReg.convertChromeURL(uri);
Zotero.debug("Loading " + fileURI.spec); Zotero.debug("Loading " + uri.spec);
// Register handler for deferred setting of content // Register handler for deferred setting of content
var self = this; var self = this;
var listener = function() { var listener = function() {
self._iframe.removeEventListener("DOMContentLoaded", listener, false); self._iframe.removeEventListener("DOMContentLoaded", listener, false);
var editor = self._iframe.contentWindow.wrappedJSObject.tinyMCE.get("tinymce"); var editor = self._iframe.contentWindow.tinyMCE.get("tinymce");
editor.onInit.add(function() { editor.onInit.add(function() {
self._editor = editor; self._editor = editor;
@ -269,13 +266,12 @@
}); });
if (self._eventHandler) { if (self._eventHandler) {
self._iframe.contentWindow.wrappedJSObject.handleEvent = self._eventHandler; self._iframe.contentWindow.handleEvent = self._eventHandler;
} }
}; };
this._iframe.addEventListener("DOMContentLoaded", listener, false); this._iframe.addEventListener("DOMContentLoaded", listener, false);
Zotero.debug("Loading " + fileURI.spec); this._iframe.webNavigation.loadURI(uri.spec,
this._iframe.webNavigation.loadURI(fileURI.spec,
Components.interfaces.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY, null, null, null); Components.interfaces.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY, null, null, null);
]]> ]]>
</body> </body>
@ -284,7 +280,7 @@
</implementation> </implementation>
<content> <content>
<xul:iframe flex="1" anonid="rt-view" class="rt-view" type="content" <xul:iframe flex="1" anonid="rt-view" class="rt-view"
xbl:inherits="onfocus,onblur,flex,width,height,hidden" xbl:inherits="onfocus,onblur,flex,width,height,hidden"
style="overflow: hidden"/> style="overflow: hidden"/>
</content> </content>

View file

@ -26,7 +26,7 @@ html, body {
// General options // General options
mode : "none", mode : "none",
theme : "advanced", theme : "advanced",
content_css : "../../../skin/default/zotero/tinymce/integration-content.css", content_css : "chrome://zotero/skin/tinymce/integration-content.css",
// Theme options // Theme options
theme_advanced_buttons1 : "bold,italic,underline,|,sub,sup,|,removeformat", theme_advanced_buttons1 : "bold,italic,underline,|,sub,sup,|,removeformat",

View file

@ -2,14 +2,14 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>TinyMCE</title> <title>TinyMCE</title>
<link type="text/css" rel="stylesheet" href="../../../skin/default/zotero/tinymce/note-ui.css"/> <link type="text/css" rel="stylesheet" href="chrome://zotero/skin/tinymce/note-ui.css"/>
<script type="text/javascript" src="tiny_mce.js"></script> <script type="text/javascript" src="tiny_mce.js"></script>
<script type="text/javascript"> <script type="text/javascript">
tinyMCE.init({ tinyMCE.init({
// General options // General options
mode : "none", mode : "none",
theme : "advanced", theme : "advanced",
content_css : "../../../skin/default/zotero/tinymce/note-content.css", content_css : "chrome://zotero/skin/tinymce/note-content.css",
button_tile_map : true, button_tile_map : true,
language : "en", // TODO: localize language : "en", // TODO: localize
entity_encoding : "raw", entity_encoding : "raw",

View file

@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>TinyMCE</title> <title>TinyMCE</title>
<link type="text/css" rel="stylesheet" href="../../../skin/default/zotero/tinymce/note-ui.css"/> <link type="text/css" rel="stylesheet" href="chrome://zotero/skin/tinymce/note-ui.css"/>
<style> <style>
table.mceLayout > tbody > tr.mceLast { table.mceLayout > tbody > tr.mceLast {
top: 0; top: 0;
@ -14,7 +14,7 @@ table.mceLayout > tbody > tr.mceLast {
// General options // General options
mode : "none", mode : "none",
theme : "advanced", theme : "advanced",
content_css : "../../../skin/default/zotero/tinymce/note-content.css", content_css : "chrome://zotero/skin/tinymce/note-content.css",
button_tile_map : true, button_tile_map : true,
language : "en", // TODO: localize language : "en", // TODO: localize
entity_encoding : "raw", entity_encoding : "raw",

View file

@ -6311,8 +6311,12 @@ tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', {
tinymce.EditorManager.baseURI = new tinymce.util.URI(tinymce.baseURL); tinymce.EditorManager.baseURI = new tinymce.util.URI(tinymce.baseURL);
// User already specified a document.domain value // User already specified a document.domain value
if (document.domain && lo.hostname != document.domain) // try/catch added by Dan S./Zotero
tinymce.relaxedDomain = document.domain; try {
if (document.domain && lo.hostname != document.domain)
tinymce.relaxedDomain = document.domain;
}
catch (e) {}
// Setup document domain if tinymce is loaded from other domain // Setup document domain if tinymce is loaded from other domain
if (!tinymce.relaxedDomain && tinymce.EditorManager.baseURI.host != lo.hostname && lo.hostname) if (!tinymce.relaxedDomain && tinymce.EditorManager.baseURI.host != lo.hostname && lo.hostname)