File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -245,11 +245,25 @@ export default class Selection extends Cursor {
245245 this . setSelection ( )
246246 }
247247
248- // Delete the contents inside the range. After that the selection will be a
249- // cursor.
248+ // Delete the farest ancestor that is an exact selection
249+ deleteExactSurroundingMarkups ( ) {
250+ const markupTags = this . getAncestorTags (
251+ ( elem ) => [ 'STRONG' , 'EM' ] . includes ( elem . nodeName )
252+ ) . reverse ( )
253+ for ( const markupTag of markupTags ) {
254+ if ( this . isExactSelection ( markupTag ) ) {
255+ markupTag . remove ( )
256+ break
257+ }
258+ }
259+ }
260+
261+ // Delete the contents inside the range and exact surrounding markups.
262+ // After that the selection will be a cursor.
250263 //
251264 // @return Cursor instance
252265 deleteContent ( ) {
266+ this . deleteExactSurroundingMarkups ( )
253267 this . range . deleteContents ( )
254268 return new Cursor ( this . host , this . range )
255269 }
You can’t perform that action at this time.
0 commit comments