Skip to content

Commit 5e621cf

Browse files
fix: editor sync changes (#8306)
* chore: upate function declarations * chore: formatted files
1 parent f1761c6 commit 5e621cf

File tree

8 files changed

+86
-79
lines changed

8 files changed

+86
-79
lines changed

apps/web/core/components/pages/editor/content-limit-banner.tsx

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,32 @@ type Props = {
66
onDismiss?: () => void;
77
};
88

9-
export const ContentLimitBanner: React.FC<Props> = ({ className, onDismiss }) => (
10-
<div
11-
className={cn(
12-
"flex items-center gap-2 bg-custom-background-80 border-b border-custom-border-200 px-4 py-2.5 text-sm",
13-
className
14-
)}
15-
>
16-
<div className="flex items-center gap-2 text-custom-text-200 mx-auto">
17-
<span className="text-amber-500">
18-
<TriangleAlert />
19-
</span>
20-
<span className="font-medium">
21-
Content limit reached and live sync is off. Create a new page or use nested pages to continue syncing.
22-
</span>
9+
export function ContentLimitBanner({ className, onDismiss }: Props) {
10+
return (
11+
<div
12+
className={cn(
13+
"flex items-center gap-2 bg-custom-background-80 border-b border-custom-border-200 px-4 py-2.5 text-sm",
14+
className
15+
)}
16+
>
17+
<div className="flex items-center gap-2 text-custom-text-200 mx-auto">
18+
<span className="text-amber-500">
19+
<TriangleAlert />
20+
</span>
21+
<span className="font-medium">
22+
Content limit reached and live sync is off. Create a new page or use nested pages to continue syncing.
23+
</span>
24+
</div>
25+
{onDismiss && (
26+
<button
27+
type="button"
28+
onClick={onDismiss}
29+
className="ml-auto text-custom-text-300 hover:text-custom-text-200"
30+
aria-label="Dismiss content limit warning"
31+
>
32+
33+
</button>
34+
)}
2335
</div>
24-
{onDismiss && (
25-
<button
26-
type="button"
27-
onClick={onDismiss}
28-
className="ml-auto text-custom-text-300 hover:text-custom-text-200"
29-
aria-label="Dismiss content limit warning"
30-
>
31-
32-
</button>
33-
)}
34-
</div>
35-
);
36+
);
37+
}

apps/web/core/components/pages/editor/editor-body.tsx

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -254,43 +254,45 @@ export const PageEditorBody = observer(function PageEditorBody(props: Props) {
254254
</div>
255255
</div>
256256
)}
257-
<div className="page-header-container group/page-header">
258-
<div className={blockWidthClassName}>
259-
<PageEditorHeaderRoot page={page} projectId={projectId} />
257+
<div>
258+
<div className="page-header-container group/page-header">
259+
<div className={blockWidthClassName}>
260+
<PageEditorHeaderRoot page={page} projectId={projectId} />
261+
</div>
260262
</div>
263+
<CollaborativeDocumentEditorWithRef
264+
editable={isContentEditable}
265+
id={pageId}
266+
fileHandler={config.fileHandler}
267+
handleEditorReady={handleEditorReady}
268+
ref={editorForwardRef}
269+
titleRef={titleEditorRef}
270+
containerClassName="h-full p-0 pb-64"
271+
displayConfig={displayConfig}
272+
getEditorMetaData={getEditorMetaData}
273+
mentionHandler={{
274+
searchCallback: async (query) => {
275+
const res = await fetchMentions(query);
276+
if (!res) throw new Error("Failed in fetching mentions");
277+
return res;
278+
},
279+
renderComponent: (props) => <EditorMentionsRoot {...props} />,
280+
getMentionedEntityDetails: (id: string) => ({ display_name: getUserDetails(id)?.display_name ?? "" }),
281+
}}
282+
updatePageProperties={updatePageProperties}
283+
realtimeConfig={realtimeConfig}
284+
serverHandler={serverHandler}
285+
user={userConfig}
286+
disabledExtensions={documentEditorExtensions.disabled}
287+
flaggedExtensions={documentEditorExtensions.flagged}
288+
aiHandler={{
289+
menu: getAIMenu,
290+
}}
291+
onAssetChange={updateAssetsList}
292+
extendedEditorProps={extendedEditorProps}
293+
isFetchingFallbackBinary={isFetchingFallbackBinary}
294+
/>
261295
</div>
262-
<CollaborativeDocumentEditorWithRef
263-
editable={isContentEditable}
264-
id={pageId}
265-
fileHandler={config.fileHandler}
266-
handleEditorReady={handleEditorReady}
267-
ref={editorForwardRef}
268-
titleRef={titleEditorRef}
269-
containerClassName="h-full p-0 pb-64"
270-
displayConfig={displayConfig}
271-
getEditorMetaData={getEditorMetaData}
272-
mentionHandler={{
273-
searchCallback: async (query) => {
274-
const res = await fetchMentions(query);
275-
if (!res) throw new Error("Failed in fetching mentions");
276-
return res;
277-
},
278-
renderComponent: (props) => <EditorMentionsRoot {...props} />,
279-
getMentionedEntityDetails: (id: string) => ({ display_name: getUserDetails(id)?.display_name ?? "" }),
280-
}}
281-
updatePageProperties={updatePageProperties}
282-
realtimeConfig={realtimeConfig}
283-
serverHandler={serverHandler}
284-
user={userConfig}
285-
disabledExtensions={documentEditorExtensions.disabled}
286-
flaggedExtensions={documentEditorExtensions.flagged}
287-
aiHandler={{
288-
menu: getAIMenu,
289-
}}
290-
onAssetChange={updateAssetsList}
291-
extendedEditorProps={extendedEditorProps}
292-
isFetchingFallbackBinary={isFetchingFallbackBinary}
293-
/>
294296
</div>
295297
</Row>
296298
);

