@jupyterlab/fileeditor 4.0.0-alpha.9 → 4.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.
Files changed (49) hide show
  1. package/lib/fileeditorlspadapter.d.ts +96 -0
  2. package/lib/fileeditorlspadapter.js +175 -0
  3. package/lib/fileeditorlspadapter.js.map +1 -0
  4. package/lib/index.d.ts +4 -0
  5. package/lib/index.js +4 -0
  6. package/lib/index.js.map +1 -1
  7. package/lib/searchprovider.d.ts +60 -0
  8. package/lib/searchprovider.js +80 -0
  9. package/lib/searchprovider.js.map +1 -0
  10. package/lib/syntaxstatus.d.ts +74 -0
  11. package/lib/syntaxstatus.js +151 -0
  12. package/lib/syntaxstatus.js.map +1 -0
  13. package/lib/tabspacestatus.d.ts +8 -12
  14. package/lib/tabspacestatus.js +23 -27
  15. package/lib/tabspacestatus.js.map +1 -1
  16. package/lib/toc/factory.d.ts +25 -0
  17. package/lib/toc/factory.js +32 -0
  18. package/lib/toc/factory.js.map +1 -0
  19. package/lib/toc/index.d.ts +4 -0
  20. package/lib/toc/index.js +7 -0
  21. package/lib/toc/index.js.map +1 -0
  22. package/lib/toc/latex.d.ts +48 -0
  23. package/lib/toc/latex.js +117 -0
  24. package/lib/toc/latex.js.map +1 -0
  25. package/lib/toc/markdown.d.ts +44 -0
  26. package/lib/toc/markdown.js +68 -0
  27. package/lib/toc/markdown.js.map +1 -0
  28. package/lib/toc/python.d.ts +44 -0
  29. package/lib/toc/python.js +116 -0
  30. package/lib/toc/python.js.map +1 -0
  31. package/lib/widget.d.ts +4 -0
  32. package/lib/widget.js +21 -4
  33. package/lib/widget.js.map +1 -1
  34. package/package.json +26 -21
  35. package/src/fileeditorlspadapter.ts +225 -0
  36. package/src/index.ts +14 -0
  37. package/src/searchprovider.ts +115 -0
  38. package/src/syntaxstatus.tsx +217 -0
  39. package/src/tabspacestatus.tsx +166 -0
  40. package/src/toc/factory.ts +72 -0
  41. package/src/toc/index.ts +7 -0
  42. package/src/toc/latex.ts +145 -0
  43. package/src/toc/markdown.ts +90 -0
  44. package/src/toc/python.ts +143 -0
  45. package/src/tokens.ts +20 -0
  46. package/src/widget.ts +267 -0
  47. package/style/base.css +8 -0
  48. package/style/index.css +4 -0
  49. package/style/index.js +4 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntaxstatus.js","sourceRoot":"","sources":["../src/syntaxstatus.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAc,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAG5E,OAAO,EAAS,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAe,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGpE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAwB1B;;;;;;GAMG;AACH,SAAS,qBAAqB,CAC5B,KAAmC;IAEnC,OAAO,oBAAC,QAAQ,IAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,WAAW,GAAI,CAAC;AAC1E,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,YAAsC;IAC5E;;OAEG;IACH,YAAY,OAAoC;;QAC9C,KAAK,CAAC,IAAI,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;QAwBzD;;WAEG;QACK,iBAAY,GAAG,GAAG,EAAE;YAC1B,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;YAC5D,MAAM,OAAO,GAAG,4BAA4B,CAAC;YAC7C,IAAI,IAAI,CAAC,MAAM,EAAE;gBACf,IAAI,CAAC,MAAM,CAAC,OAAO,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AI,EAAE;gBACtB,SAAS,CAAC,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACpE;YACD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC;YACnC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;YACtB,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;gBACzB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;aACrB;iBAAM;gBACL,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBACpE,IAAI,CAAC,SAAS,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,mCAAI,sBAAsB,CAAC,eAAe,CAAC;gBAEtE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACpE;YAED,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;QAgBD;;WAEG;QACK,cAAc,CAAC,QAAgB,EAAE,QAAgB;YACvD,IAAI,QAAQ,KAAK,QAAQ,EAAE;gBACzB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;aAChC;QACH,CAAC;KAIF;IA9DY,wBAAK,QA8DjB,CAAA;AAqBH,CAAC,EAvFgB,kBAAkB,KAAlB,kBAAkB,QAuFlC"}
