mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-21 16:26:58 +08:00
feat(editor): add experimental feature citation (#11984)
Closes: [BS-3122](https://linear.app/affine-design/issue/BS-3122/footnote-definition-adapter-适配) Closes: [BS-3123](https://linear.app/affine-design/issue/BS-3123/几个-block-card-view-适配-footnote-态) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new citation card component and web element for displaying citations. - Added support for citation-style rendering in attachment, bookmark, and linked document blocks. - Enabled citation parsing from footnote definitions in markdown for attachments, bookmarks, and linked docs. - Added a feature flag to enable or disable citation features. - Provided new toolbar logic to disable downloads for citation-style attachments. - **Improvements** - Updated block models and properties to support citation identifiers. - Added localization and settings for the citation experimental feature. - Enhanced markdown adapters to recognize and process citation footnotes. - Included new constants and styles for citation card display. - **Bug Fixes** - Ensured readonly state is respected in block interactions and rendering for citation blocks. - **Documentation** - Added exports and effects for new citation components and features. - **Tests** - Updated snapshots to include citation-related properties in block data. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -55,6 +55,8 @@ export type AttachmentBlockProps = {
|
||||
embed: boolean | BackwardCompatibleUndefined;
|
||||
|
||||
style?: (typeof AttachmentBlockStyles)[number];
|
||||
|
||||
footnoteIdentifier: string | null;
|
||||
} & Omit<GfxCommonBlockProps, 'scale'> &
|
||||
BlockMeta;
|
||||
|
||||
@@ -74,6 +76,7 @@ export const defaultAttachmentProps: AttachmentBlockProps = {
|
||||
'meta:updatedAt': undefined,
|
||||
'meta:createdBy': undefined,
|
||||
'meta:updatedBy': undefined,
|
||||
footnoteIdentifier: null,
|
||||
};
|
||||
|
||||
export const AttachmentBlockSchema = defineBlockSchema({
|
||||
|
||||
@@ -20,12 +20,14 @@ export const BookmarkStyles: EmbedCardStyle[] = [
|
||||
'horizontal',
|
||||
'list',
|
||||
'cube',
|
||||
'citation',
|
||||
] as const;
|
||||
|
||||
export type BookmarkBlockProps = {
|
||||
style: (typeof BookmarkStyles)[number];
|
||||
url: string;
|
||||
caption: string | null;
|
||||
footnoteIdentifier: string | null;
|
||||
} & LinkPreviewData &
|
||||
Omit<GfxCommonBlockProps, 'scale'> &
|
||||
BlockMeta;
|
||||
@@ -48,6 +50,8 @@ const defaultBookmarkProps: BookmarkBlockProps = {
|
||||
'meta:updatedAt': undefined,
|
||||
'meta:createdBy': undefined,
|
||||
'meta:updatedBy': undefined,
|
||||
|
||||
footnoteIdentifier: null,
|
||||
};
|
||||
|
||||
export const BookmarkBlockSchema = defineBlockSchema({
|
||||
|
||||
@@ -10,11 +10,13 @@ export const EmbedLinkedDocStyles: EmbedCardStyle[] = [
|
||||
'list',
|
||||
'cube',
|
||||
'horizontalThin',
|
||||
'citation',
|
||||
];
|
||||
|
||||
export type EmbedLinkedDocBlockProps = {
|
||||
style: EmbedCardStyle;
|
||||
caption: string | null;
|
||||
footnoteIdentifier: string | null;
|
||||
} & ReferenceInfo;
|
||||
|
||||
export class EmbedLinkedDocModel extends defineEmbedModel<EmbedLinkedDocBlockProps>(
|
||||
|
||||
@@ -14,6 +14,8 @@ const defaultEmbedLinkedDocBlockProps: EmbedLinkedDocBlockProps = {
|
||||
// title & description aliases
|
||||
title: undefined,
|
||||
description: undefined,
|
||||
|
||||
footnoteIdentifier: null,
|
||||
};
|
||||
|
||||
export const EmbedLinkedDocBlockSchema = createEmbedBlockSchema({
|
||||
|
||||
@@ -17,7 +17,8 @@ export type EmbedCardStyle =
|
||||
| 'figma'
|
||||
| 'html'
|
||||
| 'syncedDoc'
|
||||
| 'pdf';
|
||||
| 'pdf'
|
||||
| 'citation';
|
||||
|
||||
export type LinkPreviewData = {
|
||||
description: string | null;
|
||||
|
||||
Reference in New Issue
Block a user