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

New note type canvas-note using excalidraw (hand drawn notes, sketching, pen) #2798

Merged
merged 88 commits into from
May 12, 2022

Conversation

thfrei
Copy link
Contributor

@thfrei thfrei commented Apr 17, 2022

New Features:

  • Use excalidraw for new note type: canvas-note Allows basic sketching and hand-drawn notes
  • Book-View, Revisions
  • Image API without filename allowed
  • Serve node_modules folder (is this secure?)

ToDo:

Suggestion for Roadmap for next PR (not doing right now):

  • Include trilium-image or canvas-note via reference in excalidraw?
  • Change colors and pen sizes via theme?
  • Indicate status of note (note content changed, note content saved to backend)
  • Use excalidraw user libraries of icons, by adding them as js-notes (https://libraries.excalidraw.com/?theme=light&sort=default)
  • Dark theme (actually, right now, it is more of an inverted theme)
  • It would be nice to have a possibility to add canvas-notes to text-note ckeditor by dragging it onto the editor. Right now, we can only convert it to source-code, and then manually add an img-tag with the api/image-link.
  • Update excalidraw as soon as 0.12.0 is released:

Related to:

Impressions:

  • grafik
  • grafik
  • 2022-04-17 22_17_18-Canvasses - Trilium Notes
  • 2022-04-17 21_55_28-Discussion regarding canvas note
  • grafik
  • 2022-04-17 21_52_34-Discussion regarding canvas note - Trilium Notes
  • 2022-04-16 10_25_16-canvas 2 - Trilium Notes
  • Share view:
    • grafik

Comment on lines 440 to 444
onCollabButtonClick: () => {
window.alert("You clicked on collab button")
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to outright remove the collab button? It might be more helpful to say something like "Collaboration disabled within Trilium" if not, rather than just "you clicked it".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure. I think it would be good to disable some buttons and stuff. It is not possible via configuration, I think. We could hide them via CSS maybe, which is quite hacky.

Now, when I think about it, the Collab button could be used to enable shareing? Or maybe we can open a box that shows all the links to embed the canvas-note (api/image..., share/api/image...)

Copy link
Contributor

Choose a reason for hiding this comment

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

The collab button can be used to actually collaborate; it is a pretty small server. I'm not sure if it's in scope though (probably not) but it would be pretty cool.

Regardless the error message could be changed to something a bit more descriptive in case someone sees that and thinks it is enabled

Copy link
Owner

Choose a reason for hiding this comment

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

I think in the near term it would be nice to hide such buttons, with CSS if needed. But it's not a blocker.

@sigaloid
Copy link
Contributor

This is awesome. Can't wait for this to be merged. A few questions:

  • Does it render an interaction window for shared notes? It looks like it just renders the SVG and I'm curious if it would make sense to have an option to render it for people who want to zoom/pan/etc (especially with oversized notes).
  • Also: Does embedding a canvas note into another note allow it to update (ie, when I change child note, does it update image in parent)?

@thfrei
Copy link
Contributor Author

thfrei commented Apr 18, 2022

Does it render an interaction window for shared notes? It looks like it just renders the SVG and I'm curious if it would make sense to have an option to render it for people who want to zoom/pan/etc (especially with oversized notes).

It does render the view mode. I got heavily inspired by the screenshot of your code (#2328 (comment)) . What is missing, is the correct placement with the css and the flex attributes. Maybe you can give a hand there?

grafik

Also: Does embedding a canvas note into another note allow it to update (ie, when I change child note, does it update image in parent)?

It is embedded via link, so yes (image must be reloaded after a change, of course). What I still need is embedding a canvas-note in another canvas-note via link. I think that would be fun. Or, more generally speaking, embedding images into canvas-note via link. Since we store the svg in the canvas-note, it should be possible to handle this in the same way. See also: https://github.com/zadam/trilium/pull/2798/files#diff-bd7fd937c20ac950412e1e84c91ca7a6c36694eaa9de924f9862c1edcc21a887R237

grafik

thfrei added 27 commits April 19, 2022 00:13
 Conflicts:
	src/public/app/services/library_loader.js
	src/public/app/services/tree_context_menu.js
	src/public/app/widgets/note_actions.js
	src/services/consistency_checks.js
	src/services/utils.js
 Conflicts:
	src/public/app/entities/note_short.js
	src/public/app/services/tree_context_menu.js
due to some upstream changes, this was necessary.
otherwise complete inside container was not visible.
@thfrei
Copy link
Contributor Author

thfrei commented May 10, 2022

@zadam I worked on all issues. Except for 3, where I have open questions. The others, I fixed and marked the conversation as resolved (not sure, if that is how you guys do it with github though). How do you want to proceed?

@zadam
Copy link
Owner

zadam commented May 10, 2022

@thfrei great, thanks for the fast turnaround. Where are those 3 items with open questions? Somehow I don't see any ...

@thfrei
Copy link
Contributor Author

thfrei commented May 10, 2022

@zadam
Copy link
Owner

zadam commented May 10, 2022

@thfrei I see, I think that was a misunderstanding. I thought you had some questions which you wrote into those unresolved conversations ...

@thfrei
Copy link
Contributor Author

thfrei commented May 11, 2022

@thfrei I see, I think that was a misunderstanding. I thought you had some questions which you wrote into those unresolved conversations ...

I left them, so that you can decide how to proceed:

  • Should we change the WidgetType to AbstractTextTypeWidget so that we can use this.initialized?
  • I left the constant this.DEBOUNCE_TIME_ONCHANGEHANDLER = 750; // ms in the constructor, so as to indicate, that it belongs to this class.
  • this.$widget.toggleClass("full-height", true); // only add is required. I am not sure about why.

@zadam zadam merged commit 87b75a9 into zadam:master May 12, 2022
@thfrei
Copy link
Contributor Author

thfrei commented May 13, 2022

🎆
Thank you for merging :-)

@capi
Copy link
Contributor

capi commented Jun 10, 2022

I'm a very heavy user of both Trilium and Excalidraw, and seeing the two of them being combined like that is a dream I never knew I had come true! Thank you very much! The navigation between multiple drawings is so easy now, it's awesome!

@thfrei
Copy link
Contributor Author

thfrei commented Jun 10, 2022

The navigation between multiple drawings is so easy now, it's awesome!

Thank you for your kind words capi. I'm really glad you like it. I never thought of it that way, but you are right, even if you would not use trilium for notes, having like kind of a "file-browser" for different excalidraw drawings is a win :-)

@4abhinavjain
Copy link

Thanks for this feature. Really amazing. I knew of Trilium but didn't use it as the draw feature was missing. I have installed the latest 0.52.3 on windows but could not find a way to make a Canvas notes. When I click the '+' sign, as a new note, I don't get an option to add Canvas/Excalidraw

You may also want to check out: https://www.youtube.com/watch?v=o0exK-xFP3k . They are doing some amazing work with Obsidian and I think many will be more comfortable with an open-source program like Trilium over Obsidian.

@capi
Copy link
Contributor

capi commented Jun 23, 2022

You have to change the entire node type to "Canvas" in the "Basic Properties"
image

@zadam
Copy link
Owner

zadam commented Jun 23, 2022

You can also create it directly from menu:

image

@thfrei
Copy link
Contributor Author

thfrei commented Jun 24, 2022

@zadam When I think about it, it might be nice to have an attribute that defines the type of child notes. Like so:
#childrenNoteType="canvas"?? (this would be a new feature)

@4abhinavjain Another option:
If you want to create a lot of canvas notes in the same place, you could do this:

  • Create one note, under which you want to create all the canvas notes. Let's call it: CanvasParent
  • grafik
  • Create a JS backend note with the following content and title: change note type to canvas:
api.log('set to canvas test');
const note = api.originEntity;
note.type="canvas";
note.save();  
  • Now add the relateion from CanvasParent: ~runOnChildNoteCreation=change note type to canvas
  • This will chane the note type on the backend for every child note to canvas.

I exported the notes into the attached zip. (uncheck safe import, since it contains a js backend note):

PS: the title of the notes does not matter in the end, just the relation.

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.

5 participants