-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
"Cannot resolve a Slate point from DOM point" for non-editable text rendered inside of Element #3421
Comments
This is kind of strange, but I think a hack solution is to use both a CSS style and an HTML attribute. ✅ For example, this works to render elements: <div {...attributes}>
<div
style={{ userSelect: "none" }}
contentEditable={false}
>
Non-editable
</div>
<p>{children}</p>
</div> 🛑 But oddly, this doesn't work: <div {...attributes}>
<div
contentEditable={false}
>
Non-editable
</div>
<p>{children}</p>
</div> 🛑 Nor does this: <div {...attributes}>
<div
style={{ userSelect: "none" }}
>
Non-editable
</div>
<p>{children}</p>
</div> I added these examples to the example code sandbox above. I say this is a "hack solution" because ideally all you would need is NOTE: This does not seem to stop the error from happening when doubleclicking into a child, and selecting all of the text. It seems to sometimes stop it, but not always. This specifically stops the error from happening when selecting or clicking on the non-interactive text specfically. |
I am experiencing this problem as well, @Charlex thanks for the hack solution for the time being :-) |
This has been a long standing behavior of slate. It assumes that elements on the DOM that are children of the editor are either
|
Thank you so much @Charlex for the workaround! BTW, I find the "Checklist" example (https://github.com/ianstormtaylor/slate/blob/master/site/examples/check-lists.js) misleading on that matter: it works with the |
i am encountering similar issues, only while running end to end tests using a headless puppeteer environment, @Charlex does this sound similar to what you have there?
|
it's useful. |
I find this happens if you're rendering (and then interacting) with an element that doesn't have slate's data attributes, which get passed in for example:
will cause this problem. To fix it you do this:
There are occasions when you want to render content that you don't want to be part of slates content, but appear alongside it. In this case you just add `contentEditable={false} to that element. For example
If an element will have Probably would be good to throw a better error cc @ianstormtaylor |
@juliankrispel thank you for providing that context. |
@juliankrispel Thank you for providing the solution. contentEditable={false} work for me |
I have found that wrapping // bad
<XLargeText as="h2" {...attributes}> // Styled Component
{children}
</XLargeText>
// good
<XLargeText as="h2"> // Styled Component
<span {...attributes}>{children}</span>
</XLargeText> |
If you have empty initial state remove |
I ran into this problem when rendering nothing in the slate component, since the introduction tutorial starts off with nothing in the To solve this, I set this as the default value: const [value, setValue] = useState<Descendant[]>([
{
type: "paragraph",
children: [{ text: "" }],
},
]); |
Thank you @dark-swordsman. I solved this problem using your solution. |
Exactly- I was just passing in [] into the value prop. This fixes it |
@dark-swordsman that solved my problem too. However, it would be much better if slate would give us a very clear message about empty content. And I think it should be able to handle empty content as well. |
i think this issue becomes enchantment at this point. |
I keep on bumping into this error, I have absolutely no idea why, or when it happens as it seems completely random. |
In my case, I've added a draggable item, which required the ref of the element. but apparently from
to
(but I have another issue, so it's still broken :D) |
# Human says close https://github.com/vikadata/vikadata/issues/10236 ianstormtaylor/slate#3421  As a human, what have you done for this pull request? Why? What? How? <!-- 如果这个Pull Request有对应的Issue,你可以复制Issue的相关信息。 --> <!-- # Why? > 对应哪个issue? > 为什么要这个pull request? > 背景故事或原因是怎样的? > 你理解的业务需求是怎样的? --> <!-- # What? > 这是一个什么Pull Request? > 描述一下是什么? > 对哪些人有好处? --> <!-- # How? > 大概描述下,如何具体实现的这个Pull Request? --> # AI says <!-- AI auto review added here --> <!-- This is an auto-generated comment: release notes by OSS CodeRabbit --> ### Summary by CodeRabbit - Style: Code formatting and style adjustments were made to the `MagicVariableElement` component for improved readability and consistency. - Chore: Variable assignments and conditional statements were modified in the `MagicVariableElement` component without affecting the logic or functionality of the code. <!-- end of auto-generated comment: release notes by OSS CodeRabbit -->
where can i catch this error? |
Do you want to request a feature or report a bug?
Bug
What's the current behavior?
When selecting (supposed to be) non-editable text that is rendered inside of an element, I am seeing an error "Cannot resolve a Slate point from DOM point". My usecase is to have a prefix that isn't editable, but explains the purpose of the block.
Slate: 0.57.1
Browser: Chrome 79.0.3945.117
OS: MacOS 10.15.2 (19C57)
What's the expected behavior?
To see no error, and have Slate ignore the non-editable text.
The text was updated successfully, but these errors were encountered: