diff --git a/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsx b/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsx index b2f76e46f9..0bdbd7ca5b 100644 --- a/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsx +++ b/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsx @@ -188,7 +188,7 @@ export const BulletView = ({ block, editor }: CreateView) => { return ( - + diff --git a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx b/libs/components/editor-blocks/src/blocks/code/CodeView.tsx index 1bcedf4251..f5b91d7fcf 100644 --- a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx +++ b/libs/components/editor-blocks/src/blocks/code/CodeView.tsx @@ -170,7 +170,7 @@ export const CodeView = ({ block, editor }: CreateCodeView) => { editor.selectionManager.activePreviousNode(block.id, 'start'); }; return ( - + { e.stopPropagation(); @@ -198,7 +198,8 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {
- Copy + + Copy
diff --git a/libs/components/editor-blocks/src/blocks/embed-link/EmbedLinkView.tsx b/libs/components/editor-blocks/src/blocks/embed-link/EmbedLinkView.tsx index 86b43908d1..c3e7199c29 100644 --- a/libs/components/editor-blocks/src/blocks/embed-link/EmbedLinkView.tsx +++ b/libs/components/editor-blocks/src/blocks/embed-link/EmbedLinkView.tsx @@ -33,7 +33,7 @@ export const EmbedLinkView = (props: EmbedLinkView) => { }; return ( - + {embedLinkUrl ? ( { setIsSelect(isSelect); }); return ( - + {figmaUrl ? ( { }; return ( - +
- {!isSelect ? ( - - ) : null} + {!isSelect ? : null} {imgUrl ? (
{ diff --git a/libs/components/editor-blocks/src/blocks/numbered/NumberedView.tsx b/libs/components/editor-blocks/src/blocks/numbered/NumberedView.tsx index 74bcfab504..c45321a138 100644 --- a/libs/components/editor-blocks/src/blocks/numbered/NumberedView.tsx +++ b/libs/components/editor-blocks/src/blocks/numbered/NumberedView.tsx @@ -183,7 +183,7 @@ export const NumberedView = ({ block, editor }: CreateView) => { return ( - +
{getNumber(properties.numberType, number)}. diff --git a/libs/components/editor-blocks/src/blocks/page/PageView.tsx b/libs/components/editor-blocks/src/blocks/page/PageView.tsx index 64fba3ca83..123021e361 100644 --- a/libs/components/editor-blocks/src/blocks/page/PageView.tsx +++ b/libs/components/editor-blocks/src/blocks/page/PageView.tsx @@ -1,14 +1,14 @@ -import { useRef, useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useRef, useState } from 'react'; import { useParams } from 'react-router'; import { BackLink, TextProps } from '@toeverything/components/common'; import { - RenderBlockChildren, BlockPendantProvider, + RenderBlockChildren, } from '@toeverything/components/editor-core'; +import { styled } from '@toeverything/components/ui'; import { ContentColumnValue } from '@toeverything/datasource/db-service'; import { CreateView } from '@toeverything/framework/virgo'; -import { Theme, styled } from '@toeverything/components/ui'; import { TextManage, @@ -81,7 +81,7 @@ export const PageView = ({ block, editor }: CreateView) => { return ( - + - + { return ( - +
) => { @@ -23,8 +30,23 @@ export const BlockPendantProvider = ({ const showTriggerLine = properties.filter(property => getValue(property.id)).length === 0; + const onClick = useCallback( + (e: MouseEvent) => { + if (containerFlavor.includes(block.type)) { + return; + } + if (e.target === e.currentTarget) { + const rect = e.currentTarget.getBoundingClientRect(); + const middle = (rect.left + rect.right) / 2; + const position = e.clientX < middle ? 'start' : 'end'; + editor.selectionManager.activeNodeByNodeId(block.id, position); + } + }, + [editor, block] + ); + return ( - + {children} {showTriggerLine ? ( diff --git a/libs/components/editor-core/src/editor/scroll/scroll.ts b/libs/components/editor-core/src/editor/scroll/scroll.ts index 08f2b8ec16..2e3c8453e6 100644 --- a/libs/components/editor-core/src/editor/scroll/scroll.ts +++ b/libs/components/editor-core/src/editor/scroll/scroll.ts @@ -196,11 +196,11 @@ export class ScrollManager { private _getKeepInViewParams(blockRect: Rect) { if (this.scrollContainer == null) return 0; const { top, bottom } = domToRect(this._scrollContainer); - if (blockRect.top <= top + blockRect.height * 3) { + if (blockRect.top <= top + blockRect.height) { return -1; } - if (blockRect.bottom >= bottom - blockRect.height * 3) { + if (blockRect.bottom >= bottom - blockRect.height) { return 1; } return 0; diff --git a/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx b/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx index 9c339e8630..f3b8fa35a1 100644 --- a/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx +++ b/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx @@ -1,3 +1,4 @@ +import { containerFlavor } from '@toeverything/datasource/db-service'; import { BlockDropPlacement, HookType } from '@toeverything/framework/virgo'; import { domToRect, last, Point } from '@toeverything/utils'; import { StrictMode } from 'react'; @@ -9,7 +10,6 @@ import { LeftMenuDraggable, LineInfoSubject, } from './LeftMenuDraggable'; -import { ignoreBlockTypes } from './menu-config'; const DRAG_THROTTLE_DELAY = 60; export class LeftMenuPlugin extends BasePlugin { private _mousedown?: boolean; @@ -104,7 +104,7 @@ export class LeftMenuPlugin extends BasePlugin { const block = await this.editor.getBlockByPoint( new Point(event.clientX, event.clientY) ); - if (block == null || ignoreBlockTypes.includes(block.type)) return; + if (block == null || containerFlavor.includes(block.type)) return; const { direction, block: targetBlock } = await this.editor.dragDropManager.checkBlockDragTypes( event, @@ -143,7 +143,7 @@ export class LeftMenuPlugin extends BasePlugin { const node = await this.editor.getBlockByPoint( new Point(event.clientX, event.clientY) ); - if (node == null || ignoreBlockTypes.includes(node.type)) { + if (node == null || containerFlavor.includes(node.type)) { return; } if (node.dom) { diff --git a/libs/components/editor-plugins/src/menu/left-menu/menu-config.ts b/libs/components/editor-plugins/src/menu/left-menu/menu-config.ts index 0d107c15a8..d210c71a23 100644 --- a/libs/components/editor-plugins/src/menu/left-menu/menu-config.ts +++ b/libs/components/editor-plugins/src/menu/left-menu/menu-config.ts @@ -1,14 +1,14 @@ -import { BlockFlavorKeys, Protocol } from '@toeverything/datasource/db-service'; -import ShortTextIcon from '@mui/icons-material/ShortText'; -import TitleIcon from '@mui/icons-material/Title'; import FormatListBulletedIcon from '@mui/icons-material/FormatListBulleted'; import HorizontalRuleIcon from '@mui/icons-material/HorizontalRule'; +import ListIcon from '@mui/icons-material/List'; import NotificationsNoneIcon from '@mui/icons-material/NotificationsNone'; +import ShortTextIcon from '@mui/icons-material/ShortText'; +import TitleIcon from '@mui/icons-material/Title'; import { CodeBlockInlineIcon, PagesIcon, } from '@toeverything/components/common'; -import ListIcon from '@mui/icons-material/List'; +import { Protocol } from '@toeverything/datasource/db-service'; export const MENU_WIDTH = 14; export const pageConvertIconSize = 24; type MenuItem = { @@ -93,12 +93,3 @@ const textTypeBlocks: MenuItem[] = [ export const addMenuList = [...textTypeBlocks].filter(v => v); export const textConvertMenuList = textTypeBlocks; - -export const ignoreBlockTypes: BlockFlavorKeys[] = [ - Protocol.Block.Type.workspace, - Protocol.Block.Type.page, - Protocol.Block.Type.group, - Protocol.Block.Type.title, - Protocol.Block.Type.grid, - Protocol.Block.Type.gridItem, -]; diff --git a/libs/datasource/db-service/src/index.ts b/libs/datasource/db-service/src/index.ts index 3d4ffb01a9..c9e7cc2e86 100644 --- a/libs/datasource/db-service/src/index.ts +++ b/libs/datasource/db-service/src/index.ts @@ -42,6 +42,7 @@ export { type TemplateMeta, } from './services/editor-block/templates'; export type { Template } from './services/editor-block/templates/types'; +export { containerFlavor } from './services/editor-block/types'; export { DEFAULT_COLUMN_KEYS } from './services/editor-block/utils/column/default-config'; const api = new Proxy({} as DbServicesMap, { diff --git a/libs/datasource/db-service/src/services/editor-block/types.ts b/libs/datasource/db-service/src/services/editor-block/types.ts index e2bb7922b2..5c7ab2a2dd 100644 --- a/libs/datasource/db-service/src/services/editor-block/types.ts +++ b/libs/datasource/db-service/src/services/editor-block/types.ts @@ -4,6 +4,15 @@ import { Column, DefaultColumnsValue } from './utils/column'; export type BlockFlavors = typeof Protocol.Block.Type; export type BlockFlavorKeys = keyof typeof Protocol.Block.Type; +export const containerFlavor: BlockFlavorKeys[] = [ + Protocol.Block.Type.workspace, + Protocol.Block.Type.page, + Protocol.Block.Type.group, + Protocol.Block.Type.title, + Protocol.Block.Type.grid, + Protocol.Block.Type.gridItem, +]; + export interface CreateEditorBlock { workspace: string; type: keyof BlockFlavors;