Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-middle-ellipsis
Advanced tools
Adding ellipses to the end of long text is cool. But not always! Sometimes the end of the text contains vital information, particularly for URLs or filenames.
This React component is designed with that use case in mind.
yarn add react-middle-ellipsis
Once import
ed, you can then wrap any node with <MiddleEllipsis>
.
This will compute the width of the surrounding parent node. Then, it
will look for the child node (so make sure to add a span
at
minimum internally): it will use this element to compute the width
of the child, and then shorten the text element whose class is
ellipseMe
(optional) to fit within the parent.
The component re-computes things if the browser window is resized, too!
import React from "react";
import MiddleEllipsis from "react-middle-ellipsis";
const Component = props => {
return (
<>
<div style={{ width: "350px", whiteSpace: "nowrap" }}>
<MiddleEllipsis>
<span>
I am some long text that should be ellipsed in the middle because
the end contains important stuff.
</span>
</MiddleEllipsis>
</div>
<div style={{ width: "350px", whiteSpace: "nowrap" }}>
<MiddleEllipsis>
<span>
Don't ellipse me.{" "}
<span className="ellipseMe">
I am some long text that should be ellipsed in the middle because
the end contains important stuff.
</span>
</span>
</MiddleEllipsis>
</div>
<>
);
};
export default Component;
Notes for developing this component.
yarn run start
in this directory and separately also in /example
. This will
live reload any changes made in /src
.
Change the version number in package.json
and npm publish
once complete.
MIT © bluepeter
FAQs
Put the dots in the middle of a long string, versus the end.
The npm package react-middle-ellipsis receives a total of 4,766 weekly downloads. As such, react-middle-ellipsis popularity was classified as popular.
We found that react-middle-ellipsis demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.