structured-render 0.0.0 → 0.0.1
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.
- package/LICENSE-CC0 +121 -0
- package/LICENSE-MIT +21 -0
- package/README.md +13 -0
- package/dist/augments/shadow-styles.d.ts +7 -0
- package/dist/augments/shadow-styles.js +17 -0
- package/dist/elements/vir-markdown.element.d.ts +16 -0
- package/dist/elements/vir-markdown.element.js +73 -0
- package/dist/elements/vir-source.element.d.ts +24 -0
- package/dist/elements/vir-source.element.js +158 -0
- package/dist/elements/vir-structured-render.element.d.ts +19 -0
- package/dist/elements/vir-structured-render.element.js +346 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/dist/render/browser-rendering.d.ts +90 -0
- package/dist/render/browser-rendering.js +233 -0
- package/dist/render/html-to-pdf.d.ts +50 -0
- package/dist/render/html-to-pdf.js +7 -0
- package/dist/render/render-html.d.ts +38 -0
- package/dist/render/render-html.js +504 -0
- package/dist/render/render-image.d.ts +24 -0
- package/dist/render/render-image.js +35 -0
- package/dist/render/render-markdown-styles.d.ts +62 -0
- package/dist/render/render-markdown-styles.js +242 -0
- package/dist/render/render-markdown.d.ts +8 -0
- package/dist/render/render-markdown.js +169 -0
- package/dist/render/render-pdf.d.ts +35 -0
- package/dist/render/render-pdf.js +65 -0
- package/dist/render/render-types.d.ts +134 -0
- package/dist/render/render-types.js +41 -0
- package/dist/structured-render-data/create-section.d.ts +23 -0
- package/dist/structured-render-data/create-section.js +16 -0
- package/dist/structured-render-data/sections/code-block.section.d.ts +30 -0
- package/dist/structured-render-data/sections/code-block.section.js +11 -0
- package/dist/structured-render-data/sections/empty.section.d.ts +14 -0
- package/dist/structured-render-data/sections/empty.section.js +9 -0
- package/dist/structured-render-data/sections/icon.section.d.ts +25 -0
- package/dist/structured-render-data/sections/icon.section.js +40 -0
- package/dist/structured-render-data/sections/inline-code.section.d.ts +29 -0
- package/dist/structured-render-data/sections/inline-code.section.js +9 -0
- package/dist/structured-render-data/sections/list.section.d.ts +169 -0
- package/dist/structured-render-data/sections/list.section.js +29 -0
- package/dist/structured-render-data/sections/markdown.section.d.ts +29 -0
- package/dist/structured-render-data/sections/markdown.section.js +9 -0
- package/dist/structured-render-data/sections/processing.section.d.ts +14 -0
- package/dist/structured-render-data/sections/processing.section.js +9 -0
- package/dist/structured-render-data/sections/source.section.d.ts +59 -0
- package/dist/structured-render-data/sections/source.section.js +47 -0
- package/dist/structured-render-data/sections/table.section.d.ts +939 -0
- package/dist/structured-render-data/sections/table.section.js +99 -0
- package/dist/structured-render-data/sections/tag.section.d.ts +39 -0
- package/dist/structured-render-data/sections/tag.section.js +20 -0
- package/dist/structured-render-data/sections/text.section.d.ts +48 -0
- package/dist/structured-render-data/sections/text.section.js +25 -0
- package/dist/structured-render-data/structured-render-card.d.ts +918 -0
- package/dist/structured-render-data/structured-render-card.js +11 -0
- package/dist/structured-render-data/structured-render-data.d.ts +919 -0
- package/dist/structured-render-data/structured-render-data.js +8 -0
- package/dist/structured-render-data/structured-render-section.d.ts +1857 -0
- package/dist/structured-render-data/structured-render-section.js +115 -0
- package/package.json +75 -11
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { colorCss } from '@electrovir/color';
|
|
2
|
+
import { css, defineElement, html, listen, unsafeCSS } from 'element-vir';
|
|
3
|
+
import { themeDefaultKey } from 'theme-vir';
|
|
4
|
+
import { noNativeFormStyles, ViraIcon, ViraTag, viraTheme } from 'vira';
|
|
5
|
+
import { insertStyleSheet } from '../augments/shadow-styles.js';
|
|
6
|
+
import { renderStructuredHtml, SourceExpansionEvent } from '../render/render-html.js';
|
|
7
|
+
import { contentDivClass, defaultMarkdownRenderStyles } from '../render/render-markdown-styles.js';
|
|
8
|
+
import { StructuredRenderTextStyle } from '../structured-render-data/sections/text.section.js';
|
|
9
|
+
/**
|
|
10
|
+
* Used to render Structured Render data to the DOM. This is the easiest way, if you use
|
|
11
|
+
* element-vir, to include Structured Render data in your web app. You can also use
|
|
12
|
+
* {@link renderStructuredHtml} to render Structured Render data to raw HTML.
|
|
13
|
+
*
|
|
14
|
+
* @category Elements
|
|
15
|
+
*/
|
|
16
|
+
export const VirStructuredRender = defineElement()({
|
|
17
|
+
tagName: 'vir-structured-render',
|
|
18
|
+
state() {
|
|
19
|
+
return {
|
|
20
|
+
currentlyExpanded: {},
|
|
21
|
+
lastStyleString: '',
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
cssVars: {
|
|
25
|
+
'vir-structured-render-h1-font-size': '24px',
|
|
26
|
+
'vir-structured-render-h2-font-size': '18px',
|
|
27
|
+
'vir-structured-render-h3-font-size': '16px',
|
|
28
|
+
'vir-structured-render-small-font-size': '12px',
|
|
29
|
+
},
|
|
30
|
+
hostClasses: {
|
|
31
|
+
'vir-structured-render-phone-size': ({ inputs }) => !!inputs.options?.isPhoneSize,
|
|
32
|
+
'vir-structured-render-tablet-size': ({ inputs }) => !!inputs.options?.isTableSize,
|
|
33
|
+
},
|
|
34
|
+
styles: ({ cssVars, hostClasses }) => css `
|
|
35
|
+
:host {
|
|
36
|
+
${colorCss(viraTheme.colors[themeDefaultKey])}
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
align-items: stretch;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
${ViraIcon} {
|
|
43
|
+
flex-shrink: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.view-header {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-grow: 1;
|
|
49
|
+
justify-content: space-between;
|
|
50
|
+
|
|
51
|
+
& .title-wrapper {
|
|
52
|
+
display: flex;
|
|
53
|
+
gap: 32px;
|
|
54
|
+
align-items: center;
|
|
55
|
+
text-align: left;
|
|
56
|
+
|
|
57
|
+
& h2 {
|
|
58
|
+
font-size: ${cssVars['vir-structured-render-h2-font-size'].value};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
& ${ViraTag} {
|
|
63
|
+
font-size: 14px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
& .risk-counts {
|
|
67
|
+
display: flex;
|
|
68
|
+
gap: 4px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
& .header-risk {
|
|
72
|
+
flex-wrap: wrap;
|
|
73
|
+
margin-left: auto;
|
|
74
|
+
display: flex;
|
|
75
|
+
gap: 8px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
& .risk-count {
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
gap: 4px;
|
|
82
|
+
|
|
83
|
+
& .risk-count-number {
|
|
84
|
+
font-size: 16px;
|
|
85
|
+
font-family: monospace;
|
|
86
|
+
width: 3ch;
|
|
87
|
+
text-align: left;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.text-style-${unsafeCSS(StructuredRenderTextStyle.Faint)}.text-style-${unsafeCSS(StructuredRenderTextStyle.Faint)}.text-style-${unsafeCSS(StructuredRenderTextStyle.Faint)}.text-style-${unsafeCSS(StructuredRenderTextStyle.Faint)} {
|
|
93
|
+
color: ${viraTheme.colors['vira-grey-foreground-non-body'].foreground.value};
|
|
94
|
+
}
|
|
95
|
+
.text-style-${unsafeCSS(StructuredRenderTextStyle.Bold)}.text-style-${unsafeCSS(StructuredRenderTextStyle.Bold)}.text-style-${unsafeCSS(StructuredRenderTextStyle.Bold)}.text-style-${unsafeCSS(StructuredRenderTextStyle.Bold)} {
|
|
96
|
+
font-weight: bold;
|
|
97
|
+
}
|
|
98
|
+
.text-style-${unsafeCSS(StructuredRenderTextStyle.Small)}.text-style-${unsafeCSS(StructuredRenderTextStyle.Small)}.text-style-${unsafeCSS(StructuredRenderTextStyle.Small)}.text-style-${unsafeCSS(StructuredRenderTextStyle.Small)} {
|
|
99
|
+
font-size: ${cssVars['vir-structured-render-small-font-size'].value};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
${ViraIcon} {
|
|
103
|
+
display: inline-flex;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
table {
|
|
107
|
+
border-collapse: collapse;
|
|
108
|
+
max-width: 100%;
|
|
109
|
+
|
|
110
|
+
& th,
|
|
111
|
+
& td {
|
|
112
|
+
padding: 16px;
|
|
113
|
+
padding-left: 24px;
|
|
114
|
+
|
|
115
|
+
&:first-child {
|
|
116
|
+
padding-left: 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&:has(+ .source-cell) {
|
|
120
|
+
border-right: none;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&.source-cell {
|
|
124
|
+
border: none !important;
|
|
125
|
+
padding: 0;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
& td {
|
|
130
|
+
word-break: break-word;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
& th {
|
|
134
|
+
text-align: left;
|
|
135
|
+
font-weight: normal;
|
|
136
|
+
white-space: nowrap;
|
|
137
|
+
vertical-align: top;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&.wide-table {
|
|
141
|
+
font-size: 14px;
|
|
142
|
+
|
|
143
|
+
& th,
|
|
144
|
+
& td {
|
|
145
|
+
padding: 4px;
|
|
146
|
+
padding-left: 8px;
|
|
147
|
+
|
|
148
|
+
&:first-child {
|
|
149
|
+
padding-left: 0;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&.vertical {
|
|
155
|
+
& th {
|
|
156
|
+
font-weight: bold;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&.horizontal {
|
|
161
|
+
align-self: flex-start;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
& .source-row td {
|
|
165
|
+
border: none !important;
|
|
166
|
+
padding: 0 !important;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
& tfoot {
|
|
170
|
+
font-size: ${cssVars['vir-structured-render-h2-font-size'].value};
|
|
171
|
+
font-weight: bold;
|
|
172
|
+
|
|
173
|
+
& td {
|
|
174
|
+
border: none;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
& td.right-aligned-footer-cell {
|
|
178
|
+
text-align: right;
|
|
179
|
+
& > .section-wrapper {
|
|
180
|
+
display: inline-flex;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.expanded-source {
|
|
187
|
+
margin: 8px 0 !important;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
*::first-line {
|
|
191
|
+
/* this height must match the icon size */
|
|
192
|
+
line-height: 24px;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.processing-wrapper {
|
|
196
|
+
display: flex;
|
|
197
|
+
gap: 8px;
|
|
198
|
+
align-items: center;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.section-wrapper {
|
|
202
|
+
display: flex;
|
|
203
|
+
flex-direction: column;
|
|
204
|
+
|
|
205
|
+
& .source-content-wrapper {
|
|
206
|
+
display: flex;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
& .collapsible-source-wrapper {
|
|
210
|
+
border: none;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
& .text-section-text-content {
|
|
214
|
+
flex-grow: 1;
|
|
215
|
+
vertical-align: middle;
|
|
216
|
+
}
|
|
217
|
+
& .source-icon-wrapper {
|
|
218
|
+
margin-left: auto;
|
|
219
|
+
width: 32px;
|
|
220
|
+
justify-content: flex-end;
|
|
221
|
+
display: flex;
|
|
222
|
+
flex-shrink: 0;
|
|
223
|
+
align-self: top;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
& .source-icon-button {
|
|
227
|
+
${noNativeFormStyles};
|
|
228
|
+
cursor: pointer;
|
|
229
|
+
color: ${viraTheme.colors['vira-grey-foreground-non-body'].foreground.value};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
& ul {
|
|
233
|
+
margin: 0;
|
|
234
|
+
flex-grow: 1;
|
|
235
|
+
padding-left: 1em;
|
|
236
|
+
max-width: 100%;
|
|
237
|
+
display: flex;
|
|
238
|
+
flex-direction: column;
|
|
239
|
+
gap: 2px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
&.top-section-wrapper.text-section > .source-content-wrapper,
|
|
243
|
+
&.top-section-wrapper > .source-content-wrapper > ul {
|
|
244
|
+
& .source-icon-wrapper {
|
|
245
|
+
margin-left: unset;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.icon-section {
|
|
251
|
+
display: inline-flex;
|
|
252
|
+
vertical-align: middle;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.text-section {
|
|
256
|
+
display: inline-block;
|
|
257
|
+
}
|
|
258
|
+
.tag-section {
|
|
259
|
+
display: inline-flex;
|
|
260
|
+
vertical-align: middle;
|
|
261
|
+
}
|
|
262
|
+
.processing-section {
|
|
263
|
+
display: inline-flex;
|
|
264
|
+
vertical-align: middle;
|
|
265
|
+
flex-direction: row;
|
|
266
|
+
gap: 4px;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
${hostClasses['vir-structured-render-phone-size'].selector} {
|
|
270
|
+
font-size: ${cssVars['vir-structured-render-small-font-size'].value};
|
|
271
|
+
|
|
272
|
+
& h2 {
|
|
273
|
+
font-size: ${cssVars['vir-structured-render-h3-font-size'].value};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.view-header {
|
|
277
|
+
flex-direction: column;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
& th,
|
|
281
|
+
& td {
|
|
282
|
+
padding: 4px;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
& ul {
|
|
286
|
+
padding-left: 1em;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
& ${ViraIcon} {
|
|
290
|
+
width: 18px;
|
|
291
|
+
height: 18px;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
& li::marker {
|
|
295
|
+
font-size: 0.7em;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
${hostClasses['vir-structured-render-tablet-size'].selector} {
|
|
300
|
+
.view-header {
|
|
301
|
+
flex-wrap: wrap;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
@media print {
|
|
306
|
+
.source-icon-wrapper {
|
|
307
|
+
display: none !important;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
`,
|
|
311
|
+
render({ inputs, state, updateState, host }) {
|
|
312
|
+
const styles = String(inputs.options?.markdownStyles || defaultMarkdownRenderStyles);
|
|
313
|
+
if (insertStyleSheet({
|
|
314
|
+
maintainFirstStylesheet: true,
|
|
315
|
+
newStyles: styles,
|
|
316
|
+
oldStyles: state.lastStyleString,
|
|
317
|
+
shadowRoot: host.shadowRoot,
|
|
318
|
+
})) {
|
|
319
|
+
updateState({
|
|
320
|
+
lastStyleString: styles,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
const templates = renderStructuredHtml(inputs.data, {
|
|
324
|
+
...inputs.options,
|
|
325
|
+
currentlyExpanded: {
|
|
326
|
+
...inputs.options?.currentlyExpanded,
|
|
327
|
+
...state.currentlyExpanded,
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
return html `
|
|
331
|
+
<div
|
|
332
|
+
${listen(SourceExpansionEvent, (event) => {
|
|
333
|
+
updateState({
|
|
334
|
+
currentlyExpanded: {
|
|
335
|
+
...state.currentlyExpanded,
|
|
336
|
+
[event.detail.key]: event.detail.expanded,
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
})}
|
|
340
|
+
class=${contentDivClass}
|
|
341
|
+
>
|
|
342
|
+
${templates}
|
|
343
|
+
</div>
|
|
344
|
+
`;
|
|
345
|
+
},
|
|
346
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from './augments/shadow-styles.js';
|
|
2
|
+
export * from './elements/vir-markdown.element.js';
|
|
3
|
+
export * from './elements/vir-source.element.js';
|
|
4
|
+
export * from './elements/vir-structured-render.element.js';
|
|
5
|
+
export * from './render/browser-rendering.js';
|
|
6
|
+
export * from './render/render-html.js';
|
|
7
|
+
export * from './render/render-image.js';
|
|
8
|
+
export * from './render/render-markdown-styles.js';
|
|
9
|
+
export * from './render/render-markdown.js';
|
|
10
|
+
export * from './render/render-pdf.js';
|
|
11
|
+
export * from './render/render-types.js';
|
|
12
|
+
export * from './structured-render-data/create-section.js';
|
|
13
|
+
export * from './structured-render-data/sections/code-block.section.js';
|
|
14
|
+
export * from './structured-render-data/sections/empty.section.js';
|
|
15
|
+
export * from './structured-render-data/sections/icon.section.js';
|
|
16
|
+
export * from './structured-render-data/sections/inline-code.section.js';
|
|
17
|
+
export * from './structured-render-data/sections/list.section.js';
|
|
18
|
+
export * from './structured-render-data/sections/markdown.section.js';
|
|
19
|
+
export * from './structured-render-data/sections/processing.section.js';
|
|
20
|
+
export * from './structured-render-data/sections/source.section.js';
|
|
21
|
+
export * from './structured-render-data/sections/table.section.js';
|
|
22
|
+
export * from './structured-render-data/sections/tag.section.js';
|
|
23
|
+
export * from './structured-render-data/sections/text.section.js';
|
|
24
|
+
export * from './structured-render-data/structured-render-card.js';
|
|
25
|
+
export * from './structured-render-data/structured-render-data.js';
|
|
26
|
+
export * from './structured-render-data/structured-render-section.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from './augments/shadow-styles.js';
|
|
2
|
+
export * from './elements/vir-markdown.element.js';
|
|
3
|
+
export * from './elements/vir-source.element.js';
|
|
4
|
+
export * from './elements/vir-structured-render.element.js';
|
|
5
|
+
export * from './render/browser-rendering.js';
|
|
6
|
+
export * from './render/render-html.js';
|
|
7
|
+
export * from './render/render-image.js';
|
|
8
|
+
export * from './render/render-markdown-styles.js';
|
|
9
|
+
export * from './render/render-markdown.js';
|
|
10
|
+
export * from './render/render-pdf.js';
|
|
11
|
+
export * from './render/render-types.js';
|
|
12
|
+
export * from './structured-render-data/create-section.js';
|
|
13
|
+
export * from './structured-render-data/sections/code-block.section.js';
|
|
14
|
+
export * from './structured-render-data/sections/empty.section.js';
|
|
15
|
+
export * from './structured-render-data/sections/icon.section.js';
|
|
16
|
+
export * from './structured-render-data/sections/inline-code.section.js';
|
|
17
|
+
export * from './structured-render-data/sections/list.section.js';
|
|
18
|
+
export * from './structured-render-data/sections/markdown.section.js';
|
|
19
|
+
export * from './structured-render-data/sections/processing.section.js';
|
|
20
|
+
export * from './structured-render-data/sections/source.section.js';
|
|
21
|
+
export * from './structured-render-data/sections/table.section.js';
|
|
22
|
+
export * from './structured-render-data/sections/tag.section.js';
|
|
23
|
+
export * from './structured-render-data/sections/text.section.js';
|
|
24
|
+
export * from './structured-render-data/structured-render-card.js';
|
|
25
|
+
export * from './structured-render-data/structured-render-data.js';
|
|
26
|
+
export * from './structured-render-data/structured-render-section.js';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type RequireExactlyOne } from 'type-fest';
|
|
3
|
+
import { type RenderInput, type RenderMarkdownOptions } from './render-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Output method types for jsPDF. Extracted from:
|
|
6
|
+
* https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html#output
|
|
7
|
+
*
|
|
8
|
+
* @category Internal
|
|
9
|
+
*/
|
|
10
|
+
export declare enum OutputPdfType {
|
|
11
|
+
/** Returns the PDF as an `ArrayBuffer`. */
|
|
12
|
+
ArrayBuffer = "arraybuffer",
|
|
13
|
+
/** Returns the PDF as a `Blob`. */
|
|
14
|
+
Blob = "blob",
|
|
15
|
+
/** Returns a blob URI string pointing to the generated PDF. */
|
|
16
|
+
BlobUri = "bloburi",
|
|
17
|
+
/** Alias for `BlobUri`. Returns a blob URL string pointing to the generated PDF. */
|
|
18
|
+
BlobUrl = "bloburl",
|
|
19
|
+
/** Returns the PDF as a base-64 data URI string. */
|
|
20
|
+
DataUriString = "datauristring",
|
|
21
|
+
/** Alias for `DataUriString`. Returns the PDF as a base-64 data URL string. */
|
|
22
|
+
DataUrlString = "dataurlstring",
|
|
23
|
+
/** Navigates the current page location to the generated data URI. Returns `undefined`. */
|
|
24
|
+
DataUri = "datauri",
|
|
25
|
+
/**
|
|
26
|
+
* Alias for `DataUri`. Navigates the current page location to the generated data URL. Returns
|
|
27
|
+
* `undefined`.
|
|
28
|
+
*/
|
|
29
|
+
DataUrl = "dataurl",
|
|
30
|
+
/**
|
|
31
|
+
* Opens the generated PDF data URL in a new window. Returns the `Window` or `null`. Throws if
|
|
32
|
+
* the global is not a window object (e.g. Node).
|
|
33
|
+
*/
|
|
34
|
+
DataUrlNewWindow = "dataurlnewwindow",
|
|
35
|
+
/**
|
|
36
|
+
* Opens a PDF object in a new window. Returns the `Window` or `null`. Throws if the global is
|
|
37
|
+
* not a window object (e.g. Node).
|
|
38
|
+
*/
|
|
39
|
+
PdfObjectNewWindow = "pdfobjectnewwindow",
|
|
40
|
+
/** Opens the PDF via pdf.js in a new window. Returns the `Window` or `null`. */
|
|
41
|
+
PdfJsNewWindow = "pdfjsnewwindow",
|
|
42
|
+
/** Simply download the file. */
|
|
43
|
+
Download = "download"
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Html2Pdf.js image output output types.
|
|
47
|
+
*
|
|
48
|
+
* @category Internal
|
|
49
|
+
*/
|
|
50
|
+
export declare enum OutputImageType {
|
|
51
|
+
/** Returns an img element as a string. */
|
|
52
|
+
Img = "img",
|
|
53
|
+
/** Returns a data URI string. */
|
|
54
|
+
DataUriString = "datauristring",
|
|
55
|
+
/** Returns a data URI string. Alias for `DataUriString`. */
|
|
56
|
+
DataUrlString = "dataurlstring",
|
|
57
|
+
/** Returns a data URI. */
|
|
58
|
+
DataUri = "datauri",
|
|
59
|
+
/** Returns a data URI. Alias for `DataUri`. */
|
|
60
|
+
DataUrl = "dataurl",
|
|
61
|
+
/** Simply download the file. */
|
|
62
|
+
Download = "download"
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Internal common in-browser structure render renderer.
|
|
66
|
+
*
|
|
67
|
+
* @category Internal
|
|
68
|
+
*/
|
|
69
|
+
export declare function renderInBrowser(structuredRenderData: Readonly<RenderInput>, { fileName, outputType, options: userOptions, }: Readonly<{
|
|
70
|
+
fileName: string;
|
|
71
|
+
outputType: RequireExactlyOne<{
|
|
72
|
+
image: OutputImageType;
|
|
73
|
+
pdf: OutputPdfType;
|
|
74
|
+
}>;
|
|
75
|
+
options?: Readonly<PartialWithUndefined<RenderMarkdownOptions>> | undefined;
|
|
76
|
+
}>): Promise<any>;
|
|
77
|
+
/**
|
|
78
|
+
* Internal common Node.js structure render renderer.
|
|
79
|
+
*
|
|
80
|
+
* @category Internal
|
|
81
|
+
* @returns The output file path.
|
|
82
|
+
*/
|
|
83
|
+
export declare function renderInNode(structuredRenderData: Readonly<RenderInput>, { saveLocationPath, outputType, options: userOptions, }: Readonly<{
|
|
84
|
+
saveLocationPath: string;
|
|
85
|
+
outputType: RequireExactlyOne<{
|
|
86
|
+
image: true;
|
|
87
|
+
pdf: true;
|
|
88
|
+
}>;
|
|
89
|
+
options?: Readonly<PartialWithUndefined<RenderMarkdownOptions>> | undefined;
|
|
90
|
+
}>): Promise<string>;
|