Options
All
  • Public
  • Public/Protected
  • All
Menu

This extension allows an app to embed collaborative text in a domain. When declared for a certain property with a string value, the string should be updated using the @splice operator; and updates coming from the domain will also provide precise changes using @splice, as follows. The overall effect is that the string property can be manipulated concurrently by multiple users with the result being a merge of their edits (rather than an array of conflicting string values, as would otherwise be the case).

The extension should be declared at runtime in the data using declare, or provided (combined with other plugins) during clone initialisation, e.g. for a hypothetical docText property:

const meld = await clone(new MemoryLevel, IoRemotes, config, combinePlugins([
  new TSeqText('docText'), ...
]));

Once installed, a new document with text could be inserted:

await meld.write({ '@id': 'myDoc', docText: 'Initial text' });

Changes to the document should be written using splice expressions in an @update:

await meld.write({ '@update': { '@id': 'myDoc', docText: { '@splice': [0, 7, 'My'] } });

This update will be echoed by the local clone, also using the @splice operator.

This update changes the text "Initial" to "My". If a remote user updates "text" at position 8 to "words", at the same time, the update notification at this clone will correctly identify the change as happening at index position 3. Thus both clones will converge to "My words".

To generate splices, applications may consider the utility function textDiff.

To apply splices, applications may consider using updateSubject.

see

TSeq

experimental

Hierarchy

  • TSeqText

Implements

Index

Constructors

Methods

Constructors

constructor

  • new TSeqText(...properties: Iri[]): TSeqText
  • The class constructor should only be used if declaring the extension in the call to clone, i.e. at design time. To apply the extension at runtime, declare it in the data using declare.

    Parameters

    • Rest ...properties: Iri[]

      the properties to target

    Returns TSeqText

Methods

Static declare

  • declare(priority: number, ...properties: Iri[]): Subject
  • Extension declaration. Insert into the domain data to install the extension. For example (assuming a m-ld clone object and a property docText in the domain):

    clone.write(TSeqText.declare(0, 'docText'));
    

    Parameters

    • priority: number

      the preferred index into the existing list of extensions (lower value is higher priority).

    • Rest ...properties: Iri[]

      the properties to which to apply TSeq text behaviour

    Returns Subject

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method
  • Protected method

Generated using TypeDoc. Delivered by Vercel. @m-ld/m-ld - v0.10.0-edge.5 Source code licensed MIT. Privacy policy