@difizen/libro-core 0.2.35-next.0 → 0.2.36
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/command/kernel-command.js +1 -1
- package/es/command/notebook-commands.js +3 -3
- 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 +17 -13
- package/es/components/dnd-component/index.less +4 -0
- package/es/index.less +10 -2
- package/es/libro-model.js +1 -1
- package/es/libro-setting.js +2 -2
- package/es/module.d.ts.map +1 -1
- package/es/module.js +4 -1
- package/es/settings/settings-modal.d.ts.map +1 -1
- package/es/settings/settings-modal.js +2 -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 +133 -108
- package/es/toolbar/side-toolar-more-select.d.ts.map +1 -1
- package/es/toolbar/side-toolar-more-select.js +82 -81
- package/package.json +5 -5
- package/src/add-cell/libro-add-cell-view.tsx +14 -23
- package/src/cell/libro-cell-service.ts +1 -0
- package/src/command/kernel-command.ts +1 -1
- package/src/command/notebook-commands.ts +3 -3
- package/src/components/cell-protocol.ts +4 -0
- package/src/components/dnd-cell-item-render.tsx +21 -17
- package/src/components/dnd-component/index.less +4 -0
- package/src/index.less +10 -2
- package/src/libro-model.ts +1 -1
- package/src/libro-setting.ts +2 -2
- package/src/module.ts +6 -0
- package/src/settings/settings-modal.tsx +2 -1
- package/src/toolbar/hide-all-selector.tsx +4 -4
- package/src/toolbar/libro-toolbar.tsx +15 -14
- package/src/toolbar/side-toolar-more-select.tsx +76 -72
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
ViewInstance,
|
|
10
10
|
ViewRender,
|
|
11
11
|
} from '@difizen/mana-app';
|
|
12
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
12
13
|
import { Tooltip } from 'antd';
|
|
13
14
|
import classnames from 'classnames';
|
|
14
15
|
import type { FC } from 'react';
|
|
@@ -41,6 +42,7 @@ import {
|
|
|
41
42
|
} from '../material-from-designer.js';
|
|
42
43
|
import { hasErrorOutput } from '../output/index.js';
|
|
43
44
|
|
|
45
|
+
import { CellOutputBottomBlankProvider } from './cell-protocol.js';
|
|
44
46
|
import {
|
|
45
47
|
CellExecutionTimeProvider,
|
|
46
48
|
CellInputBottonBlankProvider,
|
|
@@ -50,10 +52,6 @@ import {
|
|
|
50
52
|
const CellInputContent = memo(function CellInputContent(props: { cell: CellView }) {
|
|
51
53
|
const { cell } = props;
|
|
52
54
|
const observableCell = useObserve(cell);
|
|
53
|
-
|
|
54
|
-
const CellExecutionTime = useInject<CellExecutionTimeProvider>(
|
|
55
|
-
CellExecutionTimeProvider,
|
|
56
|
-
);
|
|
57
55
|
const CellInputBottonBlank = useInject<CellInputBottonBlankProvider>(
|
|
58
56
|
CellInputBottonBlankProvider,
|
|
59
57
|
);
|
|
@@ -71,7 +69,6 @@ const CellInputContent = memo(function CellInputContent(props: { cell: CellView
|
|
|
71
69
|
}
|
|
72
70
|
return (
|
|
73
71
|
<div className="libro-cell-input-content">
|
|
74
|
-
<CellExecutionTime cell={cell} />
|
|
75
72
|
<ViewRender view={observableCell} />
|
|
76
73
|
<CellInputBottonBlank cell={cell} />
|
|
77
74
|
</div>
|
|
@@ -129,6 +126,12 @@ export const CellOutputContent: React.FC<{ cell: CellView }> = memo(
|
|
|
129
126
|
const CellOutputVisulization = useInject<CellOutputVisulizationProvider>(
|
|
130
127
|
CellOutputVisulizationProvider,
|
|
131
128
|
);
|
|
129
|
+
const CellOutputBottomBlank = useInject<CellOutputBottomBlankProvider>(
|
|
130
|
+
CellOutputBottomBlankProvider,
|
|
131
|
+
);
|
|
132
|
+
const CellExecutionTime = useInject<CellExecutionTimeProvider>(
|
|
133
|
+
CellExecutionTimeProvider,
|
|
134
|
+
);
|
|
132
135
|
|
|
133
136
|
if (!ExecutableCellView.is(cell) || !ExecutableCellView.is(observableCell)) {
|
|
134
137
|
return null;
|
|
@@ -152,8 +155,10 @@ export const CellOutputContent: React.FC<{ cell: CellView }> = memo(
|
|
|
152
155
|
<div
|
|
153
156
|
className={`libro-cell-output-content ${hasOutputsScrolled ? 'scrolled' : ''} `}
|
|
154
157
|
>
|
|
158
|
+
<CellExecutionTime cell={cell} />
|
|
155
159
|
<CellOutputVisulization cell={cell} />
|
|
156
|
-
<ViewRender view={cell.outputArea} />
|
|
160
|
+
{observableCell.outputArea.length > 0 && <ViewRender view={cell.outputArea} />}
|
|
161
|
+
<CellOutputBottomBlank cell={cell} />
|
|
157
162
|
</div>
|
|
158
163
|
);
|
|
159
164
|
},
|
|
@@ -171,6 +176,12 @@ export const LibroCellInputBottonBlank: CellInputBottonBlankProvider = forwardRe
|
|
|
171
176
|
},
|
|
172
177
|
);
|
|
173
178
|
|
|
179
|
+
export const LibroCellOutputBottomBlank: CellOutputBottomBlankProvider = forwardRef(
|
|
180
|
+
function LibroCellOutputBottomBlank() {
|
|
181
|
+
return null;
|
|
182
|
+
},
|
|
183
|
+
);
|
|
184
|
+
|
|
174
185
|
export const LibroCellVisualization: CellOutputVisulizationProvider = forwardRef(
|
|
175
186
|
function LibroCellVisualization() {
|
|
176
187
|
return null;
|
|
@@ -225,14 +236,7 @@ const CellOutput: React.FC<{ cell: CellView }> = forwardRef(function CellOutput(
|
|
|
225
236
|
// };
|
|
226
237
|
// }, [outputRef.current, cell, isExecutingRef]);
|
|
227
238
|
|
|
228
|
-
if (!ExecutableCellView.is(cell)) {
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
if (
|
|
232
|
-
!isCellView(cell) ||
|
|
233
|
-
!ExecutableCellModel.is(cell.model) ||
|
|
234
|
-
!cell.outputArea?.length
|
|
235
|
-
) {
|
|
239
|
+
if (!ExecutableCellView.is(cell) || !ExecutableCellModel.is(cell.model)) {
|
|
236
240
|
return null;
|
|
237
241
|
}
|
|
238
242
|
const handleCellOutputCollapser = () => {
|
|
@@ -259,13 +263,13 @@ const CellOutput: React.FC<{ cell: CellView }> = forwardRef(function CellOutput(
|
|
|
259
263
|
ref={outputCollapserRef}
|
|
260
264
|
onClick={handleCellOutputCollapser}
|
|
261
265
|
/>
|
|
262
|
-
{outputScrollBtnVisiable && (
|
|
266
|
+
{outputScrollBtnVisiable && cell.outputArea.length > 0 && (
|
|
263
267
|
<div className="libro-cell-output-scroll">
|
|
264
268
|
<Tooltip
|
|
265
269
|
title={`${
|
|
266
270
|
cell.model.hasOutputsScrolled
|
|
267
|
-
? '取消固定 Output 高度'
|
|
268
|
-
: '固定 Output 高度'
|
|
271
|
+
? l10n.t('取消固定 Output 高度')
|
|
272
|
+
: l10n.t('固定 Output 高度')
|
|
269
273
|
}`}
|
|
270
274
|
>
|
|
271
275
|
<div
|
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
|
|
|
@@ -716,7 +724,7 @@
|
|
|
716
724
|
|
|
717
725
|
.libro-side-toolbar-run-select-menu {
|
|
718
726
|
.@{ant-prefix}-popover-content {
|
|
719
|
-
width:
|
|
727
|
+
width: 320px;
|
|
720
728
|
height: 105px;
|
|
721
729
|
}
|
|
722
730
|
}
|
|
@@ -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/libro-model.ts
CHANGED
|
@@ -493,7 +493,7 @@ export class LibroModel implements NotebookModel, DndListModel {
|
|
|
493
493
|
getOrigin(this.sharedModel).deleteCell(position);
|
|
494
494
|
getOrigin(this.sharedModel).insertCells(position, cellData);
|
|
495
495
|
});
|
|
496
|
-
//切分
|
|
496
|
+
//切分 Cell操作结束后进入编辑态
|
|
497
497
|
this.enterEditMode();
|
|
498
498
|
};
|
|
499
499
|
|
package/src/libro-setting.ts
CHANGED
|
@@ -89,8 +89,8 @@ export const RightContentFixed: ConfigurationNode<boolean> = {
|
|
|
89
89
|
|
|
90
90
|
export const OutputScrollBtnVisiable: ConfigurationNode<boolean> = {
|
|
91
91
|
id: 'libro.cell.output.scroll.button.visiable',
|
|
92
|
-
description: l10n.t('
|
|
93
|
-
title: l10n.t('
|
|
92
|
+
description: l10n.t('Cell 输出区域高度固定按钮是否显示'),
|
|
93
|
+
title: l10n.t('Cell 输出区域高度固定按钮是否显示'),
|
|
94
94
|
type: 'checkbox',
|
|
95
95
|
defaultValue: true,
|
|
96
96
|
schema: {
|
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,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ModalItem, ModalItemProps } from '@difizen/mana-app';
|
|
2
2
|
import { ConfigurationRegistry } from '@difizen/mana-app';
|
|
3
3
|
import { useInject, ViewManager, ViewRender } from '@difizen/mana-app';
|
|
4
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
4
5
|
import { Modal } from 'antd';
|
|
5
6
|
import { useEffect, useState } from 'react';
|
|
6
7
|
|
|
@@ -33,7 +34,7 @@ export function SettingsModalComponent({ visible, close }: ModalItemProps<void>)
|
|
|
33
34
|
|
|
34
35
|
return (
|
|
35
36
|
<Modal
|
|
36
|
-
title=
|
|
37
|
+
title={l10n.t('设置')}
|
|
37
38
|
open={visible}
|
|
38
39
|
onOk={() => close()}
|
|
39
40
|
onCancel={() => close()}
|
|
@@ -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,
|
|
@@ -45,10 +46,10 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
45
46
|
id: DocumentCommands['Save'].id,
|
|
46
47
|
command: DocumentCommands['Save'].id,
|
|
47
48
|
icon: SaveIcon,
|
|
48
|
-
tooltip: (
|
|
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
|
|
|
@@ -58,7 +59,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
58
59
|
registry.registerItem({
|
|
59
60
|
id: NotebookCommands['Interrupt'].id,
|
|
60
61
|
command: NotebookCommands['Interrupt'].id,
|
|
61
|
-
tooltip: (
|
|
62
|
+
tooltip: () => (
|
|
62
63
|
<div className="libro-tooltip">
|
|
63
64
|
<span className="libro-tooltip-text">{l10n.t('中断')}</span>
|
|
64
65
|
</div>
|
|
@@ -71,7 +72,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
71
72
|
registry.registerItem({
|
|
72
73
|
id: NotebookCommands['CloseAndShutdown'].id,
|
|
73
74
|
command: NotebookCommands['CloseAndShutdown'].id,
|
|
74
|
-
tooltip: (
|
|
75
|
+
tooltip: () => (
|
|
75
76
|
<div className="libro-tooltip">
|
|
76
77
|
<span className="libro-tooltip-text">{l10n.t('关闭内核')}</span>
|
|
77
78
|
</div>
|
|
@@ -84,7 +85,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
84
85
|
registry.registerItem({
|
|
85
86
|
id: NotebookCommands['RestartClearOutput'].id,
|
|
86
87
|
command: NotebookCommands['RestartClearOutput'].id,
|
|
87
|
-
tooltip: (
|
|
88
|
+
tooltip: () => (
|
|
88
89
|
<div className="libro-tooltip">
|
|
89
90
|
<span className="libro-tooltip-text">{l10n.t('重启并清空输出')}</span>
|
|
90
91
|
</div>
|
|
@@ -97,10 +98,10 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
97
98
|
registry.registerItem({
|
|
98
99
|
id: DocumentCommands['FormatCell'].id,
|
|
99
100
|
command: DocumentCommands['FormatCell'].id,
|
|
100
|
-
tooltip: (
|
|
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
|
|
|
@@ -110,7 +111,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
110
111
|
registry.registerItem({
|
|
111
112
|
id: NotebookCommands['MoveCellUp'].id,
|
|
112
113
|
command: NotebookCommands['MoveCellUp'].id,
|
|
113
|
-
tooltip: (
|
|
114
|
+
tooltip: () => (
|
|
114
115
|
<div className="libro-side-tooltip">
|
|
115
116
|
<span className="libro-tooltip-text">{l10n.t('上移')}</span>
|
|
116
117
|
<span className="libro-tooltip-keybind">Up</span>
|
|
@@ -123,7 +124,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
123
124
|
registry.registerItem({
|
|
124
125
|
id: NotebookCommands['MoveCellDown'].id,
|
|
125
126
|
command: NotebookCommands['MoveCellDown'].id,
|
|
126
|
-
tooltip: (
|
|
127
|
+
tooltip: () => (
|
|
127
128
|
<div className="libro-side-tooltip">
|
|
128
129
|
<span className="libro-tooltip-text">{l10n.t('下移')}</span>
|
|
129
130
|
<span className="libro-tooltip-keybind">Down</span>
|
|
@@ -136,7 +137,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
136
137
|
registry.registerItem({
|
|
137
138
|
id: NotebookCommands['InsertCellBelow'].id,
|
|
138
139
|
command: NotebookCommands['InsertCellBelow'].id,
|
|
139
|
-
tooltip: (
|
|
140
|
+
tooltip: () => (
|
|
140
141
|
<div className="libro-side-tooltip">
|
|
141
142
|
<span className="libro-tooltip-text">{l10n.t('增加')}</span>
|
|
142
143
|
<span className="libro-tooltip-keybind">B</span>
|
|
@@ -149,7 +150,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
149
150
|
registry.registerItem({
|
|
150
151
|
id: NotebookCommands['DeleteCell'].id,
|
|
151
152
|
command: NotebookCommands['DeleteCell'].id,
|
|
152
|
-
tooltip: (
|
|
153
|
+
tooltip: () => (
|
|
153
154
|
<div className="libro-side-tooltip">
|
|
154
155
|
<span className="libro-tooltip-text">{l10n.t('删除')}</span>
|
|
155
156
|
<span className="libro-tooltip-keybind">D D</span>
|
|
@@ -162,7 +163,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
162
163
|
registry.registerItem({
|
|
163
164
|
id: NotebookCommands['UndoCellAction'].id,
|
|
164
165
|
command: NotebookCommands['UndoCellAction'].id,
|
|
165
|
-
tooltip: (
|
|
166
|
+
tooltip: () => (
|
|
166
167
|
<div className="libro-tooltip">
|
|
167
168
|
<span className="libro-tooltip-text">{l10n.t('撤销')}</span>
|
|
168
169
|
<span className="libro-tooltip-keybind">Z</span>
|
|
@@ -175,7 +176,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
175
176
|
registry.registerItem({
|
|
176
177
|
id: NotebookCommands['RedoCellAction'].id,
|
|
177
178
|
command: NotebookCommands['RedoCellAction'].id,
|
|
178
|
-
tooltip: (
|
|
179
|
+
tooltip: () => (
|
|
179
180
|
<div className="libro-tooltip">
|
|
180
181
|
<span className="libro-tooltip-text">{l10n.t('重做')}</span>
|
|
181
182
|
<span className="libro-tooltip-keybind">Shift + Z</span>
|
|
@@ -203,7 +204,7 @@ export class LibroToolbarContribution implements ToolbarContribution {
|
|
|
203
204
|
registry.registerItem({
|
|
204
205
|
id: NotebookCommands['ClearAllCellOutput'].id,
|
|
205
206
|
command: NotebookCommands['ClearAllCellOutput'].id,
|
|
206
|
-
tooltip: (
|
|
207
|
+
tooltip: () => (
|
|
207
208
|
<div className="libro-tooltip">
|
|
208
209
|
<span className="libro-tooltip-text">{l10n.t('清空输出')}</span>
|
|
209
210
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Toolbar } from '@difizen/mana-app';
|
|
2
|
+
import { isMacintosh } from '@difizen/mana-app';
|
|
2
3
|
import {
|
|
3
4
|
CommandRegistry,
|
|
4
5
|
getOrigin,
|
|
@@ -17,84 +18,87 @@ import { MoreOutlined } from '../material-from-designer.js';
|
|
|
17
18
|
|
|
18
19
|
import type { LibroToolbarArags } from './libro-toolbar-protocol.js';
|
|
19
20
|
|
|
20
|
-
const codeItems: LibroSideToolbarMenuItemType[] = [
|
|
21
|
-
{
|
|
22
|
-
id: NotebookCommands['HideCellCode'].id,
|
|
23
|
-
label: (
|
|
24
|
-
<>
|
|
25
|
-
<span className="libro-menu-item-label">{l10n.t('隐藏 Code')}</span>
|
|
26
|
-
<span className="libro-menu-item-keybind">Cmd + '</span>
|
|
27
|
-
</>
|
|
28
|
-
),
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
id: NotebookCommands['ShowCellCode'].id,
|
|
32
|
-
label: (
|
|
33
|
-
<>
|
|
34
|
-
<span className="libro-menu-item-label">{l10n.t('显示 Code')}</span>
|
|
35
|
-
<span className="libro-menu-item-keybind">Cmd + '</span>
|
|
36
|
-
</>
|
|
37
|
-
),
|
|
38
|
-
},
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
const outputItems: LibroSideToolbarMenuItemType[] = [
|
|
42
|
-
{
|
|
43
|
-
id: NotebookCommands['HideCellOutputs'].id,
|
|
44
|
-
label: (
|
|
45
|
-
<>
|
|
46
|
-
<span className="libro-menu-item-label">{l10n.t('隐藏 Output')}</span>
|
|
47
|
-
<span className="libro-menu-item-keybind">Cmd + O</span>
|
|
48
|
-
</>
|
|
49
|
-
),
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: NotebookCommands['ShowCellOutputs'].id,
|
|
53
|
-
label: (
|
|
54
|
-
<>
|
|
55
|
-
<span className="libro-menu-item-label">{l10n.t('显示 Output')}</span>
|
|
56
|
-
<span className="libro-menu-item-keybind">Cmd + O</span>
|
|
57
|
-
</>
|
|
58
|
-
),
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
const moreItems: LibroSideToolbarMenuItemType[] = [
|
|
63
|
-
{
|
|
64
|
-
id: NotebookCommands['CopyCell'].id,
|
|
65
|
-
label: (
|
|
66
|
-
<>
|
|
67
|
-
<span className="libro-menu-item-label">{l10n.t('复制')}</span>
|
|
68
|
-
<span className="libro-menu-item-keybind">C</span>
|
|
69
|
-
</>
|
|
70
|
-
),
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
id: NotebookCommands['CutCell'].id,
|
|
74
|
-
label: (
|
|
75
|
-
<>
|
|
76
|
-
<span className="libro-menu-item-label">{l10n.t('剪切')}</span>
|
|
77
|
-
<span className="libro-menu-item-keybind">X</span>
|
|
78
|
-
</>
|
|
79
|
-
),
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
id: NotebookCommands['PasteCellBelow'].id,
|
|
83
|
-
label: (
|
|
84
|
-
<>
|
|
85
|
-
<span className="libro-menu-item-label">{l10n.t('粘贴')}</span>
|
|
86
|
-
<span className="libro-menu-item-keybind">V</span>
|
|
87
|
-
</>
|
|
88
|
-
),
|
|
89
|
-
},
|
|
90
|
-
];
|
|
91
|
-
|
|
92
21
|
export const LibroSideToolbarMoreMenu: React.FC = () => {
|
|
93
22
|
const command = useInject(CommandRegistry);
|
|
94
23
|
const toolbar = useInject<Toolbar>(ToolbarInstance);
|
|
95
24
|
const data = toolbar.currentArgs as LibroToolbarArags;
|
|
96
25
|
const args = getOrigin(data) || [];
|
|
97
26
|
const cell = useObserve(args[0]);
|
|
27
|
+
const codeItems: LibroSideToolbarMenuItemType[] = [
|
|
28
|
+
{
|
|
29
|
+
id: NotebookCommands['HideCellCode'].id,
|
|
30
|
+
label: (
|
|
31
|
+
<>
|
|
32
|
+
<span className="libro-menu-item-label">{l10n.t('隐藏 Code')}</span>
|
|
33
|
+
<span className="libro-menu-item-keybind">
|
|
34
|
+
{`${isMacintosh ? 'Cmd' : 'Ctrl'} + `}'
|
|
35
|
+
</span>
|
|
36
|
+
</>
|
|
37
|
+
),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: NotebookCommands['ShowCellCode'].id,
|
|
41
|
+
label: (
|
|
42
|
+
<>
|
|
43
|
+
<span className="libro-menu-item-label">{l10n.t('显示 Code')}</span>
|
|
44
|
+
<span className="libro-menu-item-keybind">
|
|
45
|
+
{`${isMacintosh ? 'Cmd' : 'Ctrl'} + `}'
|
|
46
|
+
</span>
|
|
47
|
+
</>
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const outputItems: LibroSideToolbarMenuItemType[] = [
|
|
53
|
+
{
|
|
54
|
+
id: NotebookCommands['HideCellOutputs'].id,
|
|
55
|
+
label: (
|
|
56
|
+
<>
|
|
57
|
+
<span className="libro-menu-item-label">{l10n.t('隐藏 Output')}</span>
|
|
58
|
+
<span className="libro-menu-item-keybind">{`${isMacintosh ? 'Cmd' : 'Ctrl'} + O`}</span>
|
|
59
|
+
</>
|
|
60
|
+
),
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: NotebookCommands['ShowCellOutputs'].id,
|
|
64
|
+
label: (
|
|
65
|
+
<>
|
|
66
|
+
<span className="libro-menu-item-label">{l10n.t('显示 Output')}</span>
|
|
67
|
+
<span className="libro-menu-item-keybind">{`${isMacintosh ? 'Cmd' : 'Ctrl'} + O`}</span>
|
|
68
|
+
</>
|
|
69
|
+
),
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const moreItems: LibroSideToolbarMenuItemType[] = [
|
|
74
|
+
{
|
|
75
|
+
id: NotebookCommands['CopyCell'].id,
|
|
76
|
+
label: (
|
|
77
|
+
<>
|
|
78
|
+
<span className="libro-menu-item-label">{l10n.t('复制')}</span>
|
|
79
|
+
<span className="libro-menu-item-keybind">C</span>
|
|
80
|
+
</>
|
|
81
|
+
),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: NotebookCommands['CutCell'].id,
|
|
85
|
+
label: (
|
|
86
|
+
<>
|
|
87
|
+
<span className="libro-menu-item-label">{l10n.t('剪切')}</span>
|
|
88
|
+
<span className="libro-menu-item-keybind">X</span>
|
|
89
|
+
</>
|
|
90
|
+
),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: NotebookCommands['PasteCellBelow'].id,
|
|
94
|
+
label: (
|
|
95
|
+
<>
|
|
96
|
+
<span className="libro-menu-item-label">{l10n.t('粘贴')}</span>
|
|
97
|
+
<span className="libro-menu-item-keybind">V</span>
|
|
98
|
+
</>
|
|
99
|
+
),
|
|
100
|
+
},
|
|
101
|
+
];
|
|
98
102
|
if (!cell) {
|
|
99
103
|
return null;
|
|
100
104
|
}
|