refactor(editor): rename doc to blocks (#9510)
This commit is contained in:
@@ -10,7 +10,7 @@ import type {
|
||||
EdgelessEditor,
|
||||
PageEditor,
|
||||
} from '@blocksuite/affine/presets';
|
||||
import { type BlockModel, type Doc } from '@blocksuite/affine/store';
|
||||
import { type BlockModel, type Blocks } from '@blocksuite/affine/store';
|
||||
import clsx from 'clsx';
|
||||
import type React from 'react';
|
||||
import {
|
||||
@@ -27,7 +27,7 @@ import { BlocksuiteDocEditor, BlocksuiteEdgelessEditor } from './lit-adaper';
|
||||
import * as styles from './styles.css';
|
||||
|
||||
interface BlocksuiteEditorContainerProps {
|
||||
page: Doc;
|
||||
page: Blocks;
|
||||
mode: DocMode;
|
||||
shared?: boolean;
|
||||
className?: string;
|
||||
@@ -191,7 +191,7 @@ export const BlocksuiteEditorContainer = forwardRef<
|
||||
});
|
||||
|
||||
// copy from '@blocksuite/affine-shared/utils'
|
||||
export function getLastNoteBlock(doc: Doc) {
|
||||
export function getLastNoteBlock(doc: Blocks) {
|
||||
let note: NoteBlockModel | null = null;
|
||||
if (!doc.root) return null;
|
||||
const { children } = doc.root;
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { DisposableGroup } from '@blocksuite/affine/global/utils';
|
||||
import type { AffineEditorContainer } from '@blocksuite/affine/presets';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import type { CSSProperties } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
@@ -20,7 +20,7 @@ import { BlocksuiteEditorContainer } from './blocksuite-editor-container';
|
||||
import { NoPageRootError } from './no-page-error';
|
||||
|
||||
export type EditorProps = {
|
||||
page: Doc;
|
||||
page: Blocks;
|
||||
mode: DocMode;
|
||||
shared?: boolean;
|
||||
defaultOpenProperty?: DefaultOpenProperty;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { JournalService } from '@affine/core/modules/journal';
|
||||
import { i18nTime, useI18n } from '@affine/i18n';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import * as styles from './styles.css';
|
||||
|
||||
export const BlocksuiteEditorJournalDocTitle = ({ page }: { page: Doc }) => {
|
||||
export const BlocksuiteEditorJournalDocTitle = ({ page }: { page: Blocks }) => {
|
||||
const journalService = useService(JournalService);
|
||||
const journalDateStr = useLiveData(journalService.journalDate$(page.id));
|
||||
const journalDate = journalDateStr ? dayjs(journalDateStr) : null;
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
EdgelessEditor,
|
||||
PageEditor,
|
||||
} from '@blocksuite/affine/presets';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import {
|
||||
useFramework,
|
||||
useLiveData,
|
||||
@@ -85,7 +85,7 @@ const adapted = {
|
||||
};
|
||||
|
||||
interface BlocksuiteEditorProps {
|
||||
page: Doc;
|
||||
page: Blocks;
|
||||
shared?: boolean;
|
||||
defaultOpenProperty?: DefaultOpenProperty;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import type { Map as YMap } from 'yjs';
|
||||
|
||||
/**
|
||||
* TODO(@eyhn): Define error to unexpected state together in the future.
|
||||
*/
|
||||
export class NoPageRootError extends Error {
|
||||
constructor(public page: Doc) {
|
||||
constructor(public page: Blocks) {
|
||||
super('Page root not found when render editor!');
|
||||
|
||||
// Log info to let sentry collect more message
|
||||
|
||||
@@ -2,13 +2,13 @@ import type { WeekDatePickerHandle } from '@affine/component';
|
||||
import { WeekDatePicker } from '@affine/component';
|
||||
import { useJournalRouteHelper } from '@affine/core/components/hooks/use-journal';
|
||||
import { JournalService } from '@affine/core/modules/journal';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import dayjs from 'dayjs';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
export interface JournalWeekDatePickerProps {
|
||||
page: Doc;
|
||||
page: Blocks;
|
||||
}
|
||||
|
||||
const weekStyle = { maxWidth: 800, width: '100%' };
|
||||
|
||||
@@ -22,7 +22,7 @@ import { ViewService } from '@affine/core/modules/workbench/services/view';
|
||||
import { WorkspaceService } from '@affine/core/modules/workspace';
|
||||
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 {
|
||||
DuplicateIcon,
|
||||
EdgelessIcon,
|
||||
@@ -52,7 +52,7 @@ import { HistoryTipsModal } from './history-tips-modal';
|
||||
|
||||
type PageMenuProps = {
|
||||
rename?: () => void;
|
||||
page: Doc;
|
||||
page: Blocks;
|
||||
isJournal?: boolean;
|
||||
containerWidth: number;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user