(rng: Range)
| 535 | }; |
| 536 | |
| 537 | const removeRngStyle = (rng: Range) => { |
| 538 | let startContainer: Node; |
| 539 | let endContainer: Node; |
| 540 | |
| 541 | let expandedRng = ExpandRange.expandRng(dom, rng, formatList, { includeTrailingSpace: rng.collapsed }); |
| 542 | |
| 543 | if (format.split) { |
| 544 | // Split text nodes |
| 545 | expandedRng = SplitRange.split(expandedRng); |
| 546 | |
| 547 | startContainer = getContainer(ed, expandedRng, true); |
| 548 | endContainer = getContainer(ed, expandedRng); |
| 549 | |
| 550 | if (startContainer !== endContainer) { |
| 551 | // WebKit will render the table incorrectly if we wrap a TH or TD in a SPAN |
| 552 | // so let's see if we can use the first/last child instead |
| 553 | // This will happen if you triple click a table cell and use remove formatting |
| 554 | startContainer = normalizeTableSelection(startContainer, true); |
| 555 | endContainer = normalizeTableSelection(endContainer, false); |
| 556 | |
| 557 | // Wrap and split if nested |
| 558 | if (isChildOfInlineParent(dom, startContainer, endContainer)) { |
| 559 | const marker = Optional.from(startContainer.firstChild).getOr(startContainer); |
| 560 | splitToFormatRoot(wrapWithSiblings(dom, marker, true, 'span', { 'id': '_start', 'data-mce-type': 'bookmark' })); |
| 561 | unwrap(true); |
| 562 | return; |
| 563 | } |
| 564 | |
| 565 | // Wrap and split if nested |
| 566 | if (isChildOfInlineParent(dom, endContainer, startContainer)) { |
| 567 | const marker = Optional.from(endContainer.lastChild).getOr(endContainer); |
| 568 | splitToFormatRoot(wrapWithSiblings(dom, marker, false, 'span', { 'id': '_end', 'data-mce-type': 'bookmark' })); |
| 569 | unwrap(false); |
| 570 | return; |
| 571 | } |
| 572 | |
| 573 | // Wrap start/end nodes in span element since these might be cloned/moved |
| 574 | startContainer = wrap(dom, startContainer, 'span', { 'id': '_start', 'data-mce-type': 'bookmark' }); |
| 575 | endContainer = wrap(dom, endContainer, 'span', { 'id': '_end', 'data-mce-type': 'bookmark' }); |
| 576 | |
| 577 | // Split start/end and anything in between |
| 578 | const newRng = dom.createRng(); |
| 579 | newRng.setStartAfter(startContainer); |
| 580 | newRng.setEndBefore(endContainer); |
| 581 | RangeWalk.walk(dom, newRng, (nodes) => { |
| 582 | Arr.each(nodes, (n) => { |
| 583 | if (!Bookmarks.isBookmarkNode(n) && !Bookmarks.isBookmarkNode(n.parentNode)) { |
| 584 | splitToFormatRoot(n); |
| 585 | } |
| 586 | }); |
| 587 | }); |
| 588 | splitToFormatRoot(startContainer); |
| 589 | splitToFormatRoot(endContainer); |
| 590 | |
| 591 | // Unwrap start/end to get real elements again |
| 592 | // Note that the return value should always be a node since it's wrapped above |
| 593 | startContainer = unwrap(true) as Node; |
| 594 | endContainer = unwrap() as Node; |
no test coverage detected
searching dependent graphs…