Editor views
@adecore/editor-react adds language features to @adecore/editor over a LanguageService, with the React cards that show them. It also draws diffs and reviews of what an agent proposed. The package starts no language server and touches no file. The app hands it a service and the file operations it allows.
import { EditorView, ProjectLanguage } from '@adecore/editor-react';
const project = new ProjectLanguage(service, { folder: '/shop', keymap, openPlace });
<EditorView engine={engine} options={options} project={project} uri="file:///shop/src/order.ts" languageId="typescript" className="h-96" />;import type { FakeLanguageService } from '@adecore/editor-react/testing';
import { LanguageFrame } from '../shared/editor-frame.tsx';
import { useDemoLanguage } from '../shared/editor.ts';
import {
reportProblems,
respondCodeActions,
respondCompletion,
respondHighlights,
respondHover,
respondNavigation,
respondRename,
respondSignatureHelp,
respondSymbols
} from '../shared/order-service.ts';
/* Every feature the fake service answers for, as a real TypeScript server would. */
function configure(service: FakeLanguageService): void {
respondCompletion(service);
respondSignatureHelp(service);
respondHover(service);
respondNavigation(service);
respondSymbols(service);
respondHighlights(service);
respondRename(service);
respondCodeActions(service);
reportProblems(service);
}
export default function LanguageEditorDemo() {
const { project, onMount } = useDemoLanguage(configure);
return (
<LanguageFrame
project={project}
onMount={onMount}
className="h-96"
toolbar={
<span className="px-1 text-xs text-text-muted">
Type `line.` for suggestions, rest the pointer on a name, Ctrl+click `orderTotal`, or right-click.
</span>
}
/>
);
}The demos run over FakeLanguageService, with answers from docs/demos/shared/order-service.ts. No server runs.
What it does
- Suggests completions and walks snippets, shows signatures, hover cards and problems, and colors code by its meaning.
- Goes to definitions, peeks at references, walks call and type hierarchies, and keeps a history of places across files.
- Renames across files and applies code actions, through workspace edits the app's file operations carry out.
- Expands live templates, postfix templates and Emmet abbreviations, and closes and renames tags.
- Shows usages and authors above declarations, and draws documentation comments as formatted text.
- Draws diffs, proposed changes and agent attribution in the editor's font and colors.
- Shares one document per file between the editors of a project, so a server hears each change once.
What it leaves to the app
The app starts, stops and routes the language servers and implements the LanguageService over them. It owns the files. Reading, drafts, saving, renaming and deleting go through the ProjectFiles it hands over, with its own permission checks. Git stays with the app too; code vision takes a blame the app ran. Where a file opens, which keys open which bar, and what a toast looks like are the app's to decide through the LanguageHost.
Where to next
- Getting started installs the package, loads styles and words, and mounts a first editor with a fake service.
- Projects and documents covers
ProjectLanguage, the host, shared documents, language ids and the clipboard history. - Workspace edits covers how an edit across files reaches the app's files.
- EditorView covers the component,
EditorLanguagefor an editor mounted by hand, the cards and how to draw your own. - Completion and signatures and Snippets cover suggestions, signature help and snippet sessions.
- Hover, hints and colors and Problems cover hover cards, inlay hints, semantic colors and diagnostics.
- Navigation, Call hierarchy and Rename and code actions cover moving through code and changing it.
- Markup, Templates and Links, colors and more cover the smaller features, format on type included.
- FindReplace covers the find and replace bar.
- DiffView, Reviews and agents and Patch files cover diffs, proposals and editable patches.
- Code vision and Rendered documentation cover usages, authors and formatted doc comments.
- View state covers where a file was scrolled, folded and left.
- Accessibility covers what a screen reader hears.
- Testing covers
FakeLanguageServiceandManualTimers. - Models and Reference list the pure functions and every export.
Limits
- Features depend on the service. A feature only asks for methods the service supports; a command it lacks tells the person through
notify. - The editor's limits hold: no bidirectional text, and its performance limits.
- Accessibility is untested with a screen reader.
- Snippets follow the LSP syntax, with transforms in a worker. Without
snippetTransformWorker, variables stay untransformed and field transforms do not run. Oversized or deeply nested snippets insert as plain text. See snippets. - Inlay hint actions need a pointer; only the tooltip has a keyboard path, through Quick Info. See inlay hints.
- A server with neither semantic token deltas nor ranges gets a request for the whole document after each pause in typing.
applyWorkspaceEditrefuses an edit that would overwrite withoutsupportsOverwriteor lose unsaved work, and a failure halfway does not roll back. See workspace edits.- Files over 20,000 lines get no code vision rows.
The package is FSL-1.1-MIT.