An open API service indexing awesome lists of open source software.

https://github.com/antonkulaga/codemirror-facade

Facade for the codemirror
https://github.com/antonkulaga/codemirror-facade

codemirror facade scalajs

Last synced: 6 months ago
JSON representation

Facade for the codemirror

Awesome Lists containing this project

README

          

org.denigma.codemirror facade
=============================

This if a facade of org.denigma.codemirror library. All the code is inside org.denigma.codemirror subproject.

Usage
=====

In order to resolve a lib you should add a resolver::
```scala
resolvers += sbt.Resolver.bintrayRepo("denigma", "denigma-releases") //add resolver
libraryDependencies += "org.denigma" %%% "codemirror-facade" % "5.13.2-0.8" //add dependency
```

Currently both Scala 2.11.x and Scala 2.12.x are supported.

In your code:
-------------

Add text area somewhere:

```html

```

Write some simple code

```scala
import org.denigma.org.denigma.codemirror.extensions.EditorConfig
import org.denigma.org.denigma.codemirror.{CodeMirror, EditorConfiguration}
import org.scalajs.dom
import org.scalajs.dom.raw.HTMLTextAreaElement

val id = "scala"
val code = println("hello Scala!") //code to add
val mode = "clike" //language mode, some modes have weird names in org.denigma.codemirror
val params: EditorConfiguration = EditorConfig.mode(mode).lineNumbers(true) //config
val editor = dom.document.getElementById(id) match {
case el:HTMLTextAreaElement =>
val m = CodeMirror.fromTextArea(el,params)
m.getDoc().setValue(code) //add the code
case _=> dom.console.error("cannot find text area for the code!")
}
```

Preview
-------

Preview subprojects are required to see some examples of using the facade.

To run preview:
```sbt
sbt //to opens sbt console
re-start //Use this command **instead of** run to run the app
Open localhost:5554 to see the result, it should reload whenever any sources are changed
```

Extensions
----------

In org.denigma.extensions package there are some methods that extend default codemirror functionality.