Coder Social home page Coder Social logo

aarongreenlee / pubpub-editor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pubpub/pubpub-editor

0.0 1.0 0.0 5.54 MB

A stand alone, extensible WSIWYG editor based on ProseMirror

License: GNU General Public License v2.0

JavaScript 97.00% CSS 3.00%

pubpub-editor's Introduction

PubPub Editor

A stand alone, extensible WSIWYG editor based on ProseMirror.

Usage

npm install @pubpub/editor
import Editor from '@pubpub/editor';

const component = (props)=> {
    return ( 
        <Editor
            /* customNodes: Object of custom nodes. To remove default node,
            override. For example, { image: null, header: null } */
            customNodes={{}}

            /* customMarks: Object of custom marks. To remove default mark,
            override. For example, { strong: null } */
            customMarks={{}}

            /* An object of custom plugins, with key=pluginName and
            value=function. All customPlugins values should be a function,
            which is passed schema and props - and returns a Plugin or
            array of Plugins */
            customPlugins={{}}

            /* An object with nodeName keys and values of objects of
            overriding options. For example:
            nodeOptions = { image: { linkToSrc: false } } */
            nodeOptions={{}}   

            /* An object with needed collaborative properties */   
            collaborativeOptions={{}}

            /* A function that will be called on every editor
            change (cursor and content). Passes up an editorChangeObject
            which is useful for building the interfaces around the editor.
            Also fired on editor initialization. */
            onChange={(changeObject)=>{}}

            /* A editor JSON document. */
            initialContent={{}}

            /* A string to show when the editor is empty. */
            placeholder=""

            /* A boolean that will prevent edits to the document when true. */
            isReadOnly={false}

            /* An array of highlights to be shown with the highlights plugin */
            highlights={[]}

            /* A function for finding highlight content when pasted. Used by
            the highlightQuote plugin */
            getHighlightContent={(from, to)=>{}}

            /* A function that will be called for every click within the
            editor */
            handleSingleClick={(view, pos, node, nodePos, event, direct)=>{}}

            /* A function that will be called for every double click within
            the editor */
            handleDoubleClick={(view, pos, node, nodePos, event, direct)=>{}}
        />
    );
}

onChange

{
    /* The current editor view. */
    view: {},

    /* The active selection. */
    selection: {},

    /* The bounding box for the active selection. */
    selectionBoundingBox: {},

    /* The text, prefix, and suffix of the current selection */
    selectedText: {},

    /* If the active selection is of a NodeView, provide the selected node. */
    selectedNode: {},

    /* If the active selection is of a NodeView, provide a function to update the selected node. */
    /* The updateNode function expects an object of attrs as its sole input */
    updateNode: (attrs)=>{},

    /* If the active selection is of a NodeView, provide a function to change the selected node. */
    changeNode: (nodeType, attrs, content)=>{},

    /* The full list of available node insert functions. */
    /* Each insert function expect an object of attrs as */
    /* its sole input. */
    insertFunctions: {},

    /* The full list of menu items, their status, and their click handler. */
    menuItems: [],

    /* The full list of decorations and their bounding boxes */
    decorations: [],

    /* The list of shortcut keys and the text following them. */
    /* Useful for inline insert menus and autocompletes. */
    shortcutValues: {},

    /* activeLink is useful for displaying a link editing interface. */
    activeLink: {},

    /* A boolean indicating whether the collaborative document has fully loaded. */
    /* Will remain false if the collaborative functionality is not used. */
    isCollabLoaded: false

}

Development

To Install and run Storybook

npm install
npm start

Menus

Menus for this editor are to be built by whatever external tool is wrapping the component. Menu buttons should use the following to prevent focus loss:

onMouseDown={(evt)=> {
    evt.preventDefault();
}}

pubpub-editor's People

Contributors

istravis avatar thariqs avatar hassanshaikley avatar gabestein avatar idreyn avatar

Watchers

James Cloos 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.