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.

Merge remote-tracking branch 'origin/develop' into fix/experience

DarkSky280fb4d8c7d9
diff --cc libs/components/affine-board/src/Board.tsx
index 5730649545,783c469b64..8c521705e7
--- a/libs/components/affine-board/src/Board.tsx
+++ b/libs/components/affine-board/src/Board.tsx
@@@ -66,11 -68,14 +65,14 @@@ const AffineBoard = (
onMount(app) {
set_app(app);
},
+ async onPaste(e, data) {
+ console.log('e,data: ', e, data);
+ },
async onCopy(e, groupIds) {
- const clip = await getClipDataOfBlocksById(
- editor,
- groupIds
- );
+ const clip =
+ await editor.clipboard.clipboardUtils.getClipDataOfBlocksById(
+ groupIds
+ );
e.clipboardData?.setData(
clip.getMimeType(),
diff --cc libs/components/editor-blocks/src/blocks/bullet/index.ts
index 212575da31,761aab03a1..3dc79c15dc
--- a/libs/components/editor-blocks/src/blocks/bullet/index.ts
+++ b/libs/components/editor-blocks/src/blocks/bullet/index.ts
@@@ -1,16 -1,17 +1,18 @@@
-import {
- DefaultColumnsValue,
- Protocol,
-} from '@toeverything/datasource/db-service';
++import { Protocol } from '@toeverything/datasource/db-service';
import {
AsyncBlock,
BaseView,
- getTextHtml,
- getTextProperties,
- SelectBlock,
+ BlockEditor,
+ HTML2BlockResult,
} from '@toeverything/framework/virgo';
- import { Protocol } from '@toeverything/datasource/db-service';
- import { defaultBulletProps, BulletView } from './BulletView';
-// import { withTreeViewChildren } from '../../utils/with-tree-view-children';
++
+import {
+ Block2HtmlProps,
+ commonBlock2HtmlContent,
+ commonHTML2block,
+} from '../../utils/commonBlockClip';
+ import { BulletView, defaultBulletProps } from './BulletView';
+
export class BulletBlock extends BaseView {
public type = Protocol.Block.Type.bullet;
diff --cc libs/components/editor-blocks/src/blocks/file/index.ts
index 42c2bee1f6,e3119e9a16..c2f12c0c6d
--- a/libs/components/editor-blocks/src/blocks/file/index.ts
+++ b/libs/components/editor-blocks/src/blocks/file/index.ts
@@@ -13,18 -12,22 +13,18 @@@ import { Block2HtmlProps } from '../../
export class FileBlock extends BaseView {
public override selectable = true;
- public override activatable = false;
+ public override editable = false;
type = Protocol.Block.Type.file;
View = FileView;
+ override async block2html({ block }: Block2HtmlProps) {
+ const fileProperty = block.getProperty('file');
+ const fileId = fileProperty?.value;
+ const fileInfo = fileId
+ ? await services.api.file.get(fileId, block.workspace)
+ : null;
- override async block2html(
- block: AsyncBlock,
- children: SelectBlock[],
- generateHtml: (el: any[]) => Promise<string>
- ): Promise<string> {
- const file_property =
- block.getProperty('file') || ({} as FileColumnValue);
- const file_id = file_property.value;
- let file_info = null;
- if (file_id) {
- file_info = await services.api.file.get(file_id, block.workspace);
- }
- return `<p><a src=${file_info?.url}>${file_property?.name}</p>`;
+ return fileInfo
+ ? `<p><a href=${fileInfo?.url}>${fileProperty?.name}</a></p>`
+ : '';
}
}
diff --cc libs/components/editor-blocks/src/blocks/numbered/index.ts
index 5c3f8a4e4e,92187be81b..6fd9d66837
--- a/libs/components/editor-blocks/src/blocks/numbered/index.ts
+++ b/libs/components/editor-blocks/src/blocks/numbered/index.ts
@@@ -1,16 -1,16 +1,16 @@@
-import {
- DefaultColumnsValue,
- Protocol,
-} from '@toeverything/datasource/db-service';
++import { Protocol } from '@toeverything/datasource/db-service';
import {
AsyncBlock,
BaseView,
- getTextHtml,
- getTextProperties,
- SelectBlock,
+ BlockEditor,
+ HTML2BlockResult,
} from '@toeverything/framework/virgo';
- import { Protocol } from '@toeverything/datasource/db-service';
- import { defaultTodoProps, NumberedView } from './NumberedView';
-// import { withTreeViewChildren } from '../../utils/with-tree-view-children';
+import {
+ Block2HtmlProps,
+ commonBlock2HtmlContent,
+ commonHTML2block,
+} from '../../utils/commonBlockClip';
+ import { defaultTodoProps, NumberedView } from './NumberedView';
export class NumberedBlock extends BaseView {
public type = Protocol.Block.Type.numbered;
diff --cc libs/components/editor-blocks/src/blocks/todo/index.ts
index 90b1dec4d9,78f317103a..7e973e68f3
--- a/libs/components/editor-blocks/src/blocks/todo/index.ts
+++ b/libs/components/editor-blocks/src/blocks/todo/index.ts
@@@ -1,17 -1,17 +1,18 @@@
++import { Protocol } from '@toeverything/datasource/db-service';
import {
- AsyncBlock,
BaseView,
- getTextHtml,
- getTextProperties,
- SelectBlock,
+ BlockEditor,
+ HTML2BlockResult,
+ withTreeViewChildren,
-} from '@toeverything/components/editor-core';
-import {
- DefaultColumnsValue,
- Protocol,
-} from '@toeverything/datasource/db-service';
+} from '@toeverything/framework/virgo';
- import { Protocol } from '@toeverything/datasource/db-service';
- import { withTreeViewChildren } from '../../utils/WithTreeViewChildren';
- import { TodoView, defaultTodoProps } from './TodoView';
- import type { TodoAsyncBlock } from './types';
+ import { defaultTodoProps, TodoView } from './TodoView';
++
+import {
+ Block2HtmlProps,
+ commonBlock2HtmlContent,
+ commonHTML2block,
+} from '../../utils/commonBlockClip';
+ import type { TodoAsyncBlock } from './types';
export class TodoBlock extends BaseView {
type = Protocol.Block.Type.todo;
diff --cc pnpm-lock.yaml
index 3b3c62870c,e9f182f211..2e59cde1a8
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@@ -454,12 -458,8 +458,10 @@@ importers
date-fns: ^2.28.0
eventemitter3: ^4.0.7
hotkeys-js: ^3.9.4
+ html-escaper: ^3.0.3
- i: ^0.3.7
lru-cache: ^7.10.1
+ marked: ^4.0.19
nanoid: ^4.0.0
- npm: ^8.18.0
slate: ^0.81.0
style9: ^0.13.3
dependencies:
@@@ -467,12 -467,8 +469,10 @@@
date-fns: 2.28.0
eventemitter3: 4.0.7
hotkeys-js: 3.9.4
+ html-escaper: 3.0.3
- i: 0.3.7
lru-cache: 7.12.0
+ marked: 4.0.19
nanoid: 4.0.0
- npm: 8.18.0
slate: 0.81.1
style9: 0.13.3