From 7342aebe664c7deed6dd844ef188adbd65f24c9d Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 9 Dec 2015 16:16:45 -0500 Subject: [PATCH 1/2] Allow page to enable/disable previews via API calls (for use with editor previews, for example). --- unpacked/extensions/fast-preview.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/unpacked/extensions/fast-preview.js b/unpacked/extensions/fast-preview.js index a14a6d719..c71108205 100644 --- a/unpacked/extensions/fast-preview.js +++ b/unpacked/extensions/fast-preview.js @@ -33,6 +33,7 @@ var FastPreview = MathJax.Extension["fast-preview"] = { version: "2.6.0-beta", + enabled: true, // // Configuration for the chunking of the main output @@ -62,7 +63,7 @@ HUB.Config({"HTML-CSS": config.Chunks, CommonHTML: config.Chunks, SVG: config.Chunks}); } HUB.Register.MessageHook("Begin Math Output",function () { - if (!done && SETTINGS.FastPreview && SETTINGS.renderer !== "PreviewHTML") { + if (!done && SETTINGS.FastPreview && this.enabled && SETTINGS.renderer !== "PreviewHTML") { update = HUB.processUpdateTime; delay = HUB.processUpdateDelay; style = HUB.config.messageStyle; HUB.processUpdateTime = config.updateTime; @@ -81,13 +82,19 @@ } }); }, + + // + // Allow page to override user settings (for things like editor previews) + // + Disable: function () {this.enabled = false}, + Enable: function () {this.enabled = true}, // // Insert a preview span, if there isn't one already, // and call the PreviewHTML output jax to create the preview // Preview: function (data) { - if (!SETTINGS.FastPreview || SETTINGS.renderer === "PreviewHTML") return; + if (!SETTINGS.FastPreview || !this.enabled || SETTINGS.renderer === "PreviewHTML") return; var preview = data.script.MathJax.preview || data.script.previousSibling; if (!preview || preview.className !== MathJax.Hub.config.preRemoveClass) { preview = HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass}); From 59736941161cc73d03c546fe54b8b96a9e2c28dd Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 9 Dec 2015 16:26:41 -0500 Subject: [PATCH 2/2] Make a flag for output jax to control fast preview (so we don't have to maintain a blakc-list here). --- unpacked/extensions/fast-preview.js | 10 ++++++++-- unpacked/jax/output/PreviewHTML/config.js | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/unpacked/extensions/fast-preview.js b/unpacked/extensions/fast-preview.js index c71108205..2d64959ea 100644 --- a/unpacked/extensions/fast-preview.js +++ b/unpacked/extensions/fast-preview.js @@ -29,6 +29,7 @@ (function (HUB,HTML,BROWSER) { var SETTINGS = HUB.config.menuSettings; + var JAX = MathJax.OutputJax; var msieColorBug = BROWSER.isMSIE && (document.documentMode||0) < 8; var FastPreview = MathJax.Extension["fast-preview"] = { @@ -63,7 +64,7 @@ HUB.Config({"HTML-CSS": config.Chunks, CommonHTML: config.Chunks, SVG: config.Chunks}); } HUB.Register.MessageHook("Begin Math Output",function () { - if (!done && SETTINGS.FastPreview && this.enabled && SETTINGS.renderer !== "PreviewHTML") { + if (!done && FastPreview.Active()) { update = HUB.processUpdateTime; delay = HUB.processUpdateDelay; style = HUB.config.messageStyle; HUB.processUpdateTime = config.updateTime; @@ -88,13 +89,18 @@ // Disable: function () {this.enabled = false}, Enable: function () {this.enabled = true}, + + Active: function () { + return SETTINGS.FastPreview && this.enabled && + !(JAX[SETTINGS.renderer]||{}).noFastPreview; + }, // // Insert a preview span, if there isn't one already, // and call the PreviewHTML output jax to create the preview // Preview: function (data) { - if (!SETTINGS.FastPreview || !this.enabled || SETTINGS.renderer === "PreviewHTML") return; + if (!this.Active()) return; var preview = data.script.MathJax.preview || data.script.previousSibling; if (!preview || preview.className !== MathJax.Hub.config.preRemoveClass) { preview = HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass}); diff --git a/unpacked/jax/output/PreviewHTML/config.js b/unpacked/jax/output/PreviewHTML/config.js index 822f077fa..ddfe33bc7 100644 --- a/unpacked/jax/output/PreviewHTML/config.js +++ b/unpacked/jax/output/PreviewHTML/config.js @@ -30,6 +30,7 @@ MathJax.OutputJax.PreviewHTML = MathJax.OutputJax({ version: "2.6.0-beta", directory: MathJax.OutputJax.directory + "/PreviewHTML", extensionDir: MathJax.OutputJax.extensionDir + "/PreviewHTML", + noFastPreview: true, // don't do fast preview for this output jax config: { scale: 100, minScaleAdjust: 50, // global math scaling factor, and minimum adjusted scale factor