From 8106bae0c23572390e5e1aca8dac51238845003a Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 1 Oct 2024 22:39:17 +0300 Subject: [PATCH] editor-refactored --- src/components/Article/AudioPlayer/PlayerPlaylist.tsx | 4 ++-- src/components/Article/Comment/Comment.tsx | 2 +- src/components/Article/CommentsTree.tsx | 2 +- src/components/Editor/BubbleMenu/index.ts | 3 --- src/components/Editor/Editor.tsx | 8 +++++--- src/components/Editor/EditorFloatingMenu/index.ts | 1 - .../Editor/{MicroEditor => }/MicroEditor.stories.tsx | 0 src/components/Editor/{MicroEditor => }/MicroEditor.tsx | 4 ++-- .../Editor/{MiniEditor => }/MiniEditor.module.scss | 0 .../Editor/{MiniEditor => }/MiniEditor.stories.tsx | 0 src/components/Editor/{MiniEditor => }/MiniEditor.tsx | 4 ++-- .../{BubbleMenu => Toolbar}/BlockquoteBubbleMenu.tsx | 0 .../Editor/{BubbleMenu => Toolbar}/BubbleMenu.module.scss | 0 .../EditorFloatingMenu.module.scss | 0 .../EditorFloatingMenu.tsx | 0 .../Editor/{BubbleMenu => Toolbar}/FigureBubbleMenu.tsx | 0 .../Editor/{BubbleMenu => Toolbar}/IncutBubbleMenu.tsx | 0 .../{EditorFloatingMenu => Toolbar}/Menu/Menu.module.scss | 0 .../Editor/{EditorFloatingMenu => Toolbar}/Menu/Menu.tsx | 0 .../Editor/{EditorFloatingMenu => Toolbar}/Menu/index.ts | 0 .../{MicroEditor => Toolbar}/MicroBubbleMenu.module.scss | 0 .../Editor/{MicroEditor => Toolbar}/MicroBubbleMenu.tsx | 2 +- .../{BubbleMenu => Toolbar}/TextBubbleMenu.module.scss | 0 .../Editor/{BubbleMenu => Toolbar}/TextBubbleMenu.tsx | 4 ++-- src/components/Views/EditView/EditView.tsx | 2 +- src/components/Views/Inbox/Inbox.tsx | 2 +- src/components/Views/Profile/ProfileSettings.tsx | 2 +- src/components/Views/PublishSettings/PublishSettings.tsx | 2 +- src/components/_shared/SolidSwiper/EditorSwiper.tsx | 2 +- 29 files changed, 21 insertions(+), 23 deletions(-) delete mode 100644 src/components/Editor/BubbleMenu/index.ts delete mode 100644 src/components/Editor/EditorFloatingMenu/index.ts rename src/components/Editor/{MicroEditor => }/MicroEditor.stories.tsx (100%) rename src/components/Editor/{MicroEditor => }/MicroEditor.tsx (94%) rename src/components/Editor/{MiniEditor => }/MiniEditor.module.scss (100%) rename src/components/Editor/{MiniEditor => }/MiniEditor.stories.tsx (100%) rename src/components/Editor/{MiniEditor => }/MiniEditor.tsx (97%) rename src/components/Editor/{BubbleMenu => Toolbar}/BlockquoteBubbleMenu.tsx (100%) rename src/components/Editor/{BubbleMenu => Toolbar}/BubbleMenu.module.scss (100%) rename src/components/Editor/{EditorFloatingMenu => Toolbar}/EditorFloatingMenu.module.scss (100%) rename src/components/Editor/{EditorFloatingMenu => Toolbar}/EditorFloatingMenu.tsx (100%) rename src/components/Editor/{BubbleMenu => Toolbar}/FigureBubbleMenu.tsx (100%) rename src/components/Editor/{BubbleMenu => Toolbar}/IncutBubbleMenu.tsx (100%) rename src/components/Editor/{EditorFloatingMenu => Toolbar}/Menu/Menu.module.scss (100%) rename src/components/Editor/{EditorFloatingMenu => Toolbar}/Menu/Menu.tsx (100%) rename src/components/Editor/{EditorFloatingMenu => Toolbar}/Menu/index.ts (100%) rename src/components/Editor/{MicroEditor => Toolbar}/MicroBubbleMenu.module.scss (100%) rename src/components/Editor/{MicroEditor => Toolbar}/MicroBubbleMenu.tsx (98%) rename src/components/Editor/{BubbleMenu => Toolbar}/TextBubbleMenu.module.scss (100%) rename src/components/Editor/{BubbleMenu => Toolbar}/TextBubbleMenu.tsx (99%) diff --git a/src/components/Article/AudioPlayer/PlayerPlaylist.tsx b/src/components/Article/AudioPlayer/PlayerPlaylist.tsx index af0e0e5b..1e6c9125 100644 --- a/src/components/Article/AudioPlayer/PlayerPlaylist.tsx +++ b/src/components/Article/AudioPlayer/PlayerPlaylist.tsx @@ -9,7 +9,7 @@ import { SharePopup, getShareUrl } from '../SharePopup' import styles from './AudioPlayer.module.scss' -const MicroEditor = lazy(() => import('../../Editor/MicroEditor/MicroEditor')) +const MicroEditor = lazy(() => import('../../Editor/MicroEditor')) const GrowingTextarea = lazy(() => import('~/components/_shared/GrowingTextarea/GrowingTextarea')) type Props = { @@ -174,7 +174,7 @@ export const PlayerPlaylist = (props: Props) => { handleMediaItemFieldChange('body', value)} + onChange={(value: string) => handleMediaItemFieldChange('body', value)} /> import('../../Editor/MiniEditor/MiniEditor')) +const MiniEditor = lazy(() => import('../../Editor/MiniEditor')) type Props = { comment: Reaction diff --git a/src/components/Article/CommentsTree.tsx b/src/components/Article/CommentsTree.tsx index 4d666b5b..fa20e06d 100644 --- a/src/components/Article/CommentsTree.tsx +++ b/src/components/Article/CommentsTree.tsx @@ -14,7 +14,7 @@ import { ShowIfAuthenticated } from '../_shared/ShowIfAuthenticated' import styles from './Article.module.scss' import { Comment } from './Comment' -const MiniEditor = lazy(() => import('../Editor/MiniEditor/MiniEditor')) +const MiniEditor = lazy(() => import('../Editor/MiniEditor')) type Props = { articleAuthors: Author[] diff --git a/src/components/Editor/BubbleMenu/index.ts b/src/components/Editor/BubbleMenu/index.ts deleted file mode 100644 index 950f3ba3..00000000 --- a/src/components/Editor/BubbleMenu/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { FigureBubbleMenu } from './FigureBubbleMenu' -export { BlockquoteBubbleMenu } from './BlockquoteBubbleMenu' -export { IncutBubbleMenu } from './IncutBubbleMenu' diff --git a/src/components/Editor/Editor.tsx b/src/components/Editor/Editor.tsx index b49b2799..7eed52c7 100644 --- a/src/components/Editor/Editor.tsx +++ b/src/components/Editor/Editor.tsx @@ -17,9 +17,11 @@ import { Author } from '~/graphql/schema/core.gen' import { base, custom, extended } from '~/lib/editorExtensions' import { handleImageUpload } from '~/lib/handleImageUpload' import { renderUploadedImage } from '../Upload/renderUploadedImage' -import { BlockquoteBubbleMenu, FigureBubbleMenu, IncutBubbleMenu } from './BubbleMenu' -import { TextBubbleMenu } from './BubbleMenu/TextBubbleMenu' -import { EditorFloatingMenu } from './EditorFloatingMenu' +import { BlockquoteBubbleMenu } from './Toolbar/BlockquoteBubbleMenu' +import { EditorFloatingMenu } from './Toolbar/EditorFloatingMenu' +import { FigureBubbleMenu } from './Toolbar/FigureBubbleMenu' +import { IncutBubbleMenu } from './Toolbar/IncutBubbleMenu' +import { TextBubbleMenu } from './Toolbar/TextBubbleMenu' import './Editor.module.scss' diff --git a/src/components/Editor/EditorFloatingMenu/index.ts b/src/components/Editor/EditorFloatingMenu/index.ts deleted file mode 100644 index 6af80faa..00000000 --- a/src/components/Editor/EditorFloatingMenu/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { EditorFloatingMenu } from './EditorFloatingMenu' diff --git a/src/components/Editor/MicroEditor/MicroEditor.stories.tsx b/src/components/Editor/MicroEditor.stories.tsx similarity index 100% rename from src/components/Editor/MicroEditor/MicroEditor.stories.tsx rename to src/components/Editor/MicroEditor.stories.tsx diff --git a/src/components/Editor/MicroEditor/MicroEditor.tsx b/src/components/Editor/MicroEditor.tsx similarity index 94% rename from src/components/Editor/MicroEditor/MicroEditor.tsx rename to src/components/Editor/MicroEditor.tsx index 86680d17..0b9073c3 100644 --- a/src/components/Editor/MicroEditor/MicroEditor.tsx +++ b/src/components/Editor/MicroEditor.tsx @@ -4,9 +4,9 @@ import clsx from 'clsx' import { type JSX, createEffect, createSignal, on } from 'solid-js' import { createTiptapEditor, useEditorHTML } from 'solid-tiptap' import { minimal } from '~/lib/editorExtensions' -import { MicroBubbleMenu } from './MicroBubbleMenu' +import { MicroBubbleMenu } from './Toolbar/MicroBubbleMenu' -import styles from '../MiniEditor/MiniEditor.module.scss' +import styles from './MiniEditor.module.scss' interface MicroEditorProps { content?: string diff --git a/src/components/Editor/MiniEditor/MiniEditor.module.scss b/src/components/Editor/MiniEditor.module.scss similarity index 100% rename from src/components/Editor/MiniEditor/MiniEditor.module.scss rename to src/components/Editor/MiniEditor.module.scss diff --git a/src/components/Editor/MiniEditor/MiniEditor.stories.tsx b/src/components/Editor/MiniEditor.stories.tsx similarity index 100% rename from src/components/Editor/MiniEditor/MiniEditor.stories.tsx rename to src/components/Editor/MiniEditor.stories.tsx diff --git a/src/components/Editor/MiniEditor/MiniEditor.tsx b/src/components/Editor/MiniEditor.tsx similarity index 97% rename from src/components/Editor/MiniEditor/MiniEditor.tsx rename to src/components/Editor/MiniEditor.tsx index 081432b0..0aba98d8 100644 --- a/src/components/Editor/MiniEditor/MiniEditor.tsx +++ b/src/components/Editor/MiniEditor.tsx @@ -6,7 +6,7 @@ import { createTiptapEditor, useEditorHTML, useEditorIsEmpty } from 'solid-tipta import { Button } from '~/components/_shared/Button' import { useLocalize } from '~/context/localize' import { base } from '~/lib/editorExtensions' -import { ToolbarControl as Control } from '../Toolbar/ToolbarControl' +import { ToolbarControl as Control } from './Toolbar/ToolbarControl' import { Editor } from '@tiptap/core' import { Portal } from 'solid-js/web' @@ -16,8 +16,8 @@ import { Icon } from '~/components/_shared/Icon/Icon' import { Modal } from '~/components/_shared/Modal' import { useUI } from '~/context/ui' import { UploadedFile } from '~/types/upload' -import { InsertLinkForm } from '../Toolbar/InsertLinkForm' import styles from './MiniEditor.module.scss' +import { InsertLinkForm } from './Toolbar/InsertLinkForm' interface MiniEditorProps { content?: string diff --git a/src/components/Editor/BubbleMenu/BlockquoteBubbleMenu.tsx b/src/components/Editor/Toolbar/BlockquoteBubbleMenu.tsx similarity index 100% rename from src/components/Editor/BubbleMenu/BlockquoteBubbleMenu.tsx rename to src/components/Editor/Toolbar/BlockquoteBubbleMenu.tsx diff --git a/src/components/Editor/BubbleMenu/BubbleMenu.module.scss b/src/components/Editor/Toolbar/BubbleMenu.module.scss similarity index 100% rename from src/components/Editor/BubbleMenu/BubbleMenu.module.scss rename to src/components/Editor/Toolbar/BubbleMenu.module.scss diff --git a/src/components/Editor/EditorFloatingMenu/EditorFloatingMenu.module.scss b/src/components/Editor/Toolbar/EditorFloatingMenu.module.scss similarity index 100% rename from src/components/Editor/EditorFloatingMenu/EditorFloatingMenu.module.scss rename to src/components/Editor/Toolbar/EditorFloatingMenu.module.scss diff --git a/src/components/Editor/EditorFloatingMenu/EditorFloatingMenu.tsx b/src/components/Editor/Toolbar/EditorFloatingMenu.tsx similarity index 100% rename from src/components/Editor/EditorFloatingMenu/EditorFloatingMenu.tsx rename to src/components/Editor/Toolbar/EditorFloatingMenu.tsx diff --git a/src/components/Editor/BubbleMenu/FigureBubbleMenu.tsx b/src/components/Editor/Toolbar/FigureBubbleMenu.tsx similarity index 100% rename from src/components/Editor/BubbleMenu/FigureBubbleMenu.tsx rename to src/components/Editor/Toolbar/FigureBubbleMenu.tsx diff --git a/src/components/Editor/BubbleMenu/IncutBubbleMenu.tsx b/src/components/Editor/Toolbar/IncutBubbleMenu.tsx similarity index 100% rename from src/components/Editor/BubbleMenu/IncutBubbleMenu.tsx rename to src/components/Editor/Toolbar/IncutBubbleMenu.tsx diff --git a/src/components/Editor/EditorFloatingMenu/Menu/Menu.module.scss b/src/components/Editor/Toolbar/Menu/Menu.module.scss similarity index 100% rename from src/components/Editor/EditorFloatingMenu/Menu/Menu.module.scss rename to src/components/Editor/Toolbar/Menu/Menu.module.scss diff --git a/src/components/Editor/EditorFloatingMenu/Menu/Menu.tsx b/src/components/Editor/Toolbar/Menu/Menu.tsx similarity index 100% rename from src/components/Editor/EditorFloatingMenu/Menu/Menu.tsx rename to src/components/Editor/Toolbar/Menu/Menu.tsx diff --git a/src/components/Editor/EditorFloatingMenu/Menu/index.ts b/src/components/Editor/Toolbar/Menu/index.ts similarity index 100% rename from src/components/Editor/EditorFloatingMenu/Menu/index.ts rename to src/components/Editor/Toolbar/Menu/index.ts diff --git a/src/components/Editor/MicroEditor/MicroBubbleMenu.module.scss b/src/components/Editor/Toolbar/MicroBubbleMenu.module.scss similarity index 100% rename from src/components/Editor/MicroEditor/MicroBubbleMenu.module.scss rename to src/components/Editor/Toolbar/MicroBubbleMenu.module.scss diff --git a/src/components/Editor/MicroEditor/MicroBubbleMenu.tsx b/src/components/Editor/Toolbar/MicroBubbleMenu.tsx similarity index 98% rename from src/components/Editor/MicroEditor/MicroBubbleMenu.tsx rename to src/components/Editor/Toolbar/MicroBubbleMenu.tsx index cc1a0b95..0c532a32 100644 --- a/src/components/Editor/MicroEditor/MicroBubbleMenu.tsx +++ b/src/components/Editor/Toolbar/MicroBubbleMenu.tsx @@ -5,7 +5,7 @@ import { createEditorTransaction } from 'solid-tiptap' import { Icon } from '~/components/_shared/Icon' import { Popover } from '~/components/_shared/Popover' import { useLocalize } from '~/context/localize' -import { InsertLinkForm } from '../Toolbar/InsertLinkForm' +import { InsertLinkForm } from './InsertLinkForm' import styles from './MicroBubbleMenu.module.scss' diff --git a/src/components/Editor/BubbleMenu/TextBubbleMenu.module.scss b/src/components/Editor/Toolbar/TextBubbleMenu.module.scss similarity index 100% rename from src/components/Editor/BubbleMenu/TextBubbleMenu.module.scss rename to src/components/Editor/Toolbar/TextBubbleMenu.module.scss diff --git a/src/components/Editor/BubbleMenu/TextBubbleMenu.tsx b/src/components/Editor/Toolbar/TextBubbleMenu.tsx similarity index 99% rename from src/components/Editor/BubbleMenu/TextBubbleMenu.tsx rename to src/components/Editor/Toolbar/TextBubbleMenu.tsx index 5b8cf4b6..0f5d560b 100644 --- a/src/components/Editor/BubbleMenu/TextBubbleMenu.tsx +++ b/src/components/Editor/Toolbar/TextBubbleMenu.tsx @@ -5,11 +5,11 @@ import { createEditorTransaction } from 'solid-tiptap' import { Icon } from '~/components/_shared/Icon' import { Popover } from '~/components/_shared/Popover' import { useLocalize } from '~/context/localize' -import { InsertLinkForm } from '../Toolbar/InsertLinkForm' +import { InsertLinkForm } from './InsertLinkForm' import styles from './TextBubbleMenu.module.scss' -const MiniEditor = lazy(() => import('../MiniEditor/MiniEditor')) +const MiniEditor = lazy(() => import('../MiniEditor')) type BubbleMenuProps = { editor: Editor diff --git a/src/components/Views/EditView/EditView.tsx b/src/components/Views/EditView/EditView.tsx index ba153c6e..5bec0662 100644 --- a/src/components/Views/EditView/EditView.tsx +++ b/src/components/Views/EditView/EditView.tsx @@ -29,7 +29,7 @@ import { Modal } from '../../_shared/Modal' import { TableOfContents } from '../../_shared/TableOfContents' import styles from './EditView.module.scss' -const MicroEditor = lazy(() => import('../../Editor/MicroEditor/MicroEditor')) +const MicroEditor = lazy(() => import('../../Editor/MicroEditor')) const GrowingTextarea = lazy(() => import('~/components/_shared/GrowingTextarea/GrowingTextarea')) type Props = { diff --git a/src/components/Views/Inbox/Inbox.tsx b/src/components/Views/Inbox/Inbox.tsx index ffc4e7c8..170bde28 100644 --- a/src/components/Views/Inbox/Inbox.tsx +++ b/src/components/Views/Inbox/Inbox.tsx @@ -25,7 +25,7 @@ import Search from '../../Inbox/Search' import { Modal } from '../../_shared/Modal' import styles from './Inbox.module.scss' -const MiniEditor = lazy(() => import('../../Editor/MiniEditor/MiniEditor')) +const MiniEditor = lazy(() => import('../../Editor/MiniEditor')) const userSearch = (array: Author[], keyword: string) => { return array.filter((value) => new RegExp(keyword.trim(), 'gi').test(value.name || '')) diff --git a/src/components/Views/Profile/ProfileSettings.tsx b/src/components/Views/Profile/ProfileSettings.tsx index 509f9941..a5c831cf 100644 --- a/src/components/Views/Profile/ProfileSettings.tsx +++ b/src/components/Views/Profile/ProfileSettings.tsx @@ -34,7 +34,7 @@ import { SocialNetworkInput } from '../../_shared/SocialNetworkInput' import styles from './Settings.module.scss' import { profileSocialLinks } from './profileSocialLinks' -const MicroEditor = lazy(() => import('../../Editor/MicroEditor/MicroEditor')) +const MicroEditor = lazy(() => import('../../Editor/MicroEditor')) const GrowingTextarea = lazy(() => import('~/components/_shared/GrowingTextarea/GrowingTextarea')) function filterNulls(arr: InputMaybe[]): string[] { diff --git a/src/components/Views/PublishSettings/PublishSettings.tsx b/src/components/Views/PublishSettings/PublishSettings.tsx index 552535b5..9eec9b41 100644 --- a/src/components/Views/PublishSettings/PublishSettings.tsx +++ b/src/components/Views/PublishSettings/PublishSettings.tsx @@ -19,7 +19,7 @@ import { UploadModalContent } from '~/components/Upload/UploadModalContent/Uploa import stylesBeside from '../../Feed/Beside.module.scss' import styles from './PublishSettings.module.scss' -const MicroEditor = lazy(() => import('../../Editor/MicroEditor/MicroEditor')) +const MicroEditor = lazy(() => import('../../Editor/MicroEditor')) const GrowingTextarea = lazy(() => import('~/components/_shared/GrowingTextarea/GrowingTextarea')) const DESCRIPTION_MAX_LENGTH = 400 diff --git a/src/components/_shared/SolidSwiper/EditorSwiper.tsx b/src/components/_shared/SolidSwiper/EditorSwiper.tsx index 303086d7..a84ec062 100644 --- a/src/components/_shared/SolidSwiper/EditorSwiper.tsx +++ b/src/components/_shared/SolidSwiper/EditorSwiper.tsx @@ -22,7 +22,7 @@ import { MediaItem } from '~/types/mediaitem' import { UploadedFile } from '~/types/upload' import styles from './Swiper.module.scss' -const MicroEditor = lazy(() => import('../../Editor/MicroEditor/MicroEditor')) +const MicroEditor = lazy(() => import('../../Editor/MicroEditor')) type Props = { images: MediaItem[]