How can I register a node with a custom vue component with Browser build? #348
Unanswered
seafloyd16
asked this question in
Q&A
Replies: 1 comment
-
When using template strings, you need to have a compiler included with the Vue build. The BaklavaJS bundle ships without that compiler included in its Vue build to save bundle size. Therefore, using template strings doesn't work in that case. Your example works when using render functions: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@baklavajs/[email protected]/dist/syrup-dark.css"
/>
<style>
html,
body {
margin: 0;
}
#editor {
width: 100vw;
height: 100vh;
}
</style>
</head>
<body>
<div id="editor"></div>
<script>
var __VUE_PROD_DEVTOOLS__ = false;
</script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bundle.js"></script>
<script>
const { createApp, markRaw, defineComponent, ref, h } = Vue;
const { createBaklava, Engine, Core, RendererVue } = BaklavaJS;
const button = defineComponent({
props: {
modelValue: {
type: Number,
required: true,
},
},
emit: ["update:modelValue"],
setup(props, { emit }) {
const count = () => {
emit("update:modelValue", props.modelValue + 1);
};
return () => h("button", { onClick: count }, props.modelValue);
},
});
const nodeBTN = Core.defineNode({
type: "Button",
inputs: {
data: () =>
new Core.NodeInterface("My Interface", 0)
.setComponent(markRaw(button))
.setPort(false),
},
});
const visualEditor = createBaklava(document.getElementById("editor"));
const engine = new Engine.DependencyEngine(visualEditor.editor);
visualEditor.editor.registerNodeType(nodeBTN);
</script>
</body>
</html> Still, I wouldn't recommend using BaklavaJS's browser build - it is primarily designed for quick testing and tinkering, not for building production apps. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am creating an Electron app.
Basically, Electron is using CommonJS so I cannot use, and If possible, I don't want to use ESModule Import and Export.
This is why I use the browser build.
This code is what I tried at first.
A button won't be appended to a node.
And then I tried this code:
This gives me such an error:
Any solutions please?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions