import {Component, OnInit, ViewChild, ViewEncapsulation} from '@angular/core';

import {APP_SETTINGS, ClientConfigService, Editor} from 'm2-core';
import {CD_PLUGIN_NAME} from './config';
import {CdDocsTreeComponent} from './components/docs-tree/cd-docs-tree.component';


@Component({
    templateUrl: './m2-component-docs-plugin.component.html',
    styleUrls: ['./m2-component-docs-plugin.component.scss'],
    encapsulation: ViewEncapsulation.None
})
export class M2ComponentDocsPluginComponent extends Editor implements OnInit {

    constructor(
        protected clientConfigService: ClientConfigService
    ) {
        super();
    }

    @ViewChild(CdDocsTreeComponent) cdDocsTreeComponent: CdDocsTreeComponent;


    editorName = CD_PLUGIN_NAME;
    APP_SETTINGS = APP_SETTINGS;

    protected readonly editorId = 'M2ComponentDocsPlugin';
    layoutConfig = { leftRatio: .25 };

    formTxNameFn = () => this.editorName;


    ngOnInit(): void {
        this.initLayout();
    }


    onSearchQueryApplied(searchQuery: string): void {
        this.cdDocsTreeComponent?.applySearchQuery(searchQuery);
    }

}
