@jupyterlab/toc-extension 6.0.0-alpha.9 → 6.0.0-beta.1

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.
package/lib/index.d.ts CHANGED
@@ -3,14 +3,9 @@
3
3
  * @module toc-extension
4
4
  */
5
5
  import { JupyterFrontEndPlugin } from '@jupyterlab/application';
6
- import { ITableOfContentsRegistry } from '@jupyterlab/toc';
7
- /**
8
- * Initialization data for the ToC extension.
9
- *
10
- * @private
11
- */
12
- declare const extension: JupyterFrontEndPlugin<ITableOfContentsRegistry>;
6
+ import { ITableOfContentsRegistry, ITableOfContentsTracker } from '@jupyterlab/toc';
13
7
  /**
14
8
  * Exports.
15
9
  */
16
- export default extension;
10
+ declare const _default: (JupyterFrontEndPlugin<ITableOfContentsRegistry> | JupyterFrontEndPlugin<ITableOfContentsTracker>)[];
11
+ export default _default;
package/lib/index.js CHANGED
@@ -5,92 +5,80 @@
5
5
  * @module toc-extension
6
6
  */
7
7
  import { ILabShell, ILayoutRestorer } from '@jupyterlab/application';
8
- import { CodeCell, MarkdownCell } from '@jupyterlab/cells';
9
- import { IDocumentManager } from '@jupyterlab/docmanager';
10
- import { IEditorTracker } from '@jupyterlab/fileeditor';
11
- import { IMarkdownViewerTracker } from '@jupyterlab/markdownviewer';
12
- import { INotebookTracker } from '@jupyterlab/notebook';
13
- import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
14
8
  import { ISettingRegistry } from '@jupyterlab/settingregistry';
15
- import { createLatexGenerator, createMarkdownGenerator, createNotebookGenerator, createPythonGenerator, createRenderedMarkdownGenerator, ITableOfContentsRegistry, TableOfContents, TableOfContentsRegistry } from '@jupyterlab/toc';
16
- import { ITranslator } from '@jupyterlab/translation';
17
- import { tocIcon } from '@jupyterlab/ui-components';
9
+ import { ITableOfContentsRegistry, ITableOfContentsTracker, TableOfContents, TableOfContentsPanel, TableOfContentsRegistry, TableOfContentsTracker } from '@jupyterlab/toc';
10
+ import { ITranslator, nullTranslator } from '@jupyterlab/translation';
11
+ import { collapseAllIcon, CommandToolbarButton, ellipsesIcon, expandAllIcon, MenuSvg, numberingIcon, tocIcon, Toolbar, ToolbarButton } from '@jupyterlab/ui-components';
18
12
  /**
19
13
  * A namespace for command IDs of table of contents plugin.
20
14
  */
21
15
  var CommandIDs;
22
16
  (function (CommandIDs) {
23
- CommandIDs.runCells = 'toc:run-cells';
17
+ CommandIDs.displayNumbering = 'toc:display-numbering';
18
+ CommandIDs.displayH1Numbering = 'toc:display-h1-numbering';
19
+ CommandIDs.displayOutputNumbering = 'toc:display-outputs-numbering';
24
20
  CommandIDs.showPanel = 'toc:show-panel';
21
+ CommandIDs.toggleCollapse = 'toc:toggle-collapse';
25
22
  })(CommandIDs || (CommandIDs = {}));
26
23
  /**
27
24
  * Activates the ToC extension.
28
25
  *
29
26
  * @private
30
27
  * @param app - Jupyter application
31
- * @param docmanager - document manager
32
- * @param rendermime - rendered MIME registry
28
+ * @param tocRegistry - Table of contents registry
33
29
  * @param translator - translator
34
- * @param editorTracker - editor tracker
35
30
  * @param restorer - application layout restorer
36
31
  * @param labShell - Jupyter lab shell
37
- * @param markdownViewerTracker - Markdown viewer tracker
38
- * @param notebookTracker - notebook tracker
39
32
  * @param settingRegistry - setting registry
40
33
  * @returns table of contents registry
41
34
  */
