chore: bump blocksuite (#5138)

This commit is contained in:
Flrande
2023-12-04 12:02:35 +00:00
parent 7878ce5c2c
commit a2784c352f
26 changed files with 460 additions and 393 deletions
+2 -2
View File
@@ -3,8 +3,8 @@
"private": true,
"type": "module",
"devDependencies": {
"@blocksuite/global": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/store": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"react": "18.2.0",
"react-dom": "18.2.0",
"vitest": "0.34.6",
+3 -6
View File
@@ -6,12 +6,9 @@ import { isDesktop, isServer } from './constant.js';
import { UaHelper } from './ua-helper.js';
export const blockSuiteFeatureFlags = z.object({
enable_set_remote_flag: z.boolean(),
enable_block_hub: z.boolean(),
enable_toggle_block: z.boolean(),
enable_bookmark_operation: z.boolean(),
enable_note_index: z.boolean(),
enable_transformer_clipboard: z.boolean(),
enable_expand_database_block: z.boolean(),
enable_bultin_ledits: z.boolean(),
});
export const runtimeFlagsSchema = z.object({
+5 -5
View File
@@ -55,9 +55,9 @@
},
"dependencies": {
"@affine/sdk": "workspace:*",
"@blocksuite/blocks": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/global": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/store": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"jotai": "^2.5.1",
"jotai-effect": "^0.2.3",
"tinykeys": "^2.1.0",
@@ -66,8 +66,8 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/editor": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/lit": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/editor": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/lit": "0.0.0-20231130092516-0f858b95-nightly",
"@testing-library/react": "^14.0.0",
"async-call-rpc": "^6.3.1",
"electron": "link:../../frontend/electron/node_modules/electron",
+5 -5
View File
@@ -22,11 +22,11 @@
"dist"
],
"dependencies": {
"@blocksuite/block-std": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/blocks": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/editor": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/global": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/store": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/block-std": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/editor": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"jotai": "^2.5.1",
"zod": "^3.22.4"
},
+2 -2
View File
@@ -37,8 +37,8 @@
"y-provider": "workspace:*"
},
"devDependencies": {
"@blocksuite/blocks": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/store": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"fake-indexeddb": "^5.0.0",
"vite": "^4.4.11",
"vite-plugin-dts": "3.6.0",
@@ -65,7 +65,7 @@ beforeEach(() => {
id = nanoid();
workspace = new Workspace({
id,
isSSR: true,
schema,
});
vi.useFakeTimers({ toFake: ['requestIdleCallback'] });
@@ -383,7 +383,7 @@ describe('subDoc', () => {
{
const newWorkspace = new Workspace({
id,
isSSR: true,
schema,
});
const provider = createIndexedDBProvider(newWorkspace.doc, rootDBName);
@@ -423,7 +423,7 @@ describe('utils', () => {
expect(update).toBeInstanceOf(Uint8Array);
const newWorkspace = new Workspace({
id,
isSSR: true,
schema,
});
applyUpdate(newWorkspace.doc, update);
+1 -1
View File
@@ -24,7 +24,7 @@
"build": "vite build"
},
"devDependencies": {
"@blocksuite/store": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"vite": "^4.4.11",
"vite-plugin-dts": "3.6.0",
"vitest": "0.34.6",
+5 -5
View File
@@ -71,12 +71,12 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@blocksuite/blocks": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/editor": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/global": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/editor": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/icons": "2.1.36",
"@blocksuite/lit": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/store": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/lit": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"@storybook/addon-actions": "^7.5.3",
"@storybook/addon-essentials": "^7.5.3",
"@storybook/addon-interactions": "^7.5.3",
@@ -6,11 +6,9 @@ const require = createRequire(import.meta.url);
const packageJson = require('../package.json');
const editorFlags: BlockSuiteFeatureFlags = {
enable_block_hub: true,
enable_toggle_block: false,
enable_bookmark_operation: false,
enable_note_index: false,
enable_set_remote_flag: false,
enable_transformer_clipboard: false,
enable_expand_database_block: false,
enable_bultin_ledits: false,
};
export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
+7 -7
View File
@@ -25,14 +25,14 @@
"@affine/i18n": "workspace:*",
"@affine/templates": "workspace:*",
"@affine/workspace": "workspace:*",
"@blocksuite/block-std": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/blocks": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/editor": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/global": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/block-std": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/editor": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/icons": "2.1.36",
"@blocksuite/lit": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/store": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/virgo": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/lit": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/virgo": "0.0.0-20231130092516-0f858b95-nightly",
"@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^8.0.0",
"@emotion/cache": "^11.11.0",
@@ -1,169 +0,0 @@
import { Menu, MenuItem } from '@affine/component/ui/menu';
import type { SerializedBlock } from '@blocksuite/blocks';
import type { BaseBlockModel } from '@blocksuite/store';
import type { Page } from '@blocksuite/store';
import type { VEditor } from '@blocksuite/virgo';
import { useEffect, useState } from 'react';
import { createPortal } from 'react-dom';
type ShortcutMap = {
[key: string]: (e: KeyboardEvent, page: Page) => void;
};
const menuOptions = [
{
id: 'dismiss',
label: 'Dismiss',
},
{
id: 'bookmark',
label: 'Create bookmark',
},
];
function getCurrentNativeRange(selection = window.getSelection()) {
if (!selection) {
return null;
}
if (selection.rangeCount === 0) {
return null;
}
if (selection.rangeCount > 1) {
console.warn('getCurrentRange may be wrong, rangeCount > 1');
}
return selection.getRangeAt(0);
}
const handleEnter = ({
page,
selectedOption,
callback,
}: {
page: Page;
selectedOption: keyof ShortcutMap;
callback: () => void;
}) => {
if (selectedOption === 'dismiss') {
return callback();
}
const native = getCurrentNativeRange();
if (!native) {
return callback();
}
const container = native.startContainer;
const element =
container instanceof Element ? container : container?.parentElement;
const virgo = element?.closest<Element & { virgoEditor: VEditor }>(
'[data-virgo-root]'
)?.virgoEditor;
if (!virgo) {
return callback();
}
const linkInfo = virgo
?.getDeltasByVRange({
index: native.startOffset,
length: 0,
})
.find(delta => delta[0]?.attributes?.link);
if (!linkInfo) {
return;
}
const [, { index, length }] = linkInfo;
const link = linkInfo[0]?.attributes?.link as string;
const model = element?.closest<Element & { model: BaseBlockModel }>(
'[data-block-id]'
)?.model;
if (!model) {
return callback();
}
const parent = page.getParent(model);
if (!parent) {
return callback();
}
const currentBlockIndex = parent.children.indexOf(model);
page.addBlock(
'affine:bookmark',
{ url: link },
parent,
currentBlockIndex + 1
);
virgo?.deleteText({
index,
length,
});
if (model.isEmpty()) {
page.deleteBlock(model);
}
return callback();
};
const shouldShowBookmarkMenu = (pastedBlocks: Record<string, unknown>[]) => {
if (!pastedBlocks.length || pastedBlocks.length > 1) {
return;
}
const [firstBlock] = pastedBlocks as [SerializedBlock];
if (
!firstBlock.text ||
!firstBlock.text.length ||
firstBlock.text.length > 1
) {
return;
}
return !!firstBlock.text[0].attributes?.link;
};
export type BookmarkProps = {
page: Page;
};
export const Bookmark = ({ page }: BookmarkProps) => {
const [anchor, setAnchor] = useState<Range | null>(null);
useEffect(() => {
const disposer = page.slots.pasted.on(pastedBlocks => {
if (!shouldShowBookmarkMenu(pastedBlocks)) {
return;
}
window.setTimeout(() => {
setAnchor(getCurrentNativeRange());
}, 100);
});
return () => {
disposer.dispose();
};
}, [page]);
const portalContainer = anchor?.startContainer.parentElement;
return anchor && portalContainer
? createPortal(
<Menu
rootOptions={{
defaultOpen: true,
onOpenChange: (e: boolean) => !e && setAnchor(null),
}}
items={menuOptions.map(({ id, label }) => (
<MenuItem
key={id}
onClick={() =>
handleEnter({
page,
selectedOption: id,
callback: () => setAnchor(null),
})
}
>
{label}
</MenuItem>
))}
>
<span></span>
</Menu>,
portalContainer
)
: null;
};
@@ -36,7 +36,6 @@ import { fontStyleOptions } from '../atoms/settings';
import { useAppSettingHelper } from '../hooks/affine/use-app-setting-helper';
import { useBlockSuiteMetaHelper } from '../hooks/affine/use-block-suite-meta-helper';
import { BlockSuiteEditor as Editor } from './blocksuite/block-suite-editor';
import { Bookmark } from './bookmark';
import * as styles from './page-detail-editor.css';
import { editorContainer, pluginContainer } from './page-detail-editor.css';
import { TrashButtonGroup } from './pure/trash-button-group';
@@ -212,7 +211,6 @@ const EditorWrapper = memo(function EditorWrapper({
onLoadEditor={onLoadEditor}
/>
{meta.trash && <TrashButtonGroup />}
<Bookmark page={page} />
</>
);
});
+4 -4
View File
@@ -32,10 +32,10 @@
"@affine/sdk": "workspace:*",
"@affine/templates": "workspace:*",
"@affine/vue-hello-world-plugin": "workspace:*",
"@blocksuite/blocks": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/editor": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/lit": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/store": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/editor": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/lit": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"@electron-forge/cli": "^7.1.0",
"@electron-forge/core": "^7.1.0",
"@electron-forge/core-utils": "^7.1.0",
+6 -6
View File
@@ -19,12 +19,12 @@
"devDependencies": {
"@affine/debug": "workspace:*",
"@affine/env": "workspace:*",
"@blocksuite/block-std": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/blocks": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/editor": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/global": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/lit": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/store": "0.0.0-20231124123613-7c06e95d-nightly",
"@blocksuite/block-std": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/blocks": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/editor": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/global": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/lit": "0.0.0-20231130092516-0f858b95-nightly",
"@blocksuite/store": "0.0.0-20231130092516-0f858b95-nightly",
"@testing-library/react": "^14.0.0",
"@types/image-blob-reduce": "^4.1.3",
"@types/lodash.debounce": "^4.0.7",
@@ -60,7 +60,7 @@ export function useBlockSuitePagePreview(page: Page | null): Atom<string> {
page.slots.ready.on(() => {
set(getPagePreviewText(page));
}),
page.slots.yUpdated.on(() => {
page.slots.blockUpdated.on(() => {
set(getPagePreviewText(page));
}),
];
@@ -5,12 +5,9 @@ import { useBlockSuiteWorkspacePage } from './use-block-suite-workspace-page';
const weakMap = new WeakMap<Page, Atom<string[]>>();
function getPageReferences(page: Page): string[] {
// todo: is there a way to use page indexer to get all references?
return ['affine:paragraph', 'affine:list', 'affine:database']
.flatMap(f => page.getBlockByFlavour(f))
.flatMap(b => b.text?.toDelta())
.map(v => v?.attributes?.reference?.pageId)
.filter(Boolean);
return Object.values(
page.workspace.indexer.backlink.linkIndexMap[page.id] ?? {}
).flatMap(linkNodes => linkNodes.map(linkNode => linkNode.pageId));
}
const getPageReferencesAtom = (page: Page | null) => {
@@ -25,7 +22,7 @@ const getPageReferencesAtom = (page: Page | null) => {
page.slots.ready.on(() => {
set(getPageReferences(page));
}),
page.slots.yUpdated.on(() => {
page.workspace.indexer.backlink.slots.indexUpdated.on(() => {
set(getPageReferences(page));
}),
];
@@ -1,4 +1,3 @@
import { isBrowser } from '@affine/env/constant';
import type { BlockSuiteFeatureFlags } from '@affine/env/global';
import { WorkspaceFlavour } from '@affine/env/workspace';
import { createAffinePublicProviders } from '@affine/workspace/providers';
@@ -25,10 +24,6 @@ function setEditorFlags(workspace: Workspace) {
value
);
});
workspace.awarenessStore.setFlag(
'enable_bookmark_operation',
environment.isDesktop
);
}
type UpdateCallback = (
@@ -116,7 +111,6 @@ export function getOrCreateWorkspace(
const workspace = new Workspace({
id,
isSSR: !isBrowser,
providerCreators: typeof window === 'undefined' ? [] : providerCreators,
blobStorages: [
() => ({
@@ -25,7 +25,7 @@ describe('SyncEngine', () => {
{
const workspace = new Workspace({
id: 'test',
isSSR: true,
schema,
});
@@ -57,7 +57,7 @@ describe('SyncEngine', () => {
{
const workspace = new Workspace({
id: 'test',
isSSR: true,
schema,
});
const syncEngine = new SyncEngine(
@@ -76,7 +76,7 @@ describe('SyncEngine', () => {
{
const workspace = new Workspace({
id: 'test',
isSSR: true,
schema,
});
const syncEngine = new SyncEngine(
@@ -95,7 +95,7 @@ describe('SyncEngine', () => {
{
const workspace = new Workspace({
id: 'test',
isSSR: true,
schema,
});
const syncEngine = new SyncEngine(
@@ -21,7 +21,7 @@ describe('SyncPeer', () => {
{
const workspace = new Workspace({
id: 'test',
isSSR: true,
schema,
});
@@ -49,7 +49,7 @@ describe('SyncPeer', () => {
{
const workspace = new Workspace({
id: 'test',
isSSR: true,
schema,
});
const syncPeer = new SyncPeer(
@@ -67,7 +67,7 @@ describe('SyncPeer', () => {
test('status', async () => {
const workspace = new Workspace({
id: 'test - status',
isSSR: true,
schema,
});