mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 04:51:49 +08:00
feat: render document header image from document metadata (#14255)
### What Adds support for rendering an optional image above the document title using document metadata. ### Why Provides a visual identifier for documents and improves readability for users who rely on visual cues. ### How - Reads `headerImage` from document metadata (if present) - Renders the image above the editor when present - Fully optional and non-breaking - No BlockSuite or data model changes ### Related fix #14240 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Documents can now display header images in the page editor. When a header image is available, it appears above the editor content, enhancing visual presentation and providing better context for your documents. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -25,6 +25,10 @@ export interface PageDetailEditorProps {
|
|||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DocMetaWithHeaderImage = {
|
||||||
|
headerImage?: string;
|
||||||
|
};
|
||||||
|
|
||||||
export const PageDetailEditor = ({
|
export const PageDetailEditor = ({
|
||||||
onLoad,
|
onLoad,
|
||||||
readonly,
|
readonly,
|
||||||
@@ -34,6 +38,7 @@ export const PageDetailEditor = ({
|
|||||||
const defaultOpenProperty = useLiveData(editor.defaultOpenProperty$);
|
const defaultOpenProperty = useLiveData(editor.defaultOpenProperty$);
|
||||||
|
|
||||||
const doc = useService(DocService).doc;
|
const doc = useService(DocService).doc;
|
||||||
|
const docMeta = useLiveData(doc.meta$) as DocMetaWithHeaderImage | null;
|
||||||
const pageWidth = useLiveData(doc.properties$.selector(p => p.pageWidth));
|
const pageWidth = useLiveData(doc.properties$.selector(p => p.pageWidth));
|
||||||
|
|
||||||
const isSharedMode = editor.isSharedMode;
|
const isSharedMode = editor.isSharedMode;
|
||||||
@@ -54,17 +59,33 @@ export const PageDetailEditor = ({
|
|||||||
}, [editor, readonly]);
|
}, [editor, readonly]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BlockSuiteEditor
|
<>
|
||||||
className={clsx(styles.editor, {
|
{docMeta?.headerImage && (
|
||||||
'full-screen': !isSharedMode && fullWidthLayout,
|
<img
|
||||||
'is-public': isSharedMode,
|
src={docMeta.headerImage}
|
||||||
})}
|
alt="Document header"
|
||||||
mode={mode}
|
style={{
|
||||||
defaultOpenProperty={defaultOpenProperty}
|
width: '100%',
|
||||||
page={editor.doc.blockSuiteDoc}
|
maxHeight: 240,
|
||||||
shared={isSharedMode}
|
objectFit: 'cover',
|
||||||
readonly={readonly}
|
borderRadius: 8,
|
||||||
onEditorReady={onLoad}
|
marginBottom: 12,
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<BlockSuiteEditor
|
||||||
|
className={clsx(styles.editor, {
|
||||||
|
'full-screen': !isSharedMode && fullWidthLayout,
|
||||||
|
'is-public': isSharedMode,
|
||||||
|
})}
|
||||||
|
mode={mode}
|
||||||
|
defaultOpenProperty={defaultOpenProperty}
|
||||||
|
page={editor.doc.blockSuiteDoc}
|
||||||
|
shared={isSharedMode}
|
||||||
|
readonly={readonly}
|
||||||
|
onEditorReady={onLoad}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user