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:
donteatfriedrice
2025-04-29 06:59:27 +00:00
parent a326eac1bb
commit 83670ab335
58 changed files with 832 additions and 151 deletions

View File

@@ -121,10 +121,6 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
font-weight: 400;
}
.affine-paragraph-block-container {
line-height: 22px;
}
.ai-answer-text-editor {
.affine-note-block-container {
> .affine-block-children-container {
@@ -138,6 +134,23 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
}
}
}
.affine-paragraph-block-container {
line-height: 22px;
.h6 {
padding-left: 16px;
color: ${unsafeCSSVarV2('text/link')};
font-size: var(--affine-font-base);
.toggle-icon {
transform: translateX(0);
svg {
color: ${unsafeCSSVarV2('text/link')};
}
}
}
}
}
.text-renderer-container {
@@ -216,6 +229,9 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
'affine:list',
'affine:divider',
'affine:latex',
'affine:bookmark',
'affine:attachment',
'affine:embed-linked-doc',
].map(flavour => ({ flavour, viewType: 'display' })),
};

View File

@@ -105,6 +105,16 @@ export const AFFINE_FLAGS = {
configurable: isCanaryBuild,
defaultState: isCanaryBuild,
},
enable_citation: {
category: 'blocksuite',
bsFlag: 'enable_citation',
displayName:
'com.affine.settings.workspace.experimental-features.enable-citation.name',
description:
'com.affine.settings.workspace.experimental-features.enable-citation.description',
configurable: isCanaryBuild,
defaultState: isCanaryBuild,
},
enable_emoji_folder_icon: {
category: 'affine',

View File

@@ -5617,6 +5617,14 @@ export function useAFFiNEI18N(): {
* `Let your words stand out. This also include the callout in the transcription block.`
*/
["com.affine.settings.workspace.experimental-features.enable-callout.description"](): string;
/**
* `Citation`
*/
["com.affine.settings.workspace.experimental-features.enable-citation.name"](): string;
/**
* `Enable citation feature.`
*/
["com.affine.settings.workspace.experimental-features.enable-citation.description"](): string;
/**
* `Embed Iframe Block`
*/

View File

@@ -1402,6 +1402,8 @@
"com.affine.settings.workspace.experimental-features.enable-block-meta.description": "Once enabled, all blocks will have created time, updated time, created by and updated by.",
"com.affine.settings.workspace.experimental-features.enable-callout.name": "Callout",
"com.affine.settings.workspace.experimental-features.enable-callout.description": "Let your words stand out. This also include the callout in the transcription block.",
"com.affine.settings.workspace.experimental-features.enable-citation.name": "Citation",
"com.affine.settings.workspace.experimental-features.enable-citation.description": "Enable citation feature.",
"com.affine.settings.workspace.experimental-features.enable-embed-iframe-block.name": "Embed Iframe Block",
"com.affine.settings.workspace.experimental-features.enable-embed-iframe-block.description": "Enables Embed Iframe Block.",
"com.affine.settings.workspace.experimental-features.enable-emoji-folder-icon.name": "Emoji Folder Icon",