Type Editor / @type-editor/model / dom-parser/DOMSerializer / DOMSerializer
Class: DOMSerializer
Defined in: packages/model/src/dom-parser/DOMSerializer.ts:18
A DOM serializer knows how to convert ProseMirror nodes and marks of various types to DOM nodes.
Constructors
Constructor
new DOMSerializer(nodes, marks): DOMSerializer;Defined in: packages/model/src/dom-parser/DOMSerializer.ts:38
Create a serializer. nodes should map node names to functions that take a node and return a description of the corresponding DOM. marks does the same for mark names, but also gets an argument that tells it whether the mark's content is block or inline content (for typical use, it'll always be inline). A mark serializer may be null to indicate that marks of that type should not be serialized.
Parameters
| Parameter | Type | Description |
|---|---|---|
nodes | Record<string, (node) => DOMOutputSpec> | The node serialization functions. |
marks | Record<string, (mark, inline) => DOMOutputSpec> | The mark serialization functions. |
Returns
DOMSerializer
Accessors
marks
Get Signature
get marks(): Record<string, (mark, inline) => DOMOutputSpec>;Defined in: packages/model/src/dom-parser/DOMSerializer.ts:48
Returns
Record<string, (mark, inline) => DOMOutputSpec>
nodes
Get Signature
get nodes(): Record<string, (node) => DOMOutputSpec>;Defined in: packages/model/src/dom-parser/DOMSerializer.ts:44
Returns
Record<string, (node) => DOMOutputSpec>
Methods
serializeFragment()
serializeFragment(
fragment,
options?,
target?): HTMLElement | DocumentFragment;Defined in: packages/model/src/dom-parser/DOMSerializer.ts:300
Serialize the content of this selfPos to a DOM selfPos. When not in the browser, the document option, containing a DOM document, should be passed so that the serializer can create nodes.
Parameters
| Parameter | Type |
|---|---|
fragment | Fragment |
options | { document?: Document; } |
options.document? | Document |
target? | HTMLElement | DocumentFragment |
Returns
HTMLElement | DocumentFragment
serializeNode()
serializeNode(node, options?): Node;Defined in: packages/model/src/dom-parser/DOMSerializer.ts:360
Serialize this node to a DOM node. This can be useful when you need to serialize a part of a document, as opposed to the whole document. To serialize a whole document, use serializeFragment on its content.
Parameters
| Parameter | Type |
|---|---|
node | Node |
options | { document?: Document; } |
options.document? | Document |
Returns
Node
fromSchema()
static fromSchema(schema): DOMSerializer;Defined in: packages/model/src/dom-parser/DOMSerializer.ts:78
Build a serializer using the toDOM properties in a schema's node and mark specs.
Parameters
| Parameter | Type |
|---|---|
schema | Schema |
Returns
DOMSerializer
renderSpec()
static renderSpec(
doc,
structure,
xmlNS?): {
contentDOM?: HTMLElement;
dom: Node;
};Defined in: packages/model/src/dom-parser/DOMSerializer.ts:60
Render an output spec to a DOM node. If the spec has a hole (zero) in it, contentDOM will point at the node with the hole.
Parameters
| Parameter | Type |
|---|---|
doc | Document |
structure | DOMOutputSpec |
xmlNS? | string |
Returns
{
contentDOM?: HTMLElement;
dom: Node;
}| Name | Type | Defined in |
|---|---|---|
contentDOM? | HTMLElement | packages/model/src/dom-parser/DOMSerializer.ts:62 |
dom | Node | packages/model/src/dom-parser/DOMSerializer.ts:61 |