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

@raisins/core

v1.1.5

Published

Core functions for manipulating and validating HTML and raisin nodes

Downloads

1,202

Readme

Raisins Core

Raisins in a WYSIWYG visual editor for HTML and web components. The core package provides utility functions that are used to validate the HTML being edited and provide additional data, such as parent / child slot validation, locations for moving a node from one location to another, and more.

Available Functions

| Function | description | Returns | | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | | htmlSerializer | Renders a DOM node or an array of DOM nodes to a string | string | | htmlParser | Parses HTML into a RaisinDocumentNode | RaisinDocumentNode | | isNodeWithChildren | Determines whether the node has any children | boolean | | isElementNode | Determines if the given node is an HTML element | boolean | | isRoot | Determines if the given node is the root element | boolean | | isStyleNode | Determines if the given node is a style element | boolean | | isTextNode | Determines if the given node is a text-only node | boolean | | isCommentNode | Determines if the given node is an HTML comment | boolean | | isDirectiveNode | Determines if the given node is a directive (eg. <!doctype ...>) | boolean | | getSlots | Returns the available slots based on a node and metadata | NodeWithSlots | undefined | | doesChildAllowParent | Given a tag's metadata, checks if it allows children | boolean | | doesParentAllowChild | Given a child and it's parent's metadata, checks if the parent will allow the child to be embedded | boolean | | isNodeAllowed | Given two nodes and their metadata, check each side to determine if the parent allows the child, and the child allows the parent | boolean | | validateNode | Given a node and its meta, return errors of any type | ErrorStack | | validateChildConstraints | Given a node and its meta, return errors if either of the parent or child are in an invalid position | ErrorStack | | validateAttributes | Given a node and its meta, return errors if any attributes have invalid values | ErrorStack | | generateJsonPointers | Generate a set of JSON Pointers for all descendents of a RaisinNode | WeakMap<RaisinNode, string> | | getSubErrors | Given a JSON Pointer, return any errors that are descendants of the node at the given pointer | ErrorStack | | hasSubErrors | Given a JSON Pointer, return true if there are any descendants of the node at the given pointer | boolean | | removeError | Given a JSON Pointer, remove the error at that path and return a new list of errors | ErrorStack | | calculatePlopTargets | Given a parent RaisinNode, a potential plop target as a RaisinNode and any metadata, return a PlopTarget for each valid position | PlopTarget[] | | getNode | Given the root node and a NodePath, return the RaisinNode | RaisinNode | | getPath | Given the root node and a descendant node, return a NodePath if it's found | NodePath | undefined | | cssSerializer | Converts a plain CSS node AST into a css string | string | | cssParser | Parses a CSS expression and returns a pure js object AST representation of the content | CssNodePlain | | cssSelector | Given a RaisinDocumentNode and a css query string, return all matches found as RaisinElementNode[] | RaisinElementNode[] |

Other Exports

  • HTMLComponents
    • Mappings for all HTML Elements as CustomElements for use in the raisins ecosystem
  • DefaultTextMarks
    • An array of all HTML Elements that should be treated as text nodes for editing purposes
  • htmlUtil
    • A library of HTML Utility functions
  • cssUtil
    • A library of CSS Utility functions