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

@the-grid/ed

Package Overview
Dependencies
Maintainers
19
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.8.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by80%
Maintainers
19
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

  • test crucial parts
  • 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'),
    // REQUIRED -- Content array from post
    initialContent: [],
    menuTip: true,
    menuBar: false,
    // REQUIRED -- Hit on 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'
    },
    onShareFile: function (index) {
      /* App makes placeholder block(s) and calls ed.insertPlaceholders(index, count) */
      /* App uploads files and sets status on placeholder blocks with ed.setContent */
      /* On upload / measurement finishing, app replaces placeholder blocks with ed.setContent */
    },
    onShareUrl: function ({block, url}) {
      /* Ed made the placeholder with block id */
      /* App shares url with given block id */
      /* On share / measurement finishing, app replaces placeholder blocks with ed.setContent */
    },
    onPlaceholderCancel: function (id) {
      /* Ed removed the placeholder if you call ed.getContent() now */
      /* App should cancel the share or upload */
    }
  })
  
  // Returns array of inserted placeholder ids
  ed.insertPlaceholders(index, count)
  
  // Update placeholder metadata
  // {status (string), progress (number 0-100), failed (boolean)}
  ed.updatePlaceholder(id, metadata)

  // Returns content array
  // Expensive, so best to debounce and not call this on every change
  // Above the fold block is index 0, and starred
  ed.getContent()
  
  // Only inserts/updates placeholder blocks and converts placeholder blocks to media
  ed.setContent(contentArray)

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

styling

  1. Primary: Rebass defaults and rebass-theme for global overrides
  2. Secondary: inlined JS style objects (example)
  3. Deprecating: require('./component-name.css') style includes, but needed for some responsive hacks and ProseMirror overrides

code style

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

  • no unneeded semicolons
  • no trailing spaces
  • single quotes

To automatically fix easy stuff like trailing whitespace: npm run lintfix

test

npm test

Karma is set up to run tests in local Chrome and Firefox.

Tests will also run in mobile platforms via BrowserStack, if you have these environment variables set up:

BROWSERSTACK_USERNAME
BROWSERSTACK_ACCESSKEY

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 01 Apr 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