I wonder whether a trip to Puerto Rico (PR) count as a trip outside the United States for the purpose of N-400 (Application for Naturalization). I'm looking for an official source.
No, a trip (and stay) in PR does not count, since PR is US Territory, and as such your trip to PR was the same as domestic travel to any one of the 50 states.
However, this is incorrect: some US Territories do count as a trip outside the United States for the purpose of N-400. E.g., from https://www.uscis.gov/policy-manual/volume-12-part-d-chapter-4:
USCIS will only count residence in the Commonwealth of the Northern Mariana Islands on or after November 28, 2009, as time counted for physical presence within the United States for naturalization purposes.
And the Commonwealth of the Northern Mariana Islands [became a US territory in 1975](https://www.doi.gov/oia/islands/cnmi#:~:text=The%20Federal%20law%20(the%20Covenant,and%20immigration%20law%20in%202008.):
The Federal law (the Covenant) making the CNMI a U.S. territory passed in 1975.