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

lots of functions for creating blocks + demo #19

Merged
merged 19 commits into from
Feb 25, 2020
Merged

Conversation

dalmo3
Copy link
Contributor

@dalmo3 dalmo3 commented Feb 18, 2020

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.

@dalmo3 dalmo3 requested review from Stvad and PiotrSss and removed request for Stvad February 18, 2020 11:43
@houshuang
Copy link

Tested demo and seems to work great. Haven't looked at code

src/ts/utils/dom.ts Outdated Show resolved Hide resolved
Copy link
Member

@Stvad Stvad left a 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 Show resolved Hide resolved
src/ts/contentScripts/dispatcher/index.ts Outdated Show resolved Hide resolved
src/ts/utils/dom.ts Outdated Show resolved Hide resolved
src/ts/utils/mouse.ts Outdated Show resolved Hide resolved
src/ts/utils/roam.ts Outdated Show resolved Hide resolved
async createSiblingBelow() {
this.moveCursorToEnd();
await Keyboard.pressEnter(20);
await Keyboard.pressShiftTab(40);
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

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

src/ts/utils/roam.ts Show resolved Hide resolved
src/ts/utils/roam.ts Outdated Show resolved Hide resolved
src/ts/utils/roam.ts Outdated Show resolved Hide resolved
src/ts/utils/roam.ts Outdated Show resolved Hide resolved
@Stvad Stvad mentioned this pull request Feb 20, 2020
src/ts/utils/roam.ts Outdated Show resolved Hide resolved
src/ts/utils/dom.ts Outdated Show resolved Hide resolved
src/ts/utils/roam.ts Outdated Show resolved Hide resolved
Comment on lines +117 to +128
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();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed in #20

@Stvad Stvad merged commit a0257f1 into master Feb 25, 2020
@dalmo3 dalmo3 mentioned this pull request Feb 29, 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.

3 participants