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.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: lint error
QiShaoXuan03c01985c2d6
diff --git a/libs/components/common/src/lib/text/slate-utils.ts b/libs/components/common/src/lib/text/slate-utils.tsindex 1f3fd1fac2..f44d573e64 100644--- a/libs/components/common/src/lib/text/slate-utils.ts+++ b/libs/components/common/src/lib/text/slate-utils.ts@@ -25,7 +25,6 @@ import {MARKDOWN_STYLE_MAP,MatchRes,} from './utils';-import { AsyncBlock, SelectBlock } from '@toeverything/components/editor-core';function isInlineAndVoid(editor: Editor, el: any) {return editor.isInline(el) && editor.isVoid(el);diff --git a/libs/components/editor-blocks/src/blocks/bullet/index.ts b/libs/components/editor-blocks/src/blocks/bullet/index.tsindex 3dc79c15dc..6044fdb4a8 100644--- a/libs/components/editor-blocks/src/blocks/bullet/index.ts+++ b/libs/components/editor-blocks/src/blocks/bullet/index.ts@@ -26,7 +26,7 @@ export class BulletBlock extends BaseView {}return block;}- override async html2block2({+ override async html2block({element,editor,}: {@@ -43,7 +43,7 @@ export class BulletBlock extends BaseView {const childrenBlockInfos = (await Promise.all(children.map(childElement =>- this.html2block2({+ this.html2block({editor,element: childElement,})diff --git a/libs/components/editor-blocks/src/blocks/code/index.ts b/libs/components/editor-blocks/src/blocks/code/index.tsindex 23e87d9b7e..4239add745 100644--- a/libs/components/editor-blocks/src/blocks/code/index.ts+++ b/libs/components/editor-blocks/src/blocks/code/index.ts@@ -27,7 +27,7 @@ export class CodeBlock extends BaseView {return block;}- override async html2block2({+ override async html2block({element,editor,}: {diff --git a/libs/components/editor-blocks/src/blocks/divider/index.ts b/libs/components/editor-blocks/src/blocks/divider/index.tsindex 14f29b8807..f77722838f 100644--- a/libs/components/editor-blocks/src/blocks/divider/index.ts+++ b/libs/components/editor-blocks/src/blocks/divider/index.ts@@ -13,7 +13,7 @@ export class DividerBlock extends BaseView {type = Protocol.Block.Type.divider;View = DividerView;- override async html2block2({+ override async html2block({element,editor,}: {diff --git a/libs/components/editor-blocks/src/blocks/image/index.ts b/libs/components/editor-blocks/src/blocks/image/index.tsindex 2a649af50c..b170d44413 100644--- a/libs/components/editor-blocks/src/blocks/image/index.ts+++ b/libs/components/editor-blocks/src/blocks/image/index.ts@@ -15,7 +15,7 @@ export class ImageBlock extends BaseView {View = ImageView;// TODO: needs to download the image and then upload it to get a new link and then assign it- override async html2block2({+ override async html2block({element,editor,}: {diff --git a/libs/components/editor-blocks/src/blocks/numbered/index.ts b/libs/components/editor-blocks/src/blocks/numbered/index.tsindex 6fd9d66837..3dd6f74934 100644--- a/libs/components/editor-blocks/src/blocks/numbered/index.ts+++ b/libs/components/editor-blocks/src/blocks/numbered/index.ts@@ -28,7 +28,7 @@ export class NumberedBlock extends BaseView {return block;}- override async html2block2({+ override async html2block({element,editor,}: {@@ -40,7 +40,7 @@ export class NumberedBlock extends BaseView {const childrenBlockInfos = (await Promise.all(children.map(childElement =>- this.html2block2({+ this.html2block({editor,element: childElement,})diff --git a/libs/components/editor-blocks/src/blocks/text/QuoteBlock.tsx b/libs/components/editor-blocks/src/blocks/text/QuoteBlock.tsxindex 51f63e3dec..7789ec5f1c 100644--- a/libs/components/editor-blocks/src/blocks/text/QuoteBlock.tsx+++ b/libs/components/editor-blocks/src/blocks/text/QuoteBlock.tsx@@ -30,7 +30,7 @@ export class QuoteBlock extends BaseView {return block;}- override async html2block2({+ override async html2block({element,editor,}: {@@ -68,7 +68,7 @@ export class CalloutBlock extends BaseView {return block;}- override async html2block2({+ override async html2block({element,editor,}: {diff --git a/libs/components/editor-blocks/src/blocks/text/TextBlock.tsx b/libs/components/editor-blocks/src/blocks/text/TextBlock.tsxindex dbdf725129..7fb1fbd989 100644--- a/libs/components/editor-blocks/src/blocks/text/TextBlock.tsx+++ b/libs/components/editor-blocks/src/blocks/text/TextBlock.tsx@@ -27,7 +27,7 @@ export class TextBlock extends BaseView {return block;}- override async html2block2({+ override async html2block({element,editor,}: {@@ -67,7 +67,7 @@ export class Heading1Block extends BaseView {}return block;}- override async html2block2({+ override async html2block({element,editor,}: {@@ -100,7 +100,7 @@ export class Heading2Block extends BaseView {}return block;}- override async html2block2({+ override async html2block({element,editor,}: {@@ -134,7 +134,7 @@ export class Heading3Block extends BaseView {return block;}- override async html2block2({+ override async html2block({element,editor,}: {diff --git a/libs/components/editor-blocks/src/blocks/todo/index.ts b/libs/components/editor-blocks/src/blocks/todo/index.tsindex 7e973e68f3..e1de0300e4 100644--- a/libs/components/editor-blocks/src/blocks/todo/index.ts+++ b/libs/components/editor-blocks/src/blocks/todo/index.ts@@ -28,7 +28,7 @@ export class TodoBlock extends BaseView {return block;}- override async html2block2({+ override async html2block({element,editor,}: {@@ -45,7 +45,7 @@ export class TodoBlock extends BaseView {const childrenBlockInfos = (await Promise.all(children.map(childElement =>- this.html2block2({+ this.html2block({editor,element: childElement,})diff --git a/libs/components/editor-core/src/editor/block/block-helper.ts b/libs/components/editor-core/src/editor/block/block-helper.tsindex 5b672a6358..b9e7c12af9 100644--- a/libs/components/editor-core/src/editor/block/block-helper.ts+++ b/libs/components/editor-core/src/editor/block/block-helper.ts@@ -11,11 +11,8 @@ import {Selection as SlateSelection,} from 'slate';import { Editor } from '../editor';-import {- AsyncBlock,- SelectBlock,- SelectInfo,-} from '@toeverything/components/editor-core';+import { AsyncBlock } from '../block';+import { SelectBlock } from '../selection';type TextUtilsFunctions =| 'getString'@@ -121,7 +118,7 @@ export class BlockHelper {public async getFlatBlocksUnderParent(parentBlockId: string,- includeParent: boolean = false+ includeParent = false): Promise<AsyncBlock[]> {const blocks = [];const block = await this._editor.getBlockById(parentBlockId);diff --git a/libs/components/editor-core/src/editor/clipboard/clipboard.ts b/libs/components/editor-core/src/editor/clipboard/clipboard.tsindex 90865ebb38..e5e869ad1c 100644--- a/libs/components/editor-core/src/editor/clipboard/clipboard.ts+++ b/libs/components/editor-core/src/editor/clipboard/clipboard.ts@@ -1,5 +1,5 @@import { ClipboardEventDispatcher } from './clipboardEventDispatcher';-import { HookType } from '@toeverything/components/editor-core';+import { HookType } from '../types';import { Editor } from '../editor';import { Copy } from './copy';import { Paste } from './paste';diff --git a/libs/components/editor-core/src/editor/clipboard/clipboardUtils.ts b/libs/components/editor-core/src/editor/clipboard/clipboardUtils.tsindex 7a4f571c2c..09c532273c 100644--- a/libs/components/editor-core/src/editor/clipboard/clipboardUtils.ts+++ b/libs/components/editor-core/src/editor/clipboard/clipboardUtils.ts@@ -1,9 +1,6 @@import { Editor } from '../editor';-import {- AsyncBlock,- SelectBlock,- SelectInfo,-} from '@toeverything/components/editor-core';+import { SelectBlock, SelectInfo } from '../selection';+import { AsyncBlock } from '../block';import { ClipBlockInfo, OFFICE_CLIPBOARD_MIMETYPE } from './types';import { Clip } from './clip';import { commonHTML2Block, commonHTML2Text } from './utils';@@ -14,7 +11,7 @@ export class ClipboardUtils {this._editor = editor;}- shouldHandlerContinue = (event: ClipboardEvent) => {+ shouldHandlerContinue(event: ClipboardEvent) {const filterNodes = ['INPUT', 'SELECT', 'TEXTAREA'];if (event.defaultPrevented) {@@ -25,7 +22,7 @@ export class ClipboardUtils {}return this._editor.selectionManager.currentSelectInfo.type !== 'None';- };+ }async getClipInfoOfBlockById(blockId: string) {const block = await this._editor.getBlockById(blockId);@@ -160,7 +157,7 @@ export class ClipboardUtils {const [clipBlockInfos] = (await Promise.all(editableViews.map(editableView => {- return editableView?.html2block2?.({+ return editableView?.html2block?.({editor: this._editor,element: element,});@@ -194,7 +191,7 @@ export class ClipboardUtils {commonHTML2Text = commonHTML2Text;- textToBlock = (clipData: string = ''): ClipBlockInfo[] => {+ textToBlock(clipData = ''): ClipBlockInfo[] {return clipData.split('\n').map((str: string) => {return {type: 'text',@@ -204,7 +201,7 @@ export class ClipboardUtils {children: [],};});- };+ }async page2html() {const rootBlockId = this._editor.getRootBlockId();diff --git a/libs/components/editor-core/src/editor/clipboard/index.ts b/libs/components/editor-core/src/editor/clipboard/index.tsnew file mode 100644index 0000000000..41cf2aba32--- /dev/null+++ b/libs/components/editor-core/src/editor/clipboard/index.ts@@ -0,0 +1,2 @@+export { HTML2BlockResult, ClipBlockInfo } from './types';+export { Clipboard } from './clipboard';diff --git a/libs/components/editor-core/src/editor/clipboard/paste.ts b/libs/components/editor-core/src/editor/clipboard/paste.tsindex b621992837..926c3f88e1 100644--- a/libs/components/editor-core/src/editor/clipboard/paste.ts+++ b/libs/components/editor-core/src/editor/clipboard/paste.ts@@ -142,6 +142,7 @@ export class Paste {const currentSelectInfo =await this._editor.selectionManager.getSelectInfo();+ // TODO: Logic of insert blocks maybe should declare in blockHelper// When the selection is in one of the blocks, select?.type === 'Range'// Currently the selection does not support cross-blocking, so this case is not consideredif (currentSelectInfo.type === 'Range') {diff --git a/libs/components/editor-core/src/editor/clipboard/types.ts b/libs/components/editor-core/src/editor/clipboard/types.tsindex b8e6fc93d0..994554e6f0 100644--- a/libs/components/editor-core/src/editor/clipboard/types.ts+++ b/libs/components/editor-core/src/editor/clipboard/types.ts@@ -1,7 +1,6 @@import {BlockFlavorKeys,DefaultColumnsValue,- ReturnEditorBlock,} from '@toeverything/datasource/db-service';import { SelectInfo } from '../selection';diff --git a/libs/components/editor-core/src/editor/clipboard/utils.ts b/libs/components/editor-core/src/editor/clipboard/utils.tsindex 6c9df8523c..2478a5d722 100644--- a/libs/components/editor-core/src/editor/clipboard/utils.ts+++ b/libs/components/editor-core/src/editor/clipboard/utils.ts@@ -1,6 +1,6 @@import { getRandomString } from '@toeverything/components/common';-import { ClipBlockInfo } from '@toeverything/components/editor-core';import { BlockFlavorKeys, Protocol } from '@toeverything/datasource/db-service';+import { ClipBlockInfo } from './types';const getIsLink = (htmlElement: HTMLElement) => {return ['A', 'IMG'].includes(htmlElement.tagName);diff --git a/libs/components/editor-core/src/editor/editor.ts b/libs/components/editor-core/src/editor/editor.tsindex 11c03684b9..ed77d2fd40 100644--- a/libs/components/editor-core/src/editor/editor.ts+++ b/libs/components/editor-core/src/editor/editor.ts@@ -13,7 +13,7 @@ import HotKeys from 'hotkeys-js';import type { WorkspaceAndBlockId } from './block';import { AsyncBlock } from './block';import { BlockHelper } from './block/block-helper';-import { Clipboard } from './clipboard/clipboard';+import { Clipboard } from './clipboard';import { EditorCommands } from './commands';import { EditorConfig } from './config';import { DragDropManager } from './drag-drop';diff --git a/libs/components/editor-core/src/editor/index.ts b/libs/components/editor-core/src/editor/index.tsindex ed664b129f..55008f6608 100644--- a/libs/components/editor-core/src/editor/index.ts+++ b/libs/components/editor-core/src/editor/index.ts@@ -1,4 +1,3 @@-export { HTML2BlockResult, ClipBlockInfo } from './clipboard/types';export { AsyncBlock } from './block';export * from './commands/types';export { Editor as BlockEditor } from './editor';@@ -7,3 +6,4 @@ export { BlockDropPlacement, HookType, GroupDirection } from './types';export type { Plugin, PluginCreator, PluginHooks, Virgo } from './types';export { BaseView } from './views/base-view';export type { ChildrenView, CreateView } from './views/base-view';+export type { HTML2BlockResult, ClipBlockInfo } from './clipboard';diff --git a/libs/components/editor-core/src/editor/views/base-view.ts b/libs/components/editor-core/src/editor/views/base-view.tsindex 33dd6ef17a..ff6ab06098 100644--- a/libs/components/editor-core/src/editor/views/base-view.ts+++ b/libs/components/editor-core/src/editor/views/base-view.ts@@ -9,7 +9,7 @@ import type { EventData } from '../block';import { AsyncBlock } from '../block';import type { Editor } from '../editor';import { SelectBlock } from '../selection';-import { HTML2BlockResult } from '../clipboard/types';+import { HTML2BlockResult } from '../clipboard';export interface CreateView {block: AsyncBlock;editor: Editor;@@ -125,11 +125,7 @@ export abstract class BaseView {return result;}- html2block(el: Element, parseEl: (el: Element) => any[]): any[] | null {- return null;- }-- async html2block2(props: {+ async html2block(props: {element: HTMLElement | Node;editor: Editor;}): Promise<HTML2BlockResult> {@@ -144,7 +140,6 @@ export abstract class BaseView {return '';}- // TODO: Try using new methodsasync block2html(props: {editor: Editor;block: AsyncBlock;