Skip to content

Commit

Permalink
One more swing at fixing the HTML editor widget
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Nov 15, 2023
1 parent b5a1b60 commit b55d753
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/qml/FeatureForm.qml
Original file line number Diff line number Diff line change
Expand Up @@ -341,27 +341,28 @@ Page {
}
}

Component.onCompleted: {
if (visible) {
if (htmlItem === undefined) {
// avoid cost of WevView creation until needed
htmlItem = Qt.createQmlObject('import QtWebView 1.14;
WebView {
id: htmlItem;
height: 0;
opacity: 0;
anchors { top: parent.top; left: parent.left; right: parent.right; }
onLoadingChanged: { if (!loading) { runJavaScript("document.body.offsetHeight", function(result) { anchors.left = parent.left; width = parent.width; height = (result + 18); opacity = 1.0; } ) } }
}'
, htmlContent);
}
htmlItem.loadHtml(htmlCode)
}
}
onHtmlCodeChanged: {
if (visible && htmlItem) {
htmlItem.loadHtml(htmlCode);
if (htmlItem === undefined) {
htmlItem = Qt.createQmlObject('import QtWebView 1.14;
WebView {
id: htmlItem;
height: 0;
opacity: 0;
anchors { top: parent.top; left: parent.left; right: parent.right; }
onLoadingChanged: {
if (!loading) {
runJavaScript("document.body.offsetHeight", function(result) {
anchors.left = parent.left;
width = parent.width;
height = (result + 18);
opacity = 1.0;
});
}
}
}'
, htmlContent);
}
htmlItem.loadHtml(htmlCode);
}
}
}
Expand Down

1 comment on commit b55d753

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.