🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@yfs/react

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yfs/react

Synchronize text files between the browser and the file system

0.1.0
latest
Source
npm
Version published
Weekly downloads
44
1000%
Maintainers
1
Weekly downloads
 
Created
Source

YFS

Synchronize text files between the browser and the file system using the File System Access API and Yjs.

Installation

To get started, install the @yfs/react package via npm or yarn:

# npm
npm install @yfs/react

# Yarn
yarn add @yfs/react

Usage

Example:

import React, { useState } from 'react'
import * as Y from 'yjs'
import useYFS from '@yfs/react'

function Editor () {
  const { setRootDirectory, directoryName, syncDoc } = useYFS()
  const [doc] = useState<Y.Doc>(new Y.Doc())

  return (
    <div>
      <button
        onClick={() => {
          if (!directoryName) {
            setRootDirectory(true)
          } else {
            syncDoc('my-file.md', doc)
          }
        }}
      >
        Sync
      </button>
      {/* Editor code... */}
    </div>
  )
}

Authors

This library is created by the team behind Motif (@motifland).

  • Michael Fester (@michaelfester)

It is based on the great work by Kevin Jahns on Yjs.

License

MIT

FAQs

Package last updated on 03 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts