code: public static <PS, SEG, S> UndoManager<List<RichTextChange<PS, SEG, S>>> richTextUndoManager(
              GenericStyledArea<PS, SEG, S> area, UndoManagerFactory factory, Duration preventMergeDelay) {
          return factory.createMultiChangeUM(area.multiRichChanges(),
                  TextChange::invert,
                  applyMultiRichTextChange(area),
                  TextChange::mergeWith,
                  TextChange::isIdentity,
                  preventMergeDelay);
      }
docs: Returns an UndoManager that can undo/redo {@link RichTextChange}s. New changes
  emitted from the stream will not be merged with the previous change
  after {@code preventMergeDelay}