Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-11-24 10:52:21 +01:00
parent 33ce6a73f7
commit c9033f6012
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
2 changed files with 12 additions and 4 deletions

View File

@ -23,7 +23,7 @@
const parser = new DOMParser()
$: dom = parser.parseFromString(message, 'application/xhtml+xml').firstChild as HTMLElement
$: dom = parser.parseFromString(message, 'text/html').firstChild?.childNodes[1] as HTMLElement
</script>
<Nodes nodes={dom.childNodes}/>

View File

@ -25,11 +25,19 @@
{#if node.nodeType === Node.TEXT_NODE}
{node.data}
{:else}
{#if node.nodeName === 'em'}
{#if node.nodeName === 'EM'}
<em><svelte:self nodes={node.childNodes}/></em>
{:else if node.nodeName === 'strong'}
{:else if node.nodeName === 'STRONG'}
<strong><svelte:self nodes={node.childNodes}/></strong>
{:else if node.nodeName === 'span'}
{:else if node.nodeName === 'P'}
<p><svelte:self nodes={node.childNodes}/></p>
{:else if node.nodeName === 'BLOCKQUOTE'}
<blockquote><svelte:self nodes={node.childNodes}/></blockquote>
{:else if node.nodeName === 'CODE'}
<code><svelte:self nodes={node.childNodes}/></code>
{:else if node.nodeName === 'BR'}
<br/>
{:else if node.nodeName === 'SPAN'}
<Person objectId={node.getAttribute('data-id')} title={node.getAttribute('data-label')} />
{:else}
Unknown { node.nodeName }