Constructor
new Previewer(optionsopt)
Create a new Previewer instance.
Create a new Previewer instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
Optional configuration settings for rendering. |
- Source:
Methods
getParams(name) → {string}
Retrieve a query parameter from the current URL.
Retrieve a query parameter from the current URL.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Name of the parameter. |
- Source:
Returns:
- Value of the parameter if found.
- Type
- string
initializeHandlers() → {EventEmitter}
Initializes handler modules (like footnotes, counters, etc.) and sets up relevant events.
Initializes handler modules (like footnotes, counters, etc.) and sets up relevant events.
- Source:
Returns:
- The handler system that manages internal processing hooks.
- Type
- EventEmitter
(async) preview(contentopt, stylesheetsopt, renderToopt) → {Promise.<Object>}
Main method for rendering content into paged preview.
Main method for rendering content into paged preview. Triggers hooks and events, applies stylesheets, chunks the content, and returns the flow result.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
content |
HTMLElement | DocumentFragment | string |
<optional> |
The content to render. |
stylesheets |
Array.<(string|Object)> |
<optional> |
List of stylesheet hrefs or inline styles to apply. |
renderTo |
HTMLElement | string |
<optional> |
Element or selector where rendered content will be inserted. |
- Source:
Returns:
- Resolves to the rendered flow object with performance and size metadata.
- Type
- Promise.<Object>
registerHandlers() → {*}
Registers handlers with custom logic or extensions.
Registers handlers with custom logic or extensions.
- Source:
Returns:
- The result of the registerHandlers function.
- Type
- *
removeStyles(docopt) → {Array}
Removes stylesheets and inline <style>
elements that should not be processed.
Removes stylesheets and inline <style>
elements that should not be processed.
Also returns the list of removed styles for reprocessing later.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
doc |
Document |
<optional> |
document | The document to process styles from. |
- Source:
Returns:
- Array of stylesheet hrefs or inline style objects.
- Type
- Array
wrapContent() → {DocumentFragment}
Wraps the contents of the <body>
in a <template>
element if not already present.
Wraps the contents of the <body>
in a <template>
element if not already present.
This is used to preserve the original content for chunking and layout.
- Source:
Returns:
- The wrapped content.
- Type
- DocumentFragment