nuvra 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,18 +33,20 @@ var c = ".doc-content{color:#1f2328;white-space:pre-wrap;overflow-wrap:break-wor
33
33
  let { width: i, height: a } = y(e), s = t(i * m, a * m, r.text, r.diagonal), c = r.diagonal ? " transform: rotate(-35deg);" : "";
34
34
  return `
35
35
  .doc-watermark { position: ${n ? "fixed" : "absolute"}; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; color: ${r.color}; font: 700 ${s}px/1 'Times New Roman', Times, serif; letter-spacing: 0.06em; opacity: ${h}; text-transform: uppercase; white-space: nowrap; pointer-events: none;${c} }`;
36
- }, E = (t, n, r, a = []) => t.map((o, c) => {
37
- let l = {
38
- page: e(n, c + 1),
36
+ }, E = (t, n, r, a = [], o = []) => t.map((c, l) => {
37
+ let u = {
38
+ page: e(n, l + 1),
39
39
  pages: t.length,
40
40
  title: r
41
- }, u = i(n, c + 1), d = u ? C(n.header, "header", l) : "", f = u ? C(n.footer, "footer", l) : "";
42
- return `<section class="doc-sheet">${w(n.watermark)}${d}<article class="doc-content">${o}</article>${a[c]?.length ? `<div class="doc-sheet__notes">${s(a[c] ?? [])}</div>` : ""}${f}</section>`;
41
+ }, d = i(n, l + 1), f = d ? C(n.header, "header", u) : "", p = d ? C(n.footer, "footer", u) : "", m = w(n.watermark), h = a[l]?.length ? `<div class="doc-sheet__notes">${s(a[l] ?? [])}</div>` : "";
42
+ return `<section class="${o[l] ? "doc-sheet is-rotated" : "doc-sheet"}">${m}${f}<article class="doc-content">${c}</article>${h}${p}</section>`;
43
43
  }).join(""), D = (e) => {
44
44
  let { width: t, height: n } = y(e), { margins: r } = e;
45
45
  return `@page { size: ${t}mm ${n}mm; margin: 0; }
46
46
  .doc-sheet { position: relative; box-sizing: border-box; width: ${t}mm; min-height: ${n}mm; padding: ${r.top}mm ${r.right}mm ${r.bottom}mm ${r.left}mm; overflow: hidden; background: #fff; break-after: page; }
47
47
  .doc-sheet:last-child { break-after: auto; }
48
+ @page rotated { size: ${n}mm ${t}mm; margin: 0; }
49
+ .doc-sheet.is-rotated { width: ${n}mm; min-height: ${t}mm; page: rotated; }
48
50
  .doc-running { position: absolute; right: ${r.right}mm; left: ${r.left}mm; }
49
51
  .doc-sheet__notes { position: absolute; right: ${r.right}mm; bottom: ${r.bottom}mm; left: ${r.left}mm; }
50
52
  .doc-running--header { top: ${x(r.top)}mm; }
@@ -55,20 +57,20 @@ var c = ".doc-content{color:#1f2328;white-space:pre-wrap;overflow-wrap:break-wor
55
57
  .doc-running { position: fixed; right: 0; left: 0; }
56
58
  .doc-running--header { top: -${x(t.top)}mm; }
57
59
  .doc-running--footer { bottom: -${x(t.bottom)}mm; }${S}${T(e, !0)}`;
58
- }, k = (e) => e.replace(u, " ").trim() || d, A = ({ html: e, pages: t, footnotes: n, title: r, page: i }) => {
59
- let a = t !== void 0 && t.length > 0, o = {
60
+ }, k = (e) => e.replace(u, " ").trim() || d, A = ({ html: e, pages: t, rotated: n, footnotes: r, title: i, page: a }) => {
61
+ let o = t !== void 0 && t.length > 0, l = {
60
62
  page: 1,
61
63
  pages: 1,
62
- title: r
63
- }, l = `${w(i.watermark)}${C(i.header, "header", o)}${C(i.footer, "footer", o)}<article class="doc-content">${e}</article>${s(n?.flat() ?? [])}`;
64
+ title: i
65
+ }, u = `${w(a.watermark)}${C(a.header, "header", l)}${C(a.footer, "footer", l)}<article class="doc-content">${e}</article>${s(r?.flat() ?? [])}`;
64
66
  return `<!doctype html>
65
67
  <html lang="uz">
66
68
  <head>
67
69
  <meta charset="utf-8">
68
- <title>${v(r)}</title>
69
- <style>${a ? D(i) : O(i)} html, body { margin: 0; background: #fff; } ${c}</style>
70
+ <title>${v(i)}</title>
71
+ <style>${o ? D(a) : O(a)} html, body { margin: 0; background: #fff; } ${c}</style>
70
72
  </head>
71
- <body>${a && t ? E(t, i, r, n) : l}</body>
73
+ <body>${o && t ? E(t, a, i, r, n) : u}</body>
72
74
  </html>`;
73
75
  }, j = (e, t, n) => {
74
76
  let r = URL.createObjectURL(e instanceof Blob ? e : new Blob([e], { type: n })), i = document.createElement("a");
@@ -89,6 +91,6 @@ var c = ".doc-content{color:#1f2328;white-space:pre-wrap;overflow-wrap:break-wor
89
91
  }, t.srcdoc = e, document.body.appendChild(t);
90
92
  };
