mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
refactor(core): move block collection to affine and implement as doc (#9514)
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
||||
} from '@blocksuite/affine-model';
|
||||
import { propertyModelPresets } from '@blocksuite/data-view/property-pure-presets';
|
||||
import type { BlockModel, Blocks } from '@blocksuite/store';
|
||||
import { Schema } from '@blocksuite/store';
|
||||
import { Schema, Text } from '@blocksuite/store';
|
||||
import {
|
||||
createAutoIncrementIdGenerator,
|
||||
TestWorkspace,
|
||||
@@ -71,7 +71,7 @@ describe('DatabaseManager', () => {
|
||||
doc = createTestDoc();
|
||||
|
||||
rootId = doc.addBlock('affine:page', {
|
||||
title: new doc.Text('database test'),
|
||||
title: new Text('database test'),
|
||||
});
|
||||
noteBlockId = doc.addBlock('affine:note', {}, rootId);
|
||||
|
||||
@@ -114,14 +114,14 @@ describe('DatabaseManager', () => {
|
||||
p1 = doc.addBlock(
|
||||
'affine:paragraph',
|
||||
{
|
||||
text: new doc.Text('text1'),
|
||||
text: new Text('text1'),
|
||||
},
|
||||
databaseBlockId
|
||||
);
|
||||
p2 = doc.addBlock(
|
||||
'affine:paragraph',
|
||||
{
|
||||
text: new doc.Text('text2'),
|
||||
text: new Text('text2'),
|
||||
},
|
||||
databaseBlockId
|
||||
);
|
||||
@@ -173,7 +173,7 @@ describe('DatabaseManager', () => {
|
||||
const modelId = doc.addBlock(
|
||||
'affine:paragraph',
|
||||
{
|
||||
text: new doc.Text('paragraph'),
|
||||
text: new Text('paragraph'),
|
||||
},
|
||||
noteBlockId
|
||||
);
|
||||
@@ -201,7 +201,7 @@ describe('DatabaseManager', () => {
|
||||
const newRowId = doc.addBlock(
|
||||
'affine:paragraph',
|
||||
{
|
||||
text: new doc.Text('text3'),
|
||||
text: new Text('text3'),
|
||||
},
|
||||
databaseBlockId
|
||||
);
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ import { DocModeProvider } from '@blocksuite/affine-shared/services';
|
||||
import { getBlockProps } from '@blocksuite/affine-shared/utils';
|
||||
import type { EditorHost } from '@blocksuite/block-std';
|
||||
import { GfxBlockElementModel } from '@blocksuite/block-std/gfx';
|
||||
import { type BlockModel, type Blocks } from '@blocksuite/store';
|
||||
import { type BlockModel, type Blocks, Text } from '@blocksuite/store';
|
||||
|
||||
import {
|
||||
getElementProps,
|
||||
@@ -43,7 +43,7 @@ export function createLinkedDocFromNote(
|
||||
const linkedDoc = doc.collection.createDoc({});
|
||||
linkedDoc.load(() => {
|
||||
const rootId = linkedDoc.addBlock('affine:page', {
|
||||
title: new doc.Text(docTitle),
|
||||
title: new Text(docTitle),
|
||||
});
|
||||
linkedDoc.addBlock('affine:surface', {}, rootId);
|
||||
const blockProps = getBlockProps(note);
|
||||
@@ -74,7 +74,7 @@ export function createLinkedDocFromEdgelessElements(
|
||||
const linkedDoc = host.doc.collection.createDoc({});
|
||||
linkedDoc.load(() => {
|
||||
const rootId = linkedDoc.addBlock('affine:page', {
|
||||
title: new host.doc.Text(docTitle),
|
||||
title: new Text(docTitle),
|
||||
});
|
||||
const surfaceId = linkedDoc.addBlock('affine:surface', {}, rootId);
|
||||
const surface = getSurfaceBlock(linkedDoc);
|
||||
|
||||
@@ -53,7 +53,7 @@ import {
|
||||
} from '@blocksuite/affine-shared/services';
|
||||
import { getHostName, referenceToNode } from '@blocksuite/affine-shared/utils';
|
||||
import { type BlockStdScope, WidgetComponent } from '@blocksuite/block-std';
|
||||
import { type BlockModel } from '@blocksuite/store';
|
||||
import { type BlockModel, Text } from '@blocksuite/store';
|
||||
import { autoUpdate, computePosition, flip, offset } from '@floating-ui/dom';
|
||||
import { html, nothing, type TemplateResult } from 'lit';
|
||||
import { query, state } from 'lit/decorators.js';
|
||||
@@ -619,7 +619,7 @@ export class EmbedCardToolbar extends WidgetComponent<
|
||||
const insert = title || caption || url;
|
||||
yText.insert(0, insert);
|
||||
yText.format(0, insert.length, { link: url });
|
||||
const text = new doc.Text(yText);
|
||||
const text = new Text(yText);
|
||||
doc.addBlock(
|
||||
'affine:paragraph',
|
||||
{
|
||||
|
||||
@@ -709,9 +709,7 @@ export const defaultSlashMenuConfig: SlashMenuConfig = {
|
||||
model.flavour as never,
|
||||
{
|
||||
type: (model as ParagraphBlockModel).type,
|
||||
text: new rootComponent.doc.Text(
|
||||
model.text.toDelta() as DeltaInsert[]
|
||||
),
|
||||
text: new Text(model.text.toDelta() as DeltaInsert[]),
|
||||
// @ts-expect-error FIXME: ts error
|
||||
checked: model.checked,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user