Shahnevis Core is a lightweight and flexible library for building custom code editors. It provides essential features like syntax highlighting, a minimap, multi-cursor support, line numbering, and plugin management. This library is framework-agnostic, meaning you can use it in React, Vue, or any other JavaScript environment.
✅ Syntax highlighting
✅ Minimap rendering
✅ Multi-cursor support
✅ Code folding
✅ Plugin system for extensions
✅ Language support for syntax parsing
You can install shahnevis-core
via npm:
npm install shahnevis-core
or using yarn:
yarn add shahnevis-core
import {
languages, highlightHandler, updateSyntaxHighlighting, minimapHandler, updateMinimapContent,
featureHandler, updateIndentationGuides, handleSuggestions, pluginManager, loadExternalPlugins,
globalState, cleanForFolded, detectChange, generateFullCode, updateFoldingState
} from "shahnevis-core";
// Example usage
highlightHandler("your-code-here");
updateSyntaxHighlighting();
For more advanced usage, refer to the documentation.
Shahnevis Core supports a plugin system that allows developers to extend functionality dynamically.
Here's an example of a Preview Plugin that updates an iframe when the user writes HTML code:
export default {
init() {
console.log("Preview Plugin Loaded!");
},
onLanguageChange(language) {
if (language === "html") {
console.log("HTML selected!");
}
},
onInput() {
const languageSelector = document.getElementById("language-selector");
const previewFrame = document.getElementById("preview-frame");
const editor = document.getElementById("editor");
if (!languageSelector || !previewFrame || !editor) {
console.warn("Preview Plugin: Missing required DOM elements.");
return;
}
const language = languageSelector.value;
if (language === "html") {
previewFrame.srcdoc = editor.value;
}
}
};
To register this plugin, use:
const pluginURLs = [
'path to plugin'
]
const loadPlugins = async () => {
await loadExternalPlugins(pluginURLs);
console.log("Plugins loaded.");
};
loadPlugins();
Shahnevis Core comes with built-in support for multiple programming languages via the languages
module. You can extend this list with additional parsers.
We welcome contributions! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature-new
) - Commit your changes (
git commit -m "Add new feature"
) - Push to the branch (
git push origin feature-new
) - Open a pull request
This project is licensed under the GNU General Public License v3.0 (GPLv3).
See the LICENSE file for details.