Here is the answer to my own question.
It’s possible to calculate the height of a HTML structure with the bottom element.
In “panel.js”:
self.port.on("calculateHeight", function () {
self.port.emit("setHeight", document.getElementById("lastelem").offsetTop + document.getElementById("lastelem").offsetHeight);
});
In “main.js”, you just have to call this function in “onShow”:
xPanel = panel.Panel({
contentURL: self.data.url("panel.html"),
contentScriptFile: self.data.url("panel.js"),
onShow: function () {
xPanel.port.emit("calculateHeight");
},
});
xPanel.port.on("setHeight", function (n) {
xPanel.resize(800, n);
});