@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
1 lines • 1.44 kB
JavaScript
import*as Platform from"../../../core/platform/platform.js";import*as LitHtml from"../../lit-html/lit-html.js";import*as ComponentHelpers from"../helpers/helpers.js";import*as Coordinator from"../render_coordinator/render_coordinator.js";import linkifierImplStyles from"./linkifierImpl.css.js";import*as LinkifierUtils from"./LinkifierUtils.js";const coordinator=Coordinator.RenderCoordinator.RenderCoordinator.instance();export class LinkifierClick extends Event{data;static eventName="linkifieractivated";constructor(i){super(LinkifierClick.eventName,{bubbles:!0,composed:!0}),this.data=i,this.data=i}}export class Linkifier extends HTMLElement{static litTagName=LitHtml.literal`devtools-linkifier`;#i=this.attachShadow({mode:"open"});#t=Platform.DevToolsPath.EmptyUrlString;#e;#r;set data(i){if(this.#t=i.url,this.#e=i.lineNumber,this.#r=i.columnNumber,!this.#t)throw new Error("Cannot construct a Linkifier without providing a valid string URL.");this.#o()}connectedCallback(){this.#i.adoptedStyleSheets=[linkifierImplStyles]}#n(i){i.preventDefault();const t=new LinkifierClick({url:this.#t,lineNumber:this.#e,columnNumber:this.#r});this.dispatchEvent(t)}async#o(){await coordinator.write((()=>{LitHtml.render(LitHtml.html`<a class="link" href=${this.#t} =${this.#n}><slot>${LinkifierUtils.linkText(this.#t,this.#e)}</slot></a>`,this.#i,{host:this})}))}}ComponentHelpers.CustomElements.defineComponent("devtools-linkifier",Linkifier);