Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { cursor, node, start, end, anchor, all, gap } = taggedDoc.tag;
if (all) {
return new AllSelection(taggedDoc);
}
if (node) {
return new NodeSelection(taggedDoc.resolve(node));
}
if (cursor) {
return new TextSelection(taggedDoc.resolve(cursor));
}
if (gap) {
const $pos = taggedDoc.resolve(gap);
return new GapCursor($pos, $pos);
}
if (start) {
return createTextSelection({ taggedDoc, start, end });
}
const $anchor = resolveCell(taggedDoc, anchor);
if ($anchor) {
return Cast>(
new CellSelection($anchor, resolveCell(taggedDoc, taggedDoc.tag.head) ?? undefined),
);
}
return null;
};