UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

31 lines (30 loc) 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MarkerSlice = void 0; const constants_1 = require("../rga/constants"); const PersistedSlice_1 = require("./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. */ class MarkerSlice extends PersistedSlice_1.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 = constants_1.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 = constants_1.Anchor.After))); txt.delStr(range); } } exports.MarkerSlice = MarkerSlice;