Skip to content

Commit

Permalink
fix: monaco-editor can not format
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Jan 3, 2023
1 parent 5ca5fe5 commit 9d3bae6
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 604 deletions.
870 changes: 290 additions & 580 deletions build/SetupScripts/app.nsh

Large diffs are not rendered by default.

Binary file modified build/SetupScripts/nim/skin.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion build/build-nim-nozip.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

@rem 如果要调试错误,请使用下面的脚本,这样会打开编译界面(命令行界面中文会显示成?号)
@rem ".\NSIS\makensisw.exe" /DINSTALL_WITH_NO_NSIS7Z=1 ".\SetupScripts\nim\nim_setup.nsi"
@pause
@pause
10 changes: 5 additions & 5 deletions build/makensiscode.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ del ".\SetupScripts\app.nsh"
@set total=1

@echo off
@rem 统计文件总数
@rem 统计文件总数
for /f "tokens=*" %%a in ('dir /s/b/a-d %DestPath%') do (
@set /a total+=1
)

@set curr=0
@set tmpValue=1

@rem 做首级目录处理
@rem 做首级目录处理
for /f "delims=*" %%d in ('dir /a-d/b %DestPath%') do (
set /a curr+=1
@echo Push !total! >> %DestFiles%
Expand All @@ -27,7 +27,7 @@ set /a curr+=1
@rem @echo "%%d"
)

