Skip to content

Commit

Permalink
feat: path onMount prop
Browse files Browse the repository at this point in the history
  • Loading branch information
asabotovich committed Jun 17, 2024
1 parent 2758220 commit 682e760
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/harmony/FormEditor/FormEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState, ComponentProps } from 'react';
import { useDropzone } from 'react-dropzone';
import { IconAttachOutline } from '@taskany/icons';
import cn from 'classnames';
Expand Down Expand Up @@ -27,6 +27,7 @@ interface File {
type: string;
filePath: string;
}
type OnMountCallback = ComponentProps<typeof Editor>['onMount'];

interface FormEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'onBlur' | 'onFocus'> {
id?: string;
Expand Down Expand Up @@ -55,6 +56,7 @@ interface FormEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'on
onUploadSuccess?: () => void;
onUploadFail?: (message?: string) => void;
attachFormatter?: (files: File[]) => string;
onMount?: OnMountCallback;
}

const defaultAttachmentsButtonMessage = 'Attach files';
Expand Down Expand Up @@ -116,6 +118,7 @@ export const FormEditor = React.forwardRef<HTMLDivElement, FormEditorProps>(
onUploadFail,
attachFormatter = defaultAttachFormatter,
className,
onMount,
view,
...attrs
},
Expand All @@ -134,8 +137,7 @@ export const FormEditor = React.forwardRef<HTMLDivElement, FormEditorProps>(
const formCtx = useContext(formContext);
const disabled = formCtx.disabled || internalDisabled;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handleEditorDidMount = (editor: any /* IStandaloneEditor */) => {
const handleEditorDidMount: OnMountCallback = (editor, monaco) => {
monacoEditorRef.current = editor;

if (autoFocus) {
Expand All @@ -152,6 +154,8 @@ export const FormEditor = React.forwardRef<HTMLDivElement, FormEditorProps>(
});

setViewValue(value);

onMount?.(editor, monaco);
};

useEffect(() => {
Expand Down

0 comments on commit 682e760

Please sign in to comment.