mirror of
https://github.com/cudr/slate-collaborative.git
synced 2026-03-02 03:40:18 +00:00
Preserve external history option (#22)
* feat: handle node text in remove_text op * feat: add preserveExternalHistory option
This commit is contained in:
@@ -9,7 +9,9 @@ export const insertText = (
|
||||
): SyncValue => {
|
||||
const node = getTarget(doc, op.path)
|
||||
|
||||
node.text.insertAt(op.offset, ...op.text.split(''))
|
||||
const offset = Math.min(node.text.length, op.offset)
|
||||
|
||||
node.text.insertAt(offset, ...op.text.split(''))
|
||||
|
||||
return doc
|
||||
}
|
||||
@@ -20,7 +22,9 @@ export const removeText = (
|
||||
): SyncValue => {
|
||||
const node = getTarget(doc, op.path)
|
||||
|
||||
node.text.deleteAt(op.offset, op.text.length)
|
||||
const offset = Math.min(node.text.length, op.offset)
|
||||
|
||||
node.text.deleteAt(offset, op.text.length)
|
||||
|
||||
return doc
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user