mirror of
https://github.com/makeplane/plane.git
synced 2025-12-16 11:57:56 +01:00
fix: editor sync changes (#8306)
* chore: upate function declarations * chore: formatted files
This commit is contained in:
committed by
GitHub
parent
f1761c65b5
commit
5e621cf620
@@ -6,30 +6,32 @@ type Props = {
|
|||||||
onDismiss?: () => void;
|
onDismiss?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ContentLimitBanner: React.FC<Props> = ({ className, onDismiss }) => (
|
export function ContentLimitBanner({ className, onDismiss }: Props) {
|
||||||
<div
|
return (
|
||||||
className={cn(
|
<div
|
||||||
"flex items-center gap-2 bg-custom-background-80 border-b border-custom-border-200 px-4 py-2.5 text-sm",
|
className={cn(
|
||||||
className
|
"flex items-center gap-2 bg-custom-background-80 border-b border-custom-border-200 px-4 py-2.5 text-sm",
|
||||||
)}
|
className
|
||||||
>
|
)}
|
||||||
<div className="flex items-center gap-2 text-custom-text-200 mx-auto">
|
>
|
||||||
<span className="text-amber-500">
|
<div className="flex items-center gap-2 text-custom-text-200 mx-auto">
|
||||||
<TriangleAlert />
|
<span className="text-amber-500">
|
||||||
</span>
|
<TriangleAlert />
|
||||||
<span className="font-medium">
|
</span>
|
||||||
Content limit reached and live sync is off. Create a new page or use nested pages to continue syncing.
|
<span className="font-medium">
|
||||||
</span>
|
Content limit reached and live sync is off. Create a new page or use nested pages to continue syncing.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{onDismiss && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onDismiss}
|
||||||
|
className="ml-auto text-custom-text-300 hover:text-custom-text-200"
|
||||||
|
aria-label="Dismiss content limit warning"
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{onDismiss && (
|
);
|
||||||
<button
|
}
|
||||||
type="button"
|
|
||||||
onClick={onDismiss}
|
|
||||||
className="ml-auto text-custom-text-300 hover:text-custom-text-200"
|
|
||||||
aria-label="Dismiss content limit warning"
|
|
||||||
>
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -254,43 +254,45 @@ export const PageEditorBody = observer(function PageEditorBody(props: Props) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="page-header-container group/page-header">
|
<div>
|
||||||
<div className={blockWidthClassName}>
|
<div className="page-header-container group/page-header">
|
||||||
<PageEditorHeaderRoot page={page} projectId={projectId} />
|
<div className={blockWidthClassName}>
|
||||||
|
<PageEditorHeaderRoot page={page} projectId={projectId} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<CollaborativeDocumentEditorWithRef
|
||||||
|
editable={isContentEditable}
|
||||||
|
id={pageId}
|
||||||
|
fileHandler={config.fileHandler}
|
||||||
|
handleEditorReady={handleEditorReady}
|
||||||
|
ref={editorForwardRef}
|
||||||
|
titleRef={titleEditorRef}
|
||||||
|
containerClassName="h-full p-0 pb-64"
|
||||||
|
displayConfig={displayConfig}
|
||||||
|
getEditorMetaData={getEditorMetaData}
|
||||||
|
mentionHandler={{
|
||||||
|
searchCallback: async (query) => {
|
||||||
|
const res = await fetchMentions(query);
|
||||||
|
if (!res) throw new Error("Failed in fetching mentions");
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
renderComponent: (props) => <EditorMentionsRoot {...props} />,
|
||||||
|
getMentionedEntityDetails: (id: string) => ({ display_name: getUserDetails(id)?.display_name ?? "" }),
|
||||||
|
}}
|
||||||
|
updatePageProperties={updatePageProperties}
|
||||||
|
realtimeConfig={realtimeConfig}
|
||||||
|
serverHandler={serverHandler}
|
||||||
|
user={userConfig}
|
||||||
|
disabledExtensions={documentEditorExtensions.disabled}
|
||||||
|
flaggedExtensions={documentEditorExtensions.flagged}
|
||||||
|
aiHandler={{
|
||||||
|
menu: getAIMenu,
|
||||||
|
}}
|
||||||
|
onAssetChange={updateAssetsList}
|
||||||
|
extendedEditorProps={extendedEditorProps}
|
||||||
|
isFetchingFallbackBinary={isFetchingFallbackBinary}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<CollaborativeDocumentEditorWithRef
|
|
||||||
editable={isContentEditable}
|
|
||||||
id={pageId}
|
|
||||||
fileHandler={config.fileHandler}
|
|
||||||
handleEditorReady={handleEditorReady}
|
|
||||||
ref={editorForwardRef}
|
|
||||||
titleRef={titleEditorRef}
|
|
||||||
containerClassName="h-full p-0 pb-64"
|
|
||||||
displayConfig={displayConfig}
|
|
||||||
getEditorMetaData={getEditorMetaData}
|
|
||||||
mentionHandler={{
|
|
||||||
searchCallback: async (query) => {
|
|
||||||
const res = await fetchMentions(query);
|
|
||||||
if (!res) throw new Error("Failed in fetching mentions");
|
|
||||||
return res;
|
|
||||||
},
|
|
||||||
renderComponent: (props) => <EditorMentionsRoot {...props} />,
|
|
||||||
getMentionedEntityDetails: (id: string) => ({ display_name: getUserDetails(id)?.display_name ?? "" }),
|
|
||||||
}}
|
|
||||||
updatePageProperties={updatePageProperties}
|
|
||||||
realtimeConfig={realtimeConfig}
|
|
||||||
serverHandler={serverHandler}
|
|
||||||
user={userConfig}
|
|
||||||
disabledExtensions={documentEditorExtensions.disabled}
|
|
||||||
flaggedExtensions={documentEditorExtensions.flagged}
|
|
||||||
aiHandler={{
|
|
||||||
menu: getAIMenu,
|
|
||||||
}}
|
|
||||||
onAssetChange={updateAssetsList}
|
|
||||||
extendedEditorProps={extendedEditorProps}
|
|
||||||
isFetchingFallbackBinary={isFetchingFallbackBinary}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ type TPageRootProps = {
|
|||||||
customRealtimeEventHandlers?: TCustomEventHandlers;
|
customRealtimeEventHandlers?: TCustomEventHandlers;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PageRoot = observer((props: TPageRootProps) => {
|
export const PageRoot = observer(function PageRoot(props: TPageRootProps) {
|
||||||
const {
|
const {
|
||||||
config,
|
config,
|
||||||
handlers,
|
handlers,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ type Props = {
|
|||||||
syncStatus: "syncing" | "synced" | "error";
|
syncStatus: "syncing" | "synced" | "error";
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PageSyncingBadge = ({ syncStatus }: Props) => {
|
export function PageSyncingBadge({ syncStatus }: Props) {
|
||||||
const [prevSyncStatus, setPrevSyncStatus] = useState<"syncing" | "synced" | "error" | null>(null);
|
const [prevSyncStatus, setPrevSyncStatus] = useState<"syncing" | "synced" | "error" | null>(null);
|
||||||
const [isVisible, setIsVisible] = useState(syncStatus !== "synced");
|
const [isVisible, setIsVisible] = useState(syncStatus !== "synced");
|
||||||
|
|
||||||
@@ -69,4 +69,4 @@ export const PageSyncingBadge = ({ syncStatus }: Props) => {
|
|||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { useCollaborativeEditor } from "@/hooks/use-collaborative-editor";
|
|||||||
import type { EditorRefApi, ICollaborativeDocumentEditorProps } from "@/types";
|
import type { EditorRefApi, ICollaborativeDocumentEditorProps } from "@/types";
|
||||||
|
|
||||||
// Inner component that has access to collaboration context
|
// Inner component that has access to collaboration context
|
||||||
const CollaborativeDocumentEditorInner: React.FC<ICollaborativeDocumentEditorProps> = (props) => {
|
function CollaborativeDocumentEditorInner(props: ICollaborativeDocumentEditorProps) {
|
||||||
const {
|
const {
|
||||||
aiHandler,
|
aiHandler,
|
||||||
bubbleMenuEnabled = true,
|
bubbleMenuEnabled = true,
|
||||||
@@ -129,10 +129,10 @@ const CollaborativeDocumentEditorInner: React.FC<ICollaborativeDocumentEditorPro
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
// Outer component that provides collaboration context
|
// Outer component that provides collaboration context
|
||||||
const CollaborativeDocumentEditor: React.FC<ICollaborativeDocumentEditorProps> = (props) => {
|
function CollaborativeDocumentEditor(props: ICollaborativeDocumentEditorProps) {
|
||||||
const { id, realtimeConfig, serverHandler, user } = props;
|
const { id, realtimeConfig, serverHandler, user } = props;
|
||||||
|
|
||||||
const token = useMemo(() => JSON.stringify(user), [user]);
|
const token = useMemo(() => JSON.stringify(user), [user]);
|
||||||
@@ -147,13 +147,16 @@ const CollaborativeDocumentEditor: React.FC<ICollaborativeDocumentEditorProps> =
|
|||||||
<CollaborativeDocumentEditorInner {...props} />
|
<CollaborativeDocumentEditorInner {...props} />
|
||||||
</CollaborationProvider>
|
</CollaborationProvider>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
const CollaborativeDocumentEditorWithRef = React.forwardRef<EditorRefApi, ICollaborativeDocumentEditorProps>(
|
const CollaborativeDocumentEditorWithRef = React.forwardRef(function CollaborativeDocumentEditorWithRef(
|
||||||
(props, ref) => (
|
props: ICollaborativeDocumentEditorProps,
|
||||||
|
ref: React.ForwardedRef<EditorRefApi>
|
||||||
|
) {
|
||||||
|
return (
|
||||||
<CollaborativeDocumentEditor key={props.id} {...props} forwardedRef={ref as React.MutableRefObject<EditorRefApi>} />
|
<CollaborativeDocumentEditor key={props.id} {...props} forwardedRef={ref as React.MutableRefObject<EditorRefApi>} />
|
||||||
)
|
);
|
||||||
);
|
});
|
||||||
|
|
||||||
CollaborativeDocumentEditorWithRef.displayName = "CollaborativeDocumentEditorWithRef";
|
CollaborativeDocumentEditorWithRef.displayName = "CollaborativeDocumentEditorWithRef";
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ type Props = {
|
|||||||
state?: TCollabValue["state"];
|
state?: TCollabValue["state"];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EditorContainer: FC<Props> = (props) => {
|
export function EditorContainer(props: Props) {
|
||||||
const { children, displayConfig, editor, editorContainerClassName, id, isTouchDevice, provider, state } = props;
|
const { children, displayConfig, editor, editorContainerClassName, id, isTouchDevice, provider, state } = props;
|
||||||
// refs
|
// refs
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
@@ -176,4 +176,4 @@ export const EditorContainer: FC<Props> = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { EditorContent } from "@tiptap/react";
|
import { EditorContent } from "@tiptap/react";
|
||||||
import type { Editor } from "@tiptap/react";
|
import type { Editor } from "@tiptap/react";
|
||||||
import type { FC, ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -10,7 +10,7 @@ type Props = {
|
|||||||
tabIndex?: number;
|
tabIndex?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EditorContentWrapper: FC<Props> = (props) => {
|
export function EditorContentWrapper(props: Props) {
|
||||||
const { editor, className, children, tabIndex, id } = props;
|
const { editor, className, children, tabIndex, id } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -23,4 +23,4 @@ export const EditorContentWrapper: FC<Props> = (props) => {
|
|||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { getEditorRefHelpers } from "@/helpers/editor-ref";
|
|||||||
import type { IEditorPropsExtended, IEditorProps } from "@/types";
|
import type { IEditorPropsExtended, IEditorProps } from "@/types";
|
||||||
import type { EditorTitleRefApi, ICollaborativeDocumentEditorProps } from "@/types/editor";
|
import type { EditorTitleRefApi, ICollaborativeDocumentEditorProps } from "@/types/editor";
|
||||||
|
|
||||||
type Props = {
|
type TUseTitleEditorProps = {
|
||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
provider: HocuspocusProvider;
|
provider: HocuspocusProvider;
|
||||||
titleRef?: React.MutableRefObject<EditorTitleRefApi | null>;
|
titleRef?: React.MutableRefObject<EditorTitleRefApi | null>;
|
||||||
@@ -31,7 +31,7 @@ type Props = {
|
|||||||
* A hook that creates a title editor with collaboration features
|
* A hook that creates a title editor with collaboration features
|
||||||
* Uses the same Y.Doc as the main editor but a different field
|
* Uses the same Y.Doc as the main editor but a different field
|
||||||
*/
|
*/
|
||||||
export const useTitleEditor = (props: Props) => {
|
export const useTitleEditor = (props: TUseTitleEditorProps) => {
|
||||||
const {
|
const {
|
||||||
editable = true,
|
editable = true,
|
||||||
id,
|
id,
|
||||||
|
|||||||
Reference in New Issue
Block a user