Skip to content
Merged
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
8 changes: 5 additions & 3 deletions helpers/HTMLView.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export async function getNoteContentAsHTML(content: string, note: TNote): ?strin
}
const converter = new showdown.Converter(converterOptions)
let body = converter.makeHtml(lines.join(`\n`))
body = `<style>img { max-width: 100%; max-height: 100%; }</style>${body}` // fix for bug in showdown
body = `<style>img { background: white; max-width: 100%; max-height: 100%; }</style>${body}` // fix for bug in showdown

const imgTagRegex = /<img src=\"(.*?)\"/g
const matches = [...body.matchAll(imgTagRegex)]
Expand All @@ -172,8 +172,10 @@ export async function getNoteContentAsHTML(content: string, note: TNote): ?strin
const imagePath = match[1]
try {
// Handle both absolute and relative paths
const fullPath = `../../../Notes/${noteDirPath}/${decodeURI(imagePath)}`

let fullPath = `../../../Notes/${noteDirPath}/${decodeURI(imagePath)}`
if(fullPath.endsWith('.drawing')) {
fullPath = fullPath.replace('.drawing', '.png')
}
const data = await DataStore.loadData(fullPath)
if (data) {
const base64Data = `data:image/png;base64,${data.toString('base64')}`
Expand Down
3 changes: 3 additions & 0 deletions np.Preview/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# What's Changed in 🖥️ Previews plugin?
See [website README for more details](https://github.com/NotePlan/plugins/tree/main/np.Preview), and how to configure it.

## [0.4.4] - 2025-02-20
- added embed images to preview, fixed some bugs

## [0.4.3] - 2023-11-10
- stops the Preview window stealing focus in live preview mode

Expand Down
1 change: 0 additions & 1 deletion np.Preview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ It adds a 'Print (opens in system browser)' button to the preview window (on mac
## Limitations
This is designed to be a temporary solution while we wait for similar functionality to get baked into the NotePlan app itself. To that end, I don't intend to be making many improvements to this. In particular I'm aware that:

- it does not render embedded images
- there are bugs in the rendering of frontmatter arising from one of the third-party libraries this uses.

## Automatic updating
Expand Down
4 changes: 2 additions & 2 deletions np.Preview/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"plugin.icon": "",
"plugin.author": "Jonathan Clark",
"plugin.url": "https://github.com/NotePlan/plugins/tree/main/np.Preview/",
"plugin.version": "0.4.3",
"plugin.lastUpdateInfo": "v0.4.3: stop updates stealing focus from the note editor.\nv0.4.2: fix regression stopping Mermaid rendering.\nv0.4.1: improve display of [[notelinks]], ==highlights== and ~underlining~.\nv0.4.0: new command \"/start live preview\".\nv0.3.1: display improvements and turn off print button for iOS.\nv0.3.0: print button, trigger, updated Mermaid library, use appropriate Mermaid theme.",
"plugin.version": "0.4.4",
"plugin.lastUpdateInfo": "v0.4.4: added embed images to preview, fixed some bugs",
"plugin.changelog": "https://github.com/NotePlan/plugins/blob/main/np.Preview/CHANGELOG.md",
"plugin.dependencies": [],
"plugin.requiredFiles": [
Expand Down