-
Notifications
You must be signed in to change notification settings - Fork 0
EN: HTML Slice
Version added | 1.0.0 |
---|
The HTML slice is used to store raw HTML that should be rendered by a Web browser as part of the rendering of a PBOML Document. HTML slices are for compatibility purposes only. Any other type of slice is preferable, if possible.
The list of valid field are all included in the List of fields common to all types of slice.
As of version 1.0.0, here is the list of fields that can be found in an HTML slice.
field name | type | optionality | Description |
---|---|---|---|
type |
String | obligatory | set to html
|
content |
Localized String Object | required | Contains the raw HTML payload that should be rendered. |
remove_default_styles |
Boolean | optional | When true , no styles will be applied to the shadow DOM. |
css |
String | optional | Can include CSS that will be applied to the slice. |
- type: html
css: "strong {font-size: 2em;}"
content:
en: |-
<strong>
Hello, world
</strong>
fr: |-
<strong>
Bonjour, monde
</strong>
This field contains a localized object with the actual raw html to be rendered for each language. Although the rendering is, when using this project's renderer, self contained in a shadow tree, invalid html could impact rendering in the whole document.
⚠️ When using this project's HTML renderer and editor, the html and css strings will be injected as is, with only minimal last resort sanitization applied to scripts, in the body of the editor and the rendered PBOML Document. This could allow for cross-site scripting attacks. It is imperative that only trusted content be displayed and/or effective content security policies (CSP) be enforced by the page wrapping this project's element.
- type: html
presentation: figure
referenced_as:
en: Summary Figure 1
fr: Figure 1 du résumé
content:
en: >-
<table.... </table>
fr: >-
<table .... </table>
When set to true
, the renderer will not inject any styles in the shadow tree used to render the slice. A limited amount of styles (eg. the document's font) will permeate through the shadow DOM and still apply, but could be overridden by providing minimal css
instructions.
By default, the renderer will attempt to render an HTML slice using styles that mimic the whole document. As of November 2023, this means using the Tailwind CSS framework.
This field contains a raw string that will be adopted by the slice's shadow root's. It can be used to provide custom styles in addition to existing styles or, when used in conjunction with remove_default_styles
, as a complete replacement. This style is scoped to the slice and cannot be re-used from one slice to another. It is, however, rendering-language agnostic.
⚠️ The same warning as for thecontent
field potential for XSS injection applies here.
- type: html
content:
en: >-
<table.... </table>
fr: >-
<table .... </table>
css: >-
table{background-color: lavender} tr:nth-child(even):not(:first-child)
{background-color: pink} thead{background-color: bisque} @media
(prefers-color-scheme: dark) {table {rotate: -3deg}}