Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@devidw/brktfldg

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@devidw/brktfldg

Bracket folding. Collapse and expand all brackets on any website.

unpublished
latest
Source
npmnpm
Version
0.5.0
Version published
Maintainers
1
Created
Source


brktfldg

Read about the project

Usage

Load the library using the following CDN link from jsDelivr:

https://cdn.jsdelivr.net/npm/@devidw/brktfldg

To add collapse/expand functionality to all brackets inside an element and its children, use the collapseBrackets(el, options) function:

<p>This is a paragraph (and this is something useless).</p>

<script type="module">
    import { collapseBrackets } from "https://cdn.jsdelivr.net/npm/@devidw/brktfldg"

    collapseBrackets(document.querySelector("p"))
</script>

Configuration

Optionally an options object can be passed to the collapseBrackets function to configure the behaviour and look of the interactive brackets.

The following configuration options are available with their default values:

{
    needles: ["(", ")"], // The characters to search for
    needleRegex: /\((?!\))|(?<!\()\)/g, // The regex to test text nodes for
    replacements: ["(", ")"], // Replaces the original opening and closing bracket characters with the given ones
    placeholder: "…", // Displayed as text for the toggle to expand and collapse the content
    shortMaxWords: 1, // Number of words to determine if the content is short, quick expanding is possible on short conent when enabled and the word count is not displayed on short content
    wordCount: true, // Show word count
    expandShortOnHover: true, // Expand brackets with short content on hover
    ignoreTags: ["script", "style", "pre", "code", "brktfldg-container"], // Ignore these tags
}

brktfldg · Bracket Folding - Get rid of all these brackets: Read less, understand more. | Product Hunt

Keywords

reading

FAQs

Package last updated on 21 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts