mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
feat(editor): add feature flag service (#9592)
This commit is contained in:
@@ -860,22 +860,6 @@ describe('getBlock', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('flags', () => {
|
||||
it('update flags', () => {
|
||||
const options = createTestOptions();
|
||||
const collection = new TestWorkspace(options);
|
||||
collection.meta.initialize();
|
||||
|
||||
const awareness = collection.awarenessStore;
|
||||
|
||||
awareness.setFlag('enable_lasso_tool', false);
|
||||
expect(awareness.getFlag('enable_lasso_tool')).toBe(false);
|
||||
|
||||
awareness.setFlag('enable_lasso_tool', true);
|
||||
expect(awareness.getFlag('enable_lasso_tool')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface BlockModels {
|
||||
|
||||
@@ -688,4 +688,12 @@ export class Store {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
get get() {
|
||||
return this.provider.get.bind(this.provider);
|
||||
}
|
||||
|
||||
get getOptional() {
|
||||
return this.provider.getOptional.bind(this.provider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { Doc, GetBlocksOptions, Workspace } from '../model/index.js';
|
||||
import type { Query } from '../model/store/query.js';
|
||||
import { Store } from '../model/store/store.js';
|
||||
import type { AwarenessStore } from '../yjs/index.js';
|
||||
import type { TestWorkspace } from './test-workspace.js';
|
||||
|
||||
type DocOptions = {
|
||||
id: string;
|
||||
@@ -294,7 +295,9 @@ export class TestDoc implements Doc {
|
||||
readonly,
|
||||
query,
|
||||
provider,
|
||||
extensions,
|
||||
extensions: (this.workspace as TestWorkspace).storeExtensions.concat(
|
||||
extensions ?? []
|
||||
),
|
||||
});
|
||||
|
||||
this._docMap[readonlyKey].set(key, doc);
|
||||
|
||||
@@ -16,6 +16,7 @@ import merge from 'lodash.merge';
|
||||
import { Awareness } from 'y-protocols/awareness.js';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
import type { ExtensionType } from '../extension/extension.js';
|
||||
import type {
|
||||
CreateBlocksOptions,
|
||||
GetBlocksOptions,
|
||||
@@ -46,22 +47,6 @@ export type DocCollectionOptions = {
|
||||
};
|
||||
|
||||
const FLAGS_PRESET = {
|
||||
enable_synced_doc_block: false,
|
||||
enable_pie_menu: false,
|
||||
enable_database_number_formatting: false,
|
||||
enable_database_attachment_note: false,
|
||||
enable_database_full_width: false,
|
||||
enable_block_query: false,
|
||||
enable_lasso_tool: false,
|
||||
enable_edgeless_text: true,
|
||||
enable_ai_onboarding: false,
|
||||
enable_ai_chat_block: false,
|
||||
enable_color_picker: false,
|
||||
enable_mind_map_import: false,
|
||||
enable_advanced_block_visibility: false,
|
||||
enable_shape_shadow_blur: false,
|
||||
enable_mobile_keyboard_toolbar: false,
|
||||
enable_mobile_linked_doc_menu: false,
|
||||
readonly: {},
|
||||
} satisfies BlockSuiteFlags;
|
||||
|
||||
@@ -72,6 +57,8 @@ const FLAGS_PRESET = {
|
||||
export class TestWorkspace implements Workspace {
|
||||
protected readonly _schema: Schema;
|
||||
|
||||
storeExtensions: ExtensionType[] = [];
|
||||
|
||||
readonly awarenessStore: AwarenessStore;
|
||||
|
||||
readonly awarenessSync: AwarenessEngine;
|
||||
|
||||
Reference in New Issue
Block a user