diff --git a/package-lock.json b/package-lock.json index b2b6983d7..bc6ea84c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,6 +66,7 @@ "marked": "^13.0.2", "mermaid": "^10.9.1", "mime-types": "2.1.35", + "mind-elixir": "^4.0.5", "multer": "1.4.5-lts.1", "node-abi": "^3.65.0", "normalize-strings": "1.1.1", @@ -13002,6 +13003,11 @@ "dom-walk": "^0.1.0" } }, + "node_modules/mind-elixir": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/mind-elixir/-/mind-elixir-4.0.5.tgz", + "integrity": "sha512-zFYNabpchCY468d/vqo68hnhP+VDN47uPyJJ4dYlkqvL7fomRlo/WJinYgH+Rjt5vFJVLEMBtFsv5fizAC4ZYg==" + }, "node_modules/minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", diff --git a/package.json b/package.json index b88f50161..66dce9b1e 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,7 @@ "marked": "^13.0.2", "mermaid": "^10.9.1", "mime-types": "2.1.35", + "mind-elixir": "^4.0.5", "multer": "1.4.5-lts.1", "node-abi": "^3.65.0", "normalize-strings": "1.1.1", diff --git a/src/public/app/services/library_loader.js b/src/public/app/services/library_loader.js index 1d9fce599..9d73d775d 100644 --- a/src/public/app/services/library_loader.js +++ b/src/public/app/services/library_loader.js @@ -79,6 +79,12 @@ const I18NEXT = { ] }; +const MIND_ELIXIR = { + js: [ + "node_modules/mind-elixir/dist/MindElixir.iife.js" + ] +}; + async function requireLibrary(library) { if (library.css) { library.css.map(cssUrl => requireCss(cssUrl)); @@ -137,5 +143,6 @@ export default { MERMAID, EXCALIDRAW, MARKJS, - I18NEXT + I18NEXT, + MIND_ELIXIR } diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index 5b029fa14..91aa9998e 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -146,7 +146,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget { this.$widget.toggleClass("full-height", ( !this.noteContext.hasNoteList() - && ['canvas', 'webView', 'noteMap'].includes(this.type) + && ['canvas', 'webView', 'noteMap', 'mindMap'].includes(this.type) && this.mime !== 'text/x-sqlite;schema=trilium' ) || this.noteContext.viewScope.viewMode === 'attachments' diff --git a/src/public/app/widgets/type_widgets/mind_map.js b/src/public/app/widgets/type_widgets/mind_map.js index 1121a8f08..1f4dc4968 100644 --- a/src/public/app/widgets/type_widgets/mind_map.js +++ b/src/public/app/widgets/type_widgets/mind_map.js @@ -1,7 +1,21 @@ +import libraryLoader from "../../services/library_loader.js"; import TypeWidget from "./type_widget.js"; const TPL = `
+
+
+ +
`; @@ -10,15 +24,21 @@ export default class MindMapWidget extends TypeWidget { doRender() { this.$widget = $(TPL); + this.$content = this.$widget.find(".mind-map-container"); + + libraryLoader + .requireLibrary(libraryLoader.MIND_ELIXIR) + .then(() => { + const mind = new MindElixir({ + el: this.$content[0], + direction: MindElixir.LEFT + }); + mind.init(MindElixir.new("hello")); + }); super.doRender(); } - async doRefresh(note) { - this.$widget.html("

Hello

"); - this.$widget.show(); - } - cleanup() { this.$widget.empty(); } diff --git a/src/routes/assets.ts b/src/routes/assets.ts index 076f2bb21..684340466 100644 --- a/src/routes/assets.ts +++ b/src/routes/assets.ts @@ -100,6 +100,8 @@ function register(app: express.Application) { app.use(`/${assetPath}/node_modules/codemirror/addon/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/codemirror/addon/'))); app.use(`/${assetPath}/node_modules/codemirror/mode/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/codemirror/mode/'))); app.use(`/${assetPath}/node_modules/codemirror/keymap/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/codemirror/keymap/'))); + + app.use(`/${assetPath}/node_modules/mind-elixir/dist/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/mind-elixir/dist/"))); } export default {