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:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@slate-collaborative/client",
|
||||
"version": "0.5.0",
|
||||
"version": "0.6.0",
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
@@ -17,8 +17,8 @@
|
||||
"author": "cudr",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"prepublishOnly": "npm run build",
|
||||
"build": "npm run build:types && npm run build:js",
|
||||
"prepublishOnly": "npm run build:module",
|
||||
"build:module": "npm run build:types && npm run build:js",
|
||||
"build:types": "tsc --emitDeclarationOnly",
|
||||
"build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline",
|
||||
"watch": "yarn build:js -w"
|
||||
@@ -26,9 +26,9 @@
|
||||
"dependencies": {
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"@slate-collaborative/bridge": "^0.5.0",
|
||||
"automerge": "^0.14.0",
|
||||
"slate": "^0.57.2",
|
||||
"@slate-collaborative/bridge": "0.6.0",
|
||||
"automerge": "0.14.0",
|
||||
"slate": "0.58.0",
|
||||
"socket.io-client": "^2.3.0",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
@@ -44,5 +44,6 @@
|
||||
},
|
||||
"directories": {
|
||||
"lib": "lib"
|
||||
}
|
||||
},
|
||||
"gitHead": "1a29cf0da2dc171c1fadd5c8e6eac2327b5b0241"
|
||||
}
|
||||
|
||||
@@ -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