Skip to content

New plugin: Canvas View — support obsidian like .canvas files inside NotePlan - #785

Open
lifeplayer67 wants to merge 1 commit into
NotePlan:mainfrom
lifeplayer67:lifeplayer67.CanvasView
Open

lifeplayer67 wants to merge 1 commit into
NotePlan:mainfrom
lifeplayer67:lifeplayer67.CanvasView

Conversation

@lifeplayer67

@lifeplayer67 lifeplayer67 commented Sep 25, 2026 •

Copy link
Copy Markdown

Hi! First of all, thanks for the great app and flexible plugin system. I migrated to it from Obsidian. I like its native integration with Apple infra and all my calendars. A few things I was missing:

  • graph view (which I found as an extension)
  • canvases for visual thinking (which are implemented in this PR)

Sorry for doing all of that without discussion. I have ADHD and I would never finish it any other way. It implements almost all canvas features (I list what it doesn't below):

  • Cards, notes, edges, groups with all the additional stuff like labels, selecting, editing, colors, ⌘C/⌘V
  • Note cards show the actual note content (not live, but refreshed when you move back to the canvas view) and you can edit it right in the card

What it doesn't support:

  • Canvas files are JSON and they show up named { in the notes list. In addition, I cannot assign the canvas view as the default one for those files, so NotePlan opens the JSON content. This one is critical in my opinion. It would be great to support it natively.
  • Media and website nodes are not implemented.

I hope you will like it. Let me know if you have any questions or requests.

@lifeplayer67 lifeplayer67 changed the title New plugin: Canvas View — edit Obsidian Canvas (.canvas) files inside NotePlan New plugin: Canvas View — support obsidian like .canvas files inside NotePlan Sep 26, 2026
@jgclark

jgclark commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

@EduardMe please use your plugin review skill on this submission.

@EduardMe

EduardMe commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Hi @lifeplayer67, thank you for the Canvas View plugin. It is a useful feature, and the code is well organized.

Repository: We do not add community plugins to this repository anymore, we have introduced "Community Plugins" some time ago. Here is what you need to do: Please move the plugin to your own GitHub repository. Then do these steps:

  1. Publish a GitHub release. Attach plugin.json, script.js, canvasClient.js, and showdown.min.js as release assets.
  2. (optional) Change this PR so that it only adds one entry to community-plugins.json. Or we can add it to the community plugins JSON.

For an example, see https://github.com/EduardMe/noteplan-stock-ticker-plugin and its entry in community-plugins.json.

Before we can add the plugin to the list, please make these changes:

Required

  1. HTML injection: canvasClient.js puts n.color, n.x, n.y, n.width, n.height, and the edge color into the HTML without escaping. A .canvas file from another person can use this to run a script in the plugin window. That script can then overwrite notes or write files. Validate the colors (preset number or #hex only) and the numbers before you use them.
  2. Write path: saveCanvas writes to payload.path, which comes from the HTML window. In the plugin, only write to the path of the canvas that the plugin opened.
  3. Website previews: Link cards show the website in an <iframe> with allow-scripts. The plugin window has access to the NotePlan API, so do not run scripts from other websites in it. If it doesn't break the previews, remove allow-scripts from the sandbox attribute, or show the link without a live preview.

The { name in the notes list and the default view for .canvas files are NotePlan app features. We will look at these separately.

When you publish the release, add a comment here. We will then do a new review.

Thank you!

lifeplayer67 added a commit to lifeplayer67/plugins that referenced this pull request Nov 2, 2026
…suite

Address review feedback on NotePlan#785:
- HTML/SVG injection: colors are validated (preset digit or #hex only) and
  node geometry is coerced to finite numbers before it reaches style/SVG
  attributes; applied on boot, undo/redo restore and clipboard paste.
- Write path: saveCanvas only writes to canvases registered by the plugin in
  this session, with a strict fallback (inside Notes, *.canvas, no '..') for
  panes restored after an app restart.
- Link previews: iframe sandbox tightened to full restrictions (no scripts,
  no same-origin) — third-party pages can no longer run code in the plugin
  window.

Also: 11 jsdom interaction tests driving the real client (selection, drag,
rubber-band, group frame/interior semantics, delete/undo/redo, Cmd+G,
double-click create/edit) plus injection-guard unit tests — 26 tests total.
@lifeplayer67
lifeplayer67 force-pushed the lifeplayer67.CanvasView branch from 0d31672 to a39d11f Compare November 2, 2026 18:40
@lifeplayer67

Copy link
Copy Markdown
Author

Hi @EduardMe, thanks for the review! Finally I have time to solve your comments, so:

  • plugin moved to its own repo lifeplayer67/noteplan-canvas-view, release v1.0.2 is published. One note - after splitting the code for readability there are now six release assets instead of four (plugin.json, script.js, canvasCore.js, canvasClient.js, canvasView.css, showdown.min.js).
  • this PR now adds only entry to community-plugins.json.
  • all three required fixes are in:
    a. colors are validated (preset digit or #hex only) and node geometry is coerced to clamped finite numbers before anything reaches the DOM - on load, undo/redo and paste. While testing this I also found and fixed one more vector: a javascript: url in a link card now renders as inert text (same http/https rule as the preview iframe).
    b. saveCanvas only writes to canvases the plugin opened this session, with a strict fallback (inside Notes, *.canvas, no ..) for panes restored after an app restart.
    c. preview iframe runs with an empty sandbox - no scripts from third-party sites.
  • Also added a test suite along the way: 27 tests (unit + jsdom interaction tests + injection guards).

@EduardMe

EduardMe commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Hi @lifeplayer67, thank you for the update and the new tests! The repo move, the release, the write-path check and the sandboxed previews all look good.

One thing is still open before we can add the plugin to the list:

Node type is not escaped. In canvasClient.js line 160, n.type goes into the class attribute as-is, and sanitizeCanvas does not check it. A .canvas file with a value like "type": "x\"><img src=x onerror=…>" runs a script as soon as the canvas opens, with no click. Because the plugin window has access to the NotePlan API, that script could overwrite notes or read them. This is the same kind of problem as the color and position values from the first review, so a shared .canvas file (for example from an Obsidian vault) is enough.

The fix is small: in sanitizeCanvas, allow only text, file, link and group, and drop or convert other nodes. A test for it next to your other injection tests would be great.

Optional, if you have a minute: showdown does not filter link URLs, so x in a text card becomes a clickable javascript: link. Keeping only http(s), mailto:, # and relative links after makeHtml (the same rule as for link cards) closes that too. This one needs a click, so we will not block the plugin on it.

When the fix is released, add a comment here and we will add the plugin. Thank you!

Canvas View edits Obsidian Canvas (.canvas / JSON Canvas) files inside
NotePlan. Plugin lives at lifeplayer67/noteplan-canvas-view, release v1.0.0.
@lifeplayer67
lifeplayer67 force-pushed the lifeplayer67.CanvasView branch from a39d11f to 4a0df95 Compare November 14, 2026 19:27
@lifeplayer67

Copy link
Copy Markdown
Author
  • Fixed in v1.0.3 (released): node types are whitelisted before rendering - malicious "type" never reaches the class attribute. One deliberate deviation from the suggested fix: instead of dropping unknown nodes in sanitizeCanvas, they render as an inert "unsupported" card while the node data is preserved — dropping would silently delete extended node types (e.g. from Obsidian plugins) on the first save, since the plugin writes the whole document back. Raw type strings still never reach the DOM.
  • Took the optional one too: link hrefs after markdown conversion are restricted to http(s), mailto:, # and relative - in both text cards and note cards.
  • Updates are covered with tests

@EduardMe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants