Compare commits

...

21 Commits

Author SHA1 Message Date
curd
f65ab040ee feat: update changelog 2021-01-18 19:59:42 +03:00
curd
3b60f2c6c8 v0.7.2 2021-01-18 19:57:58 +03:00
George
a67986995d
fix dependency update (#50)
* Always call external onChange.

* Fix split_node missing properties bug.

* fix: dependency update build

Co-authored-by: Ulion <ulion2002@gmail.com>
2021-01-18 19:56:00 +03:00
Ulion
1a536f2fa4
Fix split_node missing properties bug. (#45) 2021-01-18 19:49:34 +03:00
Ulion
322b083f68
Always call external onChange. (#43) 2021-01-18 19:48:02 +03:00
Ulion
ef35812723
Fix setNodes undefined value since automerge does not handle undefined value correctly. (#49) 2021-01-15 16:22:28 +03:00
Ulion
d141da4430
Fix destory (#48)
* Fix destory

* In case disconnect when the doc is not loaded
2021-01-15 16:13:12 +03:00
Ulion
24dca9a49c
Fix cursor delete (#44) 2021-01-15 16:10:29 +03:00
dependabot-preview[bot]
e415684d64
build(deps): bump react from 16.14.0 to 17.0.1 (#40)
Bumps [react](https://github.com/facebook/react/tree/HEAD/packages/react) from 16.14.0 to 17.0.1.
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/v17.0.1/packages/react)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: George <codefaster@yandex.ru>
2021-01-15 16:09:45 +03:00
dependabot-preview[bot]
2bd7544977
build(deps-dev): bump husky from 3.1.0 to 4.3.6 (#46)
Bumps [husky](https://github.com/typicode/husky) from 3.1.0 to 4.3.6.
- [Release notes](https://github.com/typicode/husky/releases)
- [Commits](https://github.com/typicode/husky/compare/v3.1.0...v4.3.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-01-15 16:05:16 +03:00
dependabot-preview[bot]
67218fc8ee
build(deps): bump @types/node from 12.7.5 to 14.14.6 (#42)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 12.7.5 to 14.14.6.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-01-15 16:05:04 +03:00
dependabot-preview[bot]
e3068d0b48
build(deps-dev): bump ts-jest from 25.5.1 to 26.4.4 (#41)
Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 25.5.1 to 26.4.4.
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kulshekhar/ts-jest/compare/v25.5.1...v26.4.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-01-15 16:04:52 +03:00
dependabot-preview[bot]
1106bc1724
build(deps): bump react-dom from 16.14.0 to 17.0.1 (#39)
Bumps [react-dom](https://github.com/facebook/react/tree/HEAD/packages/react-dom) from 16.14.0 to 17.0.1.
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/v17.0.1/packages/react-dom)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-01-15 16:03:24 +03:00
dependabot-preview[bot]
829dc2a71b
build(deps-dev): bump @commitlint/cli from 9.1.2 to 11.0.0 (#38)
Bumps [@commitlint/cli](https://github.com/conventional-changelog/commitlint) from 9.1.2 to 11.0.0.
- [Release notes](https://github.com/conventional-changelog/commitlint/releases)
- [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/conventional-changelog/commitlint/compare/v9.1.2...v11.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-01-15 16:03:12 +03:00
dependabot-preview[bot]
d1d3939c6a
build(deps): bump slate-react from 0.58.3 to 0.59.0 (#37)
Bumps [slate-react](https://github.com/ianstormtaylor/slate) from 0.58.3 to 0.59.0.
- [Release notes](https://github.com/ianstormtaylor/slate/releases)
- [Changelog](https://github.com/ianstormtaylor/slate/blob/master/Changelog.md)
- [Commits](https://github.com/ianstormtaylor/slate/compare/v0.58.3...v0.59.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-01-15 16:03:01 +03:00
dependabot-preview[bot]
ba61211cf6
build(deps): bump slate from 0.58.3 to 0.59.0 (#36)
Bumps [slate](https://github.com/ianstormtaylor/slate) from 0.58.3 to 0.59.0.
- [Release notes](https://github.com/ianstormtaylor/slate/releases)
- [Changelog](https://github.com/ianstormtaylor/slate/blob/master/Changelog.md)
- [Commits](https://github.com/ianstormtaylor/slate/compare/v0.58.3...v0.59.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-01-15 16:02:50 +03:00
dependabot-preview[bot]
230117694e
build(deps): bump faker from 4.1.0 to 5.1.0 (#35)
Bumps [faker](https://github.com/Marak/Faker.js) from 4.1.0 to 5.1.0.
- [Release notes](https://github.com/Marak/Faker.js/releases)
- [Changelog](https://github.com/Marak/faker.js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Marak/Faker.js/compare/v4.1.0...v5.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-01-15 16:02:28 +03:00
dependabot-preview[bot]
b68f5afcf9
build(deps): bump nodemon from 1.19.4 to 2.0.6 (#34)
Bumps [nodemon](https://github.com/remy/nodemon) from 1.19.4 to 2.0.6.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v1.19.4...v2.0.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-01-15 16:02:17 +03:00
George
cc4449e6dd Update issue templates 2020-11-04 22:52:39 +03:00
curd
71ab42d5be feat: nodemon run example 2020-10-30 14:36:42 +03:00
curd
05e46faf4f v0.7.1 2020-10-28 08:43:53 +03:00
17 changed files with 200 additions and 79 deletions

33
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,33 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Device (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version of slate [e.g. 0.58.0]
- Version of slate-collaborative
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here.

View File

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@ -2,9 +2,39 @@
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
#### [v0.7.2](https://github.com/cudr/slate-collaborative/compare/v0.7.1...v0.7.2)
> 18 January 2021
- fix dependency update [`#50`](https://github.com/cudr/slate-collaborative/pull/50)
- Fix split_node missing properties bug. [`#45`](https://github.com/cudr/slate-collaborative/pull/45)
- Always call external onChange. [`#43`](https://github.com/cudr/slate-collaborative/pull/43)
- Fix setNodes undefined value since automerge does not handle undefined value correctly. [`#49`](https://github.com/cudr/slate-collaborative/pull/49)
- Fix destory [`#48`](https://github.com/cudr/slate-collaborative/pull/48)
- Fix cursor delete [`#44`](https://github.com/cudr/slate-collaborative/pull/44)
- build(deps): bump react from 16.14.0 to 17.0.1 [`#40`](https://github.com/cudr/slate-collaborative/pull/40)
- build(deps-dev): bump husky from 3.1.0 to 4.3.6 [`#46`](https://github.com/cudr/slate-collaborative/pull/46)
- build(deps): bump @types/node from 12.7.5 to 14.14.6 [`#42`](https://github.com/cudr/slate-collaborative/pull/42)
- build(deps-dev): bump ts-jest from 25.5.1 to 26.4.4 [`#41`](https://github.com/cudr/slate-collaborative/pull/41)
- build(deps): bump react-dom from 16.14.0 to 17.0.1 [`#39`](https://github.com/cudr/slate-collaborative/pull/39)
- build(deps-dev): bump @commitlint/cli from 9.1.2 to 11.0.0 [`#38`](https://github.com/cudr/slate-collaborative/pull/38)
- build(deps): bump slate-react from 0.58.3 to 0.59.0 [`#37`](https://github.com/cudr/slate-collaborative/pull/37)
- build(deps): bump slate from 0.58.3 to 0.59.0 [`#36`](https://github.com/cudr/slate-collaborative/pull/36)
- build(deps): bump faker from 4.1.0 to 5.1.0 [`#35`](https://github.com/cudr/slate-collaborative/pull/35)
- build(deps): bump nodemon from 1.19.4 to 2.0.6 [`#34`](https://github.com/cudr/slate-collaborative/pull/34)
- Update issue templates [`cc4449e`](https://github.com/cudr/slate-collaborative/commit/cc4449e6dd35fbf36675a5ac5a7bac61222dad06)
- feat: nodemon run example [`71ab42d`](https://github.com/cudr/slate-collaborative/commit/71ab42d5bec04b89819f51a85659a93587f1af67)
#### [v0.7.1](https://github.com/cudr/slate-collaborative/compare/v0.7.0...v0.7.1)
> 28 October 2020
- defensive code for when the document sometimes isn't there on server restarts. [`#26`](https://github.com/cudr/slate-collaborative/pull/26)
- fix: socket io namespace message broadcast [`ab3c36a`](https://github.com/cudr/slate-collaborative/commit/ab3c36ab7dd7f24059c5d0864735c5892df98028)
#### [v0.7.0](https://github.com/cudr/slate-collaborative/compare/v0.6.7...v0.7.0) #### [v0.7.0](https://github.com/cudr/slate-collaborative/compare/v0.6.7...v0.7.0)
> 1 July 2020 > 2 July 2020
- Preserve external history option [`#22`](https://github.com/cudr/slate-collaborative/pull/22) - Preserve external history option [`#22`](https://github.com/cudr/slate-collaborative/pull/22)
- Generate auto-changelog [`#21`](https://github.com/cudr/slate-collaborative/pull/21) - Generate auto-changelog [`#21`](https://github.com/cudr/slate-collaborative/pull/21)

View File

@ -1,6 +1,6 @@
{ {
"lerna": "2.7.1", "lerna": "2.7.1",
"version": "0.7.0", "version": "0.7.2",
"npmClient": "yarn", "npmClient": "yarn",
"useWorkspaces": true "useWorkspaces": true
} }

View File

@ -1,11 +1,12 @@
{ {
"private": true, "private": true,
"version": "0.7.1",
"description": "Slate collaborative plugin & microservice", "description": "Slate collaborative plugin & microservice",
"scripts": { "scripts": {
"bootstrap": "lerna bootstrap", "bootstrap": "lerna bootstrap",
"version": "auto-changelog -p ./packages/bridge/package.json --template changelog-template.hbs && git add CHANGELOG.md", "changelog": "auto-changelog -p ./packages/bridge/package.json --template changelog-template.hbs && git add CHANGELOG.md",
"clean": "rimraf ./packages/**/lib/ && rimraf ./packages/**/tsconfig.tsbuildinfo && lerna clean --yes", "clean": "rimraf ./packages/**/lib/ && rimraf ./packages/**/tsconfig.tsbuildinfo && lerna clean --yes",
"release": "yarn prebuild && yarn build && lerna version && lerna publish from-package", "release": "yarn prebuild && yarn build && lerna version && lerna publish from-package && yarn changelog",
"deploy:site": "git subtree push --prefix packages/example heroku master", "deploy:site": "git subtree push --prefix packages/example heroku master",
"dev": "lerna run --stream build:js && concurrently \"yarn watch\" \"lerna run dev --stream\"", "dev": "lerna run --stream build:js && concurrently \"yarn watch\" \"lerna run dev --stream\"",
"build": "lerna run build:module --stream", "build": "lerna run build:module --stream",
@ -37,11 +38,11 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^9.0.1", "@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^9.0.1", "@commitlint/config-conventional": "^9.0.1",
"auto-changelog": "^2.1.0", "auto-changelog": "^2.1.0",
"concurrently": "^4.1.2", "concurrently": "^4.1.2",
"husky": "^3.0.5", "husky": "^4.3.6",
"lerna": "^3.20.2", "lerna": "^3.20.2",
"lint-staged": "^9.2.5", "lint-staged": "^9.2.5",
"prettier": "^1.18.2", "prettier": "^1.18.2",

View File

@ -1,6 +1,6 @@
{ {
"name": "@slate-collaborative/backend", "name": "@slate-collaborative/backend",
"version": "0.7.0", "version": "0.7.2",
"files": [ "files": [
"lib" "lib"
], ],
@ -26,12 +26,12 @@
"dependencies": { "dependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.9.0", "@babel/plugin-proposal-optional-chaining": "^7.9.0",
"@babel/runtime": "^7.6.3", "@babel/runtime": "^7.6.3",
"@slate-collaborative/bridge": "^0.7.0", "@slate-collaborative/bridge": "^0.7.2",
"@types/lodash": "^4.14.150", "@types/lodash": "^4.14.150",
"@types/socket.io": "^2.1.4", "@types/socket.io": "^2.1.4",
"automerge": "0.14.0", "automerge": "0.14.0",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"slate": "0.58.3", "slate": "0.59.0",
"socket.io": "^2.3.0", "socket.io": "^2.3.0",
"typescript": "^3.8.3" "typescript": "^3.8.3"
}, },

View File

@ -38,7 +38,7 @@ export default class SocketIOCollaboration {
*/ */
constructor(options: SocketIOCollaborationOptions) { constructor(options: SocketIOCollaborationOptions) {
this.io = io(options.entry, options.connectOpts) this.io = io(options.entry as Server, options.connectOpts)
this.backend = new AutomergeBackend() this.backend = new AutomergeBackend()

View File

@ -1,6 +1,6 @@
{ {
"name": "@slate-collaborative/bridge", "name": "@slate-collaborative/bridge",
"version": "0.7.0", "version": "0.7.2",
"files": [ "files": [
"lib" "lib"
], ],
@ -26,7 +26,7 @@
}, },
"dependencies": { "dependencies": {
"automerge": "0.14.0", "automerge": "0.14.0",
"slate": "0.58.3", "slate": "0.59.0",
"typescript": "^3.8.3" "typescript": "^3.8.3"
}, },
"devDependencies": { "devDependencies": {
@ -39,7 +39,7 @@
"@babel/preset-typescript": "^7.6.0", "@babel/preset-typescript": "^7.6.0",
"@types/jest": "^24.9.0", "@types/jest": "^24.9.0",
"jest": "^24.9.0", "jest": "^24.9.0",
"ts-jest": "^25.4.0" "ts-jest": "^26.4.4"
}, },
"directories": { "directories": {
"lib": "lib" "lib": "lib"

View File

@ -9,7 +9,12 @@ const setNode = (doc: SyncValue, op: SetNodeOperation): SyncValue => {
const { newProperties } = op const { newProperties } = op
for (let key in newProperties) { for (let key in newProperties) {
node[key] = newProperties[key] const value = newProperties[key]
if (value !== undefined) {
node[key] = value
} else {
delete node[key]
}
} }
return doc return doc

View File

@ -8,7 +8,10 @@ const splitNode = (doc: SyncValue, op: SplitNodeOperation): SyncValue => {
const [parent, index]: [any, number] = getParent(doc, op.path) const [parent, index]: [any, number] = getParent(doc, op.path)
const target = getChildren(parent)[index] const target = getChildren(parent)[index]
const inject = cloneNode(target) const inject = {
...cloneNode(target),
...op.properties
}
if (target.text) { if (target.text) {
target.text.length > op.position && target.text.length > op.position &&

View File

@ -5,24 +5,25 @@ import { toSlatePath, toJS } from '../utils'
import { getTarget } from '../path' import { getTarget } from '../path'
const removeTextOp = (op: Automerge.Diff) => (map: any, doc: Element) => { const removeTextOp = (op: Automerge.Diff) => (map: any, doc: Element) => {
try {
const { index, path, obj } = op const { index, path, obj } = op
const slatePath = toSlatePath(path).slice(0, path?.length) const slatePath = toSlatePath(path).slice(0, path?.length)
let node let node = map[obj]
try { try {
node = getTarget(doc, slatePath) || map[obj] node = getTarget(doc, slatePath)
} catch (e) { } catch (e) {
console.error(e, op, doc) console.error(e, slatePath, op, map, toJS(doc))
} }
if (typeof index !== 'number') return if (typeof index !== 'number') return
const text = node?.text[index] || '*' const text = node?.text?.[index] || '*'
if (node) { if (node) {
node.text = node.text?.slice(0, index) + node.text?.slice(index + 1) node.text = node?.text ? (node.text.slice(0, index) + node.text.slice(index + 1)) : ''
} }
return { return {
@ -32,26 +33,43 @@ const removeTextOp = (op: Automerge.Diff) => (map: any, doc: Element) => {
text, text,
marks: [] marks: []
} }
} catch (e) {
console.error(e, op, map, toJS(doc))
}
} }
const removeNodeOp = ({ index, obj, path }: Automerge.Diff) => ( const removeNodeOp = (op: Automerge.Diff) => (
map: any, map: any,
doc: Element doc: Element
) => { ) => {
try {
const { index, obj, path } = op
const slatePath = toSlatePath(path) const slatePath = toSlatePath(path)
const parent = getTarget(doc, slatePath) const parent = getTarget(doc, slatePath)
const target = parent?.children[index as number] || { children: [] } const target = parent?.children?.[index as number] || parent?.[index as number] || { children: [] }
if (!target) {
throw new TypeError('Target is not found!')
}
if (!map.hasOwnProperty(obj)) { if (!map.hasOwnProperty(obj)) {
map[obj] = target map[obj] = target
} }
if (!Number.isInteger(index)) {
throw new TypeError('Index is not a number')
}
return { return {
type: 'remove_node', type: 'remove_node',
path: slatePath.length ? slatePath.concat(index) : [index], path: slatePath.length ? slatePath.concat(index) : [index],
node: target node: target
} }
} catch (e) {
console.error(e, op, map, toJS(doc))
}
} }
const opRemove = (op: Automerge.Diff, [map, ops]: any) => { const opRemove = (op: Automerge.Diff, [map, ops]: any) => {
@ -61,7 +79,8 @@ const opRemove = (op: Automerge.Diff, [map, ops]: any) => {
if ( if (
map.hasOwnProperty(obj) && map.hasOwnProperty(obj) &&
typeof map[obj] !== 'string' && typeof map[obj] !== 'string' &&
type !== 'text' type !== 'text' &&
map?.obj?.length
) { ) {
map[obj].splice(index, 1) map[obj].splice(index, 1)
@ -72,7 +91,7 @@ const opRemove = (op: Automerge.Diff, [map, ops]: any) => {
const key = path[path.length - 1] const key = path[path.length - 1]
if (key === 'cursors') return [map, ops] if (key === 'cursors' || op.key === 'cursors') return [map, ops]
const fn = key === 'text' ? removeTextOp : removeNodeOp const fn = key === 'text' ? removeTextOp : removeNodeOp

View File

@ -10,10 +10,10 @@ const setDataOp = (
type: 'set_node', type: 'set_node',
path: toSlatePath(path), path: toSlatePath(path),
properties: { properties: {
[key]: Automerge.getObjectById(doc, obj)?.[key] [key]: toJS(Automerge.getObjectById(doc, obj)?.[key])
}, },
newProperties: { newProperties: {
[key]: value [key]: map?.[value] || value
} }
} }
} }
@ -22,7 +22,7 @@ const opSet = (op: Automerge.Diff, [map, ops]: any, doc: any) => {
const { link, value, path, obj, key } = op const { link, value, path, obj, key } = op
try { try {
if (path && path[0] !== 'cursors') { if (path && path.length && path[0] !== 'cursors') {
ops.push(setDataOp(op, doc)) ops.push(setDataOp(op, doc))
} else if (map[obj]) { } else if (map[obj]) {
map[obj][key as any] = link ? map[value] : value map[obj][key as any] = link ? map[value] : value

View File

@ -1,6 +1,6 @@
{ {
"name": "@slate-collaborative/client", "name": "@slate-collaborative/client",
"version": "0.7.0", "version": "0.7.2",
"files": [ "files": [
"lib" "lib"
], ],
@ -26,9 +26,9 @@
"dependencies": { "dependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.9.0", "@babel/plugin-proposal-optional-chaining": "^7.9.0",
"@babel/preset-react": "^7.0.0", "@babel/preset-react": "^7.0.0",
"@slate-collaborative/bridge": "^0.7.0", "@slate-collaborative/bridge": "^0.7.2",
"automerge": "0.14.0", "automerge": "0.14.0",
"slate": "0.58.3", "slate": "0.59.0",
"slate-history": "0.58.3", "slate-history": "0.58.3",
"socket.io-client": "^2.3.0", "socket.io-client": "^2.3.0",
"typescript": "^3.8.3" "typescript": "^3.8.3"

View File

@ -130,7 +130,9 @@ export const AutomergeEditor = {
Editor.withoutNormalizing(e, () => { Editor.withoutNormalizing(e, () => {
if (HistoryEditor.isHistoryEditor(e) && !preserveExternalHistory) { if (HistoryEditor.isHistoryEditor(e) && !preserveExternalHistory) {
HistoryEditor.withoutSaving(e, () => { HistoryEditor.withoutSaving(e, () => {
slateOps.forEach((o: Operation) => e.apply(o)) slateOps.forEach((o: Operation) => {
e.apply(o)
})
}) })
} else { } else {
slateOps.forEach((o: Operation) => e.apply(o)) slateOps.forEach((o: Operation) => e.apply(o))
@ -149,8 +151,12 @@ export const AutomergeEditor = {
garbageCursor: (e: AutomergeEditor, docId: string) => { garbageCursor: (e: AutomergeEditor, docId: string) => {
const doc = e.docSet.getDoc(docId) const doc = e.docSet.getDoc(docId)
if (!doc) {
return
}
const changed = Automerge.change<SyncDoc>(doc, (d: any) => { const changed = Automerge.change<SyncDoc>(doc, (d: any) => {
delete d.cusors delete d.cursors
}) })
e.onCursor && e.onCursor(null) e.onCursor && e.onCursor(null)

View File

@ -74,10 +74,10 @@ const withAutomerge = <T extends Editor>(
if (!e.isRemote) { if (!e.isRemote) {
AutomergeEditor.applySlateOps(e, docId, operations, cursorData) AutomergeEditor.applySlateOps(e, docId, operations, cursorData)
}
onChange() onChange()
} }
}
/** /**
* Receive document value * Receive document value

View File

@ -122,6 +122,8 @@ const withSocketIO = <T extends AutomergeEditor>(
*/ */
e.destroy = () => { e.destroy = () => {
e.socket.removeListener('disconnect')
e.socket.close() e.socket.close()
e.closeConnection() e.closeConnection()

View File

@ -1,36 +1,28 @@
{ {
"name": "@slate-collaborative/example", "name": "@slate-collaborative/example",
"version": "0.7.0", "version": "0.7.2",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@emotion/core": "^10.0.17", "@emotion/core": "^10.0.17",
"@emotion/styled": "^10.0.17", "@emotion/styled": "^10.0.17",
"@slate-collaborative/backend": "^0.7.0", "@slate-collaborative/backend": "^0.7.2",
"@slate-collaborative/client": "^0.7.0", "@slate-collaborative/client": "^0.7.2",
"@types/faker": "^4.1.5",
"@types/is-url": "^1.2.28",
"@types/jest": "24.0.18",
"@types/node": "12.7.5",
"@types/randomcolor": "^0.5.4",
"@types/react-dom": "^16.9.6",
"concurrently": "^4.1.2", "concurrently": "^4.1.2",
"cross-env": "^6.0.3", "cross-env": "^6.0.3",
"express": "^4.17.1", "express": "^4.17.1",
"faker": "^4.1.0",
"is-url": "^1.2.4", "is-url": "^1.2.4",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"nodemon": "^1.19.2", "nodemon": "^2.0.6",
"randomcolor": "^0.5.4", "randomcolor": "^0.5.4",
"react": "^16.9.0", "react": "^17.0.1",
"react-dom": "^16.9.0", "react-dom": "^17.0.1",
"react-scripts": "3.1.2", "react-scripts": "3.1.2",
"slate": "0.58.3", "slate": "0.59.0",
"slate-history": "0.58.3", "slate-history": "0.58.3",
"slate-react": "0.58.3", "slate-react": "0.59.0"
"typescript": "^3.8.3"
}, },
"scripts": { "scripts": {
"start": "node server.js", "start": "nodemon server.js",
"start:cra": "react-scripts start", "start:cra": "react-scripts start",
"prebuild": "cp -f ./tsconfig.production.json ./tsconfig.json", "prebuild": "cp -f ./tsconfig.production.json ./tsconfig.json",
"build": "cross-env NODE_ENV=production && react-scripts build", "build": "cross-env NODE_ENV=production && react-scripts build",
@ -54,5 +46,15 @@
}, },
"engines": { "engines": {
"node": "12.x" "node": "12.x"
},
"devDependencies": {
"@types/faker": "^4.1.5",
"@types/is-url": "^1.2.28",
"@types/jest": "24.0.18",
"@types/node": "14.14.6",
"@types/randomcolor": "^0.5.4",
"@types/react-dom": "^16.9.6",
"faker": "^5.1.0",
"typescript": "^3.8.3"
} }
} }