Giter VIP home page Giter VIP logo

nib's Introduction

NIB

Despite various options available for rich text editing in html, it continues to be extremely challenging area. I found prosemirror to be the best available solution for the problem. It is great work by author Marijn Haverbeke.

Making an editor ground up from a framework is still much work, the project aims at building components for rich text editing using prosemirror. These components can be quickly integrated into react or even non-react applications.

Nib not only has good rich text editing capabilities but also addresses complex editing requirements like tracking changes made to a document, adding comments in document, collaborative editing and more...

Editor image

Setup

Setup of the editor is quite straight forward. It is required to be installed from npm.

Installing packages:

Either npm or yarn commands can be used.

npm i nib-core --save

Writing editor component:

import React from "react";
import Editor from "nib-core";

const MyEditor = () => <Editor />;

Please note that the lib does not work server side.

Props

Props supported by the editor.

S.No. Name Description
1 addons array of plugins for adding functionality to core editor
2 autoFocus to focus editor by default
3 config configuring the plugin, toolbar etc in editor, here are default configurations
4 defaultValue value to initialize editor content
5 licenseKey license key for nib editor
6 onChange callback which is called on any change in the editor
7 spellCheck boolean property to enable default browser spellCheck in the editor
8 styleConfig used to do more detailed style changes in the editor, here is the default
9 theme theming of the editor, here is default theme

Features

  1. Support for almost all browsers and devices
  2. Multiple rich text styling options like bold, italic, underline, strike, subscript, superscript, text color, filll color, etc
  3. Support for different block types paragraph, h1 - h6, blockquote etc
  4. Support for hyperlinks
  5. Support for nested ordered and unordered lists
  6. Support for images with options like wrapping, aligning, re-sizing or linking images
  7. Support for inline mode with floating toolbar
  8. Support for customized display - full page, word like display, etc
  9. Allow undo and redo changes.
  10. Help menu that display supported formatting options and their keyboard shortcuts
  11. Changing look and feel of editor using different themes
  12. Convert prosemirror JSON to and from markdown
  13. Convert prosemirror JSON to and from HTML
  14. Source code editing
  15. Table with advance options like add/remove column/row, resize columns, etc
  16. Support for displaying video from sources like Youtube or Vimeo
  17. Flexibility to add custom plugin
  18. Track changes make of document along with any metadata saved about the change like username, timestamp, etc
  19. Adding / editing comments to document
  20. Collaborative editing with multiple users on same document

License

GNU GENERAL PUBLIC LICENSE.

Contact

For details or queries drop mail to [email protected].

nib's People

Contributors

4e1e0603 avatar dependabot[bot] avatar dzpt avatar haibuists avatar jpuri avatar pebutler3 avatar rwaldron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nib's Issues

WAI ARIA Compliance

To comply with WIA-ARIA rules I plan to implement following:

  1. All clickable sections should be focuseable.
  2. Add following role attribute to tag as applicable:
    1. button - An input that allows for user-triggered actions when clicked or pressed.
    aria-disabled, aria-label, aria-haspopup
    2. cell - A cell in a tabular container.
    3. columnheader - A cell containing header information for a column.
    3. dialog - A dialog is a descendant window of the primary window of a web application. For HTML pages, the primary application window is the entire web document, i.e., the body element.
    aria-label, Authors SHOULD focus an element in the modal dialog when it is displayed, and authors SHOULD manage focus of modal dialogs., aria-modal
    4. heading - A heading for a section of the page.
    aria-level
    5. img - A container for a collection of elements that form an image.
    aria-label
    6. textbox - A generic type of widget that allows user input.
    aria-placeholder, aria-required, aria-label, aria-labelledby, aria-disabled,
    7. link - An interactive reference to an internal or external resource that, when activated, causes the user agent to navigate to that resource.
    aria-disabled, aria-label
    8. list - A section containing listitem elements. See related listbox.
    9. listitem - A single item in a list or directory.
    10. option - A selectable item in a select list.
    11. grid - A composite widget containing a collection of one or more rows with one or more cells where some or all cells in the grid are focusable by using methods of two-dimensional navigation, such as directional arrow keys.
    aria-label
    12. listbox - A widget that allows the user to select one or more items from a list of choices.
    13. row - A row of cells in a tabular container.
    14. rowheader - A cell containing header information for a row in a grid.
    15. separator - A divider that separates and distinguishes sections of content or groups of menuitems.
    16. table - A section containing data arranged in rows and columns.
    18. toolbar - A collection of commonly used function buttons or controls represented in compact visual form.
    Authors MUST supply a label on each toolbar when the application contains more than one toolbar.
    19. tooltip - A contextual popup that displays a description for an element.
    Authors SHOULD ensure that elements with the role tooltip are referenced through the use of aria-describedby before or at the time the tooltip is displayed.

