Skip to content

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.

tsx
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" />;
tsx
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 ​

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.
  • applyWorkspaceEdit refuses an edit that would overwrite without supportsOverwrite or 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.

Licenses and third-party notices are listed in each package.