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

@react-fluent-edit/core

Package Overview
Dependencies
Maintainers
1
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-fluent-edit/core

Slate based editor powered by plugins

1.0.2-fix-mention-editor.0
Source
npm
Version published
Weekly downloads
84
300%
Maintainers
1
Weekly downloads
 
Created
Source

@react-fluent-edit/core

This package includes the core editor component and tools to create plugins.

Installation

Install the package in your project directory with:

// with npm
npm install @react-fluent-edit/core

// with yarn
yarn add @react-fluent-edit/core

API

FluentEdit

import {
  FluentEdit,
  FluentEditProps,
  FluentEditProvider,
} from "@react-fluent-edit/core";

return (
  <FluentEdit 
    singleLine={false}
    markdown={true}
    autoFocus={true}
    placeholder=""
    initialValue=""
    onChange={value => console.log(value)}
    plugins={[...]}
  />
);

Plugin

import { Plugin } from "@react-fluent-edit"

const plugin: Plugin = {
  name: "mentions",
  leaves: [
    { 
      match: ({ leaf }) => ["bold", "italic", "underline"]
        .some(prop => leaf[prop]), 
      component: Leaf,
    }
  ],
  elements: [
    { 
      match: ({ element: { type } }) => ["list", "heading"]
        .some(item => type === item), 
      component: Element,
    }
  ],
  overrides: [{ handler: (editor) => withRichText(editor) }],
  beforeSerialize: {
    handler: (nodes) => replaceTextNodesWithRichTextNodes(nodes),
  },
  afterDeserialize: {
    handler: (nodes) => replaceRichTextNodesWithTextNodes(nodes),
  },
  handlers: {
    onClick: (event, editor) => { ... }
  }
  options,
}

useFluentEdit hook

import { useFluentEdit } from "@react-fluent-edit"

const { editor, focusEditor } = useFluentEdit()

FAQs

Package last updated on 15 Aug 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