import type { Universe } from '@ephox/boss'; import { Arr, type Optional } from '@ephox/katamari'; /** * Search the parents of both items for a common element */ const common = (universe: Universe, item1: E, item2: E): Optional => { const item1parents = [ item1 ].concat(universe.up().all(item1)); const item2parents = [ item2 ].concat(universe.up().all(item2)); return Arr.find(item1parents, (x) => { return Arr.exists(item2parents, (y) => { return universe.eq(y, x); }); }); }; export { common };