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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@layers-app/editor-core

v0.3.0

Published

Plugin SDK for @layers-app/editor — shared primitives used to build first-party and third-party editor plugins

Downloads

448

Readme

@layers-app/editor-core

Public Plugin SDK for @layers-app/editor. Use it to build first-party or third-party editor plugins.

For most consumers this package is a transitive dependency of @layers-app/editor — you don't install it directly. Install it explicitly only when you're authoring a plugin.

Install

npm install @layers-app/editor-core

Peer dependencies (install as needed): react, react-dom, lexical, @lexical/react, @mantine/core, @mantine/hooks, @mantine/dropzone, @mantine/carousel, @hugeicons/react, @hugeicons/core-free-icons, @tabler/icons-react, @tanstack/react-query, i18next, react-i18next, lodash-es.

What's exported

Plugin infrastructure types

  • PluginConfig — full plugin contract consumed by <Editor plugins={[...]} />
  • SlashMenuConfig — slash-menu entry for a plugin
  • PluginModeConfig — which editor modes a plugin is enabled in (comment / default / editor)
  • UploadData, AlignmentType, MediaPlatform

Hooks

  • useChunkedUpload({ endpoints, ... }) — chunked file upload with resume/retry
  • useCancelUpload() — AbortController helper shared by File, Images, Video uploaders

UI primitives

  • ActionIcon, MobileDrawer, Select, SelectListOptionButton
  • AlignmentMenu — simple left/center/right picker
  • NodeAlignmentMenu — wired-up menu for any Lexical node exposing setAlignment
  • ResizableContainer — media block with resize handles, touch support, alignment-aware cursors
  • Upload UI: ActionButtons, ProgressBar, UploadLoaderIndicator, UploadProgressPanel

Media utilities

  • parseVideoURL(url, isLink?) — recognizes YouTube, VK, Rutube, uploaded UUIDs
  • insertMediaNode(editor, node) — basic Lexical-safe node insertion
  • deleteNode(editor, nodeOrKey)
  • formatTime(seconds)M:SS / H:MM:SS formatting

Environment & utilities

  • IS_APPLE, IS_IOS, IS_ANDROID, IS_SAFARI, IS_FIREFOX, IS_CHROME, IS_TOUCH_DEVICE, IS_HOVER_CAPABLE, IS_TOUCH_TABLET
  • isMobile, CAN_USE_DOM
  • getAllowedControls(alignment) — resize handles allowed for a given alignment

Building a plugin — step by step

A plugin is a PluginConfig object passed to <Editor plugins={[yourPlugin(config)]} />. Below is the minimum needed to ship one.

1. Define a Lexical node

Your plugin owns a custom Lexical node. This is what gets serialized into the editor state.

// node.ts
import { DecoratorNode, type LexicalCommand, type NodeKey, createCommand } from 'lexical';

export type CalendarPayload = { date: string };

export class CalendarNode extends DecoratorNode<JSX.Element> {
  __date: string;

  static getType(): string { return 'calendar'; }
  static clone(node: CalendarNode): CalendarNode { return new CalendarNode(node.__date, node.__key); }

  constructor(date: string, key?: NodeKey) {
    super(key);
    this.__date = date;
  }

  createDOM(): HTMLElement { return document.createElement('div'); }
  updateDOM(): false { return false; }

  decorate(): JSX.Element {
    return <CalendarBlock date={this.__date} />;
  }

  exportJSON() { return { type: 'calendar', date: this.__date, version: 1 }; }
  static importJSON(json: ReturnType<CalendarNode['exportJSON']>): CalendarNode {
    return new CalendarNode(json.date);
  }
}

export const INSERT_CALENDAR_COMMAND: LexicalCommand<CalendarPayload> =
  createCommand('INSERT_CALENDAR_COMMAND');

2. Write the plugin component

The component listens to commands and inserts your node.

// CalendarPlugin.tsx
import { useEffect } from 'react';

import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
import { COMMAND_PRIORITY_LOW } from 'lexical';

import { insertMediaNode } from '@layers-app/editor-core';

import { CalendarNode, INSERT_CALENDAR_COMMAND } from './node';

export default function CalendarPlugin(): null {
  const [editor] = useLexicalComposerContext();

  useEffect(() => {
    if (!editor.hasNodes([CalendarNode])) {
      throw new Error('CalendarPlugin: CalendarNode not registered');
    }

    return editor.registerCommand(
      INSERT_CALENDAR_COMMAND,
      (payload) => {
        const node = new CalendarNode(payload.date);
        insertMediaNode(editor, node);
        return true;
      },
      COMMAND_PRIORITY_LOW,
    );
  }, [editor]);

  return null;
}

3. Wire up the factory

The factory returns the PluginConfig consumed by <Editor>.

// factory.tsx
import { Calendar01Icon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/react';

import type { PluginConfig } from '@layers-app/editor-core';

import CalendarPlugin from './CalendarPlugin';
import { CalendarNode, INSERT_CALENDAR_COMMAND } from './node';

export type CalendarPluginConfig = {
  /* config fields available to your component via context */
  defaultDate?: string;
};

export function calendarPlugin(config: CalendarPluginConfig): PluginConfig {
  return {
    key: 'calendar',
    node: CalendarNode,
    Plugin: CalendarPlugin,
    Provider: ({ children }) => <>{children}</>, // or your own context provider
    modes: { comment: false, default: true, editor: true },
    slashMenu: {
      parentKey: 'media',
      name: 'editor.calendar.name',
      description: 'editor.calendar.description',
      icon: <HugeiconsIcon icon={Calendar01Icon} size={16} />,
      keywords: ['calendar', 'date', 'event'],
      command: INSERT_CALENDAR_COMMAND,
      commandPayload: new Date().toISOString().slice(0, 10),
    },
  };
}

4. Use it in a host application

import { Editor } from '@layers-app/editor';
import { calendarPlugin } from '@your-org/editor-calendar';

const config = useMemo(() => calendarPlugin({ defaultDate: '2026-01-01' }), []);

<Editor plugins={[config]} ... />

Reference implementation

@layers-app/editor-video is the canonical reference — a fully-featured plugin (chunked upload, custom player UI, settings modal, subtitles, chapters) built using only @layers-app/editor-core. Its source is the best example of how to use everything in this SDK.

Conventions

  • Node getType() must be unique across all plugins in the editor.
  • Command names (e.g. INSERT_CALENDAR_COMMAND) should be plugin-prefixed.
  • i18n keys live in the host application; the plugin only references key names.
  • Icons: import from @hugeicons/core-free-icons + @hugeicons/react.
  • Styles: scoped to the plugin's components; if using SCSS, bundle via the package itself.

Architectural constraint

editor-core must never import from @layers-app/editor. Plugins that follow this constraint can be developed and shipped independently of the editor source.

Cross-plugin imports are also discouraged — share via editor-core instead.

License

MIT