From 6b7a6d648f58e0a6ce1f6b7a383b40d912241339 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Fri, 1 Apr 2022 12:13:23 +0800 Subject: [PATCH] refactor: format code --- packages/client/src/data/comment.ts | 2 +- packages/client/src/data/document.ts | 2 +- packages/client/src/data/message.ts | 2 +- packages/client/src/data/template.ts | 2 +- packages/client/src/data/user.tsx | 2 +- packages/client/src/data/wiki.tsx | 2 +- packages/client/src/services/document.ts | 2 +- packages/client/src/services/file.ts | 2 +- .../{HttpClient.tsx => http-client.tsx} | 0 packages/client/src/services/user.ts | 2 +- .../html-to-prosemirror/nodes/blockQuote.ts | 6 ---- .../html-to-prosemirror/nodes/blockquote.ts | 9 ++++++ .../nodes/{bulletList.ts => bullet-list.ts} | 0 ...eBlockWrapper.ts => code-block-wrapper.ts} | 0 .../nodes/{codeBlock.ts => code-block.ts} | 0 ...cumentChildren.ts => document-children.ts} | 0 ...mentReference.ts => document-reference.ts} | 0 .../nodes/{hardBreak.ts => hard-break.ts} | 0 .../{horizontalRule.ts => horizontal-rule.ts} | 0 .../nodes/{listItem.ts => list-item.ts} | 0 .../nodes/{orderedList.ts => ordered-list.ts} | 0 .../nodes/{tableCell.ts => table-cell.ts} | 0 .../nodes/{tableHeader.ts => table-header.ts} | 0 .../nodes/{tableRow.ts => table-row.ts} | 0 .../{taskListItem.ts => task-list-item.ts} | 0 .../nodes/{taskList.ts => task-list.ts} | 0 .../markdown/html-to-prosemirror/renderer.ts | 30 +++++++++---------- 27 files changed, 33 insertions(+), 30 deletions(-) rename packages/client/src/services/{HttpClient.tsx => http-client.tsx} (100%) create mode 100644 packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/blockquote.ts rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{bulletList.ts => bullet-list.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{codeBlockWrapper.ts => code-block-wrapper.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{codeBlock.ts => code-block.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{documentChildren.ts => document-children.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{documentReference.ts => document-reference.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{hardBreak.ts => hard-break.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{horizontalRule.ts => horizontal-rule.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{listItem.ts => list-item.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{orderedList.ts => ordered-list.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{tableCell.ts => table-cell.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{tableHeader.ts => table-header.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{tableRow.ts => table-row.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{taskListItem.ts => task-list-item.ts} (100%) rename packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/{taskList.ts => task-list.ts} (100%) diff --git a/packages/client/src/data/comment.ts b/packages/client/src/data/comment.ts index a520987..d2f6824 100644 --- a/packages/client/src/data/comment.ts +++ b/packages/client/src/data/comment.ts @@ -1,7 +1,7 @@ import type { IComment } from '@think/domains'; import { useState } from 'react'; import useSWR from 'swr'; -import { HttpClient } from 'services/HttpClient'; +import { HttpClient } from 'services/http-client'; export type CreateCommentDto = Pick; diff --git a/packages/client/src/data/document.ts b/packages/client/src/data/document.ts index ce1fdcd..6fb713a 100644 --- a/packages/client/src/data/document.ts +++ b/packages/client/src/data/document.ts @@ -2,7 +2,7 @@ import type { IUser, IDocument, IWiki } from '@think/domains'; import useSWR from 'swr'; import { useState, useCallback, useEffect } from 'react'; import { useAsyncLoading } from 'hooks/use-async-loading'; -import { HttpClient } from 'services/HttpClient'; +import { HttpClient } from 'services/http-client'; import { getPublicDocumentDetail } from 'services/document'; interface IAuthority { diff --git a/packages/client/src/data/message.ts b/packages/client/src/data/message.ts index b67ae00..6d2db7c 100644 --- a/packages/client/src/data/message.ts +++ b/packages/client/src/data/message.ts @@ -1,7 +1,7 @@ import type { IMessage } from '@think/domains'; import { useState } from 'react'; import useSWR from 'swr'; -import { HttpClient } from 'services/HttpClient'; +import { HttpClient } from 'services/http-client'; /** * 所有消息 diff --git a/packages/client/src/data/template.ts b/packages/client/src/data/template.ts index 1515a35..7c82612 100644 --- a/packages/client/src/data/template.ts +++ b/packages/client/src/data/template.ts @@ -1,7 +1,7 @@ import type { ITemplate } from '@think/domains'; import { useState } from 'react'; import useSWR from 'swr'; -import { HttpClient } from 'services/HttpClient'; +import { HttpClient } from 'services/http-client'; export const usePublicTemplates = () => { const [page, setPage] = useState(1); diff --git a/packages/client/src/data/user.tsx b/packages/client/src/data/user.tsx index b919935..2cf8099 100644 --- a/packages/client/src/data/user.tsx +++ b/packages/client/src/data/user.tsx @@ -2,7 +2,7 @@ import type { IUser, ILoginUser } from '@think/domains'; import useSWR from 'swr'; import { useCallback, useEffect } from 'react'; import Router, { useRouter } from 'next/router'; -import { HttpClient } from 'services/HttpClient'; +import { HttpClient } from 'services/http-client'; import { getStorage, setStorage } from 'helpers/storage'; export const useUser = () => { diff --git a/packages/client/src/data/wiki.tsx b/packages/client/src/data/wiki.tsx index d12d683..460c297 100644 --- a/packages/client/src/data/wiki.tsx +++ b/packages/client/src/data/wiki.tsx @@ -1,7 +1,7 @@ import { CollectType, IDocument, IUser, IWiki, IWikiUser } from '@think/domains'; import useSWR from 'swr'; import { useState } from 'react'; -import { HttpClient } from 'services/HttpClient'; +import { HttpClient } from 'services/http-client'; export type ICreateWiki = Pick; export type IUpdateWiki = Partial; diff --git a/packages/client/src/services/document.ts b/packages/client/src/services/document.ts index 3ef36e1..1aab461 100644 --- a/packages/client/src/services/document.ts +++ b/packages/client/src/services/document.ts @@ -1,5 +1,5 @@ import { IDocument, IUser, IWiki } from '@think/domains'; -import { HttpClient } from './HttpClient'; +import { HttpClient } from './http-client'; /** * 更新文档阅读量 diff --git a/packages/client/src/services/file.ts b/packages/client/src/services/file.ts index 028a4a7..c43fbf2 100644 --- a/packages/client/src/services/file.ts +++ b/packages/client/src/services/file.ts @@ -1,4 +1,4 @@ -import { HttpClient } from './HttpClient'; +import { HttpClient } from './http-client'; const ONE_MB = 1 * 1024 * 1024; diff --git a/packages/client/src/services/HttpClient.tsx b/packages/client/src/services/http-client.tsx similarity index 100% rename from packages/client/src/services/HttpClient.tsx rename to packages/client/src/services/http-client.tsx diff --git a/packages/client/src/services/user.ts b/packages/client/src/services/user.ts index d2bf7a0..bd8cb1d 100644 --- a/packages/client/src/services/user.ts +++ b/packages/client/src/services/user.ts @@ -1,5 +1,5 @@ import type { IUser } from '@think/domains'; -import { HttpClient } from './HttpClient'; +import { HttpClient } from './http-client'; export const register = (data: Partial): Promise => { return HttpClient.post('/user/register', data); diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/blockQuote.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/blockQuote.ts index 2724855..d4a61a5 100644 --- a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/blockQuote.ts +++ b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/blockQuote.ts @@ -6,10 +6,4 @@ export class Blockquote extends Node { matching() { return this.DOMNode.nodeName === 'BLOCKQUOTE'; } - - // data() { - // return { - // type: 'blockquote', - // }; - // } } diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/blockquote.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/blockquote.ts new file mode 100644 index 0000000..d4a61a5 --- /dev/null +++ b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/blockquote.ts @@ -0,0 +1,9 @@ +import { Node } from './node'; + +export class Blockquote extends Node { + type = 'blockquote'; + + matching() { + return this.DOMNode.nodeName === 'BLOCKQUOTE'; + } +} diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/bulletList.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/bullet-list.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/bulletList.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/bullet-list.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/codeBlockWrapper.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/code-block-wrapper.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/codeBlockWrapper.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/code-block-wrapper.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/codeBlock.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/code-block.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/codeBlock.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/code-block.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/documentChildren.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/document-children.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/documentChildren.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/document-children.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/documentReference.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/document-reference.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/documentReference.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/document-reference.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/hardBreak.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/hard-break.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/hardBreak.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/hard-break.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/horizontalRule.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/horizontal-rule.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/horizontalRule.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/horizontal-rule.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/listItem.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/list-item.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/listItem.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/list-item.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/orderedList.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/ordered-list.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/orderedList.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/ordered-list.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/tableCell.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/table-cell.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/tableCell.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/table-cell.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/tableHeader.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/table-header.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/tableHeader.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/table-header.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/tableRow.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/table-row.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/tableRow.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/table-row.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/taskListItem.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/task-list-item.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/taskListItem.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/task-list-item.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/taskList.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/task-list.ts similarity index 100% rename from packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/taskList.ts rename to packages/client/src/tiptap/services/markdown/html-to-prosemirror/nodes/task-list.ts diff --git a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/renderer.ts b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/renderer.ts index 5f33c11..5bd3a83 100644 --- a/packages/client/src/tiptap/services/markdown/html-to-prosemirror/renderer.ts +++ b/packages/client/src/tiptap/services/markdown/html-to-prosemirror/renderer.ts @@ -3,17 +3,17 @@ import { Iframe } from './nodes/iframe'; import { Attachment } from './nodes/attachment'; import { Banner } from './nodes/banner'; import { Status } from './nodes/status'; -import { DocumentReference } from './nodes/documentReference'; -import { DocumentChildren } from './nodes/documentChildren'; +import { DocumentReference } from './nodes/document-reference'; +import { DocumentChildren } from './nodes/document-children'; import { Mind } from './nodes/mind'; // 通用 -import { CodeBlock } from './nodes/codeBlock'; -import { CodeBlockWrapper } from './nodes/codeBlockWrapper'; -import { HardBreak } from './nodes/hardBreak'; +import { CodeBlock } from './nodes/code-block'; +import { CodeBlockWrapper } from './nodes/code-block-wrapper'; +import { HardBreak } from './nodes/hard-break'; import { Heading } from './nodes/heading'; import { Image } from './nodes/image'; -import { HorizontalRule } from './nodes/horizontalRule'; -import { Blockquote } from './nodes/blockQuote'; +import { HorizontalRule } from './nodes/horizontal-rule'; +import { Blockquote } from './nodes/blockquote'; // 文本 import { Title } from './nodes/title'; import { Katex } from './nodes/katex'; @@ -21,15 +21,15 @@ import { Paragraph } from './nodes/paragraph'; import { Text } from './nodes/text'; // 表格 import { Table } from './nodes/table'; -import { TableHeader } from './nodes/tableHeader'; -import { TableRow } from './nodes/tableRow'; -import { TableCell } from './nodes/tableCell'; +import { TableHeader } from './nodes/table-header'; +import { TableRow } from './nodes/table-row'; +import { TableCell } from './nodes/table-cell'; // 列表 -import { TaskList } from './nodes/taskList'; -import { TaskListItem } from './nodes/taskListItem'; -import { ListItem } from './nodes/listItem'; -import { OrderedList } from './nodes/orderedList'; -import { BulletList } from './nodes/bulletList'; +import { TaskList } from './nodes/task-list'; +import { TaskListItem } from './nodes/task-list-item'; +import { ListItem } from './nodes/list-item'; +import { OrderedList } from './nodes/ordered-list'; +import { BulletList } from './nodes/bullet-list'; // marks import { Bold } from './marks/bold';