@jupyter/docprovider-extension 3.0.0-beta.3 → 3.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,10 @@ export declare const yfile: JupyterFrontEndPlugin<void>;
13
13
  * Plugin to register the shared model factory for the content type 'notebook'.
14
14
  */
15
15
  export declare const ynotebook: JupyterFrontEndPlugin<void>;
16
+ /**
17
+ * A plugin to add a timeline slider status item to the status bar.
18
+ */
19
+ export declare const statusBarTimeline: JupyterFrontEndPlugin<void>;
16
20
  /**
17
21
  * The default file browser factory provider.
18
22
  */
@@ -4,14 +4,17 @@
4
4
  */
5
5
  import { ILabShell, IRouter, JupyterFrontEnd } from '@jupyterlab/application';
6
6
  import { Dialog, showDialog } from '@jupyterlab/apputils';
7
+ import { Widget } from '@lumino/widgets';
7
8
  import { IDefaultFileBrowser, IFileBrowserFactory } from '@jupyterlab/filebrowser';
9
+ import { IStatusBar } from '@jupyterlab/statusbar';
8
10
  import { IEditorTracker } from '@jupyterlab/fileeditor';
9
11
  import { ILoggerRegistry } from '@jupyterlab/logconsole';
10
12
  import { INotebookTracker } from '@jupyterlab/notebook';
11
13
  import { ISettingRegistry } from '@jupyterlab/settingregistry';
12
14
  import { ITranslator, nullTranslator } from '@jupyterlab/translation';
13
15
  import { YFile, YNotebook } from '@jupyter/ydoc';
14
- import { ICollaborativeDrive, IGlobalAwareness, YDrive } from '@jupyter/docprovider';
16
+ import { ICollaborativeDrive, IGlobalAwareness, TimelineWidget, YDrive } from '@jupyter/docprovider';
17
+ import { URLExt } from '@jupyterlab/coreutils';
15
18
  /**
16
19
  * The command IDs used by the file browser plugin.
17
20
  */
@@ -19,6 +22,7 @@ var CommandIDs;
19
22
  (function (CommandIDs) {
20
23
  CommandIDs.openPath = 'filebrowser:open-path';
21
24
  })(CommandIDs || (CommandIDs = {}));
25
+ const DOCUMENT_TIMELINE_URL = 'api/collaboration/timeline';
22
26
  /**
23
27
  * The default collaborative drive provider.
24
28
  */
@@ -84,6 +88,74 @@ export const ynotebook = {
84
88
  drive.sharedModelFactory.registerDocumentFactory('notebook', yNotebookFactory);
85
89
  }
86
90
  };
91
+ /**
92
+ * A plugin to add a timeline slider status item to the status bar.
93
+ */
94
+ export const statusBarTimeline = {
95
+ id: '@jupyter/docprovider-extension:statusBarTimeline',
96
+ description: 'Plugin to add a timeline slider to the status bar',
97
+ autoStart: true,
98
+ requires: [IStatusBar, ICollaborativeDrive],
99
+ activate: async (app, statusBar, drive) => {
100
+ try {
101
+ let sliderItem = null;
102
+ let timelineWidget = null;
103
+ const updateTimelineForDocument = async (documentPath, documentId) => {
104
+ if (drive) {
105
+ // Remove 'RTC:' from document path
106
+ documentPath = documentPath.slice(drive.name.length + 1);
107
+ // Dispose of the previous timelineWidget if it exists
108
+ if (timelineWidget) {
109
+ timelineWidget.dispose();
110
+ timelineWidget = null;
111
+ }
112
+ const [format, type] = documentId.split(':');
113
+ const provider = drive.providers.get(`${format}:${type}:${documentPath}`);
114
+ const fullPath = URLExt.join(app.serviceManager.serverSettings.baseUrl, DOCUMENT_TIMELINE_URL, documentPath);
115
+ timelineWidget = new TimelineWidget(fullPath, provider, provider.contentType, provider.format);
116
+ const elt = document.getElementById('jp-slider-status-bar');
117
+ if (elt && !timelineWidget.isAttached) {
118
+ Widget.attach(timelineWidget, elt);
119
+ }
120
+ }
121
+ };
122
+ if (app.shell.currentChanged) {
123
+ app.shell.currentChanged.connect(async (_, args) => {
124
+ const currentWidget = args.newValue;
125
+ if (timelineWidget) {
126
+ // Dispose of the timelineWidget when the document is closed
127
+ timelineWidget.dispose();
128
+ timelineWidget = null;
129
+ }
130
+ if (currentWidget && 'context' in currentWidget) {
131
+ await currentWidget.context.ready;
132
+ await updateTimelineForDocument(currentWidget.context.path, currentWidget.context.model.sharedModel.getState('document_id'));
133
+ }
134
+ });
135
+ }
136
+ if (statusBar) {
137
+ if (!sliderItem) {
138
+ sliderItem = new Widget();
139
+ sliderItem.addClass('jp-StatusBar-GroupItem');
140
+ sliderItem.addClass('jp-mod-highlighted');
141
+ sliderItem.id = 'jp-slider-status-bar';
142
+ statusBar.registerStatusItem('jp-slider-status-bar', {
143
+ item: sliderItem,
144
+ align: 'left',
145
+ rank: 4,
146
+ isActive: () => {
147
+ const currentWidget = app.shell.currentWidget;
148
+ return !!currentWidget && 'context' in currentWidget;
149
+ }
150
+ });
151
+ }
152
+ }
153
+ }
154
+ catch (error) {
155
+ console.error('Failed to activate statusBarTimeline plugin:', error);
156
+ }
157
+ }
158
+ };
87
159
  /**
88
160
  * The default file browser factory provider.
89
161
  */
