| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This is a demo application that showcases the capabilities of the AnycodeEditor library. It demonstrates a code editor with multi-file support where each file maintains its state (cursor position, scroll position, selection) when switching between tabs.
AnycodeEditor is a powerful, lightweight code editor library built with TypeScript that provides:
The AnycodeEditor library is available as separate packages:
# Core editor library
npm install anycode-base
# React wrapper component
npm install anycode-reactimport { AnycodeEditor } from 'anycode-base';
// Create editor instance
const editor = new AnycodeEditor(content, { language: 'javascript' });
// Initialize the editor
await editor.init();
// Set up edit handler
editor.setOnEdit((edit) => {
console.log('Edit applied:', edit);
});
// Get current content
const content = editor.getContent();
// Get editor state (cursor, selection, scroll)
const state = editor.getState();
// Restore editor state
editor.setState(state);import React from 'react';
import { AnycodeEditorReact, AnycodeEditor } from 'anycode-react';
function MyEditor() {
// First create an AnycodeEditor instance
const [editor, setEditor] = useState<AnycodeEditor | null>(null);
useEffect(() => {
const initEditor = async () => {
const initialContent = 'console.log("Hello, World!");';
const newEditor = new AnycodeEditor(initialContent, { language: 'javascript' });
await newEditor.init();
setEditor(newEditor);
};
initEditor();
}, []);
return (
<div style={{ height: '400px' }}>
{editor && (
<AnycodeEditorReact
id="my-editor"
editorState={editor}
/>
)}
</div>
);
}The AnycodeEditor supports syntax highlighting for:
Each editor instance is preserved in memory, maintaining all state (cursor, selection, scroll) without serialization. This provides instant switching between files with perfect state restoration.
The editor uses operational transformation for efficient text editing:
Built on Tree-sitter for accurate parsing and syntax highlighting:
# Install dependencies
pnpm install
# Start development server
pnpm dev
# Build demo
pnpm build# Build core library
cd anycode-base && pnpm build
# Build React wrapper
cd anycode-react && pnpm buildContributions are welcome! Please feel free to submit issues and pull requests.
Note: This is a demo application showcasing the AnycodeEditor library. For production use, consider the specific requirements of your project and the current stability of the library.
| Back | FazBrowse Home | New Git URL |