{"version":3,"file":"createPrintView.mjs","sources":["../../../../../../packages/components/controls/print/createPrintView.ts"],"sourcesContent":["/*\n * @Author: zouyaoji@https://github.com/zouyaoji\n * @Date: 2021-10-27 15:54:13\n * @LastEditTime: 2022-02-09 16:40:15\n * @LastEditors: zouyaoji\n * @Description:\n * @FilePath: \\vue-cesium@next\\packages\\components\\controls\\print\\createPrintView.ts\n */\nimport { createApp } from 'vue'\nimport VcPrintView from './print-view'\n\nconst styles = `\n  .background {\n    width: 100%;\n    fill: rgba(255, 255, 255, 1.0);\n  }\n\n  .map-image {\n    max-width: 95vw;\n    max-height: 95vh;\n  }\n\n  .layer-legends {\n    display: inline;\n    float: left;\n    padding-left: 20px;\n    padding-right: 20px;\n  }\n\n  .layer-title {\n    font-weight: bold;\n  }\n\n  h1, h2, h3 {\n    clear: both;\n  }\n`\n\nconst createPrintView = options => {\n  const { printWindow = window.open(), closeCallback, title } = options\n  if (closeCallback) {\n    printWindow.addEventListener('unload', () => {\n      closeCallback(printWindow)\n    })\n  }\n\n  // Open and immediately close the document. This works around a problem in Firefox that is\n  // captured here: https://bugzilla.mozilla.org/show_bug.cgi?id=667227.\n  // Essentially, when we first create an iframe, it has no document loaded and asynchronously\n  // starts a load of \"about:blank\". If we access the document object and start manipulating it\n  // before that async load completes, a new document will be automatically created. But then\n  // when the async load completes, the original, automatically-created document gets unloaded\n  // and the new \"about:blank\" gets swapped in. End result: everything we add to the DOM before\n  // the async load complete gets lost and Firefox ends up printing a blank page.\n  // Explicitly opening and then closing a new document _seems_ to avoid this.\n  printWindow.document.open()\n  printWindow.document.close()\n  printWindow.document.head.innerHTML = `\n    <meta charset=\"UTF-8\">\n    <title>${options.title}</title>\n    <style>${styles}</style>\n    `\n  printWindow.document.body.innerHTML = '<div id=\"print\"></div>'\n\n  options.printWindow = options.printWindow || printWindow\n\n  const printViewProps = {\n    options\n  }\n\n  const app = createApp(VcPrintView, printViewProps)\n  app.mount(printWindow.document.getElementById('print'))\n}\n\nexport default createPrintView\n"],"names":[],"mappings":";;;;AAWA,MAAM,MAAS,GAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAAA;AA2Bf,MAAM,kBAAkB,CAAW,OAAA,KAAA;AACjC,EAAA,MAAM,EAAE,WAAc,GAAA,MAAA,CAAO,MAAQ,EAAA,aAAA,EAAe,OAAU,GAAA,OAAA,CAAA;AAC9D,EAAA,IAAI,aAAe,EAAA;AACjB,IAAY,WAAA,CAAA,gBAAA,CAAiB,UAAU,MAAM;AAC3C,MAAA,aAAA,CAAc,WAAW,CAAA,CAAA;AAAA,KAC1B,CAAA,CAAA;AAAA,GACH;AAWA,EAAA,WAAA,CAAY,SAAS,IAAK,EAAA,CAAA;AAC1B,EAAA,WAAA,CAAY,SAAS,KAAM,EAAA,CAAA;AAC3B,EAAY,WAAA,CAAA,QAAA,CAAS,KAAK,SAAY,GAAA,CAAA;AAAA;AAAA,WAAA,EAE3B,QAAQ,KAAK,CAAA;AAAA,WAAA,EACb,MAAM,CAAA;AAAA,IAAA,CAAA,CAAA;AAEjB,EAAY,WAAA,CAAA,QAAA,CAAS,KAAK,SAAY,GAAA,wBAAA,CAAA;AAEtC,EAAQ,OAAA,CAAA,WAAA,GAAc,QAAQ,WAAe,IAAA,WAAA,CAAA;AAE7C,EAAA,MAAM,cAAiB,GAAA;AAAA,IACrB,OAAA;AAAA,GACF,CAAA;AAEA,EAAM,MAAA,GAAA,GAAM,SAAU,CAAA,WAAA,EAAa,cAAc,CAAA,CAAA;AACjD,EAAA,GAAA,CAAI,KAAM,CAAA,WAAA,CAAY,QAAS,CAAA,cAAA,CAAe,OAAO,CAAC,CAAA,CAAA;AACxD;;;;"}