Skip to content

v0.0.11

Compare
Choose a tag to compare
@alexjg alexjg released this 24 Apr 13:50
· 1 commit to main since this release
04cc635
  • Setting up the plugin now just requires that you create an
    automergeSyncPlugin and pass it the handle and path. I.e. you go from
    this:

    const doc = handle.docSync()
    const source = doc.text // this should use path
    const plugin = amgPlugin(doc, path)
    const semaphore = new PatchSemaphore(plugin)
    const view = (editorRoot.current = new EditorView({
      doc: source,
      extensions: [basicSetup, plugin],
      dispatch(transaction) {
        view.update([transaction])
        semaphore.reconcile(handle, view)
      },
      parent: containerRef.current,
    }))
    
    const handleChange = ({ doc, patchInfo }) => {
      semaphore.reconcile(handle, view)
    }

    To this

    const view = new EditorView({
      doc: handle.docSync()!.text,
      extensions: [
        basicSetup,
        automergeSyncPlugin({
          handle,
          path: ["text"],
        }),
      ],
      parent: container,
    })