Liking cljdoc? Tell your friends :D

Apsara

Editor macros in ClojureScript.

Apsara is a ClojureScript library for building editors. It has been tested in browsers, but should work in any environment that exposes a DOM like tree (like React Native).

Yet Another ...

There are many editors out there, so why another one? While other editors are stand alone applications Apsara is a library meant to be embedded in an application. Spreadsheets, application consoles, REPL interfaces and Literate Programming documents to name a few.

Usage

TBD

Design

REDL - Read Evaluate Display Loop

If a REPL loop only appends data to the bottom of the screen, then a REDL loop is capable of updating any part of the screen.

READ.

As text is entered, input is read. This includes handling of non-printable characters like delete, or input from a mouse. The meaning of these inputs is determined in the next phase.

EVALUATE.

There are at least two levels of evaluation. First the evaluation of the particular input operation - like appending or deleting a character. Second, evaluation of the string input. Consider this JavaScript snippet.

ar.map((t) => t.true ? 1 : 0).reduce((total, num) => total + num);

If the editor is required to highlight the syntax then it is required to understand JavaScript in some way. Ususally this is done by matching the string against a set of regular expressions. But this is not the only way. On a console, for example, it could mean dispatching the string to a remote server. So whatever needs to be done here is context specific.

DISPLAY.

After the input is evaluated the display needs to be updated. Apsara's display component, also called the renderer, exposes a DOM like model called hiccup that can be manipulated with the VDOM APIs. In the browser, the hiccup model is rendered as React components using the excellent Reagent library.

LOOP.

The loop ties everything together. Since Apsara is part of a larger application the loop is usually run by the hosting platform. For browser based applications the loop is part of the JavaScript evaluation.

Empty Shell

All parts of REDL can be swapped making Apsara's core very small. If there is one thing that is novel about Apsara, it is the formalization of the idea that editors can be built from these four parts.

License

Copyright © 2022 Ajay Mendez

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close