feat: update to slate 0.58 && fix site build

This commit is contained in:
cudr
2020-05-11 09:21:49 +03:00
parent 0fd9390a99
commit 6adf4082dc
30 changed files with 180 additions and 107 deletions

View File

@@ -66,7 +66,7 @@ export const AutomergeEditor = {
let changed
for await (let op of operations) {
changed = Automerge.change(changed || doc, d =>
changed = Automerge.change<SyncDoc>(changed || doc, d =>
applyOperation(d.children, op)
)
}
@@ -143,7 +143,7 @@ export const AutomergeEditor = {
garbageCursor: (e: AutomergeEditor, docId: string) => {
const doc = e.docSet.getDoc(docId)
const changed = Automerge.change<SyncDoc>(doc, d => {
const changed = Automerge.change<SyncDoc>(doc, (d: any) => {
delete d.cusors
})

View File

@@ -38,17 +38,28 @@ const useCursor = (
if (Range.includes(cursor, path)) {
const { focus, anchor, isForward } = cursor
const isFocusNode = Path.equals(focus.path, path)
const isAnchorNode = Path.equals(anchor.path, path)
ranges.push({
...cursor,
isCaret: isForward
? Path.equals(focus.path, path)
: Path.equals(anchor.path, path),
anchor: Path.isBefore(anchor.path, path)
? { ...anchor, offset: 0 }
: anchor,
focus: Path.isAfter(focus.path, path)
? { ...focus, offset: node.text.length }
: focus
isCaret: isFocusNode,
anchor: {
path,
offset: isAnchorNode
? anchor.offset
: isForward
? 0
: node.text.length
},
focus: {
path,
offset: isFocusNode
? focus.offset
: isForward
? node.text.length
: 0
}
})
}
})

View File

@@ -31,6 +31,7 @@ const withAutomerge = <T extends Editor>(
if (e.connection) e.connection.close()
e.connection = AutomergeEditor.createConnection(e, (data: CollabAction) =>
//@ts-ignore
e.send(data)
)