-
Notifications
You must be signed in to change notification settings - Fork 164
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
"newEntity" event not triggered when inserting entity by formatting content model #2852
Comments
@ndjonbor Please provide a minimum repro of "content" so we can try end to end repro. Thanks. |
No prob, here you go. Btw, this is also what the content looks like when exporting the editor HTML for saving to our backend. const exampleContent = '<div style="margin-left: 0; font-family: Arial"><span class="_Entity _EType_SpecTitle _EId_SpecTitle _EReadonly_1" style="color: inherit"></span></div>'; After inserting the content, the DOM looks like this: (I excluded the editor container div here) <div style="margin-left: 0px; font-family: Arial">
<span class="entityDelimiterBefore" style="font-size: 10pt"></span
><span
style=""
class="_Entity _EType_SpecTitle _EId_SpecTitle _EReadonly_1"
contenteditable="false"
>[00 Title]</span
><span class="entityDelimiterAfter" style="font-size: 10pt"></span>
</div> |
Got it. For now, we don't do auto detection of new entity from I have built a sample here: https://codepen.io/jiuqingsong/pen/zYgjXVX Just click the "Test" button, you should get a dialog showing the new entity Id: |
Gotcha, that's reasonable.
Aha, using the context is something I wasn't even aware of. Doing it that way will be a bit cleaner, and work just fine 👍 Thanks for looking into it, and for the sample! EDIT: |
Maybe we can add a parameter to allow auto detecting of new entities, then you don't need to do that manually. |
Yes, I did have to adjust a little bit in order to detect new inline entities within list elements, for example. Given the use case of entity lifecycles and hydration/dehydration, I think something like that would be useful. 👍 I'm subscribed to the new issue you linked, keeping my eyes peeled |
Describe the bug
The "newEntity" operation is supposed to notify plugins when new entity DOM nodes are added to the editor. However, when formatting the content model with entities, no "newEntity" notifications are sent, even though new entity DOM nodes are indeed added. Other entity operation notifications, such as "click" and "removeFromEnd", work as expected.
To Reproduce
Expected behavior
The "newEntity" operation should be triggered when formatting the content model, as new entity DOM nodes are added.
Screenshots
None
Device Information
Additional context
I need to rehydrate entities when loading previously stored HTML. I managed to achieve this by manually triggering EntityOperationEvent with the "newEntity" operation using the onNodeCreated callback for IEditor.formatContentModel. However, I'm unsure if this approach is correct. Any advice would be appreciated. Here’s how I’m currently formatting the content model when fetching HTML from our backend:
The text was updated successfully, but these errors were encountered: