(items, options)
| 79 | * @param {{readOnly:boolean,hasSelection:boolean}} options |
| 80 | */ |
| 81 | export function filterSelectionMenuItems(items, options) { |
| 82 | const { readOnly, hasSelection } = options; |
| 83 | return items.filter((item) => { |
| 84 | if (readOnly && !item.readOnly) return false; |
| 85 | if (hasSelection && !["selected", "all"].includes(item.mode)) return false; |
| 86 | if (!hasSelection && item.mode === "selected") return false; |
| 87 | return true; |
| 88 | }); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Detect which edge(s) should trigger drag auto-scroll. |