refactor(editor): remove blocks package (#10708)

This commit is contained in:
Saul-Mirone
2025-03-09 05:44:26 +00:00
parent 0766a2d9ae
commit 12bc142809
277 changed files with 904 additions and 1060 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,109 @@
import { DefaultTheme } from '@blocksuite/affine-model';
import { NotionTextAdapter } from '@blocksuite/affine-shared/adapters';
import type { SliceSnapshot } from '@blocksuite/store';
import { describe, expect, test } from 'vitest';
import { createJob } from '../utils/create-job.js';
import { getProvider } from '../utils/get-provider.js';
import { nanoidReplacement } from '../utils/nanoid-replacement.js';
getProvider();
describe('notion-text to snapshot', () => {
test('basic', () => {
const notionText =
'{"blockType":"text","editing":[["aaa ",[["_"],["b"],["i"]]],["nbbbb ",[["_"],["i"]]],["hjhj ",[["_"]]],["a",[["_"],["c"]]],[" ",[["_"]]],["ccc d",[["_"],["s"]]],["dd",[["_"],["s"]]]]}';
const sliceSnapshot: SliceSnapshot = {
type: 'slice',
content: [
{
type: 'block',
id: 'matchesReplaceMap[0]',
flavour: 'affine:note',
props: {
xywh: '[0,0,800,95]',
background: DefaultTheme.noteBackgrounColor,
index: 'a0',
hidden: false,
displayMode: 'both',
},
children: [
{
type: 'block',
id: 'matchesReplaceMap[1]',
flavour: 'affine:paragraph',
props: {
type: 'text',
text: {
'$blocksuite:internal:text$': true,
delta: [
{
insert: 'aaa ',
attributes: {
underline: true,
bold: true,
italic: true,
},
},
{
insert: 'nbbbb ',
attributes: {
underline: true,
italic: true,
},
},
{
insert: 'hjhj ',
attributes: {
underline: true,
},
},
{
insert: 'a',
attributes: {
underline: true,
code: true,
},
},
{
insert: ' ',
attributes: {
underline: true,
},
},
{
insert: 'ccc d',
attributes: {
underline: true,
strike: true,
},
},
{
insert: 'dd',
attributes: {
underline: true,
strike: true,
},
},
],
},
},
children: [],
},
],
},
],
workspaceId: '',
pageId: '',
};
const ntAdapter = new NotionTextAdapter(createJob());
const target = ntAdapter.toSliceSnapshot({
file: notionText,
workspaceId: '',
pageId: '',
});
expect(nanoidReplacement(target!)).toEqual(sliceSnapshot);
});
});
File diff suppressed because it is too large Load Diff