Skip to content

chore: sync affine blocksuite to packages #9097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions packages/affine/all/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@blocksuite/affine-widget-edgeless-auto-connect": "workspace:*",
"@blocksuite/affine-widget-edgeless-toolbar": "workspace:*",
"@blocksuite/affine-widget-frame-title": "workspace:*",
"@blocksuite/affine-widget-linked-doc": "workspace:*",
"@blocksuite/affine-widget-remote-selection": "workspace:*",
"@blocksuite/affine-widget-scroll-anchoring": "workspace:*",
"@blocksuite/affine-widget-slash-menu": "workspace:*",
Expand Down Expand Up @@ -115,6 +116,7 @@
"./widgets/edgeless-auto-connect": "./src/widgets/edgeless-auto-connect.ts",
"./widgets/edgeless-toolbar": "./src/widgets/edgeless-toolbar.ts",
"./widgets/frame-title": "./src/widgets/frame-title.ts",
"./widgets/linked-doc": "./src/widgets/linked-doc.ts",
"./widgets/remote-selection": "./src/widgets/remote-selection.ts",
"./widgets/scroll-anchoring": "./src/widgets/scroll-anchoring.ts",
"./widgets/slash-menu": "./src/widgets/slash-menu.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3769,6 +3769,48 @@ bbb
});
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(blockSnapshot);
});

test('escapes dollar signs followed by a digit or space and digit', async () => {
const markdown =
'The price of the T-shirt is $9.15 and the price of the hat is $ 8\n';
const blockSnapshot: BlockSnapshot = {
type: 'block',
id: 'matchesReplaceMap[0]',
flavour: 'affine:note',
props: {
xywh: '[0,0,800,95]',
background: DefaultTheme.noteBackgrounColor,
index: 'a0',
hidden: false,
displayMode: NoteDisplayMode.DocAndEdgeless,
},
children: [
{
type: 'block',
id: 'matchesReplaceMap[1]',
flavour: 'affine:paragraph',
props: {
type: 'text',
text: {
'$blocksuite:internal:text$': true,
delta: [
{
insert:
'The price of the T-shirt is $9.15 and the price of the hat is $ 8',
},
],
},
},
children: [],
},
],
};
const mdAdapter = new MarkdownAdapter(createJob(), provider);
const rawBlockSnapshot = await mdAdapter.toBlockSnapshot({
file: markdown,
});
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(blockSnapshot);
});
});

