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

Improve it

parent 23f0305e
......@@ -2,8 +2,8 @@
<html lang="en">
<meta charset="utf-8">
<head>
<link rel="stylesheet" type="text/css" href="markdown.css">
<script src="marked.min.js"></script>
<link rel="stylesheet" type="text/css" href="3rdparty/markdown.css">
<script src="3rdparty/marked.min.js"></script>
<script src="qwebchannel.js"></script>
</head>
<body>
......@@ -13,31 +13,20 @@
var placeholder = document.getElementById('placeholder');
var viewObject;
var updateText = function(text) {
placeholder.innerHTML = marked(text);
viewObject.emitRenderingDone();
}
new QWebChannel(qt.webChannelTransport,
function(channel) {
var sourceTextObject = channel.objects.sourceTextObject;
viewObject = channel.objects.viewObject;
// 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);
}
function(channel) {
var content = channel.objects.content;
updateText(content.text);
content.textChanged.connect(updateText);
}
);
</script>
</body>
</html>
......@@ -18,7 +18,7 @@
*/
#include "markdowndocument.h"
#include <QDebug>
MarkdownDocument::MarkdownDocument(QObject *parent)
: QObject(parent)
{
......@@ -35,6 +35,7 @@ void MarkdownDocument::setText(const QString &text)
if (mText == text)
return;
mText = text;
qDebug() << " void MarkdownDocument::setText(const QString &text)"<<text;
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