|
|
@@ -8,10 +8,14 @@ import type { ReactCodeMirrorProps } from '@uiw/react-codemirror';
|
|
|
|
|
|
import { GlobalCodeMirrorEditorKey, AcceptedUploadFileType } from '../../consts';
|
|
|
import { useFileDropzone, FileDropzoneOverlay } from '../../services';
|
|
|
+import {
|
|
|
+ getStrFromBol, adjustPasteData,
|
|
|
+} from '../../services/list-util/markdown-list-util';
|
|
|
import { useCodeMirrorEditorIsolated } from '../../stores';
|
|
|
|
|
|
import { Toolbar } from './Toolbar';
|
|
|
|
|
|
+
|
|
|
import style from './CodeMirrorEditor.module.scss';
|
|
|
|
|
|
const CodeMirrorEditorContainer = forwardRef<HTMLDivElement>((props, ref) => {
|
|
|
@@ -63,6 +67,12 @@ export const CodeMirrorEditor = (props: Props): JSX.Element => {
|
|
|
const handlePaste = (event: ClipboardEvent) => {
|
|
|
event.preventDefault();
|
|
|
|
|
|
+ const editor = codeMirrorEditor?.view;
|
|
|
+
|
|
|
+ if (editor == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (event.clipboardData == null) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -72,8 +82,14 @@ export const CodeMirrorEditor = (props: Props): JSX.Element => {
|
|
|
}
|
|
|
|
|
|
if (event.clipboardData.types.includes('text/plain')) {
|
|
|
+
|
|
|
const textData = event.clipboardData.getData('text/plain');
|
|
|
- codeMirrorEditor?.replaceText(textData);
|
|
|
+
|
|
|
+ const strFromBol = getStrFromBol(editor);
|
|
|
+
|
|
|
+ const adjusted = adjustPasteData(strFromBol, textData);
|
|
|
+
|
|
|
+ codeMirrorEditor?.replaceText(adjusted);
|
|
|
}
|
|
|
};
|
|
|
|