From 1acc571cae01c9caede25e39ef33ecefbc811449 Mon Sep 17 00:00:00 2001 From: Eritque arcus Date: Sun, 9 Nov 2025 21:59:29 -0600 Subject: [PATCH 1/4] feat: implement click-edit --- main.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.ts b/main.ts index 55c88ae..d346e6d 100644 --- a/main.ts +++ b/main.ts @@ -29,7 +29,10 @@ export default class PseudocodePlugin extends Plugin { ): Promise { const blockDiv = el.createDiv({ cls: "pseudocode-block" }); const blockWidth = this.settings.blockSize; - blockDiv.style.width = `${blockWidth}em`; + blockDiv.style.width = `${blockWidth}em`;; + blockDiv.addEventListener("click", (event) => { + ((event.target as HTMLElement).closest('.pseudocode-block')!.parentElement!.parentElement!.querySelector('.edit-block-button') as HTMLElement)!.click(); + }); // Extract inline macros const [inlineMacros, nonMacroLines] = extractInlineMacros(source); From 6614713042a5a50b796ba4680d2fa0081bbaac6d Mon Sep 17 00:00:00 2001 From: Eritque arcus Date: Sun, 9 Nov 2025 22:01:39 -0600 Subject: [PATCH 2/4] chore: cleanup --- main.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.ts b/main.ts index d346e6d..36dc2d3 100644 --- a/main.ts +++ b/main.ts @@ -29,9 +29,13 @@ export default class PseudocodePlugin extends Plugin { ): Promise { const blockDiv = el.createDiv({ cls: "pseudocode-block" }); const blockWidth = this.settings.blockSize; - blockDiv.style.width = `${blockWidth}em`;; + blockDiv.style.width = `${blockWidth}em`; blockDiv.addEventListener("click", (event) => { - ((event.target as HTMLElement).closest('.pseudocode-block')!.parentElement!.parentElement!.querySelector('.edit-block-button') as HTMLElement)!.click(); + ((event.target as HTMLElement) + .closest('.pseudocode-block')! + .parentElement!.parentElement! + .querySelector('.edit-block-button') as HTMLElement)! + .click(); }); // Extract inline macros From 100c1c5bad9ab52ed3dbac46f6adccff04d023c2 Mon Sep 17 00:00:00 2001 From: Eritque arcus Date: Sun, 9 Nov 2025 23:56:00 -0600 Subject: [PATCH 3/4] fix: fix click button will also enter edit --- main.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.ts b/main.ts index 36dc2d3..2d6a652 100644 --- a/main.ts +++ b/main.ts @@ -31,11 +31,13 @@ export default class PseudocodePlugin extends Plugin { const blockWidth = this.settings.blockSize; blockDiv.style.width = `${blockWidth}em`; blockDiv.addEventListener("click", (event) => { - ((event.target as HTMLElement) - .closest('.pseudocode-block')! - .parentElement!.parentElement! - .querySelector('.edit-block-button') as HTMLElement)! - .click(); + const target = (event.target as HTMLElement)!; + if(target.tagName !== 'BUTTON') + (target + .closest('.pseudocode-block')! + .parentElement!.parentElement! + .querySelector('.edit-block-button') as HTMLElement)! + .click(); }); // Extract inline macros From 1c3846f0a2ea6e1868f03d3972e3d3d702709409 Mon Sep 17 00:00:00 2001 From: Eritque arcus Date: Sun, 9 Nov 2025 23:58:25 -0600 Subject: [PATCH 4/4] chore: use soft null check --- main.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.ts b/main.ts index 2d6a652..6415390 100644 --- a/main.ts +++ b/main.ts @@ -31,13 +31,13 @@ export default class PseudocodePlugin extends Plugin { const blockWidth = this.settings.blockSize; blockDiv.style.width = `${blockWidth}em`; blockDiv.addEventListener("click", (event) => { - const target = (event.target as HTMLElement)!; - if(target.tagName !== 'BUTTON') + const target = (event.target as HTMLElement | null); + if(target && target.tagName !== 'BUTTON') (target - .closest('.pseudocode-block')! - .parentElement!.parentElement! - .querySelector('.edit-block-button') as HTMLElement)! - .click(); + .closest('.pseudocode-block') + ?.parentElement?.parentElement + ?.querySelector('.edit-block-button') as HTMLElement | null) + ?.click(); }); // Extract inline macros