Skip to content
This repository was archived by the owner on May 11, 2022. It is now read-only.

Commit e8f4920

Browse files
authored
FUSETOOLS2-1108 - improving Didact live preview (#543)
* FUSETOOLS2-1108 - initial cut at live preview * updated preview keys * updated docs and demos * update keys in readme Signed-off-by: Brian Fitzpatrick <[email protected]>
1 parent f26dc88 commit e8f4920

File tree

6 files changed

+30
-8
lines changed

6 files changed

+30
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ All notable changes to the "vscode-didact" extension will be documented in this
44

55
## 0.4.1
66

7-
- TBD
7+
- Integrated with the built-in VS Code Markdown Preview (Ctrl+Shift+V). Note that Didact links do not work from the built-in preview.
8+
- Also note that the built-in preview for the AsciiDoc extension (https://marketplace.visualstudio.com/items?itemName=asciidoctor.asciidoctor-vscode) now works, though the stylesheets are not the same and Didact links do not work from the AsciiDoc preview.
9+
- Changed `Didact: Start Didact Tutorial from File` hotkeys from `Ctrl/Cmd+Shift+V` to `Ctrl/Cmd+Alt+D` to avoid conflicting with the Markdown and AsciiDoc preview functionality. This keybinding can be changed from the VS Code `Keyboard Shortcuts` window (`File->Preferences->Keyboard Shortcuts`).
810

911
## 0.4.0
1012

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* In AsciiDoc, type `link:[Open a new terminal]`, put the cursor after `link:`, and press `Ctrl+Space`.
4141
4. Select `Start new Didact command link`.
4242
5. Choose a command from the hundreds VS Code has available (like `workbench.action.terminal.new`) and press `Enter`.
43-
6. Press `Ctrl+Alt+V` to view your new Didact tutorial and click the link you created! Done!
43+
6. Press `Ctrl/Cmd+Alt+D` to view your new Didact tutorial and click the link you created! Done!
4444

4545
![Open New Terminal Example](./images/open-new-terminal-example.gif)
4646

demos/markdown/tutorial/tutorial.didact.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Didact gives you a way of writing those same files but gives them a way to lever
1919
3. Create a new AsciiDoc or Markdown file and add “didact” to the file extension (`myfile.didact.adoc`, `myotherfile.didact.md`) [(Click here to create your first Didact markdown file named `myfirst.didact.md`.)](didact://?commandId=vscode.didact.scaffoldProject&extFilePath=redhat.vscode-didact/demos/markdown/tutorial/didactmdfile.json) [(Then click here to open the new `myfirst.didact.md` file.)](didact://?commandId=vscode.open&projectFilePath=didactmdfile.json)
2020
4. Start writing!
2121
5. When you get to a point where you want the user to click on a link to do something active, write a Didact link (we'll cover that in the next section).
22-
6. To open and test your Didact file, right-click on the file and select `Start Didact Tutorial from File` from the context menu or launch the Didact window while editing the file with `Ctrl+Shift+V` or `Cmd+Shift+V`.
22+
6. To open and test your Didact file, right-click on the file and select `Start Didact Tutorial from File` from the context menu or launch the Didact window while editing the file with `Ctrl+Alt+D` or `Cmd+Alt+D`.
2323
6. Repeat steps 4-6 until you’re done!
2424

2525
## The Basics of Didact

docs/writing-a-tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Or [click here](didact://?commandId=workbench.action.showCommands) to see the Co
5252

5353
For simple commands, that's all that necessary, so save your file.
5454

55-
To see your link in action, just right-click on the Didact file (*.didact.md or *.didact.adoc) and select **Start Didact Tutorial from File** from the context menu.
55+
To open and test your Didact file, right-click on the file (*.didact.md or *.didact.adoc) and select `Start Didact Tutorial from File` from the context menu or launch the Didact window while editing the file with `Ctrl+Alt+D` or `Cmd+Alt+D`.
5656

5757
If you click the `click here` link in your file, it should automatically open the Command Palette for you, just like we wanted it to.
5858

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@
166166
"keybindings": [
167167
{
168168
"command": "vscode.didact.startDidact",
169-
"key": "ctrl+shift+v",
170-
"mac": "cmd+shift+v",
169+
"key": "ctrl+alt+d",
170+
"mac": "cmd+alt+d",
171171
"when": "editorFocus && resourceFilename =~ /[.](didact)[.](md|adoc)$/"
172172
},
173173
{
@@ -258,7 +258,12 @@
258258
".didact.adoc"
259259
]
260260
}
261-
]
261+
],
262+
"markdown.previewStyles": [
263+
"https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css",
264+
"./media/webviewslim.css"
265+
],
266+
"markdown.markdownItPlugins": true
262267
},
263268
"files.associations": {
264269
"*.didact.md": "markdown",

src/extension.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const DEFAULT_TUTORIAL_NAME = "Didact Demo";
3535
export const didactTutorialsProvider = new DidactNodeProvider();
3636
let didactTreeView : vscode.TreeView<SimpleNode>;
3737

38-
export async function activate(context: vscode.ExtensionContext): Promise<void> {
38+
export async function activate(context: vscode.ExtensionContext): Promise<any> {
3939

4040
extensionFunctions.initialize(context);
4141

@@ -126,6 +126,21 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
126126
if (openAtStartup) {
127127
await extensionFunctions.openDidactWithDefault();
128128
}
129+
130+
return {
131+
extendMarkdownIt(md: any) {
132+
const taskLists = require('markdown-it-task-lists');
133+
const markdownItAttrs = require('markdown-it-attrs');
134+
return md.set({ typographer: true })
135+
.set({ linkify: true })
136+
.enable('linkify')
137+
.enable('replacements')
138+
.enable('strikethrough')
139+
.enable('table')
140+
.use(taskLists, {enabled: true, label: true})
141+
.use(markdownItAttrs, {});
142+
}
143+
};
129144
}
130145

131146
function createIntegrationsView(): void {

0 commit comments

Comments
 (0)