Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spatial Graph Mode #165

Merged
merged 90 commits into from
Nov 23, 2020
Merged

Conversation

tntmarket
Copy link
Contributor

@tntmarket tntmarket commented Oct 11, 2020

Demo

Spatial Mode

Save and restore previously created mind maps!

Save and Restore Workspaces

Copy the saved state using Ctrl+Shift+s, and paste it into a page. Then press Ctrl+Shift+o while on the page to restore the layout.

Keyboard Shortcuts (Works with Vim!):

  • Ctrl + h/j/k/l to jump between panels
  • Ctrl + Shift + h/j/k/l to drag panels
  • Ctrl + =/- to zoom

Jumping Between Panels

Pan/zoom with keyboard, will automatically select the vim panel in the middle of the screen.

Select multiple nodes with shift+click:

Multiselect Demo

I got it to work with a custom theme, but I had to remove css selectors that ended with [style*=".."], otherwise it lags with more than 5 pages.

Implementation Overview

Cytoscape is rendered in the background. Roam is click-throughable, in order to interact with cytoscape, but Roam Panels themselves are clickable.

Sidebar pages are diffed between opens/closes, to track when nodes should be added/removed.

The last interacted with panel is tracked, to determine which edges to draw.

Organization structure:

  • graph-visualization => manages node/edge state
  • spatial-container => sets up extra dom containers and styles
  • spatial-viewport => manages the camera and selections
  • spatial-dom-synchronizer => updates dom panels to match the graph visualization
  • roam-panel => "panels" are now shared between vim mode and spatial mode
  • roam-panel-origin => keeps track of which panel opened another panels, to draw edges

Wishlist

  • Opening a page should draw an edge (without having forward/back navigating draw edges)
  • Manually resize panels (this seems non-trivial)
  • Be able to "full screen" a panel temporarily

@Stvad
Copy link
Member

Stvad commented Oct 13, 2020

Why not inject css in the code? :)

@Stvad
Copy link
Member

Stvad commented Oct 13, 2020

Also I got weird results when Leyendecker theme was enabled. may want to add to instructions to disable custom themes?

@Stvad
Copy link
Member

Stvad commented Oct 13, 2020

Want to be able to dynamically resize cards (and maybe shortcuts for "make larger/smaller")

@Stvad
Copy link
Member

Stvad commented Oct 13, 2020

Also totally breaks intuitions for vim navigation between panels (where is next? where is down?). probably would want some id and a way to "move to panel x"

@Stvad
Copy link
Member

Stvad commented Oct 13, 2020

vim navigation up/down does not scroll panels =\

@Stvad
Copy link
Member

Stvad commented Oct 13, 2020

UX: I'd preserve scrolling up/down/left/right and would do zooming with some modifier pressed + scrolling

@Stvad
Copy link
Member

Stvad commented Oct 13, 2020

Surfingkeys help with between panel navigation.
Another wish: a shortcut to center the active panel (and/or a mode when focus follows panel switch)

@tntmarket
Copy link
Contributor Author

Also totally breaks intuitions for vim navigation between panels (where is next? where is down?). probably would want some id and a way to "move to panel x"

Long term, I'd like to support navigating left/right/up/down (with elementAtPos possibly).

Or maybe a "cycle through edges" shortcut

@tntmarket
Copy link
Contributor Author

Why not inject css in the code? :)

I'll do that once I finalize it, it was easier to play with the css in Stylus during development

@tntmarket
Copy link
Contributor Author

vim navigation up/down does not scroll panels =\

Yeah, #160 fixes scrolling. I'll resume it at some point

@tntmarket tntmarket force-pushed the spatial_graph_mode branch 4 times, most recently from feabb39 to 5a9057f Compare October 16, 2020 23:47
@tntmarket
Copy link
Contributor Author

UX: I'd preserve scrolling up/down/left/right and would do zooming with some modifier pressed + scrolling

This might be non-trivial, I didn't find anything in Cytoscape's API to change the default controls :(

@Stvad
Copy link
Member

Stvad commented Nov 8, 2020

Ctrl + arrow key conflicts with Mac global shortcuts (next/prev desktop, show all apps)

Does Ctrl + Shift + arrow work? (I forgot the default shortcuts)

Up/down are already taken by other toolkit shortcuts. Left/right should work

@Stvad
Copy link
Member

Stvad commented Nov 8, 2020

In the new version going between insert and normal mode causes the view to blink/re-render :(
Also it seems it causes the switch to insert mode to fail, when it's initiated by mouse?

@tntmarket
Copy link
Contributor Author

tntmarket commented Nov 9, 2020

In the new version going between insert and normal mode causes the view to blink/re-render :(
Also it seems it causes the switch to insert mode to fail, when it's initiated by mouse?

Yeah I get the blinking too. I currently re-render when editing blocks, in order to dynamically resize the panel as blocks are added/removed, or newlines are added. One idea is to re-render only when the difference is large enough, to avoid annoying flickers on microscopic changes. I'll try it out.

Entering insert mode with mouse is currently working for me.

@tntmarket
Copy link
Contributor Author

Ctrl + arrow key conflicts with Mac global shortcuts (next/prev desktop, show all apps)

Does Ctrl + Shift + arrow work? (I forgot the default shortcuts)

Up/down are already taken by other toolkit shortcuts. Left/right should work

I used Ctrl + Command + Arrow

@tntmarket
Copy link
Contributor Author

Ok @Stvad, I'm confident enough to merge it into master now.

It actually doesn't work in Firefox due to cytoscape/cytoscape.js-cola#51, but that seems non-trivial to fix, so I put a warning in the options UI.

Other than:

  • some refactoring of the roam-event
  • making vim mode use each sidebar page as an individual panel if graph mode is on

everything else is isolated from existing features. So I think there's a low chance this will break functionality for existing users.

I did some regression testing for vim + no spatial mode, and didn't find any issues.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Stvad
Copy link
Member

Stvad commented Nov 23, 2020

🔥

@Stvad Stvad merged commit 56995ed into roam-unofficial:master Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants