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

Allow extensions to contribute getting started content #119097

Closed
JacksonKearl opened this issue Mar 16, 2021 · 11 comments
Closed

Allow extensions to contribute getting started content #119097

JacksonKearl opened this issue Mar 16, 2021 · 11 comments

Comments

@JacksonKearl
Copy link
Contributor

JacksonKearl commented Mar 16, 2021

We want to allow extensions to contribute items to the welcome page's getting started section:
image
image

Using a package.json like this:

		"welcomeCategories": [
			{
				"id": "exampleProject",
				"title": "Turn Markdown into HTML",
				"description": "Use this sample project to learn how to convert Markdown to HTML!"
			}
		],
		"welcomeItems": {
			"exampleProject": [
				{
					"id": "md-to-html.openExample",
					"title": "Open an example folder",
					"description": "To start, try opening an example folder that has been preconfigured for this tutorial. This is optional, but helps for following along!",
					"button": {
						"title": "Open Example",
						"command": "md-to-html.openExample"
					},
					"media": {
						"path": "media/example-project.png",
						"altText": "example project"
					}
				},
				{
					"id": "md-to-html.showPreview",
					"title": "Preview your Markdown",
					"description": "Open a markdown file and click the \"Open Preview\" button at the top of the screen to see a preview of your file. This is technically optional, but it updates live and is helpful to check when creating your content!",
					"button": {
						"title": "Open Markdown File",
						"command": "md-to-html.openMarkdown"
					},
					"media": {
						"path": "media/preview.png",
						"altText": "preview"
					},
					"doneOn": {"command": "markdown.showPreviewToSide" } 
				},
				{
					"id": "md-to-html.convertToHTML",
					"title": "Create your .html file",
					"description": "To create the html file, run \"Convert Document to HTML\" from the editor actions context menu, behind the three dots top of the screen. This will create an .html file along side the markdown file.",
					"button": {
						"title": "Open Markdown File",
						"command": "md-to-html.openMarkdown"
					},
					"media": {
						"path": "media/convert-option.png",
						"altText": "showing editor actions context menu"
					},
					"doneOn": {"command": "md-to-html.convertToHTML" }
				},
				{
					"id": "md-to-html.openInBrowser",
					"title": "Open your .html file in the browser",
					"description": "Test that everything worked by opening the .html file in your browser. First open the html file in vscode, then right click in the editor and choose \"Open in Default Browser\".",
					"button": {
						"title": "Open HTML File",
						"command": "md-to-html.openHTML"
					},
					"media": {
						"path": "media/open-in-browser.png",
						"altText": "use editor context menu to open an .html file in your browser"
					},
					"doneOn": {"command": "extension.openInDefaultBrowser" }
				},
				{
					"id": "md-to-html.addKeybinding",
					"title": "Create a keyboard shortcut",
					"description": "That's all! You can share that single .html file with anyone without needing to bundle the images. To make this even easier in the future, consider adding a keybinding for the \"Convert Document to HTML\" command.",
					"button": {
						"title": "Add a keybinding",
						"command": "md-to-html.addKeybinding"
					},
					"media": {
						"path": "media/add-keybinding.png",
						"altText": "use the keybindings editor to add a keybinding for this command"
					}
				}
			]
		},

This is the change to the extension contributions interface:

export interface IExtensionContributions {
        .....
	welcomeItems?: { [category: string]: IWelcomeItem[] };
	welcomeCategories?: IWelcomeCategory[];
        .....
}
export interface IWelcomeItem {
	readonly id: string;
	readonly title: string;
	readonly description: string;
	readonly button: { title: string } & ({ command?: never, link: string } | { command: string, link?: never }),
	readonly media: { path: string | { hc: string, light: string, dark: string }, altText: string },
	readonly doneOn?:
	| { event: string; command?: never }
	| { event?: never; command: string };
	readonly when?: string;
}

export interface IWelcomeCategory {
	readonly id: string,
	readonly title: string;
	readonly description: string;
	readonly when?: string;
}
@JacksonKearl JacksonKearl self-assigned this Mar 16, 2021
@JacksonKearl JacksonKearl added this to the March 2021 milestone Mar 16, 2021
@JacksonKearl JacksonKearl added api getting-started feature-request Request for new features or functionality labels Mar 16, 2021
@JacksonKearl
Copy link
Contributor Author

JacksonKearl commented Mar 17, 2021

Updated based on feedback from API discussion:

  • Rather than a split categories/items contribution point, use a single large object
  • walkthroughs as top level contribution point (generalizable to getting started, tips&tricks, and troubleshooting), tasks for the individual items
  • Simplified image contribution - now just a single path
  • Removed eventFired doneOn mode, will add API to control programmatically in future revision

Interface:

export interface IWalkthroughTask {
	readonly id: string;
	readonly title: string;
	readonly description: string;
	readonly button:
	| { title: string, link: string, command?: never }
	| { title: string, command: string, link?: never },
	readonly media: { path: string, altText: string },
	readonly doneOn?: { command: string };
	readonly when?: string;
}

export interface IWalkthrough {
	readonly id: string,
	readonly title: string;
	readonly description: string;
	readonly tasks: IWalkthroughTask[];
	readonly primary?: boolean;
	readonly when?: string;
}

Example:

"walkthroughs": [ 
			{
				"id": "exampleProject",
				"title": "Turn Markdown into HTML",
				"description": "Use this sample project to learn how to convert Markdown to HTML!",
				"primary": true,
				"tasks": [
					{
						"id": "md-to-html.openExample",
						"title": "Open an example folder",
						"description": "To start, try opening an example folder that has been preconfigured for this tutorial. This is optional, but helps for following along!",
						"button": {
							"title": "Open Example",
							"command": "md-to-html.openExample"
						},
						"media": {
							"path": "media/example-project.png",
							"altText": "example project"
						}
					},
					{
						"id": "md-to-html.showPreview",
						"title": "Preview your Markdown",
						"description": "Open a markdown file and click the \"Open Preview\" button at the top of the screen to see a preview of your file. This is technically optional, but it updates live and is helpful to check when creating your content!",
						"button": {
							"title": "Open Markdown File",
							"command": "md-to-html.openMarkdown"
						},
						"media": {
							"path": "media/preview.png",
							"altText": "preview"
						},
						"doneOn": {"command": "markdown.showPreviewToSide" } 
					},
					{
						"id": "md-to-html.convertToHTML",
						"title": "Create your .html file",
						"description": "To create the html file, run \"Convert Document to HTML\" from the editor actions context menu, behind the three dots top of the screen. This will create an .html file along side the markdown file.",
						"button": {
							"title": "Open Markdown File",
							"command": "md-to-html.openMarkdown"
						},
						"media": {
							"path": "media/convert-option.png",
							"altText": "showing editor actions context menu"
						},
						"doneOn": {"command": "md-to-html.convertToHTML" }
					},
					{
						"id": "md-to-html.openInBrowser",
						"title": "Open your .html file in the browser",
						"description": "Test that everything worked by opening the .html file in your browser. First open the html file in vscode, then right click in the editor and choose \"Open in Default Browser\".",
						"button": {
							"title": "Open HTML File",
							"command": "md-to-html.openHTML"
						},
						"media": {
							"path": "media/open-in-browser.png",
							"altText": "use editor context menu to open an .html file in your browser"
						},
						"doneOn": {"command": "extension.openInDefaultBrowser" }
					},
					{
						"id": "md-to-html.addKeybinding",
						"title": "Create a keyboard shortcut",
						"description": "That's all! You can share that single .html file with anyone without needing to bundle the images. To make this even easier in the future, consider adding a keybinding for the \"Convert Document to HTML\" command.",
						"button": {
							"title": "Add a keybinding",
							"command": "md-to-html.addKeybinding"
						},
						"media": {
							"path": "media/add-keybinding.png",
							"altText": "use the keybindings editor to add a keybinding for this command"
						}
					}
				]
			}
		]

Edit: Added a "primary" boolean to category items indicating whether the category should be auto-opened on install.

@JacksonKearl
Copy link
Contributor Author

Moving to April for continued API discussion.

@pixieaka
Copy link

@JacksonKearl Is it option here to add images for [ light, dark, HC ] color themes from extensions?

@JacksonKearl
Copy link
Contributor Author

JacksonKearl commented Mar 29, 2021

@pixieaka that is not currently surfaced, though we support it internally and could potentially. Is this something you would use?

@pixieaka
Copy link

pixieaka commented Mar 29, 2021

