diff --git a/packages/client/src/tiptap/core/extensions/dragable.ts b/packages/client/src/tiptap/core/extensions/dragable.ts index d5e9409..460d102 100644 --- a/packages/client/src/tiptap/core/extensions/dragable.ts +++ b/packages/client/src/tiptap/core/extensions/dragable.ts @@ -28,6 +28,7 @@ export const Dragable = Extension.create({ name: 'dragable', addProseMirrorPlugins() { + let scrollContainer; let dropElement; let currentNode; let editorView; @@ -54,6 +55,11 @@ export const Dragable = Extension.create({ editorView.dragging = { slice, move: true }; } + function onScroll() { + if (!dropElement) return; + dropElement.style.opacity = 0; + } + return [ new Plugin({ view(view) { @@ -64,6 +70,12 @@ export const Dragable = Extension.create({ dropElement.className = 'drag-handler'; dropElement.addEventListener('dragstart', drag); view.dom.parentElement.appendChild(dropElement); + + scrollContainer = view.dom.parentElement.parentElement?.parentElement?.parentElement; + + if (scrollContainer) { + scrollContainer.addEventListener('scroll', onScroll); + } } return { @@ -75,6 +87,10 @@ export const Dragable = Extension.create({ dropElement.removeEventListener('dragstart', drag); dropElement.parentNode.removeChild(dropElement); } + + if (scrollContainer) { + scrollContainer.removeEventListener('scroll', onScroll); + } }, }; }, @@ -91,7 +107,7 @@ export const Dragable = Extension.create({ } }, 50); }, - mousemove(view, event) { + mousedown(view, event) { if (!dropElement) return; const coords = { left: event.clientX, top: event.clientY }; @@ -134,10 +150,6 @@ export const Dragable = Extension.create({ dropElement.style.top = rect.top + 6 + 'px'; dropElement.style.opacity = 1; }, - mouseleave() { - if (!dropElement || currentNode) return; - dropElement.style.opacity = 0; - }, }, }, }), diff --git a/packages/client/src/tiptap/core/wrappers/attachment/index.tsx b/packages/client/src/tiptap/core/wrappers/attachment/index.tsx index 50687a5..e16293e 100644 --- a/packages/client/src/tiptap/core/wrappers/attachment/index.tsx +++ b/packages/client/src/tiptap/core/wrappers/attachment/index.tsx @@ -6,6 +6,7 @@ import { Tooltip } from 'components/tooltip'; import { useToggle } from 'hooks/use-toggle'; import { useCallback, useEffect, useRef, useState } from 'react'; import { uploadFile } from 'services/file'; +import { Attachment } from 'tiptap/core/extensions/attachment'; import { DragableWrapper } from 'tiptap/core/wrappers/dragable'; import { download, extractFileExtension, extractFilename, normalizeFileSize } from 'tiptap/prose-utils'; @@ -154,5 +155,9 @@ export const AttachmentWrapper = ({ editor, node, updateAttributes }) => { } })(); - return {content}; + return ( + + {content} + + ); }; diff --git a/packages/client/src/tiptap/core/wrappers/callout/index.tsx b/packages/client/src/tiptap/core/wrappers/callout/index.tsx index f9d0371..bea8529 100644 --- a/packages/client/src/tiptap/core/wrappers/callout/index.tsx +++ b/packages/client/src/tiptap/core/wrappers/callout/index.tsx @@ -4,6 +4,7 @@ import { EmojiPicker } from 'components/emoji-picker'; import { convertColorToRGBA } from 'helpers/color'; import { Theme, ThemeEnum } from 'hooks/use-theme'; import { useCallback, useMemo } from 'react'; +import { Callout } from 'tiptap/core/extensions/callout'; import { DragableWrapper } from 'tiptap/core/wrappers/dragable'; import styles from './index.module.scss'; @@ -26,7 +27,12 @@ export const CalloutWrapper = ({ editor, node, updateAttributes }) => { ); return ( - +
(); return ( - +