UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

27 lines (26 loc) 919 B
import { Anchor } from '../rga/constants'; import { PersistedSlice } from './PersistedSlice'; /** * Represents a block split in the text, i.e. it is a *marker* that shows * where a block was split. Markers also insert one "\n" new line character. * Both marker ends are attached to the "before" anchor fo the "\n" new line * character, i.e. it is *collapsed* to the "before" anchor. */ export class MarkerSlice extends PersistedSlice { /** * Returns the {@link Range} which exactly contains the block boundary of this * marker. */ boundary() { const start = this.start; const end = start.clone(); end.anchor = Anchor.After; return this.txt.range(start, end); } del() { super.del(); const txt = this.txt; const range = txt.range(this.start, this.start.copy((p) => (p.anchor = Anchor.After))); txt.delStr(range); } }