{"version":3,"file":"taiga-ui-editor-components-editor-socket.mjs","sources":["../../../projects/editor/components/editor-socket/editor-socket.component.ts","../../../projects/editor/components/editor-socket/taiga-ui-editor-components-editor-socket.ts"],"sourcesContent":["import {DOCUMENT} from '@angular/common';\nimport {\n    ChangeDetectionStrategy,\n    Component,\n    ElementRef,\n    inject,\n    Input,\n    Renderer2,\n    SecurityContext,\n    signal,\n    ViewEncapsulation,\n} from '@angular/core';\nimport {type SafeHtml} from '@angular/platform-browser';\nimport {tuiIsElement} from '@taiga-ui/cdk';\nimport {TUI_EDITOR_OPTIONS, TUI_EDITOR_SANITIZER} from '@taiga-ui/editor/common';\nimport {TuiTiptapEditor} from '@taiga-ui/editor/directives/tiptap-editor';\n\n@Component({\n    standalone: true,\n    selector: 'tui-editor-socket',\n    template: '',\n    styleUrls: ['./editor-socket.component.less'],\n    encapsulation: ViewEncapsulation.None,\n    changeDetection: ChangeDetectionStrategy.OnPush,\n    host: {\n        '[class.tui-editor-socket]': 'options.enableDefaultStyles',\n        '(click)': 'click($event)',\n    },\n})\nexport class TuiEditorSocket {\n    private readonly editor = inject(TuiTiptapEditor, {optional: true});\n    private readonly sanitizer = inject(TUI_EDITOR_SANITIZER, {optional: true});\n    private readonly elementRef = inject(ElementRef);\n    private readonly renderer = inject(Renderer2);\n    private readonly doc = inject(DOCUMENT);\n    protected readonly options = inject(TUI_EDITOR_OPTIONS);\n    protected readonly html = signal<SafeHtml | string | null>(null);\n\n    @Input()\n    public set content(value: string | null | undefined) {\n        const content = value ?? '';\n        const safe = this.sanitizer?.sanitize(SecurityContext.HTML, content) ?? content;\n\n        this.renderer.setProperty(this.elementRef.nativeElement, 'innerHTML', safe);\n    }\n\n    /**\n     * @description:\n     * the main problem is that the external environment editor can use different base href=\"../\"\n     * More information: https://rogerkeays.com/blog/using-base-href-with-anchors\n     */\n    protected click(event: Event): void {\n        if (this.editor || !tuiIsElement(event.target)) {\n            return;\n        }\n\n        const href = event.target.closest('a')?.getAttribute('href') ?? '';\n\n        if (!href.startsWith('#')) {\n            return;\n        }\n\n        this.doc.location.hash = '';\n        this.doc.location.hash = href.replace('#', '');\n        event.preventDefault();\n    }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAiBA,MAYa,eAAe,CAAA;AAZ5B,IAAA,WAAA,GAAA;QAaqB,IAAM,CAAA,MAAA,GAAG,MAAM,CAAC,eAAe,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;QACnD,IAAS,CAAA,SAAA,GAAG,MAAM,CAAC,oBAAoB,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;AAC3D,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAChC,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAC7B,QAAA,IAAA,CAAA,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AACrB,QAAA,IAAA,CAAA,OAAO,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AACrC,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAC;AA8BpE,KAAA;IA5BG,IACW,OAAO,CAAC,KAAgC,EAAA;AAC/C,QAAA,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE,CAAC;AAC5B,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,OAAO,CAAC;AAEhF,QAAA,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;KAC/E;AAED;;;;AAIG;AACO,IAAA,KAAK,CAAC,KAAY,EAAA;QACxB,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,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