42
- async function activateTOC(app, docmanager, rendermime, translator, editorTracker, restorer, labShell, markdownViewerTracker, notebookTracker, settingRegistry) {
43
- const trans = translator.load('jupyterlab');
35
+ async function activateTOC(app, tocRegistry, translator, restorer, labShell, settingRegistry) {
36
+ const trans = (translator !== null && translator !== void 0 ? translator : nullTranslator).load('jupyterlab');
37
+ let configuration = { ...TableOfContents.defaultConfig };
44
38
  // Create the ToC widget:
45
- const toc = new TableOfContents({
46
- docmanager,
47
- rendermime,
48
- translator
49
- });
50
- // Create the ToC registry:
51
- const registry = new TableOfContentsRegistry();
52
- // Add the ToC to the left area:
39
+ const toc = new TableOfContentsPanel(translator !== null && translator !== void 0 ? translator : undefined);
53
40
  toc.title.icon = tocIcon;
54
41
  toc.title.caption = trans.__('Table of Contents');
55
42
  toc.id = 'table-of-contents';
56
43
  toc.node.setAttribute('role', 'region');
57
44
  toc.node.setAttribute('aria-label', trans.__('Table of Contents section'));
58
- app.shell.add(toc, 'left', { rank: 400 });
59
- app.commands.addCommand(CommandIDs.runCells, {
60
- execute: args => {
61
- if (!notebookTracker) {
62
- return null;
63
- }
64
- const panel = notebookTracker.currentWidget;
65
- if (panel == null) {
66
- return;
67
- }
68
- const cells = panel.content.widgets;
69
- if (cells === undefined) {
70
- return;
45
+ app.commands.addCommand(CommandIDs.displayH1Numbering, {
46
+ label: trans.__('Show first-level heading number'),
47
+ execute: () => {
48
+ if (toc.model) {
49
+ toc.model.setConfiguration({
50
+ numberingH1: !toc.model.configuration.numberingH1
51
+ });
71
52
  }
72
- const activeCell = toc.activeEntry.cellRef;
73
- if (activeCell instanceof MarkdownCell) {
74
- let level = activeCell.headingInfo.level;
75
- for (let i = cells.indexOf(activeCell) + 1; i < cells.length; i++) {
76
- const cell = cells[i];
77
- if (cell instanceof MarkdownCell &&
78
- cell.headingInfo.level <= level &&
79
- cell.headingInfo.level > -1) {
80
- break;
81
- }
82
- if (cell instanceof CodeCell) {
83
- void CodeCell.execute(cell, panel.sessionContext);
84
- }
85
- }
53
+ },
54
+ isEnabled: () => { var _a, _b; return (_b = (_a = toc.model) === null || _a === void 0 ? void 0 : _a.supportedOptions.includes('numberingH1')) !== null && _b !== void 0 ? _b : false; },
55
+ isToggled: () => { var _a, _b; return (_b = (_a = toc.model) === null || _a === void 0 ? void 0 : _a.configuration.numberingH1) !== null && _b !== void 0 ? _b : false; }
56
+ });
57
+ app.commands.addCommand(CommandIDs.displayNumbering, {
58
+ label: trans.__('Show heading number in the document'),
59
+ icon: args => (args.toolbar ? numberingIcon : undefined),
60
+ execute: () => {
61
+ if (toc.model) {
62
+ toc.model.setConfiguration({
63
+ numberHeaders: !toc.model.configuration.numberHeaders
64
+ });
65
+ app.commands.notifyCommandChanged(CommandIDs.displayNumbering);
86
66
  }
87
- else {
88
- if (activeCell instanceof CodeCell) {
89
- void CodeCell.execute(activeCell, panel.sessionContext);
90
- }
67
+ },
68
+ isEnabled: () => { var _a, _b; return (_b = (_a = toc.model) === null || _a === void 0 ? void 0 : _a.supportedOptions.includes('numberHeaders')) !== null && _b !== void 0 ? _b : false; },
69
+ isToggled: () => { var _a, _b; return (_b = (_a = toc.model) === null || _a === void 0 ? void 0 : _a.configuration.numberHeaders) !== null && _b !== void 0 ? _b : false; }
70
+ });
71
+ app.commands.addCommand(CommandIDs.displayOutputNumbering, {
72
+ label: trans.__('Show output headings'),
73
+ execute: () => {
74
+ if (toc.model) {
75
+ toc.model.setConfiguration({
76
+ includeOutput: !toc.model.configuration.includeOutput
77
+ });
91
78
  }
92
79
  },
93
- label: trans.__('Run Cell(s)')
80
+ isEnabled: () => { var _a, _b; return (_b = (_a = toc.model) === null || _a === void 0 ? void 0 : _a.supportedOptions.includes('includeOutput')) !== null && _b !== void 0 ? _b : false; },
81
+ isToggled: () => { var _a, _b; return (_b = (_a = toc.model) === null || _a === void 0 ? void 0 : _a.configuration.includeOutput) !== null && _b !== void 0 ? _b : false; }
94
82
  });
95
83
  app.commands.addCommand(CommandIDs.showPanel, {
96
84
  label: trans.__('Table of Contents'),
@@ -98,6 +86,31 @@ async function activateTOC(app, docmanager, rendermime, translator, editorTracke
98
86
  app.shell.activateById(toc.id);
99
87
  }
100
88
  });
89
+ function someExpanded(model) {
90
+ return model.headings.some(h => { var _a; return !((_a = h.collapsed) !== null && _a !== void 0 ? _a : false); });
91
+ }
92
+ app.commands.addCommand(CommandIDs.toggleCollapse, {
93
+ label: () => toc.model && !someExpanded(toc.model)
94
+ ? trans.__('Expand All Headings')
95
+ : trans.__('Collapse All Headings'),
96
+ icon: args => args.toolbar
97
+ ? toc.model && !someExpanded(toc.model)
98
+ ? expandAllIcon
99
+ : collapseAllIcon
100
+ : undefined,
101
+ execute: () => {
102
+ if (toc.model) {
103
+ if (someExpanded(toc.model)) {
104
+ toc.model.toggleCollapse({ collapsed: true });
105
+ }
106
+ else {
107
+ toc.model.toggleCollapse({ collapsed: false });
108
+ }
109
+ }
110
+ },
111
+ isEnabled: () => toc.model !== null
112
+ });
113
+ const tracker = new TableOfContentsTracker();
101
114
  if (restorer) {
102
115
  // Add the ToC widget to the application restorer:
103
116
  restorer.add(toc, '@jupyterlab/toc:plugin');
@@ -106,82 +119,154 @@ async function activateTOC(app, docmanager, rendermime, translator, editorTracke
106
119
  let settings;
107
120
  if (settingRegistry) {
108
121
  try {
109
- settings = await settingRegistry.load(extension.id);
122
+ settings = await settingRegistry.load(registry.id);
123
+ const updateSettings = (plugin) => {
124
+ const composite = plugin.composite;
125
+ for (const key of [...Object.keys(configuration)]) {
126
+ const value = composite[key];
127
+ if (value !== undefined) {
128
+ configuration[key] = value;
129
+ }
130
+ }
131
+ if (labShell) {
132
+ for (const widget of labShell.widgets('main')) {
133
+ const model = tracker.get(widget);
134
+ if (model) {
135
+ model.setConfiguration(configuration);
136
+ }
137
+ }
138
+ }
139
+ else {
140
+ if (app.shell.currentWidget) {
141
+ const model = tracker.get(app.shell.currentWidget);
142
+ if (model) {
143
+ model.setConfiguration(configuration);
144
+ }
145
+ }
146
+ }
147
+ };
148
+ if (settings) {
149
+ settings.changed.connect(updateSettings);
150
+ updateSettings(settings);
151
+ }
110
152
  }
111
153
  catch (error) {
112
154
  console.error(`Failed to load settings for the Table of Contents extension.\n\n${error}`);
113
155
  }
114
156
  }
115
- // Create a notebook generator:
116
- if (notebookTracker) {
117
- const notebookGenerator = createNotebookGenerator(notebookTracker, toc, rendermime.sanitizer, translator, settings);
118
- registry.add(notebookGenerator);
119
- }
120
- // Create a Markdown generator:
121
- if (editorTracker) {
122
- const markdownGenerator = createMarkdownGenerator(editorTracker, toc, rendermime.sanitizer, translator, settings);
123
- registry.add(markdownGenerator);
124
- // Create a LaTeX generator:
125
- const latexGenerator = createLatexGenerator(editorTracker);
126
- registry.add(latexGenerator);
127
- // Create a Python generator:
128
- const pythonGenerator = createPythonGenerator(editorTracker);
129
- registry.add(pythonGenerator);
130
- }
131
- // Create a rendered Markdown generator:
132
- if (markdownViewerTracker) {
133
- const renderedMarkdownGenerator = createRenderedMarkdownGenerator(markdownViewerTracker, toc, rendermime.sanitizer, translator, settings);
134
- registry.add(renderedMarkdownGenerator);
135
- }
157
+ // Set up the panel toolbar
158
+ const numbering = new CommandToolbarButton({
159
+ commands: app.commands,
160
+ id: CommandIDs.displayNumbering,
161
+ args: {
162
+ toolbar: true
163
+ },
164
+ label: ''
165
+ });
166
+ numbering.addClass('jp-toc-numberingButton');
167
+ toc.toolbar.addItem('display-numbering', numbering);
168
+ toc.toolbar.addItem('spacer', Toolbar.createSpacerItem());
169
+ toc.toolbar.addItem('collapse-all', new CommandToolbarButton({
170
+ commands: app.commands,
171
+ id: CommandIDs.toggleCollapse,
172
+ args: {
173
+ toolbar: true
174
+ },
175
+ label: ''
176
+ }));
177
+ const toolbarMenu = new MenuSvg({ commands: app.commands });
178
+ toolbarMenu.addItem({
179
+ command: CommandIDs.displayH1Numbering
180
+ });
181
+ toolbarMenu.addItem({
182
+ command: CommandIDs.displayOutputNumbering
183
+ });
184
+ const menuButton = new ToolbarButton({
185
+ tooltip: trans.__('More actions…'),
186
+ icon: ellipsesIcon,
187
+ actualOnClick: true,
188
+ onClick: () => {
189
+ const bbox = menuButton.node.getBoundingClientRect();
190
+ toolbarMenu.open(bbox.x, bbox.bottom);
191
+ }
192
+ });
193
+ toc.toolbar.addItem('submenu', menuButton);
194
+ // Add the ToC to the left area:
195
+ app.shell.add(toc, 'left', { rank: 400, type: 'Table of Contents' });
136
196
  // Update the ToC when the active widget changes:
137
197
  if (labShell) {
138
198
  labShell.currentChanged.connect(onConnect);
139
199
  }
140
- return registry;
200
+ // Connect to current widget
201
+ void app.restored.then(() => {
202
+ onConnect();
203
+ });
204
+ return tracker;
141
205
  /**
142
206
  * Callback invoked when the active widget changes.
143
207
  *
144
208
  * @private
145
209
  */
146
210
  function onConnect() {
211
+ var _a;
147
212
  let widget = app.shell.currentWidget;
148
213
  if (!widget) {
149
214
  return;
150
215
  }
151
- let generator = registry.find(widget);
152
- if (!generator) {
153
- // If the previously used widget is still available, stick with it.
154
- // Otherwise, set the current ToC widget to null.
155
- if (toc.current && toc.current.widget.isDisposed) {
156
- toc.current = null;
216
+ let model = tracker.get(widget);
217
+ if (!model) {
218
+ model = (_a = tocRegistry.getModel(widget, configuration)) !== null && _a !== void 0 ? _a : null;
219
+ if (model) {
220
+ tracker.add(widget, model);
157
221
  }
158
- return;
222
+ widget.disposed.connect(() => {
223
+ model === null || model === void 0 ? void 0 : model.dispose();
224
+ });
225
+ }
226
+ if (toc.model) {
227
+ toc.model.headingsChanged.disconnect(onCollapseChange);
228
+ toc.model.collapseChanged.disconnect(onCollapseChange);
229
+ }
230
+ toc.model = model;
231
+ if (toc.model) {
232
+ toc.model.headingsChanged.connect(onCollapseChange);
233
+ toc.model.collapseChanged.connect(onCollapseChange);
159
234
  }
160
- toc.current = { widget, generator };
235
+ setToolbarButtonsState();
236
+ }
237
+ function setToolbarButtonsState() {
238
+ app.commands.notifyCommandChanged(CommandIDs.displayNumbering);
239
+ app.commands.notifyCommandChanged(CommandIDs.toggleCollapse);
240
+ }
241
+ function onCollapseChange() {
242
+ app.commands.notifyCommandChanged(CommandIDs.toggleCollapse);
161
243
  }
162
244
  }
163
245
  /**
164
- * Initialization data for the ToC extension.
165
- *
166
- * @private
246
+ * Table of contents registry plugin.
167
247
  */
168
- const extension = {
248
+ const registry = {
169
249
  id: '@jupyterlab/toc-extension:registry',
170
250
  autoStart: true,
171
251
  provides: ITableOfContentsRegistry,
172
- requires: [IDocumentManager, IRenderMimeRegistry, ITranslator],
173
- optional: [
174
- IEditorTracker,
175
- ILayoutRestorer,
176
- ILabShell,
177
- IMarkdownViewerTracker,
178
- INotebookTracker,
179
- ISettingRegistry
180
- ],
252
+ activate: () => {
253
+ // Create the ToC registry
254
+ return new TableOfContentsRegistry();
255
+ }
256
+ };
257
+ /**
258
+ * Table of contents tracker plugin.
259
+ */
260
+ const tracker = {
261
+ id: '@jupyterlab/toc-extension:tracker',
262
+ autoStart: true,
263
+ provides: ITableOfContentsTracker,
264
+ requires: [ITableOfContentsRegistry],
265
+ optional: [ITranslator, ILayoutRestorer, ILabShell, ISettingRegistry],
181
266
  activate: activateTOC
182
267
  };
183
268
  /**
184
269
  * Exports.
185
270
  */
186
- export default extension;
271
+ export default [registry, tracker];
187
272
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;AAEH,OAAO,EACL,SAAS,EACT,eAAe,EAGhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,+BAA+B,EAE/B,wBAAwB,EACxB,eAAe,EACf,uBAAuB,EACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD;;GAEG;AACH,IAAU,UAAU,CAIn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C,QAAQ,EAAE,CAAC,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,gBAAgB,CAAC;IACrE,QAAQ,EAAE,WAAW;CACtB,CAAC;AAEF;;GAEG;AACH,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlab/toc-extension",
3
- "version": "6.0.0-alpha.9",
3
+ "version": "6.0.0-beta.1",
4
4
  "description": "JupyterLab - Table of Contents widget extension",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -31,7 +31,8 @@
31
31
  "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
32
32
  "schema/*.json",
33
33
  "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
34
- "style/index.js"
34
+ "style/index.js",
35
+ "src/**/*.{ts,tsx}"
35
36
  ],
36
37
  "scripts": {
37
38
  "build": "tsc -b",
@@ -40,22 +41,16 @@
40
41
  "watch": "tsc -b --watch"
41
42
  },
42
43
  "dependencies": {
43
- "@jupyterlab/application": "^4.0.0-alpha.9",
44
- "@jupyterlab/cells": "^4.0.0-alpha.9",
45
- "@jupyterlab/docmanager": "^4.0.0-alpha.9",
46
- "@jupyterlab/fileeditor": "^4.0.0-alpha.9",
47
- "@jupyterlab/markdownviewer": "^4.0.0-alpha.9",
48
- "@jupyterlab/notebook": "^4.0.0-alpha.9",
49
- "@jupyterlab/rendermime": "^4.0.0-alpha.9",
50
- "@jupyterlab/settingregistry": "^4.0.0-alpha.9",
51
- "@jupyterlab/toc": "^6.0.0-alpha.9",
52
- "@jupyterlab/translation": "^4.0.0-alpha.9",
53
- "@jupyterlab/ui-components": "^4.0.0-alpha.24"
44
+ "@jupyterlab/application": "^4.0.0-beta.1",
45
+ "@jupyterlab/settingregistry": "^4.0.0-beta.1",
46
+ "@jupyterlab/toc": "^6.0.0-beta.1",
47
+ "@jupyterlab/translation": "^4.0.0-beta.1",
48
+ "@jupyterlab/ui-components": "^4.0.0-beta.1"
54
49
  },
55
50
  "devDependencies": {
56
51
  "rimraf": "~3.0.0",
57
- "typedoc": "~0.22.10",
58
- "typescript": "~4.6.3"
52
+ "typedoc": "~0.23.25",
53
+ "typescript": "~5.0.2"
59
54
  },
60
55
  "publishConfig": {
61
56
  "access": "public"
@@ -2,7 +2,7 @@
2
2
  "jupyter.lab.setting-icon": "ui-components:toc",
3
3
  "jupyter.lab.setting-icon-label": "Table of Contents",
4
4
  "title": "Table of Contents",
5
- "description": "Table of contents settings.",
5
+ "description": "Default table of contents settings.",
6
6
  "jupyter.lab.menus": {
7
7
  "main": [
8
8
  {
@@ -18,7 +18,7 @@
18
18
  "context": [
19
19
  {
20
20
  "command": "toc:run-cells",
21
- "selector": ".jp-tocItem"
21
+ "selector": ".jp-TableOfContents-content[data-document-type=\"notebook\"] .jp-tocItem"
22
22
  }
23
23
  ]
24
24
  },
@@ -30,22 +30,34 @@
30
30
  }
31
31
  ],
32
32
  "properties": {
33
+ "maximalDepth": {
34
+ "title": "Maximal headings depth",
35
+ "type": "integer",
36
+ "minimum": 1,
37
+ "default": 4
38
+ },
33
39
  "numberingH1": {
34
- "title": "Enable h1 numbering",
35
- "description": "Whether to number first-level headings",
40
+ "title": "Enable 1st headings numbering",
41
+ "description": "Whether to number first-level headings or not.",
36
42
  "type": "boolean",
37
43
  "default": true
38
44
  },
45
+ "numberHeaders": {
46
+ "title": "Enable headings numbering",
47
+ "description": "Whether to automatically number the headings or not.",
48
+ "type": "boolean",
49
+ "default": false
50
+ },
39
51
  "includeOutput": {
40
52
  "title": "Include cell output in headings",
41
- "description": "Whether to include cell output in headings",
53
+ "description": "Whether to include cell output in headings or not.",
42
54
  "type": "boolean",
43
55
  "default": true
44
56
  },
45
57
  "syncCollapseState": {
46
58
  "type": "boolean",
47
59
  "title": "Synchronize collapse state",
48
- "description": "If set to true, when a header is collapsed in the table of contents the corresponding section in the notebook is collapsed as well and vice versa.",
60
+ "description": "If set to true, when a heading is collapsed in the table of contents the corresponding section in the document is collapsed as well and vice versa. This inhibits the cell output headings.",
49
61
  "default": false
50
62
  }
51
63
  },
package/src/index.ts ADDED
@@ -0,0 +1,340 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ /**
4
+ * @packageDocumentation
5
+ * @module toc-extension
6
+ */
7
+
8
+ import {
9
+ ILabShell,
10
+ ILayoutRestorer,
11
+ JupyterFrontEnd,
12
+ JupyterFrontEndPlugin
13
+ } from '@jupyterlab/application';
14
+ import { ISettingRegistry } from '@jupyterlab/settingregistry';
15
+ import {
16
+ ITableOfContentsRegistry,
17
+ ITableOfContentsTracker,
18
+ TableOfContents,
19
+ TableOfContentsPanel,
20
+ TableOfContentsRegistry,
21
+ TableOfContentsTracker
22
+ } from '@jupyterlab/toc';
23
+ import { ITranslator, nullTranslator } from '@jupyterlab/translation';
24
+ import {
25
+ collapseAllIcon,
26
+ CommandToolbarButton,
27
+ ellipsesIcon,
28
+ expandAllIcon,
29
+ MenuSvg,
30
+ numberingIcon,
31
+ tocIcon,
32
+ Toolbar,
33
+ ToolbarButton
34
+ } from '@jupyterlab/ui-components';
35
+
36
+ /**
37
+ * A namespace for command IDs of table of contents plugin.
38
+ */
39
+ namespace CommandIDs {
40
+ export const displayNumbering = 'toc:display-numbering';
41
+
42
+ export const displayH1Numbering = 'toc:display-h1-numbering';
43
+
44
+ export const displayOutputNumbering = 'toc:display-outputs-numbering';
45
+
46
+ export const showPanel = 'toc:show-panel';
47
+
48
+ export const toggleCollapse = 'toc:toggle-collapse';
49
+ }
50
+
51
+ /**
52
+ * Activates the ToC extension.
53
+ *
54
+ * @private
55
+ * @param app - Jupyter application
56
+ * @param tocRegistry - Table of contents registry
57
+ * @param translator - translator
58
+ * @param restorer - application layout restorer
59
+ * @param labShell - Jupyter lab shell
60
+ * @param settingRegistry - setting registry
61
+ * @returns table of contents registry
62
+ */
63
+ async function activateTOC(
64
+ app: JupyterFrontEnd,
65
+ tocRegistry: ITableOfContentsRegistry,
66
+ translator?: ITranslator | null,
67
+ restorer?: ILayoutRestorer | null,
68
+ labShell?: ILabShell | null,
69
+ settingRegistry?: ISettingRegistry | null
70
+ ): Promise<ITableOfContentsTracker> {
71
+ const trans = (translator ?? nullTranslator).load('jupyterlab');
72
+ let configuration = { ...TableOfContents.defaultConfig };
73
+
74
+ // Create the ToC widget:
75
+ const toc = new TableOfContentsPanel(translator ?? undefined);
76
+ toc.title.icon = tocIcon;
77
+ toc.title.caption = trans.__('Table of Contents');
78
+ toc.id = 'table-of-contents';
79
+ toc.node.setAttribute('role', 'region');
80
+ toc.node.setAttribute('aria-label', trans.__('Table of Contents section'));
81
+
82
+ app.commands.addCommand(CommandIDs.displayH1Numbering, {
83
+ label: trans.__('Show first-level heading number'),
84
+ execute: () => {
85
+ if (toc.model) {
86
+ toc.model.setConfiguration({
87
+ numberingH1: !toc.model.configuration.numberingH1
88
+ });
89
+ }
90
+ },
91
+ isEnabled: () =>
92
+ toc.model?.supportedOptions.includes('numberingH1') ?? false,
93
+ isToggled: () => toc.model?.configuration.numberingH1 ?? false
94
+ });
95
+
96
+ app.commands.addCommand(CommandIDs.displayNumbering, {
97
+ label: trans.__('Show heading number in the document'),
98
+ icon: args => (args.toolbar ? numberingIcon : undefined),
99
+ execute: () => {
100
+ if (toc.model) {
101
+ toc.model.setConfiguration({
102
+ numberHeaders: !toc.model.configuration.numberHeaders
103
+ });
104
+ app.commands.notifyCommandChanged(CommandIDs.displayNumbering);
105
+ }
106
+ },
107
+ isEnabled: () =>
108
+ toc.model?.supportedOptions.includes('numberHeaders') ?? false,
109
+ isToggled: () => toc.model?.configuration.numberHeaders ?? false
110
+ });
111
+
112
+ app.commands.addCommand(CommandIDs.displayOutputNumbering, {
113
+ label: trans.__('Show output headings'),
114
+ execute: () => {
115
+ if (toc.model) {
116
+ toc.model.setConfiguration({
117
+ includeOutput: !toc.model.configuration.includeOutput
118
+ });
119
+ }
120
+ },
121
+ isEnabled: () =>
122
+ toc.model?.supportedOptions.includes('includeOutput') ?? false,
123
+ isToggled: () => toc.model?.configuration.includeOutput ?? false
124
+ });
125
+
126
+ app.commands.addCommand(CommandIDs.showPanel, {
127
+ label: trans.__('Table of Contents'),
128
+ execute: () => {
129
+ app.shell.activateById(toc.id);
130
+ }
131
+ });
132
+
133
+ function someExpanded(model: TableOfContents.Model): boolean {
134
+ return model.headings.some(h => !(h.collapsed ?? false));
135
+ }
136
+
137
+ app.commands.addCommand(CommandIDs.toggleCollapse, {
138
+ label: () =>
139
+ toc.model && !someExpanded(toc.model)
140
+ ? trans.__('Expand All Headings')
141
+ : trans.__('Collapse All Headings'),
142
+ icon: args =>
143
+ args.toolbar
144
+ ? toc.model && !someExpanded(toc.model)
145
+ ? expandAllIcon
146
+ : collapseAllIcon
147
+ : undefined,
148
+ execute: () => {
149
+ if (toc.model) {
150
+ if (someExpanded(toc.model)) {
151
+ toc.model.toggleCollapse({ collapsed: true });
152
+ } else {
153
+ toc.model.toggleCollapse({ collapsed: false });
154
+ }
155
+ }
156
+ },
157
+ isEnabled: () => toc.model !== null
158
+ });
159
+
160
+ const tracker = new TableOfContentsTracker();
161
+
162
+ if (restorer) {
163
+ // Add the ToC widget to the application restorer:
164
+ restorer.add(toc, '@jupyterlab/toc:plugin');
165
+ }
166
+
167
+ // Attempt to load plugin settings:
168
+ let settings: ISettingRegistry.ISettings | undefined;
169
+ if (settingRegistry) {
170
+ try {
171
+ settings = await settingRegistry.load(registry.id);
172
+ const updateSettings = (plugin: ISettingRegistry.ISettings) => {
173
+ const composite = plugin.composite;
174
+ for (const key of [...Object.keys(configuration)]) {
175
+ const value = composite[key] as any;
176
+ if (value !== undefined) {
177
+ configuration[key] = value;
178
+ }
179
+ }
180
+
181
+ if (labShell) {
182
+ for (const widget of labShell.widgets('main')) {
183
+ const model = tracker.get(widget);
184
+ if (model) {
185
+ model.setConfiguration(configuration);
186
+ }
187
+ }
188
+ } else {
189
+ if (app.shell.currentWidget) {
190
+ const model = tracker.get(app.shell.currentWidget);
191
+ if (model) {
192
+ model.setConfiguration(configuration);
193
+ }
194
+ }
195
+ }
196
+ };
197
+ if (settings) {
198
+ settings.changed.connect(updateSettings);
199
+ updateSettings(settings);
200
+ }
201
+ } catch (error) {
202
+ console.error(
203
+ `Failed to load settings for the Table of Contents extension.\n\n${error}`
204
+ );
205
+ }
206
+ }
207
+
208
+ // Set up the panel toolbar
209
+ const numbering = new CommandToolbarButton({
210
+ commands: app.commands,
211
+ id: CommandIDs.displayNumbering,
212
+ args: {
213
+ toolbar: true
214
+ },
215
+ label: ''
216
+ });
217
+ numbering.addClass('jp-toc-numberingButton');
218
+ toc.toolbar.addItem('display-numbering', numbering);
219
+
220
+ toc.toolbar.addItem('spacer', Toolbar.createSpacerItem());
221
+
222
+ toc.toolbar.addItem(
223
+ 'collapse-all',
224
+ new CommandToolbarButton({
225
+ commands: app.commands,
226
+ id: CommandIDs.toggleCollapse,
227
+ args: {
228
+ toolbar: true
229
+ },
230
+ label: ''
231
+ })
232
+ );
233
+
234
+ const toolbarMenu = new MenuSvg({ commands: app.commands });
235
+ toolbarMenu.addItem({
236
+ command: CommandIDs.displayH1Numbering
237
+ });
238
+ toolbarMenu.addItem({
239
+ command: CommandIDs.displayOutputNumbering
240
+ });
241
+ const menuButton = new ToolbarButton({
242
+ tooltip: trans.__('More actions…'),
243
+ icon: ellipsesIcon,
244
+ actualOnClick: true,
245
+ onClick: () => {
246
+ const bbox = menuButton.node.getBoundingClientRect();
247
+ toolbarMenu.open(bbox.x, bbox.bottom);
248
+ }
249
+ });
250
+ toc.toolbar.addItem('submenu', menuButton);
251
+
252
+ // Add the ToC to the left area:
253
+ app.shell.add(toc, 'left', { rank: 400, type: 'Table of Contents' });
254
+
255
+ // Update the ToC when the active widget changes:
256
+ if (labShell) {
257
+ labShell.currentChanged.connect(onConnect);
258
+ }
259
+
260
+ // Connect to current widget
261
+ void app.restored.then(() => {
262
+ onConnect();
263
+ });
264
+
265
+ return tracker;
266
+
267
+ /**
268
+ * Callback invoked when the active widget changes.
269
+ *
270
+ * @private
271
+ */
272
+ function onConnect() {
273
+ let widget = app.shell.currentWidget;
274
+ if (!widget) {
275
+ return;
276
+ }
277
+ let model = tracker.get(widget);
278
+ if (!model) {
279
+ model = tocRegistry.getModel(widget, configuration) ?? null;
280
+ if (model) {
281
+ tracker.add(widget, model);
282
+ }
283
+
284
+ widget.disposed.connect(() => {
285
+ model?.dispose();
286
+ });
287
+ }
288
+
289
+ if (toc.model) {
290
+ toc.model.headingsChanged.disconnect(onCollapseChange);
291
+ toc.model.collapseChanged.disconnect(onCollapseChange);
292
+ }
293
+
294
+ toc.model = model;
295
+ if (toc.model) {
296
+ toc.model.headingsChanged.connect(onCollapseChange);
297
+ toc.model.collapseChanged.connect(onCollapseChange);
298
+ }
299
+ setToolbarButtonsState();
300
+ }
301
+
302
+ function setToolbarButtonsState() {
303
+ app.commands.notifyCommandChanged(CommandIDs.displayNumbering);
304
+ app.commands.notifyCommandChanged(CommandIDs.toggleCollapse);
305
+ }
306
+
307
+ function onCollapseChange() {
308
+ app.commands.notifyCommandChanged(CommandIDs.toggleCollapse);
309
+ }
310
+ }
311
+
312
+ /**
313
+ * Table of contents registry plugin.
314
+ */
315
+ const registry: JupyterFrontEndPlugin<ITableOfContentsRegistry> = {
316
+ id: '@jupyterlab/toc-extension:registry',
317
+ autoStart: true,
318
+ provides: ITableOfContentsRegistry,
319
+ activate: (): ITableOfContentsRegistry => {
320
+ // Create the ToC registry
321
+ return new TableOfContentsRegistry();
322
+ }
323
+ };
324
+
325
+ /**
326
+ * Table of contents tracker plugin.
327
+ */
328
+ const tracker: JupyterFrontEndPlugin<ITableOfContentsTracker> = {
329
+ id: '@jupyterlab/toc-extension:tracker',
330
+ autoStart: true,
331
+ provides: ITableOfContentsTracker,
332
+ requires: [ITableOfContentsRegistry],
333
+ optional: [ITranslator, ILayoutRestorer, ILabShell, ISettingRegistry],
334
+ activate: activateTOC
335
+ };
336
+
337
+ /**
338
+ * Exports.
339
+ */
340
+ export default [registry, tracker];
package/style/base.css ADDED
@@ -0,0 +1,16 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+
6
+ .jp-toc-numberingButton:hover button.lm-mod-toggled.jp-Button.jp-mod-minimal {
7
+ background-color: var(--jp-inverse-layout-color4);
8
+ }
9
+
10
+ .jp-toc-numberingButton button.lm-mod-toggled .jp-icon3[fill] {
11
+ fill: var(--jp-layout-color1);
12
+ }
13
+
14
+ .jp-toc-numberingButton button.lm-mod-toggled.jp-Button.jp-mod-minimal {
15
+ background-color: var(--jp-inverse-layout-color3);
16
+ }
package/style/index.css CHANGED
@@ -5,11 +5,7 @@
5
5
 
6
6
  /* This file was auto-generated by ensurePackage() in @jupyterlab/buildutils */
7
7
  @import url('~@jupyterlab/ui-components/style/index.css');
8
- @import url('~@jupyterlab/rendermime/style/index.css');
9
8
  @import url('~@jupyterlab/application/style/index.css');
10
- @import url('~@jupyterlab/docmanager/style/index.css');
11
- @import url('~@jupyterlab/cells/style/index.css');
12
- @import url('~@jupyterlab/fileeditor/style/index.css');
13
- @import url('~@jupyterlab/markdownviewer/style/index.css');
14
- @import url('~@jupyterlab/notebook/style/index.css');
15
9
  @import url('~@jupyterlab/toc/style/index.css');
10
+
11
+ @import url('./base.css');
package/style/index.js CHANGED
@@ -5,11 +5,7 @@
5
5
 
6
6
  /* This file was auto-generated by ensurePackage() in @jupyterlab/buildutils */
7
7
  import '@jupyterlab/ui-components/style/index.js';
8
- import '@jupyterlab/rendermime/style/index.js';
9
8
  import '@jupyterlab/application/style/index.js';
10
- import '@jupyterlab/docmanager/style/index.js';
11
- import '@jupyterlab/cells/style/index.js';
12
- import '@jupyterlab/fileeditor/style/index.js';
13
- import '@jupyterlab/markdownviewer/style/index.js';
14
- import '@jupyterlab/notebook/style/index.js';
15
9
  import '@jupyterlab/toc/style/index.js';
10
+
11
+ import './base.css';