The activeDocument.mergeVisibleLayers();
command simply flattens the image to the Background layer.
I am looking for a way to merge all layers to a new layer which stays on top of all other layers, like the Layer->Merge Visible (Ctrl+Shift+E) Photoshop command.
Is that possible?
Not sure if this is the best solution but it worked for me:
// Copy all visible layers to clipboard (true = merged)
activeDocument.activeLayer.copy(true);
// then paste them (creates a new layer)
activeDocument.paste();