-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
163 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ out | |
node_modules | ||
.vscode-test/ | ||
*.vsix | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCYPTE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="renderer" content="webkit"> | ||
<style> | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#container { | ||
display: block; | ||
width: 100vw; | ||
height: 100vh; | ||
} | ||
</style> | ||
<insert-vscode-resource/> | ||
</head> | ||
<body> | ||
<svg id="container" preserveAspectRatio="none meet"></svg> | ||
<script> | ||
const map = markmap.Markmap.create("#container", null, { "t": "heading", "d": 1, "p": {}, "v": "Rendering, please wait..." }); | ||
const vscode = acquireVsCodeApi(); | ||
window.addEventListener('message', event => { | ||
const message = event.data; | ||
switch (message.command) { | ||
case "saveSvg": { | ||
let svg = document.querySelectorAll('svg')[0]; | ||
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg"); | ||
vscode.postMessage({ command: "saveSvgData", html: svg.outerHTML }); | ||
break; | ||
} | ||
|
||
case "renderMarkdown": { | ||
map.setData(markmap.transform(message.data)); | ||
break; | ||
} | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
// The module 'vscode' contains the VS Code extensibility API | ||
// Import the module and reference it with the alias vscode in your code below | ||
import * as vscode from 'vscode'; | ||
import { MindMapPreview } from "./mindMapPreviewWebview"; | ||
|
||
// this method is called when your extension is activated | ||
// your extension is activated the very first time the command is executed | ||
export function activate(context: vscode.ExtensionContext) { | ||
let mindMapPreview: MindMapPreview; | ||
context.subscriptions.push( | ||
vscode.commands.registerCommand('mdmmp.showMindMap', () => { | ||
const mindMapPreview = new MindMapPreview(context); | ||
if ((mindMapPreview === undefined) || mindMapPreview.isDisposed) { | ||
mindMapPreview = new MindMapPreview(context); | ||
} | ||
mindMapPreview.updatePreview(); | ||
}) | ||
); | ||
context.subscriptions.push( | ||
vscode.commands.registerCommand('mdmmp.exportSvg', () => { | ||
if ((mindMapPreview === undefined) || mindMapPreview.isDisposed) { | ||
vscode.window.showWarningMessage("Sorry, you need open the preview tab first."); | ||
return; | ||
} | ||
mindMapPreview.exportSvg(); | ||
}) | ||
); | ||
} | ||
|
||
// this method is called when your extension is deactivated | ||
export function deactivate() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function getFileNameWithoutExtension(filename: string) { | ||
var pattern = /\.[A-Za-z]+$/; | ||
let ansMatch = pattern.exec(filename); | ||
if (ansMatch !== null) { | ||
return (filename.slice(0, ansMatch.index)); | ||
} else { | ||
return filename; | ||
} | ||
} |