@difizen/libro-core 0.2.34 → 0.2.35
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/es/add-cell/libro-add-cell-view.d.ts.map +1 -1
- package/es/add-cell/libro-add-cell-view.js +1 -7
- package/es/cell/libro-cell-service.d.ts.map +1 -1
- package/es/cell/libro-cell-service.js +3 -0
- package/es/cell/libro-edit-cell-view.d.ts +21 -3
- package/es/cell/libro-edit-cell-view.d.ts.map +1 -1
- package/es/cell/libro-edit-cell-view.js +194 -15
- package/es/cell/libro-executable-cell-view.d.ts +5 -1
- package/es/cell/libro-executable-cell-view.d.ts.map +1 -1
- package/es/cell/libro-executable-cell-view.js +15 -10
- package/es/components/cell-protocol.d.ts +4 -0
- package/es/components/cell-protocol.d.ts.map +1 -1
- package/es/components/cell-protocol.js +1 -0
- package/es/components/dnd-cell-item-render.d.ts +2 -0
- package/es/components/dnd-cell-item-render.d.ts.map +1 -1
- package/es/components/dnd-cell-item-render.js +15 -12
- package/es/components/dnd-component/index.less +4 -0
- package/es/index.less +9 -1
- package/es/module.d.ts.map +1 -1
- package/es/module.js +4 -1
- package/es/toolbar/hide-all-selector.js +4 -4
- package/es/toolbar/libro-toolbar.d.ts.map +1 -1
- package/es/toolbar/libro-toolbar.js +3 -2
- package/es/toolbar/side-toolar-more-select.d.ts.map +1 -1
- package/es/toolbar/side-toolar-more-select.js +8 -7
- package/package.json +5 -5
- package/src/add-cell/libro-add-cell-view.tsx +14 -23
- package/src/cell/README.md +1 -1
- package/src/cell/libro-cell-service.ts +1 -0
- package/src/cell/libro-edit-cell-view.tsx +149 -5
- package/src/cell/libro-executable-cell-view.ts +6 -1
- package/src/components/cell-protocol.ts +4 -0
- package/src/components/dnd-cell-item-render.tsx +18 -15
- package/src/components/dnd-component/index.less +4 -0
- package/src/index.less +9 -1
- package/src/module.ts +6 -0
- package/src/toolbar/hide-all-selector.tsx +4 -4
- package/src/toolbar/libro-toolbar.tsx +3 -2
- package/src/toolbar/side-toolar-more-select.tsx +9 -4
package/es/module.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ManaModule } from '@difizen/mana-app';
|
|
|
4
4
|
import { LibroCellModule } from "./cell/libro-cell-module.js";
|
|
5
5
|
import { CollapseService, CollapseServiceFactory, CollapseServiceOption, DefaultCollapseService } from "./collapse-service.js";
|
|
6
6
|
import { LibroCommandModule } from "./command/index.js";
|
|
7
|
-
import { BetweenCellProvider, CellExecutionTimeProvider, CellInputBottonBlankProvider, CellOutputVisulizationProvider, LibroBetweenCellContent, LibroCellExecutionTime, LibroCellInputBottonBlank, LibroCellVisualization } from "./components/index.js";
|
|
7
|
+
import { BetweenCellProvider, CellExecutionTimeProvider, CellInputBottonBlankProvider, CellOutputBottomBlankProvider, CellOutputVisulizationProvider, LibroBetweenCellContent, LibroCellExecutionTime, LibroCellInputBottonBlank, LibroCellOutputBottomBlank, LibroCellVisualization } from "./components/index.js";
|
|
8
8
|
import { LibroContentModule } from "./content/index.js";
|
|
9
9
|
import { LibroFormatterModule } from "./formatter/index.js";
|
|
10
10
|
import { LibroContextKey } from "./libro-context-key.js";
|
|
@@ -62,6 +62,9 @@ export var LibroModule = ManaModule.create().register(BaseWorkspaceService, Virt
|
|
|
62
62
|
}, {
|
|
63
63
|
token: CellInputBottonBlankProvider,
|
|
64
64
|
useValue: LibroCellInputBottonBlank
|
|
65
|
+
}, {
|
|
66
|
+
token: CellOutputBottomBlankProvider,
|
|
67
|
+
useValue: LibroCellOutputBottomBlank
|
|
65
68
|
}, {
|
|
66
69
|
token: CellOutputVisulizationProvider,
|
|
67
70
|
useValue: LibroCellVisualization
|
|
@@ -59,11 +59,11 @@ export var HideAllSelectInner = function HideAllSelectInner() {
|
|
|
59
59
|
onClick: handleChange,
|
|
60
60
|
items: [{
|
|
61
61
|
key: 'hideAllInputs',
|
|
62
|
-
label: l10n.t('隐藏全部Code'),
|
|
62
|
+
label: l10n.t('隐藏全部 Code'),
|
|
63
63
|
disabled: !isCodeVisiable
|
|
64
64
|
}, {
|
|
65
65
|
key: 'hideAllOutputs',
|
|
66
|
-
label: l10n.t('隐藏全部Output'),
|
|
66
|
+
label: l10n.t('隐藏全部 Output'),
|
|
67
67
|
disabled: !isOutputVisible
|
|
68
68
|
}, {
|
|
69
69
|
key: 'hideAll',
|
|
@@ -71,11 +71,11 @@ export var HideAllSelectInner = function HideAllSelectInner() {
|
|
|
71
71
|
disabled: !isCodeVisiable || !isOutputVisible
|
|
72
72
|
}, {
|
|
73
73
|
key: 'showAllInputs',
|
|
74
|
-
label: l10n.t('显示全部Code'),
|
|
74
|
+
label: l10n.t('显示全部 Code'),
|
|
75
75
|
disabled: !isCodeHidden
|
|
76
76
|
}, {
|
|
77
77
|
key: 'showAllOutputs',
|
|
78
|
-
label: l10n.t('显示全部Output'),
|
|
78
|
+
label: l10n.t('显示全部 Output'),
|
|
79
79
|
disabled: !isOutputHidden
|
|
80
80
|
}, {
|
|
81
81
|
key: 'showAll',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-toolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/libro-toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"libro-toolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/libro-toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAEL,YAAY,EAEZ,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA0BnD,qBACa,wBAAyB,YAAW,mBAAmB;IAC5C,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAC9C,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAEpE,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;CA2LtD"}
|
|
@@ -8,6 +8,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
8
8
|
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); }
|
|
9
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
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 { isMacintosh } from '@difizen/mana-app';
|
|
11
12
|
import { inject, ModalService, singleton, ToolbarContribution, useObserve } from '@difizen/mana-app';
|
|
12
13
|
import { l10n } from '@difizen/mana-l10n';
|
|
13
14
|
import { DocumentCommands, NotebookCommands } from "../command/index.js";
|
|
@@ -55,7 +56,7 @@ export var LibroToolbarContribution = (_dec = singleton({
|
|
|
55
56
|
children: l10n.t('保存')
|
|
56
57
|
}), /*#__PURE__*/_jsx("span", {
|
|
57
58
|
className: "libro-tooltip-keybind",
|
|
58
|
-
children: "Cmd + S"
|
|
59
|
+
children: "".concat(isMacintosh ? 'Cmd' : 'Ctrl', " + S")
|
|
59
60
|
})]
|
|
60
61
|
}),
|
|
61
62
|
group: ['group1'],
|
|
@@ -113,7 +114,7 @@ export var LibroToolbarContribution = (_dec = singleton({
|
|
|
113
114
|
children: l10n.t('格式化代码')
|
|
114
115
|
}), /*#__PURE__*/_jsx("span", {
|
|
115
116
|
className: "libro-tooltip-keybind",
|
|
116
|
-
children: "Shift+Option+F"
|
|
117
|
+
children: "Shift+".concat(isMacintosh ? 'Option' : 'Alt', "+F")
|
|
117
118
|
})]
|
|
118
119
|
}),
|
|
119
120
|
group: ['sidetoolbar1'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-toolar-more-select.d.ts","sourceRoot":"","sources":["../../src/toolbar/side-toolar-more-select.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"side-toolar-more-select.d.ts","sourceRoot":"","sources":["../../src/toolbar/side-toolar-more-select.tsx"],"names":[],"mappings":";AAgGA,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAkE5C,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAazC,CAAC"}
|
|
@@ -4,6 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
6
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
import { isMacintosh } from '@difizen/mana-app';
|
|
7
8
|
import { CommandRegistry, getOrigin, ToolbarInstance, useInject, useObserve } from '@difizen/mana-app';
|
|
8
9
|
import { l10n } from '@difizen/mana-l10n';
|
|
9
10
|
import { Menu, MenuContext } from '@difizen/mana-react';
|
|
@@ -12,17 +13,17 @@ import { ExecutableCellModel, ExecutableCellView } from "../cell/index.js";
|
|
|
12
13
|
import { NotebookCommands } from "../command/index.js";
|
|
13
14
|
import { MoreOutlined } from "../material-from-designer.js";
|
|
14
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
18
|
var codeItems = [{
|
|
18
19
|
id: NotebookCommands['HideCellCode'].id,
|
|
19
20
|
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
20
21
|
children: [/*#__PURE__*/_jsx("span", {
|
|
21
22
|
className: "libro-menu-item-label",
|
|
22
23
|
children: l10n.t('隐藏 Code')
|
|
23
|
-
}), /*#__PURE__*/
|
|
24
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
24
25
|
className: "libro-menu-item-keybind",
|
|
25
|
-
children: "Cmd + '"
|
|
26
|
+
children: ["".concat(isMacintosh ? 'Cmd' : 'Ctrl', " + "), "'"]
|
|
26
27
|
})]
|
|
27
28
|
})
|
|
28
29
|
}, {
|
|
@@ -31,9 +32,9 @@ var codeItems = [{
|
|
|
31
32
|
children: [/*#__PURE__*/_jsx("span", {
|
|
32
33
|
className: "libro-menu-item-label",
|
|
33
34
|
children: l10n.t('显示 Code')
|
|
34
|
-
}), /*#__PURE__*/
|
|
35
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
35
36
|
className: "libro-menu-item-keybind",
|
|
36
|
-
children: "Cmd + '"
|
|
37
|
+
children: ["".concat(isMacintosh ? 'Cmd' : 'Ctrl', " + "), "'"]
|
|
37
38
|
})]
|
|
38
39
|
})
|
|
39
40
|
}];
|
|
@@ -45,7 +46,7 @@ var outputItems = [{
|
|
|
45
46
|
children: l10n.t('隐藏 Output')
|
|
46
47
|
}), /*#__PURE__*/_jsx("span", {
|
|
47
48
|
className: "libro-menu-item-keybind",
|
|
48
|
-
children: "Cmd + O"
|
|
49
|
+
children: "".concat(isMacintosh ? 'Cmd' : 'Ctrl', " + O")
|
|
49
50
|
})]
|
|
50
51
|
})
|
|
51
52
|
}, {
|
|
@@ -56,7 +57,7 @@ var outputItems = [{
|
|
|
56
57
|
children: l10n.t('显示 Output')
|
|
57
58
|
}), /*#__PURE__*/_jsx("span", {
|
|
58
59
|
className: "libro-menu-item-keybind",
|
|
59
|
-
children: "Cmd + O"
|
|
60
|
+
children: "".concat(isMacintosh ? 'Cmd' : 'Ctrl', " + O")
|
|
60
61
|
})]
|
|
61
62
|
})
|
|
62
63
|
}];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@ant-design/icons": "^5.1.0",
|
|
37
|
-
"@difizen/libro-code-editor": "^0.2.
|
|
38
|
-
"@difizen/libro-common": "^0.2.
|
|
39
|
-
"@difizen/libro-shared-model": "^0.2.
|
|
40
|
-
"@difizen/libro-virtualized": "^0.2.
|
|
37
|
+
"@difizen/libro-code-editor": "^0.2.35",
|
|
38
|
+
"@difizen/libro-common": "^0.2.35",
|
|
39
|
+
"@difizen/libro-shared-model": "^0.2.35",
|
|
40
|
+
"@difizen/libro-virtualized": "^0.2.35",
|
|
41
41
|
"@difizen/mana-app": "latest",
|
|
42
42
|
"@difizen/mana-l10n": "latest",
|
|
43
43
|
"@difizen/mana-react": "latest",
|
|
@@ -36,29 +36,20 @@ export const LibroAddCell: React.FC = () => {
|
|
|
36
36
|
};
|
|
37
37
|
return (
|
|
38
38
|
<div className="libro-add-cell-container default-add-cell-container">
|
|
39
|
-
{instance
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
onClick={() => {
|
|
54
|
-
addCell(item.type);
|
|
55
|
-
}}
|
|
56
|
-
icon={<PlusOutlined className="libro-add-cell-icon" />}
|
|
57
|
-
>
|
|
58
|
-
{item.name}
|
|
59
|
-
</Button>
|
|
60
|
-
);
|
|
61
|
-
})}
|
|
39
|
+
{instance.getCellList().map((item: AddType) => {
|
|
40
|
+
return (
|
|
41
|
+
<Button
|
|
42
|
+
className="libro-add-cell-container-item "
|
|
43
|
+
key={item.name}
|
|
44
|
+
onClick={() => {
|
|
45
|
+
addCell(item.type);
|
|
46
|
+
}}
|
|
47
|
+
icon={<PlusOutlined className="libro-add-cell-icon" />}
|
|
48
|
+
>
|
|
49
|
+
{item.name}
|
|
50
|
+
</Button>
|
|
51
|
+
);
|
|
52
|
+
})}
|
|
62
53
|
</div>
|
|
63
54
|
);
|
|
64
55
|
};
|
package/src/cell/README.md
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
CodeEditorView,
|
|
3
|
+
CodeEditorViewOptions,
|
|
4
|
+
IEditor,
|
|
5
|
+
} from '@difizen/libro-code-editor';
|
|
6
|
+
import { CodeEditorManager } from '@difizen/libro-code-editor';
|
|
7
|
+
import { CellUri } from '@difizen/libro-common';
|
|
8
|
+
import {
|
|
9
|
+
Disposable,
|
|
10
|
+
DisposableCollection,
|
|
11
|
+
getOrigin,
|
|
12
|
+
inject,
|
|
13
|
+
prop,
|
|
14
|
+
ViewOption,
|
|
15
|
+
ViewRender,
|
|
16
|
+
watch,
|
|
17
|
+
} from '@difizen/mana-app';
|
|
3
18
|
import type { ReactNode } from 'react';
|
|
4
19
|
|
|
5
|
-
import
|
|
20
|
+
import { LibroContextKey } from '../libro-context-key.js';
|
|
21
|
+
import type { CellView, CellViewOptions } from '../libro-protocol.js';
|
|
22
|
+
import { EditorStatus } from '../libro-protocol.js';
|
|
6
23
|
import { isCellView } from '../libro-protocol.js';
|
|
7
24
|
|
|
25
|
+
import { CellService } from './libro-cell-protocol.js';
|
|
8
26
|
import { LibroCellView } from './libro-cell-view.js';
|
|
9
27
|
|
|
10
28
|
export interface EditorCellView extends CellView {
|
|
@@ -39,13 +57,139 @@ export abstract class LibroEditorCellView
|
|
|
39
57
|
extends LibroCellView
|
|
40
58
|
implements EditorCellView
|
|
41
59
|
{
|
|
60
|
+
protected toDisposeOnEditor = new DisposableCollection();
|
|
42
61
|
@prop()
|
|
43
62
|
editor: IEditor | undefined;
|
|
44
63
|
|
|
64
|
+
@inject(LibroContextKey) protected readonly libroContextKey: LibroContextKey;
|
|
65
|
+
@inject(CodeEditorManager) codeEditorManager: CodeEditorManager;
|
|
66
|
+
|
|
45
67
|
@prop()
|
|
46
|
-
|
|
68
|
+
editorView?: CodeEditorView;
|
|
47
69
|
|
|
48
|
-
|
|
70
|
+
constructor(
|
|
71
|
+
@inject(ViewOption) options: CellViewOptions,
|
|
72
|
+
@inject(CellService) cellService: CellService,
|
|
73
|
+
) {
|
|
74
|
+
super(options, cellService);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected getEditorOption(): CodeEditorViewOptions {
|
|
78
|
+
const option: CodeEditorViewOptions = {
|
|
79
|
+
uuid: CellUri.from(this.parent.model.id, this.model.id).toString(),
|
|
80
|
+
editorHostId: this.parent.id + this.id,
|
|
81
|
+
model: this.model,
|
|
82
|
+
config: {
|
|
83
|
+
readOnly: !this.parent.model.inputEditable,
|
|
84
|
+
editable: this.parent.model.inputEditable,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
return option;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
protected async afterEditorReady() {
|
|
91
|
+
this.focusEditor();
|
|
92
|
+
this.toDisposeOnEditor.push(
|
|
93
|
+
watch(this.parent.model, 'inputEditable', () => {
|
|
94
|
+
this.editorView?.editor?.setOption(
|
|
95
|
+
'readOnly',
|
|
96
|
+
getOrigin(!this.parent.model.inputEditable),
|
|
97
|
+
);
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
this.toDisposeOnEditor.push(
|
|
101
|
+
this.editorView?.onModalChange((val) => (this.hasModal = val)) ?? Disposable.NONE,
|
|
102
|
+
);
|
|
103
|
+
this.toDisposeOnEditor.push(
|
|
104
|
+
this.editor?.onModelContentChanged?.((e) => {
|
|
105
|
+
this.parent.model.onCellContentChange({ cell: this, changes: e });
|
|
106
|
+
}) ?? Disposable.NONE,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async createEditor() {
|
|
111
|
+
const option = this.getEditorOption();
|
|
112
|
+
|
|
113
|
+
this.editorStatus = EditorStatus.LOADING;
|
|
114
|
+
|
|
115
|
+
// 防止虚拟滚动中编辑器被频繁创建
|
|
116
|
+
if (this.editorView) {
|
|
117
|
+
this.editorStatus = EditorStatus.LOADED;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const editorView = await this.codeEditorManager.getOrCreateEditorView(option);
|
|
122
|
+
|
|
123
|
+
this.editorView = editorView;
|
|
124
|
+
this.editorStatus = EditorStatus.LOADED;
|
|
125
|
+
|
|
126
|
+
editorView.onEditorStatusChange((e) => {
|
|
127
|
+
if (e.status === 'ready') {
|
|
128
|
+
this.editor = this.editorView!.editor;
|
|
129
|
+
this.afterEditorReady();
|
|
130
|
+
} else if (e.status === 'disposed') {
|
|
131
|
+
this.toDisposeOnEditor.dispose();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@prop()
|
|
137
|
+
editorStatus: EditorStatus = EditorStatus.NOTLOADED;
|
|
138
|
+
|
|
139
|
+
renderEditor = () => {
|
|
140
|
+
if (this.editorView) {
|
|
141
|
+
return <ViewRender view={this.editorView} />;
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
override onViewMount() {
|
|
147
|
+
this.createEditor();
|
|
148
|
+
//选中cell时才focus
|
|
149
|
+
if (this.parent.model.active?.id === this.id) {
|
|
150
|
+
this.focus(!this.parent.model.commandMode);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
override shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>) {
|
|
155
|
+
return getOrigin(this.editorView)?.editor?.host?.contains(
|
|
156
|
+
e.target as HTMLElement,
|
|
157
|
+
) && this.parent.model.commandMode
|
|
158
|
+
? true
|
|
159
|
+
: false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
protected focusEditor() {
|
|
163
|
+
//选中cell、编辑模式、非只读时才focus
|
|
164
|
+
if (
|
|
165
|
+
this.editorView?.editor &&
|
|
166
|
+
this.editorView.editorStatus === 'ready' &&
|
|
167
|
+
this.parent.model.active?.id === this.id &&
|
|
168
|
+
!this.parent.model.commandMode &&
|
|
169
|
+
this.libroContextKey.commandModeEnabled === true && // 排除弹窗等情况
|
|
170
|
+
this.parent.model.inputEditable
|
|
171
|
+
) {
|
|
172
|
+
this.editorView?.editor.setOption('styleActiveLine', true);
|
|
173
|
+
this.editorView?.editor.setOption('highlightActiveLineGutter', true);
|
|
174
|
+
this.editorView?.editor.focus();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
override focus = (toEdit: boolean) => {
|
|
179
|
+
if (toEdit) {
|
|
180
|
+
this.focusEditor();
|
|
181
|
+
} else {
|
|
182
|
+
if (this.container?.current?.parentElement?.contains(document.activeElement)) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
this.container?.current?.parentElement?.focus();
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
override blur = () => {
|
|
190
|
+
this.editorView?.editor?.setOption('styleActiveLine', false);
|
|
191
|
+
this.editorView?.editor?.setOption('highlightActiveLineGutter', false);
|
|
192
|
+
};
|
|
49
193
|
|
|
50
194
|
get wrapperCls() {
|
|
51
195
|
return '';
|
|
@@ -38,7 +38,7 @@ export const ExecutableCellView = {
|
|
|
38
38
|
* 带有编辑器、执行、output相关能力的cell view,例如python、sql
|
|
39
39
|
* model 必须为 ExecutableCellModel
|
|
40
40
|
*/
|
|
41
|
-
export abstract class
|
|
41
|
+
export abstract class LibroEditableExecutableCellView
|
|
42
42
|
extends LibroEditorCellView
|
|
43
43
|
implements ExecutableCellView
|
|
44
44
|
{
|
|
@@ -79,3 +79,8 @@ export abstract class LibroExecutableCellView
|
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated use LibroEditableExecutableCellView instead.
|
|
85
|
+
*/
|
|
86
|
+
export const LibroExecutableCellView = LibroEditableExecutableCellView;
|
|
@@ -10,6 +10,10 @@ export type CellInputBottonBlankProvider = FC<{ cell: CellView }>;
|
|
|
10
10
|
|
|
11
11
|
export const CellInputBottonBlankProvider = Symbol('CellInputBottonBlankProvider');
|
|
12
12
|
|
|
13
|
+
export type CellOutputBottomBlankProvider = FC<{ cell: CellView }>;
|
|
14
|
+
|
|
15
|
+
export const CellOutputBottomBlankProvider = Symbol('CellOutputBottomBlankProvider');
|
|
16
|
+
|
|
13
17
|
export type CellOutputVisulizationProvider = FC<{ cell: CellView }>;
|
|
14
18
|
|
|
15
19
|
export const CellOutputVisulizationProvider = Symbol('CellOutputVisulizationProvider');
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
} from '../material-from-designer.js';
|
|
42
42
|
import { hasErrorOutput } from '../output/index.js';
|
|
43
43
|
|
|
44
|
+
import { CellOutputBottomBlankProvider } from './cell-protocol.js';
|
|
44
45
|
import {
|
|
45
46
|
CellExecutionTimeProvider,
|
|
46
47
|
CellInputBottonBlankProvider,
|
|
@@ -50,10 +51,6 @@ import {
|
|
|
50
51
|
const CellInputContent = memo(function CellInputContent(props: { cell: CellView }) {
|
|
51
52
|
const { cell } = props;
|
|
52
53
|
const observableCell = useObserve(cell);
|
|
53
|
-
|
|
54
|
-
const CellExecutionTime = useInject<CellExecutionTimeProvider>(
|
|
55
|
-
CellExecutionTimeProvider,
|
|
56
|
-
);
|
|
57
54
|
const CellInputBottonBlank = useInject<CellInputBottonBlankProvider>(
|
|
58
55
|
CellInputBottonBlankProvider,
|
|
59
56
|
);
|
|
@@ -71,7 +68,6 @@ const CellInputContent = memo(function CellInputContent(props: { cell: CellView
|
|
|
71
68
|
}
|
|
72
69
|
return (
|
|
73
70
|
<div className="libro-cell-input-content">
|
|
74
|
-
<CellExecutionTime cell={cell} />
|
|
75
71
|
<ViewRender view={observableCell} />
|
|
76
72
|
<CellInputBottonBlank cell={cell} />
|
|
77
73
|
</div>
|
|
@@ -129,6 +125,12 @@ export const CellOutputContent: React.FC<{ cell: CellView }> = memo(
|
|
|
129
125
|
const CellOutputVisulization = useInject<CellOutputVisulizationProvider>(
|
|
130
126
|
CellOutputVisulizationProvider,
|
|
131
127
|
);
|
|
128
|
+
const CellOutputBottomBlank = useInject<CellOutputBottomBlankProvider>(
|
|
129
|
+
CellOutputBottomBlankProvider,
|
|
130
|
+
);
|
|
131
|
+
const CellExecutionTime = useInject<CellExecutionTimeProvider>(
|
|
132
|
+
CellExecutionTimeProvider,
|
|
133
|
+
);
|
|
132
134
|
|
|
133
135
|
if (!ExecutableCellView.is(cell) || !ExecutableCellView.is(observableCell)) {
|
|
134
136
|
return null;
|
|
@@ -152,8 +154,10 @@ export const CellOutputContent: React.FC<{ cell: CellView }> = memo(
|
|
|
152
154
|
<div
|
|
153
155
|
className={`libro-cell-output-content ${hasOutputsScrolled ? 'scrolled' : ''} `}
|
|
154
156
|
>
|
|
157
|
+
<CellExecutionTime cell={cell} />
|
|
155
158
|
<CellOutputVisulization cell={cell} />
|
|
156
|
-
<ViewRender view={cell.outputArea} />
|
|
159
|
+
{observableCell.outputArea.length > 0 && <ViewRender view={cell.outputArea} />}
|
|
160
|
+
<CellOutputBottomBlank cell={cell} />
|
|
157
161
|
</div>
|
|
158
162
|
);
|
|
159
163
|
},
|
|
@@ -171,6 +175,12 @@ export const LibroCellInputBottonBlank: CellInputBottonBlankProvider = forwardRe
|
|
|
171
175
|
},
|
|
172
176
|
);
|
|
173
177
|
|
|
178
|
+
export const LibroCellOutputBottomBlank: CellOutputBottomBlankProvider = forwardRef(
|
|
179
|
+
function LibroCellOutputBottomBlank() {
|
|
180
|
+
return null;
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
|
|
174
184
|
export const LibroCellVisualization: CellOutputVisulizationProvider = forwardRef(
|
|
175
185
|
function LibroCellVisualization() {
|
|
176
186
|
return null;
|
|
@@ -225,14 +235,7 @@ const CellOutput: React.FC<{ cell: CellView }> = forwardRef(function CellOutput(
|
|
|
225
235
|
// };
|
|
226
236
|
// }, [outputRef.current, cell, isExecutingRef]);
|
|
227
237
|
|
|
228
|
-
if (!ExecutableCellView.is(cell)) {
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
if (
|
|
232
|
-
!isCellView(cell) ||
|
|
233
|
-
!ExecutableCellModel.is(cell.model) ||
|
|
234
|
-
!cell.outputArea?.length
|
|
235
|
-
) {
|
|
238
|
+
if (!ExecutableCellView.is(cell) || !ExecutableCellModel.is(cell.model)) {
|
|
236
239
|
return null;
|
|
237
240
|
}
|
|
238
241
|
const handleCellOutputCollapser = () => {
|
|
@@ -259,7 +262,7 @@ const CellOutput: React.FC<{ cell: CellView }> = forwardRef(function CellOutput(
|
|
|
259
262
|
ref={outputCollapserRef}
|
|
260
263
|
onClick={handleCellOutputCollapser}
|
|
261
264
|
/>
|
|
262
|
-
{outputScrollBtnVisiable && (
|
|
265
|
+
{outputScrollBtnVisiable && cell.outputArea.length > 0 && (
|
|
263
266
|
<div className="libro-cell-output-scroll">
|
|
264
267
|
<Tooltip
|
|
265
268
|
title={`${
|
package/src/index.less
CHANGED
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
height: 100%;
|
|
41
41
|
padding: 0;
|
|
42
42
|
overflow-y: auto;
|
|
43
|
+
scrollbar-gutter: stable;
|
|
43
44
|
|
|
44
45
|
.libro-dnd-list-container {
|
|
45
46
|
height: 100%;
|
|
@@ -83,6 +84,7 @@
|
|
|
83
84
|
|
|
84
85
|
.mana-toolbar {
|
|
85
86
|
.mana-toolbar-item {
|
|
87
|
+
height: 24px;
|
|
86
88
|
display: flex;
|
|
87
89
|
align-items: center;
|
|
88
90
|
justify-content: center;
|
|
@@ -408,6 +410,7 @@
|
|
|
408
410
|
height: 41px;
|
|
409
411
|
border-bottom-right-radius: 4px;
|
|
410
412
|
border-bottom-left-radius: 4px;
|
|
413
|
+
border-top: 1px solid var(--mana-libro-code-border-color);
|
|
411
414
|
|
|
412
415
|
svg {
|
|
413
416
|
position: absolute;
|
|
@@ -667,6 +670,11 @@
|
|
|
667
670
|
.mana-menu-item {
|
|
668
671
|
button {
|
|
669
672
|
display: block;
|
|
673
|
+
padding: 0 12px;
|
|
674
|
+
|
|
675
|
+
.mana-menu-item-icon {
|
|
676
|
+
display: none;
|
|
677
|
+
}
|
|
670
678
|
}
|
|
671
679
|
}
|
|
672
680
|
|
|
@@ -758,7 +766,7 @@
|
|
|
758
766
|
}
|
|
759
767
|
|
|
760
768
|
.libro-side-tooltip {
|
|
761
|
-
text-align:
|
|
769
|
+
text-align: center;
|
|
762
770
|
}
|
|
763
771
|
|
|
764
772
|
.libro-tooltip-text {
|
package/src/module.ts
CHANGED
|
@@ -14,10 +14,12 @@ import {
|
|
|
14
14
|
BetweenCellProvider,
|
|
15
15
|
CellExecutionTimeProvider,
|
|
16
16
|
CellInputBottonBlankProvider,
|
|
17
|
+
CellOutputBottomBlankProvider,
|
|
17
18
|
CellOutputVisulizationProvider,
|
|
18
19
|
LibroBetweenCellContent,
|
|
19
20
|
LibroCellExecutionTime,
|
|
20
21
|
LibroCellInputBottonBlank,
|
|
22
|
+
LibroCellOutputBottomBlank,
|
|
21
23
|
LibroCellVisualization,
|
|
22
24
|
} from './components/index.js';
|
|
23
25
|
import { LibroContentModule } from './content/index.js';
|
|
@@ -93,6 +95,10 @@ export const LibroModule = ManaModule.create()
|
|
|
93
95
|
token: CellInputBottonBlankProvider,
|
|
94
96
|
useValue: LibroCellInputBottonBlank,
|
|
95
97
|
},
|
|
98
|
+
{
|
|
99
|
+
token: CellOutputBottomBlankProvider,
|
|
100
|
+
useValue: LibroCellOutputBottomBlank,
|
|
101
|
+
},
|
|
96
102
|
{
|
|
97
103
|
token: CellOutputVisulizationProvider,
|
|
98
104
|
useValue: LibroCellVisualization,
|
|
@@ -78,12 +78,12 @@ export const HideAllSelectInner: React.FC = () => {
|
|
|
78
78
|
items={[
|
|
79
79
|
{
|
|
80
80
|
key: 'hideAllInputs',
|
|
81
|
-
label: l10n.t('隐藏全部Code'),
|
|
81
|
+
label: l10n.t('隐藏全部 Code'),
|
|
82
82
|
disabled: !isCodeVisiable,
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
key: 'hideAllOutputs',
|
|
86
|
-
label: l10n.t('隐藏全部Output'),
|
|
86
|
+
label: l10n.t('隐藏全部 Output'),
|
|
87
87
|
disabled: !isOutputVisible,
|
|
88
88
|
},
|
|
89
89
|
{
|
|
@@ -93,12 +93,12 @@ export const HideAllSelectInner: React.FC = () => {
|
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
key: 'showAllInputs',
|
|
96
|
-
label: l10n.t('显示全部Code'),
|
|
96
|
+
label: l10n.t('显示全部 Code'),
|
|
97
97
|
disabled: !isCodeHidden,
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
key: 'showAllOutputs',
|
|
101
|
-
label: l10n.t('显示全部Output'),
|
|
101
|
+
label: l10n.t('显示全部 Output'),
|
|
102
102
|
disabled: !isOutputHidden,
|
|
103
103
|
},
|
|
104
104
|
{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ToolbarRegistry } from '@difizen/mana-app';
|
|
2
|
+
import { isMacintosh } from '@difizen/mana-app';
|
|
2
3
|
import {
|
|
3
4
|
inject,
|
|
4
5
|
ModalService,
|
|
@@ -48,7 +49,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
48
49
|
tooltip: (
|
|
49
50
|
<div className="libro-tooltip">
|
|
50
51
|
<span className="libro-tooltip-text">{l10n.t('保存')}</span>
|
|
51
|
-
<span className="libro-tooltip-keybind">Cmd + S</span>
|
|
52
|
+
<span className="libro-tooltip-keybind">{`${isMacintosh ? 'Cmd' : 'Ctrl'} + S`}</span>
|
|
52
53
|
</div>
|
|
53
54
|
),
|
|
54
55
|
|
|
@@ -100,7 +101,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
100
101
|
tooltip: (
|
|
101
102
|
<div className="libro-side-tooltip">
|
|
102
103
|
<span className="libro-tooltip-text">{l10n.t('格式化代码')}</span>
|
|
103
|
-
<span className="libro-tooltip-keybind">Shift
|
|
104
|
+
<span className="libro-tooltip-keybind">{`Shift+${isMacintosh ? 'Option' : 'Alt'}+F`}</span>
|
|
104
105
|
</div>
|
|
105
106
|
),
|
|
106
107
|
|