Giter Site home page Giter Site logo

funnelql-editor's Introduction

npm version

Funnel Query Language Editor

CodeMirror based WYSIWYG editor with lint (error reporting) for Funnel Query Language.

FunnelQL Editor

Online Editor

An online demo of the editor is available om https://funnelql.com/.

Installation

npm install funnelql-editor

Including the editor

The FunnelQL editor library can be included like any regular javascript file, is safe to include in concatenation and can be loaded asynchronously.

The editor consists of a mode and lint extension of CodeMirror with a custom WYSIWYG toolbar and application frame.

The editor provides a CodeMirror extension funnelql-editor.js and a combination package that includes CodeMirror funnelql-editor+codemirror.js.

When using the extension you need to manually load lib/codemirror.js and addon/lint/lint.js from the CodeMirror package that can be installed using NPM:

npm install codemirror

It is not required to install codemirror when using the combination package.

FunnelQL editor + codemirror combined

<link rel="stylesheet" href="css/funnelql-editor+codemirror.css" />
<script src="js/funnelql-editor+codemirror.js" async></script>

FunnelQL editor extension only

If CodeMirror is already present on a page you can include just the FunnelQL editor mode and lint extension.

<!-- Optional: from CodeMirror package -->
<link rel="stylesheet" href="node_modules/codemirror/lib/codemirror.css" />
<link rel="stylesheet" href="node_modules/codemirror/addon/lint/lint.css" />
<script src="node_modules/lib/codemirror.js"></script>
<script src="node_modules/addon/lint/lint.js"></script>

<!-- Required: FunnelQL editor extension -->
<link rel="stylesheet" href="css/funnelql-editor.css" />
<script src="js/funnelql-editor.js" async></script>

Setup

The editor can be installed on any <textarea>. The FunnelQL Javascript library should be loaded before a FunnelQL editor is instantiated.

<textarea type="text" id="funnelql_editor" style="width:100%;height:250px;"></textarea>

The editor can be loaded using the Javascript constructor FunnelQLEditor with as first parameter a string ID reference or HTML element of a <textarea> and optionally a second parameter with CodeMirror Options.

var fql_editor = FunnelQLEditor('funnelql_editor', {
    /* Optional: CodeMirror options */
});

To make sure that the FunnelQL library is loaded before the editor is instantiated, use the onload callback provided by the Javascript library:

$FQL.on('load')
  .then(function() {

	/* load editor */

  });

FunnelQL CodeMirror API extension

The FunnelQLEditor constructor returns a CodeMirror editor object enhanced with additional API methods.

Method Description
parse Parse the FunnelQL input and return the parsed JSON via a Promise.

For information about the CodeMirror API, see https://codemirror.net/doc/manual.html#api

funnelql-editor's People

Contributors

optimalisatie avatar

Watchers

 avatar  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.