@difizen/libro-jupyter 0.1.29 → 0.1.31

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.
@@ -7,6 +7,13 @@
7
7
  .@{ant-prefix}-input-group-wrapper {
8
8
  background-color: var(--mana-libro-filtered-background-color) !important;
9
9
  border-radius: 6px;
10
+ .@{ant-prefix}-input {
11
+ color: var(--mana-libro-drawer-title-color);
12
+
13
+ &::placeholder {
14
+ color: var(--mana-libro-keybind-tag-text-color);
15
+ }
16
+ }
10
17
  }
11
18
 
12
19
  .@{ant-prefix}-input-group-addon {
@@ -19,6 +26,7 @@
19
26
  }
20
27
 
21
28
  .libro-keybind-instructions-drawer {
29
+ background: var(--mana-libro-popover-background-color) !important;
22
30
  .@{ant-prefix}-drawer-content-wrapper {
23
31
  box-shadow:
24
32
  0 0 16px -8px rgba(0, 0, 0, 8%),
@@ -42,9 +50,6 @@
42
50
  .@{ant-prefix}-drawer-mask {
43
51
  opacity: 0;
44
52
  }
45
- .@{ant-prefix}-drawer-content {
46
- background: var(--mana-libro-popover-background-color);
47
- }
48
53
  .@{ant-prefix}-drawer-close {
49
54
  color: var(--mana-libro-drawer-close-color);
50
55
  }
@@ -135,6 +140,7 @@
135
140
  .libro-magic-table {
136
141
  .@{ant-prefix}-table-thead > tr > th {
137
142
  background: var(--mana-libro-popover-background-color);
143
+ color: var(--mana-libro-table-title-color);
138
144
  }
139
145
 
140
146
  .@{ant-prefix}-table-tbody > tr.@{ant-prefix}-table-row:hover > td {
@@ -148,7 +154,6 @@
148
154
 
149
155
  thead tr th {
150
156
  height: 30px;
151
- color: var(--mana-libro-table-title-color);
152
157
  font-weight: 600;
153
158
  font-size: 14px;
154
159
  font-family: PingFangSC;
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" resolution-mode="require"/>
2
- import { LirboContextKey } from '@difizen/libro-core';
2
+ import { LibroContextKey } from '@difizen/libro-core';
3
3
  import type { ModalItem, ModalItemProps } from '@difizen/mana-app';
4
4
  import type { Disposable } from '@difizen/mana-app';
5
5
  import type { DataType } from './keybind-instructions-items.js';
6
6
  import './index.less';
7
7
  export declare class KeybindInstrutionsService implements Disposable {
8
- contextKey: LirboContextKey;
8
+ contextKey: LibroContextKey;
9
9
  isKeybindInstructionsMask: boolean;
10
10
  searchCommandModeData: DataType[];
11
11
  searchEditModeData: DataType[];
@@ -14,7 +14,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
14
14
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
15
  function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
16
16
  function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
17
- import { LirboContextKey } from '@difizen/libro-core';
17
+ import { LibroContextKey } from '@difizen/libro-core';
18
18
  import { inject, singleton } from '@difizen/mana-app';
19
19
  import { getOrigin, prop, useInject } from '@difizen/mana-app';
20
20
  import { l10n } from '@difizen/mana-l10n';
@@ -47,7 +47,7 @@ var getSearchResult = function getSearchResult(value, sourceData, targetData) {
47
47
  }
48
48
  });
49
49
  };
50
- export var KeybindInstrutionsService = (_dec = singleton(), _dec2 = inject(LirboContextKey), _dec3 = prop(), _dec4 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
50
+ export var KeybindInstrutionsService = (_dec = singleton(), _dec2 = inject(LibroContextKey), _dec3 = prop(), _dec4 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
51
51
  function KeybindInstrutionsService() {
52
52
  _classCallCheck(this, KeybindInstrutionsService);
53
53
  _initializerDefineProperty(this, "contextKey", _descriptor, this);
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAgC/C,eAAO,MAAM,kBAAkB,YAyD5B,CAAC"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAiC/C,eAAO,MAAM,kBAAkB,YA2D5B,CAAC"}
package/es/module.js CHANGED
@@ -9,6 +9,7 @@ import { DisplayDataOutputModule, ErrorOutputModule, StreamOutputModule } from '
9
9
  import { RawCellModule } from '@difizen/libro-raw-cell';
10
10
  import { LibroSearchModule } from '@difizen/libro-search';
11
11
  import { SearchCodeCellModule } from '@difizen/libro-search-code-cell';
12
+ import { WidgetModule } from '@difizen/libro-widget';
12
13
  import { ManaModule } from '@difizen/mana-app';
13
14
  import { LibroBetweenCellModule } from "./add-between-cell/index.js";
14
15
  import { JupyterCodeCellModel, JupyterCodeCellView } from "./cell/index.js";
@@ -29,7 +30,8 @@ import { LibroJupyterOutputArea } from "./output/index.js";
29
30
  import { PlotlyModule } from "./rendermime/index.js";
30
31
  import { LibroJupyterColorContribution } from "./theme/index.js";
31
32
  import { KernelStatusSelector, LibroJupyterToolbarContribution, SaveFileErrorContribution } from "./toolbar/index.js";
32
- export var LibroJupyterModule = ManaModule.create().register(JupyterWorkspaceService, LibroJupyterFileService, LibroJupyterCommandContribution, LibroJupyterKeybindingContribution, LibroJupyterToolbarContribution, ConfigAppContribution, SaveFileErrorContribution, LibroKeybindRegistry, LibroJupyterContentContribution, LibroJupyterContentSaveContribution, LibroJupyterOutputArea, LibroJupyterColorContribution, LibroJupyterSettingContribution, JupyterServerLaunchManager, LibroJupyterView, {
33
+ import { LibroWidgetMimeContribution } from "./widget/index.js";
34
+ export var LibroJupyterModule = ManaModule.create().register(JupyterWorkspaceService, LibroJupyterFileService, LibroJupyterCommandContribution, LibroJupyterKeybindingContribution, LibroJupyterToolbarContribution, ConfigAppContribution, SaveFileErrorContribution, LibroKeybindRegistry, LibroJupyterContentContribution, LibroJupyterContentSaveContribution, LibroJupyterOutputArea, LibroJupyterColorContribution, LibroJupyterSettingContribution, JupyterServerLaunchManager, LibroJupyterView, LibroWidgetMimeContribution, {
33
35
  token: CellExecutionTimeProvider,
34
36
  useValue: CellExecutionTip
35
37
  }, {
@@ -49,4 +51,4 @@ export var LibroJupyterModule = ManaModule.create().register(JupyterWorkspaceSer
49
51
  useClass: JupyterCodeCellView
50
52
  }).dependOn(LibroModule, CodeCellModule, MarkdownCellModule, RawCellModule, StreamOutputModule, ErrorOutputModule, DisplayDataOutputModule, LibroToolbarModule, LibroKernelManageModule, LibroSearchModule, SearchCodeCellModule, LibroAddCellModule, LibroE2EditorModule, CodeMirrorEditorModule,
51
53
  // custom module
52
- LibroBetweenCellModule, KeybindInstructionsModule, PlotlyModule, LibroJupyterFileModule, LibroLanguageClientModule);
54
+ LibroBetweenCellModule, KeybindInstructionsModule, PlotlyModule, LibroJupyterFileModule, LibroLanguageClientModule, WidgetModule);
@@ -0,0 +1,3 @@
1
+ export * from './widget-render.js';
2
+ export * from './widget-rendermime-contribution.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/widget/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qCAAqC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./widget-render.js";
2
+ export * from "./widget-rendermime-contribution.js";
@@ -0,0 +1,7 @@
1
+ .libro-widget-render {
2
+ margin: 10px 24px;
3
+ }
4
+
5
+ .libro-widget-render:empty {
6
+ margin: unset;
7
+ }
@@ -0,0 +1,7 @@
1
+ import type { BaseOutputView } from '@difizen/libro-core';
2
+ import React from 'react';
3
+ import './index.less';
4
+ export declare const WidgetRender: React.FC<{
5
+ model: BaseOutputView;
6
+ }>;
7
+ //# sourceMappingURL=widget-render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-render.d.ts","sourceRoot":"","sources":["../../src/widget/widget-render.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,cAAc,CAAC;AAItB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,cAAc,CAAA;CAAE,CAoC5D,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { RenderMimeRegistry } from '@difizen/libro-rendermime';
2
+ import { LibroWidgetManager } from '@difizen/libro-widget';
3
+ import { getOrigin, useInject, ViewRender } from '@difizen/mana-app';
4
+ import React from 'react';
5
+ import "./index.less";
6
+ import { LibroJupyterModel } from "../libro-jupyter-model.js";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ export var WidgetRender = function WidgetRender(props) {
9
+ var model = props.model;
10
+ var widgetManager = useInject(LibroWidgetManager);
11
+ var defaultRenderMime = useInject(RenderMimeRegistry);
12
+ var libro = model.cell.parent;
13
+ if (!(libro.model instanceof LibroJupyterModel) || !libro.model.kernelConnection) {
14
+ return null;
15
+ }
16
+ var widgets = widgetManager.getOrCreateWidgets(getOrigin(libro.model.kernelConnection));
17
+ var mimeType = defaultRenderMime.preferredMimeType(model);
18
+ if (mimeType) {
19
+ var model_id = JSON.parse(JSON.stringify(model.data[mimeType])).model_id;
20
+ if (model_id) {
21
+ var widgetView = widgets.getModel(model_id);
22
+ if (widgetView.isCommClosed) {
23
+ return null;
24
+ }
25
+ return /*#__PURE__*/_jsx("div", {
26
+ className: "libro-widget-render-container",
27
+ children: /*#__PURE__*/_jsx("div", {
28
+ className: "libro-widget-render",
29
+ children: /*#__PURE__*/_jsx(ViewRender, {
30
+ view: widgetView
31
+ })
32
+ })
33
+ });
34
+ }
35
+ }
36
+ return /*#__PURE__*/_jsx("div", {
37
+ className: "libro-widget-render-container",
38
+ children: /*#__PURE__*/_jsx("div", {
39
+ className: "libro-widget-render"
40
+ })
41
+ });
42
+ };
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" resolution-mode="require"/>
2
+ import type { BaseOutputView } from '@difizen/libro-core';
3
+ import { RenderMimeContribution } from '@difizen/libro-rendermime';
4
+ import { LibroWidgetManager } from '@difizen/libro-widget';
5
+ export declare class LibroWidgetMimeContribution implements RenderMimeContribution {
6
+ libroWidgetManager: LibroWidgetManager;
7
+ canHandle: (model: BaseOutputView) => number;
8
+ renderType: string;
9
+ safe: boolean;
10
+ mimeTypes: string[];
11
+ render: import("react").FC<{
12
+ model: BaseOutputView;
13
+ }>;
14
+ }
15
+ //# sourceMappingURL=widget-rendermime-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-rendermime-contribution.d.ts","sourceRoot":"","sources":["../../src/widget/widget-rendermime-contribution.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAO3D,qBACa,2BAA4B,YAAW,sBAAsB;IAC5C,kBAAkB,EAAE,kBAAkB,CAAC;IACnE,SAAS,UAAW,cAAc,YAiBhC;IACF,UAAU,SAAoB;IAC9B,IAAI,UAAQ;IACZ,SAAS,WAAgD;IACzD,MAAM;;OAAgB;CACvB"}
@@ -0,0 +1,49 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _dec2, _class, _class2, _descriptor;
3
+ function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
4
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
10
+ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
11
+ import { RenderMimeContribution } from '@difizen/libro-rendermime';
12
+ import { LibroWidgetManager } from '@difizen/libro-widget';
13
+ import { inject, singleton } from '@difizen/mana-app';
14
+ import { LibroJupyterModel } from "../libro-jupyter-model.js";
15
+ import { WidgetRender } from "./widget-render.js";
16
+ export var LibroWidgetMimeContribution = (_dec = singleton({
17
+ contrib: RenderMimeContribution
18
+ }), _dec2 = inject(LibroWidgetManager), _dec(_class = (_class2 = /*#__PURE__*/_createClass(function LibroWidgetMimeContribution() {
19
+ var _this = this;
20
+ _classCallCheck(this, LibroWidgetMimeContribution);
21
+ _initializerDefineProperty(this, "libroWidgetManager", _descriptor, this);
22
+ this.canHandle = function (model) {
23
+ var libroModel = model.cell.parent.model;
24
+ var rank = 0;
25
+ if (libroModel instanceof LibroJupyterModel && libroModel.kernelConnection) {
26
+ var kc = libroModel.kernelConnection;
27
+ var widget = _this.libroWidgetManager.getOrCreateWidgets(kc);
28
+ _this.mimeTypes.forEach(function (mimeType) {
29
+ var mimeData = model.data[mimeType];
30
+ if (mimeData && mimeData !== null) {
31
+ var data = JSON.parse(JSON.stringify(mimeData)).model_id;
32
+ if (Object.keys(model.data).includes(mimeType) && widget.hasModel(data)) {
33
+ rank = 100;
34
+ }
35
+ }
36
+ });
37
+ }
38
+ return rank;
39
+ };
40
+ this.renderType = 'widgetRenderer';
41
+ this.safe = true;
42
+ this.mimeTypes = ['application/vnd.jupyter.widget-view+json'];
43
+ this.render = WidgetRender;
44
+ }), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroWidgetManager", [_dec2], {
45
+ configurable: true,
46
+ enumerable: true,
47
+ writable: true,
48
+ initializer: null
49
+ })), _class2)) || _class);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-jupyter",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro"
@@ -31,22 +31,23 @@
31
31
  "src"
32
32
  ],
33
33
  "dependencies": {
34
- "@difizen/libro-cofine-editor": "^0.1.29",
35
- "@difizen/libro-code-editor": "^0.1.29",
36
- "@difizen/libro-code-cell": "^0.1.29",
37
- "@difizen/libro-codemirror": "^0.1.29",
38
- "@difizen/libro-rendermime": "^0.1.29",
39
- "@difizen/libro-common": "^0.1.29",
40
- "@difizen/libro-core": "^0.1.29",
41
- "@difizen/libro-kernel": "^0.1.29",
42
- "@difizen/libro-l10n": "^0.1.29",
43
- "@difizen/libro-output": "^0.1.29",
44
- "@difizen/libro-search": "^0.1.29",
45
- "@difizen/libro-search-code-cell": "^0.1.29",
46
- "@difizen/libro-lsp": "^0.1.29",
47
- "@difizen/libro-markdown-cell": "^0.1.29",
48
- "@difizen/libro-raw-cell": "^0.1.29",
49
- "@difizen/libro-language-client": "^0.1.29",
34
+ "@difizen/libro-cofine-editor": "^0.1.31",
35
+ "@difizen/libro-code-editor": "^0.1.31",
36
+ "@difizen/libro-code-cell": "^0.1.31",
37
+ "@difizen/libro-codemirror": "^0.1.31",
38
+ "@difizen/libro-rendermime": "^0.1.31",
39
+ "@difizen/libro-common": "^0.1.31",
40
+ "@difizen/libro-core": "^0.1.31",
41
+ "@difizen/libro-kernel": "^0.1.31",
42
+ "@difizen/libro-l10n": "^0.1.31",
43
+ "@difizen/libro-output": "^0.1.31",
44
+ "@difizen/libro-search": "^0.1.31",
45
+ "@difizen/libro-search-code-cell": "^0.1.31",
46
+ "@difizen/libro-lsp": "^0.1.31",
47
+ "@difizen/libro-markdown-cell": "^0.1.31",
48
+ "@difizen/libro-raw-cell": "^0.1.31",
49
+ "@difizen/libro-language-client": "^0.1.31",
50
+ "@difizen/libro-widget": "^0.1.31",
50
51
  "@difizen/mana-app": "latest",
51
52
  "@difizen/mana-l10n": "latest",
52
53
  "@ant-design/colors": "^7.0.0",
@@ -7,6 +7,13 @@
7
7
  .@{ant-prefix}-input-group-wrapper {
8
8
  background-color: var(--mana-libro-filtered-background-color) !important;
9
9
  border-radius: 6px;
10
+ .@{ant-prefix}-input {
11
+ color: var(--mana-libro-drawer-title-color);
12
+
13
+ &::placeholder {
14
+ color: var(--mana-libro-keybind-tag-text-color);
15
+ }
16
+ }
10
17
  }
11
18
 
12
19
  .@{ant-prefix}-input-group-addon {
@@ -19,6 +26,7 @@
19
26
  }
20
27
 
21
28
  .libro-keybind-instructions-drawer {
29
+ background: var(--mana-libro-popover-background-color) !important;
22
30
  .@{ant-prefix}-drawer-content-wrapper {
23
31
  box-shadow:
24
32
  0 0 16px -8px rgba(0, 0, 0, 8%),
@@ -42,9 +50,6 @@
42
50
  .@{ant-prefix}-drawer-mask {
43
51
  opacity: 0;
44
52
  }
45
- .@{ant-prefix}-drawer-content {
46
- background: var(--mana-libro-popover-background-color);
47
- }
48
53
  .@{ant-prefix}-drawer-close {
49
54
  color: var(--mana-libro-drawer-close-color);
50
55
  }
@@ -135,6 +140,7 @@
135
140
  .libro-magic-table {
136
141
  .@{ant-prefix}-table-thead > tr > th {
137
142
  background: var(--mana-libro-popover-background-color);
143
+ color: var(--mana-libro-table-title-color);
138
144
  }
139
145
 
140
146
  .@{ant-prefix}-table-tbody > tr.@{ant-prefix}-table-row:hover > td {
@@ -148,7 +154,6 @@
148
154
 
149
155
  thead tr th {
150
156
  height: 30px;
151
- color: var(--mana-libro-table-title-color);
152
157
  font-weight: 600;
153
158
  font-size: 14px;
154
159
  font-family: PingFangSC;
@@ -1,4 +1,4 @@
1
- import { LirboContextKey } from '@difizen/libro-core';
1
+ import { LibroContextKey } from '@difizen/libro-core';
2
2
  import { inject, singleton } from '@difizen/mana-app';
3
3
  import { getOrigin, prop, useInject } from '@difizen/mana-app';
4
4
  import type { ModalItem, ModalItemProps } from '@difizen/mana-app';
@@ -49,7 +49,7 @@ const getSearchResult = (
49
49
 
50
50
  @singleton()
51
51
  export class KeybindInstrutionsService implements Disposable {
52
- @inject(LirboContextKey) contextKey: LirboContextKey;
52
+ @inject(LibroContextKey) contextKey: LibroContextKey;
53
53
  isKeybindInstructionsMask = false;
54
54
  @prop() searchCommandModeData: DataType[] = [];
55
55
  @prop() searchEditModeData: DataType[] = [];
package/src/module.ts CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  import { RawCellModule } from '@difizen/libro-raw-cell';
26
26
  import { LibroSearchModule } from '@difizen/libro-search';
27
27
  import { SearchCodeCellModule } from '@difizen/libro-search-code-cell';
28
+ import { WidgetModule } from '@difizen/libro-widget';
28
29
  import { ManaModule } from '@difizen/mana-app';
29
30
 
30
31
  import { LibroBetweenCellModule } from './add-between-cell/index.js';
@@ -56,6 +57,7 @@ import {
56
57
  LibroJupyterToolbarContribution,
57
58
  SaveFileErrorContribution,
58
59
  } from './toolbar/index.js';
60
+ import { LibroWidgetMimeContribution } from './widget/index.js';
59
61
 
60
62
  export const LibroJupyterModule = ManaModule.create()
61
63
  .register(
@@ -74,6 +76,7 @@ export const LibroJupyterModule = ManaModule.create()
74
76
  LibroJupyterSettingContribution,
75
77
  JupyterServerLaunchManager,
76
78
  LibroJupyterView,
79
+ LibroWidgetMimeContribution,
77
80
  {
78
81
  token: CellExecutionTimeProvider,
79
82
  useValue: CellExecutionTip,
@@ -114,4 +117,5 @@ export const LibroJupyterModule = ManaModule.create()
114
117
  PlotlyModule,
115
118
  LibroJupyterFileModule,
116
119
  LibroLanguageClientModule,
120
+ WidgetModule,
117
121
  );
@@ -0,0 +1,7 @@
1
+ .libro-widget-render {
2
+ margin: 10px 24px;
3
+ }
4
+
5
+ .libro-widget-render:empty {
6
+ margin: unset;
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from './widget-render.js';
2
+ export * from './widget-rendermime-contribution.js';
@@ -0,0 +1,47 @@
1
+ import type { BaseOutputView } from '@difizen/libro-core';
2
+ import { RenderMimeRegistry } from '@difizen/libro-rendermime';
3
+ import type { IRenderMimeRegistry } from '@difizen/libro-rendermime';
4
+ import { LibroWidgetManager } from '@difizen/libro-widget';
5
+ import { getOrigin, useInject, ViewRender } from '@difizen/mana-app';
6
+ import React from 'react';
7
+ import './index.less';
8
+
9
+ import { LibroJupyterModel } from '../libro-jupyter-model.js';
10
+
11
+ export const WidgetRender: React.FC<{ model: BaseOutputView }> = (props: {
12
+ model: BaseOutputView;
13
+ }) => {
14
+ const { model } = props;
15
+
16
+ const widgetManager = useInject(LibroWidgetManager);
17
+ const defaultRenderMime = useInject<IRenderMimeRegistry>(RenderMimeRegistry);
18
+ const libro = model.cell.parent;
19
+ if (!(libro.model instanceof LibroJupyterModel) || !libro.model.kernelConnection) {
20
+ return null;
21
+ }
22
+ const widgets = widgetManager.getOrCreateWidgets(
23
+ getOrigin(libro.model.kernelConnection),
24
+ );
25
+ const mimeType = defaultRenderMime.preferredMimeType(model);
26
+ if (mimeType) {
27
+ const model_id = JSON.parse(JSON.stringify(model.data[mimeType])).model_id;
28
+ if (model_id) {
29
+ const widgetView = widgets.getModel(model_id);
30
+ if (widgetView.isCommClosed) {
31
+ return null;
32
+ }
33
+ return (
34
+ <div className="libro-widget-render-container">
35
+ <div className="libro-widget-render">
36
+ <ViewRender view={widgetView} />
37
+ </div>
38
+ </div>
39
+ );
40
+ }
41
+ }
42
+ return (
43
+ <div className="libro-widget-render-container">
44
+ <div className="libro-widget-render" />
45
+ </div>
46
+ );
47
+ };
@@ -0,0 +1,35 @@
1
+ import type { BaseOutputView } from '@difizen/libro-core';
2
+ import { RenderMimeContribution } from '@difizen/libro-rendermime';
3
+ import { LibroWidgetManager } from '@difizen/libro-widget';
4
+ import { inject, singleton } from '@difizen/mana-app';
5
+
6
+ import { LibroJupyterModel } from '../libro-jupyter-model.js';
7
+
8
+ import { WidgetRender } from './widget-render.js';
9
+
10
+ @singleton({ contrib: RenderMimeContribution })
11
+ export class LibroWidgetMimeContribution implements RenderMimeContribution {
12
+ @inject(LibroWidgetManager) libroWidgetManager: LibroWidgetManager;
13
+ canHandle = (model: BaseOutputView) => {
14
+ const libroModel = model.cell.parent.model;
15
+ let rank = 0;
16
+ if (libroModel instanceof LibroJupyterModel && libroModel.kernelConnection) {
17
+ const kc = libroModel.kernelConnection;
18
+ const widget = this.libroWidgetManager.getOrCreateWidgets(kc);
19
+ this.mimeTypes.forEach((mimeType) => {
20
+ const mimeData = model.data[mimeType];
21
+ if (mimeData && mimeData !== null) {
22
+ const data = JSON.parse(JSON.stringify(mimeData)).model_id;
23
+ if (Object.keys(model.data).includes(mimeType) && widget.hasModel(data)) {
24
+ rank = 100;
25
+ }
26
+ }
27
+ });
28
+ }
29
+ return rank;
30
+ };
31
+ renderType = 'widgetRenderer';
32
+ safe = true;
33
+ mimeTypes = ['application/vnd.jupyter.widget-view+json'];
34
+ render = WidgetRender;
35
+ }