@jupyterlab/rendermime-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.map +1 -1
- package/package.json +10 -9
- package/src/index.ts +113 -0
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,gBAAgB,EAChB,eAAe,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,gBAAgB,EAChB,eAAe,EAEf,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEtE,IAAU,UAAU,CAEnB;AAFD,WAAU,UAAU;IACL,qBAAU,GAAG,8BAA8B,CAAC;AAC3D,CAAC,EAFS,UAAU,KAAV,UAAU,QAEnB;AAED;;GAEG;AACH,MAAM,MAAM,GAA+C;IACzD,EAAE,EAAE,yCAAyC;IAC7C,QAAQ,EAAE;QACR,gBAAgB;QAChB,gBAAgB;QAChB,UAAU;QACV,eAAe;QACf,WAAW;KACZ;IACD,QAAQ,EAAE,mBAAmB;IAC7B,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,IAAI;CAChB,CAAC;AAEF;;GAEG;AACH,eAAe,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S;YACX,CAAC,CAAC;gBACE,UAAU,EAAE,CAAC,IAAiB,EAAE,IAAY,EAAE,EAAW,EAAE,EAAE;oBAC3D,6DAA6D;oBAC7D,wCAAwC;oBACxC,IAAI,IAAI,CAAC,OAAO,KAAK,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;wBACzD,OAAO;qBACR;oBACD,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,UAAU,EAAE;wBACzD,IAAI;wBACJ,EAAE;qBACH,CAAC,CAAC;gBACL,CAAC;aACF;QACL,eAAe,EAAE,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,SAAS;QAC7C,cAAc,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,SAAS;QAC3C,UAAU,EAAE,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,SAAS;QACnC,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,SAAS;KAClC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/rendermime-extension",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"description": "A rendermime extension for JupyterLab",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
|
|
26
26
|
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
|
|
27
|
-
"style/index.js"
|
|
27
|
+
"style/index.js",
|
|
28
|
+
"src/**/*.{ts,tsx}"
|
|
28
29
|
],
|
|
29
30
|
"scripts": {
|
|
30
31
|
"build": "tsc -b",
|
|
@@ -33,16 +34,16 @@
|
|
|
33
34
|
"watch": "tsc -b --watch"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@jupyterlab/application": "^4.0.0-
|
|
37
|
-
"@jupyterlab/apputils": "^4.0.0-
|
|
38
|
-
"@jupyterlab/docmanager": "^4.0.0-
|
|
39
|
-
"@jupyterlab/rendermime": "^4.0.0-
|
|
40
|
-
"@jupyterlab/translation": "^4.0.0-
|
|
37
|
+
"@jupyterlab/application": "^4.0.0-beta.0",
|
|
38
|
+
"@jupyterlab/apputils": "^4.0.0-beta.0",
|
|
39
|
+
"@jupyterlab/docmanager": "^4.0.0-beta.0",
|
|
40
|
+
"@jupyterlab/rendermime": "^4.0.0-beta.0",
|
|
41
|
+
"@jupyterlab/translation": "^4.0.0-beta.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"rimraf": "~3.0.0",
|
|
44
|
-
"typedoc": "~0.
|
|
45
|
-
"typescript": "~
|
|
45
|
+
"typedoc": "~0.23.25",
|
|
46
|
+
"typescript": "~5.0.2"
|
|
46
47
|
},
|
|
47
48
|
"publishConfig": {
|
|
48
49
|
"access": "public"
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* -----------------------------------------------------------------------------
|
|
2
|
+
| Copyright (c) Jupyter Development Team.
|
|
3
|
+
| Distributed under the terms of the Modified BSD License.
|
|
4
|
+
|----------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module rendermime-extension
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
JupyterFrontEnd,
|
|
12
|
+
JupyterFrontEndPlugin
|
|
13
|
+
} from '@jupyterlab/application';
|
|
14
|
+
import { ISanitizer } from '@jupyterlab/apputils';
|
|
15
|
+
import { IDocumentManager } from '@jupyterlab/docmanager';
|
|
16
|
+
import {
|
|
17
|
+
ILatexTypesetter,
|
|
18
|
+
IMarkdownParser,
|
|
19
|
+
IRenderMime,
|
|
20
|
+
IRenderMimeRegistry,
|
|
21
|
+
RenderMimeRegistry,
|
|
22
|
+
standardRendererFactories
|
|
23
|
+
} from '@jupyterlab/rendermime';
|
|
24
|
+
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
25
|
+
|
|
26
|
+
namespace CommandIDs {
|
|
27
|
+
export const handleLink = 'rendermime:handle-local-link';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A plugin providing a rendermime registry.
|
|
32
|
+
*/
|
|
33
|
+
const plugin: JupyterFrontEndPlugin<IRenderMimeRegistry> = {
|
|
34
|
+
id: '@jupyterlab/rendermime-extension:plugin',
|
|
35
|
+
optional: [
|
|
36
|
+
IDocumentManager,
|
|
37
|
+
ILatexTypesetter,
|
|
38
|
+
ISanitizer,
|
|
39
|
+
IMarkdownParser,
|
|
40
|
+
ITranslator
|
|
41
|
+
],
|
|
42
|
+
provides: IRenderMimeRegistry,
|
|
43
|
+
activate: activate,
|
|
44
|
+
autoStart: true
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Export the plugin as default.
|
|
49
|
+
*/
|
|
50
|
+
export default plugin;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Activate the rendermine plugin.
|
|
54
|
+
*/
|
|
55
|
+
function activate(
|
|
56
|
+
app: JupyterFrontEnd,
|
|
57
|
+
docManager: IDocumentManager | null,
|
|
58
|
+
latexTypesetter: ILatexTypesetter | null,
|
|
59
|
+
sanitizer: IRenderMime.ISanitizer | null,
|
|
60
|
+
markdownParser: IMarkdownParser | null,
|
|
61
|
+
translator: ITranslator | null
|
|
62
|
+
): RenderMimeRegistry {
|
|
63
|
+
const trans = (translator ?? nullTranslator).load('jupyterlab');
|
|
64
|
+
if (docManager) {
|
|
65
|
+
app.commands.addCommand(CommandIDs.handleLink, {
|
|
66
|
+
label: trans.__('Handle Local Link'),
|
|
67
|
+
execute: args => {
|
|
68
|
+
const path = args['path'] as string | undefined | null;
|
|
69
|
+
const id = args['id'] as string | undefined | null;
|
|
70
|
+
if (!path) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// First check if the path exists on the server.
|
|
74
|
+
return docManager.services.contents
|
|
75
|
+
.get(path, { content: false })
|
|
76
|
+
.then(() => {
|
|
77
|
+
// Open the link with the default rendered widget factory,
|
|
78
|
+
// if applicable.
|
|
79
|
+
const factory =
|
|
80
|
+
docManager.registry.defaultRenderedWidgetFactory(path);
|
|
81
|
+
const widget = docManager.openOrReveal(path, factory.name);
|
|
82
|
+
|
|
83
|
+
// Handle the hash if one has been provided.
|
|
84
|
+
if (widget && id) {
|
|
85
|
+
widget.setFragment(id);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return new RenderMimeRegistry({
|
|
92
|
+
initialFactories: standardRendererFactories,
|
|
93
|
+
linkHandler: !docManager
|
|
94
|
+
? undefined
|
|
95
|
+
: {
|
|
96
|
+
handleLink: (node: HTMLElement, path: string, id?: string) => {
|
|
97
|
+
// If node has the download attribute explicitly set, use the
|
|
98
|
+
// default browser downloading behavior.
|
|
99
|
+
if (node.tagName === 'A' && node.hasAttribute('download')) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
app.commandLinker.connectNode(node, CommandIDs.handleLink, {
|
|
103
|
+
path,
|
|
104
|
+
id
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
latexTypesetter: latexTypesetter ?? undefined,
|
|
109
|
+
markdownParser: markdownParser ?? undefined,
|
|
110
|
+
translator: translator ?? undefined,
|
|
111
|
+
sanitizer: sanitizer ?? undefined
|
|
112
|
+
});
|
|
113
|
+
}
|