-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
lots of functions for creating blocks + demo #19
Conversation
Tested demo and seems to work great. Haven't looked at code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great!
src/ts/utils/roam.ts
Outdated
async createSiblingBelow() { | ||
this.moveCursorToEnd(); | ||
await Keyboard.pressEnter(20); | ||
await Keyboard.pressShiftTab(40); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 40? Also we probably want to extract 20
to a constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as with the others, trial and error... 20 was fine when testing the command itself, but when building the demo, I was getting weird results and this solved it.
@panpiotrs mentioned using MutationObserver
, and that it could make things slow, but I assume that meant having it always-on watching for user interactions... if we only use it when executing the script, shouldn't be a problem. Something to test in the next iterations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Making constant alongside one with 20?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you created standardDelay
for that already, so I changed it to 20.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
standardDelay was intentionally 0, but I'm not sure if it's a right decision or if it should be 20.
With your latest change there is no way to specify anything less then 20 though, which I find worrying. As I said above - I'm not sure what standard one should be, but if it's not 0 then the passed in value should probably be not additional delay but delay override
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense - see if it's better now.
by the way just tested the demo with 0 delay and worked... for a few times, and on a blank page only, then broke again. There's no magic number since it's heavily dependant on page size - which is obvious given we really feel the delay when editing a long page.
don't want to spend too much time tinkering this delay thing since it's clear the other option must be better.
For now, 20 seems to work even for longer pages. And now can be overriden if needed
async createBlockAtTop(forceCreation:boolean = false){ | ||
await this.activateBlock(getFirstTopLevelBlock()); | ||
if (this.getActiveRoamNode()?.text || forceCreation) { | ||
await this.createSiblingAbove(); | ||
} | ||
}, | ||
|
||
async createBlockAtBottom(forceCreation:boolean = false){ | ||
await this.activateBlock(getLastTopLevelBlock()); | ||
if (this.getActiveRoamNode()?.text || forceCreation) { | ||
await this.createSiblingBelow(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed in #20
This has changed since the so much since the other pr that it needed its own branch.
Demo works on
ctrl-shift-u
, can delete it later.