mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
refactor(editor): rename doc to blocks (#9510)
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
StrokeStyle,
|
||||
TextAlign,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { useFramework, useLiveData } from '@toeverything/infra';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
@@ -357,7 +357,7 @@ export const ConnectorSettings = () => {
|
||||
return getCurrentTextColor(color);
|
||||
}, [getCurrentTextColor, settings]);
|
||||
|
||||
const getElements = useCallback((doc: Doc) => {
|
||||
const getElements = useCallback((doc: Blocks) => {
|
||||
const surface = getSurfaceBlock(doc);
|
||||
return surface?.getElementsByType('connector') || [];
|
||||
}, []);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { WorkspaceImpl } from '@affine/core/modules/workspace/impl/workspace';
|
||||
import { AffineSchemas } from '@blocksuite/affine/blocks';
|
||||
import type { Doc, DocSnapshot } from '@blocksuite/affine/store';
|
||||
import type { Blocks, DocSnapshot } from '@blocksuite/affine/store';
|
||||
import { Job, Schema } from '@blocksuite/affine/store';
|
||||
|
||||
const getCollection = (() => {
|
||||
@@ -26,7 +26,7 @@ export type DocName =
|
||||
| 'connector'
|
||||
| 'mindmap';
|
||||
|
||||
const docMap = new Map<DocName, Promise<Doc | undefined>>();
|
||||
const docMap = new Map<DocName, Promise<Blocks | undefined>>();
|
||||
|
||||
async function loadNote() {
|
||||
return (await import('./note.json')).default;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { SettingRow } from '@affine/component/setting-components';
|
||||
import { EditorSettingService } from '@affine/core/modules/editor-setting';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { LayoutType, MindmapStyle } from '@blocksuite/affine/blocks';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { useFramework, useLiveData } from '@toeverything/infra';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
@@ -93,7 +93,7 @@ export const MindMapSettings = () => {
|
||||
});
|
||||
}, [editorSetting, settings]);
|
||||
|
||||
const getElements = useCallback((doc: Doc) => {
|
||||
const getElements = useCallback((doc: Blocks) => {
|
||||
const surface = getSurfaceBlock(doc);
|
||||
return surface?.getElementsByType('mindmap') || [];
|
||||
}, []);
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
NoteShadowMap,
|
||||
StrokeStyle,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { useFramework, useLiveData } from '@toeverything/infra';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
@@ -170,7 +170,7 @@ export const NoteSettings = () => {
|
||||
return getCurrentColor(background);
|
||||
}, [getCurrentColor, settings]);
|
||||
|
||||
const getElements = useCallback((doc: Doc) => {
|
||||
const getElements = useCallback((doc: Blocks) => {
|
||||
return doc.getBlocksByFlavour('affine:note') || [];
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { SettingRow } from '@affine/component/setting-components';
|
||||
import { EditorSettingService } from '@affine/core/modules/editor-setting';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { DefaultTheme } from '@blocksuite/affine/blocks';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { useFramework, useLiveData } from '@toeverything/infra';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
@@ -59,7 +59,7 @@ export const PenSettings = () => {
|
||||
[editorSetting]
|
||||
);
|
||||
|
||||
const getElements = useCallback((doc: Doc) => {
|
||||
const getElements = useCallback((doc: Blocks) => {
|
||||
const surface = getSurfaceBlock(doc);
|
||||
return surface?.getElementsByType('brush') || [];
|
||||
}, []);
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
StrokeStyle,
|
||||
TextAlign,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { useFramework, useLiveData } from '@toeverything/infra';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
@@ -339,7 +339,7 @@ export const ShapeSettings = () => {
|
||||
}, [editorSetting, settings, currentShape, strokeColorPalettes]);
|
||||
|
||||
const getElements = useCallback(
|
||||
(doc: Doc) => {
|
||||
(doc: Blocks) => {
|
||||
const surface = getSurfaceBlock(doc);
|
||||
if (!surface) return [];
|
||||
return surface.getElementsByType('shape').filter(node => {
|
||||
@@ -353,7 +353,7 @@ export const ShapeSettings = () => {
|
||||
);
|
||||
|
||||
const firstUpdate = useCallback(
|
||||
(doc: Doc, editorHost: EditorHost) => {
|
||||
(doc: Blocks, editorHost: EditorHost) => {
|
||||
const edgelessService = editorHost.std.getService(
|
||||
'affine:page'
|
||||
) as EdgelessRootService;
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
ThemeExtensionIdentifier,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { Bound } from '@blocksuite/affine/global/utils';
|
||||
import type { Block, Doc } from '@blocksuite/affine/store';
|
||||
import type { Block, Blocks } from '@blocksuite/affine/store';
|
||||
import { createSignalFromObservable } from '@blocksuite/affine-shared/utils';
|
||||
import type { Container } from '@blocksuite/global/di';
|
||||
import type { Signal } from '@preact/signals-core';
|
||||
@@ -45,8 +45,8 @@ interface Props {
|
||||
docName: DocName;
|
||||
keyName: keyof EditorSettingSchema;
|
||||
height?: number;
|
||||
getElements: (doc: Doc) => Array<Block | GfxPrimitiveElementModel>;
|
||||
firstUpdate?: (doc: Doc, editorHost: EditorHost) => void;
|
||||
getElements: (doc: Blocks) => Array<Block | GfxPrimitiveElementModel>;
|
||||
firstUpdate?: (doc: Blocks, editorHost: EditorHost) => void;
|
||||
children?: React.ReactElement;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ export const EdgelessSnapshot = (props: Props) => {
|
||||
children,
|
||||
} = props;
|
||||
const wrapperRef = useRef<HTMLDivElement | null>(null);
|
||||
const docRef = useRef<Doc | null>(null);
|
||||
const docRef = useRef<Blocks | null>(null);
|
||||
const editorHostRef = useRef<EditorHost | null>(null);
|
||||
const framework = useFramework();
|
||||
const { editorSetting } = framework.get(EditorSettingService);
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
FontWeightMap,
|
||||
TextAlign,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { useFramework, useLiveData } from '@toeverything/infra';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
@@ -143,7 +143,7 @@ export const TextSettings = () => {
|
||||
return getCurrentColor(color);
|
||||
}, [getCurrentColor, settings]);
|
||||
|
||||
const getElements = useCallback((doc: Doc) => {
|
||||
const getElements = useCallback((doc: Blocks) => {
|
||||
return doc.getBlocksByFlavour('affine:edgeless-text') || [];
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { SurfaceBlockModel } from '@blocksuite/affine/block-std/gfx';
|
||||
import type { FrameBlockModel } from '@blocksuite/affine/blocks';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
|
||||
export function getSurfaceBlock(doc: Doc) {
|
||||
export function getSurfaceBlock(doc: Blocks) {
|
||||
const blocks = doc.getBlocksByFlavour('affine:surface');
|
||||
return blocks.length !== 0 ? (blocks[0].model as SurfaceBlockModel) : null;
|
||||
}
|
||||
|
||||
export function getFrameBlock(doc: Doc) {
|
||||
export function getFrameBlock(doc: Blocks) {
|
||||
const blocks = doc.getBlocksByFlavour('affine:frame');
|
||||
return blocks.length !== 0 ? (blocks[0].model as FrameBlockModel) : null;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import type { Workspace } from '@affine/core/modules/workspace';
|
||||
import type { AffineDNDData } from '@affine/core/types/dnd';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { track } from '@affine/track';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
@@ -49,7 +49,7 @@ const Header = forwardRef<
|
||||
Header.displayName = 'forwardRef(Header)';
|
||||
|
||||
interface PageHeaderProps {
|
||||
page: Doc;
|
||||
page: Blocks;
|
||||
workspace: Workspace;
|
||||
}
|
||||
export function JournalPageHeader({ page, workspace }: PageHeaderProps) {
|
||||
|
||||
Reference in New Issue
Block a user