diff --git a/packages/client/.eslintrc.js b/packages/client/.eslintrc.js index 47ca066..1646ab3 100644 --- a/packages/client/.eslintrc.js +++ b/packages/client/.eslintrc.js @@ -54,7 +54,21 @@ module.exports = { 'react/react-in-jsx-scope': 'off', 'react/prop-types': 'off', '@typescript-eslint/explicit-function-return-type': 'off', - 'simple-import-sort/imports': 'error', + 'simple-import-sort/imports': [ + 'error', + { + groups: [ + ['react'], + ['@douyinfe(.*)$'], + ['(@)?think(.*)$'], + ['(@)?tiptap(.*)$'], + ['^@?\\w'], + ['@/(.*)'], + ['^[./]'], + ['(.*).module.scss'], + ], + }, + ], 'simple-import-sort/exports': 'error', }, ignorePatterns: ['dist/', 'node_modules', 'scripts', 'examples'], diff --git a/packages/client/src/components/admin/system-config/index.tsx b/packages/client/src/components/admin/system-config/index.tsx index c1b12c9..8cc4228 100644 --- a/packages/client/src/components/admin/system-config/index.tsx +++ b/packages/client/src/components/admin/system-config/index.tsx @@ -1,6 +1,7 @@ -import { TabPane, Tabs } from '@douyinfe/semi-ui'; import React from 'react'; +import { TabPane, Tabs } from '@douyinfe/semi-ui'; + import { Mail } from './mail'; import { System } from './system'; diff --git a/packages/client/src/components/admin/system-config/mail/index.tsx b/packages/client/src/components/admin/system-config/mail/index.tsx index 83b84ec..968dae5 100644 --- a/packages/client/src/components/admin/system-config/mail/index.tsx +++ b/packages/client/src/components/admin/system-config/mail/index.tsx @@ -1,8 +1,10 @@ +import React, { useCallback } from 'react'; + import { Banner, Button, Form, Toast } from '@douyinfe/semi-ui'; + import { DataRender } from 'components/data-render'; import { useSystemConfig } from 'data/user'; import { useToggle } from 'hooks/use-toggle'; -import React, { useCallback } from 'react'; export const Mail = () => { const { data, loading, error, sendTestEmail, updateSystemConfig } = useSystemConfig(); diff --git a/packages/client/src/components/admin/system-config/system/index.tsx b/packages/client/src/components/admin/system-config/system/index.tsx index 0e66888..ea95047 100644 --- a/packages/client/src/components/admin/system-config/system/index.tsx +++ b/packages/client/src/components/admin/system-config/system/index.tsx @@ -1,9 +1,11 @@ +import React, { useCallback } from 'react'; + import { IconHelpCircle } from '@douyinfe/semi-icons'; import { Banner, Button, Form, Toast, Tooltip } from '@douyinfe/semi-ui'; + import { DataRender } from 'components/data-render'; import { useSystemConfig } from 'data/user'; import { useToggle } from 'hooks/use-toggle'; -import React, { useCallback } from 'react'; export const System = () => { const { data, loading, error, updateSystemConfig } = useSystemConfig(); diff --git a/packages/client/src/components/banner/index.tsx b/packages/client/src/components/banner/index.tsx index bd56e8d..b5b1288 100644 --- a/packages/client/src/components/banner/index.tsx +++ b/packages/client/src/components/banner/index.tsx @@ -1,8 +1,10 @@ +import React, { useEffect, useRef } from 'react'; + import { IconClose } from '@douyinfe/semi-icons'; import { Banner as SemiBanner } from '@douyinfe/semi-ui'; import { BannerProps } from '@douyinfe/semi-ui/banner'; + import { useToggle } from 'hooks/use-toggle'; -import React, { useEffect, useRef } from 'react'; interface IProps extends BannerProps { duration?: number; diff --git a/packages/client/src/components/color-picker/index.tsx b/packages/client/src/components/color-picker/index.tsx index 0ea7ba6..e510e47 100644 --- a/packages/client/src/components/color-picker/index.tsx +++ b/packages/client/src/components/color-picker/index.tsx @@ -1,7 +1,9 @@ +import React, { useMemo } from 'react'; + import { Dropdown, SideSheet, Typography } from '@douyinfe/semi-ui'; + import { IsOnMobile } from 'hooks/use-on-mobile'; import { useToggle } from 'hooks/use-toggle'; -import React, { useMemo } from 'react'; import styles from './style.module.scss'; diff --git a/packages/client/src/components/data-render/constant.tsx b/packages/client/src/components/data-render/constant.tsx index a0a78b4..1e43698 100644 --- a/packages/client/src/components/data-render/constant.tsx +++ b/packages/client/src/components/data-render/constant.tsx @@ -1,7 +1,9 @@ -import { Spin, Typography } from '@douyinfe/semi-ui'; -import { Empty } from 'illustrations/empty'; import React, { useMemo } from 'react'; +import { Spin, Typography } from '@douyinfe/semi-ui'; + +import { Empty } from 'illustrations/empty'; + const { Text } = Typography; export const defaultLoading = ( diff --git a/packages/client/src/components/data-render/index.tsx b/packages/client/src/components/data-render/index.tsx index 2b05bea..9f1179a 100644 --- a/packages/client/src/components/data-render/index.tsx +++ b/packages/client/src/components/data-render/index.tsx @@ -1,6 +1,7 @@ -import deepEqual from 'deep-equal'; import React from 'react'; +import deepEqual from 'deep-equal'; + import { defaultEmpty, defaultLoading, defaultRenderError, Render } from './constant'; import { LoadingWrap } from './loading'; diff --git a/packages/client/src/components/data-render/loading.tsx b/packages/client/src/components/data-render/loading.tsx index d071d2d..c696342 100644 --- a/packages/client/src/components/data-render/loading.tsx +++ b/packages/client/src/components/data-render/loading.tsx @@ -1,6 +1,7 @@ -import { useToggle } from 'hooks/use-toggle'; import React, { useEffect, useRef } from 'react'; +import { useToggle } from 'hooks/use-toggle'; + import { Render } from './constant'; export const LoadingWrap = ({ loading, delay = 200, loadingContent, normalContent }) => { diff --git a/packages/client/src/components/document-creator/index.tsx b/packages/client/src/components/document-creator/index.tsx index 07933c0..fa1b073 100644 --- a/packages/client/src/components/document-creator/index.tsx +++ b/packages/client/src/components/document-creator/index.tsx @@ -1,8 +1,10 @@ +import React from 'react'; + import { Button } from '@douyinfe/semi-ui'; + import { DocumentCreator as DocumenCreatorForm } from 'components/document/create'; import { useRouterQuery } from 'hooks/use-router-query'; import { useToggle } from 'hooks/use-toggle'; -import React from 'react'; interface IProps { onCreateDocument?: () => void; diff --git a/packages/client/src/components/document/actions/index.tsx b/packages/client/src/components/document/actions/index.tsx index fb608db..1fd9130 100644 --- a/packages/client/src/components/document/actions/index.tsx +++ b/packages/client/src/components/document/actions/index.tsx @@ -1,7 +1,11 @@ +import React, { useCallback } from 'react'; + import { IconArticle, IconBranch, IconExport, IconHistory, IconMore, IconPlus, IconStar } from '@douyinfe/semi-icons'; import { Button, Dropdown, Space, Typography } from '@douyinfe/semi-ui'; import { ButtonProps } from '@douyinfe/semi-ui/button/Button'; + import { IDocument, IOrganization, IWiki } from '@think/domains'; + import cls from 'classnames'; import { DocumentCreator } from 'components/document/create'; import { DocumentDeletor } from 'components/document/delete'; @@ -12,7 +16,6 @@ import { DocumentStar } from 'components/document/star'; import { DocumentStyle } from 'components/document/style'; import { DocumentVersionTrigger } from 'components/document/version'; import { useToggle } from 'hooks/use-toggle'; -import React, { useCallback } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/document/card/index.tsx b/packages/client/src/components/document/card/index.tsx index 93c6144..93a9ebd 100644 --- a/packages/client/src/components/document/card/index.tsx +++ b/packages/client/src/components/document/card/index.tsx @@ -1,13 +1,16 @@ +import { useCallback } from 'react'; + import { IconEdit, IconUser } from '@douyinfe/semi-icons'; import { Avatar, Button, Skeleton, Space, Tooltip, Typography } from '@douyinfe/semi-ui'; + import type { IDocument } from '@think/domains'; + import { DocumentShare } from 'components/document/share'; import { DocumentStar } from 'components/document/star'; import { IconDocument } from 'components/icons/IconDocument'; import { LocaleTime } from 'components/locale-time'; import Link from 'next/link'; import Router from 'next/router'; -import { useCallback } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/document/collaboration/index.tsx b/packages/client/src/components/document/collaboration/index.tsx index bda5856..cce3fb0 100644 --- a/packages/client/src/components/document/collaboration/index.tsx +++ b/packages/client/src/components/document/collaboration/index.tsx @@ -1,12 +1,14 @@ +import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; + import { IconUserAdd } from '@douyinfe/semi-icons'; import { Avatar, AvatarGroup, Button, Dropdown, Modal, Popover, Toast, Tooltip, Typography } from '@douyinfe/semi-ui'; + import { Members } from 'components/members'; import { useDoumentMembers } from 'data/document'; import { useUser } from 'data/user'; import { event, JOIN_USER } from 'event'; import { IsOnMobile } from 'hooks/use-on-mobile'; import { useToggle } from 'hooks/use-toggle'; -import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; interface IProps { wikiId: string; diff --git a/packages/client/src/components/document/comments/comments/index.tsx b/packages/client/src/components/document/comments/comments/index.tsx index 3738ecb..19abe1c 100644 --- a/packages/client/src/components/document/comments/comments/index.tsx +++ b/packages/client/src/components/document/comments/comments/index.tsx @@ -1,6 +1,7 @@ -import type { IComment } from '@think/domains'; import React from 'react'; +import type { IComment } from '@think/domains'; + import { CommentItem } from './item'; interface IProps { diff --git a/packages/client/src/components/document/comments/comments/item/index.tsx b/packages/client/src/components/document/comments/comments/item/index.tsx index 566f77a..2bbb07c 100644 --- a/packages/client/src/components/document/comments/comments/item/index.tsx +++ b/packages/client/src/components/document/comments/comments/item/index.tsx @@ -1,9 +1,12 @@ +import React from 'react'; + import { IconUser } from '@douyinfe/semi-icons'; import { Avatar, Popconfirm, Skeleton, Space, Typography } from '@douyinfe/semi-ui'; + import type { IComment, IUser } from '@think/domains'; + import { LocaleTime } from 'components/locale-time'; import { useUser } from 'data/user'; -import React from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/document/comments/index.tsx b/packages/client/src/components/document/comments/index.tsx index 5fcd67a..c50c55e 100644 --- a/packages/client/src/components/document/comments/index.tsx +++ b/packages/client/src/components/document/comments/index.tsx @@ -1,13 +1,17 @@ +import React, { useCallback, useRef, useState } from 'react'; + import { Avatar, Banner, Button, Pagination, Space, Spin, Typography } from '@douyinfe/semi-ui'; + +import { EditorContent, useEditor } from 'tiptap/core'; +import { CommentKit, CommentMenuBar } from 'tiptap/editor'; + import { DataRender } from 'components/data-render'; import { useComments } from 'data/comment'; import { useUser } from 'data/user'; import { useToggle } from 'hooks/use-toggle'; -import React, { useCallback, useRef, useState } from 'react'; -import { EditorContent, useEditor } from 'tiptap/core'; -import { CommentKit, CommentMenuBar } from 'tiptap/editor'; import { Comments } from './comments'; + import styles from './index.module.scss'; interface IProps { diff --git a/packages/client/src/components/document/create/index.tsx b/packages/client/src/components/document/create/index.tsx index 2846499..d392158 100644 --- a/packages/client/src/components/document/create/index.tsx +++ b/packages/client/src/components/document/create/index.tsx @@ -1,12 +1,15 @@ +import { Dispatch, SetStateAction, useCallback, useEffect, useState } from 'react'; + import { Checkbox, Modal, TabPane, Tabs } from '@douyinfe/semi-ui'; + import { IDocument, IWiki } from '@think/domains'; + import { TemplateCardEmpty } from 'components/template/card'; import { TemplateList } from 'components/template/list'; import { useCreateDocument } from 'data/document'; import { useOwnTemplates, usePublicTemplates } from 'data/template'; import { useRouterQuery } from 'hooks/use-router-query'; import Router from 'next/router'; -import { Dispatch, SetStateAction, useCallback, useEffect, useState } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/document/delete/index.tsx b/packages/client/src/components/document/delete/index.tsx index edcf759..9f92329 100644 --- a/packages/client/src/components/document/delete/index.tsx +++ b/packages/client/src/components/document/delete/index.tsx @@ -1,9 +1,11 @@ +import React, { useCallback, useMemo } from 'react'; + import { IconDelete } from '@douyinfe/semi-icons'; import { Popconfirm, Space, Typography } from '@douyinfe/semi-ui'; + import { useDeleteDocument } from 'data/document'; import { useRouterQuery } from 'hooks/use-router-query'; import Router from 'next/router'; -import React, { useCallback, useMemo } from 'react'; interface IProps { wikiId: string; diff --git a/packages/client/src/components/document/editor/editor.tsx b/packages/client/src/components/document/editor/editor.tsx index 45dc0a9..fd1899c 100644 --- a/packages/client/src/components/document/editor/editor.tsx +++ b/packages/client/src/components/document/editor/editor.tsx @@ -1,9 +1,12 @@ +import React, { useEffect, useRef } from 'react'; + import { IAuthority, ILoginUser } from '@think/domains'; + +import { CollaborationEditor, ICollaborationRefProps } from 'tiptap/editor'; + import cls from 'classnames'; import { event, triggerChangeDocumentTitle, triggerJoinUser, USE_DOCUMENT_VERSION } from 'event'; import { useMount } from 'hooks/use-mount'; -import React, { useEffect, useRef } from 'react'; -import { CollaborationEditor, ICollaborationRefProps } from 'tiptap/editor'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/document/editor/index.tsx b/packages/client/src/components/document/editor/index.tsx index e08e1e4..642e04f 100644 --- a/packages/client/src/components/document/editor/index.tsx +++ b/packages/client/src/components/document/editor/index.tsx @@ -1,5 +1,8 @@ +import React, { useCallback, useEffect, useMemo, useState } from 'react'; + import { IconChevronLeft } from '@douyinfe/semi-icons'; import { Button, Nav, Skeleton, Space, Tooltip, Typography } from '@douyinfe/semi-ui'; + import { DataRender } from 'components/data-render'; import { Divider } from 'components/divider'; import { DocumentCollaboration } from 'components/document/collaboration'; @@ -16,10 +19,10 @@ import { IsOnMobile } from 'hooks/use-on-mobile'; import { useWindowSize } from 'hooks/use-window-size'; import { SecureDocumentIllustration } from 'illustrations/secure-document'; import Router from 'next/router'; -import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { DocumentActions } from '../actions'; import { Editor } from './editor'; + import styles from './index.module.scss'; const { Text } = Typography; diff --git a/packages/client/src/components/document/export/index.tsx b/packages/client/src/components/document/export/index.tsx index 186391e..00f6577 100644 --- a/packages/client/src/components/document/export/index.tsx +++ b/packages/client/src/components/document/export/index.tsx @@ -1,18 +1,23 @@ +import React, { useCallback, useEffect, useMemo } from 'react'; + import { Badge, Button, Dropdown, Modal, Space, Typography } from '@douyinfe/semi-ui'; + import { IDocument } from '@think/domains'; + +import { createEditor } from 'tiptap/core'; +import { AllExtensions } from 'tiptap/core/all-kit'; +import { prosemirrorToMarkdown } from 'tiptap/markdown/prosemirror-to-markdown'; + import { IconJSON, IconMarkdown, IconPDF, IconWord } from 'components/icons'; import { useDocumentDetail } from 'data/document'; import FileSaver from 'file-saver'; import { safeJSONParse, safeJSONStringify } from 'helpers/json'; import { IsOnMobile } from 'hooks/use-on-mobile'; import { useToggle } from 'hooks/use-toggle'; -import React, { useCallback, useEffect, useMemo } from 'react'; -import { createEditor } from 'tiptap/core'; -import { AllExtensions } from 'tiptap/core/all-kit'; -import { prosemirrorToMarkdown } from 'tiptap/markdown/prosemirror-to-markdown'; + +import { printEditorContent } from './pdf'; import styles from './index.module.scss'; -import { printEditorContent } from './pdf'; const { Text } = Typography; diff --git a/packages/client/src/components/document/fullscreen/index.tsx b/packages/client/src/components/document/fullscreen/index.tsx index d7361ae..34933d4 100644 --- a/packages/client/src/components/document/fullscreen/index.tsx +++ b/packages/client/src/components/document/fullscreen/index.tsx @@ -1,15 +1,18 @@ +import React, { useCallback, useEffect, useRef, useState } from 'react'; +import { FullScreen, useFullScreenHandle } from 'react-full-screen'; + import { IconShrinkScreenStroked } from '@douyinfe/semi-icons'; import { Button, Space, Tooltip, Typography } from '@douyinfe/semi-ui'; + import { EditorContent, useEditor } from '@tiptap/react'; +import { CollaborationKit, Document } from 'tiptap/editor'; + import cls from 'classnames'; import { IconFullscreen } from 'components/icons/IconFullscreen'; import { IconPencil } from 'components/icons/IconPencil'; import { safeJSONParse } from 'helpers/json'; import { useDrawingCursor } from 'hooks/use-cursor'; import { useToggle } from 'hooks/use-toggle'; -import React, { useCallback, useEffect, useRef, useState } from 'react'; -import { FullScreen, useFullScreenHandle } from 'react-full-screen'; -import { CollaborationKit, Document } from 'tiptap/editor'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/document/link/index.tsx b/packages/client/src/components/document/link/index.tsx index 928e312..0cdc1fd 100644 --- a/packages/client/src/components/document/link/index.tsx +++ b/packages/client/src/components/document/link/index.tsx @@ -1,9 +1,12 @@ +import React, { useCallback } from 'react'; + import { IconLink } from '@douyinfe/semi-icons'; import { Space, Typography } from '@douyinfe/semi-ui'; + import { IDocument, IOrganization, IWiki } from '@think/domains'; + import { copy } from 'helpers/copy'; import { buildUrl } from 'helpers/url'; -import React, { useCallback } from 'react'; interface IProps { organizationId: IOrganization['id']; diff --git a/packages/client/src/components/document/reader/author.tsx b/packages/client/src/components/document/reader/author.tsx index ec44d29..575a568 100644 --- a/packages/client/src/components/document/reader/author.tsx +++ b/packages/client/src/components/document/reader/author.tsx @@ -1,8 +1,11 @@ +import React from 'react'; + import { IconUser } from '@douyinfe/semi-icons'; import { Avatar, Space } from '@douyinfe/semi-ui'; + import { IDocument } from '@think/domains'; + import { LocaleTime } from 'components/locale-time'; -import React from 'react'; interface IProps { document: IDocument; diff --git a/packages/client/src/components/document/reader/index.tsx b/packages/client/src/components/document/reader/index.tsx index 68ce6cf..f54e515 100644 --- a/packages/client/src/components/document/reader/index.tsx +++ b/packages/client/src/components/document/reader/index.tsx @@ -1,5 +1,11 @@ +import React, { useCallback, useMemo } from 'react'; +import { createPortal } from 'react-dom'; + import { IconEdit } from '@douyinfe/semi-icons'; import { Button, Layout, Nav, Skeleton, Space, Spin, Tooltip, Typography } from '@douyinfe/semi-ui'; + +import { CollaborationEditor } from 'tiptap/editor'; + import { DataRender } from 'components/data-render'; import { DocumentCollaboration } from 'components/document/collaboration'; import { DocumentStar } from 'components/document/star'; @@ -13,13 +19,11 @@ import { useMount } from 'hooks/use-mount'; import { IsOnMobile } from 'hooks/use-on-mobile'; import { useWindowSize } from 'hooks/use-window-size'; import Router from 'next/router'; -import React, { useCallback, useMemo } from 'react'; -import { createPortal } from 'react-dom'; -import { CollaborationEditor } from 'tiptap/editor'; import { DocumentActions } from '../actions'; import { DocumentFullscreen } from '../fullscreen'; import { Author } from './author'; + import styles from './index.module.scss'; const { Header } = Layout; diff --git a/packages/client/src/components/document/share/index.tsx b/packages/client/src/components/document/share/index.tsx index 4c14510..e223024 100644 --- a/packages/client/src/components/document/share/index.tsx +++ b/packages/client/src/components/document/share/index.tsx @@ -1,12 +1,15 @@ +import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; + import { IconLink } from '@douyinfe/semi-icons'; import { Button, Dropdown, Input, Modal, Space, Toast, Typography } from '@douyinfe/semi-ui'; + import { isPublicDocument } from '@think/domains'; + import { useDocumentDetail } from 'data/document'; import { getDocumentShareURL } from 'helpers/url'; import { IsOnMobile } from 'hooks/use-on-mobile'; import { useToggle } from 'hooks/use-toggle'; import { ShareIllustration } from 'illustrations/share'; -import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; interface IProps { documentId: string; diff --git a/packages/client/src/components/document/star/index.tsx b/packages/client/src/components/document/star/index.tsx index 0583ead..d21f1ff 100644 --- a/packages/client/src/components/document/star/index.tsx +++ b/packages/client/src/components/document/star/index.tsx @@ -1,11 +1,14 @@ -import { IconStar } from '@douyinfe/semi-icons'; -import { Button, Tooltip } from '@douyinfe/semi-ui'; -import { IDocument, IOrganization, IWiki } from '@think/domains'; -import { useDocumentStarToggle } from 'data/star'; -import { useToggle } from 'hooks/use-toggle'; import React, { useCallback } from 'react'; import VisibilitySensor from 'react-visibility-sensor'; +import { IconStar } from '@douyinfe/semi-icons'; +import { Button, Tooltip } from '@douyinfe/semi-ui'; + +import { IDocument, IOrganization, IWiki } from '@think/domains'; + +import { useDocumentStarToggle } from 'data/star'; +import { useToggle } from 'hooks/use-toggle'; + interface IProps { organizationId: IOrganization['id']; wikiId: IWiki['id']; diff --git a/packages/client/src/components/document/style/index.tsx b/packages/client/src/components/document/style/index.tsx index b1e753d..03e80cf 100644 --- a/packages/client/src/components/document/style/index.tsx +++ b/packages/client/src/components/document/style/index.tsx @@ -1,10 +1,12 @@ +import React, { useMemo } from 'react'; + import { IconArticle } from '@douyinfe/semi-icons'; import { Button, Dropdown, Radio, RadioGroup, Slider, Typography } from '@douyinfe/semi-ui'; + import { throttle } from 'helpers/throttle'; import { useDocumentStyle } from 'hooks/use-document-style'; import { IsOnMobile } from 'hooks/use-on-mobile'; import { useToggle } from 'hooks/use-toggle'; -import React, { useMemo } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/document/version/index.tsx b/packages/client/src/components/document/version/index.tsx index 403c6b5..3c81597 100644 --- a/packages/client/src/components/document/version/index.tsx +++ b/packages/client/src/components/document/version/index.tsx @@ -1,6 +1,11 @@ +import React, { useCallback, useEffect, useState } from 'react'; + import { IconChevronLeft } from '@douyinfe/semi-icons'; import { Button, Modal, Select, Space, Tag, Typography } from '@douyinfe/semi-ui'; + import { EditorContent, useEditor } from '@tiptap/react'; +import { CollaborationKit } from 'tiptap/editor'; + import cls from 'classnames'; import { DataRender } from 'components/data-render'; import { LocaleTime } from 'components/locale-time'; @@ -9,8 +14,6 @@ import { generateDiffHtml } from 'helpers/generate-html'; import { safeJSONParse } from 'helpers/json'; import { DocumentVersionControl } from 'hooks/use-document-version'; import { IsOnMobile } from 'hooks/use-on-mobile'; -import React, { useCallback, useEffect, useState } from 'react'; -import { CollaborationKit } from 'tiptap/editor'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/emoji-picker/index.tsx b/packages/client/src/components/emoji-picker/index.tsx index 50c70c8..473be36 100644 --- a/packages/client/src/components/emoji-picker/index.tsx +++ b/packages/client/src/components/emoji-picker/index.tsx @@ -1,10 +1,13 @@ +import React, { useCallback, useEffect, useMemo, useState } from 'react'; + import { Button, Popover, SideSheet, TabPane, Tabs } from '@douyinfe/semi-ui'; + import { createKeysLocalStorageLRUCache } from 'helpers/lru-cache'; import { IsOnMobile } from 'hooks/use-on-mobile'; import { useToggle } from 'hooks/use-toggle'; -import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { ACTIVITIES, EXPRESSIONES, GESTURES, OBJECTS, SKY_WEATHER, SYMBOLS } from './constants'; + import styles from './index.module.scss'; const emojiLocalStorageLRUCache = createKeysLocalStorageLRUCache('EMOJI_PICKER', 20); diff --git a/packages/client/src/components/empty.tsx b/packages/client/src/components/empty.tsx index 9cb26a6..de3f0df 100644 --- a/packages/client/src/components/empty.tsx +++ b/packages/client/src/components/empty.tsx @@ -1,6 +1,7 @@ -import { Typography } from '@douyinfe/semi-ui'; import React from 'react'; +import { Typography } from '@douyinfe/semi-ui'; + interface IProps { illustration?: React.ReactNode; message: React.ReactNode; diff --git a/packages/client/src/components/grid-select/grid-select.tsx b/packages/client/src/components/grid-select/grid-select.tsx index 2a6517f..52105c2 100644 --- a/packages/client/src/components/grid-select/grid-select.tsx +++ b/packages/client/src/components/grid-select/grid-select.tsx @@ -1,6 +1,7 @@ -import { Typography } from '@douyinfe/semi-ui'; import React, { useCallback, useMemo, useState } from 'react'; +import { Typography } from '@douyinfe/semi-ui'; + import { GridCell } from './grid-cell'; const { Text } = Typography; diff --git a/packages/client/src/components/icons/IconDocument.tsx b/packages/client/src/components/icons/IconDocument.tsx index 9df647e..7a50f24 100644 --- a/packages/client/src/components/icons/IconDocument.tsx +++ b/packages/client/src/components/icons/IconDocument.tsx @@ -1,6 +1,7 @@ -import { Icon } from '@douyinfe/semi-ui'; import React from 'react'; +import { Icon } from '@douyinfe/semi-ui'; + export const IconDocument: React.FC<{ style?: React.CSSProperties }> = ({ style = {} }) => { return ( = ({ style = {} }) => { return ( = ({ style = {} }) => { + return ( + + + + } + /> + ); +}; diff --git a/packages/client/src/components/icons/IconMessage.tsx b/packages/client/src/components/icons/IconMessage.tsx index 6aebdf4..4ae6e6b 100644 --- a/packages/client/src/components/icons/IconMessage.tsx +++ b/packages/client/src/components/icons/IconMessage.tsx @@ -1,6 +1,7 @@ -import { Icon } from '@douyinfe/semi-ui'; import React from 'react'; +import { Icon } from '@douyinfe/semi-ui'; + export const IconMessage: React.FC<{ style?: React.CSSProperties }> = ({ style = {} }) => { return ( = ({ style = {} }) => { return ( = ({ style = {} }) => { return ( = ({ style = {} }) => { return ( = ({ style = {} }) => { return ( any; } diff --git a/packages/client/src/components/members/edit.tsx b/packages/client/src/components/members/edit.tsx index 777b1d3..34b702d 100644 --- a/packages/client/src/components/members/edit.tsx +++ b/packages/client/src/components/members/edit.tsx @@ -1,7 +1,9 @@ -import { Banner, Popconfirm, Select, Toast } from '@douyinfe/semi-ui'; -import { AuthEnum, AuthEnumArray, IAuth, IUser } from '@think/domains'; import React, { useCallback, useState } from 'react'; +import { Banner, Popconfirm, Select, Toast } from '@douyinfe/semi-ui'; + +import { AuthEnum, AuthEnumArray, IAuth, IUser } from '@think/domains'; + interface IProps { userWithAuth: { user: IUser; auth: IAuth }; updateUser: (arg) => any; diff --git a/packages/client/src/components/members/index.tsx b/packages/client/src/components/members/index.tsx index b34b6ad..0cefa7b 100644 --- a/packages/client/src/components/members/index.tsx +++ b/packages/client/src/components/members/index.tsx @@ -1,12 +1,16 @@ +import React from 'react'; + import { IconDelete, IconEdit } from '@douyinfe/semi-icons'; import { Banner, Button, Popconfirm, Table, Typography } from '@douyinfe/semi-ui'; + import { AuthEnumTextMap } from '@think/domains'; + import { DataRender } from 'components/data-render'; import { LocaleTime } from 'components/locale-time'; -import React from 'react'; import { AddUser } from './add'; import { EditUser } from './edit'; + import styles from './index.module.scss'; interface IProps { diff --git a/packages/client/src/components/message/index.tsx b/packages/client/src/components/message/index.tsx index 7d425ea..50ebd5c 100644 --- a/packages/client/src/components/message/index.tsx +++ b/packages/client/src/components/message/index.tsx @@ -1,4 +1,7 @@ +import React, { useCallback, useMemo } from 'react'; + import { Badge, Button, Dropdown, Modal, Pagination, TabPane, Tabs, Typography } from '@douyinfe/semi-ui'; + import { DataRender } from 'components/data-render'; import { Empty } from 'components/empty'; import { IconMessage } from 'components/icons/IconMessage'; @@ -8,10 +11,10 @@ import { IsOnMobile } from 'hooks/use-on-mobile'; import { useToggle } from 'hooks/use-toggle'; import { EmptyBoxIllustration } from 'illustrations/empty-box'; import Link from 'next/link'; -import React, { useCallback, useMemo } from 'react'; + +import { Placeholder } from './placeholder'; import styles from './index.module.scss'; -import { Placeholder } from './placeholder'; const { Text } = Typography; const PAGE_SIZE = 6; diff --git a/packages/client/src/components/organization/delete/index.tsx b/packages/client/src/components/organization/delete/index.tsx index e971463..5234d8b 100644 --- a/packages/client/src/components/organization/delete/index.tsx +++ b/packages/client/src/components/organization/delete/index.tsx @@ -1,10 +1,13 @@ +import React, { useCallback } from 'react'; + import { IconDelete } from '@douyinfe/semi-icons'; import { Modal, Space, Typography } from '@douyinfe/semi-ui'; + import { IOrganization } from '@think/domains'; + import { useOrganizationDetail } from 'data/organization'; import { useRouterQuery } from 'hooks/use-router-query'; import Router from 'next/router'; -import React, { useCallback } from 'react'; interface IProps { organizationId: IOrganization['id']; diff --git a/packages/client/src/components/organization/index.tsx b/packages/client/src/components/organization/index.tsx index 9e65800..651bdbe 100644 --- a/packages/client/src/components/organization/index.tsx +++ b/packages/client/src/components/organization/index.tsx @@ -1,5 +1,6 @@ import { Typography } from '@douyinfe/semi-ui'; import { Avatar } from '@douyinfe/semi-ui'; + import { DataRender } from 'components/data-render'; import { useOrganizationDetail } from 'data/organization'; import { useRouterQuery } from 'hooks/use-router-query'; diff --git a/packages/client/src/components/organization/public-switcher/index.tsx b/packages/client/src/components/organization/public-switcher/index.tsx index f9362af..1cb4b6a 100644 --- a/packages/client/src/components/organization/public-switcher/index.tsx +++ b/packages/client/src/components/organization/public-switcher/index.tsx @@ -1,9 +1,11 @@ import { Space } from '@douyinfe/semi-ui'; + import { LogoImage, LogoText } from 'components/logo'; import { useUser } from 'data/user'; import { useWindowSize } from 'hooks/use-window-size'; import { UserOrganizationsSwitcher } from '../switcher'; + import styles from './index.module.scss'; export const OrganizationPublicSwitcher = () => { diff --git a/packages/client/src/components/organization/setting/base/index.tsx b/packages/client/src/components/organization/setting/base/index.tsx index 6e39487..874db1a 100644 --- a/packages/client/src/components/organization/setting/base/index.tsx +++ b/packages/client/src/components/organization/setting/base/index.tsx @@ -1,12 +1,15 @@ +import { useCallback, useEffect, useRef, useState } from 'react'; + import { Avatar, Button, Form, Toast } from '@douyinfe/semi-ui'; import { FormApi } from '@douyinfe/semi-ui/lib/es/form'; + import { ORGANIZATION_LOGOS } from '@think/constants'; import { IOrganization } from '@think/domains'; + import { DataRender } from 'components/data-render'; import { ImageUploader } from 'components/image-uploader'; import { useOrganizationDetail } from 'data/organization'; import { useToggle } from 'hooks/use-toggle'; -import { useCallback, useEffect, useRef, useState } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/organization/setting/index.tsx b/packages/client/src/components/organization/setting/index.tsx index 0caf402..39b55b8 100644 --- a/packages/client/src/components/organization/setting/index.tsx +++ b/packages/client/src/components/organization/setting/index.tsx @@ -1,8 +1,11 @@ -import { TabPane, Tabs } from '@douyinfe/semi-ui'; -import { IOrganization } from '@think/domains'; -import { Seo } from 'components/seo'; import React from 'react'; +import { TabPane, Tabs } from '@douyinfe/semi-ui'; + +import { IOrganization } from '@think/domains'; + +import { Seo } from 'components/seo'; + import { Base } from './base'; import { OrganizationMembers } from './members'; import { More } from './more'; diff --git a/packages/client/src/components/organization/setting/members/index.tsx b/packages/client/src/components/organization/setting/members/index.tsx index e838107..121cabf 100644 --- a/packages/client/src/components/organization/setting/members/index.tsx +++ b/packages/client/src/components/organization/setting/members/index.tsx @@ -1,7 +1,9 @@ +import React from 'react'; + import { IOrganization } from '@think/domains'; + import { Members } from 'components/members'; import { useOrganizationMembers } from 'data/organization'; -import React from 'react'; interface IProps { organizationId: IOrganization['id']; diff --git a/packages/client/src/components/organization/setting/more/index.tsx b/packages/client/src/components/organization/setting/more/index.tsx index 086c012..339a515 100644 --- a/packages/client/src/components/organization/setting/more/index.tsx +++ b/packages/client/src/components/organization/setting/more/index.tsx @@ -1,4 +1,5 @@ import { Banner, Button, Typography } from '@douyinfe/semi-ui'; + import { OrganizationDeletor } from 'components/organization/delete'; const { Paragraph } = Typography; diff --git a/packages/client/src/components/organization/switcher/index.tsx b/packages/client/src/components/organization/switcher/index.tsx index e2ee8ec..7ce7e1c 100644 --- a/packages/client/src/components/organization/switcher/index.tsx +++ b/packages/client/src/components/organization/switcher/index.tsx @@ -1,11 +1,13 @@ +import { useMemo } from 'react'; + import { IconAppCenter, IconApps, IconSmallTriangleDown } from '@douyinfe/semi-icons'; import { Button, Dropdown, Space, Typography } from '@douyinfe/semi-ui'; import { Avatar } from '@douyinfe/semi-ui'; + import { DataRender } from 'components/data-render'; import { useOrganizationDetail, useUserOrganizations } from 'data/organization'; import { useRouterQuery } from 'hooks/use-router-query'; import Link from 'next/link'; -import { useMemo } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/resizeable/resizeable.tsx b/packages/client/src/components/resizeable/resizeable.tsx index d7a959d..71db4fe 100644 --- a/packages/client/src/components/resizeable/resizeable.tsx +++ b/packages/client/src/components/resizeable/resizeable.tsx @@ -1,7 +1,8 @@ +import React, { useEffect, useRef } from 'react'; + import cls from 'classnames'; import { useClickOutside } from 'hooks/use-click-outside'; import interact from 'interactjs'; -import React, { useEffect, useRef } from 'react'; import styles from './style.module.scss'; diff --git a/packages/client/src/components/search/index.tsx b/packages/client/src/components/search/index.tsx index 2b53418..30ec208 100644 --- a/packages/client/src/components/search/index.tsx +++ b/packages/client/src/components/search/index.tsx @@ -1,6 +1,10 @@ +import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; + import { IconSearch as SemiIconSearch } from '@douyinfe/semi-icons'; import { Button, Dropdown, Input, Modal, Spin, Typography } from '@douyinfe/semi-ui'; + import { IDocument } from '@think/domains'; + import { DataRender } from 'components/data-render'; import { DocumentStar } from 'components/document/star'; import { Empty } from 'components/empty'; @@ -14,7 +18,6 @@ import { useRouterQuery } from 'hooks/use-router-query'; import { useToggle } from 'hooks/use-toggle'; import Link from 'next/link'; import Router from 'next/router'; -import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { HttpClient } from 'services/http-client'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/size-setter.tsx b/packages/client/src/components/size-setter.tsx index 1ecec19..5f31261 100644 --- a/packages/client/src/components/size-setter.tsx +++ b/packages/client/src/components/size-setter.tsx @@ -1,6 +1,7 @@ +import { useCallback, useRef } from 'react'; + import { Button, Dropdown, Form } from '@douyinfe/semi-ui'; import { FormApi } from '@douyinfe/semi-ui/lib/es/form'; -import { useCallback, useRef } from 'react'; type ISize = { width: number | string; height: number | string }; diff --git a/packages/client/src/components/template/card/index.tsx b/packages/client/src/components/template/card/index.tsx index d5fe8bd..e194aac 100644 --- a/packages/client/src/components/template/card/index.tsx +++ b/packages/client/src/components/template/card/index.tsx @@ -1,13 +1,16 @@ +import { useCallback } from 'react'; + import { IconEdit, IconPlus, IconUser } from '@douyinfe/semi-icons'; import { Avatar, Button, Modal, Skeleton, Space, Tooltip, Typography } from '@douyinfe/semi-ui'; + import type { ITemplate } from '@think/domains'; + import cls from 'classnames'; import { IconDocument } from 'components/icons/IconDocument'; import { TemplateReader } from 'components/template/reader'; import { useUser } from 'data/user'; import { useToggle } from 'hooks/use-toggle'; import Router from 'next/router'; -import { useCallback } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/template/editor/index.tsx b/packages/client/src/components/template/editor/index.tsx index c221a21..f0a6e13 100644 --- a/packages/client/src/components/template/editor/index.tsx +++ b/packages/client/src/components/template/editor/index.tsx @@ -1,5 +1,10 @@ +import React, { useCallback, useEffect, useMemo, useState } from 'react'; + import { IconChevronLeft } from '@douyinfe/semi-icons'; import { Button, Nav, Popconfirm, Space, Switch, Tooltip, Typography } from '@douyinfe/semi-ui'; + +import { CollaborationEditor } from 'tiptap/editor'; + import { DocumentStyle } from 'components/document/style'; import { Seo } from 'components/seo'; import { Theme } from 'components/theme'; @@ -10,8 +15,6 @@ import { useDocumentStyle } from 'hooks/use-document-style'; import { useMount } from 'hooks/use-mount'; import { useWindowSize } from 'hooks/use-window-size'; import Router from 'next/router'; -import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { CollaborationEditor } from 'tiptap/editor'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/template/list/index.tsx b/packages/client/src/components/template/list/index.tsx index b74eedb..255d462 100644 --- a/packages/client/src/components/template/list/index.tsx +++ b/packages/client/src/components/template/list/index.tsx @@ -1,8 +1,10 @@ +import React, { useEffect, useMemo, useState } from 'react'; + import { List, Pagination } from '@douyinfe/semi-ui'; + import { DataRender } from 'components/data-render'; import { Empty } from 'components/empty'; import { IProps as ITemplateCardProps, TemplateCard, TemplateCardPlaceholder } from 'components/template/card'; -import React, { useEffect, useMemo, useState } from 'react'; const grid = { gutter: 16, diff --git a/packages/client/src/components/template/reader/index.tsx b/packages/client/src/components/template/reader/index.tsx index f33d79c..8266ff3 100644 --- a/packages/client/src/components/template/reader/index.tsx +++ b/packages/client/src/components/template/reader/index.tsx @@ -1,9 +1,12 @@ +import React from 'react'; + import { Spin } from '@douyinfe/semi-ui'; + +import { ReaderEditor } from 'tiptap/editor'; + import { DataRender } from 'components/data-render'; import { Seo } from 'components/seo'; import { useTemplate } from 'data/template'; -import React from 'react'; -import { ReaderEditor } from 'tiptap/editor'; interface IProps { templateId: string; diff --git a/packages/client/src/components/theme/index.tsx b/packages/client/src/components/theme/index.tsx index 35de542..0e568f9 100644 --- a/packages/client/src/components/theme/index.tsx +++ b/packages/client/src/components/theme/index.tsx @@ -1,7 +1,9 @@ +import React, { useCallback } from 'react'; + import { IconDesktop, IconMoon, IconSun } from '@douyinfe/semi-icons'; import { Button, Dropdown } from '@douyinfe/semi-ui'; + import { Theme as ThemeState, ThemeEnum } from 'hooks/use-theme'; -import React, { useCallback } from 'react'; export const Theme = () => { const { userPrefer, theme, toggle } = ThemeState.useHook(); diff --git a/packages/client/src/components/tooltip/index.tsx b/packages/client/src/components/tooltip/index.tsx index 7d4732f..2cc80eb 100644 --- a/packages/client/src/components/tooltip/index.tsx +++ b/packages/client/src/components/tooltip/index.tsx @@ -1,7 +1,9 @@ +import React from 'react'; + import { Tooltip as SemiTooltip } from '@douyinfe/semi-ui'; import { Position } from '@douyinfe/semi-ui/tooltip'; + import { useToggle } from 'hooks/use-toggle'; -import React from 'react'; interface IProps { content: React.ReactNode; diff --git a/packages/client/src/components/upload/index.tsx b/packages/client/src/components/upload/index.tsx index 5865309..98cbb07 100644 --- a/packages/client/src/components/upload/index.tsx +++ b/packages/client/src/components/upload/index.tsx @@ -1,7 +1,9 @@ +import React from 'react'; + import { IconUpload } from '@douyinfe/semi-icons'; import { Button, Toast, Upload as SemiUpload } from '@douyinfe/semi-ui'; + import { useAsyncLoading } from 'hooks/use-async-loading'; -import React from 'react'; import { uploadFile } from 'services/file'; interface IProps { diff --git a/packages/client/src/components/user/index.tsx b/packages/client/src/components/user/index.tsx index ec2d7d0..1c943e8 100644 --- a/packages/client/src/components/user/index.tsx +++ b/packages/client/src/components/user/index.tsx @@ -1,9 +1,11 @@ +import React, { useCallback } from 'react'; + import { IconSpin } from '@douyinfe/semi-icons'; import { Avatar, Button, Dropdown, Modal, Toast, Typography } from '@douyinfe/semi-ui'; + import { useUser } from 'data/user'; import { useToggle } from 'hooks/use-toggle'; import Router from 'next/router'; -import React, { useCallback } from 'react'; import { ResetPassword } from './reset-password'; import { UserSetting } from './setting'; diff --git a/packages/client/src/components/user/reset-password/index.tsx b/packages/client/src/components/user/reset-password/index.tsx index 9cde8cf..32af3a2 100644 --- a/packages/client/src/components/user/reset-password/index.tsx +++ b/packages/client/src/components/user/reset-password/index.tsx @@ -1,8 +1,10 @@ +import React, { useCallback, useState } from 'react'; + import { Button, Col, Form, Row, Toast } from '@douyinfe/semi-ui'; + import { useResetPassword, useSystemPublicConfig, useUser, useVerifyCode } from 'data/user'; import { useInterval } from 'hooks/use-interval'; import { useToggle } from 'hooks/use-toggle'; -import React, { useCallback, useState } from 'react'; export const ResetPassword = ({ onSuccess }) => { const [email, setEmail] = useState(''); diff --git a/packages/client/src/components/user/setting/index.tsx b/packages/client/src/components/user/setting/index.tsx index 2e02996..17912b6 100644 --- a/packages/client/src/components/user/setting/index.tsx +++ b/packages/client/src/components/user/setting/index.tsx @@ -1,10 +1,12 @@ +import { Dispatch, SetStateAction, useCallback, useEffect, useRef, useState } from 'react'; + import { Avatar, Button, Col, Form, Modal, Row, Space, Toast } from '@douyinfe/semi-ui'; import { FormApi } from '@douyinfe/semi-ui/lib/es/form'; + import { Upload } from 'components/upload'; import { useSystemPublicConfig, useUser, useVerifyCode } from 'data/user'; import { useInterval } from 'hooks/use-interval'; import { useToggle } from 'hooks/use-toggle'; -import { Dispatch, SetStateAction, useCallback, useEffect, useRef, useState } from 'react'; interface IProps { visible: boolean; diff --git a/packages/client/src/components/wiki-creator/index.tsx b/packages/client/src/components/wiki-creator/index.tsx index 2936d04..b616458 100644 --- a/packages/client/src/components/wiki-creator/index.tsx +++ b/packages/client/src/components/wiki-creator/index.tsx @@ -1,7 +1,9 @@ +import React from 'react'; + import { Button } from '@douyinfe/semi-ui'; + import { WikiCreator as WikiCreatorForm } from 'components/wiki/create'; import { useToggle } from 'hooks/use-toggle'; -import React from 'react'; export const WikiCreator: React.FC = ({ children }) => { const [visible, toggleVisible] = useToggle(false); diff --git a/packages/client/src/components/wiki-or-document-creator/index.tsx b/packages/client/src/components/wiki-or-document-creator/index.tsx index 15da549..92d38af 100644 --- a/packages/client/src/components/wiki-or-document-creator/index.tsx +++ b/packages/client/src/components/wiki-or-document-creator/index.tsx @@ -1,10 +1,12 @@ +import React from 'react'; + import { IconPlus } from '@douyinfe/semi-icons'; import { Button, Dropdown } from '@douyinfe/semi-ui'; + import { DocumentCreator } from 'components/document/create'; import { WikiCreator } from 'components/wiki/create'; import { useRouterQuery } from 'hooks/use-router-query'; import { useToggle } from 'hooks/use-toggle'; -import React from 'react'; interface IProps { onCreateDocument?: () => void; diff --git a/packages/client/src/components/wiki/card/index.tsx b/packages/client/src/components/wiki/card/index.tsx index a818eeb..9b5ff66 100644 --- a/packages/client/src/components/wiki/card/index.tsx +++ b/packages/client/src/components/wiki/card/index.tsx @@ -1,5 +1,6 @@ import { IconUser } from '@douyinfe/semi-icons'; import { Avatar, Skeleton, Space, Typography } from '@douyinfe/semi-ui'; + import { IconDocument } from 'components/icons/IconDocument'; import { LocaleTime } from 'components/locale-time'; import { WikiStar } from 'components/wiki/star'; diff --git a/packages/client/src/components/wiki/create/index.tsx b/packages/client/src/components/wiki/create/index.tsx index d66d8a6..02d8d50 100644 --- a/packages/client/src/components/wiki/create/index.tsx +++ b/packages/client/src/components/wiki/create/index.tsx @@ -1,10 +1,13 @@ +import { Dispatch, SetStateAction, useRef } from 'react'; + import { Form, Modal } from '@douyinfe/semi-ui'; import { FormApi } from '@douyinfe/semi-ui/lib/es/form'; + import type { IWiki } from '@think/domains'; + import { ICreateWiki, useOwnWikis } from 'data/wiki'; import { useRouterQuery } from 'hooks/use-router-query'; import Router from 'next/router'; -import { Dispatch, SetStateAction, useRef } from 'react'; interface IProps { visible: boolean; diff --git a/packages/client/src/components/wiki/delete/index.tsx b/packages/client/src/components/wiki/delete/index.tsx index a1c189f..4ba29f8 100644 --- a/packages/client/src/components/wiki/delete/index.tsx +++ b/packages/client/src/components/wiki/delete/index.tsx @@ -1,9 +1,11 @@ +import React, { useCallback } from 'react'; + import { IconDelete } from '@douyinfe/semi-icons'; import { Modal, Space, Typography } from '@douyinfe/semi-ui'; + import { useOwnWikis } from 'data/wiki'; import { useRouterQuery } from 'hooks/use-router-query'; import Router from 'next/router'; -import React, { useCallback } from 'react'; interface IProps { wikiId: string; diff --git a/packages/client/src/components/wiki/documents-share/index.tsx b/packages/client/src/components/wiki/documents-share/index.tsx index 83e5516..388c3c5 100644 --- a/packages/client/src/components/wiki/documents-share/index.tsx +++ b/packages/client/src/components/wiki/documents-share/index.tsx @@ -1,9 +1,12 @@ +import React, { useCallback, useEffect, useMemo, useState } from 'react'; + import { IconClose } from '@douyinfe/semi-icons'; import { Banner, Button, Checkbox, Toast, Transfer, Typography } from '@douyinfe/semi-ui'; + import { isPublicDocument } from '@think/domains'; + import { flattenTree2Array } from 'components/wiki/tocs/utils'; import { useWikiDetail, useWikiTocs } from 'data/wiki'; -import React, { useCallback, useEffect, useMemo, useState } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/wiki/pin-card/index.tsx b/packages/client/src/components/wiki/pin-card/index.tsx index 588842f..6497466 100644 --- a/packages/client/src/components/wiki/pin-card/index.tsx +++ b/packages/client/src/components/wiki/pin-card/index.tsx @@ -1,5 +1,7 @@ import { Avatar, Skeleton, Space, Typography } from '@douyinfe/semi-ui'; + import { IWiki } from '@think/domains'; + import { IconDocument } from 'components/icons/IconDocument'; import { LocaleTime } from 'components/locale-time'; import { WikiStar } from 'components/wiki/star'; diff --git a/packages/client/src/components/wiki/placeholder/index.tsx b/packages/client/src/components/wiki/placeholder/index.tsx index d8211d0..4a107c3 100644 --- a/packages/client/src/components/wiki/placeholder/index.tsx +++ b/packages/client/src/components/wiki/placeholder/index.tsx @@ -1,6 +1,7 @@ -import { Skeleton } from '@douyinfe/semi-ui'; import React from 'react'; +import { Skeleton } from '@douyinfe/semi-ui'; + export const WorkspacePlaceholder = () => { const placeholder = (
{ const createDocument = useCallback( (e) => { diff --git a/packages/client/src/data/comment.ts b/packages/client/src/data/comment.ts index e6852fc..4db6621 100644 --- a/packages/client/src/data/comment.ts +++ b/packages/client/src/data/comment.ts @@ -1,6 +1,8 @@ -import { CommentApiDefinition, IComment } from '@think/domains'; import { useCallback, useState } from 'react'; import { useQuery } from 'react-query'; + +import { CommentApiDefinition, IComment } from '@think/domains'; + 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 d2172c5..138a79a 100644 --- a/packages/client/src/data/document.ts +++ b/packages/client/src/data/document.ts @@ -1,8 +1,10 @@ -import { DocumentApiDefinition, IAuthority, IDocument, IUser, IWiki } from '@think/domains'; -import { triggerRefreshTocs } from 'event'; -import { useAsyncLoading } from 'hooks/use-async-loading'; import { useCallback, useState } from 'react'; import { QueriesOptions, useQuery, UseQueryOptions } from 'react-query'; + +import { DocumentApiDefinition, IAuthority, IDocument, IUser, IWiki } from '@think/domains'; + +import { triggerRefreshTocs } from 'event'; +import { useAsyncLoading } from 'hooks/use-async-loading'; import { HttpClient } from 'services/http-client'; type IDocumentWithVisitedAt = IDocument & { visitedAt: string }; diff --git a/packages/client/src/data/message.ts b/packages/client/src/data/message.ts index 173e80c..aa8eb1d 100644 --- a/packages/client/src/data/message.ts +++ b/packages/client/src/data/message.ts @@ -1,6 +1,8 @@ -import { IMessage, MessageApiDefinition } from '@think/domains'; import { useCallback, useState } from 'react'; import { useQuery } from 'react-query'; + +import { IMessage, MessageApiDefinition } from '@think/domains'; + import { HttpClient } from 'services/http-client'; const getMessagesApi = diff --git a/packages/client/src/data/organization.ts b/packages/client/src/data/organization.ts index 5b6edc5..a5f7b88 100644 --- a/packages/client/src/data/organization.ts +++ b/packages/client/src/data/organization.ts @@ -1,8 +1,10 @@ -import { IAuth, IOrganization, IUser, OrganizationApiDefinition } from '@think/domains'; -import { event, REFRESH_ORGANIZATIONS, triggerRefreshOrganizations } from 'event'; -import { useAsyncLoading } from 'hooks/use-async-loading'; import { useCallback, useEffect, useState } from 'react'; import { useQuery } from 'react-query'; + +import { IAuth, IOrganization, IUser, OrganizationApiDefinition } from '@think/domains'; + +import { event, REFRESH_ORGANIZATIONS, triggerRefreshOrganizations } from 'event'; +import { useAsyncLoading } from 'hooks/use-async-loading'; import { HttpClient } from 'services/http-client'; /** diff --git a/packages/client/src/data/star.ts b/packages/client/src/data/star.ts index 05e5cf2..0618568 100644 --- a/packages/client/src/data/star.ts +++ b/packages/client/src/data/star.ts @@ -1,7 +1,9 @@ -import { IDocument, IWiki, StarApiDefinition } from '@think/domains'; -import { event, TOGGLE_STAR_DOUCMENT, TOGGLE_STAR_WIKI, triggerToggleStarDocument, triggerToggleStarWiki } from 'event'; import { useCallback, useEffect } from 'react'; import { useQuery, UseQueryOptions } from 'react-query'; + +import { IDocument, IWiki, StarApiDefinition } from '@think/domains'; + +import { event, TOGGLE_STAR_DOUCMENT, TOGGLE_STAR_WIKI, triggerToggleStarDocument, triggerToggleStarWiki } from 'event'; import { HttpClient } from 'services/http-client'; export type IWikiWithIsMember = IWiki & { isMember?: boolean }; diff --git a/packages/client/src/data/template.ts b/packages/client/src/data/template.ts index 9e8d0ba..b638309 100644 --- a/packages/client/src/data/template.ts +++ b/packages/client/src/data/template.ts @@ -1,6 +1,8 @@ -import { ITemplate, TemplateApiDefinition } from '@think/domains'; import { useCallback, useState } from 'react'; import { useQuery } from 'react-query'; + +import { ITemplate, TemplateApiDefinition } from '@think/domains'; + import { HttpClient } from 'services/http-client'; export const getPublicTemplates = ( diff --git a/packages/client/src/data/user.ts b/packages/client/src/data/user.ts index b242016..4c46a87 100644 --- a/packages/client/src/data/user.ts +++ b/packages/client/src/data/user.ts @@ -1,10 +1,13 @@ +import { useCallback, useEffect } from 'react'; +import { useQuery } from 'react-query'; + import { Toast } from '@douyinfe/semi-ui'; + import { ILoginUser, ISystemConfig, IUser, SystemApiDefinition, UserApiDefinition } from '@think/domains'; + import { getStorage, setStorage } from 'helpers/storage'; import { useAsyncLoading } from 'hooks/use-async-loading'; import Router, { useRouter } from 'next/router'; -import { useCallback, useEffect } from 'react'; -import { useQuery } from 'react-query'; import { HttpClient } from 'services/http-client'; /** diff --git a/packages/client/src/data/wiki.ts b/packages/client/src/data/wiki.ts index 213a832..66c84b8 100644 --- a/packages/client/src/data/wiki.ts +++ b/packages/client/src/data/wiki.ts @@ -1,7 +1,9 @@ -import { IAuth, IDocument, IUser, IWiki, WikiApiDefinition } from '@think/domains'; -import { event, REFRESH_TOCS } from 'event'; import { useCallback, useEffect, useState } from 'react'; import { useQuery } from 'react-query'; + +import { IAuth, IDocument, IUser, IWiki, WikiApiDefinition } from '@think/domains'; + +import { event, REFRESH_TOCS } from 'event'; import { HttpClient } from 'services/http-client'; export type ICreateWiki = Pick; diff --git a/packages/client/src/event/index.ts b/packages/client/src/event/index.ts index ff385f7..067df42 100644 --- a/packages/client/src/event/index.ts +++ b/packages/client/src/event/index.ts @@ -1,4 +1,5 @@ import { IDocument, IUser, IWiki } from '@think/domains'; + import { EventEmitter } from 'helpers/event-emitter'; export const event = new EventEmitter(); diff --git a/packages/client/src/helpers/generate-html.ts b/packages/client/src/helpers/generate-html.ts index 7a5ede6..b932284 100644 --- a/packages/client/src/helpers/generate-html.ts +++ b/packages/client/src/helpers/generate-html.ts @@ -1,7 +1,8 @@ import { generateHTML } from '@tiptap/core'; -import HtmlDiff from 'htmldiff-js'; import { CollaborationKit } from 'tiptap/editor'; +import HtmlDiff from 'htmldiff-js'; + const json2html = (json) => generateHTML(json, CollaborationKit); export const generateDiffHtml = (selected, other) => { const selectedHtml = json2html(selected); diff --git a/packages/client/src/hooks/use-document-style.tsx b/packages/client/src/hooks/use-document-style.tsx index 826fcee..fecb506 100644 --- a/packages/client/src/hooks/use-document-style.tsx +++ b/packages/client/src/hooks/use-document-style.tsx @@ -1,7 +1,8 @@ -import { getStorage, setStorage } from 'helpers/storage'; import { useCallback, useEffect } from 'react'; import { useQuery } from 'react-query'; +import { getStorage, setStorage } from 'helpers/storage'; + export enum Width { 'standardWidth' = 'standardWidth', 'fullWidth' = 'fullWidth', diff --git a/packages/client/src/hooks/use-dragable-width.tsx b/packages/client/src/hooks/use-dragable-width.tsx index 5fc3ef8..8778aea 100644 --- a/packages/client/src/hooks/use-dragable-width.tsx +++ b/packages/client/src/hooks/use-dragable-width.tsx @@ -1,8 +1,9 @@ -import { clamp } from 'helpers/clamp'; -import { getStorage, setStorage } from 'helpers/storage'; import { useCallback, useMemo, useRef } from 'react'; import { useQuery } from 'react-query'; +import { clamp } from 'helpers/clamp'; +import { getStorage, setStorage } from 'helpers/storage'; + import { IsOnMobile } from './use-on-mobile'; const key = 'dragable-menu-width'; diff --git a/packages/client/src/layouts/app-double-column/index.tsx b/packages/client/src/layouts/app-double-column/index.tsx index 4788ed6..60a0ecd 100644 --- a/packages/client/src/layouts/app-double-column/index.tsx +++ b/packages/client/src/layouts/app-double-column/index.tsx @@ -1,12 +1,15 @@ -import { IconChevronLeft, IconChevronRight } from '@douyinfe/semi-icons'; -import { Button, Layout as SemiLayout } from '@douyinfe/semi-ui'; -import cls from 'classnames'; -import { throttle } from 'helpers/throttle'; -import { useDragableWidth } from 'hooks/use-dragable-width'; import React, { useMemo } from 'react'; import SplitPane from 'react-split-pane'; +import { IconChevronLeft, IconChevronRight } from '@douyinfe/semi-icons'; +import { Button, Layout as SemiLayout } from '@douyinfe/semi-ui'; + +import cls from 'classnames'; +import { throttle } from 'helpers/throttle'; +import { useDragableWidth } from 'hooks/use-dragable-width'; + import { AppRouterHeader } from '../app-router-header'; + import styles from './index.module.scss'; const { Sider, Content } = SemiLayout; diff --git a/packages/client/src/layouts/app-router-header/index.tsx b/packages/client/src/layouts/app-router-header/index.tsx index a6ead91..8ffa861 100644 --- a/packages/client/src/layouts/app-router-header/index.tsx +++ b/packages/client/src/layouts/app-router-header/index.tsx @@ -1,5 +1,8 @@ +import React, { useMemo } from 'react'; + import { IconMenu } from '@douyinfe/semi-icons'; import { Button, Dropdown, Layout as SemiLayout, Nav, Space } from '@douyinfe/semi-ui'; + import { Message } from 'components/message'; import { OrganizationSwitcher } from 'components/organization/switcher'; import { Search } from 'components/search'; @@ -10,7 +13,6 @@ import { IsOnMobile } from 'hooks/use-on-mobile'; import { useRouterQuery } from 'hooks/use-router-query'; import { useToggle } from 'hooks/use-toggle'; import Router, { useRouter } from 'next/router'; -import React, { useMemo } from 'react'; import { Recent, RecentModal } from './recent'; import { Wiki, WikiModal } from './wiki'; diff --git a/packages/client/src/layouts/app-router-header/recent.tsx b/packages/client/src/layouts/app-router-header/recent.tsx index a0ec2b1..85ceda0 100644 --- a/packages/client/src/layouts/app-router-header/recent.tsx +++ b/packages/client/src/layouts/app-router-header/recent.tsx @@ -1,5 +1,8 @@ +import React, { useCallback, useEffect } from 'react'; + import { IconChevronDown } from '@douyinfe/semi-icons'; import { Dropdown, Modal, Space, TabPane, Tabs, Typography } from '@douyinfe/semi-ui'; + import { DataRender } from 'components/data-render'; import { DocumentStar } from 'components/document/star'; import { Empty } from 'components/empty'; @@ -9,10 +12,10 @@ import { useRecentDocuments } from 'data/document'; import { useToggle } from 'hooks/use-toggle'; import Link from 'next/link'; import { useRouter } from 'next/router'; -import React, { useCallback, useEffect } from 'react'; + +import { Placeholder } from './placeholder'; import styles from './index.module.scss'; -import { Placeholder } from './placeholder'; const { Text } = Typography; diff --git a/packages/client/src/layouts/app-router-header/wiki.tsx b/packages/client/src/layouts/app-router-header/wiki.tsx index 2aed72d..c7cd4aa 100644 --- a/packages/client/src/layouts/app-router-header/wiki.tsx +++ b/packages/client/src/layouts/app-router-header/wiki.tsx @@ -1,5 +1,8 @@ +import React, { useCallback } from 'react'; + import { IconChevronDown } from '@douyinfe/semi-icons'; import { Avatar, Dropdown, Modal, Space, Typography } from '@douyinfe/semi-ui'; + import { DataRender } from 'components/data-render'; import { Empty } from 'components/empty'; import { WikiStar } from 'components/wiki/star'; @@ -7,10 +10,10 @@ import { useStarWikisInOrganization } from 'data/star'; import { useWikiDetail } from 'data/wiki'; import Link from 'next/link'; import { useRouter } from 'next/router'; -import React, { useCallback } from 'react'; + +import { Placeholder } from './placeholder'; import styles from './index.module.scss'; -import { Placeholder } from './placeholder'; const { Text } = Typography; diff --git a/packages/client/src/layouts/app-single-column/index.tsx b/packages/client/src/layouts/app-single-column/index.tsx index 702f6d2..f805817 100644 --- a/packages/client/src/layouts/app-single-column/index.tsx +++ b/packages/client/src/layouts/app-single-column/index.tsx @@ -1,7 +1,9 @@ -import { Layout as SemiLayout } from '@douyinfe/semi-ui'; import React from 'react'; +import { Layout as SemiLayout } from '@douyinfe/semi-ui'; + import { AppRouterHeader } from '../app-router-header'; + import styles from './index.module.scss'; const { Content } = SemiLayout; diff --git a/packages/client/src/layouts/double-column/index.tsx b/packages/client/src/layouts/double-column/index.tsx index 003a6a7..4a9bc7f 100644 --- a/packages/client/src/layouts/double-column/index.tsx +++ b/packages/client/src/layouts/double-column/index.tsx @@ -1,12 +1,15 @@ -import { IconChevronLeft, IconChevronRight } from '@douyinfe/semi-icons'; -import { Button, Layout as SemiLayout } from '@douyinfe/semi-ui'; -import cls from 'classnames'; -import { throttle } from 'helpers/throttle'; -import { useDragableWidth } from 'hooks/use-dragable-width'; import React, { useMemo } from 'react'; import SplitPane from 'react-split-pane'; +import { IconChevronLeft, IconChevronRight } from '@douyinfe/semi-icons'; +import { Button, Layout as SemiLayout } from '@douyinfe/semi-ui'; + +import cls from 'classnames'; +import { throttle } from 'helpers/throttle'; +import { useDragableWidth } from 'hooks/use-dragable-width'; + import { RouterHeader } from '../router-header'; + import styles from './index.module.scss'; const { Sider, Content } = SemiLayout; diff --git a/packages/client/src/layouts/public-double-column/index.tsx b/packages/client/src/layouts/public-double-column/index.tsx index 6af27f2..79c85b9 100644 --- a/packages/client/src/layouts/public-double-column/index.tsx +++ b/packages/client/src/layouts/public-double-column/index.tsx @@ -1,10 +1,12 @@ +import React, { useMemo } from 'react'; +import SplitPane from 'react-split-pane'; + import { IconChevronLeft, IconChevronRight } from '@douyinfe/semi-icons'; import { Button, Layout as SemiLayout } from '@douyinfe/semi-ui'; + import cls from 'classnames'; import { throttle } from 'helpers/throttle'; import { useDragableWidth } from 'hooks/use-dragable-width'; -import React, { useMemo } from 'react'; -import SplitPane from 'react-split-pane'; import styles from './index.module.scss'; diff --git a/packages/client/src/layouts/router-header/index.tsx b/packages/client/src/layouts/router-header/index.tsx index f5efde8..4294758 100644 --- a/packages/client/src/layouts/router-header/index.tsx +++ b/packages/client/src/layouts/router-header/index.tsx @@ -1,4 +1,7 @@ +import React, { useCallback } from 'react'; + import { Button, Layout as SemiLayout, Nav, Space } from '@douyinfe/semi-ui'; + import { Message } from 'components/message'; import { OrganizationPublicSwitcher } from 'components/organization/public-switcher'; import { Theme } from 'components/theme'; @@ -6,7 +9,6 @@ import { User } from 'components/user'; import { useUser } from 'data/user'; import { IsOnMobile } from 'hooks/use-on-mobile'; import Router, { useRouter } from 'next/router'; -import React, { useCallback } from 'react'; const { Header: SemiHeader } = SemiLayout; diff --git a/packages/client/src/layouts/single-column/index.tsx b/packages/client/src/layouts/single-column/index.tsx index c6d13ec..4ec319e 100644 --- a/packages/client/src/layouts/single-column/index.tsx +++ b/packages/client/src/layouts/single-column/index.tsx @@ -1,7 +1,9 @@ -import { Layout as SemiLayout } from '@douyinfe/semi-ui'; import React from 'react'; +import { Layout as SemiLayout } from '@douyinfe/semi-ui'; + import { RouterHeader } from '../router-header'; + import styles from './index.module.scss'; const { Content } = SemiLayout; diff --git a/packages/client/src/pages/_app.tsx b/packages/client/src/pages/_app.tsx index 440fa1b..b3ff830 100644 --- a/packages/client/src/pages/_app.tsx +++ b/packages/client/src/pages/_app.tsx @@ -1,21 +1,23 @@ -import 'tiptap/fix-match-nodes'; -import 'viewerjs/dist/viewer.css'; -import 'styles/globals.scss'; -import 'tiptap/core/styles/index.scss'; import '@react-pdf-viewer/core/lib/styles/index.css'; import '@react-pdf-viewer/default-layout/lib/styles/index.css'; -import 'thirtypart/array-prototype-at'; - import { Worker } from '@react-pdf-viewer/core'; +import React from 'react'; +import { Hydrate, QueryClient, QueryClientProvider } from 'react-query'; + +import 'tiptap/fix-match-nodes'; +import 'tiptap/core/styles/index.scss'; +import { preloadTiptapResources } from 'tiptap/preload'; + import { isMobile } from 'helpers/env'; import { DocumentVersionControl } from 'hooks/use-document-version'; import { IsOnMobile } from 'hooks/use-on-mobile'; import { Theme } from 'hooks/use-theme'; import App from 'next/app'; import Head from 'next/head'; -import React from 'react'; -import { Hydrate, QueryClient, QueryClientProvider } from 'react-query'; -import { preloadTiptapResources } from 'tiptap/preload'; + +import 'viewerjs/dist/viewer.css'; +import 'styles/globals.scss'; +import 'thirtypart/array-prototype-at'; class MyApp extends App<{ isMobile: boolean }> { state = { diff --git a/packages/client/src/pages/admin/index.tsx b/packages/client/src/pages/admin/index.tsx index 15b4bac..da72ebf 100644 --- a/packages/client/src/pages/admin/index.tsx +++ b/packages/client/src/pages/admin/index.tsx @@ -1,4 +1,7 @@ +import React, { useCallback } from 'react'; + import { Banner, Typography } from '@douyinfe/semi-ui'; + import { SystemConfig } from 'components/admin/system-config'; import { Seo } from 'components/seo'; import { useUser } from 'data/user'; @@ -6,7 +9,6 @@ import { Forbidden } from 'illustrations/forbidden'; import { SingleColumnLayout } from 'layouts/single-column'; import type { NextPage } from 'next'; import Router, { useRouter } from 'next/router'; -import React, { useCallback } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/pages/app/index.tsx b/packages/client/src/pages/app/index.tsx index d1e032e..fd4f5ea 100644 --- a/packages/client/src/pages/app/index.tsx +++ b/packages/client/src/pages/app/index.tsx @@ -1,5 +1,9 @@ +import { useCallback, useEffect } from 'react'; + import { Avatar, Button, Table, Typography } from '@douyinfe/semi-ui'; + import { IOrganization } from '@think/domains'; + import { DataRender } from 'components/data-render'; import { LocaleTime } from 'components/locale-time'; import { Seo } from 'components/seo'; @@ -7,7 +11,6 @@ import { usePeronalOrganization, useUserOrganizations } from 'data/organization' import { SingleColumnLayout } from 'layouts/single-column'; import Link from 'next/link'; import Router from 'next/router'; -import { useCallback, useEffect } from 'react'; const { Title, Paragraph } = Typography; const { Column } = Table; diff --git a/packages/client/src/pages/app/org/[organizationId]/index.tsx b/packages/client/src/pages/app/org/[organizationId]/index.tsx index 2e1739d..b047ceb 100644 --- a/packages/client/src/pages/app/org/[organizationId]/index.tsx +++ b/packages/client/src/pages/app/org/[organizationId]/index.tsx @@ -1,5 +1,9 @@ +import React, { useEffect, useMemo } from 'react'; + import { Avatar, Button, List, Table, Typography } from '@douyinfe/semi-ui'; + import { DocumentApiDefinition, IDocument, IOrganization, StarApiDefinition } from '@think/domains'; + import { DataRender } from 'components/data-render'; import { DocumentActions } from 'components/document/actions'; import { Empty } from 'components/empty'; @@ -14,7 +18,6 @@ import { useToggle } from 'hooks/use-toggle'; import { AppSingleColumnLayout } from 'layouts/app-single-column'; import type { NextPage } from 'next'; import Link from 'next/link'; -import React, { useEffect, useMemo } from 'react'; import { serverPrefetcher } from 'services/server-prefetcher'; import styles from './index.module.scss'; diff --git a/packages/client/src/pages/app/org/[organizationId]/setting/index.tsx b/packages/client/src/pages/app/org/[organizationId]/setting/index.tsx index 160b723..29813dd 100644 --- a/packages/client/src/pages/app/org/[organizationId]/setting/index.tsx +++ b/packages/client/src/pages/app/org/[organizationId]/setting/index.tsx @@ -1,10 +1,13 @@ +import React, { useCallback } from 'react'; + import { Typography } from '@douyinfe/semi-ui'; + import { IOrganization } from '@think/domains'; + import { OrganizationSetting } from 'components/organization/setting'; import { AppSingleColumnLayout } from 'layouts/app-single-column'; import { NextPage } from 'next'; import Router, { useRouter } from 'next/router'; -import React, { useCallback } from 'react'; interface IProps { organizationId: IOrganization['id']; diff --git a/packages/client/src/pages/app/org/[organizationId]/star/index.tsx b/packages/client/src/pages/app/org/[organizationId]/star/index.tsx index a6586cc..ab4df03 100644 --- a/packages/client/src/pages/app/org/[organizationId]/star/index.tsx +++ b/packages/client/src/pages/app/org/[organizationId]/star/index.tsx @@ -1,5 +1,9 @@ +import React from 'react'; + import { List, Typography } from '@douyinfe/semi-ui'; + import { StarApiDefinition } from '@think/domains'; + import { DataRender } from 'components/data-render'; import { DocumentCard, DocumentCardPlaceholder } from 'components/document/card'; import { Empty } from 'components/empty'; @@ -14,7 +18,6 @@ import { import { useRouterQuery } from 'hooks/use-router-query'; import { AppSingleColumnLayout } from 'layouts/app-single-column'; import type { NextPage } from 'next'; -import React from 'react'; import { serverPrefetcher } from 'services/server-prefetcher'; import styles from './index.module.scss'; diff --git a/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/doc/[documentId]/edit/index.tsx b/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/doc/[documentId]/edit/index.tsx index 318c634..846159c 100644 --- a/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/doc/[documentId]/edit/index.tsx +++ b/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/doc/[documentId]/edit/index.tsx @@ -1,8 +1,10 @@ +import React from 'react'; + import { DocumentApiDefinition, IDocument } from '@think/domains'; + import { DocumentEditor } from 'components/document/editor'; import { getDocumentDetail } from 'data/document'; import { NextPage } from 'next'; -import React from 'react'; import { serverPrefetcher } from 'services/server-prefetcher'; interface IProps { diff --git a/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/doc/[documentId]/index.tsx b/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/doc/[documentId]/index.tsx index be539a5..083746b 100644 --- a/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/doc/[documentId]/index.tsx +++ b/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/doc/[documentId]/index.tsx @@ -1,11 +1,13 @@ +import React from 'react'; + import { DocumentApiDefinition, IDocument, IWiki, WikiApiDefinition } from '@think/domains'; + import { DocumentReader } from 'components/document/reader'; import { WikiTocs } from 'components/wiki/tocs'; import { getDocumentDetail } from 'data/document'; import { getWikiTocs } from 'data/wiki'; import { AppDoubleColumnLayout } from 'layouts/app-double-column'; import { NextPage } from 'next'; -import React from 'react'; import { serverPrefetcher } from 'services/server-prefetcher'; interface IProps { diff --git a/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/index.tsx b/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/index.tsx index 623260e..a89b129 100644 --- a/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/index.tsx +++ b/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/index.tsx @@ -1,12 +1,15 @@ +import React from 'react'; + import { Spin } from '@douyinfe/semi-ui'; + import { IWiki, WikiApiDefinition } from '@think/domains'; + import { DataRender } from 'components/data-render'; import { DocumentReader } from 'components/document/reader'; import { WikiTocs } from 'components/wiki/tocs'; import { getWikiDetail, getWikiTocs, useWikiDetail } from 'data/wiki'; import { AppDoubleColumnLayout } from 'layouts/app-double-column'; import { NextPage } from 'next'; -import React from 'react'; import { serverPrefetcher } from 'services/server-prefetcher'; interface IProps { diff --git a/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/setting/index.tsx b/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/setting/index.tsx index d1055fa..f7da019 100644 --- a/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/setting/index.tsx +++ b/packages/client/src/pages/app/org/[organizationId]/wiki/[wikiId]/setting/index.tsx @@ -1,11 +1,13 @@ +import React, { useCallback } from 'react'; + import { IWiki, WikiApiDefinition } from '@think/domains'; + import { WikiSetting } from 'components/wiki/setting'; import { WikiTocs } from 'components/wiki/tocs'; import { getWikiMembers, getWikiTocs } from 'data/wiki'; import { AppDoubleColumnLayout } from 'layouts/app-double-column'; import { NextPage } from 'next'; import Router, { useRouter } from 'next/router'; -import React, { useCallback } from 'react'; import { serverPrefetcher } from 'services/server-prefetcher'; interface IProps { diff --git a/packages/client/src/pages/app/org/[organizationId]/wiki/index.tsx b/packages/client/src/pages/app/org/[organizationId]/wiki/index.tsx index a831ab6..88fb217 100644 --- a/packages/client/src/pages/app/org/[organizationId]/wiki/index.tsx +++ b/packages/client/src/pages/app/org/[organizationId]/wiki/index.tsx @@ -1,5 +1,9 @@ +import React from 'react'; + import { List, TabPane, Tabs, Typography } from '@douyinfe/semi-ui'; + import { WikiApiDefinition } from '@think/domains'; + import { DataRender } from 'components/data-render'; import { Empty } from 'components/empty'; import { Seo } from 'components/seo'; @@ -10,7 +14,6 @@ import { useRouterQuery } from 'hooks/use-router-query'; import { CreateWikiIllustration } from 'illustrations/create-wiki'; import { AppSingleColumnLayout } from 'layouts/app-single-column'; import type { NextPage } from 'next'; -import React from 'react'; import { serverPrefetcher } from 'services/server-prefetcher'; const grid = { diff --git a/packages/client/src/pages/app/org/create/index.tsx b/packages/client/src/pages/app/org/create/index.tsx index acb5d7d..9cd66b7 100644 --- a/packages/client/src/pages/app/org/create/index.tsx +++ b/packages/client/src/pages/app/org/create/index.tsx @@ -1,13 +1,16 @@ +import { useCallback, useRef, useState } from 'react'; + import { Avatar, Button, Form, Typography } from '@douyinfe/semi-ui'; import { FormApi } from '@douyinfe/semi-ui/lib/es/form'; + import { ORGANIZATION_LOGOS } from '@think/constants'; + import { ImageUploader } from 'components/image-uploader'; import { Seo } from 'components/seo'; import { useCreateOrganization } from 'data/organization'; import { useToggle } from 'hooks/use-toggle'; import { SingleColumnLayout } from 'layouts/single-column'; import Router from 'next/router'; -import { useCallback, useRef, useState } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/pages/feature/csrf/index.tsx b/packages/client/src/pages/feature/csrf/index.tsx index da2b09d..d6b4edf 100644 --- a/packages/client/src/pages/feature/csrf/index.tsx +++ b/packages/client/src/pages/feature/csrf/index.tsx @@ -1,6 +1,7 @@ +import React, { useRef, useState } from 'react'; + import { SingleColumnLayout } from 'layouts/single-column'; import { useRouter } from 'next/router'; -import React, { useRef, useState } from 'react'; const Page = () => { const $container = useRef(); diff --git a/packages/client/src/pages/feature/editor/index.tsx b/packages/client/src/pages/feature/editor/index.tsx index 783cbd4..ff135fe 100644 --- a/packages/client/src/pages/feature/editor/index.tsx +++ b/packages/client/src/pages/feature/editor/index.tsx @@ -1,8 +1,10 @@ +import React, { useRef } from 'react'; + +import { CollaborationEditor, ICollaborationEditorProps, ICollaborationRefProps } from 'tiptap/editor'; + import { useUser } from 'data/user'; import { SingleColumnLayout } from 'layouts/single-column'; import { useRouter } from 'next/router'; -import React, { useRef } from 'react'; -import { CollaborationEditor, ICollaborationEditorProps, ICollaborationRefProps } from 'tiptap/editor'; const Page = () => { const $container = useRef(); diff --git a/packages/client/src/pages/find/index.tsx b/packages/client/src/pages/find/index.tsx index 14d21cc..7a0f59b 100644 --- a/packages/client/src/pages/find/index.tsx +++ b/packages/client/src/pages/find/index.tsx @@ -1,5 +1,9 @@ +import React from 'react'; + import { List, Pagination, Typography } from '@douyinfe/semi-ui'; + import { WikiApiDefinition } from '@think/domains'; + import { DataRender } from 'components/data-render'; import { Empty } from 'components/empty'; import { Seo } from 'components/seo'; @@ -7,7 +11,6 @@ import { WikiCard, WikiCardPlaceholder } from 'components/wiki/card'; import { getAllPublicWikis, useAllPublicWikis } from 'data/wiki'; import { SingleColumnLayout } from 'layouts/single-column'; import type { NextPage } from 'next'; -import React from 'react'; import { serverPrefetcher } from 'services/server-prefetcher'; const grid = { diff --git a/packages/client/src/pages/forgetPassword/index.tsx b/packages/client/src/pages/forgetPassword/index.tsx index 1c258d0..7bbad66 100644 --- a/packages/client/src/pages/forgetPassword/index.tsx +++ b/packages/client/src/pages/forgetPassword/index.tsx @@ -1,4 +1,7 @@ +import React, { useCallback } from 'react'; + import { Layout, Modal, Space, Typography } from '@douyinfe/semi-ui'; + import { Author } from 'components/author'; import { LogoImage, LogoText } from 'components/logo'; import { Seo } from 'components/seo'; @@ -6,7 +9,6 @@ import { ResetPassword } from 'components/user/reset-password'; import { useRouterQuery } from 'hooks/use-router-query'; import Link from 'next/link'; import Router from 'next/router'; -import React, { useCallback } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/pages/index.tsx b/packages/client/src/pages/index.tsx index e894fc0..2c9fdb8 100644 --- a/packages/client/src/pages/index.tsx +++ b/packages/client/src/pages/index.tsx @@ -1,11 +1,13 @@ +import React, { useCallback } from 'react'; + import { Button, Typography } from '@douyinfe/semi-ui'; + import { Seo } from 'components/seo'; import { toLogin, useUser } from 'data/user'; import { TeamWorkIllustration } from 'illustrations/team-work'; import { SingleColumnLayout } from 'layouts/single-column'; import type { NextPage } from 'next'; import Router from 'next/router'; -import React, { useCallback } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/pages/login/index.tsx b/packages/client/src/pages/login/index.tsx index 0559b23..ce7e971 100644 --- a/packages/client/src/pages/login/index.tsx +++ b/packages/client/src/pages/login/index.tsx @@ -1,4 +1,7 @@ +import React, { useCallback } from 'react'; + import { Button, Form, Layout, Space, Typography } from '@douyinfe/semi-ui'; + import { Author } from 'components/author'; import { LogoImage, LogoText } from 'components/logo'; import { Seo } from 'components/seo'; @@ -6,7 +9,6 @@ import { useUser } from 'data/user'; import { useRouterQuery } from 'hooks/use-router-query'; import { useToggle } from 'hooks/use-toggle'; import Link from 'next/link'; -import React, { useCallback } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/pages/register/index.tsx b/packages/client/src/pages/register/index.tsx index 2129f4d..452433c 100644 --- a/packages/client/src/pages/register/index.tsx +++ b/packages/client/src/pages/register/index.tsx @@ -1,4 +1,7 @@ +import React, { useCallback, useState } from 'react'; + import { Button, Col, Form, Layout, Modal, Row, Space, Toast, Typography } from '@douyinfe/semi-ui'; + import { Author } from 'components/author'; import { LogoImage, LogoText } from 'components/logo'; import { Seo } from 'components/seo'; @@ -9,7 +12,6 @@ import { useRouterQuery } from 'hooks/use-router-query'; import { useToggle } from 'hooks/use-toggle'; import Link from 'next/link'; import Router from 'next/router'; -import React, { useCallback, useState } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/pages/share/document/[documentId]/index.tsx b/packages/client/src/pages/share/document/[documentId]/index.tsx index ad022cb..09738ae 100644 --- a/packages/client/src/pages/share/document/[documentId]/index.tsx +++ b/packages/client/src/pages/share/document/[documentId]/index.tsx @@ -1,8 +1,10 @@ +import React from 'react'; + import { DocumentApiDefinition, IDocument } from '@think/domains'; + import { DocumentPublicReader } from 'components/document/reader/public'; import { getPublicDocumentDetail } from 'data/document'; import { NextPage } from 'next'; -import React from 'react'; import { serverPrefetcher } from 'services/server-prefetcher'; interface IProps { diff --git a/packages/client/src/pages/share/wiki/[wikiId]/document/[documentId]/index.tsx b/packages/client/src/pages/share/wiki/[wikiId]/document/[documentId]/index.tsx index 544976e..38648bd 100644 --- a/packages/client/src/pages/share/wiki/[wikiId]/document/[documentId]/index.tsx +++ b/packages/client/src/pages/share/wiki/[wikiId]/document/[documentId]/index.tsx @@ -1,11 +1,13 @@ +import React from 'react'; + import { DocumentApiDefinition, IDocument, IWiki, WikiApiDefinition } from '@think/domains'; + import { DocumentPublicReader } from 'components/document/reader/public'; import { WikiPublicTocs } from 'components/wiki/tocs/public'; import { getPublicDocumentDetail } from 'data/document'; import { getPublicWikiTocs } from 'data/wiki'; import { PublicDoubleColumnLayout } from 'layouts/public-double-column'; import { NextPage } from 'next'; -import React from 'react'; import { serverPrefetcher } from 'services/server-prefetcher'; interface IProps { diff --git a/packages/client/src/pages/share/wiki/[wikiId]/index.tsx b/packages/client/src/pages/share/wiki/[wikiId]/index.tsx index 40d6cb9..dc2634e 100644 --- a/packages/client/src/pages/share/wiki/[wikiId]/index.tsx +++ b/packages/client/src/pages/share/wiki/[wikiId]/index.tsx @@ -1,11 +1,13 @@ +import React from 'react'; + import { IWiki, WikiApiDefinition } from '@think/domains'; + import { DataRender } from 'components/data-render'; import { DocumentPublicReader } from 'components/document/reader/public'; import { WikiPublicTocs } from 'components/wiki/tocs/public'; import { getPublicWikiDetail, getPublicWikiHomeDocument, getPublicWikiTocs, usePublicWikiHomeDoc } from 'data/wiki'; import { PublicDoubleColumnLayout } from 'layouts/public-double-column'; import { NextPage } from 'next'; -import React from 'react'; import { serverPrefetcher } from 'services/server-prefetcher'; interface IProps { diff --git a/packages/client/src/pages/template/[templateId]/index.tsx b/packages/client/src/pages/template/[templateId]/index.tsx index 1a0097c..332208f 100644 --- a/packages/client/src/pages/template/[templateId]/index.tsx +++ b/packages/client/src/pages/template/[templateId]/index.tsx @@ -1,4 +1,5 @@ import { ITemplate, TemplateApiDefinition } from '@think/domains'; + import { TemplateEditor } from 'components/template/editor'; import { getTemplateDetail } from 'data/template'; import { NextPage } from 'next'; diff --git a/packages/client/src/pages/template/index.tsx b/packages/client/src/pages/template/index.tsx index c8d1853..81dc26f 100644 --- a/packages/client/src/pages/template/index.tsx +++ b/packages/client/src/pages/template/index.tsx @@ -1,11 +1,13 @@ +import React, { useCallback } from 'react'; + import { Button, TabPane, Tabs, Typography } from '@douyinfe/semi-ui'; + import { Seo } from 'components/seo'; import { TemplateList } from 'components/template/list'; import { useOwnTemplates, usePublicTemplates } from 'data/template'; import { SingleColumnLayout } from 'layouts/single-column'; import type { NextPage } from 'next'; import Router, { useRouter } from 'next/router'; -import React, { useCallback } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/services/file.ts b/packages/client/src/services/file.ts index 5ff3c23..457b152 100644 --- a/packages/client/src/services/file.ts +++ b/packages/client/src/services/file.ts @@ -1,4 +1,5 @@ import { FILE_CHUNK_SIZE, FileApiDefinition } from '@think/domains'; + import { string } from 'lib0'; import SparkMD5 from 'spark-md5'; diff --git a/packages/client/src/services/http-client.ts b/packages/client/src/services/http-client.ts index 4c57462..4516fec 100644 --- a/packages/client/src/services/http-client.ts +++ b/packages/client/src/services/http-client.ts @@ -1,4 +1,5 @@ import { Toast } from '@douyinfe/semi-ui'; + import axios, { Axios, AxiosRequestConfig, AxiosResponse } from 'axios'; import { toLogin } from 'data/user'; diff --git a/packages/client/src/services/server-prefetcher.ts b/packages/client/src/services/server-prefetcher.ts index 62448b7..3162966 100644 --- a/packages/client/src/services/server-prefetcher.ts +++ b/packages/client/src/services/server-prefetcher.ts @@ -1,6 +1,7 @@ -import { NextPageContext } from 'next'; import { dehydrate, QueryClient } from 'react-query'; +import { NextPageContext } from 'next'; + type PrefetchActions = Array<{ url: string | (string | number)[]; action: (cookie: string) => void; diff --git a/packages/client/src/services/user.ts b/packages/client/src/services/user.ts index 42a5bb4..85efe0b 100644 --- a/packages/client/src/services/user.ts +++ b/packages/client/src/services/user.ts @@ -1,4 +1,5 @@ import { IAuth, IUser, OrganizationApiDefinition } from '@think/domains'; + import Router from 'next/router'; import { HttpClient } from './http-client'; diff --git a/packages/client/src/thirtypart/kityminder/kity-core/core/theme.js b/packages/client/src/thirtypart/kityminder/kity-core/core/theme.js index 459493d..2cad95a 100644 --- a/packages/client/src/thirtypart/kityminder/kity-core/core/theme.js +++ b/packages/client/src/thirtypart/kityminder/kity-core/core/theme.js @@ -61,7 +61,7 @@ define(function (require, exports, module) { }, setTheme: function (name) { - if (name && !_themes[name]) throw new Error('Theme ' + name + ' not exists!'); + if (name && !_themes[name]) return; var lastTheme = this._theme; this._theme = name || null; var container = this.getRenderTarget(); diff --git a/packages/client/src/tiptap/core/all-kit.ts b/packages/client/src/tiptap/core/all-kit.ts index d7fe2a2..226505e 100644 --- a/packages/client/src/tiptap/core/all-kit.ts +++ b/packages/client/src/tiptap/core/all-kit.ts @@ -30,6 +30,7 @@ import { Image } from 'tiptap/core/extensions/image'; import { Indent } from 'tiptap/core/extensions/indent'; import { Italic } from 'tiptap/core/extensions/italic'; import { Katex } from 'tiptap/core/extensions/katex'; +import { LineHeight } from 'tiptap/core/extensions/line-height'; import { Link } from 'tiptap/core/extensions/link'; import { ListItem } from 'tiptap/core/extensions/listItem'; import { Loading } from 'tiptap/core/extensions/loading'; @@ -80,6 +81,7 @@ export const AllExtensions = [ Excalidraw, Focus, FontSize, + LineHeight, Gapcursor, HardBreak, Heading, diff --git a/packages/client/src/tiptap/core/bubble-menu/bubble-menu-plugin.tsx b/packages/client/src/tiptap/core/bubble-menu/bubble-menu-plugin.tsx index 58c8833..61965e4 100644 --- a/packages/client/src/tiptap/core/bubble-menu/bubble-menu-plugin.tsx +++ b/packages/client/src/tiptap/core/bubble-menu/bubble-menu-plugin.tsx @@ -1,7 +1,8 @@ import { Editor, isNodeSelection, isTextSelection, posToDOMRect } from '@tiptap/core'; + import { EditorState, Plugin, PluginKey } from 'prosemirror-state'; import { EditorView } from 'prosemirror-view'; -import tippy, { Instance, Props } from 'tippy.js'; +import tippy, { Instance, Props, sticky } from 'tippy.js'; export interface BubbleMenuPluginProps { pluginKey: PluginKey | string; @@ -144,6 +145,7 @@ export class BubbleMenuView { trigger: 'manual', placement: 'top', hideOnClick: 'toggle', + plugins: [sticky], ...Object.assign( { zIndex: 999, diff --git a/packages/client/src/tiptap/core/extensions/background-color.ts b/packages/client/src/tiptap/core/extensions/background-color.ts index ad8280a..68b836b 100644 --- a/packages/client/src/tiptap/core/extensions/background-color.ts +++ b/packages/client/src/tiptap/core/extensions/background-color.ts @@ -1,5 +1,4 @@ import '@tiptap/extension-text-style'; - import { Extension } from '@tiptap/core'; export type ColorOptions = { diff --git a/packages/client/src/tiptap/core/extensions/clipboard.ts b/packages/client/src/tiptap/core/extensions/clipboard.ts index 158d845..98267e1 100644 --- a/packages/client/src/tiptap/core/extensions/clipboard.ts +++ b/packages/client/src/tiptap/core/extensions/clipboard.ts @@ -1,9 +1,10 @@ import { Extension } from '@tiptap/core'; -import { Fragment } from 'prosemirror-model'; -import { Plugin, PluginKey } from 'prosemirror-state'; import { EXTENSION_PRIORITY_HIGHEST } from 'tiptap/core/constants'; import { copyNode } from 'tiptap/prose-utils'; +import { Fragment } from 'prosemirror-model'; +import { Plugin, PluginKey } from 'prosemirror-state'; + const isPureText = (content): boolean => { if (!content) return false; diff --git a/packages/client/src/tiptap/core/extensions/code-block.ts b/packages/client/src/tiptap/core/extensions/code-block.ts index 649f7d0..c2211f9 100644 --- a/packages/client/src/tiptap/core/extensions/code-block.ts +++ b/packages/client/src/tiptap/core/extensions/code-block.ts @@ -1,11 +1,12 @@ import { findChildren } from '@tiptap/core'; import BuiltInCodeBlock, { CodeBlockOptions } from '@tiptap/extension-code-block'; import { ReactNodeViewRenderer } from '@tiptap/react'; +import { CodeBlockWrapper } from 'tiptap/core/wrappers/code-block'; + import { lowlight } from 'lowlight/lib/all'; import { Node as ProsemirrorNode } from 'prosemirror-model'; import { Plugin, PluginKey } from 'prosemirror-state'; import { Decoration, DecorationSet } from 'prosemirror-view'; -import { CodeBlockWrapper } from 'tiptap/core/wrappers/code-block'; function parseNodes(nodes: any[], className: string[] = []): { text: string; classes: string[] }[] { return nodes diff --git a/packages/client/src/tiptap/core/extensions/code.ts b/packages/client/src/tiptap/core/extensions/code.ts index 808a869..45bb448 100644 --- a/packages/client/src/tiptap/core/extensions/code.ts +++ b/packages/client/src/tiptap/core/extensions/code.ts @@ -1,8 +1,9 @@ import { Extension } from '@tiptap/core'; import BuiltInCode from '@tiptap/extension-code'; -import codemark from 'prosemirror-codemark'; import { EXTENSION_PRIORITY_LOWER } from 'tiptap/core/constants'; +import codemark from 'prosemirror-codemark'; + export const Code = BuiltInCode.extend({ excludes: null, /** diff --git a/packages/client/src/tiptap/core/extensions/collaboration-cursor/cursor-plugin/index.ts b/packages/client/src/tiptap/core/extensions/collaboration-cursor/cursor-plugin/index.ts index 75cd9a9..d7e7bb3 100644 --- a/packages/client/src/tiptap/core/extensions/collaboration-cursor/cursor-plugin/index.ts +++ b/packages/client/src/tiptap/core/extensions/collaboration-cursor/cursor-plugin/index.ts @@ -1,6 +1,3 @@ -import * as math from 'lib0/math'; -import { Plugin } from 'prosemirror-state'; // eslint-disable-line -import { Decoration, DecorationSet } from 'prosemirror-view'; // eslint-disable-line import { absolutePositionToRelativePosition, relativePositionToAbsolutePosition, @@ -8,6 +5,10 @@ import { yCursorPluginKey, ySyncPluginKey, } from 'tiptap/core/thritypart/y-prosemirror/y-prosemirror'; + +import * as math from 'lib0/math'; +import { Plugin } from 'prosemirror-state'; // eslint-disable-line +import { Decoration, DecorationSet } from 'prosemirror-view'; // eslint-disable-line import * as Y from 'yjs'; /** diff --git a/packages/client/src/tiptap/core/extensions/collaboration-cursor/index.ts b/packages/client/src/tiptap/core/extensions/collaboration-cursor/index.ts index 6bdd8f0..4e21c09 100644 --- a/packages/client/src/tiptap/core/extensions/collaboration-cursor/index.ts +++ b/packages/client/src/tiptap/core/extensions/collaboration-cursor/index.ts @@ -1,4 +1,5 @@ import { Extension } from '@tiptap/core'; + import { EditorState } from 'prosemirror-state'; import { yCursorPlugin } from './cursor-plugin'; diff --git a/packages/client/src/tiptap/core/extensions/collaboration/collaboration.ts b/packages/client/src/tiptap/core/extensions/collaboration/collaboration.ts index 33c8797..d096c28 100644 --- a/packages/client/src/tiptap/core/extensions/collaboration/collaboration.ts +++ b/packages/client/src/tiptap/core/extensions/collaboration/collaboration.ts @@ -6,6 +6,7 @@ import { yUndoPlugin, yUndoPluginKey, } from 'tiptap/core/thritypart/y-prosemirror/y-prosemirror'; + import { UndoManager } from 'yjs'; declare module '@tiptap/core' { diff --git a/packages/client/src/tiptap/core/extensions/collaboration/helpers/is-change-origin.ts b/packages/client/src/tiptap/core/extensions/collaboration/helpers/is-change-origin.ts index 73a5c8e..d5321bd 100644 --- a/packages/client/src/tiptap/core/extensions/collaboration/helpers/is-change-origin.ts +++ b/packages/client/src/tiptap/core/extensions/collaboration/helpers/is-change-origin.ts @@ -1,6 +1,7 @@ -import { Transaction } from 'prosemirror-state'; import { ySyncPluginKey } from 'tiptap/core/thritypart/y-prosemirror/y-prosemirror'; +import { Transaction } from 'prosemirror-state'; + export function isChangeOrigin(transaction: Transaction): boolean { return !!transaction.getMeta(ySyncPluginKey); } diff --git a/packages/client/src/tiptap/core/extensions/color-highlighter.ts b/packages/client/src/tiptap/core/extensions/color-highlighter.ts index 00a178f..e45de0f 100644 --- a/packages/client/src/tiptap/core/extensions/color-highlighter.ts +++ b/packages/client/src/tiptap/core/extensions/color-highlighter.ts @@ -1,7 +1,8 @@ import { Extension } from '@tiptap/core'; -import { Plugin } from 'prosemirror-state'; import { findColors } from 'tiptap/prose-utils'; +import { Plugin } from 'prosemirror-state'; + export const ColorHighlighter = Extension.create({ name: 'colorHighlighter', diff --git a/packages/client/src/tiptap/core/extensions/columns.ts b/packages/client/src/tiptap/core/extensions/columns.ts index 16e8c4f..f11dc01 100644 --- a/packages/client/src/tiptap/core/extensions/columns.ts +++ b/packages/client/src/tiptap/core/extensions/columns.ts @@ -1,7 +1,8 @@ import { mergeAttributes, Node } from '@tiptap/core'; -import { TextSelection } from 'prosemirror-state'; import { addOrDeleteCol, createColumns, gotoCol } from 'tiptap/prose-utils'; +import { TextSelection } from 'prosemirror-state'; + import { EXTENSION_PRIORITY_HIGHEST } from '../constants'; declare module '@tiptap/core' { diff --git a/packages/client/src/tiptap/core/extensions/document-reference.ts b/packages/client/src/tiptap/core/extensions/document-reference.ts index aec8320..1a430fe 100644 --- a/packages/client/src/tiptap/core/extensions/document-reference.ts +++ b/packages/client/src/tiptap/core/extensions/document-reference.ts @@ -1,4 +1,5 @@ import { IUser } from '@think/domains'; + import { mergeAttributes, Node } from '@tiptap/core'; import { ReactNodeViewRenderer } from '@tiptap/react'; import { DocumentReferenceWrapper } from 'tiptap/core/wrappers/document-reference'; diff --git a/packages/client/src/tiptap/core/extensions/dragable.ts b/packages/client/src/tiptap/core/extensions/dragable.ts index e7f69be..a1dd3e4 100644 --- a/packages/client/src/tiptap/core/extensions/dragable.ts +++ b/packages/client/src/tiptap/core/extensions/dragable.ts @@ -1,4 +1,9 @@ +import ReactDOM from 'react-dom'; + import { Extension } from '@tiptap/core'; +import { safePos } from 'tiptap/prose-utils'; +import { ActiveNode, removePossibleTable, selectAncestorNodeByDom } from 'tiptap/prose-utils'; + import { NodeSelection, Plugin as PMPlugin, @@ -8,9 +13,6 @@ import { } from 'prosemirror-state'; import { findParentNodeClosestToPos } from 'prosemirror-utils'; import { __serializeForClipboard, Decoration, DecorationSet, EditorView } from 'prosemirror-view'; -import ReactDOM from 'react-dom'; -import { safePos } from 'tiptap/prose-utils'; -import { ActiveNode, removePossibleTable, selectAncestorNodeByDom } from 'tiptap/prose-utils'; const DragablePluginKey = new PMPluginKey('dragable'); diff --git a/packages/client/src/tiptap/core/extensions/emoji.ts b/packages/client/src/tiptap/core/extensions/emoji.ts index f0eb7a4..ff1d5e0 100644 --- a/packages/client/src/tiptap/core/extensions/emoji.ts +++ b/packages/client/src/tiptap/core/extensions/emoji.ts @@ -1,12 +1,13 @@ import { Node } from '@tiptap/core'; import { ReactRenderer } from '@tiptap/react'; import Suggestion from '@tiptap/suggestion'; -import { Plugin, PluginKey } from 'prosemirror-state'; -import tippy from 'tippy.js'; import { EXTENSION_PRIORITY_HIGHEST } from 'tiptap/core/constants'; import { EmojiList } from 'tiptap/core/wrappers/emoji-list'; import { emojiSearch, emojisToName } from 'tiptap/core/wrappers/emoji-list/emojis'; +import { Plugin, PluginKey } from 'prosemirror-state'; +import tippy from 'tippy.js'; + declare module '@tiptap/core' { interface Commands { emoji: { diff --git a/packages/client/src/tiptap/core/extensions/event-emitter.ts b/packages/client/src/tiptap/core/extensions/event-emitter.ts index 5e24f13..59b1cdf 100644 --- a/packages/client/src/tiptap/core/extensions/event-emitter.ts +++ b/packages/client/src/tiptap/core/extensions/event-emitter.ts @@ -1,7 +1,8 @@ import { Extension } from '@tiptap/core'; -import { EventEmitter as Em } from 'helpers/event-emitter'; import { EXTENSION_PRIORITY_HIGHEST } from 'tiptap/core/constants'; +import { EventEmitter as Em } from 'helpers/event-emitter'; + const event = new Em(); /** diff --git a/packages/client/src/tiptap/core/extensions/excalidraw.ts b/packages/client/src/tiptap/core/extensions/excalidraw.ts index d36da5c..0ba1767 100644 --- a/packages/client/src/tiptap/core/extensions/excalidraw.ts +++ b/packages/client/src/tiptap/core/extensions/excalidraw.ts @@ -1,4 +1,5 @@ import { IUser } from '@think/domains'; + import { mergeAttributes, Node, nodeInputRule } from '@tiptap/core'; import { ReactNodeViewRenderer } from '@tiptap/react'; import { ExcalidrawWrapper } from 'tiptap/core/wrappers/excalidraw'; diff --git a/packages/client/src/tiptap/core/extensions/flow.ts b/packages/client/src/tiptap/core/extensions/flow.ts index 8c795cc..2abe350 100644 --- a/packages/client/src/tiptap/core/extensions/flow.ts +++ b/packages/client/src/tiptap/core/extensions/flow.ts @@ -1,4 +1,5 @@ import { IUser } from '@think/domains'; + import { mergeAttributes, Node, nodeInputRule } from '@tiptap/core'; import { ReactNodeViewRenderer } from '@tiptap/react'; import { FlowWrapper } from 'tiptap/core/wrappers/flow'; diff --git a/packages/client/src/tiptap/core/extensions/focus.ts b/packages/client/src/tiptap/core/extensions/focus.ts index 59fbe52..0746df4 100644 --- a/packages/client/src/tiptap/core/extensions/focus.ts +++ b/packages/client/src/tiptap/core/extensions/focus.ts @@ -1,4 +1,5 @@ import { Extension } from '@tiptap/core'; + import { Plugin, PluginKey } from 'prosemirror-state'; import { Decoration, DecorationSet } from 'prosemirror-view'; diff --git a/packages/client/src/tiptap/core/extensions/font-family.ts b/packages/client/src/tiptap/core/extensions/font-family.ts index 848f3ae..dfa388b 100644 --- a/packages/client/src/tiptap/core/extensions/font-family.ts +++ b/packages/client/src/tiptap/core/extensions/font-family.ts @@ -1,5 +1,4 @@ import '@tiptap/extension-text-style'; - import { Extension } from '@tiptap/core'; declare module '@tiptap/core' { diff --git a/packages/client/src/tiptap/core/extensions/font-size.ts b/packages/client/src/tiptap/core/extensions/font-size.ts index f7df8b7..c96c5ab 100644 --- a/packages/client/src/tiptap/core/extensions/font-size.ts +++ b/packages/client/src/tiptap/core/extensions/font-size.ts @@ -1,5 +1,4 @@ import '@tiptap/extension-text-style'; - import { Extension } from '@tiptap/core'; type FontSizeOptions = { diff --git a/packages/client/src/tiptap/core/extensions/heading.ts b/packages/client/src/tiptap/core/extensions/heading.ts index c163809..26c2fad 100644 --- a/packages/client/src/tiptap/core/extensions/heading.ts +++ b/packages/client/src/tiptap/core/extensions/heading.ts @@ -1 +1,111 @@ -export { Heading } from '@tiptap/extension-heading'; +import { mergeAttributes, Node, textblockTypeInputRule } from '@tiptap/core'; + +export type Level = 1 | 2 | 3 | 4 | 5 | 6; + +export interface HeadingOptions { + levels: Level[]; + HTMLAttributes: Record; +} + +declare module '@tiptap/core' { + interface Commands { + heading: { + /** + * Set a heading node + */ + setHeading: (attributes: { level: Level }) => ReturnType; + /** + * Toggle a heading node + */ + toggleHeading: (attributes: { level: Level }) => ReturnType; + }; + } +} + +export const Heading = Node.create({ + name: 'heading', + + addOptions() { + return { + levels: [1, 2, 3, 4, 5, 6], + HTMLAttributes: {}, + }; + }, + + content: 'inline*', + + group: 'block', + + defining: true, + + addAttributes() { + return { + level: { + default: 1, + rendered: false, + }, + lineHeight: { default: null }, + }; + }, + + parseHTML() { + return this.options.levels.map((level: Level) => ({ + tag: `h${level}`, + attrs: { level }, + })); + }, + + renderHTML({ node, HTMLAttributes }) { + const hasLevel = this.options.levels.includes(node.attrs.level); + const level = hasLevel ? node.attrs.level : this.options.levels[0]; + + return [`h${level}`, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]; + }, + + addCommands() { + return { + setHeading: + (attributes) => + ({ commands }) => { + if (!this.options.levels.includes(attributes.level)) { + return false; + } + + return commands.setNode(this.name, attributes); + }, + toggleHeading: + (attributes) => + ({ commands }) => { + if (!this.options.levels.includes(attributes.level)) { + return false; + } + + return commands.toggleNode(this.name, 'paragraph', attributes); + }, + }; + }, + + addKeyboardShortcuts() { + return this.options.levels.reduce( + (items, level) => ({ + ...items, + ...{ + [`Mod-Alt-${level}`]: () => this.editor.commands.toggleHeading({ level }), + }, + }), + {} + ); + }, + + addInputRules() { + return this.options.levels.map((level) => { + return textblockTypeInputRule({ + find: new RegExp(`^(#{1,${level}})\\s$`), + type: this.type, + getAttributes: { + level, + }, + }); + }); + }, +}); diff --git a/packages/client/src/tiptap/core/extensions/horizontal-rule.ts b/packages/client/src/tiptap/core/extensions/horizontal-rule.ts index 6955be0..afbe85b 100644 --- a/packages/client/src/tiptap/core/extensions/horizontal-rule.ts +++ b/packages/client/src/tiptap/core/extensions/horizontal-rule.ts @@ -1,4 +1,5 @@ import { mergeAttributes, Node, nodeInputRule } from '@tiptap/core'; + import { TextSelection } from 'prosemirror-state'; export interface HorizontalRuleOptions { diff --git a/packages/client/src/tiptap/core/extensions/iframe.ts b/packages/client/src/tiptap/core/extensions/iframe.ts index 5b34c0c..e1787e7 100644 --- a/packages/client/src/tiptap/core/extensions/iframe.ts +++ b/packages/client/src/tiptap/core/extensions/iframe.ts @@ -1,4 +1,5 @@ import { IUser } from '@think/domains'; + import { mergeAttributes, Node, nodeInputRule } from '@tiptap/core'; import { ReactNodeViewRenderer } from '@tiptap/react'; import { IframeWrapper } from 'tiptap/core/wrappers/iframe'; diff --git a/packages/client/src/tiptap/core/extensions/indent.ts b/packages/client/src/tiptap/core/extensions/indent.ts index 519c1f4..4c57041 100644 --- a/packages/client/src/tiptap/core/extensions/indent.ts +++ b/packages/client/src/tiptap/core/extensions/indent.ts @@ -1,7 +1,8 @@ -import { Command, Extension } from '@tiptap/core'; +import { Extension } from '@tiptap/core'; +import { clamp, getNodeType, isListActive, isListNode } from 'tiptap/prose-utils'; + import { liftListItem, sinkListItem } from 'prosemirror-schema-list'; import { AllSelection, TextSelection, Transaction } from 'prosemirror-state'; -import { clamp, getNodeType, isListActive, isListNode } from 'tiptap/prose-utils'; declare module '@tiptap/core' { interface Commands { @@ -92,7 +93,7 @@ export const Indent = Extension.create({ indent: { default: this.options.defaultIndentLevel, renderHTML: (attributes) => ({ - style: `margin-left: ${attributes.indent}px!important;`, + style: `margin-left: ${attributes.indent}px;`, }), parseHTML: (element) => parseInt(element.style.marginLeft) || this.options.defaultIndentLevel, }, diff --git a/packages/client/src/tiptap/core/extensions/katex.ts b/packages/client/src/tiptap/core/extensions/katex.ts index 7e655d9..c92d4b8 100644 --- a/packages/client/src/tiptap/core/extensions/katex.ts +++ b/packages/client/src/tiptap/core/extensions/katex.ts @@ -1,4 +1,5 @@ import { IUser } from '@think/domains'; + import { mergeAttributes, Node, nodeInputRule } from '@tiptap/core'; import { ReactNodeViewRenderer } from '@tiptap/react'; import { KatexWrapper } from 'tiptap/core/wrappers/katex'; diff --git a/packages/client/src/tiptap/core/extensions/line-height.ts b/packages/client/src/tiptap/core/extensions/line-height.ts new file mode 100644 index 0000000..b63abf7 --- /dev/null +++ b/packages/client/src/tiptap/core/extensions/line-height.ts @@ -0,0 +1,58 @@ +import { Extension } from '@tiptap/core'; + +declare module '@tiptap/core' { + interface Commands { + lineHeight: { + setLineHeight: (val: number) => ReturnType; + unsetLineHeight: () => ReturnType; + }; + } +} + +export const LineHeight = Extension.create({ + name: 'lineHeight', + + addOptions() { + return { + types: ['heading', 'paragraph'], + }; + }, + + addGlobalAttributes() { + return [ + { + types: this.options.types, + attributes: { + fontSize: { + default: null, + parseHTML: (element) => element.style.lineHeight.replace(/['"]+/g, ''), + renderHTML: (attributes) => { + if (!attributes.lineHeight) { + return {}; + } + + return { + style: `line-height: ${attributes.lineHeight}`, + }; + }, + }, + }, + }, + ]; + }, + + addCommands() { + return { + setLineHeight: + (lineHeight) => + ({ commands }) => { + return this.options.types.every((type) => commands.updateAttributes(type, { lineHeight })); + }, + unsetLineHeight: + () => + ({ commands }) => { + return this.options.types.every((type) => commands.resetAttributes(type, 'lineHeight')); + }, + }; + }, +}); diff --git a/packages/client/src/tiptap/core/extensions/loading.ts b/packages/client/src/tiptap/core/extensions/loading.ts index b442c7d..afa90f6 100644 --- a/packages/client/src/tiptap/core/extensions/loading.ts +++ b/packages/client/src/tiptap/core/extensions/loading.ts @@ -1,8 +1,9 @@ import { Editor, Node } from '@tiptap/core'; import { ReactNodeViewRenderer } from '@tiptap/react'; -import { Node as PMNode } from 'prosemirror-state'; import { LoadingWrapper } from 'tiptap/core/wrappers/loading'; +import { Node as PMNode } from 'prosemirror-state'; + export function findLoadingById(editor: Editor, id: string): null | { node: PMNode; pos: number } { let target: PMNode | null = null; let pos = -1; diff --git a/packages/client/src/tiptap/core/extensions/mention.ts b/packages/client/src/tiptap/core/extensions/mention.ts index f8e15c9..2291841 100644 --- a/packages/client/src/tiptap/core/extensions/mention.ts +++ b/packages/client/src/tiptap/core/extensions/mention.ts @@ -1,10 +1,11 @@ import BulitInMention from '@tiptap/extension-mention'; import { ReactRenderer } from '@tiptap/react'; -import { getMentionUser } from 'services/user'; -import tippy from 'tippy.js'; import { MentionList } from 'tiptap/core/wrappers/mention-list'; import { getDatasetAttribute } from 'tiptap/prose-utils'; +import { getMentionUser } from 'services/user'; +import tippy from 'tippy.js'; + const suggestion = { items: async ({ query }) => { const res = await getMentionUser(); diff --git a/packages/client/src/tiptap/core/extensions/mind.ts b/packages/client/src/tiptap/core/extensions/mind.ts index fcf3e57..bbbb198 100644 --- a/packages/client/src/tiptap/core/extensions/mind.ts +++ b/packages/client/src/tiptap/core/extensions/mind.ts @@ -1,4 +1,5 @@ import { IUser } from '@think/domains'; + import { mergeAttributes, Node, nodeInputRule } from '@tiptap/core'; import { ReactNodeViewRenderer } from '@tiptap/react'; import { MindWrapper } from 'tiptap/core/wrappers/mind'; diff --git a/packages/client/src/tiptap/core/extensions/paragraph.ts b/packages/client/src/tiptap/core/extensions/paragraph.ts index bb06121..56a28f0 100644 --- a/packages/client/src/tiptap/core/extensions/paragraph.ts +++ b/packages/client/src/tiptap/core/extensions/paragraph.ts @@ -1,6 +1,62 @@ -import { mergeAttributes } from '@tiptap/core'; -import TitapParagraph from '@tiptap/extension-paragraph'; +import { mergeAttributes, Node } from '@tiptap/core'; -export const Paragraph = TitapParagraph.extend({ - selectable: true, +export interface ParagraphOptions { + HTMLAttributes: Record; +} + +declare module '@tiptap/core' { + interface Commands { + paragraph: { + /** + * Toggle a paragraph + */ + setParagraph: () => ReturnType; + }; + } +} + +export const Paragraph = Node.create({ + name: 'paragraph', + + priority: 1000, + + addOptions() { + return { + HTMLAttributes: {}, + }; + }, + + addAttributes() { + return { + lineHeight: { default: null }, + }; + }, + + group: 'block', + + content: 'inline*', + + parseHTML() { + return [{ tag: 'p' }]; + }, + + renderHTML({ HTMLAttributes, node }) { + return ['p', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]; + }, + + addCommands() { + return { + setParagraph: + () => + ({ commands }) => { + return commands.setNode(this.name); + }, + }; + }, + + addKeyboardShortcuts() { + return { + 'Mod-Alt-0': () => this.editor.commands.setParagraph(), + }; + }, }); diff --git a/packages/client/src/tiptap/core/extensions/paste.ts b/packages/client/src/tiptap/core/extensions/paste.ts index 424c73d..4f69f79 100644 --- a/packages/client/src/tiptap/core/extensions/paste.ts +++ b/packages/client/src/tiptap/core/extensions/paste.ts @@ -1,9 +1,5 @@ import { Editor as CoreEditor, Extension, getSchema } from '@tiptap/core'; import { Document } from '@tiptap/extension-document'; -import { safeJSONParse } from 'helpers/json'; -import { toggleMark } from 'prosemirror-commands'; -import { DOMParser as PMDOMParser, Fragment, Node, Schema } from 'prosemirror-model'; -import { EditorState, Plugin, PluginKey, TextSelection } from 'prosemirror-state'; import { EXTENSION_PRIORITY_HIGHEST } from 'tiptap/core/constants'; import { debug, @@ -17,6 +13,11 @@ import { safePos, } from 'tiptap/prose-utils'; +import { safeJSONParse } from 'helpers/json'; +import { toggleMark } from 'prosemirror-commands'; +import { DOMParser as PMDOMParser, Fragment, Node, Schema } from 'prosemirror-model'; +import { EditorState, Plugin, PluginKey, TextSelection } from 'prosemirror-state'; + const htmlToProsemirror = (editor: CoreEditor, html, isPasteMarkdown = false) => { const firstNode = editor.view.state.doc.content.firstChild; const shouldInsertTitleText = !!(firstNode?.textContent?.length <= 0 ?? true); diff --git a/packages/client/src/tiptap/core/extensions/placeholder.ts b/packages/client/src/tiptap/core/extensions/placeholder.ts index 2e78899..978ed6e 100644 --- a/packages/client/src/tiptap/core/extensions/placeholder.ts +++ b/packages/client/src/tiptap/core/extensions/placeholder.ts @@ -1,4 +1,5 @@ import { Editor, Extension } from '@tiptap/core'; + import { Node as ProsemirrorNode } from 'prosemirror-model'; import { Plugin } from 'prosemirror-state'; import { Decoration, DecorationSet } from 'prosemirror-view'; diff --git a/packages/client/src/tiptap/core/extensions/scroll-to-cursor.ts b/packages/client/src/tiptap/core/extensions/scroll-to-cursor.ts index 9eaa7cb..56d9ccb 100644 --- a/packages/client/src/tiptap/core/extensions/scroll-to-cursor.ts +++ b/packages/client/src/tiptap/core/extensions/scroll-to-cursor.ts @@ -1,7 +1,8 @@ import { Extension } from '@tiptap/core'; -import { Plugin } from 'prosemirror-state'; import { ImagesLoaded } from 'tiptap/image-load'; +import { Plugin } from 'prosemirror-state'; + /** * Options for customizing Scroll2Cursor plugin */ diff --git a/packages/client/src/tiptap/core/extensions/search.ts b/packages/client/src/tiptap/core/extensions/search.ts index ad8712b..61481e2 100644 --- a/packages/client/src/tiptap/core/extensions/search.ts +++ b/packages/client/src/tiptap/core/extensions/search.ts @@ -1,9 +1,10 @@ import { Extension } from '@tiptap/core'; +import { Editor } from 'tiptap/core'; + import { Node as ProsemirrorNode } from 'prosemirror-model'; import { EditorState, Plugin, PluginKey } from 'prosemirror-state'; import { Decoration, DecorationSet } from 'prosemirror-view'; import scrollIntoView from 'scroll-into-view-if-needed'; -import { Editor } from 'tiptap/core'; declare module '@tiptap/core' { interface Commands { diff --git a/packages/client/src/tiptap/core/extensions/selection.ts b/packages/client/src/tiptap/core/extensions/selection.ts index b1a244d..8c48a49 100644 --- a/packages/client/src/tiptap/core/extensions/selection.ts +++ b/packages/client/src/tiptap/core/extensions/selection.ts @@ -1,9 +1,10 @@ import { Extension } from '@tiptap/core'; -import { AllSelection, NodeSelection, Plugin, PluginKey, Selection, TextSelection } from 'prosemirror-state'; -import { Decoration, DecorationSet } from 'prosemirror-view'; import { EXTENSION_PRIORITY_HIGHEST } from 'tiptap/core/constants'; import { getCurrentNode, getNodeAtPos, isInCallout, isInCodeBlock, isTodoListNode } from 'tiptap/prose-utils'; +import { AllSelection, NodeSelection, Plugin, PluginKey, Selection, TextSelection } from 'prosemirror-state'; +import { Decoration, DecorationSet } from 'prosemirror-view'; + export const selectionPluginKey = new PluginKey('selection'); export const getTopLevelNodesFromSelection = (selection: Selection, doc) => { diff --git a/packages/client/src/tiptap/core/extensions/slash.ts b/packages/client/src/tiptap/core/extensions/slash.ts index f380d9a..eb27484 100644 --- a/packages/client/src/tiptap/core/extensions/slash.ts +++ b/packages/client/src/tiptap/core/extensions/slash.ts @@ -1,12 +1,13 @@ import { Node } from '@tiptap/core'; import { ReactRenderer } from '@tiptap/react'; import Suggestion from '@tiptap/suggestion'; -import { Plugin, PluginKey } from 'prosemirror-state'; -import tippy from 'tippy.js'; import { EXTENSION_PRIORITY_HIGHEST } from 'tiptap/core/constants'; import { insertMenuLRUCache, QUICK_INSERT_COMMANDS, transformToCommands } from 'tiptap/core/menus/commands'; import { MenuList } from 'tiptap/core/wrappers/menu-list'; +import { Plugin, PluginKey } from 'prosemirror-state'; +import tippy from 'tippy.js'; + const createSlashExtension = (char: string) => { const extensionName = `quickInsert-${char}`; const extensionPluginKey = new PluginKey('quickInsert'); diff --git a/packages/client/src/tiptap/core/extensions/status.ts b/packages/client/src/tiptap/core/extensions/status.ts index 2edca44..0512423 100644 --- a/packages/client/src/tiptap/core/extensions/status.ts +++ b/packages/client/src/tiptap/core/extensions/status.ts @@ -1,4 +1,5 @@ import { IUser } from '@think/domains'; + import { mergeAttributes, Node } from '@tiptap/core'; import { ReactNodeViewRenderer } from '@tiptap/react'; import { STATUS_COLORS, StatusWrapper } from 'tiptap/core/wrappers/status'; @@ -24,6 +25,7 @@ export const Status = Node.create({ group: 'inline', inline: true, selectable: true, + draggable: true, atom: true, addAttributes() { diff --git a/packages/client/src/tiptap/core/extensions/table-cell.tsx b/packages/client/src/tiptap/core/extensions/table-cell.tsx index 963bf6c..793c955 100644 --- a/packages/client/src/tiptap/core/extensions/table-cell.tsx +++ b/packages/client/src/tiptap/core/extensions/table-cell.tsx @@ -1,12 +1,15 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; + import { IconPlus } from '@douyinfe/semi-icons'; + import { mergeAttributes, Node } from '@tiptap/core'; +import { getCellsInColumn, isRowSelected, isTableSelected, selectRow, selectTable } from 'tiptap/prose-utils'; + import { Tooltip } from 'components/tooltip'; import { Plugin, PluginKey } from 'prosemirror-state'; import { addRowAfter } from 'prosemirror-tables'; import { Decoration, DecorationSet } from 'prosemirror-view'; -import React from 'react'; -import ReactDOM from 'react-dom'; -import { getCellsInColumn, isRowSelected, isTableSelected, selectRow, selectTable } from 'tiptap/prose-utils'; export interface TableCellOptions { HTMLAttributes: Record; diff --git a/packages/client/src/tiptap/core/extensions/table-header.tsx b/packages/client/src/tiptap/core/extensions/table-header.tsx index 4c44e14..b6b5211 100644 --- a/packages/client/src/tiptap/core/extensions/table-header.tsx +++ b/packages/client/src/tiptap/core/extensions/table-header.tsx @@ -1,12 +1,15 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; + import { IconPlus } from '@douyinfe/semi-icons'; + import { mergeAttributes, Node } from '@tiptap/core'; +import { getCellsInRow, isColumnSelected, selectColumn } from 'tiptap/prose-utils'; + import { Tooltip } from 'components/tooltip'; import { Plugin, PluginKey } from 'prosemirror-state'; import { addColumnAfter } from 'prosemirror-tables'; import { Decoration, DecorationSet } from 'prosemirror-view'; -import React from 'react'; -import ReactDOM from 'react-dom'; -import { getCellsInRow, isColumnSelected, selectColumn } from 'tiptap/prose-utils'; export interface TableHeaderOptions { HTMLAttributes: Record; diff --git a/packages/client/src/tiptap/core/extensions/table.ts b/packages/client/src/tiptap/core/extensions/table.ts index 4d5711e..b580d15 100644 --- a/packages/client/src/tiptap/core/extensions/table.ts +++ b/packages/client/src/tiptap/core/extensions/table.ts @@ -1,4 +1,5 @@ import BuiltInTable from '@tiptap/extension-table'; + import { Node as ProseMirrorNode } from 'prosemirror-model'; import { Plugin, PluginKey } from 'prosemirror-state'; import { tableNodeTypes } from 'prosemirror-tables'; diff --git a/packages/client/src/tiptap/core/extensions/task-list.ts b/packages/client/src/tiptap/core/extensions/task-list.ts index 0cb76be..66ae7a9 100644 --- a/packages/client/src/tiptap/core/extensions/task-list.ts +++ b/packages/client/src/tiptap/core/extensions/task-list.ts @@ -1,8 +1,9 @@ import { getNodeType } from '@tiptap/core'; import { TaskList as BuiltInTaskList } from '@tiptap/extension-task-list'; +import { PARSE_HTML_PRIORITY_HIGHEST } from 'tiptap/core/constants'; + import { liftListItem } from 'prosemirror-schema-list'; import { findParentNodeClosestToPos } from 'prosemirror-utils'; -import { PARSE_HTML_PRIORITY_HIGHEST } from 'tiptap/core/constants'; export const TaskList = BuiltInTaskList.extend({ parseHTML() { diff --git a/packages/client/src/tiptap/core/extensions/title.ts b/packages/client/src/tiptap/core/extensions/title.ts index 9b02bfb..d57f8e8 100644 --- a/packages/client/src/tiptap/core/extensions/title.ts +++ b/packages/client/src/tiptap/core/extensions/title.ts @@ -1,8 +1,9 @@ import { mergeAttributes, Node } from '@tiptap/core'; import { ReactNodeViewRenderer } from '@tiptap/react'; +import { getDatasetAttribute, getNodeAtPos, isInTitle, nodeAttrsToDataset } from 'tiptap/prose-utils'; + import { Plugin, PluginKey, TextSelection } from 'prosemirror-state'; import { Decoration, DecorationSet } from 'prosemirror-view'; -import { getDatasetAttribute, getNodeAtPos, isInTitle, nodeAttrsToDataset } from 'tiptap/prose-utils'; import { TitleWrapper } from '../wrappers/title'; diff --git a/packages/client/src/tiptap/core/extensions/trailing-node.ts b/packages/client/src/tiptap/core/extensions/trailing-node.ts index 57d26b0..e6dfb04 100644 --- a/packages/client/src/tiptap/core/extensions/trailing-node.ts +++ b/packages/client/src/tiptap/core/extensions/trailing-node.ts @@ -1,4 +1,5 @@ import { Extension } from '@tiptap/core'; + import { Plugin, PluginKey } from 'prosemirror-state'; /** diff --git a/packages/client/src/tiptap/core/hooks/use-active.tsx b/packages/client/src/tiptap/core/hooks/use-active.tsx index 65c7fb2..4841502 100644 --- a/packages/client/src/tiptap/core/hooks/use-active.tsx +++ b/packages/client/src/tiptap/core/hooks/use-active.tsx @@ -1,7 +1,9 @@ -import { Editor } from '@tiptap/core'; -import { useToggle } from 'hooks/use-toggle'; import React, { useEffect } from 'react'; +import { Editor } from '@tiptap/core'; + +import { useToggle } from 'hooks/use-toggle'; + export const useActive = (editor: Editor, ...args) => { const [active, toggleActive] = useToggle(false); diff --git a/packages/client/src/tiptap/core/hooks/use-attributes.tsx b/packages/client/src/tiptap/core/hooks/use-attributes.tsx index 95191dd..3f27f31 100644 --- a/packages/client/src/tiptap/core/hooks/use-attributes.tsx +++ b/packages/client/src/tiptap/core/hooks/use-attributes.tsx @@ -1,7 +1,9 @@ -import { Editor } from '@tiptap/core'; -import deepEqual from 'deep-equal'; import React, { useEffect, useRef, useState } from 'react'; +import { Editor } from '@tiptap/core'; + +import deepEqual from 'deep-equal'; + type MapFn = (arg: T) => R; function mapSelf(d: T): T { diff --git a/packages/client/src/tiptap/core/index.tsx b/packages/client/src/tiptap/core/index.tsx index 9d8ee88..e901190 100644 --- a/packages/client/src/tiptap/core/index.tsx +++ b/packages/client/src/tiptap/core/index.tsx @@ -1,9 +1,11 @@ +import { DependencyList, useEffect, useState } from 'react'; + import { EditorOptions } from '@tiptap/core'; import { Editor as BuiltInEditor } from '@tiptap/react'; import { EditorContent, NodeViewContent, NodeViewWrapper } from '@tiptap/react'; + import { EventEmitter } from 'helpers/event-emitter'; import { throttle } from 'helpers/throttle'; -import { DependencyList, useEffect, useState } from 'react'; function useForceUpdate() { const [, setValue] = useState(0); diff --git a/packages/client/src/tiptap/core/menus/_event.ts b/packages/client/src/tiptap/core/menus/_event.ts index e0f3ec8..cf06fa7 100644 --- a/packages/client/src/tiptap/core/menus/_event.ts +++ b/packages/client/src/tiptap/core/menus/_event.ts @@ -1,6 +1,7 @@ -import { EventEmitter } from 'helpers/event-emitter'; import { Editor } from 'tiptap/core'; +import { EventEmitter } from 'helpers/event-emitter'; + const getEventEmitter = (editor: Editor): EventEmitter => { try { const event = editor.eventEmitter; diff --git a/packages/client/src/tiptap/core/menus/align/index.tsx b/packages/client/src/tiptap/core/menus/align/index.tsx index 9960797..bfd5979 100644 --- a/packages/client/src/tiptap/core/menus/align/index.tsx +++ b/packages/client/src/tiptap/core/menus/align/index.tsx @@ -1,6 +1,8 @@ +import React, { useCallback, useMemo } from 'react'; + import { IconAlignCenter, IconAlignJustify, IconAlignLeft, IconAlignRight } from '@douyinfe/semi-icons'; import { Button, Dropdown, Tooltip } from '@douyinfe/semi-ui'; -import React, { useCallback, useMemo } from 'react'; + import { Editor } from 'tiptap/core'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; diff --git a/packages/client/src/tiptap/core/menus/attachment/bubble.tsx b/packages/client/src/tiptap/core/menus/attachment/bubble.tsx index d246ae9..a78aab6 100644 --- a/packages/client/src/tiptap/core/menus/attachment/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/attachment/bubble.tsx @@ -1,12 +1,15 @@ +import { useCallback } from 'react'; + import { IconCopy, IconDelete } from '@douyinfe/semi-icons'; import { Button, Space } from '@douyinfe/semi-ui'; -import { Divider } from 'components/divider'; -import { Tooltip } from 'components/tooltip'; -import { useCallback } from 'react'; + import { BubbleMenu } from 'tiptap/core/bubble-menu'; import { Attachment } from 'tiptap/core/extensions/attachment'; import { copyNode, deleteNode } from 'tiptap/prose-utils'; +import { Divider } from 'components/divider'; +import { Tooltip } from 'components/tooltip'; + export const AttachmentBubbleMenu = ({ editor }) => { const copyMe = useCallback(() => copyNode(Attachment.name, editor), [editor]); const deleteMe = useCallback(() => deleteNode(Attachment.name, editor), [editor]); diff --git a/packages/client/src/tiptap/core/menus/attachment/index.tsx b/packages/client/src/tiptap/core/menus/attachment/index.tsx index b8cbff7..f2f6150 100644 --- a/packages/client/src/tiptap/core/menus/attachment/index.tsx +++ b/packages/client/src/tiptap/core/menus/attachment/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { AttachmentBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/background-color/index.tsx b/packages/client/src/tiptap/core/menus/background-color/index.tsx index 3315b91..3347874 100644 --- a/packages/client/src/tiptap/core/menus/background-color/index.tsx +++ b/packages/client/src/tiptap/core/menus/background-color/index.tsx @@ -1,13 +1,16 @@ +import React, { useCallback } from 'react'; + import { IconMark } from '@douyinfe/semi-icons'; import { Button } from '@douyinfe/semi-ui'; -import { ColorPicker } from 'components/color-picker'; -import { Tooltip } from 'components/tooltip'; -import React, { useCallback } from 'react'; + import { Editor } from 'tiptap/core'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; import { useAttributes } from 'tiptap/core/hooks/use-attributes'; +import { ColorPicker } from 'components/color-picker'; +import { Tooltip } from 'components/tooltip'; + const FlexStyle: React.CSSProperties = { display: 'inline-flex', flexDirection: 'column', diff --git a/packages/client/src/tiptap/core/menus/blockquote/index.tsx b/packages/client/src/tiptap/core/menus/blockquote/index.tsx index 65ecc44..18adffc 100644 --- a/packages/client/src/tiptap/core/menus/blockquote/index.tsx +++ b/packages/client/src/tiptap/core/menus/blockquote/index.tsx @@ -1,12 +1,15 @@ -import { Button } from '@douyinfe/semi-ui'; -import { IconQuote } from 'components/icons'; -import { Tooltip } from 'components/tooltip'; import React, { useCallback } from 'react'; + +import { Button } from '@douyinfe/semi-ui'; + import { Editor } from 'tiptap/core'; import { Blockquote as BlockquoteExtension } from 'tiptap/core/extensions/blockquote'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; +import { IconQuote } from 'components/icons'; +import { Tooltip } from 'components/tooltip'; + export const Blockquote: React.FC<{ editor: Editor }> = ({ editor }) => { const isTitleActive = useActive(editor, Title.name); const isBlockquoteActive = useActive(editor, BlockquoteExtension.name); diff --git a/packages/client/src/tiptap/core/menus/bold/index.tsx b/packages/client/src/tiptap/core/menus/bold/index.tsx index aa3517b..170b582 100644 --- a/packages/client/src/tiptap/core/menus/bold/index.tsx +++ b/packages/client/src/tiptap/core/menus/bold/index.tsx @@ -1,12 +1,15 @@ +import React, { useCallback } from 'react'; + import { IconBold } from '@douyinfe/semi-icons'; import { Button } from '@douyinfe/semi-ui'; -import { Tooltip } from 'components/tooltip'; -import React, { useCallback } from 'react'; + import { Editor } from 'tiptap/core'; import { Bold as BoldExtension } from 'tiptap/core/extensions/bold'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; +import { Tooltip } from 'components/tooltip'; + export const Bold: React.FC<{ editor: Editor }> = ({ editor }) => { const isTitleActive = useActive(editor, Title.name); const isBoldActive = useActive(editor, BoldExtension.name); diff --git a/packages/client/src/tiptap/core/menus/bullet-list/index.tsx b/packages/client/src/tiptap/core/menus/bullet-list/index.tsx index b7463d0..9457a48 100644 --- a/packages/client/src/tiptap/core/menus/bullet-list/index.tsx +++ b/packages/client/src/tiptap/core/menus/bullet-list/index.tsx @@ -1,12 +1,15 @@ -import { Button } from '@douyinfe/semi-ui'; -import { IconList } from 'components/icons'; -import { Tooltip } from 'components/tooltip'; import React, { useCallback } from 'react'; + +import { Button } from '@douyinfe/semi-ui'; + import { Editor } from 'tiptap/core'; import { BulletList as BulletListExtension } from 'tiptap/core/extensions/bullet-list'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; +import { IconList } from 'components/icons'; +import { Tooltip } from 'components/tooltip'; + export const BulletList: React.FC<{ editor: Editor }> = ({ editor }) => { const isTitleActive = useActive(editor, Title.name); const isBulletListActive = useActive(editor, BulletListExtension.name); diff --git a/packages/client/src/tiptap/core/menus/callout/bubble.tsx b/packages/client/src/tiptap/core/menus/callout/bubble.tsx index 00a21f9..5ef4b50 100644 --- a/packages/client/src/tiptap/core/menus/callout/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/callout/bubble.tsx @@ -1,14 +1,17 @@ +import { useCallback } from 'react'; + import { IconCopy, IconDelete } from '@douyinfe/semi-icons'; import { Button, Popover, Space, Typography } from '@douyinfe/semi-ui'; -import { Divider } from 'components/divider'; -import { IconDrawBoard } from 'components/icons'; -import { Tooltip } from 'components/tooltip'; -import { useCallback } from 'react'; + import { Editor } from 'tiptap/core'; import { BubbleMenu } from 'tiptap/core/bubble-menu'; import { Callout } from 'tiptap/core/extensions/callout'; import { copyNode, deleteNode } from 'tiptap/prose-utils'; +import { Divider } from 'components/divider'; +import { IconDrawBoard } from 'components/icons'; +import { Tooltip } from 'components/tooltip'; + import styles from './bubble.module.scss'; const { Text } = Typography; diff --git a/packages/client/src/tiptap/core/menus/callout/index.tsx b/packages/client/src/tiptap/core/menus/callout/index.tsx index ec5e7b7..28854f5 100644 --- a/packages/client/src/tiptap/core/menus/callout/index.tsx +++ b/packages/client/src/tiptap/core/menus/callout/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { CalloutBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/clear-node-and-marks/index.tsx b/packages/client/src/tiptap/core/menus/clear-node-and-marks/index.tsx index 4ce3d56..e2ce4d4 100644 --- a/packages/client/src/tiptap/core/menus/clear-node-and-marks/index.tsx +++ b/packages/client/src/tiptap/core/menus/clear-node-and-marks/index.tsx @@ -1,8 +1,11 @@ +import React, { useCallback } from 'react'; + import { Button } from '@douyinfe/semi-ui'; + +import { Editor } from 'tiptap/core'; + import { IconClear } from 'components/icons'; import { Tooltip } from 'components/tooltip'; -import React, { useCallback } from 'react'; -import { Editor } from 'tiptap/core'; export const CleadrNodeAndMarks: React.FC<{ editor: Editor }> = ({ editor }) => { const clear = useCallback(() => { diff --git a/packages/client/src/tiptap/core/menus/code-block/bubble.tsx b/packages/client/src/tiptap/core/menus/code-block/bubble.tsx index cf5ad25..0e792b6 100644 --- a/packages/client/src/tiptap/core/menus/code-block/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/code-block/bubble.tsx @@ -1,12 +1,15 @@ +import React, { useCallback } from 'react'; + import { IconCopy, IconDelete } from '@douyinfe/semi-icons'; import { Button, Space } from '@douyinfe/semi-ui'; -import { Divider } from 'components/divider'; -import { Tooltip } from 'components/tooltip'; -import React, { useCallback } from 'react'; + import { BubbleMenu } from 'tiptap/core/bubble-menu'; import { CodeBlock } from 'tiptap/core/extensions/code-block'; import { copyNode, deleteNode } from 'tiptap/prose-utils'; +import { Divider } from 'components/divider'; +import { Tooltip } from 'components/tooltip'; + export const CodeBlockBubbleMenu = ({ editor }) => { const shouldShow = useCallback(() => editor.isActive(CodeBlock.name), [editor]); const getRenderContainer = useCallback((node) => { diff --git a/packages/client/src/tiptap/core/menus/code-block/index.tsx b/packages/client/src/tiptap/core/menus/code-block/index.tsx index 1795b2d..3da75fd 100644 --- a/packages/client/src/tiptap/core/menus/code-block/index.tsx +++ b/packages/client/src/tiptap/core/menus/code-block/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { CodeBlockBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/code/index.tsx b/packages/client/src/tiptap/core/menus/code/index.tsx index 5a44bea..73d1927 100644 --- a/packages/client/src/tiptap/core/menus/code/index.tsx +++ b/packages/client/src/tiptap/core/menus/code/index.tsx @@ -1,12 +1,15 @@ +import React, { useCallback } from 'react'; + import { IconCode } from '@douyinfe/semi-icons'; import { Button } from '@douyinfe/semi-ui'; -import { Tooltip } from 'components/tooltip'; -import React, { useCallback } from 'react'; + import { Editor } from 'tiptap/core'; import { Code as InlineCode } from 'tiptap/core/extensions/code'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; +import { Tooltip } from 'components/tooltip'; + export const Code: React.FC<{ editor: Editor }> = ({ editor }) => { const isTitleActive = useActive(editor, Title.name); const isCodeActive = useActive(editor, InlineCode.name); diff --git a/packages/client/src/tiptap/core/menus/columns/bubble.tsx b/packages/client/src/tiptap/core/menus/columns/bubble.tsx index c362980..8073db1 100644 --- a/packages/client/src/tiptap/core/menus/columns/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/columns/bubble.tsx @@ -1,13 +1,16 @@ +import { useCallback } from 'react'; + import { IconCopy, IconDelete } from '@douyinfe/semi-icons'; import { Button, Space } from '@douyinfe/semi-ui'; -import { Divider } from 'components/divider'; -import { IconAddColAfter, IconAddColBefore, IconDeleteCol } from 'components/icons'; -import { Tooltip } from 'components/tooltip'; -import { useCallback } from 'react'; + import { BubbleMenu } from 'tiptap/core/bubble-menu'; import { Columns } from 'tiptap/core/extensions/columns'; import { copyNode, deleteNode } from 'tiptap/prose-utils'; +import { Divider } from 'components/divider'; +import { IconAddColAfter, IconAddColBefore, IconDeleteCol } from 'components/icons'; +import { Tooltip } from 'components/tooltip'; + export const ColumnsBubbleMenu = ({ editor }) => { const getRenderContainer = useCallback((node) => { let container = node; diff --git a/packages/client/src/tiptap/core/menus/columns/index.tsx b/packages/client/src/tiptap/core/menus/columns/index.tsx index 0cbac47..3ad3476 100644 --- a/packages/client/src/tiptap/core/menus/columns/index.tsx +++ b/packages/client/src/tiptap/core/menus/columns/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { ColumnsBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/commands.tsx b/packages/client/src/tiptap/core/menus/commands.tsx index b37218c..e35b443 100644 --- a/packages/client/src/tiptap/core/menus/commands.tsx +++ b/packages/client/src/tiptap/core/menus/commands.tsx @@ -1,5 +1,9 @@ import { Dropdown, Popover } from '@douyinfe/semi-ui'; + import { IUser } from '@think/domains'; + +import { Editor } from 'tiptap/core'; + import { GridSelect } from 'components/grid-select'; import { IconAttachment, @@ -18,7 +22,6 @@ import { IconTableOfContents, } from 'components/icons'; import { createKeysLocalStorageLRUCache } from 'helpers/lru-cache'; -import { Editor } from 'tiptap/core'; import { createCountdown } from './countdown/service'; diff --git a/packages/client/src/tiptap/core/menus/countdown/bubble.tsx b/packages/client/src/tiptap/core/menus/countdown/bubble.tsx index d7dcfa4..4be3de4 100644 --- a/packages/client/src/tiptap/core/menus/countdown/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/countdown/bubble.tsx @@ -1,13 +1,16 @@ +import { useCallback } from 'react'; + import { IconCopy, IconDelete, IconEdit } from '@douyinfe/semi-icons'; import { Button, Space } from '@douyinfe/semi-ui'; -import { Divider } from 'components/divider'; -import { Tooltip } from 'components/tooltip'; -import { useCallback } from 'react'; + import { BubbleMenu } from 'tiptap/core/bubble-menu'; import { Countdown } from 'tiptap/core/extensions/countdown'; import { useAttributes } from 'tiptap/core/hooks/use-attributes'; import { copyNode, deleteNode } from 'tiptap/prose-utils'; +import { Divider } from 'components/divider'; +import { Tooltip } from 'components/tooltip'; + import { triggerOpenCountSettingModal } from '../_event'; export const CountdownBubbleMenu = ({ editor }) => { diff --git a/packages/client/src/tiptap/core/menus/countdown/index.tsx b/packages/client/src/tiptap/core/menus/countdown/index.tsx index b07c7bf..f0700ce 100644 --- a/packages/client/src/tiptap/core/menus/countdown/index.tsx +++ b/packages/client/src/tiptap/core/menus/countdown/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { CountdownBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/countdown/modal.tsx b/packages/client/src/tiptap/core/menus/countdown/modal.tsx index d91b017..b63ab7c 100644 --- a/packages/client/src/tiptap/core/menus/countdown/modal.tsx +++ b/packages/client/src/tiptap/core/menus/countdown/modal.tsx @@ -1,9 +1,12 @@ +import { useCallback, useEffect, useRef, useState } from 'react'; + import { Form, Modal } from '@douyinfe/semi-ui'; import { FormApi } from '@douyinfe/semi-ui/lib/es/form'; -import { useToggle } from 'hooks/use-toggle'; -import { useCallback, useEffect, useRef, useState } from 'react'; + import { Editor } from 'tiptap/core'; +import { useToggle } from 'hooks/use-toggle'; + import { cancelSubject, OPEN_COUNT_SETTING_MODAL, subject } from '../_event'; type IProps = { editor: Editor }; diff --git a/packages/client/src/tiptap/core/menus/document-children/bubble.tsx b/packages/client/src/tiptap/core/menus/document-children/bubble.tsx index 2ce45ce..858fc4c 100644 --- a/packages/client/src/tiptap/core/menus/document-children/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/document-children/bubble.tsx @@ -1,12 +1,15 @@ +import React, { useCallback } from 'react'; + import { IconCopy, IconDelete } from '@douyinfe/semi-icons'; import { Button, Space } from '@douyinfe/semi-ui'; -import { Divider } from 'components/divider'; -import { Tooltip } from 'components/tooltip'; -import React, { useCallback } from 'react'; + import { BubbleMenu } from 'tiptap/core/bubble-menu'; import { DocumentChildren } from 'tiptap/core/extensions/document-children'; import { copyNode, deleteNode } from 'tiptap/prose-utils'; +import { Divider } from 'components/divider'; +import { Tooltip } from 'components/tooltip'; + export const DocumentChildrenBubbleMenu = ({ editor }) => { const shouldShow = useCallback(() => editor.isActive(DocumentChildren.name), [editor]); const copyMe = useCallback(() => copyNode(DocumentChildren.name, editor), [editor]); diff --git a/packages/client/src/tiptap/core/menus/document-children/index.tsx b/packages/client/src/tiptap/core/menus/document-children/index.tsx index 44c763a..1be1a53 100644 --- a/packages/client/src/tiptap/core/menus/document-children/index.tsx +++ b/packages/client/src/tiptap/core/menus/document-children/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { DocumentChildrenBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/document-reference/bubble.tsx b/packages/client/src/tiptap/core/menus/document-reference/bubble.tsx index e89fe3d..90eb403 100644 --- a/packages/client/src/tiptap/core/menus/document-reference/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/document-reference/bubble.tsx @@ -1,5 +1,13 @@ +import { useCallback, useEffect } from 'react'; + import { IconCopy, IconDelete, IconEdit } from '@douyinfe/semi-icons'; import { Button, List, Popover, Space, Typography } from '@douyinfe/semi-ui'; + +import { BubbleMenu } from 'tiptap/core/bubble-menu'; +import { DocumentReference, IDocumentReferenceAttrs } from 'tiptap/core/extensions/document-reference'; +import { useAttributes } from 'tiptap/core/hooks/use-attributes'; +import { copyNode, deleteNode } from 'tiptap/prose-utils'; + import { DataRender } from 'components/data-render'; import { Divider } from 'components/divider'; import { IconDocument } from 'components/icons'; @@ -8,11 +16,6 @@ import { useUser } from 'data/user'; import { useWikiTocs } from 'data/wiki'; import { useToggle } from 'hooks/use-toggle'; import { useRouter } from 'next/router'; -import { useCallback, useEffect } from 'react'; -import { BubbleMenu } from 'tiptap/core/bubble-menu'; -import { DocumentReference, IDocumentReferenceAttrs } from 'tiptap/core/extensions/document-reference'; -import { useAttributes } from 'tiptap/core/hooks/use-attributes'; -import { copyNode, deleteNode } from 'tiptap/prose-utils'; const { Text } = Typography; diff --git a/packages/client/src/tiptap/core/menus/document-reference/index.tsx b/packages/client/src/tiptap/core/menus/document-reference/index.tsx index 76fc832..d493162 100644 --- a/packages/client/src/tiptap/core/menus/document-reference/index.tsx +++ b/packages/client/src/tiptap/core/menus/document-reference/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { DocumentReferenceBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/emoji/index.tsx b/packages/client/src/tiptap/core/menus/emoji/index.tsx index 1d253bf..90b314d 100644 --- a/packages/client/src/tiptap/core/menus/emoji/index.tsx +++ b/packages/client/src/tiptap/core/menus/emoji/index.tsx @@ -1,9 +1,12 @@ +import React, { useCallback } from 'react'; + import { Button } from '@douyinfe/semi-ui'; + +import { Editor } from 'tiptap/core'; + import { EmojiPicker } from 'components/emoji-picker'; import { IconEmoji } from 'components/icons'; import { Tooltip } from 'components/tooltip'; -import React, { useCallback } from 'react'; -import { Editor } from 'tiptap/core'; export const Emoji: React.FC<{ editor: Editor }> = ({ editor }) => { const setEmoji = useCallback( diff --git a/packages/client/src/tiptap/core/menus/excalidraw/bubble.tsx b/packages/client/src/tiptap/core/menus/excalidraw/bubble.tsx index 62459b1..74d3474 100644 --- a/packages/client/src/tiptap/core/menus/excalidraw/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/excalidraw/bubble.tsx @@ -1,15 +1,18 @@ +import { useCallback, useEffect } from 'react'; + import { IconCopy, IconDelete, IconEdit, IconLineHeight } from '@douyinfe/semi-icons'; import { Button, Space } from '@douyinfe/semi-ui'; -import { Divider } from 'components/divider'; -import { SizeSetter } from 'components/size-setter'; -import { Tooltip } from 'components/tooltip'; -import { useUser } from 'data/user'; -import { useCallback, useEffect } from 'react'; + import { BubbleMenu } from 'tiptap/core/bubble-menu'; import { Excalidraw, IExcalidrawAttrs } from 'tiptap/core/extensions/excalidraw'; import { useAttributes } from 'tiptap/core/hooks/use-attributes'; import { copyNode, deleteNode, getEditorContainerDOMSize } from 'tiptap/prose-utils'; +import { Divider } from 'components/divider'; +import { SizeSetter } from 'components/size-setter'; +import { Tooltip } from 'components/tooltip'; +import { useUser } from 'data/user'; + import { triggerOpenExcalidrawSettingModal } from '../_event'; export const ExcalidrawBubbleMenu = ({ editor }) => { diff --git a/packages/client/src/tiptap/core/menus/excalidraw/index.tsx b/packages/client/src/tiptap/core/menus/excalidraw/index.tsx index 3c786fd..c0e9750 100644 --- a/packages/client/src/tiptap/core/menus/excalidraw/index.tsx +++ b/packages/client/src/tiptap/core/menus/excalidraw/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { ExcalidrawBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/excalidraw/modal.tsx b/packages/client/src/tiptap/core/menus/excalidraw/modal.tsx index 8f11c87..e5a7d64 100644 --- a/packages/client/src/tiptap/core/menus/excalidraw/modal.tsx +++ b/packages/client/src/tiptap/core/menus/excalidraw/modal.tsx @@ -1,8 +1,11 @@ -import { Modal, Spin, Typography } from '@douyinfe/semi-ui'; -import { useToggle } from 'hooks/use-toggle'; import { useCallback, useEffect, useState } from 'react'; + +import { Modal, Spin, Typography } from '@douyinfe/semi-ui'; + import { Editor } from 'tiptap/core'; +import { useToggle } from 'hooks/use-toggle'; + import { cancelSubject, OPEN_EXCALIDRAW_SETTING_MODAL, subject } from '../_event'; type IProps = { editor: Editor }; diff --git a/packages/client/src/tiptap/core/menus/flow/bubble.tsx b/packages/client/src/tiptap/core/menus/flow/bubble.tsx index 98001d8..c36c899 100644 --- a/packages/client/src/tiptap/core/menus/flow/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/flow/bubble.tsx @@ -1,15 +1,18 @@ +import { useCallback, useEffect } from 'react'; + import { IconCopy, IconDelete, IconEdit, IconLineHeight } from '@douyinfe/semi-icons'; import { Button, Space } from '@douyinfe/semi-ui'; -import { Divider } from 'components/divider'; -import { SizeSetter } from 'components/size-setter'; -import { Tooltip } from 'components/tooltip'; -import { useUser } from 'data/user'; -import { useCallback, useEffect } from 'react'; + import { BubbleMenu } from 'tiptap/core/bubble-menu'; import { Flow, IFlowAttrs } from 'tiptap/core/extensions/flow'; import { useAttributes } from 'tiptap/core/hooks/use-attributes'; import { copyNode, deleteNode, getEditorContainerDOMSize } from 'tiptap/prose-utils'; +import { Divider } from 'components/divider'; +import { SizeSetter } from 'components/size-setter'; +import { Tooltip } from 'components/tooltip'; +import { useUser } from 'data/user'; + import { triggerOpenFlowSettingModal } from '../_event'; export const FlowBubbleMenu = ({ editor }) => { diff --git a/packages/client/src/tiptap/core/menus/flow/index.tsx b/packages/client/src/tiptap/core/menus/flow/index.tsx index bb99012..1c1b89c 100644 --- a/packages/client/src/tiptap/core/menus/flow/index.tsx +++ b/packages/client/src/tiptap/core/menus/flow/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { FlowBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/flow/modal.tsx b/packages/client/src/tiptap/core/menus/flow/modal.tsx index 89988ed..611519c 100644 --- a/packages/client/src/tiptap/core/menus/flow/modal.tsx +++ b/packages/client/src/tiptap/core/menus/flow/modal.tsx @@ -1,9 +1,12 @@ -import { Modal, Spin, Typography } from '@douyinfe/semi-ui'; -import { useToggle } from 'hooks/use-toggle'; import { useCallback, useEffect, useRef, useState } from 'react'; -import { createEditor, load } from 'thirtypart/diagram'; + +import { Modal, Spin, Typography } from '@douyinfe/semi-ui'; + import { Editor } from 'tiptap/core'; +import { useToggle } from 'hooks/use-toggle'; +import { createEditor, load } from 'thirtypart/diagram'; + import { cancelSubject, OPEN_FLOW_SETTING_MODAL, subject } from '../_event'; type IProps = { editor: Editor }; diff --git a/packages/client/src/tiptap/core/menus/fontfamily/index.tsx b/packages/client/src/tiptap/core/menus/fontfamily/index.tsx index 1d84302..438738d 100644 --- a/packages/client/src/tiptap/core/menus/fontfamily/index.tsx +++ b/packages/client/src/tiptap/core/menus/fontfamily/index.tsx @@ -1,5 +1,7 @@ -import { Select } from '@douyinfe/semi-ui'; import React, { useCallback } from 'react'; + +import { Select } from '@douyinfe/semi-ui'; + import { Editor } from 'tiptap/core'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; diff --git a/packages/client/src/tiptap/core/menus/fontsize/index.tsx b/packages/client/src/tiptap/core/menus/fontsize/index.tsx index 7fbba35..eddf40e 100644 --- a/packages/client/src/tiptap/core/menus/fontsize/index.tsx +++ b/packages/client/src/tiptap/core/menus/fontsize/index.tsx @@ -1,5 +1,7 @@ -import { Select } from '@douyinfe/semi-ui'; import React, { useCallback } from 'react'; + +import { Select } from '@douyinfe/semi-ui'; + import { Editor } from 'tiptap/core'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; diff --git a/packages/client/src/tiptap/core/menus/heading/index.tsx b/packages/client/src/tiptap/core/menus/heading/index.tsx index cfb31a6..cc4a24f 100644 --- a/packages/client/src/tiptap/core/menus/heading/index.tsx +++ b/packages/client/src/tiptap/core/menus/heading/index.tsx @@ -1,5 +1,7 @@ -import { Select } from '@douyinfe/semi-ui'; import React, { useCallback, useMemo } from 'react'; + +import { Select } from '@douyinfe/semi-ui'; + import { Editor } from 'tiptap/core'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; diff --git a/packages/client/src/tiptap/core/menus/horizontal-rule/index.tsx b/packages/client/src/tiptap/core/menus/horizontal-rule/index.tsx index c467785..180ca18 100644 --- a/packages/client/src/tiptap/core/menus/horizontal-rule/index.tsx +++ b/packages/client/src/tiptap/core/menus/horizontal-rule/index.tsx @@ -1,11 +1,14 @@ -import { Button } from '@douyinfe/semi-ui'; -import { IconHorizontalRule } from 'components/icons'; -import { Tooltip } from 'components/tooltip'; import React, { useCallback } from 'react'; + +import { Button } from '@douyinfe/semi-ui'; + import { Editor } from 'tiptap/core'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; +import { IconHorizontalRule } from 'components/icons'; +import { Tooltip } from 'components/tooltip'; + export const HorizontalRule: React.FC<{ editor: Editor }> = ({ editor }) => { const isTitleActive = useActive(editor, Title.name); diff --git a/packages/client/src/tiptap/core/menus/ident/index.tsx b/packages/client/src/tiptap/core/menus/ident/index.tsx index 4fb0745..4690eab 100644 --- a/packages/client/src/tiptap/core/menus/ident/index.tsx +++ b/packages/client/src/tiptap/core/menus/ident/index.tsx @@ -1,11 +1,14 @@ +import React, { useCallback } from 'react'; + import { IconIndentLeft, IconIndentRight } from '@douyinfe/semi-icons'; import { Button } from '@douyinfe/semi-ui'; -import { Tooltip } from 'components/tooltip'; -import React, { useCallback } from 'react'; + import { Editor } from 'tiptap/core'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; +import { Tooltip } from 'components/tooltip'; + export const Ident: React.FC<{ editor: Editor }> = ({ editor }) => { const isTitleActive = useActive(editor, Title.name); diff --git a/packages/client/src/tiptap/core/menus/iframe/bubble.tsx b/packages/client/src/tiptap/core/menus/iframe/bubble.tsx index db60f8f..cae992a 100644 --- a/packages/client/src/tiptap/core/menus/iframe/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/iframe/bubble.tsx @@ -1,16 +1,19 @@ +import { useCallback, useEffect, useRef } from 'react'; + import { IconCopy, IconDelete, IconEdit, IconExternalOpen, IconLineHeight } from '@douyinfe/semi-icons'; import { Button, Form, Modal, Space, Typography } from '@douyinfe/semi-ui'; import { FormApi } from '@douyinfe/semi-ui/lib/es/form'; + +import { BubbleMenu } from 'tiptap/core/bubble-menu'; +import { Iframe, IIframeAttrs } from 'tiptap/core/extensions/iframe'; +import { useAttributes } from 'tiptap/core/hooks/use-attributes'; +import { copyNode, deleteNode } from 'tiptap/prose-utils'; + import { Divider } from 'components/divider'; import { SizeSetter } from 'components/size-setter'; import { Tooltip } from 'components/tooltip'; import { useUser } from 'data/user'; import { useToggle } from 'hooks/use-toggle'; -import { useCallback, useEffect, useRef } from 'react'; -import { BubbleMenu } from 'tiptap/core/bubble-menu'; -import { Iframe, IIframeAttrs } from 'tiptap/core/extensions/iframe'; -import { useAttributes } from 'tiptap/core/hooks/use-attributes'; -import { copyNode, deleteNode } from 'tiptap/prose-utils'; const { Text } = Typography; diff --git a/packages/client/src/tiptap/core/menus/iframe/index.tsx b/packages/client/src/tiptap/core/menus/iframe/index.tsx index 7ef4f61..b9b369d 100644 --- a/packages/client/src/tiptap/core/menus/iframe/index.tsx +++ b/packages/client/src/tiptap/core/menus/iframe/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { IframeBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/image/bubble.tsx b/packages/client/src/tiptap/core/menus/image/bubble.tsx index 710670a..01f5f31 100644 --- a/packages/client/src/tiptap/core/menus/image/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/image/bubble.tsx @@ -1,3 +1,5 @@ +import React, { useCallback, useEffect, useState } from 'react'; + import { IconAlignCenter, IconAlignLeft, @@ -7,15 +9,16 @@ import { IconLineHeight, } from '@douyinfe/semi-icons'; import { Button, Space } from '@douyinfe/semi-ui'; -import { Divider } from 'components/divider'; -import { SizeSetter } from 'components/size-setter'; -import { Tooltip } from 'components/tooltip'; -import React, { useCallback, useEffect, useState } from 'react'; + import { BubbleMenu } from 'tiptap/core/bubble-menu'; import { Image } from 'tiptap/core/extensions/image'; import { useAttributes } from 'tiptap/core/hooks/use-attributes'; import { copyNode, deleteNode, getEditorContainerDOMSize } from 'tiptap/prose-utils'; +import { Divider } from 'components/divider'; +import { SizeSetter } from 'components/size-setter'; +import { Tooltip } from 'components/tooltip'; + export const ImageBubbleMenu = ({ editor }) => { const { width: maxWidth } = getEditorContainerDOMSize(editor); const { width: currentWidth, height: currentHeight } = useAttributes(editor, Image.name, { width: 0, height: 0 }); diff --git a/packages/client/src/tiptap/core/menus/image/index.tsx b/packages/client/src/tiptap/core/menus/image/index.tsx index 230d785..90aff5f 100644 --- a/packages/client/src/tiptap/core/menus/image/index.tsx +++ b/packages/client/src/tiptap/core/menus/image/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { ImageBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/insert/index.tsx b/packages/client/src/tiptap/core/menus/insert/index.tsx index 7460d07..ba106a0 100644 --- a/packages/client/src/tiptap/core/menus/insert/index.tsx +++ b/packages/client/src/tiptap/core/menus/insert/index.tsx @@ -1,13 +1,16 @@ +import React, { useCallback, useEffect, useMemo, useState } from 'react'; + import { IconPlus } from '@douyinfe/semi-icons'; import { Button, Dropdown } from '@douyinfe/semi-ui'; -import { Tooltip } from 'components/tooltip'; -import { useUser } from 'data/user'; -import { useToggle } from 'hooks/use-toggle'; -import React, { useCallback, useEffect, useMemo, useState } from 'react'; + import { Editor } from 'tiptap/core'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; +import { Tooltip } from 'components/tooltip'; +import { useUser } from 'data/user'; +import { useToggle } from 'hooks/use-toggle'; + import { COMMANDS, insertMenuLRUCache, transformToCommands } from '../commands'; const _CommandRender = ({ commands, editor, runCommand }) => { diff --git a/packages/client/src/tiptap/core/menus/italic/index.tsx b/packages/client/src/tiptap/core/menus/italic/index.tsx index 58ffd49..d422759 100644 --- a/packages/client/src/tiptap/core/menus/italic/index.tsx +++ b/packages/client/src/tiptap/core/menus/italic/index.tsx @@ -1,12 +1,15 @@ +import React, { useCallback } from 'react'; + import { IconItalic } from '@douyinfe/semi-icons'; import { Button } from '@douyinfe/semi-ui'; -import { Tooltip } from 'components/tooltip'; -import React, { useCallback } from 'react'; + import { Editor } from 'tiptap/core'; import { Italic as ItalicExtension } from 'tiptap/core/extensions/italic'; import { Title } from 'tiptap/core/extensions/title'; import { useActive } from 'tiptap/core/hooks/use-active'; +import { Tooltip } from 'components/tooltip'; + export const Italic: React.FC<{ editor: Editor }> = ({ editor }) => { const isTitleActive = useActive(editor, Title.name); const isItalicActive = useActive(editor, ItalicExtension.name); diff --git a/packages/client/src/tiptap/core/menus/katex/bubble.tsx b/packages/client/src/tiptap/core/menus/katex/bubble.tsx index 6d888b4..373bc57 100644 --- a/packages/client/src/tiptap/core/menus/katex/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/katex/bubble.tsx @@ -1,16 +1,19 @@ +import { useCallback, useEffect, useRef } from 'react'; + import { IconCopy, IconDelete, IconEdit, IconHelpCircle } from '@douyinfe/semi-icons'; import { Button, Popover, Space, TextArea, Typography } from '@douyinfe/semi-ui'; -import { Divider } from 'components/divider'; -import { Tooltip } from 'components/tooltip'; -import { useUser } from 'data/user'; -import { useToggle } from 'hooks/use-toggle'; -import { useCallback, useEffect, useRef } from 'react'; + import { Editor } from 'tiptap/core'; import { BubbleMenu } from 'tiptap/core/bubble-menu'; import { IKatexAttrs, Katex } from 'tiptap/core/extensions/katex'; import { useAttributes } from 'tiptap/core/hooks/use-attributes'; import { copyNode, deleteNode } from 'tiptap/prose-utils'; +import { Divider } from 'components/divider'; +import { Tooltip } from 'components/tooltip'; +import { useUser } from 'data/user'; +import { useToggle } from 'hooks/use-toggle'; + const { Text } = Typography; export const KatexBubbleMenu: React.FC<{ editor: Editor }> = ({ editor }) => { diff --git a/packages/client/src/tiptap/core/menus/katex/index.tsx b/packages/client/src/tiptap/core/menus/katex/index.tsx index ee5e9cc..97f4569 100644 --- a/packages/client/src/tiptap/core/menus/katex/index.tsx +++ b/packages/client/src/tiptap/core/menus/katex/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Editor } from 'tiptap/core'; import { KatexBubbleMenu } from './bubble'; diff --git a/packages/client/src/tiptap/core/menus/lineheight/index.tsx b/packages/client/src/tiptap/core/menus/lineheight/index.tsx new file mode 100644 index 0000000..b33947d --- /dev/null +++ b/packages/client/src/tiptap/core/menus/lineheight/index.tsx @@ -0,0 +1,51 @@ +import React, { useCallback } from 'react'; + +import { Button, Dropdown, Tooltip } from '@douyinfe/semi-ui'; + +import { Editor } from 'tiptap/core'; +import { Title } from 'tiptap/core/extensions/title'; +import { useActive } from 'tiptap/core/hooks/use-active'; +import { useAttributes } from 'tiptap/core/hooks/use-attributes'; + +import { IconLineHeight } from 'components/icons'; + +export const LINE_HEIGHT = [null, 1, 1.15, 1.5, 2, 2.5, 3]; + +export const LineHeight: React.FC<{ editor: Editor }> = ({ editor }) => { + const isTitleActive = useActive(editor, Title.name); + const currentValue = useAttributes(editor, 'textStyle', { lineHeight: null }, (attrs) => { + if (!attrs || !attrs.lineHeight) return null; + + const matches = attrs.lineHeight.match(/\d+/); + + if (!matches || !matches[0]) return 16; + return matches[0]; + }); + + const toggle = useCallback( + (val) => { + if (val) { + editor.chain().focus().setLineHeight(val).run(); + } else { + editor.chain().focus().unsetLineHeight().run(); + } + }, + [editor] + ); + + return ( + ( + toggle(val)}> + {val || '默认'} + + ))} + > + + +