@@ -96,10 +168,12 @@ export const defaultFileBrowser = {
96
168
  IRouter,
97
169
  JupyterFrontEnd.ITreeResolver,
98
170
  ILabShell,
99
- ISettingRegistry
171
+ ISettingRegistry,
172
+ ITranslator
100
173
  ],
101
- activate: async (app, drive, fileBrowserFactory, router, tree, labShell) => {
174
+ activate: async (app, drive, fileBrowserFactory, router, tree, labShell, translator) => {
102
175
  const { commands } = app;
176
+ const trans = (translator !== null && translator !== void 0 ? translator : nullTranslator).load('jupyterlab');
103
177
  app.serviceManager.contents.addDrive(drive);
104
178
  // Manually restore and load the default file browser.
105
179
  const defaultBrowser = fileBrowserFactory.createFileBrowser('filebrowser', {
@@ -107,6 +181,8 @@ export const defaultFileBrowser = {
107
181
  restore: false,
108
182
  driveName: drive.name
109
183
  });
184
+ defaultBrowser.node.setAttribute('role', 'region');
185
+ defaultBrowser.node.setAttribute('aria-label', trans.__('File Browser Section'));
110
186
  void Private.restoreBrowser(defaultBrowser, commands, router, tree, labShell);
111
187
  return defaultBrowser;
112
188
  }
package/lib/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * @packageDocumentation
5
5
  * @module collaboration-extension
6
6
  */
7
- import { drive, yfile, ynotebook, defaultFileBrowser, logger } from './filebrowser';
7
+ import { drive, yfile, ynotebook, defaultFileBrowser, logger, statusBarTimeline } from './filebrowser';
8
8
  import { notebookCellExecutor } from './executor';
9
9
  /**
10
10
  * Export the plugins as default.
@@ -15,6 +15,7 @@ const plugins = [
15
15
  ynotebook,
16
16
  defaultFileBrowser,
17
17
  logger,
18
- notebookCellExecutor
18
+ notebookCellExecutor,
19
+ statusBarTimeline
19
20
  ];
20
21
  export default plugins;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter/docprovider-extension",
3
- "version": "3.0.0-beta.3",
3
+ "version": "3.0.0-beta.5",
4
4
  "description": "JupyterLab - Collaborative Shared Models",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -53,7 +53,7 @@
53
53
  "watch:labextension": "jupyter labextension watch ."
54
54
  },
55
55
  "dependencies": {
56
- "@jupyter/docprovider": "^3.0.0-beta.3",
56
+ "@jupyter/docprovider": "^3.0.0-beta.5",
57
57
  "@jupyter/ydoc": "^2.0.0 || ^3.0.0-a3",
58
58
  "@jupyterlab/application": "^4.2.0",
59
59
  "@jupyterlab/apputils": "^4.2.0",