From 5caa3065036e3f9c66df62fc370e7be2d7a05c79 Mon Sep 17 00:00:00 2001 From: Adrien Jaguenet Date: Mon, 22 Jun 2026 18:39:55 +0200 Subject: [PATCH] fix: prevent deletion of library procedures - Skip delete button creation for readonly blocks (data-readonly) - Add WCProcedure.delete() override that guards against readonly --- blocks-proc.js | 5 +++++ wcblock.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/blocks-proc.js b/blocks-proc.js index 8128482..a5894a3 100644 --- a/blocks-proc.js +++ b/blocks-proc.js @@ -25,6 +25,11 @@ const LIB_ICONS = { /** Procedure definition block with inputs/outputs/description/return-style. Lives in the Procedures tab. */ class WCProcedure extends WCBlock { + delete() { + if (this.dataset.readonly) { showError("Cannot delete a library procedure."); return; } + super.delete(); + } + connectedCallback() { super.connectedCallback(); this._el.naturalName = this._require(".proc-natural-name"); diff --git a/wcblock.js b/wcblock.js index 29ac82e..49d38ea 100644 --- a/wcblock.js +++ b/wcblock.js @@ -46,7 +46,7 @@ class WCBlock extends HTMLElement { }); const isAlgoBlock = !!this.closest("#draw-area"); - if (!(this instanceof WCStart) && !(this instanceof WCEnd)) { + if (!(this instanceof WCStart) && !(this instanceof WCEnd) && !this.dataset.readonly) { const btn = document.createElement("button"); btn.className = "delete-btn"; btn.textContent = "\u00D7";