mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
web: fix finishLogics() bug
Treat MathJax as an async job.
This commit is contained in:
parent
a0b032ddfc
commit
a5e64696ea
@ -14,7 +14,8 @@ marked.setOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
var updateHtml = function(html) {
|
var updateHtml = function(html) {
|
||||||
asyncJobsCount = 0;
|
// There is at least one async job for MathJax.
|
||||||
|
asyncJobsCount = 1;
|
||||||
|
|
||||||
contentDiv.innerHTML = html;
|
contentDiv.innerHTML = html;
|
||||||
|
|
||||||
@ -84,10 +85,10 @@ var updateHtml = function(html) {
|
|||||||
MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
|
MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
content.setLog("err: " + err);
|
content.setLog("err: " + err);
|
||||||
finishLogics();
|
finishOneAsyncJob();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finishLogics();
|
finishOneAsyncJob();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -126,7 +126,8 @@ var updateText = function(text) {
|
|||||||
text = "[TOC]\n\n" + text;
|
text = "[TOC]\n\n" + text;
|
||||||
}
|
}
|
||||||
|
|
||||||
asyncJobsCount = 0;
|
// There is at least one async job for MathJax.
|
||||||
|
asyncJobsCount = 1;
|
||||||
metaDataText = null;
|
metaDataText = null;
|
||||||
|
|
||||||
var needToc = mdHasTocSection(text);
|
var needToc = mdHasTocSection(text);
|
||||||
@ -149,10 +150,10 @@ var updateText = function(text) {
|
|||||||
MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
|
MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
content.setLog("err: " + err);
|
content.setLog("err: " + err);
|
||||||
finishLogics();
|
finishOneAsyncJob();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finishLogics();
|
finishOneAsyncJob();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1276,7 +1276,7 @@ var postProcessMathJax = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finishLogics();
|
finishOneAsyncJob();
|
||||||
};
|
};
|
||||||
|
|
||||||
function getNodeText(el) {
|
function getNodeText(el) {
|
||||||
|
@ -50,7 +50,8 @@ var updateText = function(text) {
|
|||||||
text = "[TOC]\n\n" + text;
|
text = "[TOC]\n\n" + text;
|
||||||
}
|
}
|
||||||
|
|
||||||
asyncJobsCount = 0;
|
// There is at least one async job for MathJax.
|
||||||
|
asyncJobsCount = 1;
|
||||||
|
|
||||||
var needToc = mdHasTocSection(text);
|
var needToc = mdHasTocSection(text);
|
||||||
var html = markdownToHtml(text, needToc);
|
var html = markdownToHtml(text, needToc);
|
||||||
@ -71,10 +72,10 @@ var updateText = function(text) {
|
|||||||
MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
|
MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
content.setLog("err: " + err);
|
content.setLog("err: " + err);
|
||||||
finishLogics();
|
finishOneAsyncJob();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finishLogics();
|
finishOneAsyncJob();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,7 +89,8 @@ var updateText = function(text) {
|
|||||||
text = "[TOC]\n\n" + text;
|
text = "[TOC]\n\n" + text;
|
||||||
}
|
}
|
||||||
|
|
||||||
asyncJobsCount = 0;
|
// There is at least one async job for MathJax.
|
||||||
|
asyncJobsCount = 1;
|
||||||
|
|
||||||
var needToc = mdHasTocSection(text);
|
var needToc = mdHasTocSection(text);
|
||||||
var html = markdownToHtml(text, needToc);
|
var html = markdownToHtml(text, needToc);
|
||||||
@ -116,10 +117,10 @@ var updateText = function(text) {
|
|||||||
MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
|
MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentDiv, postProcessMathJax]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
content.setLog("err: " + err);
|
content.setLog("err: " + err);
|
||||||
finishLogics();
|
finishOneAsyncJob();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finishLogics();
|
finishOneAsyncJob();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -823,6 +823,10 @@ QString VUtils::generateExportHtmlTemplate(const QString &p_renderBg, bool p_inc
|
|||||||
"SVG: {\n"
|
"SVG: {\n"
|
||||||
"minScaleAdjust: 100,\n"
|
"minScaleAdjust: 100,\n"
|
||||||
"styles: {\n"
|
"styles: {\n"
|
||||||
|
/*
|
||||||
|
FIXME: Using wkhtmltopdf, without 2em, the math formula will be very small. However,
|
||||||
|
with 2em, if there are Chinese characters in it, the font will be a mess.
|
||||||
|
*/
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
"\".MathJax_SVG\": {\n"
|
"\".MathJax_SVG\": {\n"
|
||||||
"\"font-size\": \"2em !important\"\n"
|
"\"font-size\": \"2em !important\"\n"
|
||||||
|
@ -121,7 +121,7 @@ void VDocument::setFile(const VFile *p_file)
|
|||||||
|
|
||||||
void VDocument::finishLogics()
|
void VDocument::finishLogics()
|
||||||
{
|
{
|
||||||
qDebug() << "Web side finished logics";
|
qDebug() << "Web side finished logics" << this;
|
||||||
emit logicsFinished();
|
emit logicsFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user