mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 16:19:43 +08:00
refactor(editor): rename doc to blocks (#9510)
This commit is contained in:
@@ -5,7 +5,7 @@ import type {
|
||||
GroupElementModel,
|
||||
NoteBlockModel,
|
||||
} from '@blocksuite/blocks';
|
||||
import { type BlockModel, type Doc } from '@blocksuite/store';
|
||||
import { type BlockModel, type Blocks } from '@blocksuite/store';
|
||||
import { beforeEach, describe, expect, test } from 'vitest';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
@@ -19,7 +19,7 @@ import { setupEditor } from '../utils/setup.js';
|
||||
|
||||
let service!: EdgelessRootBlockComponent['service'];
|
||||
|
||||
const addNote = (doc: Doc, props: Record<string, unknown> = {}) => {
|
||||
const addNote = (doc: Blocks, props: Record<string, unknown> = {}) => {
|
||||
return _addNote(doc, {
|
||||
index: service.layer.generateIndex(),
|
||||
...props,
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
import type {
|
||||
EdgelessRootBlockComponent,
|
||||
PageRootBlockComponent,
|
||||
SurfaceBlockComponent,
|
||||
} from '@blocksuite/blocks';
|
||||
import type { Doc } from '@blocksuite/store';
|
||||
import type { Blocks } from '@blocksuite/store';
|
||||
|
||||
import type { AffineEditorContainer } from '../../index.js';
|
||||
|
||||
export function getSurface(doc: Doc, editor: AffineEditorContainer) {
|
||||
export function getSurface(doc: Blocks, editor: AffineEditorContainer) {
|
||||
const surfaceModel = doc.getBlockByFlavour('affine:surface');
|
||||
|
||||
return editor.host!.view.getBlock(
|
||||
@@ -17,17 +16,17 @@ export function getSurface(doc: Doc, editor: AffineEditorContainer) {
|
||||
}
|
||||
|
||||
export function getDocRootBlock(
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
editor: AffineEditorContainer,
|
||||
mode: 'page'
|
||||
): PageRootBlockComponent;
|
||||
export function getDocRootBlock(
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
editor: AffineEditorContainer,
|
||||
mode: 'edgeless'
|
||||
): EdgelessRootBlockComponent;
|
||||
export function getDocRootBlock(
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
editor: AffineEditorContainer,
|
||||
_?: 'edgeless' | 'page'
|
||||
) {
|
||||
@@ -36,7 +35,7 @@ export function getDocRootBlock(
|
||||
| PageRootBlockComponent;
|
||||
}
|
||||
|
||||
export function addNote(doc: Doc, props: Record<string, any> = {}) {
|
||||
export function addNote(doc: Blocks, props: Record<string, any> = {}) {
|
||||
const noteId = doc.addBlock(
|
||||
'affine:note',
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { effects as blocksEffects } from '@blocksuite/blocks/effects';
|
||||
import type { BlockCollection, Doc, Job } from '@blocksuite/store';
|
||||
import type { BlockCollection, Blocks, Job } from '@blocksuite/store';
|
||||
|
||||
import { effects } from '../../effects.js';
|
||||
|
||||
@@ -111,12 +111,12 @@ export function cleanup() {
|
||||
|
||||
declare global {
|
||||
const editor: AffineEditorContainer;
|
||||
const doc: Doc;
|
||||
const doc: Blocks;
|
||||
const collection: TestWorkspace;
|
||||
const job: Job;
|
||||
interface Window {
|
||||
editor: AffineEditorContainer;
|
||||
doc: Doc;
|
||||
doc: Blocks;
|
||||
job: Job;
|
||||
collection: TestWorkspace;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user