@@ -853,22 +853,22 @@ export class Editor<T = string> implements Printable {
853853 return true ;
854854 }
855855
856- public split ( type ?: SliceType , data ?: unknown , slices : EditorSlices < T > = this . saved ) : void {
856+ public split ( type ?: SliceType , data ?: unknown , selection : Range < T > [ ] | IterableIterator < Range < T > > = this . cursors ( ) , slices : EditorSlices < T > = this . saved ) : void {
857857 if ( type === void 0 ) {
858- for ( let i = this . cursors0 ( ) , cursor = i ( ) ; cursor ; cursor = i ( ) ) {
859- this . collapseCursor ( cursor ) ;
860- const didInsertMarker = this . splitAt ( cursor . start , slices ) ;
861- if ( didInsertMarker ) cursor . move ( 1 ) ;
858+ for ( const range of selection ) {
859+ this . collapseCursor ( range ) ;
860+ const didInsertMarker = this . splitAt ( range . start , slices ) ;
861+ if ( didInsertMarker && range instanceof Cursor ) range . move ( 1 ) ;
862862 }
863863 } else {
864- for ( let i = this . cursors0 ( ) , cursor = i ( ) ; cursor ; cursor = i ( ) ) {
865- this . collapseCursor ( cursor ) ;
864+ for ( const range of selection ) {
865+ this . collapseCursor ( range ) ;
866866 if ( type === void 0 ) {
867867 // TODO: detect current block type
868868 type = CommonSliceType . p ;
869869 }
870870 slices . insMarker ( type , data ) ;
871- cursor . move ( 1 ) ;
871+ if ( range instanceof Cursor ) range . move ( 1 ) ;
872872 }
873873 }
874874 }
@@ -920,11 +920,12 @@ export class Editor<T = string> implements Printable {
920920 public tglMarker (
921921 type : SliceType ,
922922 data ?: unknown ,
923+ selection : Range < T > [ ] | IterableIterator < Range < T > > = this . cursors ( ) ,
923924 slices : EditorSlices < T > = this . saved ,
924925 def : SliceTypeStep = SliceTypeCon . p ,
925926 ) : void {
926- for ( let i = this . cursors0 ( ) , cursor = i ( ) ; cursor ; cursor = i ( ) )
927- this . tglMarkerAt ( cursor . start , type , data , slices , def ) ;
927+ for ( const range of selection )
928+ this . tglMarkerAt ( range . start , type , data , slices , def ) ;
928929 }
929930
930931 /**
@@ -935,15 +936,15 @@ export class Editor<T = string> implements Printable {
935936 * @param slices The slices set to use, if new marker is inserted at the start
936937 * of the document.
937938 */
938- public updMarker ( type : SliceType , data ?: unknown , slices : EditorSlices < T > = this . saved ) : void {
939- for ( let i = this . cursors0 ( ) , cursor = i ( ) ; cursor ; cursor = i ( ) )
940- this . updMarkerAt ( cursor . start , type , data , slices ) ;
939+ public updMarker ( type : SliceType , data ?: unknown , selection : Range < T > [ ] | IterableIterator < Range < T > > = this . cursors ( ) , slices : EditorSlices < T > = this . saved ) : void {
940+ for ( const range of selection )
941+ this . updMarkerAt ( range . start , type , data , slices ) ;
941942 }
942943
943- public delMarker ( ) : void {
944+ public delMarker ( selection : Range < T > [ ] | IterableIterator < Range < T > > = this . cursors ( ) ) : void {
944945 const markerPoints = new Set < MarkerOverlayPoint < T > > ( ) ;
945- for ( let i = this . cursors0 ( ) , cursor = i ( ) ; cursor ; cursor = i ( ) ) {
946- const markerPoint = this . txt . overlay . getOrNextLowerMarker ( cursor . start ) ;
946+ for ( const range of selection ) {
947+ const markerPoint = this . txt . overlay . getOrNextLowerMarker ( range . start ) ;
947948 if ( markerPoint ) markerPoints . add ( markerPoint ) ;
948949 }
949950 for ( const markerPoint of markerPoints ) {
0 commit comments