UNPKG

@blinkk/editor

Version:

Structured content editor with live previews.

51 lines 2.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LocalStatus = void 0; const selective_edit_1 = require("@blinkk/selective-edit"); const COPIED_CLASS = 'le__local__command__input--copied'; const DEFAULT_PORT = 9090; class LocalStatus { constructor(container, options) { this.container = container; this.options = options; } get isNonDefaultPort() { if (!this.options?.port) { return false; } return this.options.port !== DEFAULT_PORT; } render() { selective_edit_1.render(this.template(this), this.container); } // eslint-disable-next-line @typescript-eslint/no-unused-vars template(localStatus) { let inputTimeout = undefined; const handleCommandClick = (evt) => { // Clean any existing input timeout. if (inputTimeout) { window.clearTimeout(inputTimeout); } const target = evt.target; if (target) { target.select(); document.execCommand('copy'); const inputContainer = target.parentElement; inputContainer?.classList.add(COPIED_CLASS); inputTimeout = window.setTimeout(() => { inputContainer?.classList.remove(COPIED_CLASS); }, 10000); } }; return selective_edit_1.html `<div class="le"> <div class="le__local"> <h2>Local editor not found</h2> <p>To use the editor with a local project run the following command in the main directory of your local project:</p> <p><pre><code><span class="le__local__version"># Requires <a href="https://nodejs.org/" target="_blank">Node.js</a> &gt;= 14</span> <div class="le__local__command__input"><input class="le__local__command" readonly @click=${handleCommandClick} value="npx @blinkk/editor.dev${this.isNonDefaultPort ? ` --port ${this.options?.port}` : ''}" /></div></code></pre></p> </div> </div>`; } } exports.LocalStatus = LocalStatus; //# sourceMappingURL=local.js.map