fix: 修复编辑器转化bug,增加窗口最大最小化功能

This commit is contained in:
zude.hzd 2020-10-26 22:14:17 +08:00
parent 79be069544
commit 05666af7d6
4 changed files with 40 additions and 40 deletions

View File

@ -26,13 +26,6 @@
"version": "1.0.0", "version": "1.0.0",
"urls": ["https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.js", "https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.css"], "urls": ["https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.js", "https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.css"],
"library": "MCBreadcrumb" "library": "MCBreadcrumb"
},
{
"title": "krumpDemo",
"package": "krumpDemo",
"version": "1.0.0",
"urls": ["http://30.37.82.74:8000/lc-engine.js"],
"library": "krump-test-module"
} }
], ],
"components": [ "components": [

View File

@ -89,17 +89,17 @@ export default class ExpressionView extends PureComponent {
return null; return null;
} }
onChange(value: string, actionType: string) { onChange(value: string) {
let realInputValue = value; const realInputValue = value;
const realDataSource = null; const realDataSource = null;
let nextCursorIndex: number; let nextCursorIndex: number;
// 更新值 // 更新值
if (actionType === 'itemClick' || actionType === 'enter') { // if (actionType === 'itemClick' || actionType === 'enter') {
const curValue = this.state.value; // // const curValue = this.state.value;
if (curValue) { // // if (curValue) {
realInputValue = curValue + realInputValue; // // realInputValue = curValue + realInputValue;
} // // }
} // }
// 更新数据源 // 更新数据源
const newState = { const newState = {
value: realInputValue, value: realInputValue,

View File

@ -58,12 +58,12 @@ export default class SourceEditor extends Component<{
private originSize: { private originSize: {
width: '', width: '',
height: '' height: ''
} };
state = { state = {
isShowSaveBtn: true, isShowSaveBtn: true,
visiable: false, visiable: false,
fullScreenStatus:false fullScreenStatus: false,
}; };
// eslint-disable-next-line react/no-deprecated // eslint-disable-next-line react/no-deprecated
@ -103,7 +103,7 @@ export default class SourceEditor extends Component<{
componentDidMount() { componentDidMount() {
this.editorNode = this.editorJsRef.current; // 记录当前dom节点 // this.editorNode = this.editorJsRef.current; // 记录当前dom节点
} }
/** /**
@ -152,6 +152,7 @@ export default class SourceEditor extends Component<{
css, css,
selectTab: TAB_KEY.JS_TAB, selectTab: TAB_KEY.JS_TAB,
visiable: true, visiable: true,
fullScreenStatus: false,
}); });
}; };
@ -204,9 +205,14 @@ export default class SourceEditor extends Component<{
if (this.editorCmd) { if (this.editorCmd) {
this.callEditorEvent(this.editorCmd.eventName, this.editorCmd.params); this.callEditorEvent(this.editorCmd.eventName, this.editorCmd.params);
} }
setTimeout(() => {
this.editorNode = this.editorJsRef.current; // 记录当前dom节点
}, 0);
}; };
fullScreen = () => { fullScreen = () => {
console.log(this.editorNode);
document.body.appendChild(this.editorNode); document.body.appendChild(this.editorNode);
// this.originSize = { // this.originSize = {
// width: this.editorNode.clientWidth, // width: this.editorNode.clientWidth,
@ -224,33 +230,34 @@ export default class SourceEditor extends Component<{
this.monocoEditor.layout({ this.monocoEditor.layout({
height: document.body.clientHeight, height: document.body.clientHeight,
width: document.body.clientWidth width: document.body.clientWidth,
}) });
this.monocoEditor.updateOptions(fullScreenOption); this.monocoEditor.updateOptions(fullScreenOption);
this.setState({ this.setState({
fullScreenStatus:true fullScreenStatus: true,
}) });
}; };
minScreen = () => { minScreen = () => {
const listNode = document.getElementById('editor-context-container');
// document.body.removeChild(this.editorNode); listNode.insertBefore(this.editorNode, listNode.childNodes[0]);
let node=document.getElementById("editor-context-container").lastChild;
document.getElementById('editor-context-container')?.insertBefore(node,this.editorNode);
const minScreenOption = { const minScreenOption = {
...defaultEditorOption ...defaultEditorOption,
minimap: {
enabled: false,
},
}; };
this.monocoEditor.updateOptions(minScreenOption); this.monocoEditor.updateOptions(minScreenOption);
this.setState({ this.setState({
fullScreenStatus:false fullScreenStatus: false,
}) });
} };
onTabChange = (key) => { onTabChange = (key) => {
const { editor } = this.props; const { editor } = this.props;
@ -312,7 +319,7 @@ export default class SourceEditor extends Component<{
}; };
render() { render() {
const { selectTab, jsCode, css, isShowSaveBtn, visiable,fullScreenStatus } = this.state; const { selectTab, jsCode, css, isShowSaveBtn, visiable, fullScreenStatus } = this.state;
const tabs = [ const tabs = [
{ tab: 'index.js', key: TAB_KEY.JS_TAB }, { tab: 'index.js', key: TAB_KEY.JS_TAB },
{ tab: 'style.css', key: TAB_KEY.CSS_TAB }, { tab: 'style.css', key: TAB_KEY.CSS_TAB },
@ -341,12 +348,12 @@ export default class SourceEditor extends Component<{
/> />
{ {
!fullScreenStatus? !fullScreenStatus ?
<div className="full-screen-container" onClick={this.fullScreen}> <div className="full-screen-container" onClick={this.fullScreen}>
<img src="https://gw.alicdn.com/tfs/TB1d7XqE1T2gK0jSZFvXXXnFXXa-200-200.png"></img> <img src="https://gw.alicdn.com/tfs/TB1d7XqE1T2gK0jSZFvXXXnFXXa-200-200.png" />
</div>: </div> :
<div className="min-screen-container" onClick={this.minScreen}> <div className="min-screen-container" onClick={this.minScreen}>
<img src="https://gw.alicdn.com/tfs/TB1IIonZHY1gK0jSZTEXXXDQVXa-200-200.png"></img> <img src="https://gw.alicdn.com/tfs/TB1IIonZHY1gK0jSZTEXXXDQVXa-200-200.png" />
</div> </div>
} }