Skip to content

Conversation

@fwaisi
Copy link
Contributor

@fwaisi fwaisi commented Oct 22, 2024

…… #427

@zax-assistant
Copy link
Contributor

zax-assistant bot commented Oct 24, 2024

Published version 1.8.1-LEAN-3978.0

@fwaisi
Copy link
Contributor Author

fwaisi commented Oct 28, 2024

Two problems were identified and fixed in the track changes plugin:

  • Prosemirror was attempting to insert a table node inside a paragraph node, which is invalid in the document schema. This was causing an error.

  • The splitSliceIntoMergedParts function was inadvertently removing paragraph nodes from the slice because it was attempting to merge them with incompatible nodes (like tables). To fix this, I added a node compatibility check before attempting any merge operations:

const firstNodeType = firstChild?.type?.name const nextNodeType = nodes[1]?.type?.name // Only merge when nodes are of the same type const firstMergedNode = openStart > 0 && mergeSides && firstChild && firstNodeType === nextNodeType

I also fixed a logic error in this condition which was incorrectly evaluating to true in all cases.

@IslamJMomani
Copy link
Contributor

Two problems were identified and fixed in the track changes plugin:

  • Prosemirror was attempting to insert a table node inside a paragraph node, which is invalid in the document schema. This was causing an error.
  • The splitSliceIntoMergedParts function was inadvertently removing paragraph nodes from the slice because it was attempting to merge them with incompatible nodes (like tables). To fix this, I added a node compatibility check before attempting any merge operations:

const firstNodeType = firstChild?.type?.name const nextNodeType = nodes[1]?.type?.name // Only merge when nodes are of the same type const firstMergedNode = openStart > 0 && mergeSides && firstChild && firstNodeType === nextNodeType

I also fixed a logic error in this condition which was incorrectly evaluating to true in all cases.

Are these problems occurring only when pasting the table node, rather than the entire table element? In other words, if the selection includes the whole table element, do any issues still arise?

I’m still under the impression that this is a selection issue that could be handled in the body editor. I’m inviting @mbartenev-atypon to take a look.

@fwaisi
Copy link
Contributor Author

fwaisi commented Oct 30, 2024

Two problems were identified and fixed in the track changes plugin:

  • Prosemirror was attempting to insert a table node inside a paragraph node, which is invalid in the document schema. This was causing an error.
  • The splitSliceIntoMergedParts function was inadvertently removing paragraph nodes from the slice because it was attempting to merge them with incompatible nodes (like tables). To fix this, I added a node compatibility check before attempting any merge operations:

const firstNodeType = firstChild?.type?.name const nextNodeType = nodes[1]?.type?.name // Only merge when nodes are of the same type const firstMergedNode = openStart > 0 && mergeSides && firstChild && firstNodeType === nextNodeType
I also fixed a logic error in this condition which was incorrectly evaluating to true in all cases.

Are these problems occurring only when pasting the table node, rather than the entire table element? In other words, if the selection includes the whole table element, do any issues still arise?

I’m still under the impression that this is a selection issue that could be handled in the body editor. I’m inviting @mbartenev-atypon to take a look.

@IslamJMomani, yes, it's occurring when pasting the table node. Updating the selection as I did in the beginning will fix the issue, but disabling the track-changes plugin will fix the issue as well. So I think we need to decide whether to fix it in the track-changes or in the body-editor.

@mbartenev-atypon, please advise?

@mbartenev-atypon
Copy link
Contributor

mbartenev-atypon commented Nov 4, 2024

I'd say we need to make sure that the selection in the body editor is correct in the first place and we can keep this logic here to issue warnings if anything like that happens but not fix it. E.g.: "attempt to merge incompatible nodes. aborting"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants