mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-16 11:54:27 +00:00
fix: fix source edit bug
This commit is contained in:
parent
737d06ecbb
commit
047247cfcd
File diff suppressed because one or more lines are too long
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
.editor-context{
|
.editor-context{
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.next-tabs-tabpane.active {
|
.next-tabs-tabpane.active {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import transfrom from './transform';
|
|||||||
|
|
||||||
const defaultEditorOption = {
|
const defaultEditorOption = {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '96%',
|
height: '100%',
|
||||||
options: {
|
options: {
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
automaticLayout: true,
|
automaticLayout: true,
|
||||||
@ -54,7 +54,7 @@ export default class SourceEditor extends Component<{
|
|||||||
private editorParentNode: Object;
|
private editorParentNode: Object;
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
isShow: true,
|
isFullScreen:false,
|
||||||
tabKey: TAB_KEY.JS_TAB,
|
tabKey: TAB_KEY.JS_TAB,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,6 +75,13 @@ export default class SourceEditor extends Component<{
|
|||||||
this.initCode(schema);
|
this.initCode(schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
this.editorNode = this.editorJsRef.current; //记录当前dom节点;
|
||||||
|
this.editorParentNode = this.editorNode.parentNode; //记录父节点;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行编辑器事件
|
* 执行编辑器事件
|
||||||
*/
|
*/
|
||||||
@ -170,7 +177,28 @@ export default class SourceEditor extends Component<{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fullScreen = () => {};
|
fullScreen = () => {
|
||||||
|
document.body.appendChild(this.editorNode)
|
||||||
|
|
||||||
|
const fullScreenOption = {
|
||||||
|
...defaultEditorOption,
|
||||||
|
lineNumbers: 'on',
|
||||||
|
folding: true,
|
||||||
|
scrollBeyondLastLine: true,
|
||||||
|
minimap: {
|
||||||
|
enabled: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.monocoEditor.updateOptions(fullScreenOption);
|
||||||
|
// if (this.editorParentNode) {
|
||||||
|
// if (this.editorParentNode.firstChild) {
|
||||||
|
// this.editorParentNode.insertBefore(this.editorNode, this.editorParentNode.firstChild);
|
||||||
|
// } else {
|
||||||
|
// this.editorParentNode.appendChild(this.editorNode);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
};
|
||||||
|
|
||||||
onTabChange = (key) => {
|
onTabChange = (key) => {
|
||||||
const { editor } = this.props;
|
const { editor } = this.props;
|
||||||
@ -210,7 +238,7 @@ export default class SourceEditor extends Component<{
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { isShow, selectTab, jsCode, css } = this.state;
|
const { selectTab, jsCode, css } = 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 },
|
||||||
@ -224,9 +252,9 @@ export default class SourceEditor extends Component<{
|
|||||||
))}
|
))}
|
||||||
</Tab>
|
</Tab>
|
||||||
|
|
||||||
{isShow && (
|
|
||||||
<div style={{ height: '100%' }} className="editor-context-container">
|
<div style={{ height: '100%' }} className="editor-context-container">
|
||||||
<div id="jsEditorDom" className="editor-context">
|
<div id="jsEditorDom" className="editor-context" ref={this.editorJsRef}>
|
||||||
<MonacoEditor
|
<MonacoEditor
|
||||||
value={jsCode}
|
value={jsCode}
|
||||||
{...defaultEditorOption}
|
{...defaultEditorOption}
|
||||||
@ -235,7 +263,7 @@ export default class SourceEditor extends Component<{
|
|||||||
editorDidMount={(editor, monaco) => this.editorDidMount.call(this, editor, monaco, TAB_KEY.JS_TAB)}
|
editorDidMount={(editor, monaco) => this.editorDidMount.call(this, editor, monaco, TAB_KEY.JS_TAB)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="editor-context" id="cssEditorDom">
|
<div className="editor-context" id="cssEditorDom" ref={this.editorCssRef}>
|
||||||
<MonacoEditor
|
<MonacoEditor
|
||||||
value={css}
|
value={css}
|
||||||
{...defaultEditorOption}
|
{...defaultEditorOption}
|
||||||
@ -245,7 +273,7 @@ export default class SourceEditor extends Component<{
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
|
|
||||||
<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"></img>
|
||||||
|
|||||||
@ -35,9 +35,11 @@ const transfrom = {
|
|||||||
|
|
||||||
functionNameList.map((functionName)=>{
|
functionNameList.map((functionName)=>{
|
||||||
if (functionName != 'constructor'){
|
if (functionName != 'constructor'){
|
||||||
|
if (a[functionName]){
|
||||||
let functionCode = a[functionName].toString().replace(new RegExp(functionName),'function');
|
let functionCode = a[functionName].toString().replace(new RegExp(functionName),'function');
|
||||||
functionMap[functionName] = functionCode;
|
functionMap[functionName] = functionCode;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user