Skip to content

Commit

Permalink
chore: bump blocksuite (#8230)
Browse files Browse the repository at this point in the history
## 0.17.11

### Patch Changes

- [3c61be5](toeverything/blocksuite@3c61be5): - Refactor drag handle widget
  - Split embed blocks to `@blocksuite/affine-block-embed`
  - Fix latex selected state in edgeless mode
  - Fix unclear naming
  - Fix prototype pollution
  - Fix portal interaction in affine modal
  - Fix paste linked block on edgeless
  - Add scroll anchoring widget
  - Add highlight selection
  • Loading branch information
fundon committed Sep 18, 2024
1 parent b73d3b3 commit f397815
Show file tree
Hide file tree
Showing 21 changed files with 428 additions and 304 deletions.
4 changes: 2 additions & 2 deletions packages/common/env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"private": true,
"type": "module",
"devDependencies": {
"@blocksuite/global": "0.17.10",
"@blocksuite/store": "0.17.10",
"@blocksuite/global": "0.17.11",
"@blocksuite/store": "0.17.11",
"vitest": "2.1.0"
},
"exports": {
Expand Down
10 changes: 5 additions & 5 deletions packages/common/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"@affine/debug": "workspace:*",
"@affine/env": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/blocks": "0.17.10",
"@blocksuite/global": "0.17.10",
"@blocksuite/presets": "0.17.10",
"@blocksuite/store": "0.17.10",
"@blocksuite/blocks": "0.17.11",
"@blocksuite/global": "0.17.11",
"@blocksuite/presets": "0.17.11",
"@blocksuite/store": "0.17.11",
"@datastructures-js/binary-search-tree": "^5.3.2",
"foxact": "^0.2.33",
"fuse.js": "^7.0.0",
Expand All @@ -34,7 +34,7 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/presets": "0.17.10",
"@blocksuite/presets": "0.17.11",
"@testing-library/react": "^16.0.0",
"fake-indexeddb": "^6.0.0",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/apps/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@affine/core": "workspace:*",
"@affine/i18n": "workspace:*",
"@affine/native": "workspace:*",
"@blocksuite/global": "0.17.10",
"@blocksuite/global": "0.17.11",
"@electron-forge/cli": "^7.3.0",
"@electron-forge/core": "^7.3.0",
"@electron-forge/core-utils": "^7.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@affine/component": "workspace:*",
"@affine/core": "workspace:*",
"@affine/i18n": "workspace:*",
"@blocksuite/blocks": "0.17.10",
"@blocksuite/blocks": "0.17.11",
"@blocksuite/icons": "^2.1.67",
"@sentry/react": "^8.0.0",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@blocksuite/global": "0.17.10",
"@blocksuite/global": "0.17.11",
"@blocksuite/icons": "2.1.67",
"@chromatic-com/storybook": "^2.0.0",
"@storybook/addon-essentials": "^8.2.9",
Expand Down
12 changes: 6 additions & 6 deletions packages/frontend/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"@affine/i18n": "workspace:*",
"@affine/templates": "workspace:*",
"@affine/track": "workspace:*",
"@blocksuite/block-std": "0.17.10",
"@blocksuite/blocks": "0.17.10",
"@blocksuite/global": "0.17.10",
"@blocksuite/block-std": "0.17.11",
"@blocksuite/blocks": "0.17.11",
"@blocksuite/global": "0.17.11",
"@blocksuite/icons": "2.1.67",
"@blocksuite/inline": "0.17.10",
"@blocksuite/presets": "0.17.10",
"@blocksuite/store": "0.17.10",
"@blocksuite/inline": "0.17.11",
"@blocksuite/presets": "0.17.11",
"@blocksuite/store": "0.17.11",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "^8.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,17 @@ import type {
DocMode,
DocModeProvider,
QuickSearchResult,
ReferenceParams,
RootService,
} from '@blocksuite/blocks';
import {
AffineSlashMenuWidget,
DocModeExtension,
EdgelessRootBlockComponent,
EmbedLinkedDocBlockComponent,
EmbedOptionProvider,
NotificationExtension,
ParseDocUrlExtension,
PeekViewExtension,
QuickSearchExtension,
QuickSearchProvider,
ReferenceNodeConfigExtension,
} from '@blocksuite/blocks';
import { AIChatBlockSchema } from '@blocksuite/presets';
Expand All @@ -62,6 +59,7 @@ import {
import { type TemplateResult } from 'lit';
import { customElement } from 'lit/decorators.js';
import { literal } from 'lit/static-html.js';
import { pick } from 'lodash-es';

export type ReferenceReactRenderer = (
reference: AffineReference
Expand Down Expand Up @@ -318,14 +316,13 @@ export function patchQuickSearchService(framework: FrameworkProvider) {
}

if (result.source === 'link') {
const { docId, blockIds, elementIds, mode } = result.payload;
resolve({
docId,
params: {
blockIds,
elementIds,
mode,
},
docId: result.payload.docId,
params: pick(result.payload, [
'mode',
'blockIds',
'elementIds',
]),
});
return;
}
Expand All @@ -349,13 +346,8 @@ export function patchQuickSearchService(framework: FrameworkProvider) {
primaryMode: mode,
docProps,
});
track.doc.editor.quickSearch.createDoc({
mode,
});

resolve({
docId: newDoc.id,
});
resolve({ docId: newDoc.id });
return;
}
},
Expand All @@ -373,6 +365,7 @@ export function patchQuickSearchService(framework: FrameworkProvider) {
return searchResult;
},
});

