TriplyDB / Yasgui

Yet Another Sparql GUI
https://yasgui.triply.cc
MIT License
178 stars 54 forks source link

Register plugins #200

Open eric-personal opened 2 years ago

eric-personal commented 2 years ago

Hi I'm trying to register a plugin using Yasgui. I have created a new instance of Yasgui and trying to register the gallery plugin or chart plugin but am unable to find the import for it ?

Javascript.

    import Yasgui from "@triply/yasgui";

  useEffect(() => {

    // Yasr.registerPlugin(chart, plugin: Plugin)

    const instance = new Yasgui(ref.current, {
      requestConfig: { endpoint: "https://dbpedia.org/sparql" },
      copyEndpointOnNewTab: false,
      persistencyExpire: 0,
      persistenceId: null,
      yasqe: {
        readOnly: "nocursor",
      },
      yasr: {
      },
    });

    instance.getTab().yasqe.on("change", onChangeEditor);

    return () => {
      if (instance) {
        instance.getTab().yasqe.off("change", onChangeEditor);
        instance.destroy();
        instance = null;
      }
    };
  }, []);

Based on the instance above how would I register a plugin ? The docs has the below code but it does not state where the Plugin import is coming from ? Yasr.registerPlugin('gallery', plugin: Plugin ? )

Where would I import the gallery or chart plugin from ? https://triply.cc/docs/yasgui#gallery As shown here https://yasgui.triply.cc/

I'd also like to disable the download button in the table response is there a way to disable this, apart from hide it using css ?

GerwinBosch commented 2 years ago

Hello and sorry for the confusion, we've just updated our documentation about the difference between the base plugins and the additional plugins.

Unfortunately, these plugins are only available on yasgui.triply.cc, or within TriplyDB

As for disabling the download button, the quickest way is indeed to hide it with CSS. The first thing that comes to mind to nicely disable the download button is to extend the original table plugin like this

import Yasgui from "@triply/yasgui";

class MyTable extends Yasr.plugins.table {
  download=undefined
}
Yasgui.Yasr.plugins.table = MyTable

Let me know if the snippet helps! Have a nice day.

eric-personal commented 2 years ago

Thanks @GerwinBosch

I added the Yasgui.Yasr.plugins.table = MyTable to the top of my useEffect method before the instantiation of new Yasgui() but it still does not hide the download button. I used css for now to hide it.

As for the plugins got it "they can't be used in a project programmatically."

Thanks for getting back to me.