fix: preserve whitespace when using insertContent command

This commit is contained in:
Philipp Kühn
2021-05-19 15:15:56 +02:00
parent c0cbd513f6
commit 8f101810fe
2 changed files with 9 additions and 2 deletions

View File

@@ -1,3 +1,6 @@
export default function elementFromString(value: string): HTMLElement {
return new window.DOMParser().parseFromString(value, 'text/html').body
// add a wrapper to preserve leading and trailing whitespace
const wrappedValue = `<body>${value}</body>`
return new window.DOMParser().parseFromString(wrappedValue, 'text/html').body
}