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(editor): editor layout add `min-width: 0` (#11642)

Inneiffb79fa753f8
diff --git a/src/app/[variants]/(main)/agent/profile/index.tsx b/src/app/[variants]/(main)/agent/profile/index.tsx
index d831ec750e3..9c30fb2dd7a 100644
--- a/src/app/[variants]/(main)/agent/profile/index.tsx
+++ b/src/app/[variants]/(main)/agent/profile/index.tsx
@@ -8,6 +8,7 @@ import AgentBuilder from '@/features/AgentBuilder';
import WideScreenContainer from '@/features/WideScreenContainer';
import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/selectors';
+import { StyleSheet } from '@/utils/styles';
import Header from './features/Header';
import ProfileEditor from './features/ProfileEditor';
@@ -15,13 +16,25 @@ import ProfileHydration from './features/ProfileHydration';
import ProfileProvider from './features/ProfileProvider';
import { useProfileStore } from './features/store';
+const styles = StyleSheet.create({
+ contentWrapper: {
+ cursor: 'text',
+ display: 'flex',
+ overflowY: 'auto',
+ position: 'relative',
+ },
+ profileArea: {
+ minWidth: 0,
+ },
+});
+
const ProfileArea = memo(() => {
const editor = useProfileStore((s) => s.editor);
const isAgentConfigLoading = useAgentStore(agentSelectors.isAgentConfigLoading);
return (
<>
- <Flexbox flex={1} height={'100%'}>
+ <Flexbox flex={1} height={'100%'} style={styles.profileArea}>
{isAgentConfigLoading ? (
<Loading debugId="ProfileArea" />
) : (
@@ -33,7 +46,7 @@ const ProfileArea = memo(() => {
onClick={() => {
editor?.focus();
}}
- style={{ cursor: 'text', display: 'flex', overflowY: 'auto', position: 'relative' }}
+ style={styles.contentWrapper}
width={'100%'}
>
<WideScreenContainer>
diff --git a/src/features/PageEditor/PageEditor.tsx b/src/features/PageEditor/PageEditor.tsx
index 47853baa6bf..112db959a51 100644
--- a/src/features/PageEditor/PageEditor.tsx
+++ b/src/features/PageEditor/PageEditor.tsx
@@ -15,6 +15,7 @@ import { builtinAgentSelectors } from '@/store/agent/selectors';
import { useDocumentStore } from '@/store/document';
import { editorSelectors } from '@/store/document/slices/editor';
import { usePageStore } from '@/store/page';
+import { StyleSheet } from '@/utils/styles';
import Copilot from './Copilot';
import EditorCanvas from './EditorCanvas';
@@ -25,6 +26,22 @@ import PageTitle from './PageTitle';
import TitleSection from './TitleSection';
import { usePageEditorStore } from './store';
+const styles = StyleSheet.create({
+ contentWrapper: {
+ display: 'flex',
+ overflowY: 'auto',
+ position: 'relative',
+ },
+ editorContainer: {
+ minWidth: 0,
+ position: 'relative',
+ },
+ editorContent: {
+ overflowY: 'auto',
+ position: 'relative',
+ },
+});
+
interface PageEditorProps {
emoji?: string;
knowledgeBaseId?: string;
@@ -77,16 +94,11 @@ const PageEditorCanvas = memo(() => {
style={{ backgroundColor: cssVar.colorBgContainer }}
width={'100%'}
>
- <Flexbox flex={1} height={'100%'} style={{ position: 'relative' }}>
+ <Flexbox flex={1} height={'100%'} style={styles.editorContainer}>
<Header />
- <Flexbox
- height={'100%'}
- horizontal
- style={{ display: 'flex', overflowY: 'auto', position: 'relative' }}
- width={'100%'}
- >
+ <Flexbox height={'100%'} horizontal style={styles.contentWrapper} width={'100%'}>
<WideScreenContainer onClick={() => editor?.focus()} wrapperStyle={{ cursor: 'text' }}>
- <Flexbox flex={1} style={{ overflowY: 'auto', position: 'relative' }}>
+ <Flexbox flex={1} style={styles.editorContent}>
<TitleSection />
<EditorCanvas />
</Flexbox>
diff --git a/src/utils/styles.ts b/src/utils/styles.ts
new file mode 100644
index 00000000000..1fd5de0beee
--- /dev/null
+++ b/src/utils/styles.ts
@@ -0,0 +1,10 @@
+import type { CSSProperties } from 'react';
+
+export const StyleSheet = {
+ compose: (...styles: Array<CSSProperties | undefined | null | false>): CSSProperties => {
+ return Object.assign({}, ...styles.filter(Boolean));
+ },
+ create: (styles: Record<string, CSSProperties>) => {
+ return styles;
+ },
+};