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

@@ -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"
}

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)
)