mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09:52 +08:00
MathJaxPreview: fix preview while using local mathjax
This commit is contained in:
parent
b49d5a968f
commit
22489137ae
@ -1041,6 +1041,7 @@ VMarkdownTab::VMarkdownTab(QWidget *p_parent)
|
||||
m_mathjaxConfigEdit = new VLineEdit();
|
||||
m_mathjaxConfigEdit->setToolTip(tr("Location of MathJax JavaScript and its configuration "
|
||||
"(restart VNote to make it work in in-place preview)"));
|
||||
m_mathjaxConfigEdit->setPlaceholderText(tr("Need to prepend \"file://\" to local path"));
|
||||
|
||||
// PlantUML.
|
||||
m_plantUMLModeCombo = VUtils::getComboBox();
|
||||
|
@ -908,8 +908,9 @@ with 2em, if there are Chinese characters in it, the font will be a mess.
|
||||
|
||||
QString VUtils::generateMathJaxPreviewTemplate()
|
||||
{
|
||||
QString mj = g_config->getMathjaxJavascript();
|
||||
QString templ = VNote::generateMathJaxPreviewTemplate();
|
||||
templ.replace(HtmlHolder::c_JSHolder, g_config->getMathjaxJavascript());
|
||||
templ.replace(HtmlHolder::c_JSHolder, mj);
|
||||
|
||||
QString extraFile;
|
||||
|
||||
|
@ -67,7 +67,6 @@ void VDocument::setHtml(const QString &html)
|
||||
void VDocument::setLog(const QString &p_log)
|
||||
{
|
||||
qDebug() << "JS:" << p_log;
|
||||
emit logChanged(p_log);
|
||||
}
|
||||
|
||||
void VDocument::keyPressEvent(int p_key, bool p_ctrl, bool p_shift, bool p_meta)
|
||||
|
@ -139,8 +139,6 @@ signals:
|
||||
|
||||
void htmlChanged(const QString &html);
|
||||
|
||||
void logChanged(const QString &p_log);
|
||||
|
||||
void keyPressed(int p_key, bool p_ctrl, bool p_shift, bool p_meta);
|
||||
|
||||
void requestHighlightText(const QString &p_text, int p_id, unsigned long long p_timeStamp);
|
||||
|
@ -5,6 +5,9 @@
|
||||
|
||||
#include "utils/vutils.h"
|
||||
#include "vmathjaxwebdocument.h"
|
||||
#include "vconfigmanager.h"
|
||||
|
||||
extern VConfigManager *g_config;
|
||||
|
||||
VMathJaxPreviewHelper::VMathJaxPreviewHelper(QWidget *p_parentWidget, QObject *p_parent)
|
||||
: QObject(p_parent),
|
||||
@ -67,7 +70,8 @@ void VMathJaxPreviewHelper::doInit()
|
||||
|
||||
// setHtml() will change focus if it is not disabled.
|
||||
m_webView->setEnabled(false);
|
||||
m_webView->setHtml(VUtils::generateMathJaxPreviewTemplate(), QUrl("qrc:/resources"));
|
||||
QUrl baseUrl(QUrl::fromLocalFile(g_config->getDocumentPathOrHomePath() + QDir::separator()));
|
||||
m_webView->setHtml(VUtils::generateMathJaxPreviewTemplate(), baseUrl);
|
||||
m_webView->setEnabled(true);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "vmathjaxwebdocument.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
VMathJaxWebDocument::VMathJaxWebDocument(QObject *p_parent)
|
||||
: QObject(p_parent)
|
||||
{
|
||||
@ -44,3 +46,9 @@ void VMathJaxWebDocument::previewDiagram(int p_identifier,
|
||||
p_lang,
|
||||
p_text);
|
||||
}
|
||||
|
||||
void VMathJaxWebDocument::setLog(const QString &p_log)
|
||||
{
|
||||
qDebug() << "JS:" << p_log;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@ public slots:
|
||||
const QString &p_format,
|
||||
const QString &p_data);
|
||||
|
||||
void setLog(const QString &p_log);
|
||||
|
||||
signals:
|
||||
void requestPreviewMathJax(int p_identifier,
|
||||
int p_id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user