mirror of
https://github.com/docmost/docmost.git
synced 2026-07-27 03:54:41 +10:00
fix: toolbar flicker on navigation (#2352)
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
z-index: 99;
|
z-index: 99;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
min-height: 45px;
|
||||||
background: var(--mantine-color-body);
|
background: var(--mantine-color-body);
|
||||||
border-bottom: 1px solid
|
border-bottom: 1px solid
|
||||||
light-dark(var(--mantine-color-gray-2), var(--mantine-color-dark-4));
|
light-dark(var(--mantine-color-gray-2), var(--mantine-color-dark-4));
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ export const FixedToolbar: FC<FixedToolbarProps> = ({
|
|||||||
const workspace = useAtomValue(workspaceAtom);
|
const workspace = useAtomValue(workspaceAtom);
|
||||||
const isGenerativeAiEnabled = workspace?.settings?.ai?.generative === true;
|
const isGenerativeAiEnabled = workspace?.settings?.ai?.generative === true;
|
||||||
|
|
||||||
if (!editor || !state) return null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
@@ -49,22 +47,26 @@ export const FixedToolbar: FC<FixedToolbarProps> = ({
|
|||||||
<div className={classes.divider} />
|
<div className={classes.divider} />
|
||||||
</>
|
</>
|
||||||
)} */}
|
)} */}
|
||||||
<BlockTypeGroup editor={editor} />
|
{editor && state && (
|
||||||
<div className={classes.divider} />
|
<>
|
||||||
<InlineMarksGroup editor={editor} state={state} />
|
<BlockTypeGroup editor={editor} />
|
||||||
<div className={classes.divider} />
|
<div className={classes.divider} />
|
||||||
<ColorGroup editor={editor} />
|
<InlineMarksGroup editor={editor} state={state} />
|
||||||
<div className={classes.divider} />
|
<div className={classes.divider} />
|
||||||
<ListsGroup editor={editor} state={state} />
|
<ColorGroup editor={editor} />
|
||||||
<div className={classes.divider} />
|
<div className={classes.divider} />
|
||||||
<AlignmentGroup editor={editor} />
|
<ListsGroup editor={editor} state={state} />
|
||||||
<div className={classes.divider} />
|
<div className={classes.divider} />
|
||||||
<MediaGroup editor={editor} templateMode={templateMode} />
|
<AlignmentGroup editor={editor} />
|
||||||
<div className={classes.divider} />
|
<div className={classes.divider} />
|
||||||
<QuickInsertsGroup editor={editor} />
|
<MediaGroup editor={editor} templateMode={templateMode} />
|
||||||
<MoreInsertsGroup editor={editor} templateMode={templateMode} />
|
<div className={classes.divider} />
|
||||||
<div className={classes.divider} />
|
<QuickInsertsGroup editor={editor} />
|
||||||
<HistoryGroup editor={editor} state={state} />
|
<MoreInsertsGroup editor={editor} templateMode={templateMode} />
|
||||||
|
<div className={classes.divider} />
|
||||||
|
<HistoryGroup editor={editor} state={state} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.spacer} aria-hidden />
|
<div className={classes.spacer} aria-hidden />
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import "@/features/editor/styles/index.css";
|
|||||||
import React, {
|
import React, {
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
|
useLayoutEffect,
|
||||||
useMemo,
|
useMemo,
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
@@ -100,11 +101,13 @@ export default function PageEditor({
|
|||||||
const { pageSlug } = useParams();
|
const { pageSlug } = useParams();
|
||||||
const slugId = extractPageSlugId(pageSlug);
|
const slugId = extractPageSlugId(pageSlug);
|
||||||
const [socket] = useState(getCollabSocket);
|
const [socket] = useState(getCollabSocket);
|
||||||
|
const hasCollabToken = !!collabQuery?.token;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!hasCollabToken) return;
|
||||||
acquireCollabSocket();
|
acquireCollabSocket();
|
||||||
return () => releaseCollabSocket();
|
return () => releaseCollabSocket();
|
||||||
}, []);
|
}, [hasCollabToken]);
|
||||||
|
|
||||||
const handleStateless = ({ payload }: onStatelessParameters) => {
|
const handleStateless = ({ payload }: onStatelessParameters) => {
|
||||||
try {
|
try {
|
||||||
@@ -322,6 +325,16 @@ function CollabPageEditor({
|
|||||||
[pageId, editable, extensions],
|
[pageId, editable, extensions],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
if (editor && !editor.isDestroyed) {
|
||||||
|
// @ts-ignore
|
||||||
|
setEditor(editor);
|
||||||
|
// @ts-ignore
|
||||||
|
editor.storage.pageId = pageId;
|
||||||
|
editorRef.current = editor;
|
||||||
|
}
|
||||||
|
}, [editor, pageId, setEditor]);
|
||||||
|
|
||||||
const editorIsEditable = useEditorState({
|
const editorIsEditable = useEditorState({
|
||||||
editor,
|
editor,
|
||||||
selector: (ctx) => {
|
selector: (ctx) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user