The protomagnetar model for gamma-ray bursts