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:
@@ -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
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user