UNPKG

delta-component

Version:

embeddable react component

27 lines (20 loc) 595 B
'use strict'; class RemoteOpsConsumer { constructor(doc) { this.doc = doc; } consume(newText, localCursorIndex, cursorMap) { /** * Уведомить интерфейс о новом тексте и новых позициях курсоров. */ const cachedText = this.doc.getCachedText(); if(cachedText !== newText) { this.doc.textChanged(newText); } this.doc.localCursorChanged(localCursorIndex); this.doc.cursorsChanged(cursorMap); } } module.exports = { RemoteOpsConsumer, };