-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
refactor: optimize find element coords #7063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: optimize find element coords #7063
Conversation
🦋 Changeset detectedLatest commit: a68a429 The changes in this PR will be included in the next version bump. This PR includes changesets to release 70 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
@tiptap/extension-character-count
@tiptap/extension-focus
@tiptap/extension-dropcursor
@tiptap/extension-gapcursor
@tiptap/extension-history
@tiptap/extension-list-item
@tiptap/extension-list-keymap
@tiptap/extension-placeholder
@tiptap/extension-table-cell
@tiptap/extension-table-header
@tiptap/extension-table-row
@tiptap/extension-task-item
@tiptap/extension-task-list
@tiptap/extension-blockquote
@tiptap/core
@tiptap/extension-bold
@tiptap/extension-bubble-menu
@tiptap/extension-bullet-list
@tiptap/extension-code-block
@tiptap/extension-code
@tiptap/extension-code-block-lowlight
@tiptap/extension-collaboration
@tiptap/extension-collaboration-caret
@tiptap/extension-color
@tiptap/extension-details
@tiptap/extension-document
@tiptap/extension-drag-handle-react
@tiptap/extension-drag-handle-vue-2
@tiptap/extension-drag-handle
@tiptap/extension-drag-handle-vue-3
@tiptap/extension-emoji
@tiptap/extension-file-handler
@tiptap/extension-floating-menu
@tiptap/extension-font-family
@tiptap/extension-hard-break
@tiptap/extension-highlight
@tiptap/extension-heading
@tiptap/extension-horizontal-rule
@tiptap/extension-image
@tiptap/extension-invisible-characters
@tiptap/extension-italic
@tiptap/extension-link
@tiptap/extension-list
@tiptap/extension-mention
@tiptap/extension-mathematics
@tiptap/extension-node-range
@tiptap/extension-ordered-list
@tiptap/extension-paragraph
@tiptap/extension-strike
@tiptap/extension-table
@tiptap/extension-subscript
@tiptap/extension-superscript
@tiptap/extension-text
@tiptap/extension-table-of-contents
@tiptap/extension-text-align
@tiptap/extension-typography
@tiptap/extension-text-style
@tiptap/extension-underline
@tiptap/extension-youtube
@tiptap/extension-unique-id
@tiptap/extensions
@tiptap/html
@tiptap/markdown
@tiptap/react
@tiptap/starter-kit
@tiptap/pm
@tiptap/static-renderer
@tiptap/suggestion
@tiptap/vue-3
@tiptap/vue-2
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
packages/extension-drag-handle/src/helpers/findNextElementFromCursor.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
…Cursor.ts Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good however I dislike that we updated the demos to much here. I guess you needed to test it with the UniqueID extension?
Could we revert the demo changes so the PR only includes changes to the actual extension for now?
…lam97/tiptap into refactor/optimize-find-element-coords
…lam97/tiptap into refactor/optimize-find-element-coords
Updated the PR |
Changes Overview
This PR includes two major improvements to the drag handle system:
findElementNextToCoordsto use browser's nativeelementsFromPointAPI for better performanceDragHandlecomponent (Vue 3)Implementation Approach
findElementNextToCoords Optimization
querySelectorAlltraversal withelementsFromPointclampToContenthelper to automatically clamp coordinates to editor content boundsfindClosestTopLevelBlockhelper to efficiently find top-level draggable blocksDragHandle Vue 3 Lifecycle Improvements
await nextTick()inonMountedto ensure DOM is fully ready before plugin initializationshallowRefto accessunbindmethod for proper cleanuproot.valueand editor destruction state before operationsunbind()inonBeforeUnmountto properly clean up event listenersonElementDragStartandonElementDragEndprops for drag lifecycle eventsAdditional Notes
Performance Improvements (Chrome DevTools profiling)
findElementNextToCoords optimization results:
See performance comparison screenshots below.
BEFORE

AFTER

Other Benefits
mousemovefrom root/document level, coordinate clamping ensures hovering on edges always returns correct resultsonElementDragStartandonElementDragEndcallbacks for drag lifecycle eventsChecklist
Related Issues
This update addresses and fixes the following issues:
#7055
#7054
#7052
#7034
#7022
#6978
#6960
#6923
#6942
It also closes the following pull requests:
#6921
#6980
#6931