Commit 9e515d7b authored by Laurent Montel's avatar Laurent Montel 😁

Improve it

parent 23f0305e
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<html lang="en"> <html lang="en">
<meta charset="utf-8"> <meta charset="utf-8">
<head> <head>
<link rel="stylesheet" type="text/css" href="markdown.css"> <link rel="stylesheet" type="text/css" href="3rdparty/markdown.css">
<script src="marked.min.js"></script> <script src="3rdparty/marked.min.js"></script>
<script src="qwebchannel.js"></script> <script src="qwebchannel.js"></script>
</head> </head>
<body> <body>
...@@ -13,31 +13,20 @@ ...@@ -13,31 +13,20 @@
var placeholder = document.getElementById('placeholder'); var placeholder = document.getElementById('placeholder');
var viewObject;
var updateText = function(text) { var updateText = function(text) {
placeholder.innerHTML = marked(text); placeholder.innerHTML = marked(text);
viewObject.emitRenderingDone();
} }
new QWebChannel(qt.webChannelTransport, new QWebChannel(qt.webChannelTransport,
function(channel) { function(channel) {
var sourceTextObject = channel.objects.sourceTextObject; var content = channel.objects.content;
viewObject = channel.objects.viewObject; updateText(content.text);
content.textChanged.connect(updateText);
// document.body.onscroll does not work (sometimes?) }
window.onscroll = function() {
viewObject.setScrollPosition(document.body.scrollLeft, document.body.scrollTop);
};
viewObject.requestSetScrollPosition.connect(function(x,y) {
document.body.scrollTop = y;
document.body.scrollLeft = x;
});
updateText(sourceTextObject.text);
sourceTextObject.textChanged.connect(updateText);
}
); );
</script> </script>
</body> </body>
</html> </html>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
#include "markdowndocument.h" #include "markdowndocument.h"
#include <QDebug>
MarkdownDocument::MarkdownDocument(QObject *parent) MarkdownDocument::MarkdownDocument(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
...@@ -35,6 +35,7 @@ void MarkdownDocument::setText(const QString &text) ...@@ -35,6 +35,7 @@ void MarkdownDocument::setText(const QString &text)
if (mText == text) if (mText == text)
return; return;
mText = text; mText = text;
qDebug() << " void MarkdownDocument::setText(const QString &text)"<<text;
Q_EMIT textChanged(mText); Q_EMIT textChanged(mText);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment