Open oliver-sanders opened 5 years ago
Hopefully this one we should be able to find a component that does most of what we need, then just use it with none/little customization.
Editor | TextMate Grammars | Display File Streams | Linkable Lines | Large File Handling | Auto Completion | Diffs | RE Search |
---|---|---|---|---|---|---|---|
Ace | Yes | No (would have to implement ourselves) | Yes (syntax highlight) | Yes | |||
CodeMirror | No (needs 3rd party package) | No (would have to implement ourselves) | Yes (syntax highlight) | Yes | |||
Monaco | No (needs 3rd party package) | No (would have to implement ourselves) | Yes (rich) | Yes | |||
Prism.js (read-only) | No | Yes (plugin) | N/A | Yes (syntax highlight) | No? |
Jupyterlab uses codemirror, I found this package which converts textmate grammars for codemirror editors, it's pretty small though :(
What do you mean by "small" there?
0-4 weekly downloads, 11 stars.
Update: trigger edit may use an auto-generated form which reduces the requirements as we no longer require an editor, only a viewer.
Monaco:
Monaco might be a bit heavy weight for us
Unpacked Size 79.5 MB --- https://www.npmjs.com/package/monaco-editor
I think the editor can be lazy-loaded (i.e. loaded only when used in the UI), and it should also be possible to tree-shake it, loading only what's actually used in the Cylc UI code (some times it works, some times it doesn't — e.g. I never got Vuetify to unload some modules I was sure it was not using, and I think other users reported a similar issue…).
IIRC, the… vue ui
? vue inspect
? That utility that displays the bundled web application to inspect the Vue app settings… it has a reporting tool to show the size of the artefacts generated, including imported libraries. So someone can import monaco editor (important to import like import { moduleA } from "monaco"
or so, to hint to webpack/etc what's actually used :+1:, instead of import "monaco"
or import * from monaco as bla"
, etc)
(or there are other smaller editors if the UI doesn't need a lot of features in the text editor, like Ace editor for instance - https://ace.c9.io/)
Ace looks pretty good and supports TextMate grammars which is a big win.
Given that we don't need editor functionality we might be better off going with a more light-weight display-only tool for simplicity.
VitePress uses Shikijs which supports TextMate as well as VSCode colour themes:
The monaco editor, whilst 85mb in size can be chunked. There is also a vite plugin: https://www.npmjs.com/package/vite-plugin-monaco-editor
One barrier would be that monaco integrates with webkit, but not rollup as it does not support ESM modules, this could interfere with chunking? Would need to try.
Our requirements are now fairly simplistic (we don't need an editor any more), we could get by with just a syntax highlighter.
I think the main items on the shopping list are:
With bonus marks for:
[1] The TextMate grammar approach does NOT support incremental lexing, so handing a dynamic document involves rendering and re-rendering the same code block over and over. This will need to be handled in an efficient way, and ideally one which doesn't delete the whole component and re-create it from scratch as that would create continuity issues for the user. Note, some systems use WASM code for this which should be a performance win.
The Cylc UI will need a text editor (readonly) for:
Cylc7 Functionality:
cylc cat-log
)cylc review
)[INFO]
).Potential future functionality:
We want an in-browser text editor which:
So here's our shopping list:
1) Syntax highlighting via TextMate grammar.
Additional bonus marks for an editor which:
a) Has auto-completion (e.g. for task names). b) ~Has tabbing with lazy load (e.g. open
job.*
files).~ we will likely rely on lumino for this c) Can elegantly display diffs (e.g. cylc diff). d) Regex search.