mirror of
https://github.com/cudr/slate-collaborative.git
synced 2026-03-02 03:40:18 +00:00
feat: update to slate 0.58 && fix site build
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user