All files / json-crdt-extensions/peritext constants.ts

100% Statements 11/11
100% Branches 4/4
100% Functions 3/3
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 4058x 58x     58x 58x     58x           58x           58x     58x   58x 1827x                          
import {type nodes, s} from '../../json-crdt-patch';
import {ExtensionId, ExtensionName} from '../constants';
import type {SliceSchema} from './slice/types';
 
export enum Chars {
  BlockSplitSentinel = '\n',
}
 
export enum Position {
  /**
   * Specifies the absolute start of the text, i.e. the position before the
   * first character. In model space it is defined as string ID and "after"
   * anchor.
   */
  AbsStart = -1,
 
  /**
   * Specifies the absolute end of the text, i.e. the position after the last
   * character. In model space it is defined as string ID and "before" anchor.
   */
  AbsEnd = 9007199254740991, // Number.MAX_SAFE_INTEGER
}
 
export const MNEMONIC = ExtensionName[ExtensionId.peritext];
 
export const SCHEMA = (text: string) =>
  s.vec<
    [
      /**
       * The text of the node. All rich-text textual data is stored in this node.
       */
      str: nodes.str<string>,
      /**
       * The slices of the node. All rich-text annotations are stored in this
       * node.
       */
      slices: nodes.arr<SliceSchema>,
    ]
  >(s.str<string>(text), s.arr<SliceSchema>([]));