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

@naetverkjs/comments

v0.8.54

Published

This plugin allows the creation of inline and frame comments.

Downloads

19

Readme

comment-plugin

This plugin allows the creation of inline and frame comments.

  • Inline comment can be attached to a target node.
  • Frame comments allow grouping of nodes.

Installation

Import

import { CommentPlugin } from '@naetverkjs/comments';
editor.use(CommentPlugin);

Configuration

editor.use(CommentPlugin, {
  margin: number, // The Margin of the comments. Default: 30
  snapSize: number | undefined, // If defined, the comment will snap to the grid
  types: [
    { id: 1, name: 'First Category', class: 'first_category' }, // Frame Categories and added class when selected
    { id: 2, name: 'Second Category', class: 'second_category' }, 
  ],
  // Key Bindings:
  frameCommentKeys: {
    code: 'KeyF',
    shiftKey: true,
    ctrlKey: false,
    altKey: false,
  }, // Default: Shift+F
  inlineCommentKeys: {
    code: 'KeyC',
    shiftKey: true,
    ctrlKey: false,
    altKey: false,
  }, // Default: Shift+C
  deleteCommentKeys: {
    code: 'Delete',
    shiftKey: false,
    ctrlKey: false,
    altKey: false,
  }, // Delete
});

Use

// Creates a frame around the selected nodes with the text as title
editor.trigger('addcomment', {
  type: CommentType.FRAME,
  text: 'Frame Title',
  nodes: [],
});

// Creates a comment at a given position
editor.trigger('addcomment', {
  type: CommentType.INLINE,
  text: 'Comment Title',
  position,
});

// Removes a comment or all by type
editor.trigger('removecomment', { comment });
editor.trigger('removecomment', { type });

Styling

To display the comments, add the following scss to your component. You can also overwrite this if you want.

.inline-comment,
.frame-comment {
  font-family: 'Roboto', sans-serif;
  color: black;
  padding: 12px;
  font-size: 80%;
  position: absolute;
  cursor: move;
  border-radius: 3px;
  &:focus {
    z-index: -50;
    outline: none;
    border-color: #f1df97;
  }
}
.inline-comment {
  z-index: 4;
  background: #e7edff;
  border: 2px dashed #aec4ff;
  &.connected {
    border: 2px solid #7489c5;
  }
}
.frame-comment {
  z-index: -1;
  background: rgba(15, 80, 255, 0.2);
  border: 2px solid transparent;
}

.handle {
  width: 10px;
  height: 10px;
  background: #ff0000;
  position: absolute;
  right: 0;
  bottom: 0;
  cursor: se-resize;
}

/* If you use comment types you can define overwrite styles for the frames. For
example when you use     { id: 2, name: 'Second Category', class: 'second_category' }, 
you can add .second_category{} */

Working with other plugins

Auto-Arrange Plugin

If you use the auto-arrange plugin you need to trigger the syncframes call as well - so that the comment position updates.

// Trigger the arrange call
editor.arrange();
// Also sync the comments
editor.trigger('syncframes');

Area Plugin

The Area Plugin adds a background layer. If you have the z-index of your comments to low - they will not be selectable anymore.

Snap: If you have the snap option enabled, the position of the comments are not bind to this value. You have to use the snapSize option of the comment plugin with the same value.