Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

refactor(editor): remove legacy console formatter (#9599)

Yifeng Wang4f104578158e
diff --git a/blocksuite/playground/apps/default/main.ts b/blocksuite/playground/apps/default/main.ts
index a23da626d0..5ec6fbde8b 100644
--- a/blocksuite/playground/apps/default/main.ts
+++ b/blocksuite/playground/apps/default/main.ts
@@ -1,5 +1,4 @@
import '../../style.css';
-import '../dev-format.js';
import { effects as blocksEffects } from '@blocksuite/blocks/effects';
import { effects as presetsEffects } from '@blocksuite/presets/effects';
diff --git a/blocksuite/playground/apps/dev-format.ts b/blocksuite/playground/apps/dev-format.ts
deleted file mode 100644
index 63dfff1b31..0000000000
--- a/blocksuite/playground/apps/dev-format.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import * as globalUtils from '@blocksuite/global/utils';
-import type { BlockModel } from '@blocksuite/store';
-
-function toStyledEntry(key: string, value: unknown) {
- return [
- ['span', { style: 'color: #c0c0c0' }, ` ${key}`],
- ['span', { style: 'color: #fff' }, `: `],
- ['span', { style: 'color: rgb(92, 213, 251)' }, `${JSON.stringify(value)}`],
- ];
-}
-
-export const devtoolsFormatter: typeof window.devtoolsFormatters = [
- {
- header: function (obj: unknown) {
- if ('flavour' in (obj as BlockModel) && 'yBlock' in (obj as BlockModel)) {
- globalUtils.assertType<BlockModel>(obj);
- return [
- 'span',
- { style: 'font-weight: bolder;' },
- ['span', { style: 'color: #fff' }, `Block {`],
- ...toStyledEntry('flavour', obj.flavour),
- ['span', { style: 'color: #fff' }, `,`],
- ...toStyledEntry('id', obj.id),
- ['span', { style: 'color: #fff' }, `}`],
- ] as HTMLTemplate;
- }
-
- return null;
- },
- hasBody: (obj: unknown) => {
- if ('flavour' in (obj as BlockModel) && 'yBlock' in (obj as BlockModel)) {
- return true;
- }
-
- return null;
- },
- body: (obj: unknown) => {
- if ('flavour' in (obj as BlockModel) && 'yBlock' in (obj as BlockModel)) {
- globalUtils.assertType<BlockModel>(obj);
-
- // @ts-expect-error ignore
- const { props } = obj.page._blockTree.getBlock(obj.id)._parseYBlock();
-
- const propsArr = Object.entries(props).flatMap(([key]) => {
- return [
- // @ts-expect-error ignore
- ...toStyledEntry(key, obj[key]),
- ['div', {}, ''],
- ] as HTMLTemplate[];
- });
-
- return ['div', { style: 'padding-left: 1em' }, ...propsArr];
- }
-
- return null;
- },
- },
-];
-
-window.devtoolsFormatters = devtoolsFormatter;
diff --git a/blocksuite/playground/apps/env.d.ts b/blocksuite/playground/apps/env.d.ts
index 5b9296f7b6..1922372b8e 100644
--- a/blocksuite/playground/apps/env.d.ts
+++ b/blocksuite/playground/apps/env.d.ts
@@ -26,11 +26,5 @@ declare global {
wsProvider: ReturnType<typeof setupBroadcastProvider>;
bcProvider: ReturnType<typeof setupBroadcastProvider>;
-
- devtoolsFormatters: {
- header: (obj: unknown, config: unknown) => null | HTMLTemplate;
- hasBody: (obj: unknown, config: unknown) => boolean | null;
- body: (obj: unknown, config: unknown) => null | HTMLTemplate;
- }[];
}
}
diff --git a/blocksuite/playground/apps/starter/main.ts b/blocksuite/playground/apps/starter/main.ts
index 6805316b4f..4855f8d770 100644
--- a/blocksuite/playground/apps/starter/main.ts
+++ b/blocksuite/playground/apps/starter/main.ts
@@ -1,5 +1,4 @@
import '../../style.css';
-import '../dev-format.js';
import {
WidgetViewMapExtension,