@@ -1,4 +1,3 @@
1
- import { CodeEditor } from '@jupyterlab/codeeditor';
2
1
  import { ITranslator } from '@jupyterlab/translation';
3
2
  import { VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
4
3
  import { Menu } from '@lumino/widgets';
@@ -12,13 +11,11 @@ declare namespace TabSpaceComponent {
12
11
  */
13
12
  interface IProps {
14
13
  /**
15
- * The number of spaces to insert on tab.
14
+ * The number of spaces for indentation.
15
+ *
16
+ * `null` means use tab character for indentation.
16
17
  */
17
- tabSpace: number;
18
- /**
19
- * Whether to use spaces or tabs.
20
- */
21
- isSpaces: boolean;
18
+ tabSpace: number | null;
22
19
  /**
23
20
  * The application language translator.
24
21
  */
@@ -64,12 +61,11 @@ export declare namespace TabSpaceStatus {
64
61
  */
65
62
  class Model extends VDomModel {
66
63
  /**
67
- * The editor config from the settings system.
64
+ * Code editor indentation unit
68
65
  */
69
- get config(): CodeEditor.IConfig | null;
70
- set config(val: CodeEditor.IConfig | null);
71
- private _triggerChange;
72
- private _config;
66
+ get indentUnit(): string | null;
67
+ set indentUnit(v: string | null);
68
+ private _indentUnit;
73
69
  }
74
70
  /**
75
71
  * Options for creating a TabSpace status item.
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Jupyter Development Team.
2
2
  // Distributed under the terms of the Modified BSD License.
3
- import { clickedItem, interactiveItem, showPopup, TextItem } from '@jupyterlab/statusbar';
3
+ import { showPopup, TextItem } from '@jupyterlab/statusbar';
4
4
  import { nullTranslator } from '@jupyterlab/translation';
5
5
  import { VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
6
6
  import React from 'react';
@@ -10,10 +10,12 @@ import React from 'react';
10
10
  function TabSpaceComponent(props) {
11
11
  const translator = props.translator || nullTranslator;
12
12
  const trans = translator.load('jupyterlab');
13
- const description = props.isSpaces
13
+ const description = typeof props.tabSpace === 'number'
14
14
  ? trans.__('Spaces')
15
- : trans.__('Tab Size');
16
- return (React.createElement(TextItem, { onClick: props.handleClick, source: `${description}: ${props.tabSpace}`, title: trans.__('Change Tab indentation…') }));
15
+ : trans.__('Tab Indent');
16
+ return (React.createElement(TextItem, { onClick: props.handleClick, source: typeof props.tabSpace === 'number'
17
+ ? `${description}: ${props.tabSpace}`
18
+ : description, title: trans.__('Change the indentation…') }));
17
19
  }
18
20
  /**
19
21
  * A VDomRenderer for a tabs vs. spaces status item.
@@ -27,17 +29,21 @@ export class TabSpaceStatus extends VDomRenderer {
27
29
  this._popup = null;
28
30
  this._menu = options.menu;
29
31
  this.translator = options.translator || nullTranslator;
30
- this.addClass(interactiveItem);
32
+ this.addClass('jp-mod-highlighted');
31
33
  }
32
34
  /**
33
35
  * Render the TabSpace status item.
34
36
  */
35
37
  render() {
36
- if (!this.model || !this.model.config) {
38
+ var _a;
39
+ if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.indentUnit)) {
37
40
  return null;
38
41
  }
39
42
  else {
40
- return (React.createElement(TabSpaceComponent, { isSpaces: this.model.config.insertSpaces, tabSpace: this.model.config.tabSize, handleClick: () => this._handleClick(), translator: this.translator }));
43
+ const tabSpace = this.model.indentUnit === 'Tab'
44
+ ? null
45
+ : parseInt(this.model.indentUnit, 10);
46
+ return (React.createElement(TabSpaceComponent, { tabSpace: tabSpace, handleClick: () => this._handleClick(), translator: this.translator }));
41
47
  }
42
48
  }
43
49
  /**
@@ -54,9 +60,11 @@ export class TabSpaceStatus extends VDomRenderer {
54
60
  anchor: this,
55
61
  align: 'right'
56
62
  });
63
+ // Update the menu items
64
+ menu.update();
57
65
  }
58
66
  _menuClosed() {
59
- this.removeClass(clickedItem);
67
+ this.removeClass('jp-mod-clicked');
60
68
  }
61
69
  }
62
70
  /**
@@ -67,28 +75,16 @@ export class TabSpaceStatus extends VDomRenderer {
67
75
  * A VDomModel for the TabSpace status item.
68
76
  */
69
77
  class Model extends VDomModel {
70
- constructor() {
71
- super(...arguments);
72
- this._config = null;
73
- }
74
78
  /**
75
- * The editor config from the settings system.
79
+ * Code editor indentation unit
76
80
  */
77
- get config() {
78
- return this._config;
79
- }
80
- set config(val) {
81
- const oldConfig = this._config;
82
- this._config = val;
83
- this._triggerChange(oldConfig, this._config);
81
+ get indentUnit() {
82
+ return this._indentUnit;
84
83
  }
85
- _triggerChange(oldValue, newValue) {
86
- const oldSpaces = oldValue && oldValue.insertSpaces;
87
- const oldSize = oldValue && oldValue.tabSize;
88
- const newSpaces = newValue && newValue.insertSpaces;
89
- const newSize = newValue && newValue.tabSize;
90
- if (oldSpaces !== newSpaces || oldSize !== newSize) {
91
- this.stateChanged.emit(void 0);
84
+ set indentUnit(v) {
85
+ if (v !== this._indentUnit) {
86
+ this._indentUnit = v;
87
+ this.stateChanged.emit();
92
88
  }
93
89
  }
94
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tabspacestatus.js","sourceRoot":"","sources":["../src/tabspacestatus.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EACL,WAAW,EACX,eAAe,EAEf,SAAS,EACT,QAAQ,EACT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAe,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAiC1B;;GAEG;AACH,SAAS,iBAAiB,CACxB,KAA+B;IAE/B,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,cAAc,CAAC;IACtD,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ;QAChC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC;QACpB,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;IACzB,OAAO,CACL,oBAAC,QAAQ,IACP,OAAO,EAAE,KAAK,CAAC,WAAW,EAC1B,MAAM,EAAE,GAAG,WAAW,KAAK,KAAK,CAAC,QAAQ,EAAE,EAC3C,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAAC,GAC1C,CACH,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,YAAkC;IACpE;;OAEG;IACH,YAAY,OAAgC;QAC1C,KAAK,CAAC,IAAI,cAAc,CAAC,KAAK,E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Factory, TableOfContentsModel } from '@jupyterlab/toc';
3
+ import { FileEditor } from '../widget';
4
+ /**
5
+ * Interface describing a file editor heading.
6
+ */
7
+ export interface IEditorHeading extends TableOfContents.IHeading {
8
+ /**
9
+ * Heading line number.
10
+ */
11
+ line: number;
12
+ }
13
+ /**
14
+ * Base table of contents model factory for file editor
15
+ */
16
+ export declare abstract class EditorTableOfContentsFactory extends TableOfContentsFactory<IDocumentWidget<FileEditor>> {
17
+ /**
18
+ * Create a new table of contents model for the widget
19
+ *
20
+ * @param widget - widget
21
+ * @param configuration - Table of contents configuration
22
+ * @returns The table of contents model
23
+ */
24
+ createNew(widget: IDocumentWidget<FileEditor, DocumentRegistry.IModel>, configuration?: TableOfContents.IConfig): TableOfContentsModel<IEditorHeading, IDocumentWidget<FileEditor, DocumentRegistry.IModel>>;
25
+ }
@@ -0,0 +1,32 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { TableOfContentsFactory } from '@jupyterlab/toc';
4
+ /**
5
+ * Base table of contents model factory for file editor
6
+ */
7
+ export class EditorTableOfContentsFactory extends TableOfContentsFactory {
8
+ /**
9
+ * Create a new table of contents model for the widget
10
+ *
11
+ * @param widget - widget
12
+ * @param configuration - Table of contents configuration
13
+ * @returns The table of contents model
14
+ */
15
+ createNew(widget, configuration) {
16
+ const model = super.createNew(widget, configuration);
17
+ const onActiveHeadingChanged = (model, heading) => {
18
+ if (heading) {
19
+ widget.content.editor.setCursorPosition({
20
+ line: heading.line,
21
+ column: 0
22
+ });
23
+ }
24
+ };
25
+ model.activeHeadingChanged.connect(onActiveHeadingChanged);
26
+ widget.disposed.connect(() => {
27
+ model.activeHeadingChanged.disconnect(onActiveHeadingChanged);
28
+ });
29
+ return model;
30
+ }
31
+ }
32
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/toc/factory.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EAEL,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAazB;;GAEG;AACH,MAAM,OAAgB,4BAA6B,SAAQ,sBAE1D;IACC;;;;;;OAMG;IACH,SAAS,CACP,MAA4D,EAC5D,aAAuC;QAKvC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAC3B,MAAM,EACN,aAAa,CAId,CAAC;QAEF,MAAM,sBAAsB,GAAG,CAC7B,KAGC,EACD,OAA8B,EAC9B,EAAE;YACF,IAAI,OAAO,EAAE;gBACX,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC;oBACtC,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,MAAM,EAAE,CAAC;iBACV,CAAC,CAAC;aACJ;QACH,CAAC,CAAC;QAEF,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QAC3D,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE;YAC3B,KAAK,CAAC,oBAAoB,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export * from './factory';
2
+ export * from './latex';
3
+ export * from './markdown';
4
+ export * from './python';
@@ -0,0 +1,7 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ export * from './factory';
4
+ export * from './latex';
5
+ export * from './markdown';
6
+ export * from './python';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/toc/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry';
2
+ import { TableOfContents, TableOfContentsModel } from '@jupyterlab/toc';
3
+ import { Widget } from '@lumino/widgets';
4
+ import { FileEditor } from '../widget';
5
+ import { EditorTableOfContentsFactory, IEditorHeading } from './factory';
6
+ /**
7
+ * Table of content model for LaTeX files.
8
+ */
9
+ export declare class LaTeXTableOfContentsModel extends TableOfContentsModel<IEditorHeading, IDocumentWidget<FileEditor, DocumentRegistry.IModel>> {
10
+ /**
11
+ * Type of document supported by the model.
12
+ *
13
+ * #### Notes
14
+ * A `data-document-type` attribute with this value will be set
15
+ * on the tree view `.jp-TableOfContents-content[data-document-type="..."]`
16
+ */
17
+ get documentType(): string;
18
+ /**
19
+ * List of configuration options supported by the model.
20
+ */
21
+ get supportedOptions(): (keyof TableOfContents.IConfig)[];
22
+ /**
23
+ * Produce the headings for a document.
24
+ *
25
+ * @returns The list of new headings or `null` if nothing needs to be updated.
26
+ */
27
+ protected getHeadings(): Promise<IEditorHeading[] | null>;
28
+ }
29
+ /**
30
+ * Table of content model factory for LaTeX files.
31
+ */
32
+ export declare class LaTeXTableOfContentsFactory extends EditorTableOfContentsFactory {
33
+ /**
34
+ * Whether the factory can handle the widget or not.
35
+ *
36
+ * @param widget - widget
37
+ * @returns boolean indicating a ToC can be generated
38
+ */
39
+ isApplicable(widget: Widget): boolean;
40
+ /**
41
+ * Create a new table of contents model for the widget
42
+ *
43
+ * @param widget - widget
44
+ * @param configuration - Table of contents configuration
45
+ * @returns The table of contents model
46
+ */
47
+ protected _createNew(widget: IDocumentWidget<FileEditor, DocumentRegistry.IModel>, configuration?: TableOfContents.IConfig): LaTeXTableOfContentsModel;
48
+ }
@@ -0,0 +1,117 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { TableOfContentsModel, TableOfContentsUtils } from '@jupyterlab/toc';
4
+ import { EditorTableOfContentsFactory } from './factory';
5
+ /**
6
+ * Maps LaTeX section headings to HTML header levels.
7
+ *
8
+ * ## Notes
9
+ *
10
+ * - As `part` and `chapter` section headings appear to be less common, assign them to heading level 1.
11
+ *
12
+ * @private
13
+ */
14
+ const LATEX_LEVELS = {
15
+ part: 1,
16
+ chapter: 1,
17
+ section: 1,
18
+ subsection: 2,
19
+ subsubsection: 3,
20
+ paragraph: 4,
21
+ subparagraph: 5
22
+ };
23
+ /**
24
+ * Regular expression to create the outline
25
+ */
26
+ const SECTIONS = /^\s*\\(section|subsection|subsubsection){(.+)}/;
27
+ /**
28
+ * Table of content model for LaTeX files.
29
+ */
30
+ export class LaTeXTableOfContentsModel extends TableOfContentsModel {
31
+ /**
32
+ * Type of document supported by the model.
33
+ *
34
+ * #### Notes
35
+ * A `data-document-type` attribute with this value will be set
36
+ * on the tree view `.jp-TableOfContents-content[data-document-type="..."]`
37
+ */
38
+ get documentType() {
39
+ return 'latex';
40
+ }
41
+ /**
42
+ * List of configuration options supported by the model.
43
+ */
44
+ get supportedOptions() {
45
+ return ['maximalDepth', 'numberHeaders'];
46
+ }
47
+ /**
48
+ * Produce the headings for a document.
49
+ *
50
+ * @returns The list of new headings or `null` if nothing needs to be updated.
51
+ */
52
+ getHeadings() {
53
+ if (!this.isActive) {
54
+ return Promise.resolve(null);
55
+ }
56
+ // Split the text into lines:
57
+ const lines = this.widget.content.model.sharedModel
58
+ .getSource()
59
+ .split('\n');
60
+ const levels = new Array();
61
+ let previousLevel = levels.length;
62
+ const headings = new Array();
63
+ for (let i = 0; i < lines.length; i++) {
64
+ const match = lines[i].match(SECTIONS);
65
+ if (match) {
66
+ const level = LATEX_LEVELS[match[1]];
67
+ if (level <= this.configuration.maximalDepth) {
68
+ const prefix = TableOfContentsUtils.getPrefix(level, previousLevel, levels, {
69
+ ...this.configuration,
70
+ // Force base numbering and numbering first level
71
+ baseNumbering: 1,
72
+ numberingH1: true
73
+ });
74
+ previousLevel = level;
75
+ headings.push({
76
+ text: match[2],
77
+ prefix: prefix,
78
+ level,
79
+ line: i
80
+ });
81
+ }
82
+ }
83
+ }
84
+ return Promise.resolve(headings);
85
+ }
86
+ }
87
+ /**
88
+ * Table of content model factory for LaTeX files.
89
+ */
90
+ export class LaTeXTableOfContentsFactory extends EditorTableOfContentsFactory {
91
+ /**
92
+ * Whether the factory can handle the widget or not.
93
+ *
94
+ * @param widget - widget
95
+ * @returns boolean indicating a ToC can be generated
96
+ */
97
+ isApplicable(widget) {
98
+ var _a, _b;
99
+ const isApplicable = super.isApplicable(widget);
100
+ if (isApplicable) {
101
+ let mime = (_b = (_a = widget.content) === null || _a === void 0 ? void 0 : _a.model) === null || _b === void 0 ? void 0 : _b.mimeType;
102
+ return mime && (mime === 'text/x-latex' || mime === 'text/x-stex');
103
+ }
104
+ return false;
105
+ }
106
+ /**
107
+ * Create a new table of contents model for the widget
108
+ *
109
+ * @param widget - widget
110
+ * @param configuration - Table of contents configuration
111
+ * @returns The table of contents model
112
+ */
113
+ _createNew(widget, configuration) {
114
+ return new LaTeXTableOfContentsModel(widget, configuration);
115
+ }
116
+ }
117
+ //# sourceMappingURL=latex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latex.js","sourceRoot":"","sources":["../../src/toc/latex.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EAEL,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,4BAA4B,EAAkB,MAAM,WAAW,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,YAAY,GAAgC;IAChD,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,CAAC;IAChB,SAAS,EAAE,CAAC;IACZ,YAAY,EAAE,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,QAAQ,GAAG,gDAAgD,CAAC;AAElE;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAA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C,CAAC,CAAC;wBACd,MAAM,EAAE,MAAM;wBACd,KAAK;wBACL,IAAI,EAAE,CAAC;qBACR,CAAC,CAAC;iBACJ;aACF;SACF;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,4BAA4B;IAC3E;;;;;OAKG;IACH,YAAY,CAAC,MAAc;;QACzB,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAEhD,IAAI,YAAY,EAAE;YAChB,IAAI,IAAI,GAAG,MAAA,MAAC,MAAc,CAAC,OAAO,0CAAE,KAAK,0CAAE,QAAQ,CAAC;YACpD,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,KAAK,aAAa,CAAC,CAAC;SACpE;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;OAMG;IACO,UAAU,CAClB,MAA4D,EAC5D,aAAuC;QAEvC,OAAO,IAAI,yBAAyB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC9D,CAAC;CACF"}
@@ -0,0 +1,44 @@
1
+ import { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry';
2
+ import { TableOfContents, TableOfContentsModel } from '@jupyterlab/toc';
3
+ import { Widget } from '@lumino/widgets';
4
+ import { FileEditor } from '../widget';
5
+ import { EditorTableOfContentsFactory, IEditorHeading } from './factory';
6
+ /**
7
+ * Table of content model for Markdown files.
8
+ */
9
+ export declare class MarkdownTableOfContentsModel extends TableOfContentsModel<IEditorHeading, IDocumentWidget<FileEditor, DocumentRegistry.IModel>> {
10
+ /**
11
+ * Type of document supported by the model.
12
+ *
13
+ * #### Notes
14
+ * A `data-document-type` attribute with this value will be set
15
+ * on the tree view `.jp-TableOfContents-content[data-document-type="..."]`
16
+ */
17
+ get documentType(): string;
18
+ /**
19
+ * Produce the headings for a document.
20
+ *
21
+ * @returns The list of new headings or `null` if nothing needs to be updated.
22
+ */
23
+ protected getHeadings(): Promise<IEditorHeading[] | null>;
24
+ }
25
+ /**
26
+ * Table of content model factory for Markdown files.
27
+ */
28
+ export declare class MarkdownTableOfContentsFactory extends EditorTableOfContentsFactory {
29
+ /**
30
+ * Whether the factory can handle the widget or not.
31
+ *
32
+ * @param widget - widget
33
+ * @returns boolean indicating a ToC can be generated
34
+ */
35
+ isApplicable(widget: Widget): boolean;
36
+ /**
37
+ * Create a new table of contents model for the widget
38
+ *
39
+ * @param widget - widget
40
+ * @param configuration - Table of contents configuration
41
+ * @returns The table of contents model
42
+ */
43
+ protected _createNew(widget: IDocumentWidget<FileEditor, DocumentRegistry.IModel>, configuration?: TableOfContents.IConfig): MarkdownTableOfContentsModel;
44
+ }
@@ -0,0 +1,68 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { TableOfContentsModel, TableOfContentsUtils } from '@jupyterlab/toc';
4
+ import { EditorTableOfContentsFactory } from './factory';
5
+ /**
6
+ * Table of content model for Markdown files.
7
+ */
8
+ export class MarkdownTableOfContentsModel extends TableOfContentsModel {
9
+ /**
10
+ * Type of document supported by the model.
11
+ *
12
+ * #### Notes
13
+ * A `data-document-type` attribute with this value will be set
14
+ * on the tree view `.jp-TableOfContents-content[data-document-type="..."]`
15
+ */
16
+ get documentType() {
17
+ return 'markdown';
18
+ }
19
+ /**
20
+ * Produce the headings for a document.
21
+ *
22
+ * @returns The list of new headings or `null` if nothing needs to be updated.
23
+ */
24
+ getHeadings() {
25
+ if (!this.isActive) {
26
+ return Promise.resolve(null);
27
+ }
28
+ const content = this.widget.content.model.sharedModel.getSource();
29
+ const headings = TableOfContentsUtils.filterHeadings(TableOfContentsUtils.Markdown.getHeadings(content), {
30
+ ...this.configuration,
31
+ // Force removing numbering as they cannot be displayed
32
+ // in the document
33
+ numberHeaders: false
34
+ });
35
+ return Promise.resolve(headings);
36
+ }
37
+ }
38
+ /**
39
+ * Table of content model factory for Markdown files.
40
+ */
41
+ export class MarkdownTableOfContentsFactory extends EditorTableOfContentsFactory {
42
+ /**
43
+ * Whether the factory can handle the widget or not.
44
+ *
45
+ * @param widget - widget
46
+ * @returns boolean indicating a ToC can be generated
47
+ */
48
+ isApplicable(widget) {
49
+ var _a, _b;
50
+ const isApplicable = super.isApplicable(widget);
51
+ if (isApplicable) {
52
+ let mime = (_b = (_a = widget.content) === null || _a === void 0 ? void 0 : _a.model) === null || _b === void 0 ? void 0 : _b.mimeType;
53
+ return mime && TableOfContentsUtils.Markdown.isMarkdown(mime);
54
+ }
55
+ return false;
56
+ }
57
+ /**
58
+ * Create a new table of contents model for the widget
59
+ *
60
+ * @param widget - widget
61
+ * @param configuration - Table of contents configuration
62
+ * @returns The table of contents model
63
+ */
64
+ _createNew(widget, configuration) {
65
+ return new MarkdownTableOfContentsModel(widget, configuration);
66
+ }
67
+ }
68
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/toc/markdown.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EAEL,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,4BAA4B,EAAkB,MAAM,WAAW,CAAC;AAEzE;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,oBAGjD;IACC;;;;;;OAMG;IACH,IAAI,YAAY;QACd,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACO,WAAW;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC9B;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;QAElE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,cAAc,CAClD,oBAAoB,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,EAClD;YACE,GAAG,IAAI,CAAC,aAAa;YACrB,uDAAuD;YACvD,kBAAkB;YAClB,aAAa,EAAE,KAAK;SACrB,CACF,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,4BAA4B;IAC9E;;;;;OAKG;IACH,YAAY,CAAC,MAAc;;QACzB,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAEhD,IAAI,YAAY,EAAE;YAChB,IAAI,IAAI,GAAG,MAAA,MAAC,MAAc,CAAC,OAAO,0CAAE,KAAK,0CAAE,QAAQ,CAAC;YACpD,OAAO,IAAI,IAAI,oBAAoB,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SAC/D;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;OAMG;IACO,UAAU,CAClB,MAA4D,EAC5D,aAAuC;QAEvC,OAAO,IAAI,4BAA4B,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACjE,CAAC;CACF"}
@@ -0,0 +1,44 @@
1
+ import { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry';
2
+ import { TableOfContents, TableOfContentsModel } from '@jupyterlab/toc';
3
+ import { Widget } from '@lumino/widgets';
4
+ import { FileEditor } from '../widget';
5
+ import { EditorTableOfContentsFactory, IEditorHeading } from './factory';
6
+ /**
7
+ * Table of content model for Python files.
8
+ */
9
+ export declare class PythonTableOfContentsModel extends TableOfContentsModel<IEditorHeading, IDocumentWidget<FileEditor, DocumentRegistry.IModel>> {
10
+ /**
11
+ * Type of document supported by the model.
12
+ *
13
+ * #### Notes
14
+ * A `data-document-type` attribute with this value will be set
15
+ * on the tree view `.jp-TableOfContents-content[data-document-type="..."]`
16
+ */
17
+ get documentType(): string;
18
+ /**
19
+ * Produce the headings for a document.
20
+ *
21
+ * @returns The list of new headings or `null` if nothing needs to be updated.
22
+ */
23
+ protected getHeadings(): Promise<IEditorHeading[] | null>;
24
+ }
25
+ /**
26
+ * Table of content model factory for Python files.
27
+ */
28
+ export declare class PythonTableOfContentsFactory extends EditorTableOfContentsFactory {
29
+ /**
30
+ * Whether the factory can handle the widget or not.
31
+ *
32
+ * @param widget - widget
33
+ * @returns boolean indicating a ToC can be generated
34
+ */
35
+ isApplicable(widget: Widget): boolean;
36
+ /**
37
+ * Create a new table of contents model for the widget
38
+ *
39
+ * @param widget - widget
40
+ * @param configuration - Table of contents configuration
41
+ * @returns The table of contents model
42
+ */
43
+ protected _createNew(widget: IDocumentWidget<FileEditor>, configuration?: TableOfContents.IConfig): PythonTableOfContentsModel;
44
+ }