mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
support for local image in markdown
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
7bce2cb298
commit
5ff4382f90
@ -2,9 +2,9 @@
|
||||
<html lang="en">
|
||||
<meta charset="utf-8">
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="markdown.css">
|
||||
<script src="../utils/marked/marked.min.js"></script>
|
||||
<script src="qwebchannel.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="CSS_PLACE_HOLDER">
|
||||
<script src="qrc:/utils/marked/marked.min.js"></script>
|
||||
<script src="qrc:/resources/qwebchannel.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="placeholder"></div>
|
||||
|
@ -169,7 +169,7 @@ void VEditor::setupMarkdownPreview()
|
||||
QWebChannel *channel = new QWebChannel(this);
|
||||
channel->registerObject(QStringLiteral("content"), &document);
|
||||
page->setWebChannel(channel);
|
||||
webPreviewer->setUrl(QUrl(VNote::templateUrl));
|
||||
webPreviewer->setHtml(VNote::templateHtml, QUrl::fromLocalFile(noteFile->path + QDir::separator()));
|
||||
|
||||
addWidget(webPreviewer);
|
||||
}
|
||||
|
13
vnote.cpp
13
vnote.cpp
@ -8,11 +8,22 @@ const QString VNote::appName = QString("VNote");
|
||||
const QString VNote::welcomePagePath = QString(":/resources/welcome.html");
|
||||
const QString VNote::preTemplatePath = QString(":/resources/pre_template.html");
|
||||
const QString VNote::postTemplatePath = QString(":/resources/post_template.html");
|
||||
const QString VNote::templateUrl = QString("qrc:/resources/template.html");
|
||||
const QString VNote::templatePath = QString(":/resources/template.html");
|
||||
const QString VNote::defaultCssUrl = QString("qrc:/resources/markdown.css");
|
||||
|
||||
QString VNote::templateHtml;
|
||||
QString VNote::cssUrl = VNote::defaultCssUrl;
|
||||
|
||||
VNote::VNote()
|
||||
: curNotebookIndex(0)
|
||||
{
|
||||
decorateTemplate();
|
||||
}
|
||||
|
||||
void VNote::decorateTemplate()
|
||||
{
|
||||
templateHtml = VUtils::readFileFromDisk(templatePath);
|
||||
templateHtml.replace("CSS_PLACE_HOLDER", cssUrl);
|
||||
}
|
||||
|
||||
void VNote::readGlobalConfig()
|
||||
|
10
vnote.h
10
vnote.h
@ -17,10 +17,14 @@ public:
|
||||
int getCurNotebookIndex() const;
|
||||
void setCurNotebookIndex(int index);
|
||||
|
||||
static void decorateTemplate();
|
||||
|
||||
static const QString orgName;
|
||||
static const QString appName;
|
||||
static const QString welcomePagePath;
|
||||
static const QString templateUrl;
|
||||
static const QString templatePath;
|
||||
|
||||
static QString templateHtml;
|
||||
|
||||
private:
|
||||
// Write notebooks section of global config
|
||||
@ -32,6 +36,10 @@ private:
|
||||
int curNotebookIndex;
|
||||
static const QString preTemplatePath;
|
||||
static const QString postTemplatePath;
|
||||
static const QString defaultCssUrl;
|
||||
|
||||
// For self CSS definition
|
||||
static QString cssUrl;
|
||||
};
|
||||
|
||||
#endif // VNOTE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user