fix: editor sync changes (#8306)

* chore: upate function declarations

* chore: formatted files
This commit is contained in:
sriram veeraghanta 2025-12-11 13:01:25 +05:30 committed by GitHub
parent f1761c65b5
commit 5e621cf620
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 86 additions and 79 deletions

View file

@ -15,7 +15,7 @@ import { useCollaborativeEditor } from "@/hooks/use-collaborative-editor";
import type { EditorRefApi, ICollaborativeDocumentEditorProps } from "@/types";
// Inner component that has access to collaboration context
const CollaborativeDocumentEditorInner: React.FC<ICollaborativeDocumentEditorProps> = (props) => {
function CollaborativeDocumentEditorInner(props: ICollaborativeDocumentEditorProps) {
const {
aiHandler,
bubbleMenuEnabled = true,
@ -129,10 +129,10 @@ const CollaborativeDocumentEditorInner: React.FC<ICollaborativeDocumentEditorPro
</div>
</>
);
};
}
// Outer component that provides collaboration context
const CollaborativeDocumentEditor: React.FC<ICollaborativeDocumentEditorProps> = (props) => {
function CollaborativeDocumentEditor(props: ICollaborativeDocumentEditorProps) {
const { id, realtimeConfig, serverHandler, user } = props;
const token = useMemo(() => JSON.stringify(user), [user]);
@ -147,13 +147,16 @@ const CollaborativeDocumentEditor: React.FC<ICollaborativeDocumentEditorProps> =
<CollaborativeDocumentEditorInner {...props} />
</CollaborationProvider>
);
};
}
const CollaborativeDocumentEditorWithRef = React.forwardRef<EditorRefApi, ICollaborativeDocumentEditorProps>(
(props, ref) => (
const CollaborativeDocumentEditorWithRef = React.forwardRef(function CollaborativeDocumentEditorWithRef(
props: ICollaborativeDocumentEditorProps,
ref: React.ForwardedRef<EditorRefApi>
) {
return (
<CollaborativeDocumentEditor key={props.id} {...props} forwardedRef={ref as React.MutableRefObject<EditorRefApi>} />
)
);
);
});
CollaborativeDocumentEditorWithRef.displayName = "CollaborativeDocumentEditorWithRef";

View file

@ -26,7 +26,7 @@ type Props = {
state?: TCollabValue["state"];
};
export const EditorContainer: FC<Props> = (props) => {
export function EditorContainer(props: Props) {
const { children, displayConfig, editor, editorContainerClassName, id, isTouchDevice, provider, state } = props;
// refs
const containerRef = useRef<HTMLDivElement>(null);
@ -176,4 +176,4 @@ export const EditorContainer: FC<Props> = (props) => {
</div>
</>
);
};
}

View file

@ -1,6 +1,6 @@
import { EditorContent } from "@tiptap/react";
import type { Editor } from "@tiptap/react";
import type { FC, ReactNode } from "react";
import type { ReactNode } from "react";
type Props = {
className?: string;
@ -10,7 +10,7 @@ type Props = {
tabIndex?: number;
};
export const EditorContentWrapper: FC<Props> = (props) => {
export function EditorContentWrapper(props: Props) {
const { editor, className, children, tabIndex, id } = props;
return (
@ -23,4 +23,4 @@ export const EditorContentWrapper: FC<Props> = (props) => {
{children}
</div>
);
};
}

View file

@ -13,7 +13,7 @@ import { getEditorRefHelpers } from "@/helpers/editor-ref";
import type { IEditorPropsExtended, IEditorProps } from "@/types";
import type { EditorTitleRefApi, ICollaborativeDocumentEditorProps } from "@/types/editor";
type Props = {
type TUseTitleEditorProps = {
editable?: boolean;
provider: HocuspocusProvider;
titleRef?: React.MutableRefObject<EditorTitleRefApi | null>;
@ -31,7 +31,7 @@ type Props = {
* A hook that creates a title editor with collaboration features
* Uses the same Y.Doc as the main editor but a different field
*/
export const useTitleEditor = (props: Props) => {
export const useTitleEditor = (props: TUseTitleEditorProps) => {
const {
editable = true,
id,