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

@evergraph/turtle-editor

v1.1.6

Published

This is a work in progress towards a web component for editing turtle (RDF) documents easier than before. The evergraph prefix comes from my dream of breaking down the barriers between information - both data and logic - produced and consumed across the g

Downloads

44

Readme

Evergraph Turtle Editor

This is a work in progress towards a web component for editing turtle (RDF) documents easier than before. The evergraph prefix comes from my dream of breaking down the barriers between information - both data and logic - produced and consumed across the globe.

Try it out at https://evergraphme.github.io/turtle-editor/

Usage

Embedding

<html>
  <head>
    <title>Turtle Editor Example</title>
    <script type="text/javascript" src="https://evergraphme.github.io/turtle-editor/bundle.js"></script>
  </head>

  <body>
    <turtle-editor text="#contents"/>

    <script id="contents" type="text/turtle">
      @base <http://example.org/> .
      @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
      @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
      @prefix foaf: <http://xmlns.com/foaf/0.1/> .
      @prefix rel: <http://www.perceive.net/schemas/relationship/> .

      <#green-goblin>
        rel:enemyOf <#spiderman> ;
        a foaf:Person ;
        foaf:name 'Green Goblin' .

      <#spiderman>
        rel:enemyOf <#green-goblin> ;
        a foaf:Person ;
        foaf:name 'Spiderman', 'Человек-паук'@ru .
    </script>
  </body>
</html>

Inserting RDF

  1. <turtle-editor text="#selector"/>. Provide initial text in a script tag, fetched on intialization by retrieving the DOM element targeted by the selector (see example above).
  2. <turtle-editor text="<urn:subject> <urn:predicate> <urn:object> ."/>. Provide initial text inline as an attribute to the component.
  3. document.querySelector('turtle-editor').text('#selector'). Same as above but using javascript.
  4. document.querySelector('turtle-editor').dataset(dataset). Provide initial text via a RDF/JS dataset;

Retrieving RDF

  1. document.querySelector('turtle-editor').text() returns the text as seen in the editor.
  2. document.querySelector('turtle-editor').dataset() returns a RDF/JS dataset with all parsed quads in the document.

Subscribing to updates

The editor will post updates as soon as new quads are parsed (or removed). See example below on how to be notified. The event contains two properties, added and removed, each an array of added or removed quads.

    <script type="text/javascript">
      document.querySelector('turtle-editor').$on('change', (e) => {
        let output = '';
        for (let quad of e.detail.added) {
          output = output + `Added ${quad.subject.value} ${quad.predicate.value} ${quad.object.value} .\n`;
        }
        for (let quad of e.detail.removed) {
          output = output + `Removed ${quad.subject.value} ${quad.predicate.value} ${quad.object.value} .\n`;
        }
        console.log(output);
      })
    </script>

Styling

Example CSS

turtle-editor {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: auto;
}
turtle-editor::part(editor) {
  height:100%;
}

Direct access to text editor

The editor is currently built a top of the Ace text editor which can be accessed directly via document.querySelector('turtle-editor').editorElement.editor. This can be utilized to modify styling or access the text directly.

Input assistance

The editor will try to assist input to increase input speed, ensure validity and improve readability.

Indentation

The editor will indent as you type to follow the following indentation pattern. Extraneous whitespace will be ignored/removed.

subject
  predicate object ;
  predicate
    object,
    object .

Shortcuts

  • After an object, type enter to complete the statement (add .\n)
  • After an object, type space once to add another object (add ,\n )
  • After an object, type space twice to add another predicate (add ;\n )
  • Backspace after one of the above removes all the text and moves the cursor back to just after the object

Alternative editors for Turtle

  • https://perfectkb.github.io/yate/