mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
chore(core): remove snapshot import export feature flag (#8865)
This commit is contained in:
@@ -8,6 +8,7 @@ import { UrlService } from '@affine/core/modules/url';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
import {
|
||||
HtmlTransformer,
|
||||
MarkdownTransformer,
|
||||
NotionHtmlTransformer,
|
||||
openFileOrFiles,
|
||||
@@ -15,24 +16,22 @@ import {
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import type { DocCollection } from '@blocksuite/affine/store';
|
||||
import {
|
||||
ExportToHtmlIcon,
|
||||
ExportToMarkdownIcon,
|
||||
HelpIcon,
|
||||
NotionIcon,
|
||||
PageIcon,
|
||||
ZipIcon,
|
||||
} from '@blocksuite/icons/rc';
|
||||
import {
|
||||
FeatureFlagService,
|
||||
useLiveData,
|
||||
useService,
|
||||
WorkspaceService,
|
||||
} from '@toeverything/infra';
|
||||
import { useService, WorkspaceService } from '@toeverything/infra';
|
||||
import { cssVar } from '@toeverything/theme';
|
||||
import { cssVarV2 } from '@toeverything/theme/v2';
|
||||
import { type ReactElement, useCallback, useState } from 'react';
|
||||
|
||||
import * as style from './styles.css';
|
||||
|
||||
type ImportType = 'markdown' | 'markdownZip' | 'notion' | 'snapshot';
|
||||
type AcceptType = 'Markdown' | 'Zip';
|
||||
type ImportType = 'markdown' | 'markdownZip' | 'notion' | 'snapshot' | 'html';
|
||||
type AcceptType = 'Markdown' | 'Zip' | 'Html';
|
||||
type Status = 'idle' | 'importing' | 'success' | 'error';
|
||||
type ImportResult = {
|
||||
docIds: string[];
|
||||
@@ -68,14 +67,31 @@ const importOptions = [
|
||||
key: 'markdownZip',
|
||||
label: 'com.affine.import.markdown-with-media-files',
|
||||
prefixIcon: (
|
||||
<ExportToMarkdownIcon
|
||||
<ZipIcon color={cssVarV2('icon/primary')} width={20} height={20} />
|
||||
),
|
||||
suffixIcon: (
|
||||
<HelpIcon color={cssVarV2('icon/primary')} width={20} height={20} />
|
||||
),
|
||||
suffixTooltip: 'com.affine.import.markdown-with-media-files.tooltip',
|
||||
testId: 'editor-option-menu-import-markdown-with-media',
|
||||
type: 'markdownZip' as ImportType,
|
||||
},
|
||||
{
|
||||
key: 'html',
|
||||
label: 'com.affine.import.html-files',
|
||||
prefixIcon: (
|
||||
<ExportToHtmlIcon
|
||||
color={cssVarV2('icon/primary')}
|
||||
width={20}
|
||||
height={20}
|
||||
/>
|
||||
),
|
||||
testId: 'editor-option-menu-import-markdown-with-media',
|
||||
type: 'markdownZip' as ImportType,
|
||||
suffixIcon: (
|
||||
<HelpIcon color={cssVarV2('icon/primary')} width={20} height={20} />
|
||||
),
|
||||
suffixTooltip: 'com.affine.import.html-files.tooltip',
|
||||
testId: 'editor-option-menu-import-html',
|
||||
type: 'html' as ImportType,
|
||||
},
|
||||
{
|
||||
key: 'notion',
|
||||
@@ -88,6 +104,15 @@ const importOptions = [
|
||||
testId: 'editor-option-menu-import-notion',
|
||||
type: 'notion' as ImportType,
|
||||
},
|
||||
{
|
||||
key: 'snapshot',
|
||||
label: 'com.affine.import.snapshot',
|
||||
prefixIcon: (
|
||||
<PageIcon color={cssVarV2('icon/primary')} width={20} height={20} />
|
||||
),
|
||||
testId: 'editor-option-menu-import-snapshot',
|
||||
type: 'snapshot' as ImportType,
|
||||
},
|
||||
];
|
||||
|
||||
const importConfigs: Record<ImportType, ImportConfig> = {
|
||||
@@ -128,6 +153,28 @@ const importConfigs: Record<ImportType, ImportConfig> = {
|
||||
};
|
||||
},
|
||||
},
|
||||
html: {
|
||||
fileOptions: { acceptType: 'Html', multiple: true },
|
||||
importFunction: async (docCollection, files) => {
|
||||
if (!Array.isArray(files)) {
|
||||
throw new Error('Expected an array of files for html files import');
|
||||
}
|
||||
const docIds: string[] = [];
|
||||
for (const file of files) {
|
||||
const text = await file.text();
|
||||
const fileName = file.name.split('.').slice(0, -1).join('.');
|
||||
const docId = await HtmlTransformer.importHTMLToDoc({
|
||||
collection: docCollection,
|
||||
html: text,
|
||||
fileName,
|
||||
});
|
||||
if (docId) docIds.push(docId);
|
||||
}
|
||||
return {
|
||||
docIds,
|
||||
};
|
||||
},
|
||||
},
|
||||
notion: {
|
||||
fileOptions: { acceptType: 'Zip', multiple: false },
|
||||
importFunction: async (docCollection, file) => {
|
||||
@@ -200,10 +247,6 @@ const ImportOptions = ({
|
||||
onImport: (type: ImportType) => void;
|
||||
}) => {
|
||||
const t = useI18n();
|
||||
const featureFlagService = useService(FeatureFlagService);
|
||||
const enableSnapshotImportExport = useLiveData(
|
||||
featureFlagService.flags.enable_snapshot_import_export.$
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -232,14 +275,6 @@ const ImportOptions = ({
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
{enableSnapshotImportExport && (
|
||||
<div className={style.importModalTip}>
|
||||
{t['Import']()}{' '}
|
||||
<span className={style.link} onClick={() => onImport('snapshot')}>
|
||||
{t['Snapshot']()}.
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<div className={style.importModalTip}>
|
||||
{t['com.affine.import.modal.tip']()}{' '}
|
||||
<a
|
||||
@@ -373,6 +408,9 @@ export const ImportDialog = ({
|
||||
docCount: docIds.length,
|
||||
},
|
||||
});
|
||||
track.$.importModal.$.createDoc({
|
||||
control: 'import',
|
||||
});
|
||||
} catch (error) {
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : 'Unknown error occurred';
|
||||
|
||||
@@ -10,11 +10,7 @@ import { appIconMap, appNames } from '@affine/core/utils/channel';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { mixpanel } from '@affine/track';
|
||||
import { ArrowRightSmallIcon, OpenInNewIcon } from '@blocksuite/icons/rc';
|
||||
import {
|
||||
FeatureFlagService,
|
||||
useLiveData,
|
||||
useServices,
|
||||
} from '@toeverything/infra';
|
||||
import { useServices } from '@toeverything/infra';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { useAppSettingHelper } from '../../../../../components/hooks/affine/use-app-setting-helper';
|
||||
@@ -29,13 +25,9 @@ export const AboutAffine = () => {
|
||||
const channel = BUILD_CONFIG.appBuildType;
|
||||
const appIcon = appIconMap[channel];
|
||||
const appName = appNames[channel];
|
||||
const { urlService, featureFlagService } = useServices({
|
||||
const { urlService } = useServices({
|
||||
UrlService,
|
||||
FeatureFlagService,
|
||||
});
|
||||
const enableSnapshotImportExport = useLiveData(
|
||||
featureFlagService.flags.enable_snapshot_import_export.$
|
||||
);
|
||||
|
||||
const onSwitchAutoCheck = useCallback(
|
||||
(checked: boolean) => {
|
||||
@@ -65,13 +57,6 @@ export const AboutAffine = () => {
|
||||
[updateSettings]
|
||||
);
|
||||
|
||||
const onSwitchSnapshotImportExport = useCallback(
|
||||
(checked: boolean) => {
|
||||
featureFlagService.flags.enable_snapshot_import_export.set(checked);
|
||||
},
|
||||
[featureFlagService]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<SettingHeader
|
||||
@@ -155,16 +140,6 @@ export const AboutAffine = () => {
|
||||
{t['com.affine.aboutAFFiNE.contact.community']()}
|
||||
<OpenInNewIcon className="icon" />
|
||||
</a>
|
||||
<SettingRow
|
||||
name={t['com.affine.snapshot.import-export.enable']()}
|
||||
desc={t['com.affine.snapshot.import-export.enable.desc']()}
|
||||
className={styles.snapshotImportExportRow}
|
||||
>
|
||||
<Switch
|
||||
checked={enableSnapshotImportExport}
|
||||
onChange={onSwitchSnapshotImportExport}
|
||||
/>
|
||||
</SettingRow>
|
||||
</SettingWrapper>
|
||||
<SettingWrapper title={t['com.affine.aboutAFFiNE.community.title']()}>
|
||||
<div className={styles.communityWrapper}>
|
||||
|
||||
Reference in New Issue
Block a user