A woman put the lives of residents at risk by starting a fire at the block of flats where she lived, a court heard.
Victoria Galley, 43, also attacked firefighters and police who were called to the blaze at Carlton Rise, Little London, on July 24 last year.
Leeds Crown Court heard Galley used a cigarette lighter to set fire to a pile of rubbish and furniture on the third floor landing outside her flat.
Duncan Ritchie, prosecuting, said Galley was drinking from a can at the time and appeared to be drunk.
Galley then went back inside her home but a neighbour who witnessed the incident raised the alarm.
Mr Ritchie said the neighbour was concerned for the safety of a disabled elderly woman who lived on the ground floor.
Firefighters were called and all residents were safely evacuated before the fire was brought under control.
Galley assaulted firefighters and spat at them as she was escorted from the building.
She then used the lighter to try to set fire to her clothing.
Police arrested her at the scene and she tried to attack them.
Galley was interviewed and admitted starting the fire.
She said she had been drinking at the time and had been suffering from depression.
Galley also admitted that she had started the blaze intending to kill herself but did not want to hurt any of the other residents.
Mr Ritchie said: “She told police that her head had just completely gone.”
Galley pleaded guilty to arson being reckless as to whether life was endangered.
The court heard she has no previous convictions.
She was made the subject of a hospital order and detained indefinitely under the Mental Health Act.
Judge Sean Morris told Galley that it was necessary to make the order to protect the public and so she could continue to receive treatment in hospital.