fix(ts_web): resolve TypeScript nullability and event typing issues across web components
This commit is contained in:
@@ -447,7 +447,7 @@ export class DeesWorkspaceFiletree extends DeesElement {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const menuItems = [];
|
||||
const menuItems: Array<{ name?: string; iconName?: string; action?: () => Promise<void>; divider?: boolean }> = [];
|
||||
|
||||
if (node.type === 'directory') {
|
||||
// Directory-specific options
|
||||
@@ -503,7 +503,7 @@ export class DeesWorkspaceFiletree extends DeesElement {
|
||||
}
|
||||
);
|
||||
|
||||
await DeesContextmenu.openContextMenuWithOptions(e, menuItems);
|
||||
await DeesContextmenu.openContextMenuWithOptions(e, menuItems as any);
|
||||
}
|
||||
|
||||
private async handleEmptySpaceContextMenu(e: MouseEvent) {
|
||||
@@ -561,14 +561,14 @@ export class DeesWorkspaceFiletree extends DeesElement {
|
||||
menuOptions: [
|
||||
{
|
||||
name: 'Cancel',
|
||||
action: async (modalRef) => {
|
||||
action: async (modalRef: any) => {
|
||||
await modalRef.destroy();
|
||||
resolve(null);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: options.buttonName || 'Create',
|
||||
action: async (modalRef) => {
|
||||
action: async (modalRef: any) => {
|
||||
// Query the input element directly and read its value
|
||||
const contentEl = modalRef.shadowRoot?.querySelector('.modal .content');
|
||||
const inputElement = contentEl?.querySelector('dees-input-text') as DeesInputText | null;
|
||||
|
||||
@@ -129,8 +129,8 @@ export class DeesWorkspaceMarkdown extends DeesElement {
|
||||
@state()
|
||||
accessor isDragging: boolean = false;
|
||||
|
||||
private resizeHandleElement: HTMLElement;
|
||||
private containerElement: HTMLElement;
|
||||
private resizeHandleElement!: HTMLElement;
|
||||
private containerElement!: HTMLElement;
|
||||
|
||||
public render() {
|
||||
return html`
|
||||
@@ -173,26 +173,26 @@ const hello = 'yes'
|
||||
`;
|
||||
}
|
||||
|
||||
public async firstUpdated(_changedPropertiesArg) {
|
||||
public async firstUpdated(_changedPropertiesArg: Map<string | number | symbol, unknown>) {
|
||||
await super.firstUpdated(_changedPropertiesArg);
|
||||
|
||||
// Initialize current ratio from property
|
||||
this.currentSplitRatio = this.splitRatio;
|
||||
|
||||
// Cache elements
|
||||
this.containerElement = this.shadowRoot.querySelector('.splitContainer');
|
||||
this.resizeHandleElement = this.shadowRoot.querySelector('.resizeHandle');
|
||||
this.containerElement = this.shadowRoot!.querySelector('.splitContainer')!;
|
||||
this.resizeHandleElement = this.shadowRoot!.querySelector('.resizeHandle')!;
|
||||
|
||||
const editor = this.shadowRoot.querySelector('dees-workspace-monaco') as DeesWorkspaceMonaco;
|
||||
const editor = this.shadowRoot!.querySelector('dees-workspace-monaco') as DeesWorkspaceMonaco;
|
||||
|
||||
// Wire up markdown rendering
|
||||
const markdownOutlet = this.shadowRoot.querySelector('dees-workspace-markdownoutlet');
|
||||
const markdownOutlet = this.shadowRoot!.querySelector('dees-workspace-markdownoutlet');
|
||||
const smartmarkdownInstance = new domtools.plugins.smartmarkdown.SmartMarkdown();
|
||||
const mdParsedResult = await smartmarkdownInstance.getMdParsedResultFromMarkdown('loading...')
|
||||
editor.contentSubject.subscribe(async contentArg => {
|
||||
await mdParsedResult.updateFromMarkdownString(contentArg)
|
||||
const html = mdParsedResult.html;
|
||||
markdownOutlet.updateHtmlText(html);
|
||||
markdownOutlet!.updateHtmlText(html);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ const hello = 'yes'
|
||||
document.removeEventListener('mouseup', this.handleMouseUp);
|
||||
|
||||
// Trigger resize on monaco editor
|
||||
const editor = this.shadowRoot.querySelector('dees-workspace-monaco') as DeesWorkspaceMonaco;
|
||||
const editor = this.shadowRoot!.querySelector('dees-workspace-monaco') as DeesWorkspaceMonaco;
|
||||
if (editor) {
|
||||
// Monaco needs to be notified of size changes
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
|
||||
@@ -381,7 +381,7 @@ export class DeesWorkspaceMarkdownoutlet extends DeesElement {
|
||||
];
|
||||
|
||||
// INSTANCE
|
||||
private outlet: HTMLElement;
|
||||
private outlet!: HTMLElement;
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html`
|
||||
@@ -394,13 +394,13 @@ export class DeesWorkspaceMarkdownoutlet extends DeesElement {
|
||||
|
||||
public async firstUpdated(_changedProperties: Map<string | number | symbol, unknown>) {
|
||||
await super.firstUpdated(_changedProperties);
|
||||
this.outlet = this.shadowRoot.querySelector('.outlet');
|
||||
this.outlet = this.shadowRoot!.querySelector('.outlet')!;
|
||||
}
|
||||
|
||||
public async updateHtmlText(htmlTextArg: string) {
|
||||
await this.updateComplete;
|
||||
if (!this.outlet) {
|
||||
this.outlet = this.shadowRoot.querySelector('.outlet');
|
||||
this.outlet = this.shadowRoot!.querySelector('.outlet')!;
|
||||
}
|
||||
this.outlet.innerHTML = htmlTextArg;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ export class DeesWorkspaceMonaco extends DeesElement {
|
||||
_changedProperties: Map<string | number | symbol, unknown>
|
||||
): Promise<void> {
|
||||
super.firstUpdated(_changedProperties);
|
||||
const container = this.shadowRoot.getElementById('container');
|
||||
const container = this.shadowRoot!.getElementById('container')!
|
||||
const monacoCdnBase = `https://cdn.jsdelivr.net/npm/monaco-editor@${MONACO_VERSION}`;
|
||||
|
||||
if (!DeesWorkspaceMonaco.monacoDeferred) {
|
||||
@@ -174,7 +174,7 @@ export class DeesWorkspaceMonaco extends DeesElement {
|
||||
).text();
|
||||
const styleElement = document.createElement('style');
|
||||
styleElement.textContent = css;
|
||||
this.shadowRoot.append(styleElement);
|
||||
this.shadowRoot!.append(styleElement);
|
||||
|
||||
|
||||
// editor is setup let do the rest
|
||||
|
||||
Reference in New Issue
Block a user