apps/web/core/components/pages/editor/page-root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type TPageRootProps = {
4343
customRealtimeEventHandlers?: TCustomEventHandlers;
4444
};
4545

46-
export const PageRoot = observer((props: TPageRootProps) => {
46+
export const PageRoot = observer(function PageRoot(props: TPageRootProps) {
4747
const {
4848
config,
4949
handlers,

apps/web/core/components/pages/header/syncing-badge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type Props = {
66
syncStatus: "syncing" | "synced" | "error";
77
};
88

9-
export const PageSyncingBadge = ({ syncStatus }: Props) => {
9+
export function PageSyncingBadge({ syncStatus }: Props) {
1010
const [prevSyncStatus, setPrevSyncStatus] = useState<"syncing" | "synced" | "error" | null>(null);
1111
const [isVisible, setIsVisible] = useState(syncStatus !== "synced");
1212

@@ -69,4 +69,4 @@ export const PageSyncingBadge = ({ syncStatus }: Props) => {
6969
</div>
7070
</Tooltip>
7171
);
72-
};
72+
}

packages/editor/src/core/components/editors/document/collaborative-editor.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useCollaborativeEditor } from "@/hooks/use-collaborative-editor";
1515
import type { EditorRefApi, ICollaborativeDocumentEditorProps } from "@/types";
1616

1717
// Inner component that has access to collaboration context
18-
const CollaborativeDocumentEditorInner: React.FC<ICollaborativeDocumentEditorProps> = (props) => {
18+
function CollaborativeDocumentEditorInner(props: ICollaborativeDocumentEditorProps) {
1919
const {
2020
aiHandler,
2121
bubbleMenuEnabled = true,
@@ -129,10 +129,10 @@ const CollaborativeDocumentEditorInner: React.FC<ICollaborativeDocumentEditorPro
129129
</div>
130130
</>
131131
);
132-
};
132+
}
133133

134134
// Outer component that provides collaboration context
135-
const CollaborativeDocumentEditor: React.FC<ICollaborativeDocumentEditorProps> = (props) => {
135+
function CollaborativeDocumentEditor(props: ICollaborativeDocumentEditorProps) {
136136
const { id, realtimeConfig, serverHandler, user } = props;
137137

138138
const token = useMemo(() => JSON.stringify(user), [user]);
@@ -147,13 +147,16 @@ const CollaborativeDocumentEditor: React.FC<ICollaborativeDocumentEditorProps> =
147147
<CollaborativeDocumentEditorInner {...props} />
148148
</CollaborationProvider>
149149
);
150-
};
150+
}
151151

152-
const CollaborativeDocumentEditorWithRef = React.forwardRef<EditorRefApi, ICollaborativeDocumentEditorProps>(
153-
(props, ref) => (
152+
const CollaborativeDocumentEditorWithRef = React.forwardRef(function CollaborativeDocumentEditorWithRef(
153+
props: ICollaborativeDocumentEditorProps,
154+
ref: React.ForwardedRef<EditorRefApi>
155+
) {
156+
return (
154157
<CollaborativeDocumentEditor key={props.id} {...props} forwardedRef={ref as React.MutableRefObject<EditorRefApi>} />
155-
)
156-
);
158+
);
159+
});
157160

158161
CollaborativeDocumentEditorWithRef.displayName = "CollaborativeDocumentEditorWithRef";
159162

packages/editor/src/core/components/editors/editor-container.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type Props = {
2626
state?: TCollabValue["state"];
2727
};
2828

29-
export const EditorContainer: FC<Props> = (props) => {
29+
export function EditorContainer(props: Props) {
3030
const { children, displayConfig, editor, editorContainerClassName, id, isTouchDevice, provider, state } = props;
3131
// refs
3232
const containerRef = useRef<HTMLDivElement>(null);
@@ -176,4 +176,4 @@ export const EditorContainer: FC<Props> = (props) => {
176176
</div>
177177
</>
178178
);
179-
};
179+
}

packages/editor/src/core/components/editors/editor-content.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EditorContent } from "@tiptap/react";
22
import type { Editor } from "@tiptap/react";
3-
import type { FC, ReactNode } from "react";
3+
import type { ReactNode } from "react";
44

55
type Props = {
66
className?: string;
@@ -10,7 +10,7 @@ type Props = {
1010
tabIndex?: number;
1111
};
1212

13-
export const EditorContentWrapper: FC<Props> = (props) => {
13+
export function EditorContentWrapper(props: Props) {
1414
const { editor, className, children, tabIndex, id } = props;
1515

1616
return (
@@ -23,4 +23,4 @@ export const EditorContentWrapper: FC<Props> = (props) => {
2323
{children}
2424
</div>
2525
);
26-
};
26+
}

packages/editor/src/core/hooks/use-title-editor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { getEditorRefHelpers } from "@/helpers/editor-ref";
1313
import type { IEditorPropsExtended, IEditorProps } from "@/types";
1414
import type { EditorTitleRefApi, ICollaborativeDocumentEditorProps } from "@/types/editor";
1515

16-
type Props = {
16+
type TUseTitleEditorProps = {
1717
editable?: boolean;
1818
provider: HocuspocusProvider;
1919
titleRef?: React.MutableRefObject<EditorTitleRefApi | null>;
@@ -31,7 +31,7 @@ type Props = {
3131
* A hook that creates a title editor with collaboration features
3232
* Uses the same Y.Doc as the main editor but a different field
3333
*/
34-
export const useTitleEditor = (props: Props) => {
34+
export const useTitleEditor = (props: TUseTitleEditorProps) => {
3535
const {
3636
editable = true,
3737
id,

0 commit comments

Comments
 (0)