Coder Social home page Coder Social logo

boltex / leojs Goto Github PK

View Code? Open in Web Editor NEW
26.0 4.0 1.0 16.06 MB

Leo Literate Editor with Outline in Typescript

Home Page: https://boltex.github.io/leojs/

License: MIT License

JavaScript 8.31% TypeScript 90.37% CSS 0.77% HTML 0.54%
leo-editor literate-programming outline-editor vscode

leojs's People

Contributors

boltex avatar edreamleo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

leojs's Issues

Add the UUID/KSUID gnx string generation capabilities

one of the things that keeps me from using at-file nodes (i.e. with sentinels), is the lack of customization for the node identity's.
i'm aware that this came up a long time ago for leo proper and the issue was shut down (so i was forced to stop using them).

what i'd very much prefer to use are perhaps: KSUID = K-Sortable Unique IDentifier. a globally unique id that also sorts correctly by time. https://github.com/segmentio/ksuid

there are other options of course, but i work on a team and i really don't like/can't have my username and timestamp as the identifier. but ksuid's could even be used across applications.

ideally we could even alias these nodes so that named '#region' references could also/instead be used for imports.

i have much more to say on this, but this is/was one of my major pain points with leo.

thanks for considering.

ksuid background: https://segment.com/blog/a-brief-history-of-the-uuid/

python lib example:
https://pypi.org/project/svix-ksuid/

Create core Leo JS files using Transcrypt

The ekr-tests branch now contains the work. See PR #27.

Run Transcrypt (with -a -b -m -n option), inserting pragmas as needed, on at least these files:

  • leoGlobals.py
  • leoNodes.py
  • leoFind.py (includes cff commands)
  • leoUndo.py
  • leoCommands.py (for iterators). Maybe: create a new file just for c.iterators.

See also Leo issue #1788.

LeoJS icon in sidebar missing in vsc but not vscodium

I no longer see the LeoJS icon in the icon strip at the left of the VSC window. It's there in VSCodium. Without this icon, when I closed the last LeoJS window I could no longer use it until I restarted VSC. I didn't see a setting to restore the icon, and I don't know what if anything I did to cause the situation.

github discussions

Hi Felix, perhaps it might be possible to open the discussions and perhaps wiki sections here on github.
I'd like to contribute some comments here, i.e. some possible advantages of this platform (leojs), and try to draw some attention this project :-D

Revert to saved does not refresh the @button panel

It seems to reload the parts of the outline based on the saved file, but removed or added @buttons in the button panel do not reflect what should be appearing in it from the saved file. (it does not seem to be rebuilt)

Perhaps the revert command does not really destroy and rebuild the commander?

As starting point/ hint to help fix this: There was a similar problem lately in the real Leo which was fixed. So this might be related.

Alt-N, goto-next-clone, does not select proper body text

This is a serious bug that might lead to corrupted data.

Using LeoJS in vscode.dev:

  • Open Leo's github repo: https://github.com/leo-editor/leo-editor
  • Open LeoPyRef.leo in LeoJS.
  • Clone a node containing text. I cloned class NestedSplitterTopLevel (QWidget)
  • Move the clone so it is the last top-level node.
  • Alt-N selects the original (now cloned) node but does not select the proper body text!

It appears that the body text is the text of the node's parent.

Advice for newbies

EKR: After cloning the repo, remember to do npm install in the repo's top-level directory.

Félix: My first recommendation for building good vscode extension development knowledge is to 'git clone' this repo on your pc : https://github.com/microsoft/vscode-extension-samples

tip: do not open the whole thing in vscode, instead, right click one of the subfolders for a particular extension example, choose "open with vscode" and try out or look at the code for a project 'individually'. (to actually run and try a sample instead of just looking at its source code, in each case, a simple "npm install" in the terminal will install all dependencies for any particular example, and then hitting F5 will start the sample in its own window. But you know that already for finishing the basics tutorials ;) hehe)

It gives good examples for distinct and precise aspects of vscode without overwhelming aspects of a full-blown extension which tries to do a dozen things at once.

Markdown writer adds an extra newline after each body written to file

The markdown writer (for @auto nodes) adds an extra newline after each body content when writing files.

** @edreamleo Note: Leo does it but only on nodes with are non-terminal nodes.** (is it a bug also?)

Easily reproduce with this command to clone a minimal reproducible example repo:

git clone https://github.com/boltex/test-markdown.git

And then reproduce with ctrl+shift+w to re-write the markdown file and see the diff it creates.

Errors While Reading Settings In leoSettins.leo

During startup, when leoSettings.leo is read, there is an exception: TypeError: d.get is not a function.

This does not seem to prevent viewing and editing an outline.

reading settings in leoSettings.leo
reading settings in C:/Users/tom/.leo/myLeoSettings.leo
read outline in 0.19 seconds
TypeError: d.get is not a function
	at SettingsTreeParser.parseOpenWithLine (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1107288)
	at SettingsTreeParser.parseOpenWith (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1106787)
	at SettingsTreeParser.doOpenWith (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1103369)
	at SettingsTreeParser.visitNode (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1122680)
	at SettingsTreeParser.traverse (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1109316)
	at async LoadManager.createSettingsDicts (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:927028)
	at async LoadManager.computeLocalSettings (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:926211)
	at async LoadManager.readGlobalSettingsFiles (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:930584)
	at async LoadManager.doPrePluginsInit (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:933058)
	at async LoadManager.load (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:930893)
	at async runLeo (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1809091)
	at async activate (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1816422)
	at async u.n (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6255)
	at async u.m (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6218)
	at async u.l (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:5675)
es_exception called without error!
LeoJS 0.2.5, master branch, build 2f8dca6
2023-12-16 23:36:29 -0500
Node.js v18.15.0, VSCode version 1.85.0
Windows 10 Home x64 (build 10.0.19045)
      home: C:\Users\tom
leo-editor: C:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5

Consider a leoJS-specific settings file

Currently, leoJS reads the standard Leo leoSettings.leo file, and I presume, myLeoSettings.leo. But in the future, there will be a need for settings files specific to leoJS. For example, @button nodes may need to contain contain javascript instead of Python code.

I propose that leoJS should first look for a settings file specific to leoJS. If not found, copy and rename the corresponding Leo file. For example, on startup:

  1. Try to open leoSettingsJS.leo;
  2. If it does not exist, copy leoSettings.leo to leoSettingsJS.leo;
  3. Process leoSettingsJS.leo.

Where Is The Nav Pane?

I thought I remembered that leoInteg had a working Nav tab, but I can't find it in leoJS. I use the Nav tab for almost all my searches, so this is important to me.

LeoJS 0.2.5, master branch, build 2f8dca6
2023-12-16 23:36:29 -0500
Node.js v18.15.0, VSCode version 1.85.0
Windows 10 Home x64 (build 10.0.19045)
      home: C:\Users\tom
leo-editor: C:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5

Make g.os_path_normslashes a do-nothing in leoJS

Leo PR #3241, merged into devel, contains non-controversial changes to Leo as part of Leo issue #3235.

Within Leo itself, g.os_path_normslashes translates backslash to forward slashes, but only on Windows. Imo, g.os_path_normslashes should be a do-nothing method on leoJS:

  • There is no obvious reason why the hack in g.os_path_normslashes should be necessary,
    even on Windows.
  • Messing with os.sep might (as an edge case) invalidate otherwise valid file specs.
  • At present, making g.os_path_normslashes causes weird problems in Leo's Qt drawing code,
    but these weird problems do not justify propagating the hack to leoJS.
  • leoJS should follow vs-code's handling of (external) files:
    leoJS should treat Windows file specs differently only if vs-code explicitly does so.

Summary

  • The hack in g.os_path_normslashes is non-intuitive and troubling. I would like to remove it from Leo.
  • leoJS need not (should not!) contain the same hack. Now it the best time to make g.os_path_normslashes a do-nothing in leoJS.
  • In leoJS, adding calls to g.os_path_normslashes per Leo PR #3241 would encapsulate the dubious code to a single method. Comments in g.os_path_normslashes can discuss and justify the difference between Leo and leoJS.

Design of leojs

This issue continues Leo issue #1774. This is the proper place for this discussion.

Félix: leojs...would be most useful to test things on the [vs-code/js] side, without communicating to python / bridge etc., in order to sometimes get some help from vscode's team when trying to have them install and run the extension to test things, and show live-examples of what an (non-literate) outliner can do, without the need for them to also get leo setup. And I would ultimately merge the project into leoInteg. It could also be a starting point for someone who wants to re-do leo in js / rust/webassembly"

EKR: Preliminary design

Hurray! leojs doesn't have to do any of the following.

  • Gui stuff, including key handling and themes!
  • Standard text-editing commands, including text-oriented undo/redo.
  • Abbreviations that expand to text only.
  • Code completion.
  • Settings, including leoConfig.py, leoSettings.py, and myLeoSettings.leo.
    vs-code should present Leo's settings organized as an outline.
    Happily, many of Leo's present settings are not needed in vs-code.
  • @test and @suite. leojs should have unit tests.
    These unit tests should based on standard js testing frameworks,
    not on leoTest.py (or even leoTest2.py)
  • leoBridge.py. leojs might use Leo's bridge, but leojs need not re-implement the bridge.

The kernel of leojs

  • A transliteration of Leo's DOM: positions, vnodes, iterators.
  • A transliteration of Leo-specific commands, commands not found in other editors.
    • Leo's essential commands must be done first:
      • outline-oriented find,
      • undo/redo
    • Leo's signature commands probably should be done next:
      • clone-find,
      • git-diff and git-diff-pr
      • execute-script (composing scripts from outlines).

Later improvements

The following Leonine features could be postponed until after all essential features are in place:

  • A transliteration of the @clean update algorithm.
    We might be happy using @file or even @nosent for a long time.
  • Abbreviations that expand to outlines.
  • Leonine scripting: access to c, g and p.
    Félix: leojs might even have access to the vs-code base!
  • Leo's importers.
  • Leo-specific plugins.

Custom Menus

In Leo, the user can add menu items and even entire menus by adding them to the @settings. I realize that VSC menus work differently, but I have come to depend on some of my custom additions. Some of them contain standard Leo commands, some my own command scripts.

Is there going to be a path to creating the equivalent of Leo's custom menus and menu items?

CUE Project

Recently I've been doing a lot of work with the CUE language + project.
It's really a new paradigm of structured data + logic programming.

One of the features of the language is non-locality, i.e. where you put things doesn't matter,
which makes using Leo and Cue a very nice pair.

The project started at Google but now their independent, funded, and open source.
Also, they have a growing presence in the CNCF (Cloud Native Computing Foundation),
so LeoJS could be run remotely and fit in very well here (imho).

https://cuelang.org/
https://cuetorials.com/introduction/

I recommend anyone interested to join their slack channel.

Block all commands except 'setLeoID' if leoID is 'None' or falsy.

For now, cancelling leo id input sets it to 'None'.

But It should instead be set to empty string, and let the startup finish, but set the leoReadyFlag to false (making all commands unavailable except 'setLeoID') until a valid leo id is entered via the setLeoId command.

