+ let [start, end] = selection?.getStartEndPoints() || [null, null];
+
+ // Ensure we ignore parent list items of the top-most list item since,
+ // although technically part of the selection, from a user point of
+ // view the selection does not spread to encompass this outer element.
+ const itemsToIgnore: Set<string> = new Set();
+ if (selection && start) {
+ if (selection.isBackward() && end) {
+ [end, start] = [start, end];
+ }
+
+ const startParents = start.getNode().getParents();
+ let foundList = false;
+ for (const parent of startParents) {
+ if ($isListItemNode(parent)) {
+ if (foundList) {
+ itemsToIgnore.add(parent.getKey());
+ } else {
+ foundList = true;
+ }
+ }
+ }
+ }