@jupyterlab/markdownviewer-extension 4.0.0-alpha.8 → 4.0.0-beta.0
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.js +10 -4
- package/lib/index.js.map +1 -1
- package/package.json +13 -11
- package/src/index.ts +195 -0
- package/style/index.css +1 -0
- package/style/index.js +1 -0
package/lib/index.js
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
import { ILayoutRestorer } from '@jupyterlab/application';
|
|
8
8
|
import { WidgetTracker } from '@jupyterlab/apputils';
|
|
9
9
|
import { PathExt } from '@jupyterlab/coreutils';
|
|
10
|
-
import { IMarkdownViewerTracker, MarkdownViewer, MarkdownViewerFactory } from '@jupyterlab/markdownviewer';
|
|
10
|
+
import { IMarkdownViewerTracker, MarkdownViewer, MarkdownViewerFactory, MarkdownViewerTableOfContentsFactory } from '@jupyterlab/markdownviewer';
|
|
11
11
|
import { IRenderMimeRegistry, markdownRendererFactory } from '@jupyterlab/rendermime';
|
|
12
12
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
13
|
+
import { ITableOfContentsRegistry } from '@jupyterlab/toc';
|
|
13
14
|
import { ITranslator } from '@jupyterlab/translation';
|
|
14
15
|
/**
|
|
15
16
|
* The command IDs used by the markdownviewer plugin.
|
|
@@ -31,13 +32,13 @@ const plugin = {
|
|
|
31
32
|
id: '@jupyterlab/markdownviewer-extension:plugin',
|
|
32
33
|
provides: IMarkdownViewerTracker,
|
|
33
34
|
requires: [IRenderMimeRegistry, ITranslator],
|
|
34
|
-
optional: [ILayoutRestorer, ISettingRegistry],
|
|
35
|
+
optional: [ILayoutRestorer, ISettingRegistry, ITableOfContentsRegistry],
|
|
35
36
|
autoStart: true
|
|
36
37
|
};
|
|
37
38
|
/**
|
|
38
39
|
* Activate the markdown viewer plugin.
|
|
39
40
|
*/
|
|
40
|
-
function activate(app, rendermime, translator, restorer, settingRegistry) {
|
|
41
|
+
function activate(app, rendermime, translator, restorer, settingRegistry, tocRegistry) {
|
|
41
42
|
const trans = translator.load('jupyterlab');
|
|
42
43
|
const { commands, docRegistry } = app;
|
|
43
44
|
// Add the markdown renderer factory.
|
|
@@ -46,7 +47,9 @@ function activate(app, rendermime, translator, restorer, settingRegistry) {
|
|
|
46
47
|
const tracker = new WidgetTracker({
|
|
47
48
|
namespace
|
|
48
49
|
});
|
|
49
|
-
let config =
|
|
50
|
+
let config = {
|
|
51
|
+
...MarkdownViewer.defaultConfig
|
|
52
|
+
};
|
|
50
53
|
/**
|
|
51
54
|
* Update the settings of a widget.
|
|
52
55
|
*/
|
|
@@ -138,6 +141,9 @@ function activate(app, rendermime, translator, restorer, settingRegistry) {
|
|
|
138
141
|
},
|
|
139
142
|
label: trans.__('Show Markdown Editor')
|
|
140
143
|
});
|
|
144
|
+
if (tocRegistry) {
|
|
145
|
+
tocRegistry.add(new MarkdownViewerTableOfContentsFactory(tracker, rendermime.markdownParser));
|
|
146
|
+
}
|
|
141
147
|
return tracker;
|
|
142
148
|
}
|
|
143
149
|
/**
|
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,eAAe,EAGhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EACL,sBAAsB,EAEtB,cAAc,EACd,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;AAEH,OAAO,EACL,eAAe,EAGhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAs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O,EAAE,OAAO;gBAChB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;aACzB,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;IAEH,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,cAAc,EAAE;QAC7C,OAAO,EAAE,GAAG,EAAE;YACZ,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;YACrC,IAAI,CAAC,MAAM,EAAE;gBACX,OAAO;aACR;YACD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;YACjC,OAAO,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EAAE;gBACzC,IAAI;gBACJ,OAAO,EAAE,QAAQ;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,aAAa;iBACpB;aACF,CAAC,CAAC;QACL,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;YACrC,OAAO,CACL,CAAC,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,KAAK,CACpE,CAAC;QACJ,CAAC;QACD,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAAC;KACxC,CAAC,CAAC;IAEH,IAAI,WAAW,EAAE;QACf,WAAW,CAAC,GAAG,CACb,IAAI,oCAAoC,CACtC,OAAO,EACP,UAAU,CAAC,cAAc,CAC1B,CACF,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,eAAe,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/markdownviewer-extension",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"description": "JupyterLab - Markdown Renderer Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"lib/*.js",
|
|
29
29
|
"schema/*.json",
|
|
30
30
|
"style/**/*.css",
|
|
31
|
-
"style/index.js"
|
|
31
|
+
"style/index.js",
|
|
32
|
+
"src/**/*.{ts,tsx}"
|
|
32
33
|
],
|
|
33
34
|
"scripts": {
|
|
34
35
|
"build": "tsc -b",
|
|
@@ -37,18 +38,19 @@
|
|
|
37
38
|
"watch": "tsc -b --watch"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@jupyterlab/application": "^4.0.0-
|
|
41
|
-
"@jupyterlab/apputils": "^4.0.0-
|
|
42
|
-
"@jupyterlab/coreutils": "^6.0.0-
|
|
43
|
-
"@jupyterlab/markdownviewer": "^4.0.0-
|
|
44
|
-
"@jupyterlab/rendermime": "^4.0.0-
|
|
45
|
-
"@jupyterlab/settingregistry": "^4.0.0-
|
|
46
|
-
"@jupyterlab/
|
|
41
|
+
"@jupyterlab/application": "^4.0.0-beta.0",
|
|
42
|
+
"@jupyterlab/apputils": "^4.0.0-beta.0",
|
|
43
|
+
"@jupyterlab/coreutils": "^6.0.0-beta.0",
|
|
44
|
+
"@jupyterlab/markdownviewer": "^4.0.0-beta.0",
|
|
45
|
+
"@jupyterlab/rendermime": "^4.0.0-beta.0",
|
|
46
|
+
"@jupyterlab/settingregistry": "^4.0.0-beta.0",
|
|
47
|
+
"@jupyterlab/toc": "^6.0.0-beta.0",
|
|
48
|
+
"@jupyterlab/translation": "^4.0.0-beta.0"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"rimraf": "~3.0.0",
|
|
50
|
-
"typedoc": "~0.
|
|
51
|
-
"typescript": "~
|
|
52
|
+
"typedoc": "~0.23.25",
|
|
53
|
+
"typescript": "~5.0.2"
|
|
52
54
|
},
|
|
53
55
|
"publishConfig": {
|
|
54
56
|
"access": "public"
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
/**
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
* @module markdownviewer-extension
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ILayoutRestorer,
|
|
10
|
+
JupyterFrontEnd,
|
|
11
|
+
JupyterFrontEndPlugin
|
|
12
|
+
} from '@jupyterlab/application';
|
|
13
|
+
import { WidgetTracker } from '@jupyterlab/apputils';
|
|
14
|
+
import { PathExt } from '@jupyterlab/coreutils';
|
|
15
|
+
import {
|
|
16
|
+
IMarkdownViewerTracker,
|
|
17
|
+
MarkdownDocument,
|
|
18
|
+
MarkdownViewer,
|
|
19
|
+
MarkdownViewerFactory,
|
|
20
|
+
MarkdownViewerTableOfContentsFactory
|
|
21
|
+
} from '@jupyterlab/markdownviewer';
|
|
22
|
+
import {
|
|
23
|
+
IRenderMimeRegistry,
|
|
24
|
+
markdownRendererFactory
|
|
25
|
+
} from '@jupyterlab/rendermime';
|
|
26
|
+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
27
|
+
import { ITableOfContentsRegistry } from '@jupyterlab/toc';
|
|
28
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The command IDs used by the markdownviewer plugin.
|
|
32
|
+
*/
|
|
33
|
+
namespace CommandIDs {
|
|
34
|
+
export const markdownPreview = 'markdownviewer:open';
|
|
35
|
+
export const markdownEditor = 'markdownviewer:edit';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The name of the factory that creates markdown viewer widgets.
|
|
40
|
+
*/
|
|
41
|
+
const FACTORY = 'Markdown Preview';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The markdown viewer plugin.
|
|
45
|
+
*/
|
|
46
|
+
const plugin: JupyterFrontEndPlugin<IMarkdownViewerTracker> = {
|
|
47
|
+
activate,
|
|
48
|
+
id: '@jupyterlab/markdownviewer-extension:plugin',
|
|
49
|
+
provides: IMarkdownViewerTracker,
|
|
50
|
+
requires: [IRenderMimeRegistry, ITranslator],
|
|
51
|
+
optional: [ILayoutRestorer, ISettingRegistry, ITableOfContentsRegistry],
|
|
52
|
+
autoStart: true
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Activate the markdown viewer plugin.
|
|
57
|
+
*/
|
|
58
|
+
function activate(
|
|
59
|
+
app: JupyterFrontEnd,
|
|
60
|
+
rendermime: IRenderMimeRegistry,
|
|
61
|
+
translator: ITranslator,
|
|
62
|
+
restorer: ILayoutRestorer | null,
|
|
63
|
+
settingRegistry: ISettingRegistry | null,
|
|
64
|
+
tocRegistry: ITableOfContentsRegistry | null
|
|
65
|
+
): IMarkdownViewerTracker {
|
|
66
|
+
const trans = translator.load('jupyterlab');
|
|
67
|
+
const { commands, docRegistry } = app;
|
|
68
|
+
|
|
69
|
+
// Add the markdown renderer factory.
|
|
70
|
+
rendermime.addFactory(markdownRendererFactory);
|
|
71
|
+
|
|
72
|
+
const namespace = 'markdownviewer-widget';
|
|
73
|
+
const tracker = new WidgetTracker<MarkdownDocument>({
|
|
74
|
+
namespace
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
let config: Partial<MarkdownViewer.IConfig> = {
|
|
78
|
+
...MarkdownViewer.defaultConfig
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Update the settings of a widget.
|
|
83
|
+
*/
|
|
84
|
+
function updateWidget(widget: MarkdownViewer): void {
|
|
85
|
+
Object.keys(config).forEach((k: keyof MarkdownViewer.IConfig) => {
|
|
86
|
+
widget.setOption(k, config[k] ?? null);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (settingRegistry) {
|
|
91
|
+
const updateSettings = (settings: ISettingRegistry.ISettings) => {
|
|
92
|
+
config = settings.composite as Partial<MarkdownViewer.IConfig>;
|
|
93
|
+
tracker.forEach(widget => {
|
|
94
|
+
updateWidget(widget.content);
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Fetch the initial state of the settings.
|
|
99
|
+
settingRegistry
|
|
100
|
+
.load(plugin.id)
|
|
101
|
+
.then((settings: ISettingRegistry.ISettings) => {
|
|
102
|
+
settings.changed.connect(() => {
|
|
103
|
+
updateSettings(settings);
|
|
104
|
+
});
|
|
105
|
+
updateSettings(settings);
|
|
106
|
+
})
|
|
107
|
+
.catch((reason: Error) => {
|
|
108
|
+
console.error(reason.message);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Register the MarkdownViewer factory.
|
|
113
|
+
const factory = new MarkdownViewerFactory({
|
|
114
|
+
rendermime,
|
|
115
|
+
name: FACTORY,
|
|
116
|
+
label: trans.__('Markdown Preview'),
|
|
117
|
+
primaryFileType: docRegistry.getFileType('markdown'),
|
|
118
|
+
fileTypes: ['markdown'],
|
|
119
|
+
defaultRendered: ['markdown']
|
|
120
|
+
});
|
|
121
|
+
factory.widgetCreated.connect((sender, widget) => {
|
|
122
|
+
// Notify the widget tracker if restore data needs to update.
|
|
123
|
+
widget.context.pathChanged.connect(() => {
|
|
124
|
+
void tracker.save(widget);
|
|
125
|
+
});
|
|
126
|
+
// Handle the settings of new widgets.
|
|
127
|
+
updateWidget(widget.content);
|
|
128
|
+
void tracker.add(widget);
|
|
129
|
+
});
|
|
130
|
+
docRegistry.addWidgetFactory(factory);
|
|
131
|
+
|
|
132
|
+
// Handle state restoration.
|
|
133
|
+
if (restorer) {
|
|
134
|
+
void restorer.restore(tracker, {
|
|
135
|
+
command: 'docmanager:open',
|
|
136
|
+
args: widget => ({ path: widget.context.path, factory: FACTORY }),
|
|
137
|
+
name: widget => widget.context.path
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
commands.addCommand(CommandIDs.markdownPreview, {
|
|
142
|
+
label: trans.__('Markdown Preview'),
|
|
143
|
+
execute: args => {
|
|
144
|
+
const path = args['path'];
|
|
145
|
+
if (typeof path !== 'string') {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
return commands.execute('docmanager:open', {
|
|
149
|
+
path,
|
|
150
|
+
factory: FACTORY,
|
|
151
|
+
options: args['options']
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
commands.addCommand(CommandIDs.markdownEditor, {
|
|
157
|
+
execute: () => {
|
|
158
|
+
const widget = tracker.currentWidget;
|
|
159
|
+
if (!widget) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const path = widget.context.path;
|
|
163
|
+
return commands.execute('docmanager:open', {
|
|
164
|
+
path,
|
|
165
|
+
factory: 'Editor',
|
|
166
|
+
options: {
|
|
167
|
+
mode: 'split-right'
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
isVisible: () => {
|
|
172
|
+
const widget = tracker.currentWidget;
|
|
173
|
+
return (
|
|
174
|
+
(widget && PathExt.extname(widget.context.path) === '.md') || false
|
|
175
|
+
);
|
|
176
|
+
},
|
|
177
|
+
label: trans.__('Show Markdown Editor')
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
if (tocRegistry) {
|
|
181
|
+
tocRegistry.add(
|
|
182
|
+
new MarkdownViewerTableOfContentsFactory(
|
|
183
|
+
tracker,
|
|
184
|
+
rendermime.markdownParser
|
|
185
|
+
)
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return tracker;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Export the plugin as default.
|
|
194
|
+
*/
|
|
195
|
+
export default plugin;
|
package/style/index.css
CHANGED
|
@@ -7,4 +7,5 @@
|
|
|
7
7
|
@import url('~@jupyterlab/apputils/style/index.css');
|
|
8
8
|
@import url('~@jupyterlab/rendermime/style/index.css');
|
|
9
9
|
@import url('~@jupyterlab/application/style/index.css');
|
|
10
|
+
@import url('~@jupyterlab/toc/style/index.css');
|
|
10
11
|
@import url('~@jupyterlab/markdownviewer/style/index.css');
|
package/style/index.js
CHANGED