mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix: rebase glitch
This commit is contained in:
@@ -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<PropsWithChildren<RenderRootProps>> = ({
|
||||
};
|
||||
|
||||
const onDragOver = (event: React.DragEvent<Element>) => {
|
||||
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<PropsWithChildren<RenderRootProps>> = ({
|
||||
};
|
||||
|
||||
const onDragOverCapture = (event: React.DragEvent<Element>) => {
|
||||
event.preventDefault();
|
||||
if (editor.dragDropManager.isEnabled()) {
|
||||
editor.getHooks().onRootNodeDragOver(event);
|
||||
}
|
||||
@@ -177,6 +181,7 @@ export const RenderRoot: FC<PropsWithChildren<RenderRootProps>> = ({
|
||||
onDragOverCapture={onDragOverCapture}
|
||||
onDragEnd={onDragEnd}
|
||||
onDrop={onDrop}
|
||||
isOnDrag={isOnDrag}
|
||||
>
|
||||
<Content style={{ maxWidth: pageWidth + 'px' }}>
|
||||
{children}
|
||||
|
||||
@@ -13,6 +13,7 @@ export function DragDropWrapper({
|
||||
block,
|
||||
}: DragDropWrapperProps) {
|
||||
const handlerDragOver: React.DragEventHandler<HTMLDivElement> = event => {
|
||||
event.preventDefault();
|
||||
if (block.dom) {
|
||||
editor.getHooks().afterOnNodeDragOver(event, {
|
||||
blockId: block.id,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -143,7 +143,7 @@ export const useRecastView = () => {
|
||||
updateView,
|
||||
renameView,
|
||||
removeView,
|
||||
// TODO reorder API
|
||||
// TODO: reorder API
|
||||
|
||||
withKanbanView,
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 ? (
|
||||
<ClickAwayListener onClickAway={() => setShowMenu(false)}>
|
||||
<Grow
|
||||
in={showMenu}
|
||||
style={{ transformOrigin: '0 0 0' }}
|
||||
{...{ timeout: 'auto' }}
|
||||
<Grow
|
||||
in={showMenu}
|
||||
style={{ transformOrigin: '0 0 0' }}
|
||||
{...{ timeout: 'auto' }}
|
||||
>
|
||||
<ToolbarContainer
|
||||
style={containerStyle}
|
||||
onMouseDown={e => {
|
||||
// prevent toolbar from taking focus away from editor
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<ToolbarContainer
|
||||
style={containerStyle}
|
||||
onMouseDown={e => {
|
||||
// prevent toolbar from taking focus away from editor
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<InlineMenuToolbar
|
||||
editor={editor}
|
||||
selectionInfo={selectionInfo}
|
||||
setShow={setShowMenu}
|
||||
/>
|
||||
</ToolbarContainer>
|
||||
</Grow>
|
||||
</ClickAwayListener>
|
||||
<InlineMenuToolbar
|
||||
editor={editor}
|
||||
selectionInfo={selectionInfo}
|
||||
setShow={setShowMenu}
|
||||
/>
|
||||
</ToolbarContainer>
|
||||
</Grow>
|
||||
) : null;
|
||||
};
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<Popper
|
||||
|
||||
Reference in New Issue
Block a user