91
93
  //#endregion
92
- export { A as buildPrintableHtml, j as downloadFile, M as printHtml, k as toFileName };
94
+ export { A as buildPrintableHtml, j as downloadFile, y as paperSize, M as printHtml, k as toFileName };
93
95
 
94
- //# sourceMappingURL=export-DhHI3ZrQ.js.map
96
+ //# sourceMappingURL=export-B06RXLqn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-B06RXLqn.js","names":[],"sources":["../src/styles/document-content.css?inline","../src/core/export.ts"],"sourcesContent":["/*\n * Typography of the document itself. Shared by the editor page, print output and Word/HTML export,\n * so every rule is plain CSS scoped to `.doc-content`. Vertical rhythm uses bottom margins only:\n * no margin collapsing keeps page layout measurements exact.\n */\n\n/* Base text. Typed spaces are content, so they are kept exactly. */\n.doc-content {\n color: #1f2328;\n font-family: \"Times New Roman\", Times, serif;\n font-size: 12pt;\n line-height: 1.5;\n white-space: pre-wrap;\n overflow-wrap: break-word;\n tab-size: 4;\n}\n\n/* Paragraphs without an explicit direction follow their own text (Arabic and Latin in one document). */\n.doc-content :is(p, h1, h2, h3, h4, h5, h6):not([dir]) {\n unicode-bidi: plaintext;\n}\n\n/* Paragraphs and headings. */\n.doc-content p {\n margin: 0 0 6pt;\n}\n\n.doc-content h1,\n.doc-content h2,\n.doc-content h3,\n.doc-content h4,\n.doc-content h5,\n.doc-content h6 {\n margin: 0 0 6pt;\n padding-top: 6pt;\n font-weight: 700;\n line-height: 1.25;\n}\n\n.doc-content h1 {\n font-size: 20pt;\n}\n\n.doc-content h2 {\n font-size: 16pt;\n}\n\n.doc-content h3 {\n font-size: 14pt;\n}\n\n.doc-content h4 {\n font-size: 12pt;\n}\n\n.doc-content h5 {\n font-size: 11pt;\n}\n\n.doc-content h6 {\n font-size: 10pt;\n}\n\n/* Lists, including task lists with a checkbox label and a content column. */\n.doc-content ul,\n.doc-content ol {\n margin: 0 0 6pt;\n padding-left: 24pt;\n}\n\n.doc-content li > p {\n margin-bottom: 2pt;\n}\n\n/* Legal numbering (1., 1.1., 1.1.1.) for regulations and orders: nested ordered lists continue their parent's number. */\n.doc-content ol[data-numbering=\"legal\"],\n.doc-content ol[data-numbering=\"legal\"] ol {\n padding-left: 0;\n list-style: none;\n counter-reset: doc-legal;\n}\n\n/* The number sits in its own column, so wrapped lines and nested lists align with the item text. */\n.doc-content ol[data-numbering=\"legal\"] > li,\n.doc-content ol[data-numbering=\"legal\"] ol > li {\n display: grid;\n grid-template-columns: auto minmax(0, 1fr);\n column-gap: 6pt;\n counter-increment: doc-legal;\n}\n\n.doc-content ol[data-numbering=\"legal\"] > li::before,\n.doc-content ol[data-numbering=\"legal\"] ol > li::before {\n grid-row: 1;\n grid-column: 1;\n content: counters(doc-legal, \".\") \".\";\n}\n\n.doc-content ol[data-numbering=\"legal\"] li > * {\n grid-column: 2;\n}\n\n.doc-content ol[data-numbering=\"legal\"] ol {\n margin: 2pt 0 0;\n}\n\n.doc-content ul[data-type=\"taskList\"] {\n padding-left: 2pt;\n list-style: none;\n}\n\n.doc-content ul[data-type=\"taskList\"] li {\n display: flex;\n align-items: flex-start;\n gap: 6pt;\n}\n\n.doc-content ul[data-type=\"taskList\"] li > label {\n flex: 0 0 auto;\n margin-top: 0.3em;\n user-select: none;\n}\n\n.doc-content ul[data-type=\"taskList\"] li > div {\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.doc-content ul[data-type=\"taskList\"] li[data-checked=\"true\"] > div {\n color: #667085;\n text-decoration: line-through;\n}\n\n/* Quotes. */\n.doc-content blockquote {\n margin: 0 0 6pt;\n padding: 2pt 0 2pt 12pt;\n border-left: 3px solid #b3c5f5;\n color: #475467;\n}\n\n/* The last paragraph of a container adds no space below it. */\n.doc-content blockquote > p:last-child,\n.doc-content li > p:last-child,\n.doc-content td > p:last-child,\n.doc-content th > p:last-child {\n margin-bottom: 0;\n}\n\n/* Code blocks and inline code. */\n.doc-content pre {\n margin: 0 0 6pt;\n padding: 8pt 10pt;\n border-radius: 4px;\n background: #f4f6f8;\n font-family: Consolas, \"Courier New\", monospace;\n font-size: 10pt;\n line-height: 1.45;\n white-space: pre-wrap;\n}\n\n.doc-content code {\n padding: 1px 4px;\n border-radius: 3px;\n background: #eef1f4;\n font-family: Consolas, \"Courier New\", monospace;\n font-size: 0.9em;\n}\n\n.doc-content pre code {\n padding: 0;\n background: none;\n font-size: inherit;\n}\n\n/* Horizontal rule. */\n.doc-content hr {\n height: 0;\n margin: 0 0 6pt;\n padding-top: 6pt;\n border: 0;\n border-bottom: 1px solid #c4cad4;\n}\n\n/* Inline marks. */\n.doc-content a {\n color: #1d4ed8;\n text-decoration: underline;\n}\n\n.doc-content mark {\n padding: 0 1px;\n border-radius: 2px;\n color: inherit;\n}\n\n/* Images are blocks aligned through their data-align attribute. */\n.doc-content img {\n max-width: 100%;\n height: auto;\n}\n\n.doc-content img[data-align=\"left\"] {\n display: block;\n margin: 0 auto 6pt 0;\n}\n\n.doc-content img[data-align=\"center\"] {\n display: block;\n margin: 0 auto 6pt;\n}\n\n.doc-content img[data-align=\"right\"] {\n display: block;\n margin: 0 0 6pt auto;\n}\n\n/* Tables. */\n.doc-content table {\n width: 100%;\n margin: 0 0 6pt;\n border-collapse: collapse;\n table-layout: fixed;\n}\n\n.doc-content td,\n.doc-content th {\n box-sizing: border-box;\n min-width: 1em;\n padding: 3pt 5pt;\n border: 1px solid #8f99a8;\n vertical-align: top;\n}\n\n.doc-content th {\n background: #f2f4f7;\n font-weight: 700;\n text-align: left;\n}\n\n/* Signature blocks and the table of contents are laid out in tables without visible borders. */\n.doc-content table[data-type=\"signature\"] td,\n.doc-content table[data-type=\"signature\"] th,\n.doc-content table[data-type=\"toc\"] td,\n.doc-content table[data-type=\"toc\"] th {\n padding: 0 5pt;\n border: 0;\n background: none;\n}\n\n.doc-content table[data-type=\"toc\"] tr:first-child td {\n padding-bottom: 6pt;\n}\n\n/* Tracked changes are shown, and printed, as reviewers expect them from Word. */\n.doc-content ins[data-change] {\n color: #15803d;\n text-decoration: underline;\n}\n\n.doc-content del[data-change] {\n color: #b91c1c;\n text-decoration: line-through;\n}\n\n/* Footnote references are numbered in document order; saved HTML also carries the number as text. */\n.doc-content {\n counter-reset: doc-footnote;\n}\n\n.doc-content sup[data-footnote] {\n counter-increment: doc-footnote;\n}\n\n.doc-content sup[data-footnote]:empty::after {\n content: counter(doc-footnote);\n}\n\n/* Notes at the bottom of a sheet, under a short rule. */\n.doc-footnotes {\n box-sizing: border-box;\n padding-top: 4pt;\n color: #1f2328;\n font:\n 10pt / 1.3 \"Times New Roman\",\n Times,\n serif;\n}\n\n.doc-footnotes::before {\n display: block;\n width: 33%;\n margin-bottom: 3pt;\n border-top: 1px solid #667085;\n content: \"\";\n}\n\n.doc-footnotes p {\n margin: 0 0 2pt;\n text-align: justify;\n}\n\n/* Manual page break: invisible in print, where it starts a new sheet. */\n.doc-content .doc-page-break {\n height: 0;\n break-after: page;\n page-break-after: always;\n}\n","import contentCss from '../styles/document-content.css?inline';\nimport { type SheetFootnote, footnotesHtml } from './footnotes';\nimport {\n type HeaderFooterContext,\n PAGE_SIZES,\n type PageHeaderFooter,\n type PageSettings,\n type PageWatermark,\n WATERMARK_ANGLE,\n hasHeaderFooterText,\n hasWatermarkText,\n pageNumberOf,\n renderHeaderFooter,\n showsRunningTexts,\n watermarkFontSize\n} from './page';\n\n/** Everything needed to print or export the document. */\ninterface DocumentSnapshot {\n /** Clean document HTML, used when the document is not laid out in sheets. */\n html: string;\n /**\n * Clean HTML of every sheet, in document order. The page view passes it so printing repeats the header and footer\n * with real page numbers and breaks the pages exactly where the editor shows them.\n */\n pages?: string[];\n /** For every sheet of `pages`, whether a section break turned it against the document's orientation. */\n rotated?: boolean[];\n /** Footnotes of every sheet of `pages`; without pages, the notes of all of them are printed after the document. */\n footnotes?: SheetFootnote[][];\n /** Document title, used for the print title and file names. */\n title: string;\n /** Page size, orientation, margins and the running texts. */\n page: PageSettings;\n}\n\n/** Characters escaped when text is placed into HTML. */\nconst HTML_ESCAPES: Record<string, string> = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;', \"'\": '&#39;' };\n/** Characters not allowed in file names on common systems. */\nconst INVALID_FILE_NAME_CHARACTERS = /[\\\\/:*?\"<>|]+/g;\n/** File name used when the title is empty. */\nconst DEFAULT_FILE_NAME = 'document';\n/** Removes the print iframe even when the browser never reports `afterprint`. */\nconst PRINT_CLEANUP_TIMEOUT_MS = 60_000;\n/** Distance a running text keeps from the paper edge when its margin is too small to centre it in, in millimetres. */\nconst MIN_RUNNING_EDGE_MM = 4;\n/** CSS pixels per millimetre at 96 DPI, used to size the watermark for the paper. */\nconst PX_PER_MM = 96 / 25.4;\n/** How faintly the watermark is printed. */\nconst WATERMARK_OPACITY = 0.16;\n/** The three parts of a running text, in the order they are drawn. */\nconst RUNNING_PARTS = ['left', 'center', 'right'] as const;\n/** Styles that keep the print iframe out of view without `display: none`, which would stop it from printing. */\nconst HIDDEN_FRAME_STYLE: Partial<CSSStyleDeclaration> = {\n position: 'fixed',\n left: '-10000px',\n top: '0',\n width: '1px',\n height: '1px',\n border: '0'\n};\n\n/** Escapes text for use inside HTML. */\nconst escapeHtml = (value: string) => value.replace(/[&<>\"']/g, character => HTML_ESCAPES[character] ?? character);\n\n/** Paper width and height in millimetres, in the chosen orientation. */\nexport const paperSize = ({ size, orientation }: PageSettings) => {\n const paper = PAGE_SIZES[size] ?? PAGE_SIZES.a4;\n const portrait = orientation === 'portrait';\n return { width: portrait ? paper.width : paper.height, height: portrait ? paper.height : paper.width };\n};\n\n/** CSS declarations for `@page` with the paper size and margins of the page settings. */\nconst pageRule = (page: PageSettings) => {\n const { width, height } = paperSize(page);\n const { margins } = page;\n return `size: ${width}mm ${height}mm; margin: ${margins.top}mm ${margins.right}mm ${margins.bottom}mm ${margins.left}mm;`;\n};\n\n/** Distance of a running text from the top or bottom edge of the paper, centred in its margin. */\nconst runningEdge = (margin: number) => Math.max(MIN_RUNNING_EDGE_MM, margin / 2 - 2);\n\n/** Shared look of the header and footer, both in print and in the exported page. */\nconst RUNNING_CSS = `\n.doc-running { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; color: #475467; font: 10pt/1.4 'Times New Roman', Times, serif; }\n.doc-running span { min-width: 0; overflow: hidden; white-space: pre-wrap; }\n.doc-running span:nth-child(2) { text-align: center; }\n.doc-running span:nth-child(3) { text-align: right; }`;\n\n/** One running text rendered for a page, or an empty string when it holds no text. */\nconst runningHtml = (\n value: PageHeaderFooter | undefined,\n place: 'header' | 'footer',\n context: HeaderFooterContext\n): string => {\n if (!value || !hasHeaderFooterText(value)) return '';\n const parts = RUNNING_PARTS.map(part => `<span>${escapeHtml(renderHeaderFooter(value[part], context))}</span>`).join(\n ''\n );\n return `<div class=\"doc-running doc-running--${place}\">${parts}</div>`;\n};\n\n/** The watermark of a page, or an empty string when the document has none. */\nconst watermarkHtml = (watermark: PageWatermark | undefined): string =>\n hasWatermarkText(watermark) && watermark\n ? `<div class=\"doc-watermark\">${escapeHtml(watermark.text.trim())}</div>`\n : '';\n\n/** Look of the watermark; it is positioned per sheet when the pages are known, and fixed when the document flows. */\nconst watermarkCss = (page: PageSettings, fixed: boolean): string => {\n const { watermark } = page;\n if (!hasWatermarkText(watermark) || !watermark) return '';\n const { width, height } = paperSize(page);\n const size = watermarkFontSize(width * PX_PER_MM, height * PX_PER_MM, watermark.text, watermark.diagonal);\n const rotation = watermark.diagonal ? ` transform: rotate(${WATERMARK_ANGLE}deg);` : '';\n return `\n.doc-watermark { position: ${fixed ? 'fixed' : 'absolute'}; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; color: ${watermark.color}; font: 700 ${size}px/1 'Times New Roman', Times, serif; letter-spacing: 0.06em; opacity: ${WATERMARK_OPACITY}; text-transform: uppercase; white-space: nowrap; pointer-events: none;${rotation} }`;\n};\n\n/** Sheets with their own header and footer, used when the editor knows where the pages break. */\nconst sheetsHtml = (\n pages: string[],\n page: PageSettings,\n title: string,\n footnotes: SheetFootnote[][] = [],\n rotated: boolean[] = []\n): string =>\n pages\n .map((content, index) => {\n const context: HeaderFooterContext = { page: pageNumberOf(page, index + 1), pages: pages.length, title };\n const shown = showsRunningTexts(page, index + 1);\n const header = shown ? runningHtml(page.header, 'header', context) : '';\n const footer = shown ? runningHtml(page.footer, 'footer', context) : '';\n const watermark = watermarkHtml(page.watermark);\n const notes = footnotes[index]?.length\n ? `<div class=\"doc-sheet__notes\">${footnotesHtml(footnotes[index] ?? [])}</div>`\n : '';\n const className = rotated[index] ? 'doc-sheet is-rotated' : 'doc-sheet';\n return `<section class=\"${className}\">${watermark}${header}<article class=\"doc-content\">${content}</article>${notes}${footer}</section>`;\n })\n .join('');\n\n/** Page geometry of the sheet layout: the paper is the page box and every sheet carries the margins itself. */\nconst sheetCss = (page: PageSettings) => {\n const { width, height } = paperSize(page);\n const { margins } = page;\n return `@page { size: ${width}mm ${height}mm; margin: 0; }\n.doc-sheet { position: relative; box-sizing: border-box; width: ${width}mm; min-height: ${height}mm; padding: ${margins.top}mm ${margins.right}mm ${margins.bottom}mm ${margins.left}mm; overflow: hidden; background: #fff; break-after: page; }\n.doc-sheet:last-child { break-after: auto; }\n@page rotated { size: ${height}mm ${width}mm; margin: 0; }\n.doc-sheet.is-rotated { width: ${height}mm; min-height: ${width}mm; page: rotated; }\n.doc-running { position: absolute; right: ${margins.right}mm; left: ${margins.left}mm; }\n.doc-sheet__notes { position: absolute; right: ${margins.right}mm; bottom: ${margins.bottom}mm; left: ${margins.left}mm; }\n.doc-running--header { top: ${runningEdge(margins.top)}mm; }\n.doc-running--footer { bottom: ${runningEdge(margins.bottom)}mm; }${RUNNING_CSS}${watermarkCss(page, false)}`;\n};\n\n/** Page geometry of the flowing layout, where the browser breaks the pages and repeats the fixed running texts. */\nconst flowCss = (page: PageSettings) => {\n const { margins } = page;\n return `@page { ${pageRule(page)} }\n.doc-running { position: fixed; right: 0; left: 0; }\n.doc-running--header { top: -${runningEdge(margins.top)}mm; }\n.doc-running--footer { bottom: -${runningEdge(margins.bottom)}mm; }${RUNNING_CSS}${watermarkCss(page, true)}`;\n};\n\n/** Turns a document title into a safe file name without extension. */\nexport const toFileName = (title: string): string =>\n title.replace(INVALID_FILE_NAME_CHARACTERS, ' ').trim() || DEFAULT_FILE_NAME;\n\n/**\n * Standalone HTML with the page size, margins and running texts encoded in CSS, used for printing and HTML export.\n * With the sheets of the page view every page carries its own header and footer, so the page numbers are exact and\n * the pages break where the editor shows them; without them the document flows and the browser repeats one fixed\n * header and footer on every page.\n */\nexport const buildPrintableHtml = ({ html, pages, rotated, footnotes, title, page }: DocumentSnapshot): string => {\n const paginated = pages !== undefined && pages.length > 0;\n const context: HeaderFooterContext = { page: 1, pages: 1, title };\n const flow = `${watermarkHtml(page.watermark)}${runningHtml(page.header, 'header', context)}${runningHtml(page.footer, 'footer', context)}<article class=\"doc-content\">${html}</article>${footnotesHtml(footnotes?.flat() ?? [])}`;\n return `<!doctype html>\n<html lang=\"uz\">\n<head>\n<meta charset=\"utf-8\">\n<title>${escapeHtml(title)}</title>\n<style>${paginated ? sheetCss(page) : flowCss(page)} html, body { margin: 0; background: #fff; } ${contentCss}</style>\n</head>\n<body>${paginated && pages ? sheetsHtml(pages, page, title, footnotes, rotated) : flow}</body>\n</html>`;\n};\n\n/** Offers text or binary content as a file download. */\nexport const downloadFile = (content: string | Blob, fileName: string, type: string): void => {\n const url = URL.createObjectURL(content instanceof Blob ? content : new Blob([content], { type }));\n const link = document.createElement('a');\n link.href = url;\n link.download = fileName;\n link.click();\n setTimeout(() => URL.revokeObjectURL(url), 0);\n};\n\n/** Prints through a detached iframe so the application chrome never ends up on paper. Waits for images first. */\nexport const printHtml = (documentHtml: string): void => {\n const frame = document.createElement('iframe');\n frame.setAttribute('aria-hidden', 'true');\n frame.tabIndex = -1;\n Object.assign(frame.style, HIDDEN_FRAME_STYLE);\n\n /** Removes the iframe once printing is done. */\n const cleanup = () => frame.remove();\n frame.onload = () => {\n const printWindow = frame.contentWindow;\n if (!printWindow) return cleanup();\n const pendingImages = Array.from(printWindow.document.images)\n .filter(image => !image.complete)\n .map(\n image =>\n new Promise(resolve => {\n image.addEventListener('load', resolve, { once: true });\n image.addEventListener('error', resolve, { once: true });\n })\n );\n void Promise.allSettled(pendingImages).then(() => {\n printWindow.addEventListener('afterprint', () => setTimeout(cleanup, 0), { once: true });\n printWindow.focus();\n printWindow.print();\n setTimeout(cleanup, PRINT_CLEANUP_TIMEOUT_MS);\n });\n };\n frame.srcdoc = documentHtml;\n document.body.appendChild(frame);\n};\n"],"mappings":";;;u8HCqCM,IAAuC;CAAE,KAAK;CAAS,KAAK;CAAQ,KAAK;CAAQ,MAAK;CAAU,KAAK;AAAQ,GAE7G,IAA+B,kBAE/B,IAAoB,YAEpB,IAA2B,KAE3B,IAAsB,GAEtB,IAAY,KAAK,MAEjB,IAAoB,KAEpB,IAAgB;CAAC;CAAQ;CAAU;AAAO,GAE1C,IAAmD;CACvD,UAAU;CACV,MAAM;CACN,KAAK;CACL,OAAO;CACP,QAAQ;CACR,QAAQ;AACV,GAGM,KAAc,MAAkB,EAAM,QAAQ,aAAY,MAAa,EAAa,MAAc,CAAS,GAGpG,KAAa,EAAE,SAAM,qBAAgC;CAChE,IAAM,IAAQ,EAAW,MAAS,EAAW,IACvC,IAAW,MAAgB;CACjC,OAAO;EAAE,OAAO,IAAW,EAAM,QAAQ,EAAM;EAAQ,QAAQ,IAAW,EAAM,SAAS,EAAM;CAAM;AACvG,GAGM,KAAY,MAAuB;CACvC,IAAM,EAAE,UAAO,cAAW,EAAU,CAAI,GAClC,EAAE,eAAY;CACpB,OAAO,SAAS,EAAM,KAAK,EAAO,cAAc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SAAS,KAAK,YAAY,CAAK;AACjC"}
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@
4
4
  */
5
5
  export { default as DocumentCompare } from './compare.vue';
6
6
  export { default as DocumentEditor } from './components/document-editor.vue';
7
+ export type { Collaborator, SelectionOffsets } from './core/collaboration';
8
+ export { collaboratorColor } from './core/collaboration';
7
9
  export type { DocumentComment, DocumentCommentReply } from './core/comments';
8
10
  export { createCommentId } from './core/comments';
9
11
  export { formatLongDate, formatShortDate } from './core/dates';