Giter Site home page Giter Site logo

foxsir / editor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from letterpad/editor

0.0 1.0 0.0 2.07 MB

The letterpad editor - A high level abstraction of the slate editor with plugin architecture

Home Page: https://letterpad-editor.netlify.com/

License: MIT License

HTML 5.59% JavaScript 12.99% TypeScript 78.60% Shell 2.82%

editor's Introduction

Letterpad Editor

This editor is an extract from the Letterpad CMS.

Build Status

This editor gives a high level api of the slate editor along with a flexible plugin architecture.

How to use

// using yarn
yarn add letterpad-editor

//using npm
npm install letterpad-editor

Now you can use this in your react project

import React from "react";
import LetterpadEditor from "letterpad-editor";

const MyEditor = () => {
  return (
    <LetterpadEditor
      theme="dark"
      spellCheck={false}
      defaultFont={true}
      onChange={(html: string) => {
        console.log(html);
      }}
      html="Hello World"
    />
  );
};

export default MyEditor;
Props Description
defaultValue Markdown content
placeholder Override the default text. (default: "Write something nice")
readOnly Setting this to true will not allow the user to edit
autoFocus Focus the document automatically on load
spellCheck Allow spellchecking. (default: true)
plugins Allow additional plugins matching SlateJS API
schema Allow additional schema to be passed to Slate Editor
dark Set this to true to use the dark theme. (default: light)
style You can pass css string to override the defaults. eg. "body {font-size: 18px}"
Look for base.css to see the default css

Callback options

Props Description
uploadImage This function is called a user uploads an image.
<Editor 
uploadImage={async file => {
const result = await upload(file);
}
/>
onSave(done: boolean) This is called when the user uses shortcut keys (Ctrl+S or Cmd+S) to save the document. (Ctrl+Enter or Cmd+Enter) is to save and exist and sets done to true.
onChange(() => value) This is called when the content is edited. Remember that callback is a function and when its called, it serializes the JSON value to markdown
onClickLink(href) This callback can be used to override link handling. You may want to open external link in new tab and internal link in the same tab.
getLinkComponent(Node) The editor automatically detects a wide variety of links (youtube, soundcloud, vimeo, gist, figma, etc). However, you may override this by returning a component

Development

git clone [email protected]:letterpad/editor.git
cd editor
yarn install
yarn dev

Tests

Most part is covered with integration tests using Cypress.

# Run all tests locally
yarn bundle # build the bundle
yarn testServer
yarn cy:run # validate the bundle

editor's People

Contributors

abhisaha1 avatar boopathi avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.