diff --git a/src/components/Editor/Editor.tsx b/src/components/Editor/Editor.tsx index b3c06777..162feb24 100644 --- a/src/components/Editor/Editor.tsx +++ b/src/components/Editor/Editor.tsx @@ -1,12 +1,9 @@ import { createEffect } from 'solid-js' import { createTiptapEditor, useEditorHTML } from 'solid-tiptap' -import { clsx } from 'clsx' import { useLocalize } from '../../context/localize' import { Blockquote } from '@tiptap/extension-blockquote' import { Bold } from '@tiptap/extension-bold' import { BubbleMenu } from '@tiptap/extension-bubble-menu' -import * as Y from 'yjs' -import { WebrtcProvider } from 'y-webrtc' import { Dropcursor } from '@tiptap/extension-dropcursor' import { Italic } from '@tiptap/extension-italic' import { Strike } from '@tiptap/extension-strike' diff --git a/src/components/Editor/EditorBubbleMenu/EditorBubbleMenu.module.scss b/src/components/Editor/EditorBubbleMenu/EditorBubbleMenu.module.scss index 3b607f45..ced091f2 100644 --- a/src/components/Editor/EditorBubbleMenu/EditorBubbleMenu.module.scss +++ b/src/components/Editor/EditorBubbleMenu/EditorBubbleMenu.module.scss @@ -36,41 +36,6 @@ width: 1px; } - .linkForm { - display: flex; - flex-direction: row; - flex-wrap: nowrap; - padding: 6px 11px; - - input { - margin: 0 12px 0 0; - padding: 0; - flex: 1; - border: none; - min-width: 200px; - - &:focus { - outline: none; - } - - &::placeholder { - color: rgba(#000, 0.3); - } - } - } - - .linkError { - padding: 6px 11px; - color: red; - font-size: 0.7em; - position: absolute; - bottom: -3rem; - left: 0; - right: 0; - background: #fff; - box-shadow: 0 4px 10px rgba(#000, 0.25); - } - .dropDownHolder { position: relative; cursor: pointer; diff --git a/src/components/Editor/EditorBubbleMenu/EditorBubbleMenu.tsx b/src/components/Editor/EditorBubbleMenu/EditorBubbleMenu.tsx index 8de91a56..0d86e74c 100644 --- a/src/components/Editor/EditorBubbleMenu/EditorBubbleMenu.tsx +++ b/src/components/Editor/EditorBubbleMenu/EditorBubbleMenu.tsx @@ -5,7 +5,7 @@ import { Icon } from '../../_shared/Icon' import { clsx } from 'clsx' import { createEditorTransaction } from 'solid-tiptap' import { useLocalize } from '../../../context/localize' -import validateUrl from '../../../utils/validateUrl' +import { LinkForm } from './LinkForm' type BubbleMenuProps = { editor: Editor @@ -38,44 +38,10 @@ export const EditorBubbleMenu = (props: BubbleMenuProps) => { const isBulletList = isActive('isBulletList') const isLink = isActive('link') - //TODO: вынести логику линки в отдельный компонент const toggleLinkForm = () => { - setLinkError(null) setLinkEditorOpen(true) } - const currentUrl = createEditorTransaction( - () => props.editor, - (editor) => { - return (editor && editor.getAttributes('link').href) || '' - } - ) - - const clearLinkForm = () => { - if (currentUrl()) { - props.editor.chain().focus().unsetLink().run() - } - setUrl('') - setLinkEditorOpen(false) - } - const handleUrlChange = (value) => { - setUrl(value) - } - const handleSubmitLink = () => { - if (validateUrl(url())) { - props.editor.chain().focus().setLink({ href: url() }).run() - setLinkEditorOpen(false) - } else { - setLinkError(t('Invalid url format')) - } - } - - const handleKeyPress = (event) => { - const key = event.key - if (key === 'Enter') handleSubmitLink() - if (key === 'Esc') clearLinkForm() - } - const toggleTextSizePopup = () => { if (listBubbleOpen()) setListBubbleOpen(false) setTextSizeBubbleOpen((prev) => !prev) @@ -90,25 +56,7 @@ export const EditorBubbleMenu = (props: BubbleMenuProps) => {