fix(core): add switch button to switch-to-edgeless notification (#8300)
fix AF-1359
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { notify } from '@affine/component';
|
|
||||||
import { AIProvider } from '@affine/core/blocksuite/presets/ai';
|
import { AIProvider } from '@affine/core/blocksuite/presets/ai';
|
||||||
import { toggleGeneralAIOnboarding } from '@affine/core/components/affine/ai-onboarding/apis';
|
import { toggleGeneralAIOnboarding } from '@affine/core/components/affine/ai-onboarding/apis';
|
||||||
import { authAtom, openSettingModalAtom } from '@affine/core/components/atoms';
|
import { authAtom, openSettingModalAtom } from '@affine/core/components/atoms';
|
||||||
@@ -7,7 +6,6 @@ import {
|
|||||||
type getCopilotHistoriesQuery,
|
type getCopilotHistoriesQuery,
|
||||||
type RequestOptions,
|
type RequestOptions,
|
||||||
} from '@affine/graphql';
|
} from '@affine/graphql';
|
||||||
import { Trans } from '@affine/i18n';
|
|
||||||
import { track } from '@affine/track';
|
import { track } from '@affine/track';
|
||||||
import { UnauthorizedError } from '@blocksuite/blocks';
|
import { UnauthorizedError } from '@blocksuite/blocks';
|
||||||
import { assertExists } from '@blocksuite/global/utils';
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
@@ -480,13 +478,5 @@ Could you make a new website based on these notes and send back just the html fi
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
AIProvider.slots.requestRunInEdgeless.on(() => {
|
|
||||||
notify.warning({
|
|
||||||
title: (
|
|
||||||
<Trans i18nKey="com.affine.ai.action.edgeless-only.dialog-title" />
|
|
||||||
),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
setupTracker();
|
setupTracker();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Scrollable, useHasScrollTop } from '@affine/component';
|
import { notify, Scrollable, useHasScrollTop } from '@affine/component';
|
||||||
import { PageDetailSkeleton } from '@affine/component/page-detail-skeleton';
|
import { PageDetailSkeleton } from '@affine/component/page-detail-skeleton';
|
||||||
import type { ChatPanel } from '@affine/core/blocksuite/presets/ai';
|
import type { ChatPanel } from '@affine/core/blocksuite/presets/ai';
|
||||||
import { AIProvider } from '@affine/core/blocksuite/presets/ai';
|
import { AIProvider } from '@affine/core/blocksuite/presets/ai';
|
||||||
@@ -9,6 +9,7 @@ import { useDocMetaHelper } from '@affine/core/components/hooks/use-block-suite-
|
|||||||
import { EditorService } from '@affine/core/modules/editor';
|
import { EditorService } from '@affine/core/modules/editor';
|
||||||
import { RecentDocsService } from '@affine/core/modules/quicksearch';
|
import { RecentDocsService } from '@affine/core/modules/quicksearch';
|
||||||
import { ViewService } from '@affine/core/modules/workbench/services/view';
|
import { ViewService } from '@affine/core/modules/workbench/services/view';
|
||||||
|
import { useI18n } from '@affine/i18n';
|
||||||
import { RefNodeSlotsProvider } from '@blocksuite/blocks';
|
import { RefNodeSlotsProvider } from '@blocksuite/blocks';
|
||||||
import { DisposableGroup } from '@blocksuite/global/utils';
|
import { DisposableGroup } from '@blocksuite/global/utils';
|
||||||
import { AiIcon, FrameIcon, TocIcon, TodayIcon } from '@blocksuite/icons/rc';
|
import { AiIcon, FrameIcon, TocIcon, TodayIcon } from '@blocksuite/icons/rc';
|
||||||
@@ -94,6 +95,8 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
|||||||
// TODO(@eyhn): remove jotai here
|
// TODO(@eyhn): remove jotai here
|
||||||
const [_, setActiveBlockSuiteEditor] = useActiveBlocksuiteEditor();
|
const [_, setActiveBlockSuiteEditor] = useActiveBlocksuiteEditor();
|
||||||
|
|
||||||
|
const t = useI18n();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isActiveView) {
|
if (isActiveView) {
|
||||||
setActiveBlockSuiteEditor(editorContainer);
|
setActiveBlockSuiteEditor(editorContainer);
|
||||||
@@ -187,6 +190,22 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disposable.add(
|
||||||
|
AIProvider.slots.requestRunInEdgeless.on(({ host }) => {
|
||||||
|
if (host === editorHost) {
|
||||||
|
notify.warning({
|
||||||
|
title: t['com.affine.ai.action.edgeless-only.dialog-title'](),
|
||||||
|
action: {
|
||||||
|
label: t['Switch'](),
|
||||||
|
onClick: () => {
|
||||||
|
editor.setMode('edgeless');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
editor.setEditorContainer(editorContainer);
|
editor.setEditorContainer(editorContainer);
|
||||||
const unbind = editor.bindEditorContainer(
|
const unbind = editor.bindEditorContainer(
|
||||||
editorContainer,
|
editorContainer,
|
||||||
@@ -199,7 +218,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
|||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[editor, openPage, docCollection.id, jumpToPageBlock]
|
[editor, openPage, docCollection.id, jumpToPageBlock, t]
|
||||||
);
|
);
|
||||||
|
|
||||||
const [refCallback, hasScrollTop] = useHasScrollTop();
|
const [refCallback, hasScrollTop] = useHasScrollTop();
|
||||||
|
|||||||
Reference in New Issue
Block a user