refactor(editor): reorg code structure of store package (#9525)
This commit is contained in:
@@ -3,14 +3,15 @@ import { describe, expect, test, vi } from 'vitest';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
import {
|
||||
Block,
|
||||
defineBlockSchema,
|
||||
internalPrimitives,
|
||||
Schema,
|
||||
type SchemaToModel,
|
||||
} from '../schema/index.js';
|
||||
import { Block, type YBlock } from '../store/doc/block/index.js';
|
||||
} from '../model/block/index.js';
|
||||
import type { YBlock } from '../model/block/types.js';
|
||||
import { Schema } from '../schema/index.js';
|
||||
import { createAutoIncrementIdGenerator } from '../test/index.js';
|
||||
import { TestWorkspace } from '../test/test-workspace.js';
|
||||
import { createAutoIncrementIdGenerator } from '../utils/id-generator.js';
|
||||
|
||||
const pageSchema = defineBlockSchema({
|
||||
flavour: 'page',
|
||||
|
||||
@@ -4,13 +4,11 @@ import type { Slot } from '@blocksuite/global/utils';
|
||||
import { assert, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { applyUpdate, type Doc, encodeStateAsUpdate } from 'yjs';
|
||||
|
||||
import { COLLECTION_VERSION, PAGE_VERSION } from '../consts.js';
|
||||
import type { BlockModel, Blocks, BlockSchemaType } from '../index.js';
|
||||
import type { BlockModel, Blocks, BlockSchemaType, DocMeta } from '../index.js';
|
||||
import { Schema } from '../index.js';
|
||||
import { Text } from '../reactive/text.js';
|
||||
import type { DocMeta } from '../store/workspace.js';
|
||||
import { createAutoIncrementIdGenerator } from '../test/index.js';
|
||||
import { TestWorkspace } from '../test/test-workspace.js';
|
||||
import { createAutoIncrementIdGenerator } from '../utils/id-generator.js';
|
||||
import {
|
||||
NoteBlockSchema,
|
||||
ParagraphBlockSchema,
|
||||
@@ -115,8 +113,8 @@ describe('basic', () => {
|
||||
tags: [],
|
||||
},
|
||||
],
|
||||
workspaceVersion: COLLECTION_VERSION,
|
||||
pageVersion: PAGE_VERSION,
|
||||
workspaceVersion: 2,
|
||||
pageVersion: 2,
|
||||
blockVersions: {
|
||||
'affine:note': 1,
|
||||
'affine:page': 2,
|
||||
|
||||
@@ -2,9 +2,8 @@ import { expect, test, vi } from 'vitest';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
import { Schema } from '../schema/index.js';
|
||||
import { BlockViewType } from '../store/index.js';
|
||||
import { createAutoIncrementIdGenerator } from '../test/index.js';
|
||||
import { TestWorkspace } from '../test/test-workspace.js';
|
||||
import { createAutoIncrementIdGenerator } from '../utils/id-generator.js';
|
||||
import {
|
||||
DividerBlockSchema,
|
||||
ListBlockSchema,
|
||||
@@ -220,7 +219,7 @@ test('query', () => {
|
||||
match: [
|
||||
{
|
||||
flavour: 'affine:list',
|
||||
viewType: BlockViewType.Hidden,
|
||||
viewType: 'hidden',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -233,14 +232,14 @@ test('query', () => {
|
||||
const paragraph1 = doc1.addBlock('affine:paragraph', {}, note);
|
||||
const list1 = doc1.addBlock('affine:list' as never, {}, note);
|
||||
|
||||
expect(doc2?.getBlock(paragraph1)?.blockViewType).toBe(BlockViewType.Display);
|
||||
expect(doc2?.getBlock(list1)?.blockViewType).toBe(BlockViewType.Display);
|
||||
expect(doc3?.getBlock(list1)?.blockViewType).toBe(BlockViewType.Hidden);
|
||||
expect(doc2?.getBlock(paragraph1)?.blockViewType).toBe('display');
|
||||
expect(doc2?.getBlock(list1)?.blockViewType).toBe('display');
|
||||
expect(doc3?.getBlock(list1)?.blockViewType).toBe('hidden');
|
||||
|
||||
const list2 = doc1.addBlock('affine:list' as never, {}, note);
|
||||
|
||||
expect(doc2?.getBlock(list2)?.blockViewType).toBe(BlockViewType.Display);
|
||||
expect(doc3?.getBlock(list2)?.blockViewType).toBe(BlockViewType.Hidden);
|
||||
expect(doc2?.getBlock(list2)?.blockViewType).toBe('display');
|
||||
expect(doc3?.getBlock(list2)?.blockViewType).toBe('hidden');
|
||||
});
|
||||
|
||||
test('local readonly', () => {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { literal } from 'lit/static-html.js';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import type { BlockModel } from '../model/block/block-model.js';
|
||||
import { defineBlockSchema } from '../model/block/zod.js';
|
||||
// import some blocks
|
||||
import { type BlockModel, defineBlockSchema } from '../schema/base.js';
|
||||
import { SchemaValidateError } from '../schema/error.js';
|
||||
import { Schema } from '../schema/index.js';
|
||||
import { createAutoIncrementIdGenerator } from '../test/index.js';
|
||||
import { TestWorkspace } from '../test/test-workspace.js';
|
||||
import { createAutoIncrementIdGenerator } from '../utils/id-generator.js';
|
||||
import {
|
||||
DividerBlockSchema,
|
||||
ListBlockSchema,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { defineBlockSchema, type SchemaToModel } from '../schema/index.js';
|
||||
import { defineBlockSchema, type SchemaToModel } from '../model/index.js';
|
||||
|
||||
export const RootBlockSchema = defineBlockSchema({
|
||||
flavour: 'affine:page',
|
||||
|
||||
@@ -2,16 +2,13 @@ import { expect, test } from 'vitest';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
import { MemoryBlobCRUD } from '../adapter/index.js';
|
||||
import type { BlockModel } from '../model/block/block-model.js';
|
||||
import { defineBlockSchema, type SchemaToModel } from '../model/block/zod.js';
|
||||
import { Text } from '../reactive/index.js';
|
||||
import {
|
||||
type BlockModel,
|
||||
defineBlockSchema,
|
||||
Schema,
|
||||
type SchemaToModel,
|
||||
} from '../schema/index.js';
|
||||
import { Schema } from '../schema/index.js';
|
||||
import { createAutoIncrementIdGenerator } from '../test/index.js';
|
||||
import { TestWorkspace } from '../test/test-workspace.js';
|
||||
import { AssetsManager, BaseBlockTransformer } from '../transformer/index.js';
|
||||
import { createAutoIncrementIdGenerator } from '../utils/id-generator.js';
|
||||
|
||||
const docSchema = defineBlockSchema({
|
||||
flavour: 'page',
|
||||
|
||||
Reference in New Issue
Block a user