修复文件为空无法保存

This commit is contained in:
hanhh
2021-08-03 19:03:41 +08:00
parent d8587b64a5
commit 9e4b41ce48
4 changed files with 6 additions and 11 deletions
-3
View File
@@ -179,9 +179,6 @@ const Log = () => {
glyphMargin: false,
wordWrap: 'on',
}}
onChange={(val, ev) => {
setValue((val as string).replace(/\r\n/g, '\n'));
}}
/>
)}
</div>
+5 -4
View File
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useRef } from 'react';
import { Drawer, Button, Tabs, Badge, Select, TreeSelect } from 'antd';
import { request } from '@/utils/http';
import config from '@/utils/config';
@@ -44,6 +44,7 @@ const EditModal = ({
const [isNewFile, setIsNewFile] = useState<boolean>(false);
const [log, setLog] = useState<string>('');
const { theme } = useTheme();
const editorRef = useRef<any>(null);
const cancel = () => {
handleCancel();
@@ -164,8 +165,8 @@ const EditModal = ({
lineNumbersMinChars: 3,
glyphMargin: false,
}}
onChange={(val) => {
setValue((val as string).replace(/\r\n/g, '\n'));
onMount={(editor) => {
editorRef.current = editor;
}}
/>
<div>
@@ -178,7 +179,7 @@ const EditModal = ({
setSaveModalVisible(false);
}}
isNewFile={isNewFile}
file={{ content: value, filename: fileName }}
file={{ content: editorRef.current.getValue(1), filename: fileName }}
/>
<SettingModal
visible={settingModalVisible}
-3
View File
@@ -167,9 +167,6 @@ const Script = () => {
folding: false,
glyphMargin: false,
}}
onChange={(val) => {
setValue((val as string).replace(/\r\n/g, '\n'));
}}
/>
)}
<EditModal