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

codemirror-examples

v1.0.52

Published

Codemirror examples including handlebars linting integration.

Downloads

58

Readme

codemirror-examples

Example codemirror in textarea supporting html and css linting and auto resize in a bootstrap template.

  • Demo: https://dhollenbeck.github.io/codemirror-examples/

Install

npm install codemirror-examples --save-dev

Then include the js and css in your web app.

Auto Resize

Auto resize is great for editing of small content. However, it becomes painful for large content. There should be a method to toggle this feature. Auto resize is enabled by default. You can set an explict editor height by:

element.editor({
	height: '300px' // auto, or pixels
});

Full Screen

All demos support fullscreen mode. This mode is really full viewport. After you click inside the editor keypress:

  • F11 - toggles full viewport
  • ESC - exits full viewport

For editors with toolbars wrap the editor with div:

<div class="cm-fullscreen-container">
	<!-- start of mega menu -->
	<!-- textarea here -->
</div>

The <div> which is expanded to full viewport is determined by:

  • The outer closest div (<div class="cm-fullscreen-container">) to the codemirror div, if not found
  • The code mirror wrapper instance (<div class="codemirror">).

Flexbox Layout: Toolbars, Footers, Flexbox and Fullscreen

You can add Bootstrap navbars (toobars) and footers to codemirror. The HTML flexbox layout is:

<div class="cm-fullscreen-container cm-flex-container">
	<div class="cm-toolbar cm-flex-child-fixed">
		{{! your bootstrap navbar}}
	</div>
	<div class="cm-body cm-flex-child-grow">
		{{! your textarea for codemirror}}
	</div>
	<div class="cm-footer cm-flex-child-fixed">
		{{! your footer navbar}}
	</div>
</div>

The css is shown below and is included in the examples:

.cm-flex-container {display: flex;flex-direction: column;height: 100%;}
.cm-flex-child-fixed {flex: none;}
.cm-flex-child-grow {flex: auto; overflow-y:hidden;}

Useful resources for flexbox include:

  • https://css-tricks.com/snippets/css/a-guide-to-flexbox/
  • https://css-tricks.com/snippets/css/complete-guide-grid/
  • http://flexboxgrid.com/

Auto-Sizing Limit

There should be option to limit the size of the editor in auto-scrolling.

Todo: Code Folding

  • https://codemirror.net/demo/folding.html

Todo: Drag Resizing

  • https://github.com/codemirror/CodeMirror/issues/850
  • https://interactjs.io/

Todo: Improve fullscreen

  • Support window scroll on exit: Be the user presses the fullscreen mode the browser window might be scrolled. This scrolled state should be restore upon existing fullscreen.
  • Support codemirror scroll on enter: Before the user presses fullscreen mode the editor might be too large for fullscreen. In this case the editor will scroll. The cursor can be below the fold.

Todo: add byte system to footer

Show the textarea value length as 10.1 KB

Todo: Workings of Monaco Editor For Comparison

  • https://microsoft.github.io/monaco-editor/

Todo: Problem with sticky tooltips

When do the following:

  • Create lint error,
  • Click on the source of the error,
  • Move mouse to display the tooltip
  • Type on keyboard to fix the lint error
  • Tooltip is still visable and stuck to the cursor even though the lint error is resolved.

Check the lint integration compared to the demo:

  • Demo: view-source:https://codemirror.net/demo/lint.html

See: //https://github.com/codemirror/CodeMirror/pull/4308

Workflow

grunt build