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
- Host: GitHub
- URL: https://github.com/antonkulaga/codemirror-facade
- Owner: antonkulaga
- License: mpl-2.0
- Created: 2015-06-03T22:24:44.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-07-15T13:09:06.000Z (about 8 years ago)
- Last Synced: 2025-04-13T13:14:23.467Z (6 months ago)
- Topics: codemirror, facade, scalajs
- Language: Scala
- Size: 70.3 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.HTMLTextAreaElementval 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.