@rem 循环遍历各个子目录,进行处理,生成NSIS指令
@rem 循环遍历各个子目录,进行处理,生成NSIS指令
@set dstString=
for /f "delims=*" %%a in ('dir /s/ad/b %DestPath%') do (

Expand All @@ -38,7 +38,7 @@ for /f "delims=*" %%a in ('dir /s/ad/b %DestPath%') do (

@echo SetOutPath "$INSTDIR\!foldername!" >> %DestFiles%

@rem 循环其下的文件
@rem 循环其下的文件
for /f "delims=*" %%c in ('dir /a-d/b %%a') do (
@set /a curr+=1
@echo Push !total! >> %DestFiles%
Expand All @@ -53,4 +53,4 @@ for /f "delims=*" %%c in ('dir /a-d/b %%a') do (
@echo Push %total% >> %DestFiles%
@echo Push %total% >> %DestFiles%
@echo Call ExtractCallback >> %DestFiles%
chcp 936
chcp 936
2 changes: 1 addition & 1 deletion build/makeskinzip.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ rem ����skin.zip
for /f "delims=" %%a in ('dir /ad/b %DestPath%') do (
7z.exe a ".\SetupScripts\%1\skin.zip" ".\SetupScripts\%1\skin\%%a"
@echo "compressing .\SetupScripts\%1\skin\%%a"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,22 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges
rerenderEditor = () => {
this.codeEdtor?.layout?.();
};
updateReadOnlyCode(callback) {
this.codeEdtor?.updateOptions({ readOnly: false });
callback();
this.codeEdtor?.updateOptions({ readOnly: this.config.readOnly });
}
formatCode() {
return new Promise<string>(resolve => {
requestAnimationFrame(async () => {
this.codeEdtor?.updateOptions({ readOnly: false });
await this.codeEdtor?.getAction('editor.action.formatDocument')?.run();
this.codeEdtor?.updateOptions({ readOnly: this.config.readOnly });
resolve(this.codeEdtor?.getValue() || '');
if (this.codeEdtor) {
this.updateReadOnlyCode(async () => {
await this.codeEdtor?.getAction('editor.action.formatDocument')?.run();
resolve(this.codeEdtor?.getValue() || '');
});
} else {
resolve(await this.formatCode());
}
});
});
}
Expand All @@ -296,7 +305,7 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges
// const value = session.getValue();
// const code = this.formatCode();
// session.setValue(code);
this.formatCode(); //自动格式化代码
await this.formatCode(); //自动格式化代码
break;
}
case 'copy': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ElectronService } from 'eo/workbench/browser/src/app/core/services';
import { LanguageService } from 'eo/workbench/browser/src/app/core/services/language/language.service';
import { ModuleInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager';

import { WebService } from '../../../core/services/web/web.service';
import { EoExtensionInfo } from '../extension.model';
Expand All @@ -13,7 +14,7 @@ import { ExtensionService } from '../extension.service';
styleUrls: ['./extension-detail.component.scss']
})
export class ExtensionDetailComponent implements OnInit {
@Input() extensionData = '';
@Input() extensionData: ModuleInfo | null = null;
@Output() readonly goBack: EventEmitter<any> = new EventEmitter();
isOperating = false;
introLoading = false;
Expand Down Expand Up @@ -43,8 +44,9 @@ export class ExtensionDetailComponent implements OnInit {
}

async getDetail() {
this.extensionDetail = { ...this.extensionDetail, ...this.extensionData };
if (this.electron.isElectron) {
this.isOperating = window.electron.getInstallingExtension(this.extensionData, ({ type, status }) => {
this.isOperating = window.electron.getInstallingExtension(this.extensionData?.name, ({ type, status }) => {
if (type === 'install' && status === 'success') {
this.extensionDetail.installed = true;
}
Expand All @@ -54,7 +56,7 @@ export class ExtensionDetailComponent implements OnInit {
this.isOperating = false;
});
}
this.extensionDetail = await this.extensionService.getDetail(this.extensionData, this.extensionData);
this.extensionDetail = await this.extensionService.getDetail(this.extensionData?.name, this.extensionData?.name);

if (!this.extensionDetail?.installed || this.webService.isWeb) {
await this.fetchReadme(this.language.systemLanguage);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ElectronService } from 'eo/workbench/browser/src/app/core/services';
import { ModuleInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager';
import { observable, makeObservable, computed, action } from 'mobx';
import { NzFormatEmitEvent, NzTreeNodeOptions } from 'ng-zorro-antd/tree';

Expand All @@ -12,7 +13,7 @@ import { ExtensionService } from './extension.service';
styleUrls: ['./extension.component.scss']
})
export class ExtensionComponent implements OnInit {
@observable extensionName = '';
@observable currentExtension: ModuleInfo | null = null;
@observable selectGroup: ExtensionGroupType | string = ExtensionGroupType.all;
keyword = '';
nzSelectedKeys: Array<number | string> = ['all'];
Expand All @@ -36,11 +37,11 @@ export class ExtensionComponent implements OnInit {
];

@computed get hasExtension() {
return !!this.extensionName;
return !!this.currentExtension;
}

@computed get getExtension() {
return this.extensionName;
return this.currentExtension;
}

constructor(public extensionService: ExtensionService, public electron: ElectronService) {}
Expand All @@ -49,8 +50,8 @@ export class ExtensionComponent implements OnInit {
makeObservable(this);
}

selectExtension(name = '') {
this.setExtension(name);
selectExtension(ext = null) {
this.setExtension(ext);
}
/**
* Group tree item click.
Expand All @@ -66,7 +67,7 @@ export class ExtensionComponent implements OnInit {
this.selectGroup = data;
}

@action setExtension(data = '') {
this.extensionName = data;
@action setExtension(data = null) {
this.currentExtension = data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ExtensionListComponent implements OnInit {
});
}
clickExtension(event, item) {
this.selectChange.emit(item.name);
this.selectChange.emit(item);
}
async searchPlugin(groupType, keyword = '') {
this.loading = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
class="mt-[20px] border-all"
[autoFormat]="true"
[code]="model.body"
[config]="{ readOnly: true }"
[config]="{ readOnly: false }"
[isBase64]="['longText', 'stream'].includes(model.responseType)"
[eventList]="['type', 'format', 'copy', 'search']"
></eo-monaco-editor>
Expand Down

0 comments on commit 9d3bae6

Please sign in to comment.