aria-readonly, aria-required, aria-label, aria-labelledby, aria-disabled, aria-hidden, aria-keyshortcuts

  1. Menu items should all be focuseable.

Ref: https://www.w3.org/TR/wai-aria-1.1/#introduction

"hardBreak" is producing broken html

I wrote a visitor that replaces these nodes:

{ type: "paragraph" }

With:

{ type: "hardBreak" }

(because I need to preserve newlines)

But this is what convertToHTML produces: <brundefined></br>

Adding options make module crash "inline block link list image history"

<Editor config={{ plugins: { options: "inline block link list image history", image: { uploadCallback } }, toolbar: { options: "top", top: { block: { grouped }, options: "inline block link list image history" /* link */ } } }} onChange={this.handleChange2} defaultValue={defaultValue} styleConfig={{ editor: () => ({ height: "400px" }) }} />

image

How to integrate with Formik?

Hi,

I'm trying to integrate your great editor with Formik in React.

My code:

import React, { useState } from 'react';
import { Input, Textarea, ErrrorMessage } from '../forms/Input';
import { Formik, Form } from 'formik';
import { ButtonFullWidth } from '../forms/Button';
import { Spinner } from '../common/Icons';
import Editor from "nib-core";


interface IProps {
	value: string;
	cardContentAction?: any;
}

const ComplexityEdit: React.FC<IProps> = ({ value, cardContentAction }) => {
	const [data, setData] = useState({ analysing: null });

	let onSubmit = (values) => {
		cardContentAction(values['complexity'])
	};

	const initialValue = {
		complexity: value,
	};
	const MyEditor = () => <Editor />;

	return (
		<div>
			<Formik
				onSubmit={onSubmit}
				initialValues={initialValue}
				render={({ errors, status, touched, isSubmitting}) => (
					<Form>
						<Input name='complexity' component={MyEditor} />
						<ButtonFullWidth type='submit'>Opslaan {isSubmitting && <Spinner />}</ButtonFullWidth>
					</Form>
				)}
			/>
		</div>
	);
};

export default ComplexityEdit;

This is a functional component that gets it's data from value and sends it back via cardContentAction. It works fine with an input or textarea but I can't figure out how to use initialValues or send the data back when I press submit.

Input is just a simple styled-component Field from Formik

Number of line breaks is growing

Somehow this:

<p ><br></p><p >

Turns into this:

<p ><br ><br></br></p><p >

By doing something as simple as focusing away from the editor and back.

Rick

Please add support to class names

Having default classes and allowing us to config the class names will be great as it provides more customization towards styling.

Image uploading doesn't work

Image uploading doesn't appear to work on Windows OS in Chrome Browser, and on iOS in Safari Browser. I tried using the example from the docs website.

Layout fixes in the editor

[] overflow should scroll properly
[] it should be possible to set height and default height should also work well

Issue with select all

Steps:

  1. create only an ordered list in editor
  2. select-a
  3. change list type to un-ordered

It does not works.

Demo not working?

Please find the attached screenshot, geting 'Applying a mismatched transaction' error!

Screenshot 2019-09-09 at 8 45 45 PM

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.