@openeditor/exporters
v0.0.29
Published
Serialize OpenEditor documents to JSON, HTML, or plain text.
Readme
@openeditor/exporters
Serialize OpenEditor documents to JSON, HTML, or plain text.
toHtml and exportDocument(document, "html") are publishing-safe built-in
exports: unsafe URL schemes and inline styles are omitted. Unknown nodes fall
back to their children.
toUnsafeHtml and exportDocumentUnsafe are explicit trusted-host APIs for
custom HTML exporters. Their callbacks receive escapeHtml and
escapeAttribute, but the returned HTML is arbitrary and must not be rendered
from untrusted extensions.
Safe HTML uses the same openEditorPublicUrlPolicy contract as the React viewer.
Pass { urlPolicy } as the second argument to toHtml for a more specific
trusted-preview policy. Custom extension HTML remains restricted to the explicit
unsafe path because OpenEditor cannot certify arbitrary host-generated markup.
Built-in HTML carries stable semantic oe-* classes and
data-openeditor-* attributes. When placed inside an .oe-viewer container it
can use @openeditor/ui/styles.css; consumers may also target the data attributes
from independent publishing CSS. DOM shapes may differ where static HTML has a
more semantic representation, such as <details> for toggle items, but document
meaning and styling hooks remain stable.
Pure import/export helpers for OpenEditor documents.
Public surface
- JSON, HTML, and plain text export helpers
- JSON import and validation helpers
- strict versioned OpenEditor parsing; raw ProseMirror importing is a separate core API
Internal notes
- Exporters remain side-effect free and renderer-independent.
- Keep format transforms here rather than in
@openeditor/react,@openeditor/ui, or@openeditor/native.
