shahnevis-core
v1.1.0
Published
**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,
Maintainers
Readme
📜 Shahnevis Core
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.
🚀 Features
✅ Syntax highlighting
✅ Minimap rendering
✅ Multi-cursor support
✅ Code folding
✅ Plugin system for extensions
✅ Language support for syntax parsing
📦 Installation
You can install shahnevis-core via npm:
npm install shahnevis-coreor using yarn:
yarn add shahnevis-core🛠️ Usage
Example: Using Shahnevis Core in React
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.
🔌 Plugin System
Shahnevis Core supports a plugin system that allows developers to extend functionality dynamically.
📥 Creating a Plugin
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;
}
}
};🛠️ Registering the Plugin
To register this plugin, use:
const pluginURLs = [
'path to plugin'
]
const loadPlugins = async () => {
await loadExternalPlugins(pluginURLs);
console.log("Plugins loaded.");
};
loadPlugins();🌍 Supported Languages
Shahnevis Core comes with built-in support for multiple programming languages via the languages module. You can extend this list with additional parsers.
🤝 Contributing
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
License
This project is licensed under the GNU General Public License v3.0 (GPLv3).
See the LICENSE file for details.
