An open API service indexing awesome lists of open source software.

https://github.com/qq15725/vue-crdt

CRDT in Vue.js
https://github.com/qq15725/vue-crdt

crdt vue yjs

Last synced: about 1 year ago
JSON representation

CRDT in Vue.js

Awesome Lists containing this project

README

          

Vue CRDT



Minzip


Version


Downloads


Issues


License

## 📦 Install

```shell
npm i vue-crdt

// peerDependencies
npm i yjs
```

## 🦄 Usage

```ts
import { reactive, ref } from 'vue'
import { defineStore, useHistory } from 'vue-crdt'

const useEditorStore = defineStore(doc => {
// use y-webrtc
//
// new WebrtcProvider(
// 'your-room-name',
// doc,
// { password: 'optional-room-password' },
// )

return {
workspace: reactive({
pages: { a: 'b' },
activePage: null,
}),
width: ref(800),
height: ref(600),
}
})

const { workspace, width, height } = useEditorStore()

const history = useHistory(workspace)

workspace.activePage = 123
history.stopCapturing()
workspace.activePage = 456
history.undo()

console.log(workspace)
```