Skip to content

Help test and implement the markdown custom editor preview #84520

Closed

Description

@mjbvz

Background

Users would like the markdown preview to be opened when they open a markdown file. Feature requests #2766 and #54776 track a few different use cases, but the main one we are interested in right now is: when I open a markdown file, instead of opening the normal text editor, the markdown preview is opened instead.

This can now be implemented using custom editors: #77131

Current Status

The current insiders (1.41) contributes a custom editor for the markdown preview. It is not enabled by default by can be selected by running View: Reopen with with a markdown file open. You can also use the following setting to always open markdown files in preview mode instead of in the editor:

"workbench.editorAssociations": [
    {
        "viewType": "vscode.markdown.preview.editor",
        "filenamePattern": "*.md"
    }
]

The custom editor should look identical to the existing markdown preview.

How to help

The markdown custom editor needs testing and polish before it can be shipped. We are looking for the community to drive this. I've created this issue to collect feedback and discussion of this work.

Before we ship this feature, we need to make sure that custom editor based previews work as existing VS Code users would expect and work with the existing markdown preview's behavior and settings. This issue is intentionally open ended. Try playing around with the custom editor based markdown preview and exploring what works as expected and what doesn't

Some starting areas to focus on:

  • How do custom editor based previews Integrate with existing markdown previews?
  • Switching editors.
  • Scrolling.
  • Links. (For example, where do links open?)
  • Markdown security settings.

Activity

  1. added
    help wanted
    markdown-ext
    good first issue
    on Nov 11, 2019
  2. added this to the Backlog milestone on Nov 11, 2019
  3. mjbvz commented on Nov 13, 2019

    @mjbvz
    ContributorAuthor

    Thanks. Can you please split individual problems to separate issue so we can track them better (link them back to this issue).

    Also note that I am looking for the community to implement this, so please submit PRs with fixes if you want to see this stabilized.

  4. sverg1 commented on Nov 18, 2019

    @sverg1
    Contributor

    Matt Bierner (@mjbvz) @jcgerhard I am considering tackling the editor toggle; this will be my first dive into open-source and could use a quick pointer as to where I should be looking! I have the preview Markdown editor up and running on my fork, but where may I look in src? I can make and link an issue once I get my bearings.

  5. mjbvz commented on Nov 19, 2019

    @mjbvz
    ContributorAuthor

    sverg1 This should likely not be a markdown specific command but a generic for custom editors. Something like: toggle custom editor that would switch between VS Code's standard text editor and the custom one (i.e. the markdown preview)

    Here's where the custom editor commands live:

    const REOPEN_WITH_COMMAND_ID = 'reOpenWith';

    The ICustomEditorService and IEditorService should have the functionality you need to implement this:

    • Getting the currently active editor.
    • Switching it to the custom editor or to the default text editor.

    Since this change would be going into core VS Code, it should not hardcode anything markdown specific

  6. msindone commented on Dec 8, 2019

    @msindone

    Matt Bierner (@mjbvz) @jcgerhard Is help still wanted on the Outline View? This would also be my first dive into open source, so I was wondering if this would be a good task to work on and if I could have quick pointer as to where I should be looking in src? I have the preview Markdown editor up and running on my fork. Thanks!

  7. thadras commented on Feb 3, 2020

    @thadras

    Usage notes of odd and errant behavior when double clicking within an md file
    that has been opened within a preview viewport.

    Given that the Markdown extension allows clicking links of other md files to open the target file, such is done within the tab of the referrer. Whereas, one might suspect another tab would have been opened to preview the target file.

    Further, when double-clicking regular text within the file's preview, rather than open a tab with an editor view, the application throws an error:

      ERR Failed to show text document file://<currently-previewed>.md, should show in editor #undefined: Error: Failed to show text document file://<currently-previewed>.md, should show in editor #undefined
    	at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:641:878
    

    Also, the scroll position of the preview tab does not persist after changing away from, and then returning to the tab, as the above mentioned reference links to a known issue.

    Otherwise, the experimental feature works as expected.

  8. added
    feature-request
    on Nov 3, 2020
  9. s1-en commented on Nov 10, 2020

    @s1-en

    I want to report that Markdown files opened by default in the preview that have links that point to other Markdown files do not seem to load the other file. No matter how many times I click the link just wouldn't work.

    However, if I double-click the preview (hence entering edit mode) and then open up the preview again from the icon in the top right, then the links work fine.

  10. jasonwilliams commented on Dec 8, 2020

    @jasonwilliams
    Contributor

    Hey Matt Bierner (@mjbvz) i really like this, does this work on stable VSCode? I can see the View: Reopen with option that does work, but that config doesn't work in the settings.json.

    I agree with @jcgerhard there needs to be some variable bindings to switch back and forth between preview and code.
    But apart from that, what's holding this up?

  11. 1 remaining item

  12. jasonwilliams commented on Dec 8, 2020

    @jasonwilliams
    Contributor

    Thanks. Can you please split individual problems to separate issue so we can track them better (link them back to this issue).

    Also note that I am looking for the community to implement this, so please submit PRs with fixes if you want to see this stabilized.

    I agree, a lot of fixes here can be broken up.
    Matt Bierner (@mjbvz) can I make an issue for toggling preview/editing mode with a keybinding? (in the background this would call View: Reopen with). This sounds like it could be done in isolation

  13. jasonwilliams commented on Dec 22, 2020

    @jasonwilliams
    Contributor

    CMD+E = Toggle edit mode

    CMD + E is already assigned to "Find with selection" We would need another shortcut that lets you toggle between edit mode and preview. Suggestions welcome.

    "ctrl + cmd + p" could work

  14. jasonwilliams commented on Dec 22, 2020

    @jasonwilliams
    Contributor

    As per Matt Bierner (@mjbvz) advice I've created a scoped-down issue which just focuses on being able to toggle back and forth from the custom editor to the normal one.

    #113298

    Matt Bierner (@mjbvz) do you know how hard/easy it is to keep state so when opening a new document you're still using the custom editor of vice versa?

  15. added
    hackathon
    and removed
    hackathon
    on Feb 8, 2021
  16. ssmooncoder commented on Aug 6, 2021

    @ssmooncoder

    Find widget Cmd/Ctrl + F doesn't seem to work in preview.

  17. ssmooncoder commented on Aug 10, 2021

    @ssmooncoder

    this._register(vscode.window.registerCustomEditorProvider(this.customEditorViewType, this));

    Passing webviewOptions: {enableFindWidget: true} as the third param seems to fix this problem.

  18. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Nov 5, 2021
  19. locked and limited conversation to collaborators on Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestgood first issuehelp wantedinsiders-releasedmarkdown-exton-testplan

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions