adding_content.rst 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. - Add a reference to the new library in ``src/typings.d.ts``.
  15. - Create a folder in ``src`` for the plugin.
  16. - Add ``index.ts`` and ``plugin.ts`` files.
  17. - If creating CSS, import them in ``src/default-themes/index.css``.
  18. - The ``index.ts`` file should have the core logic for the plugin. In
  19. this case, it should create a widget and widget factory for rendering
  20. geojson files (see :ref:`documents`).
  21. - The ``plugin.ts`` file should create the extension and add the
  22. content to the application. In this case registering the widget
  23. factory using the document registry.
  24. - Run ``jlpm run build`` from ``jupyterlab/jupyterlab``
  25. - Run ``jupyter lab`` and verify changes.