fix: prevent deletion of library procedures

- Skip delete button creation for readonly blocks (data-readonly)
- Add WCProcedure.delete() override that guards against readonly
This commit is contained in:
2026-06-22 18:39:55 +02:00
parent 087c836c60
commit 5caa306503
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -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");
+1 -1
View File
@@ -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";