Commit 7f6a15b8 authored by Laurent Montel's avatar Laurent Montel 😁

Add more javascript script

parent 40bcd0f7
......@@ -259,22 +259,12 @@ void MailWebEngineView::scrollPageUp(int percent)
void MailWebEngineView::injectAttachments(const boost::function<QString()> &delayedHtml)
{
const QString html = delayedHtml();
qDebug()<<" void MailWebEngineView::injectAttachments(const boost::function<QString()> &delayedHtml) not implemented " << delayedHtml;
if (html.isEmpty()) {
return;
}
//TODO
#if 0
QWebElement doc = page()->currentFrame()->documentElement();
QWebElement injectionPoint = doc.findFirst(QStringLiteral("*#attachmentInjectionPoint"));
if (injectionPoint.isNull()) {
return;
}
assert(injectionPoint.tagName().toLower() == QLatin1String("div"));
injectionPoint.setInnerXml(html)
#endif
qDebug()<<" void MailWebEngineView::injectAttachments(const boost::function<QString()> &delayedHtml) " << html;
//TODO verify
page()->runJavaScript(MessageViewer::WebEngineScript::injectAttachments(html, QStringLiteral("*#attachmentInjectionPoint")));
}
bool MailWebEngineView::replaceInnerHtml(const QString &id, const boost::function<QString()> &delayedHtml)
......
......@@ -187,3 +187,12 @@ QString WebEngineScript::replaceInnerHtml()
//TODO
return {};
}
QString WebEngineScript::injectAttachments(const QString &delayedHtml, const QString &elementStr)
{
const QString source = QString::fromLatin1("var element = document.getElementById('%1'); "
"if (element) { "
" element.innerHTML = '%2';"
"}").arg(elementStr).arg(delayedHtml);
return source;
}
......@@ -39,6 +39,7 @@ MESSAGEVIEWER_EXPORT QString scrollPercentage(int percent);
MESSAGEVIEWER_EXPORT QString scrollToRelativePosition(int pos);
MESSAGEVIEWER_EXPORT QString removeStyleToElement(const QString &element);
MESSAGEVIEWER_EXPORT QString replaceInnerHtml();
MESSAGEVIEWER_EXPORT QString injectAttachments(const QString &delayedHtml, const QString &element);
}
}
#endif // WEBENGINESCRIPT_H
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