@JacksonKearl Yeah I could use this feature to unify my extension experience to mate user interface like HC or Light. Can this be optional if extension slides need to display code photos it would be better to be customizable for user UI.

@JacksonKearl
Copy link
Contributor Author

That sounds reasonable, can you create a new issue for it?

@pixieaka
Copy link

@JacksonKearl Absolutely! #120122 .

@Eskibear
Copy link
Member

For those who want to try this new feature, I just want to mention that, setting workbench.welcomePage.experimental.extensionContributions to true (for the insiders built on 2021/04/28) is a pre-requisite. Otherwise you don't see anything.

@JacksonKearl
Copy link
Contributor Author

New API:

"walkthroughs": [
  {
    "id": "exampleProject",
    "title": "Turn Markdown into HTML",
    "description": "Use this sample project to learn how to convert Markdown to HTML!",
    "primary": true,
    "steps": [
      {
        "id": "md-to-html.openExample",
        "title": "Open an example folder",
        "description": "To start, try opening an example folder that has been preconfigured for this tutorial. **This is optional**, but helps for following along!\n[Open Example](command:md-to-html.openExample)",
        "media": {
          "path": "media/openExample.md"
        },
        "completionEvents": ["extensionInstalled:tyriar.luna-paint"] 
      },
      {
        "id": "md-to-html.showPreview",
        "title": "Preview your Markdown",
        "description": "Open a markdown file and click the __\"Open Preview\"__ button at the top of the screen to see a preview of your file. **This is technically optional**, but it updates live and is helpful to check when creating your content!\n[Open Markdown File](command:toSide:workbench.action.quickOpen?%22.md%22)",
        "media": {
          "path": "media/preview.png",
          "altText": "preview"
        },
        "completionEvents": ["onCommand:markdown.showPreviewToSide"]
      },
      {
        "id": "md-to-html.convertToHTML",
        "title": "Create your .html file",
        "description": "To create the ``.html`` file, run __\"Convert Document to HTML\"__ from the editor actions context menu, behind the three dots top of the screen. This will create an ``.html`` file along side the markdown file.\n[Open Markdown File](command:toSide:workbench.action.quickOpen?%22.md%22)",
        "media": {
          "path": "media/convert-option.png",
          "altText": "showing editor actions context menu"
        },
        "completionEvents": ["onCommand:md-to-html.convertToHTML"]
      },
      {
        "id": "md-to-html.openInBrowser",
        "title": "Open your .html file in the browser",
        "description": "Test that everything worked by opening the ``.html`` file in your browser. This requires [installing the open in broswer extension](command:workbench.extensions.installExtension?%22techer.open-in-browser%22).\n First open the html file in vscode, then right click in the editor and choose \"Open in Default Browser\".\n[Open HTML File](command:toSide:workbench.action.quickOpen?%22.html%22)",
        "media": {
          "path": "media/open-in-browser.png",
          "altText": "use editor context menu to open an .html file in your browser"
        },
        "completionEvents": ["onCommand:extension.openInDefaultBrowser"]
      },
      {
        "id": "md-to-html.addKeybinding",
        "title": "Create a keyboard shortcut",
        "description": "That's all! You can share that single ``.html`` file with anyone without needing to bundle the images. To make this even easier in the future, consider adding a keybinding for the \"Convert Document to HTML\" command.\n[Add a keybinding](command:workbench.action.openGlobalKeybindings?%22md-to-html.convertToHTML%22)",
        "media": {
          "path": "media/add-keybinding.png",
          "altText": "use the keybindings editor to add a keybinding for this command"
        }
      }
    ]
  }
],

Where completionEvents follows same basic flow as avtivationEvents, and takes keys like: onCommand: onLink: onView: onSettingChanged: onContextKeyDefined: extensionInstalled: stepSelected

@JacksonKearl
Copy link
Contributor Author

JacksonKearl commented May 25, 2021

Notes from API review:

  • onContextKeyDefined => onContext
  • Consider supporting configuration in a separate file (see snippets)
  • Better name for "primary" Removed entirely
  • media.path => media.image, media.markdown

@JacksonKearl
Copy link
Contributor Author

Implemented remaining items from API review. Will consider supporting separate config files as needed by implementors

@github-actions github-actions bot locked and limited conversation to collaborators Jul 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants