Skip to content

[Refactor] Notes#11971

Draft
SchrodingersGat wants to merge 98 commits into
inventree:masterfrom
SchrodingersGat:block-notes
Draft

[Refactor] Notes#11971
SchrodingersGat wants to merge 98 commits into
inventree:masterfrom
SchrodingersGat:block-notes

Conversation

@SchrodingersGat
Copy link
Copy Markdown
Member

@SchrodingersGat SchrodingersGat commented May 20, 2026

Example Screenshots

Description Screenshot
Display Mode image
Edit Mode image
Rendered to report image

Generic Notes Table

The major item here is to move all notes into a new table, which has generic FK links to other items. This brings it into line with how we handle attachments, parameters, etc.

Multiple Notes

We can now specify multiple, separate notes per item. This is useful for keeping different types of notes separate - e.g. shipping instructions vs inspection instructions (for e.g.)

Render to report

Rendering notes to reports is now greatly improved. In particular, images are correctly handled now - and can even be resized based on the specified size in the HTML content

Editor Updates

Also introduces the possibility of a more intuitive notes editor.

At this stage, I am trialing BlockNote - which provides navite mantine support, and provides a "notion style" editing interface.

I am using the Rich Text Editor shipped as part of the Mantine framework.

Pros:

  • Intuitive, "modern" editing interface
  • Supports more content layout features
  • Resizable images

Cons:

  • Requires HTML formatting
  • Current notes use markdown

Tasks

  • Display note information (title / description / last updated by)
  • Allow edit notes (if user has permission)
  • Allow delete notes (if user has permission)
  • Client side sanitize of notes
  • Server side sanitize of notes
  • Support direct image upload (drag and drop / copy-paste)
  • Render notes in PDF reports
  • Ensure inline images are rendered correctly in PDF reports
  • Documentation
  • Data migration for existing notes
  • Data migration for existing notes image
  • Handle legacy "NotesImage" concept - how to detect and embed these images?
  • prevent navigation away when notes are dirty
  • Allow note selection from query params
  • Update demo dataset with notes / images / etc (BEFORE migration)
  • Apply data migration to demo dataset
  • Unit tests (backend)
  • Duplicate notes from existing instance - also copies embedded images
  • Playwright tests
  • Unit tests for data migrations
  • Remove "notes" field from any models which use the new approach
  • Delete the old "notes" mixin class
  • Support dark mode
  • Support localization
  • Remove old dependencies for simplemde
  • Delete old "delete_old_notes_images" task
  • Mark "delete_old_notes_images" task as outdated
  • Update app support (display multiple notes)
  • Add CHANGELOG entry

Ideas for future work

  • Add plugin to link directly to attachments
  • Add plugin to link to other pages (e.g. parts / orders / etc)
  • Export notes?

@SchrodingersGat SchrodingersGat added this to the 1.4.0 milestone May 20, 2026
@SchrodingersGat SchrodingersGat added api Relates to the API refactor feature migration Data or schema migrations User Interface Related to the frontend / User Interface full-run Always do a full QC CI run labels May 20, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 20, 2026

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit a46bb39
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a213cb75881a60008d4ebcb
😎 Deploy Preview https://deploy-preview-11971--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 93 (no change from production)
Accessibility: 82 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@SchrodingersGat SchrodingersGat marked this pull request as draft May 20, 2026 12:41
@SchrodingersGat
Copy link
Copy Markdown
Member Author

@matmair @wolflu05 before I go too far with this I'd be interested in your feedback around two major points:

Data Structure Refactor: Are we on board with the idea of supporting multiple notes per item?

Editor: Do you have any objections to moving to a new editor, and move to HTML notes? We will obviously have to tackle any data sanitizing required here

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 82.12928% with 94 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.94%. Comparing base (47c6906) to head (a46bb39).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11971      +/-   ##
==========================================
- Coverage   91.44%   90.94%   -0.50%     
==========================================
  Files         976      984       +8     
  Lines       52162    52596     +434     
==========================================
+ Hits        47701    47835     +134     
- Misses       4461     4761     +300     
Flag Coverage Δ
backend 89.97% <82.12%> (-0.49%) ⬇️
migrations 40.28% <38.21%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 91.12% <50.00%> (-0.65%) ⬇️
Backend General 93.11% <88.91%> (-0.27%) ⬇️
Frontend ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matmair
Copy link
Copy Markdown
Member

matmair commented May 20, 2026

I think the general idea is very good; a few points/ideas:

  • I would like to see some tests in the final PR to ensure we do not leak data due to this migration
  • if we already build a new model we might as well add created, updated and created_by, updated_by fields
  • does a note owner make sense?
  • should we add user customizable types?
  • should we addnote states?
  • having a special "primary" note that still renders to the api seems like a good idea; i have seen a bunch of ppl use notes fields for all kind of plugins; this change would be pretty breaking

I like blocknote as a choice, the OpenProject and a bunch of other EU sovereign gov cloud products use it.
How we save/provide notes data in the future is still a bit of a question; there is markdown support from what I can tell. And if we are already switching data model why not use the native document format and just save a html (or markdown) representation on the side? That seems safer and better for future customizations of the editor capabilities.

Things i am unsure about:

  • what does rendering to reports look like? are existing reports breaking?
  • possible security problems?

@wolflu05
Copy link
Copy Markdown
Member

I also like the general idea, the current notes editor seems very limited. But I would appreciate if there would be some easy migration path from markdown based notes to the new format, and a method to render the new notes format to reports.

Comment thread docs/docs/concepts/notes.md Outdated
Copy link
Copy Markdown
Member

@matmair matmair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great effort; looks very close already!
Maybe we can merge this in the next-breaking branch for now?

Comment thread docs/docs/concepts/terminology.md Outdated
Comment thread src/backend/InvenTree/common/api.py Outdated
return self.template.description


class Note(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Having a stable order identifier on the model might be interesting

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matmair can you clarify this point? I'm not sure what you mean here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a field that keeps the order of the notes for that object. That could be used to set a stable order of notes in the UI. Right now the order depends on the creation order/pk if I interpret it right.

self.check_delete()
super().delete()

def clean(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible I would like to see security relevant cleaning data outside of a model class and tested independently so that missing coverage is more visible in the reports

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you propose what that would look like?

Comment thread src/backend/InvenTree/InvenTree/helpers.py Outdated
Comment thread src/frontend/package.json Outdated
Comment thread src/frontend/package.json
@matmair
Copy link
Copy Markdown
Member

matmair commented Jun 3, 2026

Can we remove django-markdownify with this? would remove a few dependencies. I have made a small demo branch for this: matmair#676

SchrodingersGat and others added 6 commits June 4, 2026 18:44
Co-authored-by: Matthias Mair <code@mjmair.com>
- Only used for this migration
- Will potentially be removed at some point in the future?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API breaking Indicates a major update or change which breaks compatibility feature full-run Always do a full QC CI run migration Data or schema migrations refactor User Interface Related to the frontend / User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notes Improvements

3 participants