adding_content.rst 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. Adding Content
  2. --------------
  3. As an example: Add a leaflet viewer plugin for geoJSON files.
  4. - Go to npm: search for
  5. `leaflet <https://www.npmjs.com/package/leaflet>`__ (success!).
  6. - Go to ``jupyterlab`` top level source directory:
  7. ``jlpm add leaflet``. This adds the file to the ``dependencies`` in
  8. ``package.json``.
  9. - Next we see if there is a typing declaration for leaflet:
  10. ``jlpm add --dev @types/leaflet``. Success!
  11. - If there are no typings, we must create our own. An example typings
  12. file that exports functions is
  13. `codemirror <https://github.com/jupyterlab/jupyterlab/blob/master/packages/codemirror/typings/codemirror/codemirror.d.ts>`__.
  14. An example with a class is
  15. `xterm <https://github.com/jupyterlab/jupyterlab/blob/master/packages/terminal/src/xterm.d.ts>`__.
  16. - Add a reference to the new library in ``src/typings.d.ts``.
  17. - Create a folder in ``src`` for the plugin.
  18. - Add ``index.ts`` and ``plugin.ts`` files.
  19. - If creating CSS, import them in ``src/default-themes/index.css``.
  20. - The ``index.ts`` file should have the core logic for the plugin. In
  21. this case, it should create a widget and widget factory for rendering
  22. geojson files (see :ref:`documents`).
  23. - The ``plugin.ts`` file should create the extension and add the
  24. content to the application. In this case registering the widget
  25. factory using the document registry.
  26. - Run ``jlpm run build`` from ``jupyterlab/jupyterlab``
  27. - Run ``jupyter lab`` and verify changes.