Transform.replaceWith split marks?

I just realised that Transform.replaceWith used in the linter example:

function fixPunc(replacement) {
  return function({state, dispatch}) {
    dispatch(state.tr.replaceWith(this.from, this.to,
                                  state.schema.text(replacement)))
  }
}

split marks.

Initial dom structure (with punctuation problem):

<p>
  and, double-click them to 
  <strong>
    automaticall fix
    <div class="lint-icon ProseMirror-widget" title="Suspicious spacing around punctuation" contenteditable="false">
    </div>
    <span class="problem"> . </span>
    it
  </strong> 
  (if supported).
</p>

Result after fixPunct did it’s thing:

<p>
  and, double-click them to 
  <strong>automaticall fix</strong>
  .
  <strong>it</strong> 
  (if supported).
</p>

Is there a way to do a replace text and keep the surrounding mark intact?

There’s no automatic adding of marks in replaceWith, but you can get the active marks at a position with ResolvedPos.marks, and add them to your node.