const SlashMenuQuickSearchExtension = patchSpecService<RootService>(
'affine:page',
() => {},
Expand All @@ -383,51 +376,38 @@ export function patchQuickSearchService(framework: FrameworkProvider) {
'action' in item &&
(item.name === 'Linked Doc' || item.name === 'Link')
) {
const oldAction = item.action;
item.action = async ({ model, rootComponent }) => {
const { host, std } = rootComponent;
const quickSearchService =
component.std.getOptional(QuickSearchProvider);

if (!quickSearchService)
return oldAction({ model, rootComponent });

const result = await quickSearchService.openQuickSearch();
if (result === null) return;

if ('docId' in result) {
const linkedDoc = std.collection.getDoc(result.docId);
if (!linkedDoc) return;

const props: {
flavour: string;
pageId: string;
params?: ReferenceParams;
} = {
flavour: 'affine:embed-linked-doc',
pageId: linkedDoc.id,
};

if (result.params) {
props.params = result.params;
}

host.doc.addSiblingBlocks(model, [props]);

track.doc.editor.slashMenu.linkDoc({ control: 'linkDoc' });
} else if (result.externalUrl) {
const embedOptions = std
.get(EmbedOptionProvider)
.getEmbedBlockOptions(result.externalUrl);
if (!embedOptions) return;

host.doc.addSiblingBlocks(model, [
{
flavour: embedOptions.flavour,
url: result.externalUrl,
},
]);
}
item.action = async ({ rootComponent }) => {
// TODO(@Mirone): fix the type
// @ts-expect-error fixme
const { success, insertedLinkType } =
// @ts-expect-error fixme
rootComponent.std.command.exec('insertLinkByQuickSearch');

if (!success) return;

// TODO(@Mirone): fix the type
insertedLinkType
?.then(
(type: {
flavour?: 'affine:embed-linked-doc' | 'affine:bookmark';
}) => {
const flavour = type?.flavour;
if (!flavour) return;

if (flavour === 'affine:embed-linked-doc') {
track.doc.editor.slashMenu.linkDoc({
control: 'linkDoc',
});
return;
}

if (flavour === 'affine:bookmark') {
track.doc.editor.slashMenu.bookmark();
return;
}
}
)
.catch(console.error);
};
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import {
WorkspaceService,
} from '@toeverything/infra';

export function createLinkedWidgetConfig(framework: FrameworkProvider) {
// TODO: fix the type
export function createLinkedWidgetConfig(
framework: FrameworkProvider
): Partial<Record<string, unknown>> {
return {
getMenus: (
query: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { notify } from '@affine/component';
import { getAffineCloudBaseUrl } from '@affine/core/modules/cloud/services/fetch';
import { toURLSearchParams } from '@affine/core/utils';
import { useI18n } from '@affine/i18n';
import { track } from '@affine/track';
import { type EditorHost } from '@blocksuite/block-std';
Expand Down Expand Up @@ -34,20 +35,14 @@ export const generateUrl = ({
if (!baseUrl) return null;

try {
const url = new URL(`${baseUrl}/workspace/${workspaceId}/${pageId}`);
const search = url.searchParams;
if (shareMode) {
search.append('mode', shareMode);
}
if (blockIds && blockIds.length > 0) {
search.append('blockIds', blockIds.join(','));
}
if (elementIds && elementIds.length > 0) {
search.append('elementIds', elementIds.join(','));
}
if (xywh) {
search.append('xywh', xywh);
}
const url = new URL(`/workspace/${workspaceId}/${pageId}`, baseUrl);
const search = toURLSearchParams({
mode: shareMode,
blockIds,
elementIds,
xywh,
});
if (search) url.search = search.toString();
return url.toString();
} catch {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useAutoFocus } from '@affine/component';
import { getSvgPath } from '@blocksuite/global/utils';
import { getFigmaSquircleSvgPath } from '@blocksuite/global/utils';
import { SearchIcon } from '@blocksuite/icons/rc';
import clsx from 'clsx';
import { debounce } from 'lodash-es';
Expand Down Expand Up @@ -49,7 +49,13 @@ export const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(
const [inputValue, setInputValue] = useState(value);

const clipPath = useMemo(
() => getSvgPath({ width, height, cornerRadius, cornerSmoothing }),
() =>
getFigmaSquircleSvgPath({
width,
height,
cornerRadius,
cornerSmoothing,
}),
[cornerRadius, cornerSmoothing, height, width]
);

Expand Down
28 changes: 11 additions & 17 deletions packages/frontend/core/src/modules/editor/entities/editor.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import type { DocMode, EdgelessRootService } from '@blocksuite/blocks';
import type {
DocMode,
EdgelessRootService,
ReferenceParams,
} from '@blocksuite/blocks';
import type { InlineEditor } from '@blocksuite/inline';
import type { AffineEditorContainer, DocTitle } from '@blocksuite/presets';
import type { DocService, WorkspaceService } from '@toeverything/infra';
import { Entity, LiveData } from '@toeverything/infra';
import { isEqual } from 'lodash-es';

import { paramsParseOptions, preprocessParams } from '../../navigation/utils';
import type { WorkbenchView } from '../../workbench';
import { EditorScope } from '../scopes/editor';
import type { EditorSelector } from '../types';
Expand Down Expand Up @@ -58,22 +63,11 @@ export class Editor extends Entity {
*/
bindWorkbenchView(view: WorkbenchView) {
// eslint-disable-next-line rxjs/finnish
const viewParams$ = view.queryString$<{
mode?: DocMode;
blockIds?: string[];
elementIds?: string[];
refreshKey?: string;
}>({
// Cannot handle single id situation correctly: `blockIds=xxx`
arrayFormat: 'none',
types: {
mode: value =>
value === 'page' || value === 'edgeless' ? value : undefined,
blockIds: value => (value.length ? value.split(',') : []),
elementIds: value => (value.length ? value.split(',') : []),
refreshKey: 'string',
},
});
const viewParams$ = view
.queryString$<
ReferenceParams & { refreshKey?: string }
>(paramsParseOptions)
.map(preprocessParams);

const stablePrimaryMode = this.doc.getPrimaryMode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
EdgelessRootService,
PageRootService,
} from '@blocksuite/blocks';
import { ZOOM_MAX } from '@blocksuite/blocks';
import { Bound, deserializeXYWH } from '@blocksuite/global/utils';

function scrollAnchoringInEdgelessMode(
Expand Down Expand Up @@ -47,8 +46,7 @@ function scrollAnchoringInEdgelessMode(

const { zoom, centerX, centerY } = service.getFitToScreenData(
[20, 20, 100, 20],
[bounds],
ZOOM_MAX
[bounds]
);

service.viewport.setCenter(centerX, centerY);
Expand Down
Loading

0 comments on commit f397815

Please sign in to comment.