mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
chore: bump blocksuite (#6448)
## Features - https://github.com/toeverything/BlockSuite/pull/6679 @pengx17 - https://github.com/toeverything/BlockSuite/pull/6620 @doouding - https://github.com/toeverything/BlockSuite/pull/6602 @golok727 - https://github.com/toeverything/BlockSuite/pull/6661 @Flrande - https://github.com/toeverything/BlockSuite/pull/6591 @fundon - https://github.com/toeverything/BlockSuite/pull/6634 @golok727 - https://github.com/toeverything/BlockSuite/pull/6626 @regischen - https://github.com/toeverything/BlockSuite/pull/6630 @Saul-Mirone - https://github.com/toeverything/BlockSuite/pull/6605 @donteatfriedrice - https://github.com/toeverything/BlockSuite/pull/6614 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/6508 @doouding - https://github.com/toeverything/BlockSuite/pull/6578 @donteatfriedrice - https://github.com/toeverything/BlockSuite/pull/6572 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/6571 @golok727 - https://github.com/toeverything/BlockSuite/pull/6573 @fundon - https://github.com/toeverything/BlockSuite/pull/6580 @Flrande - https://github.com/toeverything/BlockSuite/pull/6540 @golok727 - https://github.com/toeverything/BlockSuite/pull/6567 @Flrande - https://github.com/toeverything/BlockSuite/pull/6565 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/6561 @zzj3720 ## Bugfix - https://github.com/toeverything/BlockSuite/pull/6677 @donteatfriedrice - https://github.com/toeverything/BlockSuite/pull/6681 @fundon - https://github.com/toeverything/BlockSuite/pull/6673 @fundon - https://github.com/toeverything/BlockSuite/pull/6652 @fundon - https://github.com/toeverything/BlockSuite/pull/6641 @fourdim - https://github.com/toeverything/BlockSuite/pull/6649 @golok727 - https://github.com/toeverything/BlockSuite/pull/6648 @doouding - https://github.com/toeverything/BlockSuite/pull/6662 @Flrande - https://github.com/toeverything/BlockSuite/pull/6659 @zkwolf - https://github.com/toeverything/BlockSuite/pull/6644 @doouding - https://github.com/toeverything/BlockSuite/pull/6633 @golok727 - https://github.com/toeverything/BlockSuite/pull/6632 @golok727 - https://github.com/toeverything/BlockSuite/pull/6622 @RubaXa - https://github.com/toeverything/BlockSuite/pull/6622 @RubaXa - https://github.com/toeverything/BlockSuite/pull/6622 @RubaXa - https://github.com/toeverything/BlockSuite/pull/6622 @RubaXa - https://github.com/toeverything/BlockSuite/pull/6622 @RubaXa - https://github.com/toeverything/BlockSuite/pull/6600 @fourdim - https://github.com/toeverything/BlockSuite/pull/6617 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/6618 @Flrande - https://github.com/toeverything/BlockSuite/pull/6576 @fundon - https://github.com/toeverything/BlockSuite/pull/6595 @fundon - https://github.com/toeverything/BlockSuite/pull/6596 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/6574 @fundon - https://github.com/toeverything/BlockSuite/pull/6593 @Saul-Mirone - https://github.com/toeverything/BlockSuite/pull/6588 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/6590 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/6589 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/6584 @lawvs - https://github.com/toeverything/BlockSuite/pull/6579 @fundon - https://github.com/toeverything/BlockSuite/pull/6538 @golok727 - https://github.com/toeverything/BlockSuite/pull/6570 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/6569 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/6564 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/6563 @zzj3720 ## Refactor - https://github.com/toeverything/BlockSuite/pull/6683 @doodlewind - https://github.com/toeverything/BlockSuite/pull/6668 @Flrande - https://github.com/toeverything/BlockSuite/pull/6635 @donteatfriedrice - https://github.com/toeverything/BlockSuite/pull/6653 @fundon - https://github.com/toeverything/BlockSuite/pull/6615 @Flrande - https://github.com/toeverything/BlockSuite/pull/6534 @Saul-Mirone - https://github.com/toeverything/BlockSuite/pull/6553 @golok727 ## Misc - chore(examples): cleanup types - https://github.com/toeverything/BlockSuite/pull/6664 @fourdim - https://github.com/toeverything/BlockSuite/pull/6657 @fourdim - https://github.com/toeverything/BlockSuite/pull/6654 @fourdim - https://github.com/toeverything/BlockSuite/pull/6587 @Saul-Mirone - https://github.com/toeverything/BlockSuite/pull/6562 @donteatfriedrice
This commit is contained in:
Vendored
+2
-2
@@ -3,8 +3,8 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@blocksuite/global": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/global": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/store": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/store": "0.14.0-canary-202404090831-25c5310",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"vitest": "1.4.0"
|
"vitest": "1.4.0"
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
"@affine/debug": "workspace:*",
|
"@affine/debug": "workspace:*",
|
||||||
"@affine/env": "workspace:*",
|
"@affine/env": "workspace:*",
|
||||||
"@affine/templates": "workspace:*",
|
"@affine/templates": "workspace:*",
|
||||||
"@blocksuite/blocks": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/blocks": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/global": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/global": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/store": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/store": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@datastructures-js/binary-search-tree": "^5.3.2",
|
"@datastructures-js/binary-search-tree": "^5.3.2",
|
||||||
"foxact": "^0.2.31",
|
"foxact": "^0.2.31",
|
||||||
"jotai": "^2.6.5",
|
"jotai": "^2.6.5",
|
||||||
@@ -28,8 +28,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@affine-test/fixtures": "workspace:*",
|
"@affine-test/fixtures": "workspace:*",
|
||||||
"@affine/templates": "workspace:*",
|
"@affine/templates": "workspace:*",
|
||||||
"@blocksuite/block-std": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/block-std": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/presets": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/presets": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@testing-library/react": "^14.2.1",
|
"@testing-library/react": "^14.2.1",
|
||||||
"async-call-rpc": "^6.4.0",
|
"async-call-rpc": "^6.4.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
|||||||
@@ -32,14 +32,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@blocksuite/global": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/global": "0.14.0-canary-202404090831-25c5310",
|
||||||
"idb": "^8.0.0",
|
"idb": "^8.0.0",
|
||||||
"nanoid": "^5.0.6",
|
"nanoid": "^5.0.6",
|
||||||
"y-provider": "workspace:*"
|
"y-provider": "workspace:*"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@blocksuite/blocks": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/blocks": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/store": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/store": "0.14.0-canary-202404090831-25c5310",
|
||||||
"fake-indexeddb": "^5.0.2",
|
"fake-indexeddb": "^5.0.2",
|
||||||
"vite": "^5.1.4",
|
"vite": "^5.1.4",
|
||||||
"vite-plugin-dts": "3.7.3",
|
"vite-plugin-dts": "3.7.3",
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
"build": "vite build"
|
"build": "vite build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@blocksuite/store": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/store": "0.14.0-canary-202404090831-25c5310",
|
||||||
"vite": "^5.1.4",
|
"vite": "^5.1.4",
|
||||||
"vite-plugin-dts": "3.7.3",
|
"vite-plugin-dts": "3.7.3",
|
||||||
"vitest": "1.4.0",
|
"vitest": "1.4.0",
|
||||||
|
|||||||
@@ -75,12 +75,12 @@
|
|||||||
"zod": "^3.22.4"
|
"zod": "^3.22.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@blocksuite/block-std": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/block-std": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/blocks": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/blocks": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/global": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/global": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/icons": "2.1.46",
|
"@blocksuite/icons": "2.1.46",
|
||||||
"@blocksuite/presets": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/presets": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/store": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/store": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@storybook/addon-actions": "^7.6.17",
|
"@storybook/addon-actions": "^7.6.17",
|
||||||
"@storybook/addon-essentials": "^7.6.17",
|
"@storybook/addon-essentials": "^7.6.17",
|
||||||
"@storybook/addon-interactions": "^7.6.17",
|
"@storybook/addon-interactions": "^7.6.17",
|
||||||
|
|||||||
@@ -19,13 +19,13 @@
|
|||||||
"@affine/i18n": "workspace:*",
|
"@affine/i18n": "workspace:*",
|
||||||
"@affine/templates": "workspace:*",
|
"@affine/templates": "workspace:*",
|
||||||
"@affine/workspace-impl": "workspace:*",
|
"@affine/workspace-impl": "workspace:*",
|
||||||
"@blocksuite/block-std": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/block-std": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/blocks": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/blocks": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/global": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/global": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/icons": "2.1.46",
|
"@blocksuite/icons": "2.1.46",
|
||||||
"@blocksuite/inline": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/inline": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/presets": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/presets": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/store": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/store": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@dnd-kit/core": "^6.1.0",
|
"@dnd-kit/core": "^6.1.0",
|
||||||
"@dnd-kit/modifiers": "^7.0.0",
|
"@dnd-kit/modifiers": "^7.0.0",
|
||||||
"@dnd-kit/sortable": "^8.0.0",
|
"@dnd-kit/sortable": "^8.0.0",
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
|
import { AIProvider } from '@blocksuite/presets';
|
||||||
|
|
||||||
|
import { textToTextStream } from './request';
|
||||||
|
|
||||||
|
export function setupAIProvider() {
|
||||||
|
AIProvider.provideAction('chat', options => {
|
||||||
|
assertExists(options.stream);
|
||||||
|
return textToTextStream({
|
||||||
|
docId: options.docId,
|
||||||
|
workspaceId: options.workspaceId,
|
||||||
|
prompt: options.input,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AIProvider.provideAction('summary', options => {
|
||||||
|
assertExists(options.stream);
|
||||||
|
const prompt = `
|
||||||
|
Summarize the key points from the following content in a clear and concise manner,
|
||||||
|
suitable for a reader who is seeking a quick understanding of the original content.
|
||||||
|
Ensure to capture the main ideas and any significant details without unnecessary elaboration:
|
||||||
|
|
||||||
|
${options.input}
|
||||||
|
`;
|
||||||
|
return textToTextStream({
|
||||||
|
docId: options.docId,
|
||||||
|
workspaceId: options.workspaceId,
|
||||||
|
prompt,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AIProvider.provideAction('translate', options => {
|
||||||
|
assertExists(options.stream);
|
||||||
|
const prompt = `Translate the following content to ${options.lang}: ${options.input}`;
|
||||||
|
return textToTextStream({
|
||||||
|
docId: options.docId,
|
||||||
|
workspaceId: options.workspaceId,
|
||||||
|
prompt,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AIProvider.provideAction('changeTone', options => {
|
||||||
|
assertExists(options.stream);
|
||||||
|
const prompt = `Change the tone of the following content to ${options.tone}: ${options.input}`;
|
||||||
|
return textToTextStream({
|
||||||
|
docId: options.docId,
|
||||||
|
workspaceId: options.workspaceId,
|
||||||
|
prompt,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AIProvider.provideAction('improveWriting', options => {
|
||||||
|
assertExists(options.stream);
|
||||||
|
const prompt = `Improve the writing of the following content: ${options.input}`;
|
||||||
|
return textToTextStream({
|
||||||
|
docId: options.docId,
|
||||||
|
workspaceId: options.workspaceId,
|
||||||
|
prompt,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AIProvider.provideAction('improveGrammar', options => {
|
||||||
|
assertExists(options.stream);
|
||||||
|
const prompt = `Improve the grammar of the following content: ${options.input}`;
|
||||||
|
return textToTextStream({
|
||||||
|
docId: options.docId,
|
||||||
|
workspaceId: options.workspaceId,
|
||||||
|
prompt,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AIProvider.provideAction('fixSpelling', options => {
|
||||||
|
assertExists(options.stream);
|
||||||
|
const prompt = `Fix the spelling of the following content: ${options.input}`;
|
||||||
|
return textToTextStream({
|
||||||
|
docId: options.docId,
|
||||||
|
workspaceId: options.workspaceId,
|
||||||
|
prompt,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AIProvider.provideAction('createHeadings', options => {
|
||||||
|
assertExists(options.stream);
|
||||||
|
const prompt = `Create headings for the following content: ${options.input}`;
|
||||||
|
return textToTextStream({
|
||||||
|
docId: options.docId,
|
||||||
|
workspaceId: options.workspaceId,
|
||||||
|
prompt,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AIProvider.provideAction('makeLonger', options => {
|
||||||
|
assertExists(options.stream);
|
||||||
|
const prompt = `Make the following content longer: ${options.input}`;
|
||||||
|
return textToTextStream({
|
||||||
|
docId: options.docId,
|
||||||
|
workspaceId: options.workspaceId,
|
||||||
|
prompt,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AIProvider.provideAction('makeShorter', options => {
|
||||||
|
assertExists(options.stream);
|
||||||
|
const prompt = `Make the following content shorter: ${options.input}`;
|
||||||
|
return textToTextStream({
|
||||||
|
docId: options.docId,
|
||||||
|
workspaceId: options.workspaceId,
|
||||||
|
prompt,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AIProvider.provideAction('checkCodeErrors', options => {
|
||||||
|
assertExists(options.stream);
|
||||||
|
const prompt = `Check the code errors in the following content: ${options.input}`;
|
||||||
|
return textToTextStream({
|
||||||
|
docId: options.docId,
|
||||||
|
workspaceId: options.workspaceId,
|
||||||
|
prompt,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { getBaseUrl } from '@affine/graphql';
|
||||||
|
import { CopilotClient, toTextStream } from '@blocksuite/presets';
|
||||||
|
|
||||||
|
const TIMEOUT = 5000;
|
||||||
|
|
||||||
|
export function textToTextStream({
|
||||||
|
docId,
|
||||||
|
workspaceId,
|
||||||
|
prompt,
|
||||||
|
}: {
|
||||||
|
docId: string;
|
||||||
|
workspaceId: string;
|
||||||
|
prompt: string;
|
||||||
|
}): BlockSuitePresets.TextStream {
|
||||||
|
const client = new CopilotClient(getBaseUrl());
|
||||||
|
return {
|
||||||
|
[Symbol.asyncIterator]: async function* () {
|
||||||
|
const session = await client.createSession({
|
||||||
|
workspaceId,
|
||||||
|
docId,
|
||||||
|
promptName: 'Summary', // placeholder
|
||||||
|
});
|
||||||
|
const eventSource = client.textToTextStream(prompt, session);
|
||||||
|
yield* toTextStream(eventSource, { timeout: TIMEOUT });
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { getAISpecs } from '@blocksuite/presets';
|
||||||
|
|
||||||
|
import { setupAIProvider } from './provider';
|
||||||
|
|
||||||
|
export function getParsedAISpecs() {
|
||||||
|
setupAIProvider();
|
||||||
|
return getAISpecs();
|
||||||
|
}
|
||||||
@@ -4,14 +4,19 @@ import type { ParagraphService, RootService } from '@blocksuite/blocks';
|
|||||||
import {
|
import {
|
||||||
AttachmentService,
|
AttachmentService,
|
||||||
CanvasTextFonts,
|
CanvasTextFonts,
|
||||||
EdgelessEditorBlockSpecs,
|
|
||||||
EdgelessRootService,
|
EdgelessRootService,
|
||||||
PageEditorBlockSpecs,
|
|
||||||
PageRootService,
|
PageRootService,
|
||||||
} from '@blocksuite/blocks';
|
} from '@blocksuite/blocks';
|
||||||
import bytes from 'bytes';
|
import bytes from 'bytes';
|
||||||
import type { TemplateResult } from 'lit';
|
import type { TemplateResult } from 'lit';
|
||||||
|
|
||||||
|
import { getParsedAISpecs } from './ai/spec';
|
||||||
|
|
||||||
|
const {
|
||||||
|
pageModeSpecs: PageEditorBlockSpecs,
|
||||||
|
edgelessModeSpecs: EdgelessEditorBlockSpecs,
|
||||||
|
} = getParsedAISpecs();
|
||||||
|
|
||||||
class CustomAttachmentService extends AttachmentService {
|
class CustomAttachmentService extends AttachmentService {
|
||||||
override mounted(): void {
|
override mounted(): void {
|
||||||
// blocksuite default max file size is 10MB, we override it to 2GB
|
// blocksuite default max file size is 10MB, we override it to 2GB
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { DebugLogger } from '@affine/debug';
|
import { DebugLogger } from '@affine/debug';
|
||||||
import { getBaseUrl } from '@affine/graphql';
|
import { getBaseUrl } from '@affine/graphql';
|
||||||
|
import { AIProvider } from '@blocksuite/presets';
|
||||||
import { useEffect, useMemo, useReducer } from 'react';
|
import { useEffect, useMemo, useReducer } from 'react';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
@@ -149,7 +150,12 @@ export function useCurrentUser(): CheckedUser {
|
|||||||
// maybe lift user state up to global state?
|
// maybe lift user state up to global state?
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (session.user) {
|
if (session.user) {
|
||||||
dispatcher({ type: 'update', payload: session.user });
|
const user = session.user;
|
||||||
|
dispatcher({ type: 'update', payload: user });
|
||||||
|
// todo: move this to a better place!
|
||||||
|
AIProvider.provideUserInfo(() => {
|
||||||
|
return user;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
dispatcher({ type: 'fetchError', payload: null });
|
dispatcher({ type: 'fetchError', payload: null });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { AffineEditorContainer } from '@blocksuite/presets';
|
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||||
|
|
||||||
export type SidebarTabName = 'outline' | 'frame' | 'copilot' | 'journal';
|
export type SidebarTabName = 'outline' | 'frame' | 'chat' | 'journal';
|
||||||
|
|
||||||
export interface SidebarTabProps {
|
export interface SidebarTabProps {
|
||||||
editor: AffineEditorContainer | null;
|
editor: AffineEditorContainer | null;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { SidebarTab } from './sidebar-tab';
|
import type { SidebarTab } from './sidebar-tab';
|
||||||
import { copilotTab } from './tabs/copilot';
|
import { chatTab } from './tabs/chat';
|
||||||
import { framePanelTab } from './tabs/frame';
|
import { framePanelTab } from './tabs/frame';
|
||||||
import { journalTab } from './tabs/journal';
|
import { journalTab } from './tabs/journal';
|
||||||
import { outlineTab } from './tabs/outline';
|
import { outlineTab } from './tabs/outline';
|
||||||
@@ -7,8 +7,8 @@ import { outlineTab } from './tabs/outline';
|
|||||||
// the list of all possible tabs in affine.
|
// the list of all possible tabs in affine.
|
||||||
// order matters (determines the order of the tabs)
|
// order matters (determines the order of the tabs)
|
||||||
export const sidebarTabs: SidebarTab[] = [
|
export const sidebarTabs: SidebarTab[] = [
|
||||||
|
chatTab,
|
||||||
journalTab,
|
journalTab,
|
||||||
outlineTab,
|
outlineTab,
|
||||||
framePanelTab,
|
framePanelTab,
|
||||||
copilotTab,
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
|
import { AiIcon } from '@blocksuite/icons';
|
||||||
|
import { ChatPanel } from '@blocksuite/presets';
|
||||||
|
import { useCallback, useRef } from 'react';
|
||||||
|
|
||||||
|
import type { SidebarTab, SidebarTabProps } from '../sidebar-tab';
|
||||||
|
import * as styles from './chat.css';
|
||||||
|
|
||||||
|
// A wrapper for CopilotPanel
|
||||||
|
const EditorChatPanel = ({ editor }: SidebarTabProps) => {
|
||||||
|
const chatPanelRef = useRef<ChatPanel | null>(null);
|
||||||
|
|
||||||
|
const onRefChange = useCallback((container: HTMLDivElement | null) => {
|
||||||
|
if (container) {
|
||||||
|
assertExists(chatPanelRef.current, 'chat panel should be initialized');
|
||||||
|
container.append(chatPanelRef.current);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (!editor) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!chatPanelRef.current) {
|
||||||
|
chatPanelRef.current = new ChatPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (editor !== chatPanelRef.current?.editor) {
|
||||||
|
(chatPanelRef.current as ChatPanel).editor = editor;
|
||||||
|
// (copilotPanelRef.current as CopilotPanel).fitPadding = [20, 20, 20, 20];
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div className={styles.root} ref={onRefChange} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const chatTab: SidebarTab = {
|
||||||
|
name: 'chat',
|
||||||
|
icon: <AiIcon />,
|
||||||
|
Component: EditorChatPanel,
|
||||||
|
};
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
import { assertExists } from '@blocksuite/global/utils';
|
|
||||||
import { AiIcon } from '@blocksuite/icons';
|
|
||||||
import { CopilotPanel } from '@blocksuite/presets';
|
|
||||||
import { useCallback, useRef } from 'react';
|
|
||||||
|
|
||||||
import type { SidebarTab, SidebarTabProps } from '../sidebar-tab';
|
|
||||||
import * as styles from './outline.css';
|
|
||||||
|
|
||||||
// A wrapper for CopilotPanel
|
|
||||||
const EditorCopilotPanel = ({ editor }: SidebarTabProps) => {
|
|
||||||
const copilotPanelRef = useRef<CopilotPanel | null>(null);
|
|
||||||
|
|
||||||
const onRefChange = useCallback((container: HTMLDivElement | null) => {
|
|
||||||
if (container) {
|
|
||||||
assertExists(
|
|
||||||
copilotPanelRef.current,
|
|
||||||
'copilot panel should be initialized'
|
|
||||||
);
|
|
||||||
container.append(copilotPanelRef.current);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (!editor) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!copilotPanelRef.current) {
|
|
||||||
copilotPanelRef.current = new CopilotPanel();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (editor !== copilotPanelRef.current?.editor) {
|
|
||||||
(copilotPanelRef.current as CopilotPanel).editor = editor;
|
|
||||||
// (copilotPanelRef.current as CopilotPanel).fitPadding = [20, 20, 20, 20];
|
|
||||||
}
|
|
||||||
|
|
||||||
return <div className={styles.root} ref={onRefChange} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const copilotTab: SidebarTab = {
|
|
||||||
name: 'copilot',
|
|
||||||
icon: <AiIcon />,
|
|
||||||
Component: EditorCopilotPanel,
|
|
||||||
};
|
|
||||||
@@ -33,7 +33,7 @@ export const MultiTabSidebarHeaderSwitcher = ({
|
|||||||
const exts = useMemo(
|
const exts = useMemo(
|
||||||
() =>
|
() =>
|
||||||
tabs.filter(ext => {
|
tabs.filter(ext => {
|
||||||
if (ext.name === 'copilot' && !copilotEnabled) return false;
|
if (ext.name === 'chat' && !copilotEnabled) return false;
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
[copilotEnabled, tabs]
|
[copilotEnabled, tabs]
|
||||||
|
|||||||
@@ -28,10 +28,10 @@
|
|||||||
"@affine/env": "workspace:*",
|
"@affine/env": "workspace:*",
|
||||||
"@affine/i18n": "workspace:*",
|
"@affine/i18n": "workspace:*",
|
||||||
"@affine/native": "workspace:*",
|
"@affine/native": "workspace:*",
|
||||||
"@blocksuite/block-std": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/block-std": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/blocks": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/blocks": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/presets": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/presets": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/store": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/store": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@electron-forge/cli": "^7.3.0",
|
"@electron-forge/cli": "^7.3.0",
|
||||||
"@electron-forge/core": "^7.3.0",
|
"@electron-forge/core": "^7.3.0",
|
||||||
"@electron-forge/core-utils": "^7.3.0",
|
"@electron-forge/core-utils": "^7.3.0",
|
||||||
|
|||||||
@@ -23,13 +23,13 @@
|
|||||||
"storybook-addon-react-router-v6": "^2.0.10"
|
"storybook-addon-react-router-v6": "^2.0.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@blocksuite/block-std": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/block-std": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/blocks": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/blocks": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/global": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/global": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/icons": "2.1.46",
|
"@blocksuite/icons": "2.1.46",
|
||||||
"@blocksuite/inline": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/inline": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/presets": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/presets": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@blocksuite/store": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/store": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@storybook/addon-actions": "^7.6.17",
|
"@storybook/addon-actions": "^7.6.17",
|
||||||
"@storybook/addon-essentials": "^7.6.17",
|
"@storybook/addon-essentials": "^7.6.17",
|
||||||
"@storybook/addon-interactions": "^7.6.17",
|
"@storybook/addon-interactions": "^7.6.17",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"@affine/env": "workspace:*",
|
"@affine/env": "workspace:*",
|
||||||
"@affine/templates": "workspace:*",
|
"@affine/templates": "workspace:*",
|
||||||
"@aws-sdk/client-s3": "3.537.0",
|
"@aws-sdk/client-s3": "3.537.0",
|
||||||
"@blocksuite/presets": "0.14.0-canary-202403250855-4171ecd",
|
"@blocksuite/presets": "0.14.0-canary-202404090831-25c5310",
|
||||||
"@clack/core": "^0.3.4",
|
"@clack/core": "^0.3.4",
|
||||||
"@clack/prompts": "^0.7.0",
|
"@clack/prompts": "^0.7.0",
|
||||||
"@magic-works/i18n-codegen": "^0.5.0",
|
"@magic-works/i18n-codegen": "^0.5.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user