Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.9.8 #352

Merged
merged 7 commits into from
Mar 10, 2024
Merged

0.9.8 #352

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ Please visit https://github.com/shd101wyy/vscode-markdown-preview-enhanced/relea

## [Unreleased]

## [0.9.8] - 2024-3-10

### New features

- @moonlitusun sidebarToc supports local caching

### Updates

- @oneWaveAdrian updated the `mermaid` version to the latest `10.9.0`.

### Bug fixes

- Fixed [[BUG] #tag is treated as Header 1](https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1937)
- Fixed [[BUG] toml code block support is not very good](https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1920)
- Fixed [[BUG] If URL encoding is used, the preview cannot be displayed.](https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1934)

## [0.9.7] - 2023-12-10

### New features
Expand Down
2 changes: 1 addition & 1 deletion dependencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ I managed some of the libraries by myself instead of through npm to reduce the o
"font-awesome": "6.4.2", // Download from here: https://fontawesome.com/download
// Fontawesome cheatsheet is available here: https://kapeli.com/cheat_sheets/Font_Awesome.docset/Contents/Resources/Documents/index
"katex": "v0.16.9", // Only keep the css and fonts files.
"mermaid": "10.8.0", // https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js
"mermaid": "10.9.0", // https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js
"reveal": "4.6.0",

// NOTE: Don't forget to update `dependentLibraryMaterials` in `markdown-engine/index.ts`
Expand Down
884 changes: 577 additions & 307 deletions dependencies/mermaid/mermaid.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crossnote",
"version": "0.9.7",
"version": "0.9.8",
"description": "A powerful markdown notebook tool",
"keywords": [
"markdown"
Expand Down Expand Up @@ -93,7 +93,7 @@
"markdown-it-sub": "^1.0.0",
"markdown-it-sup": "^1.0.0",
"md5": "^2.3.0",
"mermaid": "^10.8.0",
"mermaid": "^10.9.0",
"minisearch": "^6.1.0",
"mkdirp": "^3.0.1",
"monaco-editor": "^0.43.0",
Expand Down
2 changes: 1 addition & 1 deletion src/markdown-engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ window["initRevealPresentation"] = async function() {
'./dependencies/mermaid/mermaid.min.js',
)}" charset="UTF-8"></script>`;
} else {
mermaidScript = `<script src="https://${this.notebook.config.jsdelivrCdnHost}/npm/mermaid@10.8.0/dist/mermaid.min.js"></script>`;
mermaidScript = `<script src="https://${this.notebook.config.jsdelivrCdnHost}/npm/mermaid@10.9.0/dist/mermaid.min.js"></script>`;
}

mermaidInitScript += `<script type="module">
Expand Down
2 changes: 1 addition & 1 deletion src/markdown-engine/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ export async function transformMarkdown(
}
// ========== End: Custom Comment ==========
// ========== Start: Heading ==========
else if ((headingMatch = line.match(/^(#{1,7}).*/))) {
else if ((headingMatch = line.match(/^(#{1,7})\s.*/))) {
let heading = line.replace(headingMatch[1], '').trim();
const tag = headingMatch[1];
const level = tag.length;
Expand Down
87 changes: 46 additions & 41 deletions src/webview/containers/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,50 +784,55 @@ const PreviewContainer = createContainer(() => {
if (!hrefAttr) {
continue;
}
const href = decodeURIComponent(hrefAttr); // decodeURI here for Chinese like unicode heading
if (href && href[0] === '#') {
a.onclick = (event) => {
event.preventDefault();
event.stopPropagation();

if (!previewElement.current) {
return;
}
try {
const href = decodeURIComponent(hrefAttr); // decodeURI here for Chinese like unicode heading
if (href && href[0] === '#') {
a.onclick = (event) => {
event.preventDefault();
event.stopPropagation();

// NOTE: CSS.escape is needed here to escape special characters like '[' and number ID.
const targetElement = previewElement.current.querySelector(
`#${CSS.escape(href.slice(1))}`,
) as HTMLElement;
if (!targetElement) {
return;
}
if (!previewElement.current) {
return;
}

// jump to tag position
let offsetTop = 0;
let el = targetElement;
while (el && el !== previewElement.current) {
offsetTop += el.offsetTop;
el = el.offsetParent as HTMLElement;
}
// NOTE: CSS.escape is needed here to escape special characters like '[' and number ID.
const targetElement = previewElement.current.querySelector(
`#${CSS.escape(href.slice(1))}`,
) as HTMLElement;
if (!targetElement) {
return;
}

if (getWindowScrollTop() > offsetTop) {
setWindowScrollTop(offsetTop - 32 - targetElement.offsetHeight);
} else {
setWindowScrollTop(offsetTop);
}
};
} else {
a.onclick = (event) => {
event.preventDefault();
event.stopPropagation();
postMessage('clickTagA', [
{
uri: sourceUri.current,
href: encodeURIComponent(href.replace(/\\/g, '/')),
scheme: sourceScheme.current,
},
]);
};
// jump to tag position
let offsetTop = 0;
let el = targetElement;
while (el && el !== previewElement.current) {
offsetTop += el.offsetTop;
el = el.offsetParent as HTMLElement;
}

if (getWindowScrollTop() > offsetTop) {
setWindowScrollTop(offsetTop - 32 - targetElement.offsetHeight);
} else {
setWindowScrollTop(offsetTop);
}
};
} else {
a.onclick = (event) => {
event.preventDefault();
event.stopPropagation();
postMessage('clickTagA', [
{
uri: sourceUri.current,
href: encodeURIComponent(href.replace(/\\/g, '/')),
scheme: sourceScheme.current,
},
]);
};
}
} catch (error) {
// https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1934
continue;
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions styles/preview.less
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,9 @@ body.floating-action-open.preview-container {
max-width: 100%;
}
}

// https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1920
// it seems like tailwindcss overrides the `table` style.
pre span.token.table {
display: inline;
}
9 changes: 5 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6112,10 +6112,10 @@ merge2@^1.3.0, merge2@^1.4.1:
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==

mermaid@^10.8.0:
version "10.8.0"
resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-10.8.0.tgz#557123be494e216a9173bbaca3b5be5551428644"
integrity sha512-9CzfSreRjdDJxX796+jW4zjEq0DVw5xVF0nWsqff8OTbrt+ml0TZ5PyYUjjUZJa2NYxYJZZXewEquxGiM8qZEA==
mermaid@^10.9.0:
version "10.9.0"
resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-10.9.0.tgz#4d1272fbe434bd8f3c2c150554dc8a23a9bf9361"
integrity sha512-swZju0hFox/B/qoLKK0rOxxgh8Cf7rJSfAUc1u8fezVihYMvrJAS45GzAxTVf4Q+xn9uMgitBcmWk7nWGXOs/g==
dependencies:
"@braintree/sanitize-url" "^6.0.1"
"@types/d3-scale" "^4.0.3"
Expand All @@ -6128,6 +6128,7 @@ mermaid@^10.8.0:
dayjs "^1.11.7"
dompurify "^3.0.5"
elkjs "^0.9.0"
katex "^0.16.9"
khroma "^2.0.0"
lodash-es "^4.17.21"
mdast-util-from-markdown "^1.3.0"
Expand Down
Loading