Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 5c35055

Browse files
committed
various little fixups
1 parent 0b6ee6b commit 5c35055

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

packages/plugin-dom-helpers/src/DomHelpers.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class DomHelpers<T extends JWPluginConfig = JWPluginConfig> extends JWPlu
142142
*/
143143
async replace(params: { domNodes: Node | Node[]; html: string }): Promise<void> {
144144
const nodes = this.getNodes(params.domNodes);
145-
const parsedNodes = await this._parseHTMLString(params.html);
145+
const parsedNodes = await this._parseHtmlString(params.html);
146146
const firstNode = nodes[0];
147147
for (const parsedNode of parsedNodes) {
148148
firstNode.before(parsedNode);
@@ -163,7 +163,7 @@ export class DomHelpers<T extends JWPluginConfig = JWPluginConfig> extends JWPlu
163163
'The provided container must be a ContainerNode in the Jabberwock structure.',
164164
);
165165
}
166-
const parsedNodes = await this._parseHTMLString(params.html);
166+
const parsedNodes = await this._parseHtmlString(params.html);
167167
for (const parsedNode of parsedNodes) {
168168
container.wrap(parsedNode);
169169
}
@@ -212,7 +212,7 @@ export class DomHelpers<T extends JWPluginConfig = JWPluginConfig> extends JWPlu
212212
nodes = [this.editor.selection.range.start];
213213
position = RelativePosition.BEFORE;
214214
}
215-
const parsedNodes = await this._parseHTMLString(params.html);
215+
const parsedNodes = await this._parseHtmlString(params.html);
216216
switch (position.toUpperCase()) {
217217
case RelativePosition.BEFORE.toUpperCase():
218218
for (const parsedNode of parsedNodes) {
@@ -255,16 +255,21 @@ export class DomHelpers<T extends JWPluginConfig = JWPluginConfig> extends JWPlu
255255
// Private
256256
//--------------------------------------------------------------------------
257257

258-
async _parseHTMLString(content: string): Promise<VNode[]> {
258+
/**
259+
* Parse an HTML string and return the resulting `VNodes`.
260+
*
261+
* @param html
262+
*/
263+
async _parseHtmlString(html: string): Promise<VNode[]> {
259264
const parser = this.editor.plugins.get(Parser);
260-
const domParser = parser && parser.engines.dom;
265+
const domParser = parser && parser.engines['dom/html'];
261266
if (!domParser) {
262267
// TODO: remove this when the editor can be instantiated on
263268
// something else than DOM.
264269
throw new Error(`No DOM parser installed.`);
265270
}
266271
const div = document.createElement('div');
267-
div.innerHTML = content;
272+
div.innerHTML = html;
268273
return (await domParser.parse(div))[0].children();
269274
}
270275
}

packages/plugin-dom-layout/src/ui/DomLayoutEngine.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ export class DomLayoutEngine extends LayoutEngine {
104104
getNodes(domNode: Node): VNode[] {
105105
return this._domReconciliationEngine.fromDom(domNode);
106106
}
107+
/**
108+
* Return the DOM Node(s) corresponding to the given VNode.
109+
*
110+
* @param node
111+
*/
107112
getDomNodes(node: VNode): Node[] {
108113
return this._domReconciliationEngine.toDom(node);
109114
}

0 commit comments

Comments
 (0)