akumatus
2024-07-23 15:24:57 +00:00
parent 0dbed968a0
commit f89945e730
19 changed files with 123 additions and 128 deletions

View File

@@ -3,8 +3,8 @@
"private": true,
"type": "module",
"devDependencies": {
"@blocksuite/global": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/store": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/global": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/store": "0.16.0-canary-202407230727-128fc57",
"react": "18.3.1",
"react-dom": "18.3.1",
"vitest": "1.6.0"

View File

@@ -14,9 +14,9 @@
"@affine/debug": "workspace:*",
"@affine/env": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/blocks": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/global": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/store": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/blocks": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/global": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/store": "0.16.0-canary-202407230727-128fc57",
"@datastructures-js/binary-search-tree": "^5.3.2",
"foxact": "^0.2.33",
"fuse.js": "^7.0.0",
@@ -33,8 +33,8 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/block-std": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/presets": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/block-std": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/presets": "0.16.0-canary-202407230727-128fc57",
"@testing-library/react": "^16.0.0",
"async-call-rpc": "^6.4.0",
"fake-indexeddb": "^6.0.0",

View File

@@ -78,12 +78,12 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@blocksuite/block-std": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/blocks": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/global": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/block-std": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/blocks": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/global": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/icons": "2.1.59",
"@blocksuite/presets": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/store": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/presets": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/store": "0.16.0-canary-202407230727-128fc57",
"@storybook/addon-actions": "^7.6.17",
"@storybook/addon-essentials": "^7.6.17",
"@storybook/addon-interactions": "^7.6.17",

View File

@@ -19,13 +19,13 @@
"@affine/graphql": "workspace:*",
"@affine/i18n": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/block-std": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/blocks": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/global": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/block-std": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/blocks": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/global": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/icons": "2.1.59",
"@blocksuite/inline": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/presets": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/store": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/inline": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/presets": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/store": "0.16.0-canary-202407230727-128fc57",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "^8.0.0",

View File

@@ -10,7 +10,6 @@ import type {
SurfaceBlockModel,
} from '@blocksuite/blocks';
import {
Bound,
DeleteIcon,
EDGELESS_ELEMENT_TOOLBAR_WIDGET,
EDGELESS_TEXT_BLOCK_MIN_HEIGHT,
@@ -23,7 +22,7 @@ import {
NoteDisplayMode,
ResetIcon,
} from '@blocksuite/blocks';
import { assertExists } from '@blocksuite/global/utils';
import { assertExists, Bound } from '@blocksuite/global/utils';
import type { TemplateResult } from 'lit';
import { AIPenIcon, ChatWithAIIcon } from '../_common/icons';

View File

@@ -4,13 +4,12 @@ import {
AffineAIPanelWidget,
type AffineAIPanelWidgetConfig,
type AIItemConfig,
Bound,
ImageBlockModel,
isInsideEdgelessEditor,
matchFlavours,
NoteDisplayMode,
} from '@blocksuite/blocks';
import { assertExists } from '@blocksuite/global/utils';
import { assertExists, Bound } from '@blocksuite/global/utils';
import type { TemplateResult } from 'lit';
import {

View File

@@ -3,17 +3,14 @@ import type {
EditorHost,
TextSelection,
} from '@blocksuite/block-std';
import type {
EdgelessRootService,
ImageSelection,
SerializedXYWH,
} from '@blocksuite/blocks';
import type { EdgelessRootService, ImageSelection } from '@blocksuite/blocks';
import {
BlocksUtils,
Bound,
getElementsBound,
NoteDisplayMode,
} from '@blocksuite/blocks';
import type { SerializedXYWH } from '@blocksuite/global/utils';
import { Bound } from '@blocksuite/global/utils';
import { CreateIcon, InsertBelowIcon, ReplaceIcon } from '../../_common/icons';
import { reportResponse } from '../../utils/action-reporter';

View File

@@ -20,7 +20,7 @@ export function setupCodeToolbarEntry(codeToolbar: AffineCodeToolbarWidget) {
const onAskAIClick = () => {
const { host } = codeToolbar;
const { selection } = host;
const codeBlock = codeToolbar.blockElement;
const codeBlock = codeToolbar.block;
selection.setGroup('note', [
selection.create('block', { blockId: codeBlock.blockId }),
]);

View File

@@ -20,7 +20,7 @@ export function setupImageToolbarEntry(imageToolbar: AffineImageToolbarWidget) {
const onAskAIClick = () => {
const { host } = imageToolbar;
const { selection } = host;
const imageBlock = imageToolbar.blockElement;
const imageBlock = imageToolbar.block;
selection.setGroup('note', [
selection.create('image', { blockId: imageBlock.blockId }),
]);

View File

@@ -1,4 +1,4 @@
import { Bound } from '@blocksuite/blocks';
import { Bound } from '@blocksuite/global/utils';
import { nanoid } from '@blocksuite/store';
import { AIProvider } from '../provider';

View File

@@ -1,4 +1,4 @@
import type { BlockElement, EditorHost } from '@blocksuite/block-std';
import type { BlockComponent, EditorHost } from '@blocksuite/block-std';
import {
AFFINE_EDGELESS_COPILOT_WIDGET,
type EdgelessCopilotWidget,
@@ -59,7 +59,7 @@ export function getEdgelessCopilotWidget(
return copilotWidget;
}
export function findNoteBlockModel(blockElement: BlockElement) {
export function findNoteBlockModel(blockElement: BlockComponent) {
let curBlock = blockElement;
while (curBlock) {
if (matchFlavours(curBlock.model, ['affine:note'])) {
@@ -68,7 +68,7 @@ export function findNoteBlockModel(blockElement: BlockElement) {
if (matchFlavours(curBlock.model, ['affine:page', 'affine:surface'])) {
return null;
}
curBlock = curBlock.parentBlockElement;
curBlock = curBlock.parentBlock;
}
return null;
}

View File

@@ -1,5 +1,5 @@
import type {
BlockElement,
BlockComponent,
EditorHost,
TextSelection,
} from '@blocksuite/block-std';
@@ -13,10 +13,10 @@ import {
markdownToSnapshot,
} from './markdown-utils';
const getNoteId = (blockElement: BlockElement) => {
const getNoteId = (blockElement: BlockComponent) => {
let element = blockElement;
while (element && element.flavour !== 'affine:note') {
element = element.parentBlockElement;
while (element.flavour !== 'affine:note') {
element = element.parentBlock;
}
return element.model.id;
@@ -24,7 +24,7 @@ const getNoteId = (blockElement: BlockElement) => {
const setBlockSelection = (
host: EditorHost,
parent: BlockElement,
parent: BlockComponent,
models: BlockModel[]
) => {
const selections = models
@@ -50,10 +50,10 @@ const setBlockSelection = (
export const insert = async (
host: EditorHost,
content: string,
selectBlock: BlockElement,
selectBlock: BlockComponent,
below: boolean = true
) => {
const blockParent = selectBlock.parentBlockElement;
const blockParent = selectBlock.parentBlock;
const index = blockParent.model.children.findIndex(
model => model.id === selectBlock.model.id
);
@@ -72,7 +72,7 @@ export const insert = async (
export const insertBelow = async (
host: EditorHost,
content: string,
selectBlock: BlockElement
selectBlock: BlockComponent
) => {
await insert(host, content, selectBlock, true);
};
@@ -80,7 +80,7 @@ export const insertBelow = async (
export const insertAbove = async (
host: EditorHost,
content: string,
selectBlock: BlockElement
selectBlock: BlockComponent
) => {
await insert(host, content, selectBlock, false);
};
@@ -88,11 +88,11 @@ export const insertAbove = async (
export const replace = async (
host: EditorHost,
content: string,
firstBlock: BlockElement,
firstBlock: BlockComponent,
selectedModels: BlockModel[],
textSelection?: TextSelection
) => {
const firstBlockParent = firstBlock.parentBlockElement;
const firstBlockParent = firstBlock.parentBlock;
const firstIndex = firstBlockParent.model.children.findIndex(
model => model.id === firstBlock.model.id
);

View File

@@ -1,4 +1,4 @@
import type { BlockElement } from '@blocksuite/block-std';
import type { BlockComponent } from '@blocksuite/block-std';
import type {
AffineEditorContainer,
EdgelessEditor,
@@ -56,7 +56,7 @@ type BlocksuiteEditorContainerRef = Pick<
function findBlockElementById(container: HTMLElement, blockId: string) {
const element = container.querySelector(
`[data-block-id="${blockId}"]`
) as BlockElement | null;
) as BlockComponent | null;
return element;
}
@@ -67,7 +67,7 @@ const useBlockElementById = (
blockId: string | undefined,
timeout = 1000
) => {
const [blockElement, setBlockElement] = useState<BlockElement | null>(null);
const [blockElement, setBlockElement] = useState<BlockComponent | null>(null);
useEffect(() => {
if (!blockId) {
return;
@@ -210,7 +210,7 @@ export const BlocksuiteEditorContainer = forwardRef<
useEffect(() => {
let canceled = false;
const handleScrollToBlock = (blockElement: BlockElement) => {
const handleScrollToBlock = (blockElement: BlockComponent) => {
if (!mode || !blockElement) {
return;
}

View File

@@ -1,4 +1,4 @@
import type { BlockElement } from '@blocksuite/block-std';
import type { BlockComponent } from '@blocksuite/block-std';
import {
AffineReference,
type EmbedLinkedDocModel,
@@ -17,7 +17,7 @@ import type { WorkbenchService } from '../../workbench';
export type PeekViewTarget =
| HTMLElement
| BlockElement
| BlockComponent
| AffineReference
| HTMLAnchorElement
| { docId: string; blockId?: string };

View File

@@ -6,8 +6,8 @@ import { BlockSuiteEditor } from '@affine/core/components/blocksuite/block-suite
import { useNavigateHelper } from '@affine/core/hooks/use-navigate-helper';
import { PageNotFound } from '@affine/core/pages/404';
import { DebugLogger } from '@affine/debug';
import { Bound, type EdgelessRootService } from '@blocksuite/blocks';
import { DisposableGroup } from '@blocksuite/global/utils';
import { type EdgelessRootService } from '@blocksuite/blocks';
import { Bound, DisposableGroup } from '@blocksuite/global/utils';
import type { AffineEditorContainer } from '@blocksuite/presets';
import type { DocMode } from '@toeverything/infra';
import { DocsService, FrameworkScope, useService } from '@toeverything/infra';

View File

@@ -1,5 +1,5 @@
import { toReactNode } from '@affine/component';
import { BlockElement } from '@blocksuite/block-std';
import { BlockComponent } from '@blocksuite/block-std';
import { useLiveData, useService } from '@toeverything/infra';
import { useEffect, useMemo } from 'react';
@@ -91,7 +91,7 @@ export const PeekViewManagerModal = () => {
useEffect(() => {
const subscription = peekViewEntity.show$.subscribe(() => {
if (activePeekView?.target instanceof BlockElement) {
if (activePeekView?.target instanceof BlockComponent) {
activePeekView.target.requestUpdate();
}
});

View File

@@ -29,10 +29,10 @@
"@affine/env": "workspace:*",
"@affine/i18n": "workspace:*",
"@affine/native": "workspace:*",
"@blocksuite/block-std": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/blocks": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/presets": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/store": "0.16.0-canary-202407200848-42035fe",
"@blocksuite/block-std": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/blocks": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/presets": "0.16.0-canary-202407230727-128fc57",
"@blocksuite/store": "0.16.0-canary-202407230727-128fc57",
"@electron-forge/cli": "^7.3.0",
"@electron-forge/core": "^7.3.0",
"@electron-forge/core-utils": "^7.3.0",