Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(page-editor): align table bleed with controllers (#15588)

Innei69cefce3d912
diff --git a/package.json b/package.json
index 1624c97e83b..6cfa5b45f68 100644
--- a/package.json
+++ b/package.json
@@ -287,7 +287,7 @@
"@lobehub/analytics": "^1.6.2",
"@lobehub/charts": "^5.0.0",
"@lobehub/desktop-ipc-typings": "workspace:*",
- "@lobehub/editor": "^4.17.0",
+ "@lobehub/editor": "https://pkg.pr.new/@lobehub/editor@90f7402",
"@lobehub/icons": "^5.0.0",
"@lobehub/market-sdk": "0.34.0",
"@lobehub/tts": "^5.1.2",
diff --git a/src/features/PageEditor/PageEditor.tsx b/src/features/PageEditor/PageEditor.tsx
index 2fac7781975..15d6e4cf1ce 100644
--- a/src/features/PageEditor/PageEditor.tsx
+++ b/src/features/PageEditor/PageEditor.tsx
@@ -2,13 +2,16 @@
import { DEFAULT_BLOCK_ANCHOR_PADDING, EditorProvider } from '@lobehub/editor/react';
import { Flexbox } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import type { FC, ReactNode } from 'react';
+import { createStyles, cssVar } from 'antd-style';
+import type { CSSProperties, FC, ReactNode } from 'react';
import { memo } from 'react';
+import { CONVERSATION_MIN_WIDTH } from '@/const/layoutTokens';
import DiffAllToolbar from '@/features/EditorCanvas/DiffAllToolbar';
import WideScreenContainer from '@/features/WideScreenContainer';
import { useRegisterFilesHotkeys } from '@/hooks/useHotkeys';
+import { useGlobalStore } from '@/store/global';
+import { systemStatusSelectors } from '@/store/global/selectors';
import { usePageStore } from '@/store/page';
import { StyleSheet } from '@/utils/styles';
@@ -31,8 +34,12 @@ import TitleSection from './TitleSection';
*/
type PageEditorHeader = ReactNode | null;
+const WIDE_SCREEN_CONTAINER_PADDING = 16;
+const TABLE_BASE_BLEED = DEFAULT_BLOCK_ANCHOR_PADDING + WIDE_SCREEN_CONTAINER_PADDING;
+
const styles = StyleSheet.create({
contentWrapper: {
+ containerType: 'inline-size',
display: 'flex',
overflowY: 'auto',
position: 'relative',
@@ -47,6 +54,23 @@ const styles = StyleSheet.create({
},
});
+const useTableOverrideStyles = createStyles(({ css }) => ({
+ editorContent: css`
+ .lobe-editor-table-scroll-wrapper.lobe-editor-table-scroll-wrapper {
+ --lobe-block-anchor-padding: var(--lobe-pageeditor-table-bleed-inline);
+
+ position: relative;
+ box-sizing: border-box;
+ width: 100cqi;
+ margin-inline: calc(var(--lobe-pageeditor-table-bleed-inline) * -1);
+ }
+
+ .lobe-editor-table-scroll-wrapper .editor_table {
+ width: max-content;
+ }
+ `,
+}));
+
interface PageEditorProps {
emoji?: string;
/**
@@ -75,6 +99,15 @@ interface PageEditorCanvasProps {
const PageEditorCanvas = memo<PageEditorCanvasProps>(({ header, fullWidthHeader }) => {
const editor = usePageEditorStore((s) => s.editor);
const documentId = usePageEditorStore((s) => s.documentId);
+ const wideScreen = useGlobalStore(systemStatusSelectors.wideScreen);
+ const { styles: overrideStyles } = useTableOverrideStyles();
+ const tableBleedInline = wideScreen
+ ? `${TABLE_BASE_BLEED}px`
+ : `calc(${TABLE_BASE_BLEED}px + max((100cqi - ${CONVERSATION_MIN_WIDTH}px) / 2, 0px))`;
+ const editorContentStyle = {
+ ...styles.editorContent,
+ '--lobe-pageeditor-table-bleed-inline': tableBleedInline,
+ } as CSSProperties;
// Register Files scope and save document hotkey
useRegisterFilesHotkeys();
@@ -86,7 +119,7 @@ const PageEditorCanvas = memo<PageEditorCanvasProps>(({ header, fullWidthHeader
{!fullWidthHeader && headerSlot}
<Flexbox horizontal height={'100%'} style={styles.contentWrapper} width={'100%'}>
<WideScreenContainer wrapperStyle={{ cursor: 'text' }} onClick={() => editor?.focus()}>
- <Flexbox flex={1} style={styles.editorContent}>
+ <Flexbox className={overrideStyles.editorContent} flex={1} style={editorContentStyle}>
<TitleSection />
<EditorCanvas />
</Flexbox>