From d7a5809861633defc082d1adc9c65ffad21fda06 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Mon, 1 Aug 2022 02:15:25 +0800 Subject: [PATCH] fix: rebase glitch --- Dockerfile-keck | 2 +- README.md | 1 - .../components/editor-core/src/RenderRoot.tsx | 5 ++ .../src/drag-drop-wrapper/DragDropWrapper.tsx | 1 + .../editor-core/src/editor/scroll/scroll.ts | 2 +- .../editor-core/src/recast-block/view.ts | 2 +- .../src/menu/command-menu/Container.tsx | 2 +- .../src/menu/inline-menu/Container.tsx | 55 ++++++++----------- libs/components/ui/src/tooltip/Tooltip.tsx | 2 +- libs/datasource/feature-flags/src/config.ts | 2 +- 10 files changed, 34 insertions(+), 40 deletions(-) diff --git a/Dockerfile-keck b/Dockerfile-keck index d464e16da0..598fded0ab 100644 --- a/Dockerfile-keck +++ b/Dockerfile-keck @@ -23,7 +23,7 @@ ENV FIREBASE_PROJECT= ENV HOST=0.0.0.0 ENV PORT=3000 -# 编码相关 +# coding ENV TZ 'Asia/Shanghai' ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en diff --git a/README.md b/README.md index 7d894c9fb2..147ed616eb 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,6 @@ Have a look at [the examples to see AFFiNE in action](https://app.affine.pro/). - [how-to-customize-rollup-config.md](docs/how-to-customize-rollup-config.md) - [how-to-auto-download-figma-assets-in-affine.md](docs/how-to-auto-download-figma-assets-in-affine.md) - [affine-icons-user-guide.md](docs/affine-icons-user-guide.md) -- [How to develop api server in virgo](./apps/keck/README.md) ## Community diff --git a/libs/components/editor-core/src/RenderRoot.tsx b/libs/components/editor-core/src/RenderRoot.tsx index 6d836ae1e8..06e0f22804 100644 --- a/libs/components/editor-core/src/RenderRoot.tsx +++ b/libs/components/editor-core/src/RenderRoot.tsx @@ -11,6 +11,7 @@ import { type ReturnUnobserve, } from '@toeverything/datasource/db-service'; import { addNewGroup } from './recast-block'; +import { useIsOnDrag } from './hooks'; interface RenderRootProps { editor: BlockEditor; @@ -133,6 +134,8 @@ export const RenderRoot: FC> = ({ }; const onDragOver = (event: React.DragEvent) => { + event.dataTransfer.dropEffect = 'move'; + event.preventDefault(); editor.dragDropManager.handlerEditorDragOver(event); if (editor.dragDropManager.isEnabled()) { editor.getHooks().onRootNodeDragOver(event); @@ -140,6 +143,7 @@ export const RenderRoot: FC> = ({ }; const onDragOverCapture = (event: React.DragEvent) => { + event.preventDefault(); if (editor.dragDropManager.isEnabled()) { editor.getHooks().onRootNodeDragOver(event); } @@ -177,6 +181,7 @@ export const RenderRoot: FC> = ({ onDragOverCapture={onDragOverCapture} onDragEnd={onDragEnd} onDrop={onDrop} + isOnDrag={isOnDrag} > {children} diff --git a/libs/components/editor-core/src/drag-drop-wrapper/DragDropWrapper.tsx b/libs/components/editor-core/src/drag-drop-wrapper/DragDropWrapper.tsx index 859fea03de..030c2b5c20 100644 --- a/libs/components/editor-core/src/drag-drop-wrapper/DragDropWrapper.tsx +++ b/libs/components/editor-core/src/drag-drop-wrapper/DragDropWrapper.tsx @@ -13,6 +13,7 @@ export function DragDropWrapper({ block, }: DragDropWrapperProps) { const handlerDragOver: React.DragEventHandler = event => { + event.preventDefault(); if (block.dom) { editor.getHooks().afterOnNodeDragOver(event, { blockId: block.id, diff --git a/libs/components/editor-core/src/editor/scroll/scroll.ts b/libs/components/editor-core/src/editor/scroll/scroll.ts index 81d50eb422..efe65e50c0 100644 --- a/libs/components/editor-core/src/editor/scroll/scroll.ts +++ b/libs/components/editor-core/src/editor/scroll/scroll.ts @@ -15,7 +15,7 @@ type ScrollController = { }; export class ScrollManager { - private _editor: Block_editor; + private _editor: BlockEditor; private _scrollContainer: HTMLElement; private _animationFrame: null | number = null; private _eventName = 'scrolling'; diff --git a/libs/components/editor-core/src/recast-block/view.ts b/libs/components/editor-core/src/recast-block/view.ts index c14ef93267..c41d09809e 100644 --- a/libs/components/editor-core/src/recast-block/view.ts +++ b/libs/components/editor-core/src/recast-block/view.ts @@ -143,7 +143,7 @@ export const useRecastView = () => { updateView, renameView, removeView, - // TODO reorder API + // TODO: reorder API withKanbanView, }; diff --git a/libs/components/editor-plugins/src/menu/command-menu/Container.tsx b/libs/components/editor-plugins/src/menu/command-menu/Container.tsx index cb56362892..70522d9b9c 100644 --- a/libs/components/editor-plugins/src/menu/command-menu/Container.tsx +++ b/libs/components/editor-plugins/src/menu/command-menu/Container.tsx @@ -192,7 +192,7 @@ export const CommandMenuContainer = ({ useEffect(() => { const sub = hooks .get(HookType.ON_ROOT_NODE_KEYDOWN_CAPTURE) - .subscribe(handle_key_down); + .subscribe(handleKeyDown); return () => { sub.unsubscribe(); diff --git a/libs/components/editor-plugins/src/menu/inline-menu/Container.tsx b/libs/components/editor-plugins/src/menu/inline-menu/Container.tsx index 99dfa797f3..3959d1c60b 100644 --- a/libs/components/editor-plugins/src/menu/inline-menu/Container.tsx +++ b/libs/components/editor-plugins/src/menu/inline-menu/Container.tsx @@ -34,6 +34,7 @@ export const InlineMenuContainer = ({ editor }: InlineMenuContainerProps) => { !editor.blockHelper.getCurrentSelection(anchorNode.id) || editor.blockHelper.isSelectionCollapsed(anchorNode.id) ) { + setShowMenu(false); return; } @@ -43,46 +44,34 @@ export const InlineMenuContainer = ({ editor }: InlineMenuContainerProps) => { setSelectionInfo(info); setShowMenu(true); setContainerStyle({ - left: rect.left - editor.container.getBoundingClientRect().left, - top: anchorNode.dom.offsetTop - 64, + left: rect.left - left, + top: rect.top - top - 64, }); }); return unsubscribe; }, [editor]); - useEffect(() => { - const hideInlineMenu = () => { - setShowMenu(false); - }; - editor.plugins.observe('hide-inline-menu', hideInlineMenu); - - return () => - editor.plugins.unobserve('hide-inline-menu', hideInlineMenu); - }, [editor.plugins]); - return showMenu && containerStyle ? ( - setShowMenu(false)}> - + { + // prevent toolbar from taking focus away from editor + e.preventDefault(); + e.stopPropagation(); + }} > - { - // prevent toolbar from taking focus away from editor - e.preventDefault(); - e.stopPropagation(); - }} - > - - - - + + + ) : null; }; diff --git a/libs/components/ui/src/tooltip/Tooltip.tsx b/libs/components/ui/src/tooltip/Tooltip.tsx index 0ae501dfba..2c896e5c0d 100644 --- a/libs/components/ui/src/tooltip/Tooltip.tsx +++ b/libs/components/ui/src/tooltip/Tooltip.tsx @@ -20,7 +20,7 @@ export const Tooltip = forwardRef< >((props, ref) => { const { content, placement = 'top-start' } = props; const style = useTooltipStyle(); - // 如果没有内容,则永远隐藏 + // If there is no content, hide forever const visibleProp = content ? {} : { visible: false }; return (