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.8.7 #1838

Merged
merged 1 commit into from
Oct 15, 2023
Merged

0.8.7 #1838

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
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.8.7] - 2023-10-15

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

### New features

- Added `ID` button to copy the element id to clipboard:

![Screenshot from 2023-10-15 15-34-27](https://github.com/shd101wyy/crossnote/assets/1908863/ede91390-3cca-4b83-8e30-33027bf0a363)

- Supported to import section of markdown by header id:

```markdown
@import "test.md#header-id"

or

![](test.md#header-id)

or

![[test#header-id]]
```

### Bug fixes

- URL fragments on image links do not load: https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1837
- Supported matplotlib-type preview for other Python tools like `pipenv`: https://github.com/shd101wyy/crossnote/issues/332
- Fixed jump to header from link like `[link](test.md#header-id)`.
- Better handling of source map for importing files.

## [0.8.6] - 2023-10-14

This MPE version reduced the VS Code version requirement to 1.70.0 or above.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "markdown-preview-enhanced",
"displayName": "%displayName%",
"version": "0.8.6",
"version": "0.8.7",
"description": "%description%",
"categories": [
"Other"
Expand Down Expand Up @@ -674,7 +674,7 @@
"@types/crypto-js": "^4.1.2",
"@types/vfile": "^3.0.2",
"async-mutex": "^0.4.0",
"crossnote": "^0.9.1",
"crossnote": "^0.9.3",
"crypto-js": "^4.1.1"
},
"devDependencies": {
Expand Down
32 changes: 30 additions & 2 deletions src/extension-common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// For both node.js and browser environments
import { PreviewMode, utility } from 'crossnote';
import { HeadingIdGenerator, PreviewMode, utility } from 'crossnote';
import { SHA256 } from 'crypto-js';
import * as vscode from 'vscode';
import { PreviewColorScheme, getMPEConfig, updateMPEConfig } from './config';
Expand Down Expand Up @@ -581,7 +581,9 @@ export async function initExtensionCommon(context: vscode.ExtensionContext) {
});
} else {
// Open fileUri
const editor = await vscode.window.showTextDocument(document, col);
const editor = await vscode.window.showTextDocument(document, {
viewColumn: col,
});
// if there was line fragment, jump to line
if (line >= 0) {
let viewPos = vscode.TextEditorRevealType.InCenter;
Expand All @@ -591,6 +593,32 @@ export async function initExtensionCommon(context: vscode.ExtensionContext) {
const sel = new vscode.Selection(line, 0, line, 0);
editor.selection = sel;
editor.revealRange(sel, viewPos);
} else if (fileUri.fragment) {
// Normal fragment
// Find heading with this id
const headingIdGenerator = new HeadingIdGenerator();
const text = editor.document.getText();
const lines = text.split('\n');
let i = 0;
for (i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.match(/^#+\s+/)) {
const heading = line.replace(/^#+\s+/, '');
const headingId = headingIdGenerator.generateId(heading);
if (headingId === fileUri.fragment) {
// Reveal editor line
let viewPos = vscode.TextEditorRevealType.InCenter;
if (editor.selection.active.line === i) {
viewPos =
vscode.TextEditorRevealType.InCenterIfOutsideViewport;
}
const sel = new vscode.Selection(i, 0, i, 0);
editor.selection = sel;
editor.revealRange(sel, viewPos);
break;
}
}
}
}
}
} else {
Expand Down
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.9.1:
version "0.9.1"
resolved "https://registry.yarnpkg.com/crossnote/-/crossnote-0.9.1.tgz#337501353c0d9f756aca3f692437ec98a7f3b2e3"
integrity sha512-KITHY/6RQSun5qSZBVbpIYUme0af0bb74pd75gSRuKBVmrgJooOC1AFpdRfREVqIboHXfmXvtRM84xtRk0Y0ow==
crossnote@^0.9.3:
version "0.9.3"
resolved "https://registry.yarnpkg.com/crossnote/-/crossnote-0.9.3.tgz#b8bb76eea4042839520ed764bd28155023b2b2b3"
integrity sha512-j1JIoswsKPYmEpqQ3iZoA/EnCaWNRmzhgnRIJR+2xfvqAvLif4beYHGwktJo9kDIqxQhCrK+QjSvDoAgk3cTOQ==
dependencies:
"@headlessui/react" "^1.7.17"
"@heroicons/react" "^2.0.18"
Expand Down
Loading