Support for Multiple, Discontinuous Selections?

Is there a clean, established way to create multiple selections and/or a selection with multiple, discontinuous ranges?

I notice that Selection contains a ranges array, but I don’t see any constructors or static helper methods for creating multiple ranges.

Perhaps the right way to do this would be to extend Selection with a new class that accepts multiple start/end positions—something like MultiNodeSelection or DiscontinuousTextSelection. If I were to do so, do all commands respect the Selection.ranges array when appropriate? Or do some simply use the anchor/head or from/to positions directly?

1 Like

Yes, creating a new Selection subclass, along with all the user interactions that go with it, would be the way to do this. You can see the CellSelection class in the tables module for an example.

1 Like