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, MARKDOWN_STYLE_MAP,
MatchRes, MatchRes,
} from './utils'; } from './utils';
import { AsyncBlock, SelectBlock } from '@toeverything/components/editor-core';
function isInlineAndVoid(editor: Editor, el: any) { function isInlineAndVoid(editor: Editor, el: any) {
return editor.isInline(el) && editor.isVoid(el); return editor.isInline(el) && editor.isVoid(el);

View File

@@ -26,7 +26,7 @@ export class BulletBlock extends BaseView {
} }
return block; return block;
} }
override async html2block2({ override async html2block({
element, element,
editor, editor,
}: { }: {
@@ -43,7 +43,7 @@ export class BulletBlock extends BaseView {
const childrenBlockInfos = ( const childrenBlockInfos = (
await Promise.all( await Promise.all(
children.map(childElement => children.map(childElement =>
this.html2block2({ this.html2block({
editor, editor,
element: childElement, element: childElement,
}) })

View File

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

View File

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

View File

@@ -15,7 +15,7 @@ export class ImageBlock extends BaseView {
View = ImageView; View = ImageView;
// TODO: needs to download the image and then upload it to get a new link and then assign it // 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, element,
editor, editor,
}: { }: {

View File

@@ -28,7 +28,7 @@ export class NumberedBlock extends BaseView {
return block; return block;
} }
override async html2block2({ override async html2block({
element, element,
editor, editor,
}: { }: {
@@ -40,7 +40,7 @@ export class NumberedBlock extends BaseView {
const childrenBlockInfos = ( const childrenBlockInfos = (
await Promise.all( await Promise.all(
children.map(childElement => children.map(childElement =>
this.html2block2({ this.html2block({
editor, editor,
element: childElement, element: childElement,
}) })

View File

@@ -30,7 +30,7 @@ export class QuoteBlock extends BaseView {
return block; return block;
} }
override async html2block2({ override async html2block({
element, element,
editor, editor,
}: { }: {
@@ -68,7 +68,7 @@ export class CalloutBlock extends BaseView {
return block; return block;
} }
override async html2block2({ override async html2block({
element, element,
editor, editor,
}: { }: {

View File

@@ -27,7 +27,7 @@ export class TextBlock extends BaseView {
return block; return block;
} }
override async html2block2({ override async html2block({
element, element,
editor, editor,
}: { }: {
@@ -67,7 +67,7 @@ export class Heading1Block extends BaseView {
} }
return block; return block;
} }
override async html2block2({ override async html2block({
element, element,
editor, editor,
}: { }: {
@@ -100,7 +100,7 @@ export class Heading2Block extends BaseView {
} }
return block; return block;
} }
override async html2block2({ override async html2block({
element, element,
editor, editor,
}: { }: {
@@ -134,7 +134,7 @@ export class Heading3Block extends BaseView {
return block; return block;
} }
override async html2block2({ override async html2block({
element, element,
editor, editor,
}: { }: {

View File

@@ -28,7 +28,7 @@ export class TodoBlock extends BaseView {
return block; return block;
} }
override async html2block2({ override async html2block({
element, element,
editor, editor,
}: { }: {
@@ -45,7 +45,7 @@ export class TodoBlock extends BaseView {
const childrenBlockInfos = ( const childrenBlockInfos = (
await Promise.all( await Promise.all(
children.map(childElement => children.map(childElement =>
this.html2block2({ this.html2block({
editor, editor,
element: childElement, element: childElement,
}) })

View File

@@ -11,11 +11,8 @@ import {
Selection as SlateSelection, Selection as SlateSelection,
} from 'slate'; } from 'slate';
import { Editor } from '../editor'; import { Editor } from '../editor';
import { import { AsyncBlock } from '../block';
AsyncBlock, import { SelectBlock } from '../selection';
SelectBlock,
SelectInfo,
} from '@toeverything/components/editor-core';
type TextUtilsFunctions = type TextUtilsFunctions =
| 'getString' | 'getString'
@@ -121,7 +118,7 @@ export class BlockHelper {
public async getFlatBlocksUnderParent( public async getFlatBlocksUnderParent(
parentBlockId: string, parentBlockId: string,
includeParent: boolean = false includeParent = false
): Promise<AsyncBlock[]> { ): Promise<AsyncBlock[]> {
const blocks = []; const blocks = [];
const block = await this._editor.getBlockById(parentBlockId); const block = await this._editor.getBlockById(parentBlockId);

View File

@@ -1,5 +1,5 @@
import { ClipboardEventDispatcher } from './clipboardEventDispatcher'; import { ClipboardEventDispatcher } from './clipboardEventDispatcher';
import { HookType } from '@toeverything/components/editor-core'; import { HookType } from '../types';
import { Editor } from '../editor'; import { Editor } from '../editor';
import { Copy } from './copy'; import { Copy } from './copy';
import { Paste } from './paste'; import { Paste } from './paste';

View File

@@ -1,9 +1,6 @@
import { Editor } from '../editor'; import { Editor } from '../editor';
import { import { SelectBlock, SelectInfo } from '../selection';
AsyncBlock, import { AsyncBlock } from '../block';
SelectBlock,
SelectInfo,
} from '@toeverything/components/editor-core';
import { ClipBlockInfo, OFFICE_CLIPBOARD_MIMETYPE } from './types'; import { ClipBlockInfo, OFFICE_CLIPBOARD_MIMETYPE } from './types';
import { Clip } from './clip'; import { Clip } from './clip';
import { commonHTML2Block, commonHTML2Text } from './utils'; import { commonHTML2Block, commonHTML2Text } from './utils';
@@ -14,7 +11,7 @@ export class ClipboardUtils {
this._editor = editor; this._editor = editor;
} }
shouldHandlerContinue = (event: ClipboardEvent) => { shouldHandlerContinue(event: ClipboardEvent) {
const filterNodes = ['INPUT', 'SELECT', 'TEXTAREA']; const filterNodes = ['INPUT', 'SELECT', 'TEXTAREA'];
if (event.defaultPrevented) { if (event.defaultPrevented) {
@@ -25,7 +22,7 @@ export class ClipboardUtils {
} }
return this._editor.selectionManager.currentSelectInfo.type !== 'None'; return this._editor.selectionManager.currentSelectInfo.type !== 'None';
}; }
async getClipInfoOfBlockById(blockId: string) { async getClipInfoOfBlockById(blockId: string) {
const block = await this._editor.getBlockById(blockId); const block = await this._editor.getBlockById(blockId);
@@ -160,7 +157,7 @@ export class ClipboardUtils {
const [clipBlockInfos] = ( const [clipBlockInfos] = (
await Promise.all( await Promise.all(
editableViews.map(editableView => { editableViews.map(editableView => {
return editableView?.html2block2?.({ return editableView?.html2block?.({
editor: this._editor, editor: this._editor,
element: element, element: element,
}); });
@@ -194,7 +191,7 @@ export class ClipboardUtils {
commonHTML2Text = commonHTML2Text; commonHTML2Text = commonHTML2Text;
textToBlock = (clipData: string = ''): ClipBlockInfo[] => { textToBlock(clipData = ''): ClipBlockInfo[] {
return clipData.split('\n').map((str: string) => { return clipData.split('\n').map((str: string) => {
return { return {
type: 'text', type: 'text',
@@ -204,7 +201,7 @@ export class ClipboardUtils {
children: [], children: [],
}; };
}); });
}; }
async page2html() { async page2html() {
const rootBlockId = this._editor.getRootBlockId(); 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 = const currentSelectInfo =
await this._editor.selectionManager.getSelectInfo(); 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' // 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 // Currently the selection does not support cross-blocking, so this case is not considered
if (currentSelectInfo.type === 'Range') { if (currentSelectInfo.type === 'Range') {

View File

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

View File

@@ -1,6 +1,6 @@
import { getRandomString } from '@toeverything/components/common'; import { getRandomString } from '@toeverything/components/common';
import { ClipBlockInfo } from '@toeverything/components/editor-core';
import { BlockFlavorKeys, Protocol } from '@toeverything/datasource/db-service'; import { BlockFlavorKeys, Protocol } from '@toeverything/datasource/db-service';
import { ClipBlockInfo } from './types';
const getIsLink = (htmlElement: HTMLElement) => { const getIsLink = (htmlElement: HTMLElement) => {
return ['A', 'IMG'].includes(htmlElement.tagName); return ['A', 'IMG'].includes(htmlElement.tagName);

View File

@@ -13,7 +13,7 @@ import HotKeys from 'hotkeys-js';
import type { WorkspaceAndBlockId } from './block'; import type { WorkspaceAndBlockId } from './block';
import { AsyncBlock } from './block'; import { AsyncBlock } from './block';
import { BlockHelper } from './block/block-helper'; import { BlockHelper } from './block/block-helper';
import { Clipboard } from './clipboard/clipboard'; import { Clipboard } from './clipboard';
import { EditorCommands } from './commands'; import { EditorCommands } from './commands';
import { EditorConfig } from './config'; import { EditorConfig } from './config';
import { DragDropManager } from './drag-drop'; import { DragDropManager } from './drag-drop';

View File

@@ -1,4 +1,3 @@
export { HTML2BlockResult, ClipBlockInfo } from './clipboard/types';
export { AsyncBlock } from './block'; export { AsyncBlock } from './block';
export * from './commands/types'; export * from './commands/types';
export { Editor as BlockEditor } from './editor'; 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 type { Plugin, PluginCreator, PluginHooks, Virgo } from './types';
export { BaseView } from './views/base-view'; export { BaseView } from './views/base-view';
export type { ChildrenView, CreateView } 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 { AsyncBlock } from '../block';
import type { Editor } from '../editor'; import type { Editor } from '../editor';
import { SelectBlock } from '../selection'; import { SelectBlock } from '../selection';
import { HTML2BlockResult } from '../clipboard/types'; import { HTML2BlockResult } from '../clipboard';
export interface CreateView { export interface CreateView {
block: AsyncBlock; block: AsyncBlock;
editor: Editor; editor: Editor;
@@ -125,11 +125,7 @@ export abstract class BaseView {
return result; return result;
} }
html2block(el: Element, parseEl: (el: Element) => any[]): any[] | null { async html2block(props: {
return null;
}
async html2block2(props: {
element: HTMLElement | Node; element: HTMLElement | Node;
editor: Editor; editor: Editor;
}): Promise<HTML2BlockResult> { }): Promise<HTML2BlockResult> {
@@ -144,7 +140,6 @@ export abstract class BaseView {
return ''; return '';
} }
// TODO: Try using new methods
async block2html(props: { async block2html(props: {
editor: Editor; editor: Editor;
block: AsyncBlock; block: AsyncBlock;