fetchPreview = ({ url, body, options, setPreviews, node_id, isView }) => {
  fetch(url, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "CSRF-Token": options.csrfToken,
      "X-Requested-With": "XMLHttpRequest",
    },
    body: JSON.stringify(body),
  })
    .then(function (response) {
      if (response.status < 399) return response.text();
      else return "";
    })
    .then(function (html) {
      $(".preview-scratchpad").html(html);
      $(".preview-scratchpad").find("iframe").css("pointer-events", "none");
      $(".preview-scratchpad").find("a").attr("href", "#");
      $(".preview-scratchpad")
        .find("[onclick], button, a, input, select")
        .attr("onclick", "return false");

      //.attr("disabled", true);
      $(".preview-scratchpad").find("textarea").attr("readonly", true);
      $(".preview-scratchpad .full-page-width").removeClass("full-page-width");
      if (isView) {
        $(".preview-scratchpad").find("input").attr("readonly", true);
      }
      const newHtml = $(".preview-scratchpad").html();
      setPreviews((prevState) => ({ ...prevState, [node_id]: newHtml }));

      // for react-view previews
      document.dispatchEvent(new Event("preview-loaded"));
    })
    .catch((e) => {
      console.log("Unable to fetch the preview:");
      console.log(e);
    });
}
@param {object} opts
@param {string} opts.url
@param {object} opts.body
@param {object} opts.options
@param {function} opts.setPreviews
@param {*} opts.node_id
@param {boolean} opts.isView
@returns {void}