Moved Content to HTML functionallity to Shared API and implement IMG files#624
Conversation
jgclark
left a comment
There was a problem hiding this comment.
Overall, makes good sense to shift the code around.
Some small points to fix, please.
helpers/HTMLView.js
Outdated
| * Convert a note's content to HTML and include any images as base64 | ||
| * @author @cwhittl | ||
| * @param {string} content | ||
| * @param {NPNote} Note |
| /** | ||
| * Convert a note's content to HTML and include any images as base64 | ||
| * @author @cwhittl | ||
| * @param {string} content |
There was a problem hiding this comment.
Why pass content and note? Is this different content from what the note has?
helpers/HTMLView.js
Outdated
|
|
||
| /** | ||
| * Convert a note's content to HTML and include any images as base64 | ||
| * @author @cwhittl |
There was a problem hiding this comment.
You mean because i wrote a few lines it's not my code? I 100% don't know what I was thinking, removed.
np.Preview/src/previewMain.js
Outdated
| * @param {string?} mermaidTheme name (optional) | ||
| */ | ||
| export function previewNote(mermaidTheme?: string): void { | ||
| export async function previewNote(mermaidTheme?: string): void { |
There was a problem hiding this comment.
You've removed a default for mermaidTheme. Please add='green'.
|
@cwhittl @jgclark I pulled and tried to test the PR but I wasn't 100% sure what to test. Here's what the @jgclark test document looks like when shared using the built-in NotePlan sharing: Note that Eduard is loading the fonts remotely: Download the test documents: |
|
@cwhittl @jgclark I wonder if you can bake @EduardMe's custom noteplanstate font into the html itself? ChatGPT says we can. https://chatgpt.com/share/67b55c18-1244-8012-a635-2d8f9e3c123d Here are the font files: Here are the ascii chars that generate each glyph as far as I can tell: const states = [
{ type: 'open', icon: '*', class: 'noteplanstate' },
{ type: 'done', icon: 'a', class: 'noteplanstate' },
{ type: 'scheduled', icon: 'b', class: 'noteplanstate' },
{ type: 'cancelled', icon: 'c', class: 'noteplanstate' },
{ type: 'list', icon: '-', class: 'noteplanstate' },
{ type: 'checklist', icon: '+', class: 'noteplanstate' },
{ type: 'checklistDone', icon: 'd', class: 'noteplanstate' },
{ type: 'checklistCancelled', icon: 'e', class: 'noteplanstate' },
{ type: 'checklistScheduled', icon: 'f', class: 'noteplanstate' },
]Also in case anybody is interested for posterity, there's some Eduard -> Jonathan discussion here about FontAwesome glyphs. |
|
Now that I look at this document I realize... @EduardMe has gone to great lengths to make the HTML version of a published note look as much like it does in the editor as possible. Maybe you guys want to look at whether you can adapt his JS code (which is basically one JS file) to generate the HTML preview rather than using the more general purpose showdown or doing it by hand? Just a thought... Of course, @cwhittl still needs @EduardMe to take a look at getting the HTML to clipboard. |
|
@jgclark @dwertheimer @EduardMe I'm really fine either way, my goal has been to be able to copy an HTML version of the a note including images to other applications. With this change to preview I can do that but completely ok switching gears and looking in another direction if you all want to point me there. If you want I can move the code back to np.Preview and we can get the functionallity for now this way and then work on using @EduardMe version (if he's ok with that) to make a more common library. |
|
I will leave that to @jgclark. But are you able to copy to the Clipboard? |
|
Right now to make it work I just do a preview and then copy and paste from that window. On my other plugin that I am making the clipboard doesn't work other than just Clipboard.string from what I have tested. |
|
Copying html into the clipboard through the API is fixed for the next update. |
|
IMHO we now have a couple of different design questions, and at least one bug, here.
|
|
On 2: I'm happy to try this: perhaps "HTML Output" with commands "Save as HTML" (the one one) and "Preview as HTML" (the existing one). Thoughts? On 3: I hope @EduardMe can comment on whether getting an API call like |
|
An API call like |
|
So this PR was to make images work with Preview and to move that functionality to a shared place to be used by other plugins. Are we ok with that? The bug that @EduardMe has put a fix for doesn't keep this PR from going it will be a problem for my extension (that's not on this PR) and will test it during that process. |
|
I know I was going beyond the scope of the PR with the discussion above, but wanted to capture it while I was thinking about it. |




Moved Content to HTML functionallity to Shared API and implement IMG files to base64