fix(core): cannot scroll when dragging (#6070)

close TOV-671
This commit is contained in:
JimmFly
2024-03-12 05:43:47 +00:00
parent eca35ded2f
commit f832ada98c
4 changed files with 27 additions and 26 deletions

View File

@@ -8,7 +8,6 @@ import {
PageEditor, PageEditor,
} from '@blocksuite/presets'; } from '@blocksuite/presets';
import { type Doc } from '@blocksuite/store'; import { type Doc } from '@blocksuite/store';
import clsx from 'clsx';
import React, { import React, {
forwardRef, forwardRef,
useCallback, useCallback,
@@ -103,10 +102,7 @@ export const BlocksuiteDocEditor = forwardRef<
return ( return (
<div className={styles.docEditorRoot}> <div className={styles.docEditorRoot}>
<div <div className={styles.affineDocViewport}>
className={clsx('affine-page-viewport', styles.affineDocViewport)}
data-doc-viewport={true}
>
{!isJournal ? ( {!isJournal ? (
<adapted.DocTitle doc={page} ref={titleRef} /> <adapted.DocTitle doc={page} ref={titleRef} />
) : ( ) : (

View File

@@ -5,28 +5,10 @@ export const docEditorRoot = style({
background: cssVar('backgroundPrimaryColor'), background: cssVar('backgroundPrimaryColor'),
}); });
// brings styles of .affine-page-viewport from blocksuite
export const affineDocViewport = style({ export const affineDocViewport = style({
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
userSelect: 'none', paddingBottom: '150px',
containerName: 'viewport',
// todo: find out what this does in bs
containerType: 'inline-size',
background: cssVar('backgroundPrimaryColor'),
'@media': {
print: {
display: 'none',
zIndex: -1,
},
},
selectors: {
'&[data-doc-viewport="true"]': {
overflowX: 'visible',
overflowY: 'visible',
height: 'auto',
},
},
}); });
export const docContainer = style({ export const docContainer = style({

View File

@@ -16,3 +16,19 @@ export const editorContainer = style({
flex: 1, flex: 1,
zIndex: 0, zIndex: 0,
}); });
// brings styles of .affine-page-viewport from blocksuite
export const affineDocViewport = style({
display: 'flex',
flexDirection: 'column',
userSelect: 'none',
containerName: 'viewport',
// todo: find out what this does in bs
containerType: 'inline-size',
background: cssVar('backgroundPrimaryColor'),
'@media': {
print: {
display: 'none',
zIndex: -1,
},
},
});

View File

@@ -22,6 +22,7 @@ import {
} from '@toeverything/infra'; } from '@toeverything/infra';
import { Workspace } from '@toeverything/infra'; import { Workspace } from '@toeverything/infra';
import { useService } from '@toeverything/infra'; import { useService } from '@toeverything/infra';
import clsx from 'clsx';
import { useSetAtom } from 'jotai'; import { useSetAtom } from 'jotai';
import { import {
memo, memo,
@@ -198,9 +199,15 @@ const DetailPageImpl = memo(function DetailPageImpl() {
<div className={styles.mainContainer}> <div className={styles.mainContainer}>
{/* Add a key to force rerender when page changed, to avoid error boundary persisting. */} {/* Add a key to force rerender when page changed, to avoid error boundary persisting. */}
<AffineErrorBoundary key={currentPageId}> <AffineErrorBoundary key={currentPageId}>
<TopTip pageId={currentPageId} workspace={currentWorkspace} />
<Scrollable.Root> <Scrollable.Root>
<Scrollable.Viewport className={styles.editorContainer}> <Scrollable.Viewport
<TopTip pageId={currentPageId} workspace={currentWorkspace} /> className={clsx(
'affine-page-viewport',
styles.affineDocViewport,
styles.editorContainer
)}
>
<PageDetailEditor <PageDetailEditor
pageId={currentPageId} pageId={currentPageId}
onLoad={onLoad} onLoad={onLoad}