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

Add support for live preview and live navigation #2

Merged
merged 8 commits into from
Jun 20, 2016
Merged

Add support for live preview and live navigation #2

merged 8 commits into from
Jun 20, 2016

Conversation

xoofx
Copy link
Collaborator

@xoofx xoofx commented Jun 20, 2016

Hi @madskristensen,

I have started to work on:

  • a live preview that would update the document at every typing (after a 0.5s delay of pause)
  • a live navigation that scrolls according to the top level line

This PR is not yet ready for merge, it's a work in progress! Just wanted to get early feedback on it.

The live preview seems working well.
For the live navigation, I have yet to found a more reliable way to scroll to the best suitable position. It may also be more relevant to keep the previous system (offset in document) and provide a settings+a button to disable live navigation sync.

@madskristensen
Copy link
Owner

madskristensen commented Jun 20, 2016

Man, that looks sweet. That's my early feedback :)

It's been a big user request for years in Web Essentials to sync scrolling in the preview window. One way of doing it is to use the WebBrowser class as a ScriptObject to communicate with the HtmlDocument instance to make it scroll.

@xoofx
Copy link
Collaborator Author

xoofx commented Jun 20, 2016

The navigation sync is actually not so bad after testing it on several big markdown documents. It is using a new markdig extension that can emit pragma-line HTML ids so that synchronization is quite precise. There are a few cases may be where it is not ideal.

Not sure now how I can add a checkbox somewhere on the document/adornment to allow to disable live navigation sync on the document being edited (I will have to add this also at the general settings level)

@madskristensen
Copy link
Owner

madskristensen commented Jun 20, 2016

That's great. You can add a Boolean option in Options.cs for now

@madskristensen
Copy link
Owner

madskristensen commented Jun 20, 2016

Instead of an adornment, I know how to add custom XAML into the status bar. We can add an icon that looks like a sync symbol that the user can click to toggle enable/disable. It would still persist the setting in Options.cs so we need that regardless. What do you think about that?

@xoofx
Copy link
Collaborator Author

xoofx commented Jun 20, 2016

I have added the option to the settings.

Instead of an adornment, I know how to add custom XAML into the status bar. We can add an icon that looks like a sync symbol that the user can click to toggle enable/disable. It would still persist the setting in Options.cs so we need that regardless

Actually, I was more thinking about a document level checkbox that takes the value from the general option (when initialized), but then can be changed on the document being edited. This way, if sync is not working well for a particular doc we can disable it, and keep sync for others. Thoughts?

@madskristensen
Copy link
Owner

Yes, that makes sense. That's exactly what my idea of a statusbar icon would be. Instead of a checkbox in the editor itself, it is a sync symbol in the status bar that can be toggled. VSCode uses the status bar for this type of stuff and we could do the same

@madskristensen
Copy link
Owner

here's a screenshot of VSCode statusbar

image

@xoofx
Copy link
Collaborator Author

xoofx commented Jun 20, 2016

Let me know if you want me to do more things on this branch or you will be able to start from this state.

@madskristensen
Copy link
Owner

We can add the bells and whistles later. Is it ready to be merged?

@xoofx
Copy link
Collaborator Author

xoofx commented Jun 20, 2016

Somehow yes, but test it before!

@madskristensen
Copy link
Owner

Ok. I'll do it first thing in the morning.

@madskristensen madskristensen merged commit 696fcce into madskristensen:master Jun 20, 2016
@madskristensen
Copy link
Owner

Oh man, it works great. This is a great experience that I know people will love

@madskristensen
Copy link
Owner

It doesn't always scroll. It may be when there are no headings and only inline/paragraph content in the file. Can we make it so that when you move the cursor or click in the editor that the preview window syncs to that location?

@xoofx xoofx deleted the live_preview_and_navigation branch June 21, 2016 00:25
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.

None yet

2 participants