public void remove(SurfaceSelection selection) {
    Range range = selection.getSelection().getRange();

    Element ancestor = getCommonMatchingAncestor(selection);
    if (ancestor != null && ancestor.getParentElement() != null) {
      Node startNode = range.getStartContainer();
      Node endNode = range.getEndContainer();
      // nouvelle liste recueillant les lis après la sélection
      Element list =
          startNode.getOwnerDocument().createElement(action.getEmptyElement().getTagName());
      ancestor.getParentNode().insertAfter(list, ancestor);
      // on fait la liste des li concernés par la sélection

      Node nextSibling, child = ancestor.getFirstChild();
      boolean started = false, finished = false;
      while (child != null) {
        nextSibling = child.getNextSibling();
        if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equalsIgnoreCase("li")) {
          if (child.isOrHasChild(startNode)) {
            started = true;
          }
          if (started) {
            if (!finished) {
              if (child.isOrHasChild(endNode)) {
                finished = true;
              }
              child.removeFromParent();
              ancestor.getParentNode().insertBefore(child, list);
              action.onRevert((Element) child, selection);
            } else {
              child.removeFromParent();
              list.appendChild(child);
            }
          }
        }
        child = nextSibling;
      }
      DOMUtil.cleanBranch(ancestor);
      DOMUtil.cleanBranch(list);
    }
  }