donteatfriedrice
2024-07-25 07:26:39 +00:00
parent 2b42f84815
commit dd6901fe15
23 changed files with 156 additions and 166 deletions
@@ -160,7 +160,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
const editorHost = editor.host;
// provide image proxy endpoint to blocksuite
editorHost.std.clipboard.use(
editorHost?.std.clipboard.use(
customImageProxyMiddleware(runtimeConfig.imageProxyUrl)
);
ImageBlockService.setImageProxyURL(runtimeConfig.imageProxyUrl);
@@ -179,22 +179,24 @@ const DetailPageImpl = memo(function DetailPageImpl() {
// provide page mode and updated date to blocksuite
const pageService =
editorHost.std.spec.getService<PageRootService>('affine:page');
editorHost?.std.spec.getService<PageRootService>('affine:page');
const disposable = new DisposableGroup();
doc.setMode(mode);
disposable.add(
pageService.slots.docLinkClicked.on(({ docId, blockId }) => {
return blockId
? jumpToPageBlock(docCollection.id, docId, blockId)
: openPage(docCollection.id, docId);
})
);
disposable.add(
pageService.slots.tagClicked.on(({ tagId }) => {
jumpToTag(workspace.id, tagId);
})
);
if (pageService) {
disposable.add(
pageService.slots.docLinkClicked.on(({ docId, blockId }) => {
return blockId
? jumpToPageBlock(docCollection.id, docId, blockId)
: openPage(docCollection.id, docId);
})
);
disposable.add(
pageService.slots.tagClicked.on(({ tagId }) => {
jumpToTag(workspace.id, tagId);
})
);
}
setEditor(editor);
@@ -42,7 +42,8 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
useEffect(() => {
if (!editor) return;
const pageService = editor.host.spec.getService('affine:page');
const pageService = editor.host?.spec.getService('affine:page');
if (!pageService) return;
const disposable = [
pageService.slots.docLinkClicked.on(() => {
@@ -65,7 +66,9 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
chatPanelRef.current = new ChatPanel();
}
(chatPanelRef.current as ChatPanel).host = editor.host;
if (editor.host) {
(chatPanelRef.current as ChatPanel).host = editor.host;
}
(chatPanelRef.current as ChatPanel).doc = editor.doc;
// (copilotPanelRef.current as CopilotPanel).fitPadding = [20, 20, 20, 20];