Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

Commit cc093a9

Browse files
committed
feat: legacy open-scd compatibility
1 parent 6dadd95 commit cc093a9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

oscd-template-generator.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ import '@openscd/oscd-tree-grid';
1818

1919
import { generateTemplates } from './generate-templates.js';
2020

21+
// open-scd editor action for backwards compatibility
22+
function newCreateEvent(parent: Node, element: Node, reference?: Node | null) {
23+
return new CustomEvent('editor-action', {
24+
bubbles: true,
25+
composed: true,
26+
detail: { action: { new: { parent, element, reference } } },
27+
});
28+
}
29+
2130
const tree = await fetch(new URL('./tree.json', import.meta.url)).then(res =>
2231
res.json()
2332
);
@@ -122,6 +131,7 @@ export default class TemplateGenerator extends LitElement {
122131
this.dispatchEvent(
123132
newEditEvent({ parent: this.doc.documentElement, node: templates })
124133
);
134+
this.dispatchEvent(newCreateEvent(this.doc.documentElement, templates));
125135
}
126136

127137
// delete this.treeUI.selection['']; // workaround for UI bug
@@ -138,6 +148,7 @@ export default class TemplateGenerator extends LitElement {
138148
this.dispatchEvent(
139149
newEditEvent({ parent: templates, node: element, reference })
140150
);
151+
this.dispatchEvent(newCreateEvent(templates, element, reference));
141152
}
142153
});
143154

0 commit comments

Comments
 (0)