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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@uiw/codemirror-extensions-events

v4.23.6

Published

Events Extensions for CodeMirror6.

Downloads

32,267

Readme

Events Extensions

Buy me a coffee npm version

Events Extensions for CodeMirror6.

Install

npm install @uiw/codemirror-extensions-events --save
import * as events from '@uiw/codemirror-extensions-events';
import { element } from '@uiw/codemirror-extensions-events';

const extension1 = events.scroll({
  scroll: (evn) => {
    /* ... */
  },
});

const extension1 = events.dom({
  click: (evn) => {
    /* ... */
  },
});

const extension2 = events.content({
  focus: (evn) => {
    /* ... */
  },
  blur: (evn) => {
    /* ... */
  },
});

const extension3 = element({
  type: 'content',
  props: {
    inputMode: 'none',
  },
});

Usage

import CodeMirror from '@uiw/react-codemirror';
import * as events from '@uiw/codemirror-extensions-events';
import { element } from '@uiw/codemirror-extensions-events';

function App() {
  const [scrollTop, setScrollTop] = useState(0);

  const eventExt = events.scroll({
    scroll: (evn) => {
      setScrollTop(evn.target.scrollTop);
    },
  });

  const eventExt2 = events.content({
    focus: (evn) => {
      console.log('focus');
    },
    blur: (evn) => {
      console.log('blur');
    },
  });

  return (
    <CodeMirror
      value="console.log('hello world!');"
      height="200px"
      extensions={[
        element({
          type: 'content',
          props: {
            inputMode: 'none',
          },
        }),
        eventExt,
        eventExt2,
      ]}
    />
  );
}
export default App;
import { EditorView } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
import * as events from '@uiw/codemirror-extensions-events';

const eventExt = events.content({
  focus: (evn) => {
    console.log('focus');
  },
  blur: (evn) => {
    console.log('blur');
  },
});

const state = EditorState.create({
  doc: 'my source code',
  extensions: [eventExt],
});

const view = new EditorView({
  parent: document.querySelector('#editor'),
  state,
});

API

import { ViewPlugin, EditorView } from '@codemirror/view';
export declare type Events<K extends keyof HTMLElementEventMap> = Record<
  K,
  (this: HTMLElement, event: HTMLElementEventMap[K]) => void
>;
/**
 * The DOM element that can be styled to scroll.
 * (Note that it may not have been, so you can't assume this is scrollable.)
 */
export declare function dom<T extends keyof HTMLElementEventMap>(
  opts: Events<T>,
): ViewPlugin<{
  dom?: HTMLElement | undefined;
  view: EditorView;
  destroy(): void;
}>;
/**
 * The DOM element that wraps the entire editor view.
 */
export declare function scroll<T extends keyof HTMLElementEventMap>(
  opts: Events<T>,
): ViewPlugin<{
  dom?: HTMLElement | undefined;
  view: EditorView;
  destroy(): void;
}>;
/**
 * The editable DOM element holding the editor content.
 * You should not, usually, interact with this content directly though the DOM,
 * since the editor will immediately undo most of the changes you make.
 */
export declare function content<T extends keyof HTMLElementEventMap>(
  opts: Events<T>,
): ViewPlugin<{
  dom?: HTMLElement | undefined;
  view: EditorView;
  destroy(): void;
}>;

Contributors

As always, thanks to our amazing contributors!

Made with github-action-contributors.

License

Licensed under the MIT License.