@jupyterlab/htmlviewer-extension 3.3.0-alpha.1 → 3.3.0-alpha.13
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 +34 -8
- package/lib/index.js.map +1 -1
- package/package.json +11 -9
- package/schema/plugin.json +72 -0
package/lib/index.js
CHANGED
|
@@ -7,10 +7,15 @@
|
|
|
7
7
|
* @module htmlviewer-extension
|
|
8
8
|
*/
|
|
9
9
|
import { ILayoutRestorer } from '@jupyterlab/application';
|
|
10
|
-
import { ICommandPalette, WidgetTracker } from '@jupyterlab/apputils';
|
|
11
|
-
import { HTMLViewerFactory, IHTMLViewerTracker } from '@jupyterlab/htmlviewer';
|
|
10
|
+
import { createToolbarFactory, ICommandPalette, IToolbarWidgetRegistry, WidgetTracker } from '@jupyterlab/apputils';
|
|
11
|
+
import { HTMLViewerFactory, IHTMLViewerTracker, ToolbarItems } from '@jupyterlab/htmlviewer';
|
|
12
|
+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
12
13
|
import { ITranslator } from '@jupyterlab/translation';
|
|
13
14
|
import { html5Icon } from '@jupyterlab/ui-components';
|
|
15
|
+
/**
|
|
16
|
+
* Factory name
|
|
17
|
+
*/
|
|
18
|
+
const FACTORY = 'HTML Viewer';
|
|
14
19
|
/**
|
|
15
20
|
* Command IDs used by the plugin.
|
|
16
21
|
*/
|
|
@@ -26,15 +31,28 @@ const htmlPlugin = {
|
|
|
26
31
|
id: '@jupyterlab/htmlviewer-extension:plugin',
|
|
27
32
|
provides: IHTMLViewerTracker,
|
|
28
33
|
requires: [ITranslator],
|
|
29
|
-
optional: [
|
|
34
|
+
optional: [
|
|
35
|
+
ICommandPalette,
|
|
36
|
+
ILayoutRestorer,
|
|
37
|
+
ISettingRegistry,
|
|
38
|
+
IToolbarWidgetRegistry
|
|
39
|
+
],
|
|
30
40
|
autoStart: true
|
|
31
41
|
};
|
|
32
42
|
/**
|
|
33
43
|
* Activate the HTMLViewer extension.
|
|
34
44
|
*/
|
|
35
|
-
function activateHTMLViewer(app, translator, palette, restorer) {
|
|
36
|
-
|
|
45
|
+
function activateHTMLViewer(app, translator, palette, restorer, settingRegistry, toolbarRegistry) {
|
|
46
|
+
let toolbarFactory;
|
|
37
47
|
const trans = translator.load('jupyterlab');
|
|
48
|
+
if (toolbarRegistry) {
|
|
49
|
+
toolbarRegistry.registerFactory(FACTORY, 'refresh', widget => ToolbarItems.createRefreshButton(widget, translator));
|
|
50
|
+
toolbarRegistry.registerFactory(FACTORY, 'trust', widget => ToolbarItems.createTrustButton(widget, translator));
|
|
51
|
+
if (settingRegistry) {
|
|
52
|
+
toolbarFactory = createToolbarFactory(toolbarRegistry, settingRegistry, FACTORY, htmlPlugin.id, translator);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Add an HTML file type to the docregistry.
|
|
38
56
|
const ft = {
|
|
39
57
|
name: 'html',
|
|
40
58
|
contentType: 'file',
|
|
@@ -47,10 +65,13 @@ function activateHTMLViewer(app, translator, palette, restorer) {
|
|
|
47
65
|
app.docRegistry.addFileType(ft);
|
|
48
66
|
// Create a new viewer factory.
|
|
49
67
|
const factory = new HTMLViewerFactory({
|
|
50
|
-
name:
|
|
68
|
+
name: FACTORY,
|
|
69
|
+
label: trans.__('HTML Viewer'),
|
|
51
70
|
fileTypes: ['html'],
|
|
52
71
|
defaultFor: ['html'],
|
|
53
|
-
readOnly: true
|
|
72
|
+
readOnly: true,
|
|
73
|
+
toolbarFactory,
|
|
74
|
+
translator
|
|
54
75
|
});
|
|
55
76
|
// Create a widget tracker for HTML documents.
|
|
56
77
|
const tracker = new WidgetTracker({
|
|
@@ -86,13 +107,18 @@ function activateHTMLViewer(app, translator, palette, restorer) {
|
|
|
86
107
|
// allowing script executions in its context.
|
|
87
108
|
app.commands.addCommand(CommandIDs.trustHTML, {
|
|
88
109
|
label: trans.__('Trust HTML File'),
|
|
110
|
+
caption: trans.__(`Whether the HTML file is trusted.
|
|
111
|
+
Trusting the file allows scripts to run in it,
|
|
112
|
+
which may result in security risks.
|
|
113
|
+
Only enable for files you trust.`),
|
|
89
114
|
isEnabled: () => !!tracker.currentWidget,
|
|
90
115
|
isToggled: () => {
|
|
91
116
|
const current = tracker.currentWidget;
|
|
92
117
|
if (!current) {
|
|
93
118
|
return false;
|
|
94
119
|
}
|
|
95
|
-
|
|
120
|
+
const sandbox = current.content.sandbox;
|
|
121
|
+
return sandbox.indexOf('allow-scripts') !== -1;
|
|
96
122
|
},
|
|
97
123
|
execute: () => {
|
|
98
124
|
const current = tracker.currentWidget;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AAEH,OAAO,EACL,eAAe,EAGhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AAEH,OAAO,EACL,eAAe,EAGhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,aAAa,EACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,GAAG,aAAa,CAAC;AAE9B;;GAEG;AACH,IAAU,UAAU,CAEnB;AAFD,WAAU,UAAU;IACL,oBAAS,GAAG,uBAAuB,CAAC;AACnD,CAAC,EAFS,UAAU,KAAV,UAAU,QA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iB,CAAC;SACtC,CAAC,CAAC;KACJ;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AACD;;GAEG;AACH,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/htmlviewer-extension",
|
|
3
|
-
"version": "3.3.0-alpha.
|
|
3
|
+
"version": "3.3.0-alpha.13",
|
|
4
4
|
"description": "JupyterLab extension to render HTML files",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jupyter",
|
|
@@ -24,22 +24,23 @@
|
|
|
24
24
|
"style": "style/index.css",
|
|
25
25
|
"files": [
|
|
26
26
|
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
|
|
27
|
+
"schema/*.json",
|
|
27
28
|
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
|
|
28
29
|
"style/index.js"
|
|
29
30
|
],
|
|
30
31
|
"scripts": {
|
|
31
32
|
"build": "tsc -b",
|
|
32
33
|
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
|
|
33
|
-
"prepublishOnly": "npm run build",
|
|
34
34
|
"watch": "tsc -w"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@jupyterlab/application": "^3.3.0-alpha.
|
|
38
|
-
"@jupyterlab/apputils": "^3.3.0-alpha.
|
|
39
|
-
"@jupyterlab/docregistry": "^3.3.0-alpha.
|
|
40
|
-
"@jupyterlab/htmlviewer": "^3.3.0-alpha.
|
|
41
|
-
"@jupyterlab/
|
|
42
|
-
"@jupyterlab/
|
|
37
|
+
"@jupyterlab/application": "^3.3.0-alpha.13",
|
|
38
|
+
"@jupyterlab/apputils": "^3.3.0-alpha.13",
|
|
39
|
+
"@jupyterlab/docregistry": "^3.3.0-alpha.13",
|
|
40
|
+
"@jupyterlab/htmlviewer": "^3.3.0-alpha.13",
|
|
41
|
+
"@jupyterlab/settingregistry": "^3.3.0-alpha.13",
|
|
42
|
+
"@jupyterlab/translation": "^3.3.0-alpha.13",
|
|
43
|
+
"@jupyterlab/ui-components": "^3.3.0-alpha.13"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"rimraf": "~3.0.0",
|
|
@@ -49,7 +50,8 @@
|
|
|
49
50
|
"access": "public"
|
|
50
51
|
},
|
|
51
52
|
"jupyterlab": {
|
|
52
|
-
"extension": true
|
|
53
|
+
"extension": true,
|
|
54
|
+
"schemaDir": "schema"
|
|
53
55
|
},
|
|
54
56
|
"styleModule": "style/index.js"
|
|
55
57
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "HTML Viewer",
|
|
3
|
+
"description": "HTML Viewer settings.",
|
|
4
|
+
"jupyter.lab.toolbars": {
|
|
5
|
+
"HTML Viewer": [
|
|
6
|
+
{ "name": "refresh", "rank": 10 },
|
|
7
|
+
{ "name": "trust", "rank": 20 }
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"jupyter.lab.transform": true,
|
|
11
|
+
"properties": {
|
|
12
|
+
"toolbar": {
|
|
13
|
+
"title": "HTML viewer toolbar items",
|
|
14
|
+
"description": "Note: To disable a toolbar item,\ncopy it to User Preferences and add the\n\"disabled\" key. The following example will disable the refresh item:\n{\n \"toolbar\": [\n {\n \"name\": \"refresh\",\n \"disabled\": true\n }\n ]\n}\n\nToolbar description:",
|
|
15
|
+
"items": {
|
|
16
|
+
"$ref": "#/definitions/toolbarItem"
|
|
17
|
+
},
|
|
18
|
+
"type": "array",
|
|
19
|
+
"default": []
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"additionalProperties": false,
|
|
23
|
+
"type": "object",
|
|
24
|
+
"definitions": {
|
|
25
|
+
"toolbarItem": {
|
|
26
|
+
"properties": {
|
|
27
|
+
"name": {
|
|
28
|
+
"title": "Unique name",
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"args": {
|
|
32
|
+
"title": "Command arguments",
|
|
33
|
+
"type": "object"
|
|
34
|
+
},
|
|
35
|
+
"command": {
|
|
36
|
+
"title": "Command id",
|
|
37
|
+
"type": "string",
|
|
38
|
+
"default": ""
|
|
39
|
+
},
|
|
40
|
+
"disabled": {
|
|
41
|
+
"title": "Whether the item is ignored or not",
|
|
42
|
+
"type": "boolean",
|
|
43
|
+
"default": false
|
|
44
|
+
},
|
|
45
|
+
"icon": {
|
|
46
|
+
"title": "Item icon id",
|
|
47
|
+
"description": "If defined, it will override the command icon",
|
|
48
|
+
"type": "string"
|
|
49
|
+
},
|
|
50
|
+
"label": {
|
|
51
|
+
"title": "Item label",
|
|
52
|
+
"description": "If defined, it will override the command label",
|
|
53
|
+
"type": "string"
|
|
54
|
+
},
|
|
55
|
+
"type": {
|
|
56
|
+
"title": "Item type",
|
|
57
|
+
"type": "string",
|
|
58
|
+
"enum": ["command", "spacer"]
|
|
59
|
+
},
|
|
60
|
+
"rank": {
|
|
61
|
+
"title": "Item rank",
|
|
62
|
+
"type": "number",
|
|
63
|
+
"minimum": 0,
|
|
64
|
+
"default": 50
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"required": ["name"],
|
|
68
|
+
"additionalProperties": false,
|
|
69
|
+
"type": "object"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|