diff --git a/blocksuite/affine/all/src/__tests__/adapters/markdown.unit.spec.ts b/blocksuite/affine/all/src/__tests__/adapters/markdown.unit.spec.ts index b5531145eb..ad30d2741d 100644 --- a/blocksuite/affine/all/src/__tests__/adapters/markdown.unit.spec.ts +++ b/blocksuite/affine/all/src/__tests__/adapters/markdown.unit.spec.ts @@ -4393,6 +4393,61 @@ hhh }, children: [], }, + { + type: 'block', + id: 'matchesReplaceMap[2]', + flavour: 'affine:paragraph', + props: { + type: 'h6', + text: { + '$blocksuite:internal:text$': true, + delta: [ + { + insert: 'Sources', + }, + ], + }, + collapsed: true, + }, + children: [], + }, + { + type: 'block', + id: 'matchesReplaceMap[3]', + flavour: 'affine:bookmark', + props: { + style: 'citation', + url, + title, + description, + icon: favicon, + footnoteIdentifier: '1', + }, + children: [], + }, + { + type: 'block', + id: 'matchesReplaceMap[4]', + flavour: 'affine:embed-linked-doc', + props: { + style: 'citation', + pageId: 'deadbeef', + footnoteIdentifier: '2', + }, + children: [], + }, + { + type: 'block', + id: 'matchesReplaceMap[5]', + flavour: 'affine:attachment', + props: { + name: 'test.txt', + sourceId: 'abcdefg', + footnoteIdentifier: '3', + style: 'citation', + }, + children: [], + }, ], }; @@ -4469,6 +4524,38 @@ hhh }, children: [], }, + { + type: 'block', + id: 'matchesReplaceMap[2]', + flavour: 'affine:paragraph', + props: { + type: 'h6', + text: { + '$blocksuite:internal:text$': true, + delta: [ + { + insert: 'Sources', + }, + ], + }, + collapsed: true, + }, + children: [], + }, + { + type: 'block', + id: 'matchesReplaceMap[3]', + flavour: 'affine:bookmark', + props: { + style: 'citation', + url, + title, + description, + icon: favicon, + footnoteIdentifier: '1', + }, + children: [], + }, ], }; diff --git a/blocksuite/affine/blocks/attachment/src/adapters/markdown.ts b/blocksuite/affine/blocks/attachment/src/adapters/markdown.ts index 5f5e8537f5..a7ec4d0e54 100644 --- a/blocksuite/affine/blocks/attachment/src/adapters/markdown.ts +++ b/blocksuite/affine/blocks/attachment/src/adapters/markdown.ts @@ -10,7 +10,6 @@ import { isFootnoteDefinitionNode, type MarkdownAST, } from '@blocksuite/affine-shared/adapters'; -import { FeatureFlagService } from '@blocksuite/affine-shared/services'; import { nanoid } from '@blocksuite/store'; const isAttachmentFootnoteDefinitionNode = (node: MarkdownAST) => { @@ -36,15 +35,7 @@ export const attachmentBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatcher fromMatch: o => o.node.flavour === AttachmentBlockSchema.model.flavour, toBlockSnapshot: { enter: (o, context) => { - const { provider } = context; - let enableCitation = false; - try { - const featureFlagService = provider?.get(FeatureFlagService); - enableCitation = !!featureFlagService?.getFlag('enable_citation'); - } catch { - enableCitation = false; - } - if (!isFootnoteDefinitionNode(o.node) || !enableCitation) { + if (!isFootnoteDefinitionNode(o.node)) { return; } @@ -73,6 +64,7 @@ export const attachmentBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatcher name: fileName, sourceId: blobId, footnoteIdentifier, + style: 'citation', }, children: [], }, diff --git a/blocksuite/affine/blocks/bookmark/src/adapters/markdown/markdown.ts b/blocksuite/affine/blocks/bookmark/src/adapters/markdown/markdown.ts index 56dfc0d4be..604a759dce 100644 --- a/blocksuite/affine/blocks/bookmark/src/adapters/markdown/markdown.ts +++ b/blocksuite/affine/blocks/bookmark/src/adapters/markdown/markdown.ts @@ -10,7 +10,6 @@ import { isFootnoteDefinitionNode, type MarkdownAST, } from '@blocksuite/affine-shared/adapters'; -import { FeatureFlagService } from '@blocksuite/affine-shared/services'; import { nanoid } from '@blocksuite/store'; const isUrlFootnoteDefinitionNode = (node: MarkdownAST) => { @@ -33,15 +32,7 @@ export const bookmarkBlockMarkdownAdapterMatcher = toMatch: o => isUrlFootnoteDefinitionNode(o.node), toBlockSnapshot: { enter: (o, context) => { - const { provider } = context; - let enableCitation = false; - try { - const featureFlagService = provider?.get(FeatureFlagService); - enableCitation = !!featureFlagService?.getFlag('enable_citation'); - } catch { - enableCitation = false; - } - if (!isFootnoteDefinitionNode(o.node) || !enableCitation) { + if (!isFootnoteDefinitionNode(o.node)) { return; } diff --git a/blocksuite/affine/blocks/embed-doc/src/embed-linked-doc-block/adapters/markdown.ts b/blocksuite/affine/blocks/embed-doc/src/embed-linked-doc-block/adapters/markdown.ts index 1d405e5408..7258dc93e3 100644 --- a/blocksuite/affine/blocks/embed-doc/src/embed-linked-doc-block/adapters/markdown.ts +++ b/blocksuite/affine/blocks/embed-doc/src/embed-linked-doc-block/adapters/markdown.ts @@ -11,7 +11,6 @@ import { isFootnoteDefinitionNode, type MarkdownAST, } from '@blocksuite/affine-shared/adapters'; -import { FeatureFlagService } from '@blocksuite/affine-shared/services'; import { nanoid } from '@blocksuite/store'; const isLinkedDocFootnoteDefinitionNode = (node: MarkdownAST) => { @@ -36,15 +35,7 @@ export const embedLinkedDocBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatc fromMatch: o => o.node.flavour === EmbedLinkedDocBlockSchema.model.flavour, toBlockSnapshot: { enter: (o, context) => { - const { provider } = context; - let enableCitation = false; - try { - const featureFlagService = provider?.get(FeatureFlagService); - enableCitation = !!featureFlagService?.getFlag('enable_citation'); - } catch { - enableCitation = false; - } - if (!isFootnoteDefinitionNode(o.node) || !enableCitation) { + if (!isFootnoteDefinitionNode(o.node)) { return; } diff --git a/blocksuite/affine/blocks/note/src/adapters/markdown.ts b/blocksuite/affine/blocks/note/src/adapters/markdown.ts index a625bd5791..e62f58ce8a 100644 --- a/blocksuite/affine/blocks/note/src/adapters/markdown.ts +++ b/blocksuite/affine/blocks/note/src/adapters/markdown.ts @@ -6,7 +6,6 @@ import { isFootnoteDefinitionNode, type MarkdownAST, } from '@blocksuite/affine-shared/adapters'; -import { FeatureFlagService } from '@blocksuite/affine-shared/services'; import type { Root } from 'mdast'; const isRootNode = (node: MarkdownAST): node is Root => node.type === 'root'; @@ -66,34 +65,19 @@ const createNoteBlockMarkdownAdapterMatcher = ( } }); - const { provider } = context; - let enableCitation = false; - try { - const featureFlagService = provider?.get(FeatureFlagService); - enableCitation = !!featureFlagService?.getFlag('enable_citation'); - } catch { - enableCitation = false; - } - if (enableCitation) { - // if there are footnoteDefinition nodes, add a heading node to the noteAst before the first footnoteDefinition node - const footnoteDefinitionIndex = noteAst.children.findIndex(child => - isFootnoteDefinitionNode(child) - ); - if (footnoteDefinitionIndex !== -1) { - noteAst.children.splice(footnoteDefinitionIndex, 0, { - type: 'heading', - depth: 6, - data: { - collapsed: true, - }, - children: [{ type: 'text', value: 'Sources' }], - }); - } - } else { - // Remove the footnoteDefinition node from the noteAst - noteAst.children = noteAst.children.filter( - child => !isFootnoteDefinitionNode(child) - ); + // if there are footnoteDefinition nodes, add a heading node to the noteAst before the first footnoteDefinition node + const footnoteDefinitionIndex = noteAst.children.findIndex(child => + isFootnoteDefinitionNode(child) + ); + if (footnoteDefinitionIndex !== -1) { + noteAst.children.splice(footnoteDefinitionIndex, 0, { + type: 'heading', + depth: 6, + data: { + collapsed: true, + }, + children: [{ type: 'text', value: 'Sources' }], + }); } }, }, diff --git a/blocksuite/affine/shared/src/services/feature-flag-service.ts b/blocksuite/affine/shared/src/services/feature-flag-service.ts index 155b762c7f..3d41a43740 100644 --- a/blocksuite/affine/shared/src/services/feature-flag-service.ts +++ b/blocksuite/affine/shared/src/services/feature-flag-service.ts @@ -21,7 +21,6 @@ export interface BlockSuiteFlags { enable_table_virtual_scroll: boolean; enable_embed_doc_with_alias: boolean; enable_turbo_renderer: boolean; - enable_citation: boolean; enable_link_preview_cache: boolean; enable_dom_renderer: boolean; } @@ -49,7 +48,6 @@ export class FeatureFlagService extends StoreExtension { enable_table_virtual_scroll: false, enable_embed_doc_with_alias: false, enable_turbo_renderer: false, - enable_citation: false, enable_link_preview_cache: false, enable_dom_renderer: false, }); diff --git a/packages/frontend/core/src/modules/feature-flag/constant.ts b/packages/frontend/core/src/modules/feature-flag/constant.ts index 981049acf9..f0c162e3d4 100644 --- a/packages/frontend/core/src/modules/feature-flag/constant.ts +++ b/packages/frontend/core/src/modules/feature-flag/constant.ts @@ -106,16 +106,6 @@ 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_link_preview_cache: { category: 'blocksuite', bsFlag: 'enable_link_preview_cache', diff --git a/packages/frontend/i18n/src/i18n.gen.ts b/packages/frontend/i18n/src/i18n.gen.ts index fb82a13d13..578d8a2682 100644 --- a/packages/frontend/i18n/src/i18n.gen.ts +++ b/packages/frontend/i18n/src/i18n.gen.ts @@ -5778,14 +5778,6 @@ 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; /** * `Link Preview Cache` */ diff --git a/packages/frontend/i18n/src/resources/en.json b/packages/frontend/i18n/src/resources/en.json index 5d88d65e4d..bdec5d01e1 100644 --- a/packages/frontend/i18n/src/resources/en.json +++ b/packages/frontend/i18n/src/resources/en.json @@ -1443,8 +1443,6 @@ "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-link-preview-cache.name": "Link Preview Cache", "com.affine.settings.workspace.experimental-features.enable-link-preview-cache.description": "Once enabled, the link preview will be cached and cached data will be used when the same link is fetched again. Otherwise, the link preview will be fetched every time.", "com.affine.settings.workspace.experimental-features.enable-embed-iframe-block.name": "Embed Iframe Block",