0

I have successfully imported the nodes by importing it from a json file. However, it doesn't work because I try to modify(transform,remove) the nodes I brought. What should I do?

Here is code. Thank you!

function setFile() {
    const files = document.querySelector('.selectFile').files;
    if (files.length <= 0) {
        return false;
    }
    const fr = new FileReader();

    fr.onload = function(e) {
        
        const result = JSON.parse(e.target.result);
        const formatted = JSON.stringify(result, null, 2);
        console.log(formatted)
        layer.destroyChildren();
        stage = Konva.Node.create(formatted, 'container');

        stage.draw()
    }

    fr.readAsText(files.item(0))
}

Codepen

Otter
  • 1
  • 2
  • imported = Konva.Node.create(formatted, 'container'); stage = imported.getStage(); stage.add(layer); const newRect = stage.find('.rect'); if (newRect) { layer.add(newRect); } – Otter Nov 28 '20 at 13:06
  • It becomes an editable Node, but they remains afterimage in Canves. Anyone knows? – Otter Dec 07 '20 at 02:36

1 Answers1

0

I think you missed adding layer to the stage

dcruz1990
  • 1
  • 2