codemirror 0.4.5+5.41.0

  • README.md
  • changelog.md
  • Installing
  • Versions
  • 68

codemirror.dart #

Build Status Dart strong mode

What is it? #

A Dart wrapper around the CodeMirror text editor. From codemirror.net:

CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with a number of language modes and addons that implement more advanced editing functionality.

An example #

Map options = {
  'mode': 'javascript',
  'theme': 'monokai'
};

CodeMirror editor = new CodeMirror.fromElement(
    querySelector('#textContainer'), options: options);
editor.getDoc().setValue('foo.bar(1, 2, 3);');

See also our example/ directory.

How do I use it? #

In your main html file, link to the style sheet:

<link href="packages/codemirror/codemirror.css" rel="stylesheet">

reference the CodeMirror JavaScript code:

<script src="packages/codemirror/codemirror.js"></script>

and, in your Dart code, import the library:

import 'package:codemirror/codemirror.dart';

What about modes? Addons? #

This Dart package ships with several language modes built in. CodeMirror itself supports over 100 modes; the modes built into the Dart package include the usual suspects for web development - css, html, dart and javascript as well as a few others. In order to add additional modes, you'll need to reference the mode file from your html entry-point. So,

<script src="packages/codemirror/mode/lua.js"></script>

will bring in support for Lua.

Similarly with addons, we've included a few common ones, and have made the others available to import on a case-by-case basis. In order to use the active-line addon, import:

<script src="packages/codemirror/addon/selection/active-line.js"></script>

Be aware that many addons need additional configuration in order to enable then. This is generally done by passing values into the options of the CodeMirror constructor.

Some addons are exposed through the main Dart interface. Some are exposed via side-car Dart libraries available in the main package, and some have yet to be exposed. Pull requests welcome :)

Themes #

By importing the codemirror.css file:

<link href="packages/codemirror/codemirror.css" rel="stylesheet">

You get access to all the CodeMirror themes. If you only want a few, or don't want to pay the network roundtrip cost to load all the themes, you can import only the ones you're interested in:

<link href="packages/codemirror/theme/monokai.css" rel="stylesheet">
<link href="packages/codemirror/theme/zenburn.css" rel="stylesheet">

Polymer transformer #

The Polymer transfomer will inline our theme css references incorrectly. Currently, to use the codemirror package with Polymer, you'll need to add the following lines to your pubspec.yaml file.

- polymer:
    entry_points: web/foo_bar.html
    inline_stylesheets:
      packages/codemirror/codemirror.css: false

Disclaimer #

This is not an official Google product.

Changelog #

0.4.5 #

  • fix v0.4.4 - update the Javascript codemirror resources

0.4.4 #

  • updated to CodeMirror 5.41.0
  • exposed more themes

0.4.3 #

  • increase the SDK dependency range

0.4.2 #

  • strong mode fixes
  • remove the use of deprecated constants

0.4.1 #

  • updated to CodeMirror 5.13.4
  • expose Doc.eachLine
  • expose Doc.addSelection
  • expose Doc.extendSelection
  • expose Doc.extendSelections
  • expose Doc.extendSelectionsBy
  • expose Doc.setExtending and Doc.getExtending

0.4.0 #

  • update the CodeMirror.addCommand to better support custom commands

0.3.2 #

  • updated to CodeMirror 5.8.0 (with improvements to the Dart mode)
  • Dart mode: improved syntax highlighting for triple-quoted strings
  • Dart mode: added syntax highlighting support for string interpolation

0.3.1 #

  • strong mode fixes
  • fix an issue with the async code completer

0.3.0 #

  • updated to CodeMirror 5.7.0
  • more strong mode fixes

0.2.9 #

  • made ddc (strong mode) compliant
  • fixed an issues returning the TextMarker positions of bookmarks

0.2.8 #

  • updated to CodeMirror 5.5.0
  • expose defineExtension and defineDocExtension

0.2.7 #

  • updated to CodeMirror 5.2.0
  • bug fix to Doc.getModeAt
  • added Doc.getModeName() and Doc.getModeNameAt() methods

0.2.6 #

0.2.5 #

  • expose the hints panel select, pick, and update events

0.2.4 #

  • expose the hints panel shown and close events (HintResults.registerOnShown)

0.2.3 #

  • patch in a fix for the code completion popup

0.2.2 #

  • upgrade to CodeMirror 5.1.0
  • expose more functionality from the hint addon

0.2.1 #

  • exposed execCommand

0.2.0 #

  • upgrade to CodeMirror 5.0.0
  • exposed CodeMirror.getInputField

0.1.6 #

  • upgrade to CodeMirror 4.12.0
  • added CodeMirror.findModeByFileName
  • expose more API (LineHandle, ...)

0.1.5 #

  • expose the hints (code completion) addon

0.1.4 #

  • include additional (optional) modes and addons

0.1.3 #

  • expose additional CodeMirror addons (comment editing, tag closing, element insertion)
  • expose additional CodeMirror APIs, esp. around Tokens and modes

0.1.2 #

  • added a missing hinter
  • removed all but a few modes from the defaults (codemirror.js went from 1.2MB to 520k)

