diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index abce6e6..1cabc2e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -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: @@ -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. diff --git a/CHANGELOG.md b/CHANGELOG.md index ce9a259..3ce7675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/package.json b/package.json index 9cfa9ba..b8b3c61 100644 --- a/package.json +++ b/package.json @@ -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" ], @@ -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": { @@ -704,5 +703,6 @@ }, "engines": { "vscode": "^1.80.0" - } + }, + "icon": "media/mpe.png" } diff --git a/src/extension-common.ts b/src/extension-common.ts index 7df4819..e70678d 100644 --- a/src/extension-common.ts +++ b/src/extension-common.ts @@ -9,7 +9,7 @@ import { PreviewCustomEditorProvider } from './preview-custom-editor-provider'; import { PreviewProvider, getPreviewUri } from './preview-provider'; import { getBottomVisibleLine, - getEditorActiveLine, + getEditorActiveCursorLine, getPreviewMode, getTopVisibleLine, getWorkspaceFolderUri, @@ -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, @@ -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, @@ -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, @@ -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)) { @@ -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 ?? diff --git a/src/notebooks-manager.ts b/src/notebooks-manager.ts index 79997a1..6db8a1f 100644 --- a/src/notebooks-manager.ts +++ b/src/notebooks-manager.ts @@ -117,6 +117,8 @@ class NotebooksManager { ...vscodeMPEConfig, ...globalConfig, ...workspaceConfig, + globalCss: + (globalConfig.globalCss ?? '') + (workspaceConfig.globalCss ?? ''), previewTheme, }; } diff --git a/src/preview-provider.ts b/src/preview-provider.ts index 485065f..96773f1 100644 --- a/src/preview-provider.ts +++ b/src/preview-provider.ts @@ -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 { // console.log('@initPreview: ', sourceUri); @@ -311,7 +311,7 @@ export class PreviewProvider { sourceUri, document, viewOptions, - activeLine, + cursorLine, }); } else { previewPanel = PreviewProvider.singlePreviewPanel; @@ -325,7 +325,7 @@ export class PreviewProvider { document, webviewPanel: preview, viewOptions, - activeLine, + cursorLine, }), ), ); @@ -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() ?? ''; @@ -425,7 +425,7 @@ export class PreviewProvider { inputString, config: { sourceUri: sourceUri.toString(), - initialLine, + cursorLine: initialLine, isVSCode: true, scrollSync: getMPEConfig('scrollSync'), imageUploader: getMPEConfig('imageUploader'), diff --git a/src/utils.ts b/src/utils.ts index a25fd4d..4e7a38d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -142,6 +142,6 @@ export function getPreviewMode() { return getMPEConfig('previewMode'); } -export function getEditorActiveLine(editor: vscode.TextEditor) { +export function getEditorActiveCursorLine(editor: vscode.TextEditor) { return editor.selections[0].active.line ?? 0; } diff --git a/yarn.lock b/yarn.lock index cdd0790..8238f9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"