-
Notifications
You must be signed in to change notification settings - Fork 81
SD-1460 - fix: don't drop track format on run nodes #1850
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { TrackDeleteMarkName, TrackInsertMarkName } from '@extensions/track-changes/constants.js'; | ||
| import { TrackDeleteMarkName, TrackInsertMarkName, TrackFormatMarkName } from '@extensions/track-changes/constants.js'; | ||
|
|
||
| const cloneMark = (mark) => { | ||
| if (!mark) return mark; | ||
|
|
@@ -24,8 +24,9 @@ const cloneRuns = (runs = []) => runs.map((run) => cloneNode(run)); | |
|
|
||
| export const prepareRunTrackingContext = (node = {}) => { | ||
| const marks = Array.isArray(node.marks) ? node.marks : []; | ||
| const trackingMarks = marks.filter( | ||
| (mark) => mark?.type === TrackInsertMarkName || mark?.type === TrackDeleteMarkName, | ||
|
|
||
| const trackingMarks = marks.filter((mark) => | ||
| [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName].includes(mark?.type), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
const preservedMarks = marks
.filter((mark) => ![TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName].includes(mark?.type))
.map((mark) => cloneMark(mark));
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tupizz 👀 |
||
| ); | ||
|
|
||
| if (!trackingMarks.length) { | ||
|
|
@@ -88,7 +89,8 @@ export const ensureTrackedWrapper = (runs, trackingMarksByType = new Map()) => { | |
|
|
||
| if (!trackingMarksByType.size) return runs; | ||
|
|
||
| if (trackingMarksByType.has(TrackInsertMarkName)) { | ||
| const isTrackInsertMark = trackingMarksByType.has(TrackInsertMarkName); | ||
| if (isTrackInsertMark) { | ||
| const mark = trackingMarksByType.get(TrackInsertMarkName); | ||
| const clonedRuns = cloneRuns(runs); | ||
| const wrapper = { | ||
|
|
@@ -107,7 +109,8 @@ export const ensureTrackedWrapper = (runs, trackingMarksByType = new Map()) => { | |
| return [wrapper]; | ||
| } | ||
|
|
||
| if (trackingMarksByType.has(TrackDeleteMarkName)) { | ||
| const isTrackDeleteMark = trackingMarksByType.has(TrackDeleteMarkName); | ||
| if (isTrackDeleteMark) { | ||
| const mark = trackingMarksByType.get(TrackDeleteMarkName); | ||
| const clonedRuns = cloneRuns(runs); | ||
| clonedRuns.forEach(renameTextElementsForDeletion); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed this - the current name seems counter-intuitive, it's not creating a mark, but instead decoding it back to OOXML.
Thoughts?