Giter Site home page Giter Site logo

bearhunter49 / remirror Goto Github PK

View Code? Open in Web Editor NEW

This project forked from remirror/remirror

0.0 0.0 0.0 50.81 MB

ProseMirror toolkit for React 馃帀

Home Page: https://remirror.io

License: MIT License

JavaScript 0.75% TypeScript 95.46% CSS 3.79% HTML 0.01%

remirror's Introduction

animated remirror logo

A toolkit for building cross-platform text editors
in the framework of your choice.


MotivationStatusDocumentationStorybookContributing


Bundled sized of core [getJSON]brary Continuous integration badge for automatic releases Continuous integration badge for docs deployment Project maintainability provided by CodeClimate Unit test coverage for the codebase Discord


Introduction

import React from 'react';
import { BoldExtension, ItalicExtension, UnderlineExtension } from 'remirror/extensions';
import { Remirror, useRemirror } from '@remirror/react';

const extensions = () => [new BoldExtension(), new ItalicExtension(), new UnderlineExtension()];

const Editor = () => {
  const { manager, onChange, state } = useRemirror({
    extensions,
    content: '<p>Hi <strong>Friend</strong></p>',
    stringHandler: 'html',
    selection: 'end',
  });

  return <Remirror onChange={onChange} manager={manager} initialContent={state} />;
};

With this code snippet your editor now supports basic editing functionality.


Installation

yarn add remirror @remirror/react @remirror/pm # Yarn

npm add remirror @remirror/react @remirror/pm # npm

pnpm add remirror @remirror/react @remirror/pm # pnpm

If you run into any issues we recommend any of the following:

  • Open an issue in our github repo.
  • Join our discord server and discuss the problem with our community.
  • Create a pull request with your proposed improvement by clicking the edit button on the relevant page.

Whatever you decide thanks for taking the time to explore the remirror project.


Documentation

View our documentation website here.


Features

  • A11y focused and ARIA compatible.
  • I18n support via lingui.
  • Collaborative editing with yjs.
  • 30+ extensions for creating fully customized editing experiences.
  • Zero configuration support for Server Side Rendering (SSR).
  • Cross platform and cross-framework, with an Angular solution coming later this year.

Prerequisites


Getting Started

To add an editor to your codebase, first install the required dependencies.

# yarn
yarn add remirror @remirror/react @remirror/pm

# pnpm
pnpm add remirror @remirror/react @remirror/pm

# npm
npm install remirror @remirror/react @remirror/pm

Usage

Once installed you will be able to add the following code which creates an editor with the bold extension active. Clicking the button when text is selected will toggle between bold.

import React, { useCallback } from 'react';
import { BoldExtension } from 'remirror/extensions';
import {
  EditorComponent,
  Remirror,
  useActive,
  useCommands,
  useHelpers,
  useKeymap,
  useRemirror,
} from '@remirror/react';

const Button = () => {
  // Determines whether "bold" is active within the current text selection
  const { bold } = useActive();
  // Provides the ability to toggle bold on or off for the current selection
  const { toggleBold } = useCommands();

  return (
    <button
      onClick={() => toggleBold()}
      disabled={toggleBold.enabled()}
      style={{ fontWeight: bold() ? 'bold' : undefined }}
    >
      Bold
    </button>
  );
};

// Hooks can be added to the context without the need for creating custom components
const hooks = [
  () => {
    const { getJSON } = useHelpers();

    const onSave = useCallback(
      (props) => {
        const { state } = props;
        saveToBackend(getJSON(state));

        return true; // Prevents any further key handlers from being run.
      },
      [getJSON],
    );

    // "Mod" means platform agnostic modifier key - i.e. Ctrl on Windows, or Cmd on MacOS
    useKeymap('Mod-s', onSave);
  },
];

const Editor = () => {
  const { manager, state } = useRemirror({ extensions: () => [new BoldExtension()] });

  // The editor is built up like lego blocks of functionality within the editor
  // provider.
  return (
    <Remirror manager={manager} initialContent={state} hooks={hooks}>
      <Button />
      <EditorComponent />
    </Remirror>
  );
};

Contributing

Please read our contribution guide for details on our code of conduct, and the process for submitting pull requests. It also outlines the project structure so you can find help when navigating your way around the codebase.

In addition each folder in this codebase includes a readme describing why it exists.

You might also notice there are surprisingly few files in the root directory of this project. All the configuration files have been moved to the support/root directory and are symlinked to the root directory in a preinstall hook. For more information take a look at folder and readme.

Finally you can keep track on what's being worked on via the projects.


Versioning

This project uses SemVer for versioning. For the versions available, see the tags on this repository.


License

This project is licensed under the MIT License - see the LICENSE file for details

remirror's People

Contributors

ifiokjr avatar ocavue avatar benjie avatar ronnyroeller avatar github-actions[bot] avatar remirror-bot avatar whawker avatar renovate[bot] avatar ankon avatar allcontributors[bot] avatar aarongreenlee avatar hcharley avatar renovate-bot avatar gaaaga avatar tomas-c avatar georgemandis avatar tao-yi avatar stevebuik avatar stefkors avatar hennessyevan avatar cmanou avatar bertg avatar thezjy avatar lanyusan avatar domq avatar bart-kneepkens avatar zofiag avatar zhaoyao91 avatar splitinfinities avatar tommoor 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.