The previous implementation apparently came from an old version of summernote (see https://github.com/odoo/odoo/commit/d33086c03fc1a0882be38ae62989b7f72df20d3b). This commits should improve it to handle all known cases. See https://github.com/odoo/odoo/issues/20877