Socket
Socket
Sign inDemoInstall

codemirror-ssr

Package Overview
Dependencies
3
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    codemirror-ssr

SSR compatible CodeMirror 5


Version published
Weekly downloads
3K
increased by6.88%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

codemirror-ssr

SSR compatible CodeMirror 5

Motivation

CodeMirror 5 uses some client-only APIs at top level, which makes it not compatible with SSR. A way to solve this problem is to dynamic import codemirror module and its addons in client-only lifecycles. It works, but would cause unnecessary bundle split and increase the final loading time.

Usage

Before

import codemirror from "codemirror";
import "codemirror/addon/display/placeholder";

const editor = codemirror.fromTextArea(textarea, {
  // options
});

After

import factory from "codemirror-ssr";
import usePlaceholder from "codemirror-ssr/addon/display/placeholder";

// the client-only lifecycle
function mounted() {
  const codemirror = factory();
  usePlaceholder(codemirror); // apply addons manually

  const editor = codemirror.fromTextArea(textarea, {
    // options
  });
}

Built with codemirror-ssr

  • ByteMD: A hackable Markdown editor component built with Svelte

License

MIT

FAQs

Last updated on 15 May 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc