I've published an open-source rich text editor package library Taze Editor. It provides a set of functions to help you build a rich text editor.
Docs: https://taze-editor.vercel.app
Source code: https://github.com/taze-editor/taze-editor
Docs: https://taze-editor.vercel.app
Source code: https://github.com/taze-editor/taze-editor