show hovered link in status line in read mode

This commit is contained in:
Le Tan 2018-04-27 20:35:58 +08:00
parent adacaef1c7
commit 960426579b
5 changed files with 29 additions and 1 deletions

View File

@ -859,6 +859,7 @@ var finishOneAsyncJob = function() {
// markdown-specifi handle logics, such as Mermaid, MathJax. // markdown-specifi handle logics, such as Mermaid, MathJax.
var finishLogics = function() { var finishLogics = function() {
if (asyncJobsCount <= 0) { if (asyncJobsCount <= 0) {
hookLinks();
content.finishLogics(); content.finishLogics();
calculateWordCount(); calculateWordCount();
} }
@ -1427,3 +1428,18 @@ var setPreviewContent = function(lang, html) {
previewDiv.className = ''; previewDiv.className = '';
} }
}; };
// Show the href text of a link when mouse is over it.
var showRefInLink = function(e) {
if (typeof content.showHoveredLink != 'undefined') {
content.showHoveredLink(this.href);
}
};
var hookLinks = function() {
var As = document.links;
for (var i = 0; i < As.length; ++i){
As[i].onmouseover = showRefInLink;
}
};

View File

@ -188,3 +188,8 @@ void VDocument::previewCodeBlockCB(int p_id, const QString &p_lang, const QStrin
{ {
emit codeBlockPreviewReady(p_id, p_lang, p_html); emit codeBlockPreviewReady(p_id, p_lang, p_html);
} }
void VDocument::showHoveredLink(const QString &p_link)
{
emit linkHovered(p_link);
}

View File

@ -112,6 +112,9 @@ public slots:
void previewCodeBlockCB(int p_id, const QString &p_lang, const QString &p_html); void previewCodeBlockCB(int p_id, const QString &p_lang, const QString &p_html);
// Show @p_link in status line.
void showHoveredLink(const QString &p_link);
signals: signals:
void textChanged(const QString &text); void textChanged(const QString &text);
@ -173,6 +176,8 @@ signals:
void codeBlockPreviewReady(int p_id, const QString &p_lang, const QString &p_html); void codeBlockPreviewReady(int p_id, const QString &p_lang, const QString &p_html);
void linkHovered(const QString &p_link);
private: private:
QString m_toc; QString m_toc;
QString m_header; QString m_header;

View File

@ -2542,7 +2542,7 @@ QAction *VMainWindow::newAction(const QIcon &p_icon,
void VMainWindow::showStatusMessage(const QString &p_msg) void VMainWindow::showStatusMessage(const QString &p_msg)
{ {
const int timeout = 3000; const int timeout = 5000;
statusBar()->showMessage(p_msg, timeout); statusBar()->showMessage(p_msg, timeout);
} }

View File

@ -457,6 +457,8 @@ void VMdTab::setupMarkdownViewer()
emit statusUpdated(info); emit statusUpdated(info);
}); });
connect(m_document, &VDocument::linkHovered,
this, &VMdTab::statusMessage);
page->setWebChannel(channel); page->setWebChannel(channel);