fix: #198 WordML MergeFields remove parent and crashes if multiple fields share parent #199
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We use SyncFusion Document Editor to edit documents and perform MailMerge operations, which we process on our backend with Sablon.
Occasionally, we have errors thrown when users have put mergefields on the same line as another merge field, particularly if those mergefields insert WordML such as tables or images.
This seems to happen because
Sablon::Content::WordML
removes the parent, expecting only one WordML variable per parent paragraph.I made a ticket on this but thought I'd try to to be helpful and propose a fix, which is to insert a new paragraph as the previous sibling to the existing paragraph, then replace that paragraph with the variable instead, ensuring that it never removes a paragraph unless the mergefield is the last mergefield of that paragraph