Nasa Editor Library is a lightweight library that enables developers to effortlessly create custom code editors. The library supports execution of HTML, CSS, and JavaScript code and is compatible with API levels 21 - 34. Whether you're building a custom code editor or integrating code execution into an app, this library simplifies the process.
In your settings.gradle
file, ensure JitPack is included:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
// other repositories
maven { url 'https://jitpack.io' }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
// other repositories
maven { url = uri("https://jitpack.io") }
}
}
In your app-level build.gradle
file, add the dependency:
dependencies {
// Nasa Editor Library
implementation 'com.github.CodeWithTamim:Nasa-Editor-Library:1.0.1'
}
dependencies {
// Nasa Editor Library
implementation("com.github.CodeWithTamim:Nasa-Editor-Library:1.0.1")
}
Define a WebView
in your XML layout:
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:scrollbars="none" />
In your Activity or Fragment, initialize the editor:
// Using view binding
NasaEditor editor = new NasaEditor(binding.webView);
// Using findViewById
NasaEditor editor = new NasaEditor(findViewById(R.id.webView));
// Using view binding
val editor = NasaEditor(binding.webView)
// Using findViewById
val editor = NasaEditor(findViewById(R.id.webView))
Inject HTML, CSS, and JavaScript code into the editor:
editor.setHtmlCode("Your html code");
editor.setCssCode("Your css code");
editor.setJsCode("Your js code");
editor.htmlCode = "Your html code"
editor.cssCode = "Your css code"
editor.jsCode = "Your js code"
Run the code in the editor:
editor.runCode();
editor.runCode();
You can also retrieve default HTML, CSS, and JavaScript code or access the WebView
:
editor.getDefaultHtmlCode();
editor.getDefaultCssCode();
editor.getDefaultJsCode();
editor.getDefaultHtmlCode();
editor.getDefaultCssCode();
editor.getDefaultJsCode();
editor.getWebView();
editor.getWebView();
If Nasa Editor Library helps you in your project, consider giving it a βοΈ on GitHub. Contributions are encouraged! Fork the repository, make improvements, and submit a pull request.
For any questions or issues, feel free to open an issue or email me.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Thanks for using Nasa Editor Library!