Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to export to json then re-import? #4

Open
j2l opened this issue Jan 6, 2022 · 0 comments
Open

how to export to json then re-import? #4

j2l opened this issue Jan 6, 2022 · 0 comments

Comments

@j2l
Copy link

j2l commented Jan 6, 2022

Hello Sir,

To save/export as JSON, I tried changing the save function to:

async save () {
    try {
      let blob = await this.cy.json(false, 'elements')
      if (window.navigator.msSaveBlob) {
        window.navigator.msSaveBlob(blob, `chart-${Date.now()}.json`)
      } else {
        let a = document.createElement('a')
        a.download = `chart-${Date.now()}.json`
        a.href = window.URL.createObjectURL(blob)
        a.click()
      }
    } catch (e) {
      console.log(e)
    }
  }

but I get an error about the createObjectURL:

TypeError: URL.createObjectURL: Argument 1 is not valid for any of the 1-argument overloads.
    save index.js:513
    _handleCommand index.js:359
    _loop2 cytoscape.cjs.js:10505
    trigger cytoscape.cjs.js:10517
    forEachEventObj cytoscape.cjs.js:10401
    trigger cytoscape.cjs.js:10475
    emit cytoscape.cjs.js:14157
    command index.js:59
    _initEvents index.js:62
    Toolbar index.js:32
    default index.js:140
    _initPlugin index.js:245
    _init index.js:43
    CyEditor index.js:36
    mounted cyeditor.js:38
    VueJS 11
    <anonymous> main.js:8
    js app.js:864
    __webpack_require__ app.js:724
    fn app.js:101
    1 app.js:1995
    __webpack_require__ app.js:724
    <anonymous> app.js:791
    <anonymous> app.js:794

How would I add export to JSON and import as JSON buttons?

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant