test: register table plugin using a test API

pull/2052/head
Cameron Yick 2023-03-23 22:42:51 -04:00
rodzic 305a4de982
commit ab9bc5fd19
2 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -21,6 +21,8 @@ const datasetteManager = {
// Does pluginMetadata need to be serializable, or can we let it be stateful / have functions?
// Should we notify plugins that have dependencies
// when all dependencies were fulfilled? (leaflet, codemirror, etc)
// https://github.com/simonw/datasette-leaflet -> this way
// multiple plugins can all request the same copy of leaflet.
plugins: new Map(),
registerPlugin: (name, pluginMetadata) => {
if (datasetteManager.plugins.get(name)) {
@ -29,6 +31,8 @@ const datasetteManager = {
datasetteManager.plugins.set(name, pluginMetadata);
},
/** State helpers */
// https://github.com/simonw/datasette/issues/1144
// Datasette "core" -> Methods/APIs that are so core, we don't store them as a plugin
/** Selectors for significant DOM elements. Store identifier rather than addresses rather than immediate references in case they haven't loaded yet */
@ -43,7 +47,6 @@ const datasetteManager = {
};
/**
* Fire AFTER the document has been parsed
* Initialization... TODO how to make sure this exists BEFORE datasette manager is loaded? */

Wyświetl plik

@ -272,3 +272,14 @@ var DROPDOWN_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="14" heig
}
});
})();
// TODO: plugins need to wait for a custom event
// TODO: document what events they can listen for
document.addEventListener("InitDatasette", function (evt) {
// Manager is in event.detail
console.log(evt.detail);
evt.detail.registerPlugin('table', { version: 12, myCoolHello: () => console.log('hello') });
});