getEditPageWithHtmlFile = async (req, res, page) => {
  const htmlFile = page.html_file;
  const iframeId = "page_preview_iframe";
  const updateBttnId = "addnUpdBtn";
  const file = await File.findOne(htmlFile);
  if (!file) {
    req.flash("error", req.__("File not found"));
    return res.redirect(`/pageedit`);
  }
  const editForm = new Form({
    action: `/pageedit/edit/${encodeURIComponent(page.name)}`,
    fields: [
      {
        name: "code",
        form_name: "code",
        label: "Code",
        input_type: "code",
        attributes: { mode: "text/html" },
        validator(s) {
          return true;
        },
      },
    ],
    values: {
      code: await fsp.readFile(file.location, "utf8"),
    },
    onChange: `document.getElementById('${updateBttnId}').disabled = false;`,
    additionalButtons: [
      {
        label: req.__("Update"),
        id: updateBttnId,
        class: "btn btn-primary",
        onclick: `saveAndContinue(this, () => {
          document.getElementById('${iframeId}').contentWindow.location.reload();
          document.getElementById('${updateBttnId}').disabled = true;
        })`,
        disabled: true,
      },
    ],
    submitLabel: req.__("Finish") + " &raquo;",
  });
  res.sendWrap(req.__("Edit %s", page.title), {
    above: [
      {
        type: "card",
        title: "Edit",
        titleAjaxIndicator: true,
        contents: [renderForm(editForm, req.csrfToken())],
      },
      {
        type: "card",
        title: "Preview",
        contents: [
          iframe({
            id: iframeId,
            src: `/files/serve/${encodeURIComponent(htmlFile)}`,
          }),
          script(`
            const iframe = document.getElementById("${iframeId}");
            iframe.onload = () => {
              const _iframe = document.getElementById("${iframeId}");
              if (_iframe.contentWindow.document.body) {
                _iframe.width = _iframe.contentWindow.document.body.scrollWidth;
                _iframe.height = _iframe.contentWindow.document.body.scrollHeight;
              }
            }`),
        ],
      },
    ],
  });
}
open a file editor with an iframe preview
@param {*} req
@param {*} res
@param {*} page