chore(editor): disable legacy validation (#9473)

This commit is contained in:
Saul-Mirone
2025-01-01 13:45:37 +00:00
parent 4b21dac4f8
commit 4be031b311
9 changed files with 16 additions and 120 deletions

View File

@@ -5,7 +5,6 @@ export interface BlockSuiteFlags {
enable_database_attachment_note: boolean; enable_database_attachment_note: boolean;
enable_database_full_width: boolean; enable_database_full_width: boolean;
enable_block_query: boolean; enable_block_query: boolean;
enable_legacy_validation: boolean;
enable_lasso_tool: boolean; enable_lasso_tool: boolean;
enable_edgeless_text: boolean; enable_edgeless_text: boolean;
enable_ai_onboarding: boolean; enable_ai_onboarding: boolean;
@@ -14,7 +13,6 @@ export interface BlockSuiteFlags {
enable_mind_map_import: boolean; enable_mind_map_import: boolean;
enable_advanced_block_visibility: boolean; enable_advanced_block_visibility: boolean;
enable_shape_shadow_blur: boolean; enable_shape_shadow_blur: boolean;
enable_new_dnd: boolean;
enable_mobile_keyboard_toolbar: boolean; enable_mobile_keyboard_toolbar: boolean;
enable_mobile_linked_doc_menu: boolean; enable_mobile_linked_doc_menu: boolean;
readonly: Record<string, boolean>; readonly: Record<string, boolean>;

View File

@@ -94,14 +94,12 @@ describe('basic', () => {
const options = createTestOptions(); const options = createTestOptions();
const collection = new DocCollection(options); const collection = new DocCollection(options);
collection.meta.initialize(); collection.meta.initialize();
assert.equal(collection.isEmpty, true);
const doc = collection.createDoc({ id: 'doc:home' }); const doc = collection.createDoc({ id: 'doc:home' });
doc.load(); doc.load();
const actual = serializCollection(collection.doc); const actual = serializCollection(collection.doc);
const actualDoc = actual[spaceMetaId].pages[0] as DocMeta; const actualDoc = actual[spaceMetaId].pages[0] as DocMeta;
assert.equal(collection.isEmpty, false);
assert.equal(typeof actualDoc.createDate, 'number'); assert.equal(typeof actualDoc.createDate, 'number');
// @ts-expect-error ignore // @ts-expect-error ignore
delete actualDoc.createDate; delete actualDoc.createDate;

View File

@@ -52,7 +52,6 @@ const FLAGS_PRESET = {
enable_database_number_formatting: false, enable_database_number_formatting: false,
enable_database_attachment_note: false, enable_database_attachment_note: false,
enable_database_full_width: false, enable_database_full_width: false,
enable_legacy_validation: true,
enable_block_query: false, enable_block_query: false,
enable_lasso_tool: false, enable_lasso_tool: false,
enable_edgeless_text: true, enable_edgeless_text: true,
@@ -62,7 +61,6 @@ const FLAGS_PRESET = {
enable_mind_map_import: false, enable_mind_map_import: false,
enable_advanced_block_visibility: false, enable_advanced_block_visibility: false,
enable_shape_shadow_blur: false, enable_shape_shadow_blur: false,
enable_new_dnd: true,
enable_mobile_keyboard_toolbar: false, enable_mobile_keyboard_toolbar: false,
enable_mobile_linked_doc_menu: false, enable_mobile_linked_doc_menu: false,
readonly: {}, readonly: {},
@@ -106,20 +104,6 @@ export class DocCollection {
return this.blockCollections; return this.blockCollections;
} }
get isEmpty() {
if (this.doc.store.clients.size === 0) return true;
let flag = false;
if (this.doc.store.clients.size === 1) {
const items = Array.from(this.doc.store.clients.values())[0];
// workspaceVersion and pageVersion were set when the collection is initialized
if (items.length <= 2) {
flag = true;
}
}
return flag;
}
get schema() { get schema() {
return this._schema; return this._schema;
} }

View File

@@ -252,11 +252,6 @@ export class BlockCollection {
// Initialization from empty yDoc, indicating that the document is new. // Initialization from empty yDoc, indicating that the document is new.
if (!this.collection.meta.hasVersion) { if (!this.collection.meta.hasVersion) {
this.collection.meta.writeVersion(this.collection); this.collection.meta.writeVersion(this.collection);
} else {
// Initialization from existing yDoc, indicating that the document is loaded from storage.
if (this.awarenessStore.getFlag('enable_legacy_validation')) {
this.collection.meta.validateVersion(this.collection);
}
} }
} }

View File

@@ -1,4 +1,3 @@
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { Slot } from '@blocksuite/global/utils'; import { Slot } from '@blocksuite/global/utils';
import type * as Y from 'yjs'; import type * as Y from 'yjs';
@@ -243,76 +242,6 @@ export class DocCollectionMeta {
this.docMetaUpdated.emit(); this.docMetaUpdated.emit();
} }
/**
* @deprecated Only used for legacy doc version validation
*/
validateVersion(collection: DocCollection) {
const workspaceVersion = this._proxy.workspaceVersion;
if (!workspaceVersion) {
throw new BlockSuiteError(
ErrorCode.DocCollectionError,
'Invalid workspace data, workspace version is missing. Please make sure the data is valid.'
);
}
if (workspaceVersion < COLLECTION_VERSION) {
throw new BlockSuiteError(
ErrorCode.DocCollectionError,
`Workspace version ${workspaceVersion} is outdated. Please upgrade the editor.`
);
}
const pageVersion = this._proxy.pageVersion;
if (!pageVersion) {
throw new BlockSuiteError(
ErrorCode.DocCollectionError,
'Invalid workspace data, page version is missing. Please make sure the data is valid.'
);
}
if (pageVersion < PAGE_VERSION) {
throw new BlockSuiteError(
ErrorCode.DocCollectionError,
`Doc version ${pageVersion} is outdated. Please upgrade the editor.`
);
}
const blockVersions = { ...this._proxy.blockVersions };
if (!blockVersions) {
throw new BlockSuiteError(
ErrorCode.DocCollectionError,
'Invalid workspace data, versions data is missing. Please make sure the data is valid'
);
}
const dataFlavours = Object.keys(blockVersions);
if (dataFlavours.length === 0) {
throw new BlockSuiteError(
ErrorCode.DocCollectionError,
'Invalid workspace data, missing versions field. Please make sure the data is valid.'
);
}
dataFlavours.forEach(dataFlavour => {
const dataVersion = blockVersions[dataFlavour] as number;
const editorVersion =
collection.schema.flavourSchemaMap.get(dataFlavour)?.version;
if (!editorVersion) {
throw new BlockSuiteError(
ErrorCode.DocCollectionError,
`Editor missing ${dataFlavour} flavour. Please make sure this block flavour is registered.`
);
} else if (dataVersion > editorVersion) {
throw new BlockSuiteError(
ErrorCode.DocCollectionError,
`Editor doesn't support ${dataFlavour}@${dataVersion}. Please upgrade the editor.`
);
} else if (dataVersion < editorVersion) {
throw new BlockSuiteError(
ErrorCode.DocCollectionError,
`In workspace data, the block flavour ${dataFlavour}@${dataVersion} is outdated. Please downgrade the editor or try data migration.`
);
}
});
}
/** /**
* @internal Only for doc initialization * @internal Only for doc initialization
*/ */

View File

@@ -16,16 +16,6 @@ export const AFFINE_FLAGS = {
configurable: true, configurable: true,
defaultState: true, defaultState: true,
}, },
enable_new_dnd: {
category: 'blocksuite',
bsFlag: 'enable_new_dnd',
displayName:
'com.affine.settings.workspace.experimental-features.enable-new-dnd.name',
description:
'com.affine.settings.workspace.experimental-features.enable-new-dnd.description',
configurable: false,
defaultState: true,
},
enable_database_full_width: { enable_database_full_width: {
category: 'blocksuite', category: 'blocksuite',
bsFlag: 'enable_database_full_width', bsFlag: 'enable_database_full_width',

View File

@@ -1,5 +1,5 @@
{ {
"ar": 68, "ar": 67,
"ca": 5, "ca": 5,
"da": 5, "da": 5,
"de": 26, "de": 26,
@@ -15,10 +15,10 @@
"ja": 90, "ja": 90,
"ko": 72, "ko": 72,
"pl": 0, "pl": 0,
"pt-BR": 78, "pt-BR": 77,
"ru": 66, "ru": 66,
"sv-SE": 4, "sv-SE": 4,
"ur": 2, "ur": 2,
"zh-Hans": 91, "zh-Hans": 90,
"zh-Hant": 90 "zh-Hant": 90
} }

View File

@@ -410,7 +410,7 @@ export function useAFFiNEI18N(): {
*/ */
Select(): string; Select(): string;
/** /**
* `Sign in AFFiNE Cloud` * `Sign in`
*/ */
["Sign in"](): string; ["Sign in"](): string;
/** /**
@@ -5119,14 +5119,6 @@ export function useAFFiNEI18N(): {
* `Enable or disable ALL AI features.` * `Enable or disable ALL AI features.`
*/ */
["com.affine.settings.workspace.experimental-features.enable-ai.description"](): string; ["com.affine.settings.workspace.experimental-features.enable-ai.description"](): string;
/**
* `Enable New DND`
*/
["com.affine.settings.workspace.experimental-features.enable-new-dnd.name"](): string;
/**
* `Enable new drag and drop features.`
*/
["com.affine.settings.workspace.experimental-features.enable-new-dnd.description"](): string;
/** /**
* `Database Full Width` * `Database Full Width`
*/ */
@@ -5303,6 +5295,14 @@ export function useAFFiNEI18N(): {
* `Once enabled, users can edit edgeless canvas.` * `Once enabled, users can edit edgeless canvas.`
*/ */
["com.affine.settings.workspace.experimental-features.enable-mobile-edgeless-editing.description"](): string; ["com.affine.settings.workspace.experimental-features.enable-mobile-edgeless-editing.description"](): string;
/**
* `PDF embed preview`
*/
["com.affine.settings.workspace.experimental-features.enable-pdf-embed-preview.name"](): string;
/**
* `Once enabled, you can preview PDF in embed view.`
*/
["com.affine.settings.workspace.experimental-features.enable-pdf-embed-preview.description"](): string;
/** /**
* `Only an owner can edit the workspace avatar and name. Changes will be shown for everyone.` * `Only an owner can edit the workspace avatar and name. Changes will be shown for everyone.`
*/ */
@@ -6477,6 +6477,10 @@ export function useAFFiNEI18N(): {
* `Got It` * `Got It`
*/ */
["com.affine.payment.sync-paused.member.member.confirm"](): string; ["com.affine.payment.sync-paused.member.member.confirm"](): string;
/**
* `Delete Server`
*/
["com.affine.server.delete"](): string;
} { const { t } = useTranslation(); return useMemo(() => createProxy((key) => t.bind(null, key)), [t]); } } { const { t } = useTranslation(); return useMemo(() => createProxy((key) => t.bind(null, key)), [t]); }
function createComponent(i18nKey: string) { function createComponent(i18nKey: string) {
return (props) => createElement(Trans, { i18nKey, shouldUnescape: true, ...props }); return (props) => createElement(Trans, { i18nKey, shouldUnescape: true, ...props });

View File

@@ -1277,8 +1277,6 @@
"com.affine.settings.workspace.experimental-features.prompt-warning-title": "WARNING MESSAGE", "com.affine.settings.workspace.experimental-features.prompt-warning-title": "WARNING MESSAGE",
"com.affine.settings.workspace.experimental-features.enable-ai.name": "Enable AI", "com.affine.settings.workspace.experimental-features.enable-ai.name": "Enable AI",
"com.affine.settings.workspace.experimental-features.enable-ai.description": "Enable or disable ALL AI features.", "com.affine.settings.workspace.experimental-features.enable-ai.description": "Enable or disable ALL AI features.",
"com.affine.settings.workspace.experimental-features.enable-new-dnd.name": "Enable New DND",
"com.affine.settings.workspace.experimental-features.enable-new-dnd.description": "Enable new drag and drop features.",
"com.affine.settings.workspace.experimental-features.enable-database-full-width.name": "Database Full Width", "com.affine.settings.workspace.experimental-features.enable-database-full-width.name": "Database Full Width",
"com.affine.settings.workspace.experimental-features.enable-database-full-width.description": "The database will be displayed in full-width mode.", "com.affine.settings.workspace.experimental-features.enable-database-full-width.description": "The database will be displayed in full-width mode.",
"com.affine.settings.workspace.experimental-features.enable-database-attachment-note.name": "Database Attachment Note", "com.affine.settings.workspace.experimental-features.enable-database-attachment-note.name": "Database Attachment Note",