Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@lexical/utils
Advanced tools
@lexical/utils is a utility package for the Lexical framework, which is a modern, extensible text editor framework. This package provides various utility functions to facilitate the manipulation and management of Lexical nodes, editors, and other related components.
Node Manipulation
This feature allows you to create and manipulate nodes within the Lexical editor. In this example, a text node is created and appended to the root node.
const { $createTextNode, $getRoot } = require('@lexical/utils');
const root = $getRoot();
const textNode = $createTextNode('Hello, world!');
root.append(textNode);
Editor State Management
This feature provides functions to get and set the editor state, allowing for more controlled and dynamic updates to the editor's content.
const { $getEditorState, $setEditorState } = require('@lexical/utils');
const editorState = $getEditorState();
// Modify the editor state as needed
$setEditorState(editorState);
Event Handling
This feature allows you to add and remove event listeners to the Lexical editor, enabling custom event handling and interaction.
const { $addEventListener, $removeEventListener } = require('@lexical/utils');
const handleClick = (event) => {
console.log('Editor clicked!', event);
};
$addEventListener('click', handleClick);
// Later, if needed
$removeEventListener('click', handleClick);
Draft.js is a rich text editor framework for React. It provides a set of tools for building complex text editors with features like text formatting, media embedding, and more. Compared to @lexical/utils, Draft.js offers a more comprehensive set of features for building rich text editors but may be more complex to use.
Slate is another framework for building rich text editors in React. It is highly customizable and provides a lot of flexibility in terms of editor behavior and appearance. Slate is similar to @lexical/utils in that it offers utilities for managing editor state and nodes, but it is generally more flexible and powerful.
ProseMirror is a toolkit for building rich text editors with a focus on extensibility and performance. It provides a robust set of tools for manipulating document structures and handling complex editor interactions. ProseMirror is more feature-rich and versatile compared to @lexical/utils, but it also comes with a steeper learning curve.
FAQs
This package contains misc utilities for Lexical.
The npm package @lexical/utils receives a total of 434,455 weekly downloads. As such, @lexical/utils popularity was classified as popular.
We found that @lexical/utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers 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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.