retejs / vue-plugin

https://retejs.org
MIT License
38 stars 36 forks source link

[question] rete control is not rendered (only html comment instead) #38

Closed charleshetier closed 3 years ago

charleshetier commented 3 years ago

Hello,

I'm struggling a bit with control creation: I think there is something obvious I have been missing for 2 hours.... I have these pieces of sample code:

class MyControl extends Rete.Control {
    constructor(emitter: NodeEditor, key: string) {
        super(key);

        // @ts-ignore
        this.render = 'vue';
        // @ts-ignore
        this.component = {
            template: '<div>Hello template</div>',
            mounted() {
                console.log('mounted', this.$el);
            },
        };
    }
}

and in my component:

async builder(node: Node) {
        const input1= new Rete.Input('in1', 'in1', mySocket);
        input1.addControl(new MyControl (this.editor!, 'in1'));
        node.addInput(input1);
    }

editor is initialized with: editor.use(VueRenderPlugin)

And during runtime the console output (from mounted vue hook): image

and indeed, in devtools I can only see: image

The packages I'm using are:

    "rete": "^1.4.5",
    "rete-connection-plugin": "^0.9.0",
    "rete-vue-render-plugin": "^0.5.1",

Am I doing something wrong here ?

I'm not within a Vuejs application (vanillajs), so no direct reference to vue, but I was expecting the vue plugin to use the one used by rete himself. Is this asumption true ? image

... sorry for my average english...

Ni55aN commented 3 years ago

It should work fine with these versions (see https://codepen.io/Ni55aN/pen/xzgQYq)

// this line has syntax error
 input1.addControl(new MyControl (this.editor!, 'in1'));
charleshetier commented 3 years ago

@Ni55aN Thank you very much for your reply. About the syntax error, I forgot to mention the code is Typescript, the "!" is a not null assertion (usefull in strict mode).

I have already checked the codepen you pointed out. I don't really undestand your proposal though. Are you suggesting I should downgrade the version of vue-render-plugin I'am using ?

Maybe, as another clue, I'm using Webpack to bundle my project (I'am currently digging this way, but without any success for now)

charleshetier commented 3 years ago

Ok, I found the issue I got. On a bare project (without vue-cli, vuejs not explicitly installed) it seems that I cannot compile vue templates on runtime. If I provide precompiled vue templates to the rete control (thanks to vue-loader with webpack in my case), it suddenly works fine.

So absolutly no problem with lastest versions of rete packages, I'm still using them and my control is still there.

Again, thanks a lot for your time and this amazing library