Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@the-grid/ed

Package Overview
Dependencies
Maintainers
20
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@the-grid/ed

the grid api with prosemirror

  • 0.0.40
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by80%
Maintainers
20
Weekly downloads
 
Created
Source

npm start

ed

:warning: WIP; not in production yet. :warning: Build Status

Using ProseMirror with data from the Grid API

Demo: the-grid.github.io/ed/

The demo shows translating from ProseMirror to the the Grid API JSON and back.

purpose

ProseMirror provides a high-level schema-based interface for interacting with contenteditable, taking care of that pain. This project is focused on:

  • Schema to translate between the Grid API data and ProseMirror doc type
  • Coordinating widgets (block editors specialized by type) (example)

todo

  • API communication layer
  • iframe widgets
  • native widgets
  • handle image, video, article, quote types
    • edit attribution
  • Integrate into web app
  • Integrate into mobile apps
  • Read-only mode

use

  ed = new Ed({
    // Where ed will mount
    container: document.querySelector('#ed'),
    // Content array from post
    initialContent: [],
    menutip: true,
    menubar: false,
    // Every change
    onChange: function () {
      /* App can show "unsaved changes" in UI */
      /* Don't call ed.getContent() here */
    },
    // Optional imgflo image proxy config
    imgfloConfig: {
      server: 'https://imgflo.herokuapp.com/',
      key: 'key',
      secret: 'secret'
    },
    // Debounced changes
    autosaveInterval: 100,
    onAutosave: function () {
      /* App chooses when to call ed.getContent() and save to API */
    },
    onShareFile: function (index) {
      /* App splices placeholder block(s) and calls ed.setContent() */
    },
    onShareUrl: function (index, url) {
      /* App replaces text block with url and calls ed.setContent() */
    }
  })  
  • You can only call ed.setContent() with full content once (or as constructor initialContent option).
    • Future calls will only update placeholder blocks.
    • If you need to load new content in, you must make a new Ed.
  • ed.getContent() takes some processing and should not be done on every change.

Demo: ./demo/demo.js

dev

server

npm start and open http://localhost:8080/

In development mode, webpack builds and serves the targets in memory from /webpack/

Changes will trigger a browser refresh.

plugins

Plugins are ES2015 classes with 2 required methods:

  • constructor (ed) {} gets a reference to the main ed, where you can
    • listen to PM events: ed.pm.on('draw', ...)
    • and set up UI: ed.pluginContainer.appendChild(...)
  • teardown () {} where all listeners and UI should be removed

widgets

Widgets are mini-editors built to edit specific media types

iframe

Run in iframe and communicate via postMessage

Example: ced - widget for code editing

native

Example: WIP

code style

Feross standard checked by ESLint with npm test or npm run lint

  • no unneeded semicolons
  • no trailing spaces
  • single quotes

test

npm test

build

npm run build

Outputs minified dist/ed.js and copies widgets defined in package.json.

deploying

Travis will publish tags to npm and build the demo to publish to gh-pages.

FAQs

Package last updated on 13 Feb 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc