fix: lint error

This commit is contained in:
QiShaoXuan 2022-08-25 10:51:27 +08:00
parent 2e2d0b121b
commit 03c01985c2
19 changed files with 34 additions and 44 deletions

View File

@ -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);

View File

@ -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,
})

View File

@ -27,7 +27,7 @@ export class CodeBlock extends BaseView {
return block;
}
override async html2block2({
override async html2block({
element,
editor,
}: {

View File

@ -13,7 +13,7 @@ export class DividerBlock extends BaseView {
type = Protocol.Block.Type.divider;
View = DividerView;
override async html2block2({
override async html2block({
element,
editor,
}: {

View File

@ -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,
}: {

View File

@ -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,
})

View File

@ -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,
}: {

View File

@ -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,
}: {

View File

@ -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,
})

View File

@ -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);

View File

@ -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';

View File

@ -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();

View File

@ -0,0 +1,2 @@
export { HTML2BlockResult, ClipBlockInfo } from './types';
export { Clipboard } from './clipboard';

View File

@ -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 considered
if (currentSelectInfo.type === 'Range') {

View File

@ -1,7 +1,6 @@
import {
BlockFlavorKeys,
DefaultColumnsValue,
ReturnEditorBlock,
} from '@toeverything/datasource/db-service';
import { SelectInfo } from '../selection';

View File

@ -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);

View File

@ -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';

View File

@ -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';

View File

@ -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 methods
async block2html(props: {
editor: Editor;
block: AsyncBlock;