diff --git a/src/dialog/vcopytextashtmldialog.cpp b/src/dialog/vcopytextashtmldialog.cpp
new file mode 100644
index 00000000..d7a7287b
--- /dev/null
+++ b/src/dialog/vcopytextashtmldialog.cpp
@@ -0,0 +1,81 @@
+#include "vcopytextashtmldialog.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include "utils/vutils.h"
+#include "utils/vclipboardutils.h"
+#include "utils/vwebutils.h"
+#include "vconfigmanager.h"
+
+extern VConfigManager *g_config;
+
+VCopyTextAsHtmlDialog::VCopyTextAsHtmlDialog(const QString &p_text, QWidget *p_parent)
+ : QDialog(p_parent), m_text(p_text)
+{
+ setupUI();
+}
+
+void VCopyTextAsHtmlDialog::setupUI()
+{
+ QLabel *textLabel = new QLabel(tr("Text:"));
+ m_textEdit = new QPlainTextEdit(m_text);
+ m_textEdit->setReadOnly(true);
+ m_textEdit->setProperty("LineEdit", true);
+
+ m_htmlLabel = new QLabel(tr("HTML:"));
+ m_htmlViewer = VUtils::getWebEngineView();
+ m_htmlViewer->setContextMenuPolicy(Qt::NoContextMenu);
+ m_htmlViewer->setMinimumSize(600, 400);
+
+ m_infoLabel = new QLabel(tr("Converting text to HTML ..."));
+
+ m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok);
+ connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
+ m_btnBox->button(QDialogButtonBox::Ok)->setProperty("SpecialBtn", true);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout();
+ mainLayout->addWidget(textLabel);
+ mainLayout->addWidget(m_textEdit);
+ mainLayout->addWidget(m_htmlLabel);
+ mainLayout->addWidget(m_htmlViewer);
+ mainLayout->addWidget(m_infoLabel);
+ mainLayout->addStretch();
+ mainLayout->addWidget(m_btnBox);
+
+ setLayout(mainLayout);
+ setWindowTitle(tr("Copy Text As HTML"));
+
+ setHtmlVisible(false);
+}
+
+void VCopyTextAsHtmlDialog::setHtmlVisible(bool p_visible)
+{
+ m_htmlLabel->setVisible(p_visible);
+ m_htmlViewer->setVisible(p_visible);
+}
+
+void VCopyTextAsHtmlDialog::setConvertedHtml(const QUrl &p_baseUrl,
+ const QString &p_html)
+{
+ QString html = QString("%1").arg(p_html);
+ m_htmlViewer->setHtml(html, p_baseUrl);
+ setHtmlVisible(true);
+
+ // Fix image source.
+ if (g_config->getFixImageSrcInWebWhenCopied()) {
+ VWebUtils::fixImageSrcInHtml(p_baseUrl, html);
+ }
+
+ QClipboard *clipboard = QApplication::clipboard();
+ QMimeData *data = new QMimeData();
+ data->setText(m_text);
+ data->setHtml(html);
+ VClipboardUtils::setMimeDataToClipboard(clipboard, data, QClipboard::Clipboard);
+
+ QTimer::singleShot(3000, this, &VCopyTextAsHtmlDialog::accept);
+ m_infoLabel->setText(tr("HTML has been copied. Will be closed in 3 seconds."));
+}
diff --git a/src/dialog/vcopytextashtmldialog.h b/src/dialog/vcopytextashtmldialog.h
new file mode 100644
index 00000000..93d935b1
--- /dev/null
+++ b/src/dialog/vcopytextashtmldialog.h
@@ -0,0 +1,46 @@
+#ifndef VCOPYTEXTASHTMLDIALOG_H
+#define VCOPYTEXTASHTMLDIALOG_H
+
+#include
+#include
+
+
+class QPlainTextEdit;
+class QWebEngineView;
+class QDialogButtonBox;
+class VWaitingWidget;
+class QLabel;
+
+class VCopyTextAsHtmlDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ VCopyTextAsHtmlDialog(const QString &p_text, QWidget *p_parent = nullptr);
+
+ void setConvertedHtml(const QUrl &p_baseUrl, const QString &p_html);
+
+ const QString &getText() const;
+
+private:
+ void setupUI();
+
+ void setHtmlVisible(bool p_visible);
+
+ QPlainTextEdit *m_textEdit;
+
+ QLabel *m_htmlLabel;
+
+ QWebEngineView *m_htmlViewer;
+
+ QLabel *m_infoLabel;
+
+ QDialogButtonBox *m_btnBox;
+
+ QString m_text;
+};
+
+inline const QString &VCopyTextAsHtmlDialog::getText() const
+{
+ return m_text;
+}
+#endif // VCOPYTEXTASHTMLDIALOG_H
diff --git a/src/resources/hoedown.js b/src/resources/hoedown.js
index 80e253c0..67934f1b 100644
--- a/src/resources/hoedown.js
+++ b/src/resources/hoedown.js
@@ -69,3 +69,15 @@ var highlightText = function(text, id, timeStamp) {
var html = marked(text);
content.highlightTextCB(html, id, timeStamp);
}
+
+var textToHtml = function(text) {
+ var html = marked(text);
+ var container = document.getElementById('text-to-html-div');
+ container.innerHTML = html;
+
+ html = getHtmlWithInlineStyles(container);
+
+ container.innerHTML = "";
+
+ content.textToHtmlCB(text, html);
+}
diff --git a/src/resources/markdown-it.js b/src/resources/markdown-it.js
index b3055cd2..1de7c0cf 100644
--- a/src/resources/markdown-it.js
+++ b/src/resources/markdown-it.js
@@ -124,3 +124,14 @@ var highlightText = function(text, id, timeStamp) {
content.highlightTextCB(html, id, timeStamp);
}
+var textToHtml = function(text) {
+ var html = mdit.render(text);
+ var container = document.getElementById('text-to-html-div');
+ container.innerHTML = html;
+
+ html = getHtmlWithInlineStyles(container);
+
+ container.innerHTML = "";
+
+ content.textToHtmlCB(text, html);
+}
diff --git a/src/resources/markdown_template.html b/src/resources/markdown_template.html
index 4dd4a332..be804b3c 100644
--- a/src/resources/markdown_template.html
+++ b/src/resources/markdown_template.html
@@ -31,5 +31,7 @@
+
+