Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
added collapsible widgets to the docs
zadam8526cb231593
diff --git a/docs/frontend_api/Branch.html b/docs/frontend_api/Branch.htmlindex e4d6a52e84..f8a5d85737 100644--- a/docs/frontend_api/Branch.html+++ b/docs/frontend_api/Branch.html@@ -879,7 +879,7 @@</div><nav>- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul></nav><br class="clear">diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.htmlindex bf5e6142f4..4be2672707 100644--- a/docs/frontend_api/FrontendScriptApi.html+++ b/docs/frontend_api/FrontendScriptApi.html@@ -5483,7 +5483,7 @@ Typical use case is when new note has been created, we should wait until it is s</div><nav>- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul></nav><br class="clear">diff --git a/docs/frontend_api/NoteComplement.html b/docs/frontend_api/NoteComplement.htmlindex 02e7ea1970..ae6edadd3b 100644--- a/docs/frontend_api/NoteComplement.html+++ b/docs/frontend_api/NoteComplement.html@@ -507,7 +507,7 @@</div><nav>- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul></nav><br class="clear">diff --git a/docs/frontend_api/NoteShort.html b/docs/frontend_api/NoteShort.htmlindex d3c6337842..df31231edf 100644--- a/docs/frontend_api/NoteShort.html+++ b/docs/frontend_api/NoteShort.html@@ -6813,7 +6813,7 @@ Cache is note instance scoped.</div><nav>- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul></nav><br class="clear">diff --git a/docs/frontend_api/entities_attribute.js.html b/docs/frontend_api/entities_attribute.js.htmlindex 6c73abfce9..a74c256fb4 100644--- a/docs/frontend_api/entities_attribute.js.html+++ b/docs/frontend_api/entities_attribute.js.html@@ -79,7 +79,7 @@ export default Attribute;</code></pre></div><nav>- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul></nav><br class="clear">diff --git a/docs/frontend_api/entities_branch.js.html b/docs/frontend_api/entities_branch.js.htmlindex 1c60b1af39..f492aabbb5 100644--- a/docs/frontend_api/entities_branch.js.html+++ b/docs/frontend_api/entities_branch.js.html@@ -81,7 +81,7 @@ export default Branch;</code></pre></div><nav>- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul></nav><br class="clear">diff --git a/docs/frontend_api/entities_note_complement.js.html b/docs/frontend_api/entities_note_complement.js.htmlindex 5e85d7b9ad..75b9636e8b 100644--- a/docs/frontend_api/entities_note_complement.js.html+++ b/docs/frontend_api/entities_note_complement.js.html@@ -61,7 +61,7 @@ export default NoteComplement;</code></pre></div><nav>- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul></nav><br class="clear">diff --git a/docs/frontend_api/entities_note_short.js.html b/docs/frontend_api/entities_note_short.js.htmlindex 34a9d0e208..4f56dd9ceb 100644--- a/docs/frontend_api/entities_note_short.js.html+++ b/docs/frontend_api/entities_note_short.js.html@@ -493,7 +493,7 @@ export default NoteShort;</code></pre></div><nav>- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul></nav><br class="clear">diff --git a/docs/frontend_api/global.html b/docs/frontend_api/global.htmlindex 1d2eca8683..6525a2d093 100644--- a/docs/frontend_api/global.html+++ b/docs/frontend_api/global.html@@ -95,6 +95,275 @@++ <h3 class="subsection-title">Methods</h3>++++++++ <h4 class="name" id="decorateWidget"><span class="type-signature"></span>decorateWidget<span class="signature">()</span><span class="type-signature"></span></h4>+++++++<div class="description">+ for overriding+</div>++++++++++++++<dl class="details">+++++++++++++++++++++++++++ <dt class="tag-source">Source:</dt>+ <dd class="tag-source"><ul class="dummy"><li>+ <a href="widgets_collapsible_widget.js.html">widgets/collapsible_widget.js</a>, <a href="widgets_collapsible_widget.js.html#line93">line 93</a>+ </li></ul></dd>++++++++</dl>+++++++++++++++++++++++++++ <h4 class="name" id="doRenderBody"><span class="type-signature">(async) </span>doRenderBody<span class="signature">()</span><span class="type-signature"></span></h4>+++++++<div class="description">+ for overriding+</div>++++++++++++++<dl class="details">+++++++++++++++++++++++++++ <dt class="tag-source">Source:</dt>+ <dd class="tag-source"><ul class="dummy"><li>+ <a href="widgets_collapsible_widget.js.html">widgets/collapsible_widget.js</a>, <a href="widgets_collapsible_widget.js.html#line96">line 96</a>+ </li></ul></dd>++++++++</dl>+++++++++++++++++++++++++++ <h4 class="name" id="widgetCollapsedStateChangedEvent"><span class="type-signature"></span>widgetCollapsedStateChangedEvent<span class="signature">()</span><span class="type-signature"></span></h4>+++++++<div class="description">+ This event is used to synchronize collapsed state of all the tab-cached widgets since they are all rendered+separately but should behave uniformly for the user.+</div>++++++++++++++<dl class="details">+++++++++++++++++++++++++++ <dt class="tag-source">Source:</dt>+ <dd class="tag-source"><ul class="dummy"><li>+ <a href="widgets_collapsible_widget.js.html">widgets/collapsible_widget.js</a>, <a href="widgets_collapsible_widget.js.html#line86">line 86</a>+ </li></ul></dd>++++++++</dl>+++++++++++++++++++++@@ -333,7 +602,7 @@</div><nav>- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul></nav><br class="clear">diff --git a/docs/frontend_api/index.html b/docs/frontend_api/index.htmlindex 73c03637b1..978ebed4f6 100644--- a/docs/frontend_api/index.html+++ b/docs/frontend_api/index.html@@ -50,7 +50,7 @@</div><nav>- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul></nav><br class="clear">diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.htmlindex 4dcfd43e98..0d32d82ba2 100644--- a/docs/frontend_api/services_frontend_script_api.js.html+++ b/docs/frontend_api/services_frontend_script_api.js.html@@ -443,7 +443,7 @@ export default FrontendScriptApi;</code></pre></div><nav>- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul></nav><br class="clear">diff --git a/docs/frontend_api/widgets_collapsible_widget.js.html b/docs/frontend_api/widgets_collapsible_widget.js.htmlnew file mode 100644index 0000000000..e5ec10b7b4--- /dev/null+++ b/docs/frontend_api/widgets_collapsible_widget.js.html@@ -0,0 +1,151 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="utf-8">+ <title>JSDoc: Source: widgets/collapsible_widget.js</title>++ <script src="scripts/prettify/prettify.js"> </script>+ <script src="scripts/prettify/lang-css.js"> </script>+ <!--[if lt IE 9]>+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>+ <![endif]-->+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">+</head>++<body>++<div id="main">++ <h1 class="page-title">Source: widgets/collapsible_widget.js</h1>+++++++ <section>+ <article>+ <pre class="prettyprint source linenums"><code>import TabAwareWidget from "./tab_aware_widget.js";+import options from "../services/options.js";++const WIDGET_TPL = `+<div class="card widget">+ <div class="card-header">+ <div>+ <button class="btn btn-sm widget-title" data-toggle="collapse" data-target="#[to be set]">+ Collapsible Group Item+ </button>++ <a class="widget-help external no-arrow bx bx-info-circle"></a>+ </div>++ <div class="widget-header-actions"></div>+ </div>++ <div id="[to be set]" class="collapse body-wrapper" style="transition: none; ">+ <div class="card-body"></div>+ </div>+</div>`;++export default class CollapsibleWidget extends TabAwareWidget {+ get widgetTitle() { return "Untitled widget"; }++ get headerActions() { return []; }++ get help() { return {}; }++ doRender() {+ this.$widget = $(WIDGET_TPL);+ this.$widget.find('[data-target]').attr('data-target', "#" + this.componentId);++ this.$bodyWrapper = this.$widget.find('.body-wrapper');+ this.$bodyWrapper.attr('id', this.componentId); // for toggle to work we need id++ this.widgetName = this.constructor.name;++ if (!options.is(this.widgetName + 'Collapsed')) {+ this.$bodyWrapper.collapse("show");+ }++ // using immediate variants of the event so that the previous collapse is not caught+ this.$bodyWrapper.on('hide.bs.collapse', () => this.saveCollapsed(true));+ this.$bodyWrapper.on('show.bs.collapse', () => this.saveCollapsed(false));++ this.$body = this.$bodyWrapper.find('.card-body');++ this.$title = this.$widget.find('.widget-title');+ this.$title.text(this.widgetTitle);++ this.$help = this.$widget.find('.widget-help');++ if (this.help.title) {+ this.$help.attr("title", this.help.title);+ this.$help.attr("href", this.help.url || "javascript:");++ if (!this.help.url) {+ this.$help.addClass('no-link');+ }+ }+ else {+ this.$help.hide();+ }++ this.$headerActions = this.$widget.find('.widget-header-actions');+ this.$headerActions.append(...this.headerActions);++ this.initialized = this.doRenderBody();++ this.decorateWidget();++ return this.$widget;+ }++ saveCollapsed(collapse) {+ options.save(this.widgetName + 'Collapsed', collapse.toString());++ this.triggerEvent(`widgetCollapsedStateChanged`, {widgetName: this.widgetName, collapse});+ }++ /**+ * This event is used to synchronize collapsed state of all the tab-cached widgets since they are all rendered+ * separately but should behave uniformly for the user.+ */+ widgetCollapsedStateChangedEvent({widgetName, collapse}) {+ if (widgetName === this.widgetName) {+ this.$bodyWrapper.toggleClass('show', !collapse);+ }+ }++ /** for overriding */+ decorateWidget() {}++ /** for overriding */+ async doRenderBody() {}++ isExpanded() {+ return this.$bodyWrapper.hasClass("show");+ }+}</code></pre>+ </article>+ </section>+++++</div>++<nav>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul>+</nav>++<br class="clear">++<footer>+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>+</footer>++<script> prettyPrint(); </script>+<script src="scripts/linenumber.js"> </script>+</body>+</html>diff --git a/package.json b/package.jsonindex ebb165f2e4..ff3b9a9c58 100644--- a/package.json+++ b/package.json@@ -16,7 +16,7 @@"start-server": "TRILIUM_ENV=dev node ./src/www","start-electron": "TRILIUM_ENV=dev electron .","build-backend-docs": "./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/entities/*.js src/services/backend_script_api.js",- "build-frontend-docs": "./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/app/entities/*.js src/public/app/services/frontend_script_api.js",+ "build-frontend-docs": "./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/app/entities/*.js src/public/app/services/frontend_script_api.js src/public/app/widgets/collapsible_widget.js","build-docs": "npm run build-backend-docs && npm run build-frontend-docs","webpack": "npx webpack -c webpack-desktop.config.js && npx webpack -c webpack-mobile.config.js && npx webpack -c webpack-setup.config.js"},