Skip to content
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

fix(extension-suggestion): get client rect by anchor. #5395

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

YonLJ
Copy link

@YonLJ YonLJ commented Jul 26, 2024

Changes Overview

Previously, clientRect was only obtained through decorationNode. If decorationNode could not be obtained, the value of clientRect was assigned to null. This commit adds a new method to obtain clientRect.

Implementation Approach

If decorationNode cannot be obtained, the coordinates are obtained according to the editor's cursor position, and the cursor position is used to generate a DOMRect.

Testing Done

In scenarios where Chinese IME is used, the value of clientRect is almost always null, which causes the "suggestion" to not render. This commit fixes this issue.

Verification Steps

Just type @ when using the Chinese input method and the result will be verified.

Additional Notes

before

after

Checklist

  • I have created a changeset for this PR if necessary.
  • My changes do not break the library.
  • I have added tests where applicable.
  • I have followed the project guidelines.
  • I have fixed any lint issues.

Related Issues

Copy link

changeset-bot bot commented Jul 26, 2024

⚠️ No Changeset found

Latest commit: 841753d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Jul 26, 2024

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 841753d
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/66bc5617a3de7800084daf48
😎 Deploy Preview https://deploy-preview-5395--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@bdbch
Copy link
Contributor

bdbch commented Aug 7, 2024

Just to clarify a little bit more - which decoration node are we talking about here?
For suggestions I usually used the posToDOMRect util function that is included in @tiptap/core, @tiptap/react and @tiptap/vue-* to get the clientRect by editor position (for example the cursor position)

@YonLJ
Copy link
Author

YonLJ commented Aug 8, 2024

Just to clarify a little bit more - which decoration node are we talking about here? For suggestions I usually used the posToDOMRect util function that is included in @tiptap/core, @tiptap/react and @tiptap/vue-* to get the clientRect by editor position (for example the cursor position)

The decoration node discussed here is the HTML tag that wraps the "@" character (like this <span data-decoration-id="id_xxxxxxx" class="suggestion">@</span>), which determines the display position of the "suggestion" component.

If it work properly, the html in the editor will look like this

<p>What do you all think about the new <span class="mention" data-type="mention" data-id="Winona Ryder" contenteditable="false">@Winona Ryder</span> movie? <span data-decoration-id="id_3457874414" class="suggestion">@</span></p>

When using Chinese input method, it is often impossible to obtain the decoration node by

view.dom.querySelector(`[data-decoration-id="${decorationId}"]`) 

@codeingforcoffee
Copy link

I have same problem, hope this can fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage open
Development

Successfully merging this pull request may close these issues.

3 participants