test('reference', async () => {
Expand Down
68 changes: 39 additions & 29 deletions packages/affine/all/src/adapters/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,46 @@ import { defaultMarkdownPreprocessors } from './markdown/preprocessor';
import { defaultBlockNotionHtmlAdapterMatchers } from './notion-html/block-matcher';
import { defaultBlockPlainTextAdapterMatchers } from './plain-text/block-matcher';

export const AdapterFactoryExtensions: ExtensionType[] = [
AttachmentAdapterFactoryExtension,
ImageAdapterFactoryExtension,
MarkdownAdapterFactoryExtension,
PlainTextAdapterFactoryExtension,
HtmlAdapterFactoryExtension,
NotionTextAdapterFactoryExtension,
NotionHtmlAdapterFactoryExtension,
MixTextAdapterFactoryExtension,
];
export function getAdapterFactoryExtensions(): ExtensionType[] {
return [
AttachmentAdapterFactoryExtension,
ImageAdapterFactoryExtension,
MarkdownAdapterFactoryExtension,
PlainTextAdapterFactoryExtension,
HtmlAdapterFactoryExtension,
NotionTextAdapterFactoryExtension,
NotionHtmlAdapterFactoryExtension,
MixTextAdapterFactoryExtension,
];
}

export const HtmlAdapterExtension: ExtensionType[] = [
...HtmlInlineToDeltaAdapterExtensions,
...defaultBlockHtmlAdapterMatchers,
...InlineDeltaToHtmlAdapterExtensions,
];
export function getHtmlAdapterExtensions(): ExtensionType[] {
return [
...HtmlInlineToDeltaAdapterExtensions,
...defaultBlockHtmlAdapterMatchers,
...InlineDeltaToHtmlAdapterExtensions,
];
}

export const MarkdownAdapterExtension: ExtensionType[] = [
...MarkdownInlineToDeltaAdapterExtensions,
...defaultBlockMarkdownAdapterMatchers,
...InlineDeltaToMarkdownAdapterExtensions,
...defaultMarkdownPreprocessors,
];
export function getMarkdownAdapterExtensions(): ExtensionType[] {
return [
...MarkdownInlineToDeltaAdapterExtensions,
...defaultBlockMarkdownAdapterMatchers,
...InlineDeltaToMarkdownAdapterExtensions,
...defaultMarkdownPreprocessors,
];
}

export const NotionHtmlAdapterExtension: ExtensionType[] = [
...NotionHtmlInlineToDeltaAdapterExtensions,
...defaultBlockNotionHtmlAdapterMatchers,
];
export function getNotionHtmlAdapterExtensions(): ExtensionType[] {
return [
...NotionHtmlInlineToDeltaAdapterExtensions,
...defaultBlockNotionHtmlAdapterMatchers,
];
}

export const PlainTextAdapterExtension: ExtensionType[] = [
...defaultBlockPlainTextAdapterMatchers,
...InlineDeltaToPlainTextAdapterExtensions,
];
export function getPlainTextAdapterExtensions(): ExtensionType[] {
return [
...defaultBlockPlainTextAdapterMatchers,
...InlineDeltaToPlainTextAdapterExtensions,
];
}
20 changes: 10 additions & 10 deletions packages/affine/all/src/extensions/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ import {
import type { ExtensionType } from '@blocksuite/store';

import {
AdapterFactoryExtensions,
HtmlAdapterExtension,
MarkdownAdapterExtension,
NotionHtmlAdapterExtension,
PlainTextAdapterExtension,
getAdapterFactoryExtensions,
getHtmlAdapterExtensions,
getMarkdownAdapterExtensions,
getNotionHtmlAdapterExtensions,
getPlainTextAdapterExtensions,
} from '../adapters/extension.js';

export const StoreExtensions: ExtensionType[] = [
Expand Down Expand Up @@ -96,11 +96,11 @@ export const StoreExtensions: ExtensionType[] = [
DatabaseSelectionExtension,
TableSelectionExtension,

HtmlAdapterExtension,
MarkdownAdapterExtension,
NotionHtmlAdapterExtension,
PlainTextAdapterExtension,
AdapterFactoryExtensions,
getHtmlAdapterExtensions(),
getMarkdownAdapterExtensions(),
getNotionHtmlAdapterExtensions(),
getPlainTextAdapterExtensions(),
getAdapterFactoryExtensions(),

FeatureFlagService,
LinkPreviewerService,
Expand Down
1 change: 1 addition & 0 deletions packages/affine/all/src/widgets/linked-doc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/affine-widget-linked-doc';
61 changes: 31 additions & 30 deletions packages/affine/all/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
},
"include": ["./src"],
"references": [
{ "path": "../blocks/block-attachment" },
{ "path": "../blocks/block-bookmark" },
{ "path": "../blocks/block-callout" },
{ "path": "../blocks/block-code" },
{ "path": "../blocks/block-data-view" },
{ "path": "../blocks/block-database" },
{ "path": "../blocks/block-divider" },
{ "path": "../blocks/block-edgeless-text" },
{ "path": "../blocks/block-embed" },
{ "path": "../blocks/block-frame" },
{ "path": "../blocks/block-image" },
{ "path": "../blocks/block-latex" },
{ "path": "../blocks/block-list" },
{ "path": "../blocks/block-note" },
{ "path": "../blocks/block-paragraph" },
{ "path": "../blocks/block-root" },
{ "path": "../blocks/block-surface" },
{ "path": "../blocks/block-surface-ref" },
{ "path": "../blocks/block-table" },
{ "path": "../blocks/attachment" },
{ "path": "../blocks/bookmark" },
{ "path": "../blocks/callout" },
{ "path": "../blocks/code" },
{ "path": "../blocks/data-view" },
{ "path": "../blocks/database" },
{ "path": "../blocks/divider" },
{ "path": "../blocks/edgeless-text" },
{ "path": "../blocks/embed" },
{ "path": "../blocks/frame" },
{ "path": "../blocks/image" },
{ "path": "../blocks/latex" },
{ "path": "../blocks/list" },
{ "path": "../blocks/note" },
{ "path": "../blocks/paragraph" },
{ "path": "../blocks/root" },
{ "path": "../blocks/surface" },
{ "path": "../blocks/surface-ref" },
{ "path": "../blocks/table" },
{ "path": "../components" },
{ "path": "../fragments/fragment-doc-title" },
{ "path": "../fragments/fragment-frame-panel" },
{ "path": "../fragments/fragment-outline" },
{ "path": "../fragments/doc-title" },
{ "path": "../fragments/frame-panel" },
{ "path": "../fragments/outline" },
{ "path": "../gfx/brush" },
{ "path": "../gfx/connector" },
{ "path": "../gfx/group" },
Expand All @@ -48,14 +48,15 @@
{ "path": "../model" },
{ "path": "../rich-text" },
{ "path": "../shared" },
{ "path": "../widgets/widget-drag-handle" },
{ "path": "../widgets/widget-edgeless-auto-connect" },
{ "path": "../widgets/widget-edgeless-toolbar" },
{ "path": "../widgets/widget-frame-title" },
{ "path": "../widgets/widget-remote-selection" },
{ "path": "../widgets/widget-scroll-anchoring" },
{ "path": "../widgets/widget-slash-menu" },
{ "path": "../widgets/widget-toolbar" },
{ "path": "../widgets/drag-handle" },
{ "path": "../widgets/edgeless-auto-connect" },
{ "path": "../widgets/edgeless-toolbar" },
{ "path": "../widgets/frame-title" },
{ "path": "../widgets/linked-doc" },
{ "path": "../widgets/remote-selection" },
{ "path": "../widgets/scroll-anchoring" },
{ "path": "../widgets/slash-menu" },
{ "path": "../widgets/toolbar" },
{ "path": "../data-view" },
{ "path": "../../framework/global" },
{ "path": "../../framework/std" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
},
"include": ["./src"],
"references": [
{ "path": "../block-note" },
{ "path": "../block-surface" },
{ "path": "../embed" },
{ "path": "../surface" },
{ "path": "../../components" },
{ "path": "../../model" },
{ "path": "../../shared" },
{ "path": "../../widgets/widget-slash-menu" },
{ "path": "../../widgets/slash-menu" },
{ "path": "../../../framework/global" },
{ "path": "../../../framework/std" },
{ "path": "../../../framework/store" }
Expand Down
20 changes: 0 additions & 20 deletions packages/affine/blocks/block-frame/tsconfig.json

This file was deleted.

This file was deleted.

This file was deleted.

44 changes: 0 additions & 44 deletions packages/affine/blocks/block-root/src/types.ts

This file was deleted.

Loading