2025-09-06 00:26:50 +00:00
|
|
|
import './style.css';
|
|
|
|
|
import './app.css';
|
|
|
|
|
|
2026-03-14 10:10:11 +00:00
|
|
|
import {basicSetup} from "codemirror";
|
|
|
|
|
import {EditorView, keymap} from "@codemirror/view";
|
2026-05-03 01:31:55 +00:00
|
|
|
import {Compartment} from "@codemirror/state";
|
|
|
|
|
import {oneDark} from "@codemirror/theme-one-dark";
|
2025-09-14 11:58:30 +00:00
|
|
|
import {Application} from "@hotwired/stimulus";
|
|
|
|
|
|
|
|
|
|
import {textProcessor} from "./services.js";
|
|
|
|
|
import {multiCursorKeymap, commandPalette} from "./cmplugins.js";
|
2026-03-14 10:10:11 +00:00
|
|
|
import {indentWithTab} from "@codemirror/commands";
|
2025-09-06 00:26:50 +00:00
|
|
|
|
2026-05-03 01:31:55 +00:00
|
|
|
const darkMode = window.matchMedia("(prefers-color-scheme: dark)");
|
|
|
|
|
const themeCompartment = new Compartment();
|
|
|
|
|
|
2026-01-25 00:00:40 +00:00
|
|
|
import {StatusController} from "./controllers/status_controller.js";
|
2025-09-06 01:26:54 +00:00
|
|
|
import {CommandsController} from "./controllers/commands_controller.js";
|
2026-03-14 10:52:13 +00:00
|
|
|
import {PromptController} from "./controllers/prompt_controller.js";
|
2025-09-06 00:26:50 +00:00
|
|
|
|
2025-09-14 11:58:30 +00:00
|
|
|
|
2026-01-25 00:00:40 +00:00
|
|
|
|
2025-09-06 00:26:50 +00:00
|
|
|
const view = new EditorView({
|
2026-01-25 00:00:40 +00:00
|
|
|
parent: document.querySelector("#app .editor-mountpoint"),
|
2025-09-06 00:26:50 +00:00
|
|
|
doc: "",
|
|
|
|
|
extensions: [
|
|
|
|
|
basicSetup,
|
2026-03-14 10:10:11 +00:00
|
|
|
keymap.of([indentWithTab]),
|
2025-09-14 11:58:30 +00:00
|
|
|
EditorView.lineWrapping,
|
|
|
|
|
multiCursorKeymap,
|
|
|
|
|
commandPalette,
|
2026-05-03 01:31:55 +00:00
|
|
|
themeCompartment.of(darkMode.matches ? oneDark : []),
|
2025-09-06 00:26:50 +00:00
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
|
2026-05-03 01:31:55 +00:00
|
|
|
darkMode.addEventListener("change", (e) => {
|
|
|
|
|
view.dispatch({
|
|
|
|
|
effects: themeCompartment.reconfigure(e.matches ? oneDark : []),
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2025-09-06 00:26:50 +00:00
|
|
|
window.Stimulus = Application.start()
|
|
|
|
|
Stimulus.register("commands", CommandsController);
|
2026-03-14 10:52:13 +00:00
|
|
|
Stimulus.register("prompt", PromptController);
|
2026-01-25 00:00:40 +00:00
|
|
|
Stimulus.register("status", StatusController);
|
2025-09-06 00:26:50 +00:00
|
|
|
|
2025-09-06 01:26:54 +00:00
|
|
|
textProcessor.setCodeMirrorEditor(view);
|
2026-01-25 22:31:14 +00:00
|
|
|
textProcessor.loadCurrentBuffer().then(() => textProcessor.startAutoSaver());
|
2025-09-06 01:26:54 +00:00
|
|
|
|
2025-09-06 00:26:50 +00:00
|
|
|
view.focus();
|