From 2e20926e6a6e9979bf4d4425284903d860be80dc Mon Sep 17 00:00:00 2001 From: Yiyi Wang Date: Fri, 6 Oct 2023 22:51:50 +0800 Subject: [PATCH] 0.8.1 (#1806) * feat: Updated crossnote to 0.8.19 * fix: Fixed loading global style.less --- CHANGELOG.md | 21 +++++++++++++++++++++ package.json | 31 +++++++++++++++++++++++++++++-- src/config.ts | 10 ++++++++++ src/notebooks-manager.ts | 21 +++++++++++++-------- src/preview-provider.ts | 2 +- yarn.lock | 14 ++++++++++---- 6 files changed, 84 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73960e3..ce9a259 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [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). + +### Changes + +- Deprecated the `processWikiLink` in `parser.js`. Now `crossnote` handles how we process the wiki link. + We also added two more options: + - `wikiLinkTargetFileExtension`: The file extension of the target file. Default is `md`. For example: + - `[[test]]` will be transformed to `[test](test.md)` + - `[[test.md]]` will be transformed to `[test](test.md)` + - `[[test.pdf]]` will be transformed to `[test](test.pdf)` because it has a file extension. + - `wikiLinkTargetFileNameChangeCase`: How we transform the file name. Default is `none` so we won't change the file name. + A list of available options can be found at: https://shd101wyy.github.io/crossnote/types/WikiLinkTargetFileNameChangeCase.html + +### Bug fixes + +- Reverted the markdown transformer and deleted the logic of inserting anchor elements as it's causing a lot of problems. + The in-preview editor is not working as expected. So we now hide its highlight lines and elements feature if the markdown file failed to generate the correct source map. +- Fixed the bug that global custom CSS is not working. + ## [0.8.0] - 2023-10-05 Updated [crossnote](https://github.com/shd101wyy/crossnote) to version [0.8.17](https://github.com/shd101wyy/crossnote/releases/tag/0.8.17) then version [0.8.18](https://github.com/shd101wyy/crossnote/releases/tag/0.8.18). diff --git a/package.json b/package.json index 0e76ebe..1425f0a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "markdown-preview-enhanced", "displayName": "%displayName%", - "version": "0.8.0", + "version": "0.8.1", "description": "%description%", "categories": [ "Other" @@ -290,6 +290,33 @@ "default": false, "type": "boolean" }, + "markdown-preview-enhanced.wikiLinkTargetFileExtension": { + "markdownDescription": "The file extension for the link in wikilink if the link does not have an extension.", + "default": ".md", + "type": "string" + }, + "markdown-preview-enhanced.wikiLinkTargetFileNameChangeCase": { + "markdownDescription": "The case for the file name in wikilink. If the value is `none`, then the file name will not be changed. Otherwise, the file name will be transformed to the specified case. You can read https://www.npmjs.com/package/case-anything for more details.", + "default": "none", + "type": "string", + "enum": [ + "none", + "camelCase", + "pascalCase", + "kebabCase", + "snakeCase", + "constantCase", + "trainCase", + "adaCase", + "cobolCase", + "dotNotation", + "pathCase", + "spaceCase", + "capitalCase", + "lowerCase", + "upperCase" + ] + }, "markdown-preview-enhanced.frontMatterRenderingOption": { "description": "Front matter rendering option", "type": "string", @@ -646,7 +673,7 @@ "@types/crypto-js": "^4.1.2", "@types/vfile": "^3.0.2", "async-mutex": "^0.4.0", - "crossnote": "^0.8.18", + "crossnote": "^0.8.19", "crypto-js": "^4.1.1" }, "devDependencies": { diff --git a/src/config.ts b/src/config.ts index 4b620ea..2a8a17c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -11,6 +11,7 @@ import { PreviewMode, PreviewTheme, RevealJsTheme, + WikiLinkTargetFileNameChangeCase, getDefaultNotebookConfig, } from 'crossnote'; import { JsonObject } from 'type-fest'; @@ -88,6 +89,8 @@ export class MarkdownPreviewEnhancedConfig implements NotebookConfig { public readonly jsdelivrCdnHost: string; public readonly krokiServer: string; public readonly alwaysShowBacklinksInPreview: boolean; + public readonly wikiLinkTargetFileExtension: string; + public readonly wikiLinkTargetFileNameChangeCase: WikiLinkTargetFileNameChangeCase; // Don't set values for these properties in constructor: public readonly includeInHeader: string; public readonly globalCss: string; @@ -244,6 +247,13 @@ export class MarkdownPreviewEnhancedConfig implements NotebookConfig { this.alwaysShowBacklinksInPreview = getMPEConfig('alwaysShowBacklinksInPreview') ?? defaultConfig.alwaysShowBacklinksInPreview; + this.wikiLinkTargetFileExtension = + getMPEConfig('wikiLinkTargetFileExtension') ?? + defaultConfig.wikiLinkTargetFileExtension; + this.wikiLinkTargetFileNameChangeCase = + getMPEConfig( + 'wikiLinkTargetFileNameChangeCase', + ) ?? defaultConfig.wikiLinkTargetFileNameChangeCase; } public isEqualTo(otherConfig: MarkdownPreviewEnhancedConfig) { diff --git a/src/notebooks-manager.ts b/src/notebooks-manager.ts index 4b15095..79997a1 100644 --- a/src/notebooks-manager.ts +++ b/src/notebooks-manager.ts @@ -88,14 +88,19 @@ class NotebooksManager { getWorkspaceFolderUri(uri), './.crossnote', ); - try { - workspaceConfig = await loadConfigsInDirectory( - workspaceConfigPath.fsPath, - notebook.fs, - createWorkspaceConfigDirectoryIfNotExists, - ); - } catch (error) { - console.error(error); + if ( + (await notebook.fs.exists(workspaceConfigPath.fsPath)) || + createWorkspaceConfigDirectoryIfNotExists + ) { + try { + workspaceConfig = await loadConfigsInDirectory( + workspaceConfigPath.fsPath, + notebook.fs, + createWorkspaceConfigDirectoryIfNotExists, + ); + } catch (error) { + console.error(error); + } } // VSCode config diff --git a/src/preview-provider.ts b/src/preview-provider.ts index 20c9049..485065f 100644 --- a/src/preview-provider.ts +++ b/src/preview-provider.ts @@ -540,7 +540,7 @@ export class PreviewProvider { useRelativeFilePath: false, hideFrontMatter: false, triggeredBySave, - vscodePreviewPanel: preview, // TODO: + vscodePreviewPanel: preview, }); // check JSAndCssFiles if ( diff --git a/yarn.lock b/yarn.lock index d9be403..cdd0790 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.18: - version "0.8.18" - resolved "https://registry.yarnpkg.com/crossnote/-/crossnote-0.8.18.tgz#806a37f6ff8627cada55ee645b9e8c1e2307479d" - integrity sha512-LvhWOU3/T6BAoDrWC/5I7XgnC/PMvKZJFyVBnrl/l5+OZtNw4QTU0jx+Q3dge2HCpER7xdApQo0ITZWER8Xm9g== +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== dependencies: "@headlessui/react" "^1.7.17" "@heroicons/react" "^2.0.18" @@ -1943,6 +1943,7 @@ crossnote@^0.8.18: crypto-js "^4.1.1" daisyui "^3.7.3" esbuild-plugin-tailwindcss "^1.1.1" + escape-string-regexp "^5.0.0" html-escaper "^3.0.3" html-react-parser "^4.2.2" imagemagick-cli "^0.5.0" @@ -2969,6 +2970,11 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== +escape-string-regexp@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz#4683126b500b61762f2dbebace1806e8be31b1c8" + integrity sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw== + escodegen@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.1.0.tgz#ba93bbb7a43986d29d6041f99f5262da773e2e17"