josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON

Home Page:https://jsoneditoronline.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add an instance to a window on the site

AlexRMU opened this issue · comments

commented

Add the editor instance and all package exports to the window object so that they can be used from the console on the site

Ah, that wouldn't be hard to do. I suppose you're referring to https://jsoneditoronline.org ?

This makes me curious: what kind of things are you currently missing that you would like to do via the developer console?

commented

You also need to write about this in the site docs

commented
  • Change json (sorting, filtering, etc.) using js, and immediately update it in the editor
  • Use the editor API, change the settings
  • Interact with schemas, plugins, etc. that will appear in the future

Thanks for the clarification.

  1. Note that you can change JSON (sorting, filtering, etc) in the Transform modal too, using JavaScript + Lodash. I understand though that using the developer console may give more freedom (I'm a developer myself 😅 ).
    afbeelding
  2. So which API do you want to use directly via JS exactly? Most features are configurable via Options > Editor configuration and Configure JSON Schema.
commented
  1. Instance methods, utility functions, functions, what will appear in the future. Maybe someone will come in handy.

I like your ideas. More generally: we can expose all stuff in the developer console that is useful to work with JSON data.

Things that cross my mind:

  • expose the two editor instances (it is a a bit use-on-your-own-risk: the UI may get out of sync when doing stuff in one of the editor itself, like change config)
  • expose all the util functions that come with svelte-jsoneditor itself
  • expose immutable-json-patch
  • expose jsonrepair
  • expose jmespath
  • expose lodash _
  • expose ajv
commented

Yes, it will be cool

I think you'll like the latest version of https://jsoneditoronline.org (v6.14.0), it has exposed all the mentioned libraries and the two editors in the Developer Console. If you open the Developer Console you'll find detailed information.