npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

csdl-editor

v1.0.0

Published

DataSift CSDL Editor is a code editor for CSDL.

Downloads

12

Readme

DataSift CSDL Editor

DataSift CSDL Editor is a code editor for CSDL.

Quick start

Several quick start options are available:

  • Download the latest release.
  • Clone the repo: git clone https://github.com/datasift/csdl-editor.git.
  • Install with Bower: bower install csdl-editor.
  • Install with npm: npm install csdl-editor.

Usage/Setup

Include the following files on your page:

<link rel="stylesheet" href="[path_to_editor]/csdleditor.min.css">
<script type="text/javascript" src="[path_to_editor]/csdleditor.config.js"></script>
<script type="text/javascript" src="[path_to_editor]/csdleditor.min.js"></script>

Prepare a HTML element where the editor will be embedded:

<div id="csdleditor"></div>

And initialize the editor in JavaScript:

var editor = new CSDLEditor.Editor('#csdleditor', {});

This will return instance of the editor. The second argument is a list of options (see below).

You can also initialize the editor as a jQuery plugin:

$('#csdleditor').csdlEditor({});

This will return a jQuery object ($('#csdleditor')). The second argument is a list of options (see below).

Options

There are several options you can pass to the editor on its initialization. They should be passed as properties of an object literal.

var options = {
    value : '',                     // initial value of the editor (CSDL code)
    googleMapsApiKey: '',           // if you have a Google Maps API key it is advised to set it here for additional usage allowance

    // visual tweaks
    mapsOverlay : {                 // arguments for the overlay of Google Map
        strokeWeight : 0,
        fillColor : '#7585dd',
        fillOpacity : 0.5
    },
    mapsMarker : null,              // URL to the marker image used on maps if you want to specify your own

    // hooks/event handles
    save : function(code) {},       // event triggered on manual user save
    autosave : function(code) {},    // event triggered on auto save 
autofocus: false		// autofocus on initialization; defaults to false
};

Save/autosave

There are two hooks for save events that you can use. You can define them on initialization when passing options (see above).

save event is triggered when user manually clicks "Save" button (or presses ctrl/cmd+s) autosave event is triggered few miliseconds after user has applied latest change to the content of the editor

Both hooks take one argument code which is the current value/content inside the editor.

Corresponding DOM events are also triggered on the element on which the editor was initialized.

Public methods

When using the editor as a jQuery plugin you can call several public methods:

// assuming the editor was already initialized on $('#csdleditor'):
$('#csdleditor').csdlEditor('save'); // triggers save

var val = $('#csdleditor').csdlEditor('value'); // reads the value from the editor
$('#csdleditor').csdlEditor('value', 'interaction.content contains "datasift"'); // sets the value of the editor to what is passed as 2nd argument

$('#csdleditor').csdlEditor('showIndicator'); // shows loading indicator in the bottom bar
$('#csdleditor').csdlEditor('hideIndicator'); // hides the loading indicator in the bottom bar

$('#csdleditor').csdlEditor('fullscreen'); // maximizes the editor to full screen
$('#csdleditor').csdlEditor('maximize'); // maximizes the editor to full screen
$('#csdleditor').csdlEditor('minimize'); // minimizes the editor

$('#csdleditor').csdlEditor('undo'); // triggers an undo
$('#csdleditor').csdlEditor('redo'); // triggers a redo

Contributing

The editor uses Bundy to build minified version. Install it using NPM:

$ npm install bundy

And then run bundy.js:

$ node bundy.js

This will minify all JavaScript and CSS files and copy image files and place them inside minified/ directory.