Skip to content

Commit

Permalink
feat: Ready to release 0.8.2 (#1816)
Browse files Browse the repository at this point in the history
  • Loading branch information
shd101wyy authored Oct 9, 2023
1 parent 06b2ca0 commit a060d52
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 23 deletions.
7 changes: 5 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ A clear and concise description of what the bug is.

**Environment**
- OS: Windows 11
- VSCode: 1.81.0
- Markdown Preview Enhanced: 0.7.0
- VSCode: 1.82.0
- Markdown Preview Enhanced: 0.8.0

**To Reproduce**
Steps to reproduce the behavior:
Expand All @@ -25,6 +25,9 @@ Steps to reproduce the behavior:
**Expected behavior**
A clear and concise description of what you expected to happen.

**Markdown file**
Please attach the markdown file that can reproduce the bug.

**Screenshots**
If applicable, add screenshots to help explain your problem.

Expand Down
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.8.2] - 2023-10-09

Special Thanks to [@mavaddat](https://github.com/mavaddat) for creating the awesome extension logo for MPE in this [pull request](https://github.com/shd101wyy/vscode-markdown-preview-enhanced/pull/1808) 🎉 We finally have a beautiful logo for MPE.

Updated [crossnote](https://github.com/shd101wyy/crossnote) to version [0.8.20](https://github.com/shd101wyy/crossnote/releases/tag/0.8.20).

### New features

- Supported prefix in front of Kroki diagram types https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1785.
So now all diagrams below will get rendered using Kroki:

````markdown
```kroki-plantuml
@startuml
A -> B
@enduml
```

```plantuml {kroki=true}
@startuml
A -> B
@enduml
```
````

- Improved the source map handling for `@import "..."` syntax.

### Bug fixes

- Exporting files no longer includes the source map.
- Fixed some Reveal.js presentation related bugs:
- https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1815
- https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1814
- Both the `style.less` from `Markdown Preview Enhanced: Customize Css (Global)` and the `style.less` from `Markdown Preview Enhanced: Customize Css (Workspace)` will now be loaded. The `style.less` from `Markdown Preview Enhanced: Customize Css (Workspace)` will have higher priority.
- Fixed the bug where deleting config files from workspace did not update the preview.

## [0.8.1] - 2023-10-06

Updated [crossnote](https://github.com/shd101wyy/crossnote) to version [0.8.19](https://github.com/shd101wyy/crossnote/releases/tag/0.8.19).
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "markdown-preview-enhanced",
"displayName": "%displayName%",
"version": "0.8.1",
"version": "0.8.2",
"description": "%description%",
"icon": "media/mpe.png",
"categories": [
"Other"
],
Expand Down Expand Up @@ -675,7 +674,7 @@
"@types/crypto-js": "^4.1.2",
"@types/vfile": "^3.0.2",
"async-mutex": "^0.4.0",
"crossnote": "^0.8.19",
"crossnote": "^0.8.20",
"crypto-js": "^4.1.1"
},
"devDependencies": {
Expand Down Expand Up @@ -704,5 +703,6 @@
},
"engines": {
"vscode": "^1.80.0"
}
},
"icon": "media/mpe.png"
}
37 changes: 32 additions & 5 deletions src/extension-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { PreviewCustomEditorProvider } from './preview-custom-editor-provider';
import { PreviewProvider, getPreviewUri } from './preview-provider';
import {
getBottomVisibleLine,
getEditorActiveLine,
getEditorActiveCursorLine,
getPreviewMode,
getTopVisibleLine,
getWorkspaceFolderUri,
Expand Down Expand Up @@ -64,7 +64,7 @@ export async function initExtensionCommon(context: vscode.ExtensionContext) {
previewProvider.initPreview({
sourceUri: uri,
document: editor.document,
activeLine: getEditorActiveLine(editor),
cursorLine: getEditorActiveCursorLine(editor),
viewOptions: {
viewColumn: vscode.ViewColumn.Two,
preserveFocus: true,
Expand All @@ -85,7 +85,7 @@ export async function initExtensionCommon(context: vscode.ExtensionContext) {
previewProvider.initPreview({
sourceUri: uri,
document: editor.document,
activeLine: getEditorActiveLine(editor),
cursorLine: getEditorActiveCursorLine(editor),
viewOptions: {
viewColumn: vscode.ViewColumn.One,
preserveFocus: false,
Expand Down Expand Up @@ -573,7 +573,7 @@ export async function initExtensionCommon(context: vscode.ExtensionContext) {
previewProvider.initPreview({
sourceUri: fileUri,
document,
activeLine: line,
cursorLine: line,
viewOptions: {
viewColumn: vscode.ViewColumn.Active,
preserveFocus: true,
Expand Down Expand Up @@ -710,6 +710,33 @@ export async function initExtensionCommon(context: vscode.ExtensionContext) {
}),
);

context.subscriptions.push(
vscode.workspace.onDidDeleteFiles(async ({ files }) => {
for (const file of files) {
// Check if there is change under `${workspaceDir}/.crossnote` directory
// and filename is in one of below
// - style.less
// - config.js
// - parser.js
// - head.html
// If so, refresh the preview of the workspace.
const workspaceUri = getWorkspaceFolderUri(file);
const workspaceDir = workspaceUri.fsPath;
const relativePath = path.relative(workspaceDir, file.fsPath);
if (
relativePath.startsWith('.crossnote') &&
['style.less', 'config.js', 'parser.js', 'head.html'].includes(
path.basename(relativePath),
)
) {
const provider = await getPreviewContentProvider(file);
await notebooksManager.updateNotebookConfig(workspaceUri);
provider.refreshAllPreviews();
}
}
}),
);

context.subscriptions.push(
vscode.workspace.onDidChangeTextDocument(async (event) => {
if (isMarkdownFile(event.document)) {
Expand Down Expand Up @@ -834,7 +861,7 @@ export async function initExtensionCommon(context: vscode.ExtensionContext) {
previewProvider.initPreview({
sourceUri,
document: editor.document,
activeLine: getEditorActiveLine(editor),
cursorLine: getEditorActiveCursorLine(editor),
viewOptions: {
viewColumn:
previewProvider.getPreviews(sourceUri)?.at(0)?.viewColumn ??
Expand Down
2 changes: 2 additions & 0 deletions src/notebooks-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class NotebooksManager {
...vscodeMPEConfig,
...globalConfig,
...workspaceConfig,
globalCss:
(globalConfig.globalCss ?? '') + (workspaceConfig.globalCss ?? ''),
previewTheme,
};
}
Expand Down
14 changes: 7 additions & 7 deletions src/preview-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,13 @@ export class PreviewProvider {
sourceUri,
document,
webviewPanel,
activeLine,
cursorLine,
viewOptions,
}: {
sourceUri: vscode.Uri;
document: vscode.TextDocument;
webviewPanel?: vscode.WebviewPanel;
activeLine?: number;
cursorLine?: number;
viewOptions: { viewColumn: vscode.ViewColumn; preserveFocus?: boolean };
}): Promise<void> {
// console.log('@initPreview: ', sourceUri);
Expand All @@ -311,7 +311,7 @@ export class PreviewProvider {
sourceUri,
document,
viewOptions,
activeLine,
cursorLine,
});
} else {
previewPanel = PreviewProvider.singlePreviewPanel;
Expand All @@ -325,7 +325,7 @@ export class PreviewProvider {
document,
webviewPanel: preview,
viewOptions,
activeLine,
cursorLine,
}),
),
);
Expand Down Expand Up @@ -412,10 +412,10 @@ export class PreviewProvider {
// set title
previewPanel.title = `Preview ${path.basename(sourceUri.fsPath)}`;

// init markdown engine
// init markdown engine.
let initialLine: number | undefined;
if (document.uri.fsPath === sourceUri.fsPath) {
initialLine = activeLine;
initialLine = cursorLine;
}

const inputString = document.getText() ?? '';
Expand All @@ -425,7 +425,7 @@ export class PreviewProvider {
inputString,
config: {
sourceUri: sourceUri.toString(),
initialLine,
cursorLine: initialLine,
isVSCode: true,
scrollSync: getMPEConfig<boolean>('scrollSync'),
imageUploader: getMPEConfig<ImageUploader>('imageUploader'),
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ export function getPreviewMode() {
return getMPEConfig<PreviewMode>('previewMode');
}

export function getEditorActiveLine(editor: vscode.TextEditor) {
export function getEditorActiveCursorLine(editor: vscode.TextEditor) {
return editor.selections[0].active.line ?? 0;
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1920,10 +1920,10 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
shebang-command "^2.0.0"
which "^2.0.1"

crossnote@^0.8.19:
version "0.8.19"
resolved "https://registry.yarnpkg.com/crossnote/-/crossnote-0.8.19.tgz#a92f176d665ad0fc89b3744de566ec35f4a89dce"
integrity sha512-D/QaUBJ1ApBmq1DJOHvJ3/+g/Y8kBXhvXcbnjX6zKbzEEJ1GDQYUKIYTli8sx+3fY7nJn3BMU67DiOv4Q3mh+Q==
crossnote@^0.8.20:
version "0.8.20"
resolved "https://registry.yarnpkg.com/crossnote/-/crossnote-0.8.20.tgz#be5ed32d64dc1bc82a18dcada10e98d709305f4b"
integrity sha512-MdL6tost+X7hDhIYA68b/rMqnfQgSXSQZjLZ1nHriv2zVqkPSs6LGQzdLb0lrT9SjpSmDjwz3dXYQknq6IphQg==
dependencies:
"@headlessui/react" "^1.7.17"
"@heroicons/react" "^2.0.18"
Expand Down

0 comments on commit a060d52

Please sign in to comment.