|
@@ -1,3 +1,5 @@
|
|
|
|
|
+import { useCallback } from 'react';
|
|
|
|
|
+
|
|
|
import {
|
|
import {
|
|
|
UncontrolledDropdown,
|
|
UncontrolledDropdown,
|
|
|
DropdownToggle,
|
|
DropdownToggle,
|
|
@@ -5,19 +7,37 @@ import {
|
|
|
DropdownItem,
|
|
DropdownItem,
|
|
|
} from 'reactstrap';
|
|
} from 'reactstrap';
|
|
|
|
|
|
|
|
|
|
+import type { GlobalCodeMirrorEditorKey } from '../../../consts';
|
|
|
import { AcceptedUploadFileType } from '../../../consts/accepted-upload-file-type';
|
|
import { AcceptedUploadFileType } from '../../../consts/accepted-upload-file-type';
|
|
|
|
|
+import type Linker from '../../../services/link-util/Linker';
|
|
|
|
|
+import { useCodeMirrorEditorIsolated } from '../../../stores';
|
|
|
|
|
+import { useLinkEditModal } from '../../../stores/use-link-edit-modal';
|
|
|
|
|
+
|
|
|
|
|
|
|
|
import { AttachmentsButton } from './AttachmentsButton';
|
|
import { AttachmentsButton } from './AttachmentsButton';
|
|
|
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
|
|
|
+ editorKey: string | GlobalCodeMirrorEditorKey,
|
|
|
onFileOpen: () => void,
|
|
onFileOpen: () => void,
|
|
|
acceptedFileType: AcceptedUploadFileType,
|
|
acceptedFileType: AcceptedUploadFileType,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export const AttachmentsDropup = (props: Props): JSX.Element => {
|
|
export const AttachmentsDropup = (props: Props): JSX.Element => {
|
|
|
|
|
+ const { onFileOpen, acceptedFileType, editorKey } = props;
|
|
|
|
|
+
|
|
|
|
|
+ const { open: openLinkEditModal } = useLinkEditModal();
|
|
|
|
|
+ const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(editorKey);
|
|
|
|
|
+
|
|
|
|
|
+ const onClickOpenLinkEditModal = useCallback(() => {
|
|
|
|
|
+ const onSubmit = (linkText: string) => {
|
|
|
|
|
+ return;
|
|
|
|
|
+ };
|
|
|
|
|
+ const defaultMarkdownLink = {} as Linker;
|
|
|
|
|
+
|
|
|
|
|
+ openLinkEditModal(defaultMarkdownLink, onSubmit);
|
|
|
|
|
+ }, [openLinkEditModal]);
|
|
|
|
|
|
|
|
- const { onFileOpen, acceptedFileType } = props;
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<UncontrolledDropdown direction="up" className="lh-1">
|
|
<UncontrolledDropdown direction="up" className="lh-1">
|
|
@@ -31,7 +51,7 @@ export const AttachmentsDropup = (props: Props): JSX.Element => {
|
|
|
</DropdownItem>
|
|
</DropdownItem>
|
|
|
<DropdownItem divider />
|
|
<DropdownItem divider />
|
|
|
<AttachmentsButton onFileOpen={onFileOpen} acceptedFileType={acceptedFileType} />
|
|
<AttachmentsButton onFileOpen={onFileOpen} acceptedFileType={acceptedFileType} />
|
|
|
- <DropdownItem className="d-flex gap-1 align-items-center">
|
|
|
|
|
|
|
+ <DropdownItem className="d-flex gap-1 align-items-center" onClick={onClickOpenLinkEditModal}>
|
|
|
<span className="material-symbols-outlined fs-5">link</span>
|
|
<span className="material-symbols-outlined fs-5">link</span>
|
|
|
Link
|
|
Link
|
|
|
</DropdownItem>
|
|
</DropdownItem>
|