rich text editor: fix the attribute replacement mechanism, loop over each tag rather than replacing everything with the first match