Skip to content

Commit 5a9dba2

Browse files
authored
fix(output): disable the minimap and fix output can't refresh problem (#124)
fix #123
1 parent 6d97e5a commit 5a9dba2

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

src/services/workbench/panelService.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ export class PanelService extends Component<IPanel> implements IPanelService {
126126
const targetIndex = panes?.findIndex(searchById(data.id));
127127
if (targetIndex !== undefined && targetIndex > -1) {
128128
Object.assign(panes[targetIndex], data);
129-
this.render();
129+
this.setState({
130+
data: [...panes],
131+
});
130132
return panes[targetIndex];
131133
}
132134
return undefined;

src/workbench/panel/output.tsx

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
import * as React from 'react';
2-
import { memo } from 'react';
32
import { prefixClaName } from 'mo/common/className';
43
import { IPanelItem } from 'mo/model/workbench/panel';
54
import MonacoEditor from 'mo/components/monaco';
65

76
const defaultClassName = prefixClaName('output');
87

98
function Output(props: IPanelItem) {
10-
const { data } = props;
9+
const { data = '' } = props;
10+
// TODO: Output should export the editorInstance, it's used for update the editor Language, Monarch
1111
return (
12-
<div className={defaultClassName}>
12+
<div
13+
className={defaultClassName}
14+
style={{ width: '100%', height: '100%' }}
15+
>
1316
<MonacoEditor
17+
key={data.length}
1418
options={{
1519
value: data,
1620
readOnly: true,
1721
lineDecorationsWidth: 0,
1822
lineNumbers: 'off',
19-
minimap: undefined,
23+
minimap: {
24+
enabled: false,
25+
},
2026
automaticLayout: true,
2127
}}
2228
/>
2329
</div>
2430
);
2531
}
2632

27-
export default memo(Output);
33+
export default Output;

src/workbench/panel/panel.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { memo } from 'react';
32
import { getBEMElement, prefixClaName } from 'mo/common/className';
43
import { IPanel } from 'mo/model/workbench/panel';
54
import { IPanelController } from 'mo/controller/panel';
@@ -40,4 +39,4 @@ function Panel(props: IPanel & IPanelController) {
4039
);
4140
}
4241

43-
export default memo(Panel);
42+
export default Panel;

stories/extensions/test/testPane.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ export default class TestPane extends React.Component {
6565
panelService.showHide();
6666
};
6767

68+
const updateOutput = () => {
69+
panelService.appendOutput('Number: ' + Math.random() * 10);
70+
};
71+
6872
const newEditor = function () {
6973
const key = (Math.random() * 10 + 1).toFixed(2);
7074
const tabData: IEditorTab = {
@@ -111,6 +115,7 @@ export type GenericClassDecorator<T> = (target: T) => void;`,
111115
<h2>Add a new Panel:</h2>
112116
<Button onClick={addPanel}>Add Panel</Button>
113117
<Button onClick={showHidePanel}>Show/Hide Panel</Button>
118+
<Button onClick={updateOutput}>Update Output</Button>
114119
</div>
115120
<div style={{ margin: '50px 20px' }}>
116121
<h2>Notification:</h2>

0 commit comments

Comments
 (0)