mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-20 07:47:19 +08:00
refactor(editor): rename doc to blocks (#9510)
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
||||
type ParagraphProps,
|
||||
type RootBlockProps,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { type Doc, Text } from '@blocksuite/affine/store';
|
||||
import { type Blocks, Text } from '@blocksuite/affine/store';
|
||||
|
||||
export interface DocProps {
|
||||
page?: Partial<RootBlockProps>;
|
||||
@@ -14,7 +14,7 @@ export interface DocProps {
|
||||
paragraph?: Partial<ParagraphProps>;
|
||||
}
|
||||
|
||||
export function initEmptyDoc(doc: Doc, title?: string) {
|
||||
export function initEmptyDoc(doc: Blocks, title?: string) {
|
||||
doc.load(() => {
|
||||
initDocFromProps(doc, {
|
||||
page: {
|
||||
@@ -24,7 +24,7 @@ export function initEmptyDoc(doc: Doc, title?: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export function initDocFromProps(doc: Doc, props?: DocProps) {
|
||||
export function initDocFromProps(doc: Blocks, props?: DocProps) {
|
||||
doc.load(() => {
|
||||
const pageBlockId = doc.addBlock(
|
||||
'affine:page',
|
||||
|
||||
@@ -20,8 +20,8 @@ import {
|
||||
import { Container, type ServiceProvider } from '@blocksuite/affine/global/di';
|
||||
import { WithDisposable } from '@blocksuite/affine/global/utils';
|
||||
import {
|
||||
type Blocks,
|
||||
BlockViewType,
|
||||
type Doc,
|
||||
type JobMiddleware,
|
||||
type Query,
|
||||
type Schema,
|
||||
@@ -174,7 +174,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
||||
}
|
||||
};
|
||||
|
||||
private _doc: Doc | null = null;
|
||||
private _doc: Blocks | null = null;
|
||||
|
||||
private readonly _query: Query = {
|
||||
mode: 'strict',
|
||||
|
||||
@@ -17,8 +17,8 @@ import type { ServiceProvider } from '@blocksuite/affine/global/di';
|
||||
import { assertExists } from '@blocksuite/affine/global/utils';
|
||||
import type {
|
||||
BlockModel,
|
||||
Blocks,
|
||||
BlockSnapshot,
|
||||
Doc,
|
||||
DraftModel,
|
||||
JobMiddleware,
|
||||
Schema,
|
||||
@@ -166,7 +166,7 @@ export const markdownToSnapshot = async (
|
||||
export async function insertFromMarkdown(
|
||||
host: EditorHost,
|
||||
markdown: string,
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
parent?: string,
|
||||
index?: number
|
||||
) {
|
||||
@@ -235,5 +235,5 @@ export async function markDownToDoc(
|
||||
if (!doc) {
|
||||
console.error('Failed to convert markdown to doc');
|
||||
}
|
||||
return doc as Doc;
|
||||
return doc as Blocks;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
getCommonBoundWithRotation,
|
||||
type SerializedXYWH,
|
||||
} from '@blocksuite/affine/global/utils';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import type { TemplateResult } from 'lit';
|
||||
|
||||
import type { ChatMessage } from '../../../blocks';
|
||||
@@ -101,7 +101,7 @@ export function constructUserInfoWithMessages(
|
||||
}
|
||||
|
||||
export async function constructRootChatBlockMessages(
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
forkSessionId: string
|
||||
) {
|
||||
// Convert chat messages to AI chat block messages
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { EditorHost } from '@blocksuite/affine/block-std';
|
||||
import { ShadowlessElement } from '@blocksuite/affine/block-std';
|
||||
import { NotificationProvider } from '@blocksuite/affine/blocks';
|
||||
import { debounce, WithDisposable } from '@blocksuite/affine/global/utils';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { css, html, type PropertyValues } from 'lit';
|
||||
import { property, state } from 'lit/decorators.js';
|
||||
import { createRef, type Ref, ref } from 'lit/directives/ref.js';
|
||||
@@ -141,7 +141,7 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {
|
||||
accessor host!: EditorHost;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor doc!: Doc;
|
||||
accessor doc!: Blocks;
|
||||
|
||||
@state()
|
||||
accessor isLoading = false;
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { AffineSchemas } from '@blocksuite/affine/blocks/schemas';
|
||||
import { WithDisposable } from '@blocksuite/affine/global/utils';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { Schema } from '@blocksuite/affine/store';
|
||||
import { css, html, LitElement, nothing } from 'lit';
|
||||
import { property, query } from 'lit/decorators.js';
|
||||
@@ -53,7 +53,7 @@ export class AISlidesRenderer extends WithDisposable(LitElement) {
|
||||
private readonly _editorContainer: Ref<HTMLDivElement> =
|
||||
createRef<HTMLDivElement>();
|
||||
|
||||
private _doc!: Doc;
|
||||
private _doc!: Blocks;
|
||||
|
||||
private _docCollection: WorkspaceImpl | null = null;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import type { ServiceProvider } from '@blocksuite/affine/global/di';
|
||||
import { WithDisposable } from '@blocksuite/affine/global/utils';
|
||||
import { type Doc, Job, Schema } from '@blocksuite/affine/store';
|
||||
import { type Blocks, Job, Schema } from '@blocksuite/affine/store';
|
||||
import { css, html, LitElement, nothing } from 'lit';
|
||||
import { property, query } from 'lit/decorators.js';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
@@ -79,7 +79,7 @@ export class MiniMindmapPreview extends WithDisposable(LitElement) {
|
||||
}
|
||||
`;
|
||||
|
||||
doc?: Doc;
|
||||
doc?: Blocks;
|
||||
|
||||
mindmapId?: string;
|
||||
|
||||
@@ -131,7 +131,7 @@ export class MiniMindmapPreview extends WithDisposable(LitElement) {
|
||||
this.requestUpdate();
|
||||
}
|
||||
|
||||
private _toMindmapNode(answer: string, doc: Doc) {
|
||||
private _toMindmapNode(answer: string, doc: Blocks) {
|
||||
return markdownToMindmap(answer, doc, this.host.std.provider);
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ type Node = {
|
||||
|
||||
export const markdownToMindmap = (
|
||||
answer: string,
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
provider: ServiceProvider
|
||||
) => {
|
||||
let result: Node | null = null;
|
||||
|
||||
Reference in New Issue
Block a user