0.1.1 #

  • added the ability to create TextMarkers (see Doc.markText and associated methods)
  • upgrade to CodeMirror 4.11.0

0.1.0 #

0.0.13 #

  • added posFromIndex and indexFromPos

0.0.12 #

  • added a CodeMirror.fromJsObject constructor
  • added CodeMirror.getLine

0.0.11 #

  • expose some gutter, widget, and marker manipulation methods
  • some support for the lint addon

0.0.10 #

  • included the addon/ directory in the package
  • concatenated likely addons to the codemirror.js script

0.0.9 #

  • upgrade to CodeMirror 4.8.0
  • expose CodeMirror.findModeByExtension, CodeMirror.findModeByMime, and CodeMirror.findModeByName

0.0.8 #

  • upgrade to CodeMirror 4.7.0

0.0.7 #

  • fixed a bug in Doc.onChange
  • fixed a bug in CodeMirror.getReadOnly
  • added Doc.getSelection

0.0.6 #

  • added a new constructor for Doc

0.0.5 #

  • add a CodeMirror.swapDoc method

0.0.4 #

  • fix for exception when listening for changes

0.0.3 #

  • republished to capture files omitted due to the .gitignore pub behavior

0.0.2 #

  • changed to consuming CodeMirror from bower
  • we now concatenate all modes into the main codemirror.js file

0.0.1 #

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  codemirror: ^0.4.5+5.41.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:codemirror/codemirror.dart';
  
Version Uploaded Documentation Archive
0.5.6+5.47.0 May 28, 2019 Go to the documentation of codemirror 0.5.6+5.47.0 Download codemirror 0.5.6+5.47.0 archive
0.5.5+5.46.0 May 13, 2019 Go to the documentation of codemirror 0.5.5+5.46.0 Download codemirror 0.5.5+5.46.0 archive
0.5.4+5.45.0 May 7, 2019 Go to the documentation of codemirror 0.5.4+5.45.0 Download codemirror 0.5.4+5.45.0 archive
0.5.3+5.44.0 Mar 8, 2019 Go to the documentation of codemirror 0.5.3+5.44.0 Download codemirror 0.5.3+5.44.0 archive
0.5.2+5.44.0 Mar 4, 2019 Go to the documentation of codemirror 0.5.2+5.44.0 Download codemirror 0.5.2+5.44.0 archive
0.5.1+5.44.0 Mar 4, 2019 Go to the documentation of codemirror 0.5.1+5.44.0 Download codemirror 0.5.1+5.44.0 archive
0.5.0+5.43.0 Feb 3, 2019 Go to the documentation of codemirror 0.5.0+5.43.0 Download codemirror 0.5.0+5.43.0 archive
0.4.7+5.41.0 Dec 21, 2018 Go to the documentation of codemirror 0.4.7+5.41.0 Download codemirror 0.4.7+5.41.0 archive
0.4.6+5.41.0 Nov 30, 2018 Go to the documentation of codemirror 0.4.6+5.41.0 Download codemirror 0.4.6+5.41.0 archive
0.4.5+5.41.0 Nov 15, 2018 Go to the documentation of codemirror 0.4.5+5.41.0 Download codemirror 0.4.5+5.41.0 archive

All 49 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
52
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
89
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on May 30, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.1
  • pana: 0.12.17

Platforms

Detected platforms: web

Primary library: package:codemirror/codemirror.dart with components: html, js.

Health suggestions

Fix lib/codemirror.dart. (-43.81 points)

Analysis of lib/codemirror.dart reported 115 hints, including:

line 15 col 1: Prefer using /// for doc comments.

line 20 col 1: Prefer using /// for doc comments.

line 25 col 1: Prefer using /// for doc comments.

line 30 col 1: Prefer using /// for doc comments.

line 109 col 3: Prefer using /// for doc comments.

Fix lib/hints.dart. (-2.96 points)

Analysis of lib/hints.dart reported 6 hints, including:

line 5 col 1: Prefer using /// for doc comments.

line 26 col 1: Prefer using /// for doc comments.

line 100 col 1: Prefer using /// for doc comments.

line 112 col 3: Prefer using /// for doc comments.

line 118 col 3: Prefer using /// for doc comments.

Fix lib/src/js_utils.dart. (-2.96 points)

Analysis of lib/src/js_utils.dart reported 6 hints, including:

line 5 col 1: Prefer using /// for doc comments.

line 17 col 1: Prefer using /// for doc comments.

line 22 col 1: Prefer using /// for doc comments.

line 30 col 1: Prefer using /// for doc comments.

line 35 col 1: Prefer using /// for doc comments.

Fix lib/panel.dart. (-1.99 points)

Analysis of lib/panel.dart reported 4 hints:

line 5 col 1: Prefer using /// for doc comments.

line 17 col 3: Prefer using /// for doc comments.

line 36 col 3: Prefer using /// for doc comments.

line 41 col 3: Prefer using /// for doc comments.

Maintenance suggestions

The package description is too short. (-11 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and codemirror.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
grinder ^0.8.0
test ^1.0.0