(Once a valid leoid is entered the 'setLeoID' command should then be hidden and unavailable.

Using myLeojs.leo and leojs.leo.

leojs.leo is the "official" .leo file for this project.

Individual contributors should make a copy of leojs.leo, called myLeojs.leo, for their own use. .gitignore ignores myLeojs.leo, so you can change it freely.

Important: leojs.leo uses @clean for all files. This means that all collaborators should keep the outline structure of all external files in sync! Otherwise, the @clean update algorithm will "assign" lines to the wrong nodes when reading @clean files. So the rule is:

Update leojs.leo whenever adding, moving or deleting nodes in an @clean tree.

It is easy to update leojs.leo from myLeojs.leo. Just use @button write-leojs. This script writes the top-level 'Startup', 'Documentation', and 'Code' nodes to leojs.leo. The script checks that it is, in fact, being run from myLeojs.leo.

The name of the body tab should be f"LeoJS: {c.p.h}"

The present name is "LEOJS: BODY".

At minimum, it should be "LeoJS: Body". There is no need for all caps.

A static name is fine during startup.

After startup, I recommend the following:

  • The name of the tab should be LeoJS: followed by c.p.h.
  • It's fine not to update the tab's name while rapidly changing c.p.
    In other words, it may be best to update the tab's name at idle time.

Ctrl-Click UNL navigation does not work

I have a node in my Workbook that contains some unl strings to other nodes both in and outside of the Workbook so I can test Ctrl-click navigation. This navigation works in Leo but not in leoJS.

LeoJS 0.2.6, master branch, build 91d1141
2023-12-21 23:06:09 -0500
Node.js v18.15.0, VSCode version 1.85.1
Windows 10 Home x64 (build 10.0.19045)

Do more of the editCommands.py functionality

Although the text operations are more easily done with vscode's commands, it would be cool to have the rest of the editCommands.py content translated into typescript. (Most of those functions are easy enough for chatGPT to convert)

Add settings to customize visible command-icons over panels

I'm not a big fan of icons in general. Here are two (somewhat conflicting!) suggestions:

  • Add an option to suppress the icons in the 'Outline' pane.
    These icons obscure the path, which imo is much more important.
    True, these icons disappear when focus is outside the 'Outline' are, but an option to dispense with them would be welcome.

  • Add an icon/menu item to go to the LeoJS: Welcome pane.
    This would complement the standard "gear" icon.
    This suggestion is less important imo.

Script Buttons Should Not Be Added If Their Code Cannot Compile

I noticed that when I open an outline, I see buttons that I've defined in myLeoSettings.leo. But they don't work since they contain Python code that works with Leo. Also, the right-click goto Script does not work with them.

These buttons should not be shown.

Add @button write-leojs to leojs.leo

Run this from myLeojs.leo to update leojs.leo.

Such a script is especially important because leojs.leo uses @clean nodes throughout.

This script will be based on the @button write-leoPyRef in leoPyRef.leo, modified as necessary.

Problem with the '.ini' importer

From @tbpassin :

All right, it installed in vsc and it did open an outline. I saw a lot of errors like this:

reading settings in C:/Users/tom/.leo/workbook.leo
TypeError: Cannot read properties of undefined (reading 'trim')
at Ini_Importer.find_blocks (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1507413)
at Ini_Importer.gen_block (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1508153)
at Ini_Importer.gen_lines (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1511889)
at Ini_Importer.import_from_string (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1512400)
at exports.do_import (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1522910)
at LeoImportCommands.createOutline (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1338218)
at async AtFile.readOneAtAutoNode (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:955878)
at async AtFile.readFileAtPosition (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:954544)
at async AtFile.readAll (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:953359)
at async FileCommands.readExternalFiles (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1151896)
at async FileCommands._getLeoFileByName (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1151493)
at async FileCommands.getAnyLeoFileByName (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1149953)
at async LoadManager.openFileByName (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:937514)
at async LoadManager.loadLocalFile (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:936309)
at async SessionManager.load_session (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1439599)
at async LoadManager.doPostPluginsInit (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:932259)
at async LoadManager.load (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:931126)
at async runLeo (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1807739)
at async activate (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1815070)
at async u.n (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6255)
at async u.m (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6218)
at async u.l (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:5675)

How To Add Tab frames To VSC Log Panel

leoJS logs to a tab in one of the standard VSC panes, usually located at the bottom right of the VSC window. When there is time to write up some guidance on programming leoJS, please explain how to add another tab there and communicate with it.

In Leo, I have some applications that live in a tab in the Log pane, and I'd like to be able to do something similar in leoJS. They need to be able to respond to user typed input and clicks, and to display clickable links that navigate to places in the outline.

Use @clean for package.json

Alas, vs-code will accept neither '#' comments nor html block comments in package.json. This could be called a buglet in the vs-code parser, but we are stuck with it. So...

@file can not be used for package.json

@clean is good enough, provided that leojs.leo is kept up to date with @button write-leojs.

Compatibility with Eclipse Theia IDE

The Theia IDE [https://theia-ide.org/] is a compatible alternative to VSCode. They're doing some very interesting work although it's still in the earlier stages. Particularly paired with the work that TypeFox [https://www.typefox.io/] is doing with Langium, Sprotty and GLSP (the Graphical Language Server protocol) makes this very compelling.

In theory, VSCode plugins and Language Servers are fully compatible with Theia, just thought it was worth pointing out and having a look at.

Also, VSCode sometimes seems to take over, so to have your code in VSCode, with Leo2 running separately in Theia might be a bit more straight-forward for some users.

"es_exception called without error!" - a frequently seen message

Introducing a deliberate error into a script (using print()) produces the message, as do other errors -

exception executing script
ReferenceError: print is not defined
	at eval (eval at executeScriptHelper (c:\Users\tom\.vscode-oss\extensions\boltex.leojs-0.2.8-universal\dist\extension-node.js:2:1065610), <anonymous>:9:1)
	at eval (eval at executeScriptHelper (c:\Users\tom\.vscode-oss\extensions\boltex.leojs-0.2.8-universal\dist\extension-node.js:2:1065610), <anonymous>:13:3)
	at Commands.executeScriptHelper (c:\Users\tom\.vscode-oss\extensions\boltex.leojs-0.2.8-universal\dist\extension-node.js:2:1065648)
	at Commands.executeScript (c:\Users\tom\.vscode-oss\extensions\boltex.leojs-0.2.8-universal\dist\extension-node.js:2:1064871)
es_exception called without error!
saved: workbook.leo

It seems to be a minor error, but it seems pointless it it gets omitted over and over. The exclamation mark at the end becomes annoying, too.

Finish support restructured text (rST) in leoRst.ts

Most of leoRst.ts is implemented, but the following lines importing the 3rd party libraries to handle restructured text (rST) in leoRst.py can not easily be reproduces in leoRst.ts, preventing the whole of the rst functionality to run:

# Third-part imports...
try:
    import docutils
    import docutils.core
    from docutils import parsers
    from docutils.parsers import rst
except Exception:
    docutils = None  # type:ignore

Find some libraries to do the equivalent, or implement this functionality from scratch (or via transliterating the python sources) to enable the rst functionality in LeoJS.

Keyboard navigation seems broken when outline is hoisted.

To reproduce: hoist a node and try to navigate its hoisted suboutline with the arrow keys.

Note: the top icons above the outline seem to change so it looks like the 'refresh' cycle only has 'states' refreshing but not the outline and body pane themselves.

About info issues

I'll use info issues to document what I learn about vs-code, js/ts, etc. that might be valuable for others who might want to join this project.

Organize package.json with child nodes

See PR #23 for the ekr-scripts2 branch.

package.json contains a lot of data. Make the JSON as Leonine as possible by adding separate nodes for various entries.

  • Write: script: split contributes/command section of package.json.
  • Write: script: split the "contributes/menus" section of package.json.
  • Write: Script: split the "contributes/keybindings" section of package.json.
  • Move the generated nodes to be children of @clean package.json.

After running these scripts, it will be easy to alphabetize nodes and organize them with organizer nodes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.