import { html, css, TemplateResult, CSSResultArray } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import hljs from 'highlight.js/lib/core'; import xml from 'highlight.js/lib/languages/xml'; import NileElement from '../../internal/nile-element'; import { sanitizeHtml } from '../engine/sanitize'; import './preview'; // HTML highlighting only — reuses the same lib the code-block feature already // bundles, so this adds no new dependency. Registration is idempotent. hljs.registerLanguage('xml', xml); /** * Raw HTML source editing mode. A split view: the raw HTML on the left, a * live rendered preview on the right, with a draggable divider between them * and a resizable body. The preview runs the same sanitizer the host applies * on the way back, so what you see is what the document becomes. Emits * `wysiwyg-source-apply` detail: { html } and `wysiwyg-source-cancel`. * * The code pane is a lightweight editor: a real `
${this.draft.trim() ? html`` : html`Nothing to preview`}
`; } } declare global { interface HTMLElementTagNameMap { 'nile-wysiwyg-source-view': NileWysiwygSourceView; } }