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
tab row widgetizing
zadam9d81bf030d75
diff --git a/config-sample.ini b/config-sample.iniindex 36d546ebe3..20c747197c 100644--- a/config-sample.ini+++ b/config-sample.ini@@ -8,7 +8,7 @@ instanceName=[Network]# host setting is relevant only for web deployments - set the host on which the server will listen# host=0.0.0.0-# port setting is relevant only for web deployments, desktop builds run on random free port+# port setting is relevant only for web deployments, desktop builds run on a fixed port (changeable with TRILIUM_PORT environment variable)port=8080# true for TLS/SSL/HTTPS (secure), false for HTTP (unsecure).https=falsediff --git a/src/public/javascripts/desktop.js b/src/public/javascripts/desktop.jsindex ece9f98851..b93de56a61 100644--- a/src/public/javascripts/desktop.js+++ b/src/public/javascripts/desktop.js@@ -3,7 +3,7 @@ import contextMenu from './services/tree_context_menu.js';import link from './services/link.js';import ws from './services/ws.js';import noteDetailService from './services/note_detail.js';-import noteType from './services/note_type.js';+import noteType from './widgets/note_type.js';import protectedSessionService from './services/protected_session.js';import protectedSessionHolder from './services/protected_session_holder.js';import searchNotesService from './services/search_notes.js';@@ -21,7 +21,7 @@ import bundle from "./services/bundle.js";import treeCache from "./services/tree_cache.js";import libraryLoader from "./services/library_loader.js";import hoistedNoteService from './services/hoisted_note.js';-import noteTypeService from './services/note_type.js';+import noteTypeService from './widgets/note_type.js';import linkService from './services/link.js';import noteAutocompleteService from './services/note_autocomplete.js';import macInit from './services/mac_init.js';diff --git a/src/public/javascripts/services/app_context.js b/src/public/javascripts/services/app_context.jsindex c241736983..336b0a3579 100644--- a/src/public/javascripts/services/app_context.js+++ b/src/public/javascripts/services/app_context.js@@ -2,13 +2,12 @@ import GlobalButtonsWidget from "../widgets/global_buttons.js";import SearchBoxWidget from "../widgets/search_box.js";import SearchResultsWidget from "../widgets/search_results.js";import NoteTreeWidget from "../widgets/note_tree.js";-import tabRow from "./tab_row.js";import treeService from "./tree.js";import noteDetailService from "./note_detail.js";import TabContext from "./tab_context.js";import server from "./server.js";import keyboardActionService from "./keyboard_actions.js";-import contextMenuService from "./context_menu.js";+import TabRowWidget from "./tab_row.js";class AppContext {constructor() {@@ -16,6 +15,30 @@ class AppContext {/** @type {TabContext[]} */this.tabContexts = [];this.tabsChangedTaskId = null;+ /** @type {TabRowWidget} */+ this.tabRow = null;+ }++ showWidgets() {+ const $leftPane = $("#left-pane");++ this.tabRow = new TabRowWidget(this);+ $("#tab-row-container").append(this.tabRow.render());++ this.noteTreeWidget = new NoteTreeWidget(this);++ this.widgets = [+ new GlobalButtonsWidget(this),+ new SearchBoxWidget(this),+ new SearchResultsWidget(this),+ this.noteTreeWidget+ ];++ for (const widget of this.widgets) {+ const $widget = widget.render();++ $leftPane.append($widget);+ }}trigger(name, data) {@@ -31,7 +54,7 @@ class AppContext {/** @returns {TabContext} */getActiveTabContext() {- const activeTabEl = tabRow.activeTabEl;+ const activeTabEl = this.tabRow.activeTabEl;if (!activeTabEl) {return null;@@ -115,25 +138,6 @@ class AppContext {}}- showWidgets() {- const $leftPane = $("#left-pane");-- this.noteTreeWidget = new NoteTreeWidget(this);-- this.widgets = [- new GlobalButtonsWidget(this),- new SearchBoxWidget(this),- new SearchResultsWidget(this),- this.noteTreeWidget- ];-- for (const widget of this.widgets) {- const $widget = widget.render();-- $leftPane.append($widget);- }- }-/*** @return {NoteTreeWidget}*/@@ -144,7 +148,7 @@ class AppContext {getTab(newTab, state) {if (!this.getActiveTabContext() || newTab) {// if it's a new tab explicitly by user then it's in background- const ctx = new TabContext(tabRow, state);+ const ctx = new TabContext(this.tabRow, state);this.tabContexts.push(ctx);return ctx;@@ -174,16 +178,16 @@ class AppContext {}async openEmptyTab() {- const ctx = new TabContext(tabRow);+ const ctx = new TabContext(this.tabRow);this.tabContexts.push(ctx);- await tabRow.activateTab(ctx.$tab[0]);+ await this.tabRow.activateTab(ctx.$tab[0]);}async filterTabs(noteId) {for (const tc of this.tabContexts) {if (tc.notePath && !tc.notePath.split("/").includes(noteId)) {- await tabRow.removeTab(tc.$tab[0]);+ await this.tabRow.removeTab(tc.$tab[0]);}}@@ -197,7 +201,7 @@ class AppContext {async saveOpenTabs() {const openTabs = [];- for (const tabEl of tabRow.tabEls) {+ for (const tabEl of this.tabRow.tabEls) {const tabId = tabEl.getAttribute('data-tab-id');const tabContext = appContext.getTabContexts().find(tc => tc.tabId === tabId);@@ -229,81 +233,63 @@ class AppContext {this.tabsChangedTaskId = setTimeout(() => this.saveOpenTabs(), 1000);}-}-const appContext = new AppContext();+ newTabListener() {+ this.openEmptyTab();+ }-tabRow.addListener('newTab', () => appContext.openEmptyTab());+ async activeTabChangedListener({tabEl}) {+ const tabId = tabEl.getAttribute('data-tab-id');-tabRow.addListener('activeTabChange', async ({ detail }) => {- const tabId = detail.tabEl.getAttribute('data-tab-id');+ await this.showTab(tabId);+ }- await appContext.showTab(tabId);-});+ async tabRemoveListener({tabEl}) {+ const tabId = tabEl.getAttribute('data-tab-id');-tabRow.addListener('tabRemove', async ({ detail }) => {- const tabId = detail.tabEl.getAttribute('data-tab-id');+ this.tabContexts.filter(nc => nc.tabId === tabId)+ .forEach(tc => tc.remove());- appContext.tabContexts.filter(nc => nc.tabId === tabId)- .forEach(tc => tc.remove());+ this.tabContexts = this.tabContexts.filter(nc => nc.tabId !== tabId);- appContext.tabContexts = appContext.tabContexts.filter(nc => nc.tabId !== tabId);+ if (this.tabContexts.length === 0) {+ this.openEmptyTab();+ }- if (appContext.tabContexts.length === 0) {- appContext.openEmptyTab();+ this.openTabsChanged();}-});-tabRow.addListener('activeTabChange', () => appContext.openTabsChanged());-tabRow.addListener('tabRemove', () => appContext.openTabsChanged());-tabRow.addListener('tabReorder', () => appContext.openTabsChanged());+ tabReorderListener() {+ this.openTabsChanged();+ }+}++const appContext = new AppContext();keyboardActionService.setGlobalActionHandler('OpenNewTab', () => {appContext.openEmptyTab();});keyboardActionService.setGlobalActionHandler('CloseActiveTab', () => {- if (tabRow.activeTabEl) {- tabRow.removeTab(tabRow.activeTabEl);+ if (this.tabRow.activeTabEl) {+ this.tabRow.removeTab(this.tabRow.activeTabEl);}});keyboardActionService.setGlobalActionHandler('ActivateNextTab', () => {- const nextTab = tabRow.nextTabEl;+ const nextTab = this.tabRow.nextTabEl;if (nextTab) {- tabRow.activateTab(nextTab);+ this.tabRow.activateTab(nextTab);}});keyboardActionService.setGlobalActionHandler('ActivatePreviousTab', () => {- const prevTab = tabRow.previousTabEl;+ const prevTab = this.tabRow.previousTabEl;if (prevTab) {- tabRow.activateTab(prevTab);+ this.tabRow.activateTab(prevTab);}});-$(tabRow.el).on('contextmenu', '.note-tab', e => {- e.preventDefault();-- const tab = $(e.target).closest(".note-tab");-- contextMenuService.initContextMenu(e, {- getContextMenuItems: () => {- return [- {title: "Close all tabs", cmd: "removeAllTabs", uiIcon: "empty"},- {title: "Close all tabs except for this", cmd: "removeAllTabsExceptForThis", uiIcon: "empty"}- ];- },- selectContextMenuItem: (e, cmd) => {- if (cmd === 'removeAllTabs') {- tabRow.removeAllTabs();- } else if (cmd === 'removeAllTabsExceptForThis') {- tabRow.removeAllTabsExceptForThis(tab[0]);- }- }- });-});-export default appContext;\ No newline at end of filediff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.jsindex 4f7af4d605..4730492d38 100644--- a/src/public/javascripts/services/note_detail.js+++ b/src/public/javascripts/services/note_detail.js@@ -4,10 +4,8 @@ import server from './server.js';import ws from "./ws.js";import treeCache from "./tree_cache.js";import NoteFull from "../entities/note_full.js";-import contextMenuService from "./context_menu.js";import treeUtils from "./tree_utils.js";import tabRow from "./tab_row.js";-import keyboardActionService from "./keyboard_actions.js";import appContext from "./app_context.js";const $tabContentsContainer = $("#note-tab-container");diff --git a/src/public/javascripts/services/tab_context.js b/src/public/javascripts/services/tab_context.jsindex 794e8f80a1..8cee17575a 100644--- a/src/public/javascripts/services/tab_context.js+++ b/src/public/javascripts/services/tab_context.js@@ -3,13 +3,8 @@ import protectedSessionHolder from "./protected_session_holder.js";import server from "./server.js";import bundleService from "./bundle.js";import Attributes from "./attributes.js";-import treeUtils from "./tree_utils.js";import utils from "./utils.js";-import NoteTypeContext from "./note_type.js";-import noteDetailService from "./note_detail.js";-import protectedSessionService from "./protected_session.js";import optionsService from "./options.js";-import linkService from "./link.js";import Sidebar from "./sidebar.js";import appContext from "./app_context.js";@@ -36,7 +31,7 @@ optionsService.addLoadListener(options => {class TabContext {/**- * @param {TabRow} tabRow+ * @param {TabRowWidget} tabRow* @param {object} state*/constructor(tabRow, state = {}) {@@ -61,13 +56,8 @@ class TabContext {$tabContentsContainer.append(this.$tabContent);- this.$noteTitle = this.$tabContent.find(".note-title");- this.$noteTitleRow = this.$tabContent.find(".note-title-row");- this.$notePathList = this.$tabContent.find(".note-path-list");- this.$notePathCount = this.$tabContent.find(".note-path-count");this.$noteDetailComponents = this.$tabContent.find(".note-detail-component");this.$scriptArea = this.$tabContent.find(".note-detail-script-area");- this.$savedIndicator = this.$tabContent.find(".saved-indicator");this.noteChangeDisabled = false;this.isNoteChanged = false;this.attributes = new Attributes(this);@@ -78,41 +68,10 @@ class TabContext {};this.sidebar = new Sidebar(this, sidebarState);- this.noteType = new NoteTypeContext(this);}this.components = {};- this.$noteTitle.on('input', () => {- if (!this.note) {- return;- }-- this.noteChanged();-- this.note.title = this.$noteTitle.val();-- this.tabRow.updateTab(this.$tab[0], {title: this.note.title});- treeService.setNoteTitle(this.note.noteId, this.note.title);-- this.setTitleBar();- });-- if (utils.isDesktop()) {- // keyboard plugin is not loaded in mobile- utils.bindElShortcut(this.$noteTitle, 'return', () => {- this.getComponent().focus();-- return false; // to not propagate the enter into the editor (causes issues with codemirror)- });- }-- this.$protectButton = this.$tabContent.find(".protect-button");- this.$protectButton.on('click', protectedSessionService.protectNoteAndSendToServer);-- this.$unprotectButton = this.$tabContent.find(".unprotect-button");- this.$unprotectButton.on('click', protectedSessionService.unprotectNoteAndSendToServer);-await this.initComponent();}@@ -156,8 +115,6 @@ class TabContext {this.noteChangeDisabled = true;try {- this.$noteTitle.val(this.note.title);-await this.renderComponent();} finally {this.noteChangeDisabled = false;@@ -177,12 +134,6 @@ class TabContext {}}, 5000);- this.showPaths();-- if (utils.isDesktop()) {- this.noteType.update();- }-bundleService.executeRelationBundles(this.note, 'runOnNoteView', this);// after loading new note make sure editor is scrolled to the top@@ -281,12 +232,7 @@ class TabContext {this.$tabContent.addClass(utils.getNoteTypeClass(this.note.type));this.$tabContent.addClass(utils.getMimeTypeClass(this.note.mime));- this.$noteTitleRow.show(); // might be hidden from empty detailthis.$tabContent.toggleClass("protected", this.note.isProtected);- this.$protectButton.toggleClass("active", this.note.isProtected);- this.$protectButton.prop("disabled", this.note.isProtected);- this.$unprotectButton.toggleClass("active", !this.note.isProtected);- this.$unprotectButton.prop("disabled", !this.note.isProtected || !protectedSessionHolder.isProtectedSessionAvailable());}getComponent() {@@ -349,12 +295,11 @@ class TabContext {protectedSessionHolder.touchProtectedSession();}- this.$savedIndicator.fadeIn();+ // FIXME trigger "noteSaved" event so that title indicator is triggered+ this.eventReceived('noteSaved');// run asyncbundleService.executeRelationBundles(this.note, 'runOnNoteChange', this);-- this.eventReceived('noteSaved');}async saveNoteIfChanged() {@@ -372,65 +317,10 @@ class TabContext {this.isNoteChanged = true;+ // FIMXE: trigger noteChanged eventthis.$savedIndicator.fadeOut();}- async addPath(notePath, isCurrent) {- const title = await treeUtils.getNotePathTitle(notePath);-- const noteLink = await linkService.createNoteLink(notePath, {title});-- noteLink- .addClass("no-tooltip-preview")- .addClass("dropdown-item");-- if (isCurrent) {- noteLink.addClass("current");- }-- this.$notePathList.append(noteLink);- }-- async showPaths() {- if (this.note.noteId === 'root') {- // root doesn't have any parent, but it's still technically 1 path-- this.$notePathCount.html("1 path");-- this.$notePathList.empty();-- await this.addPath('root', true);- }- else {- const parents = await this.note.getParentNotes();-- this.$notePathCount.html(parents.length + " path" + (parents.length > 1 ? "s" : ""));- this.$notePathList.empty();-- const pathSegments = this.notePath.split("/");- const activeNoteParentNoteId = pathSegments[pathSegments.length - 2]; // we know this is not root so there must be a parent-- for (const parentNote of parents) {- const parentNotePath = await treeService.getSomeNotePath(parentNote);- // this is to avoid having root notes leading '/'- const notePath = parentNotePath ? (parentNotePath + '/' + this.note.noteId) : this.note.noteId;- const isCurrent = activeNoteParentNoteId === parentNote.noteId;-- await this.addPath(notePath, isCurrent);- }-- const cloneLink = $("<div>")- .addClass("dropdown-item")- .append(- $('<button class="btn btn-sm">')- .text('Clone note to new location...')- .on('click', () => import("../dialogs/clone_to.js").then(d => d.showDialog([this.note.noteId])))- );-- this.$notePathList.append(cloneLink);- }- }-async remove() {if (this.$tabContent) {// sometimes there are orphan autocompletes after closing the tabdiff --git a/src/public/javascripts/services/tab_row.js b/src/public/javascripts/services/tab_row.jsindex d36f3b9562..a03621cf7a 100644--- a/src/public/javascripts/services/tab_row.js+++ b/src/public/javascripts/services/tab_row.js@@ -5,7 +5,10 @@* MIT license*/-!function(i,e){"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(t){return e(i,t)}):"object"==typeof module&&module.exports?module.exports=e(i,require("jquery")):i.jQueryBridget=e(i,i.jQuery)}(window,function(t,i){"use strict";var c=Array.prototype.slice,e=t.console,p=void 0===e?function(){}:function(t){e.error(t)};function n(d,o,u){(u=u||i||t.jQuery)&&(o.prototype.option||(o.prototype.option=function(t){u.isPlainObject(t)&&(this.options=u.extend(!0,this.options,t))}),u.fn[d]=function(t){if("string"==typeof t){var i=c.call(arguments,1);return s=i,a="$()."+d+'("'+(r=t)+'")',(e=this).each(function(t,i){var e=u.data(i,d);if(e){var n=e[r];if(n&&"_"!=r.charAt(0)){var o=n.apply(e,s);h=void 0===h?o:h}else p(a+" is not a valid method")}else p(d+" not initialized. Cannot call methods, i.e. "+a)}),void 0!==h?h:e}var e,r,s,h,a,n;return n=t,this.each(function(t,i){var e=u.data(i,d);e?(e.option(n),e._init()):(e=new o(i,n),u.data(i,d,e))}),this},r(u))}function r(t){!t||t&&t.bridget||(t.bridget=n)}return r(i||t.jQuery),n}),function(t,i){"use strict";"function"==typeof define&&define.amd?define("get-size/get-size",[],function(){return i()}):"object"==typeof module&&module.exports?module.exports=i():t.getSize=i()}(window,function(){"use strict";function m(t){var i=parseFloat(t);return-1==t.indexOf("%")&&!isNaN(i)&&i}var e="undefined"==typeof console?function(){}:function(t){console.error(t)},y=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],b=y.length;function E(t){var i=getComputedStyle(t);return i||e("Style returned "+i+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),i}var _,x=!1;function P(t){if(function(){if(!x){x=!0;var t=document.createElement("div");t.style.width="200px",t.style.padding="1px 2px 3px 4px",t.style.borderStyle="solid",t.style.borderWidth="1px 2px 3px 4px",t.style.boxSizing="border-box";var i=document.body||document.documentElement;i.appendChild(t);var e=E(t);P.isBoxSizeOuter=_=200==m(e.width),i.removeChild(t)}}(),"string"==typeof t&&(t=document.querySelector(t)),t&&"object"==typeof t&&t.nodeType){var i=E(t);if("none"==i.display)return function(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},i=0;i<b;i++)t[y[i]]=0;return t}();var e={};e.width=t.offsetWidth,e.height=t.offsetHeight;for(var n=e.isBorderBox="border-box"==i.boxSizing,o=0;o<b;o++){var r=y[o],s=i[r],h=parseFloat(s);e[r]=isNaN(h)?0:h}var a=e.paddingLeft+e.paddingRight,d=e.paddingTop+e.paddingBottom,u=e.marginLeft+e.marginRight,c=e.marginTop+e.marginBottom,p=e.borderLeftWidth+e.borderRightWidth,f=e.borderTopWidth+e.borderBottomWidth,g=n&&_,l=m(i.width);!1!==l&&(e.width=l+(g?0:a+p));var v=m(i.height);return!1!==v&&(e.height=v+(g?0:d+f)),e.innerWidth=e.width-(a+p),e.innerHeight=e.height-(d+f),e.outerWidth=e.width+u,e.outerHeight=e.height+c,e}}return P}),function(t,i){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",i):"object"==typeof module&&module.exports?module.exports=i():t.EvEmitter=i()}("undefined"!=typeof window?window:this,function(){function t(){}var i=t.prototype;return i.on=function(t,i){if(t&&i){var e=this._events=this._events||{},n=e[t]=e[t]||[];return-1==n.indexOf(i)&&n.push(i),this}},i.once=function(t,i){if(t&&i){this.on(t,i);var e=this._onceEvents=this._onceEvents||{};return(e[t]=e[t]||{})[i]=!0,this}},i.off=function(t,i){var e=this._events&&this._events[t];if(e&&e.length){var n=e.indexOf(i);return-1!=n&&e.splice(n,1),this}},i.emitEvent=function(t,i){var e=this._events&&this._events[t];if(e&&e.length){e=e.slice(0),i=i||[];for(var n=this._onceEvents&&this._onceEvents[t],o=0;o<e.length;o++){var r=e[o];n&&n[r]&&(this.off(t,r),delete n[r]),r.apply(this,i)}return this}},i.allOff=function(){delete this._events,delete this._onceEvents},t}),function(i,e){"function"==typeof define&&define.amd?define("unipointer/unipointer",["ev-emitter/ev-emitter"],function(t){return e(i,t)}):"object"==typeof module&&module.exports?module.exports=e(i,require("ev-emitter")):i.Unipointer=e(i,i.EvEmitter)}(window,function(o,t){function i(){}var e=i.prototype=Object.create(t.prototype);e.bindStartEvent=function(t){this._bindStartEvent(t,!0)},e.unbindStartEvent=function(t){this._bindStartEvent(t,!1)},e._bindStartEvent=function(t,i){var e=(i=void 0===i||i)?"addEventListener":"removeEventListener",n="mousedown";o.PointerEvent?n="pointerdown":"ontouchstart"in o&&(n="touchstart"),t[e](n,this)},e.handleEvent=function(t){var i="on"+t.type;this[i]&&this[i](t)},e.getTouch=function(t){for(var i=0;i<t.length;i++){var e=t[i];if(e.identifier==this.pointerIdentifier)return e}},e.onmousedown=function(t){var i=t.button;i&&0!==i&&1!==i||this._pointerDown(t,t)},e.ontouchstart=function(t){this._pointerDown(t,t.changedTouches[0])},e.onpointerdown=function(t){this._pointerDown(t,t)},e._pointerDown=function(t,i){t.button||this.isPointerDown||(this.isPointerDown=!0,this.pointerIdentifier=void 0!==i.pointerId?i.pointerId:i.identifier,this.pointerDown(t,i))},e.pointerDown=function(t,i){this._bindPostStartEvents(t),this.emitEvent("pointerDown",[t,i])};var n={mousedown:["mousemove","mouseup"],touchstart:["touchmove","touchend","touchcancel"],pointerdown:["pointermove","pointerup","pointercancel"]};return e._bindPostStartEvents=function(t){if(t){var i=n[t.type];i.forEach(function(t){o.addEventListener(t,this)},this),this._boundPointerEvents=i}},e._unbindPostStartEvents=function(){this._boundPointerEvents&&(this._boundPointerEvents.forEach(function(t){o.removeEventListener(t,this)},this),delete this._boundPointerEvents)},e.onmousemove=function(t){this._pointerMove(t,t)},e.onpointermove=function(t){t.pointerId==this.pointerIdentifier&&this._pointerMove(t,t)},e.ontouchmove=function(t){var i=this.getTouch(t.changedTouches);i&&this._pointerMove(t,i)},e._pointerMove=function(t,i){this.pointerMove(t,i)},e.pointerMove=function(t,i){this.emitEvent("pointerMove",[t,i])},e.onmouseup=function(t){this._pointerUp(t,t)},e.onpointerup=function(t){t.pointerId==this.pointerIdentifier&&this._pointerUp(t,t)},e.ontouchend=function(t){var i=this.getTouch(t.changedTouches);i&&this._pointerUp(t,i)},e._pointerUp=function(t,i){this._pointerDone(),this.pointerUp(t,i)},e.pointerUp=function(t,i){this.emitEvent("pointerUp",[t,i])},e._pointerDone=function(){this._pointerReset(),this._unbindPostStartEvents(),this.pointerDone()},e._pointerReset=function(){this.isPointerDown=!1,delete this.pointerIdentifier},e.pointerDone=function(){},e.onpointercancel=function(t){t.pointerId==this.pointerIdentifier&&this._pointerCancel(t,t)},e.ontouchcancel=function(t){var i=this.getTouch(t.changedTouches);i&&this._pointerCancel(t,i)},e._pointerCancel=function(t,i){this._pointerDone(),this.pointerCancel(t,i)},e.pointerCancel=function(t,i){this.emitEvent("pointerCancel",[t,i])},i.getPointerPoint=function(t){return{x:t.pageX,y:t.pageY}},i}),function(i,e){"function"==typeof define&&define.amd?define("unidragger/unidragger",["unipointer/unipointer"],function(t){return e(i,t)}):"object"==typeof module&&module.exports?module.exports=e(i,require("unipointer")):i.Unidragger=e(i,i.Unipointer)}(window,function(r,t){function i(){}var e=i.prototype=Object.create(t.prototype);e.bindHandles=function(){this._bindHandles(!0)},e.unbindHandles=function(){this._bindHandles(!1)},e._bindHandles=function(t){for(var i=(t=void 0===t||t)?"addEventListener":"removeEventListener",e=t?this._touchActionValue:"",n=0;n<this.handles.length;n++){var o=this.handles[n];this._bindStartEvent(o,t),o[i]("click",this),r.PointerEvent&&(o.style.touchAction=e)}},e._touchActionValue="none",e.pointerDown=function(t,i){this.okayPointerDown(t)&&(this.pointerDownPointer=i,t.preventDefault(),this.pointerDownBlur(),this._bindPostStartEvents(t),this.emitEvent("pointerDown",[t,i]))};var o={TEXTAREA:!0,INPUT:!0,SELECT:!0,OPTION:!0},s={radio:!0,checkbox:!0,button:!0,submit:!0,image:!0,file:!0};return e.okayPointerDown=function(t){var i=o[t.target.nodeName],e=s[t.target.type],n=!i||e;return n||this._pointerReset(),n},e.pointerDownBlur=function(){var t=document.activeElement;t&&t.blur&&t!=document.body&&t.blur()},e.pointerMove=function(t,i){var e=this._dragPointerMove(t,i);this.emitEvent("pointerMove",[t,i,e]),this._dragMove(t,i,e)},e._dragPointerMove=function(t,i){var e={x:i.pageX-this.pointerDownPointer.pageX,y:i.pageY-this.pointerDownPointer.pageY};return!this.isDragging&&this.hasDragStarted(e)&&this._dragStart(t,i),e},e.hasDragStarted=function(t){return 3<Math.abs(t.x)||3<Math.abs(t.y)},e.pointerUp=function(t,i){this.emitEvent("pointerUp",[t,i]),this._dragPointerUp(t,i)},e._dragPointerUp=function(t,i){this.isDragging?this._dragEnd(t,i):this._staticClick(t,i)},e._dragStart=function(t,i){this.isDragging=!0,this.isPreventingClicks=!0,this.dragStart(t,i)},e.dragStart=function(t,i){this.emitEvent("dragStart",[t,i])},e._dragMove=function(t,i,e){this.isDragging&&this.dragMove(t,i,e)},e.dragMove=function(t,i,e){t.preventDefault(),this.emitEvent("dragMove",[t,i,e])},e._dragEnd=function(t,i){this.isDragging=!1,setTimeout(function(){delete this.isPreventingClicks}.bind(this)),this.dragEnd(t,i)},e.dragEnd=function(t,i){this.emitEvent("dragEnd",[t,i])},e.onclick=function(t){this.isPreventingClicks&&t.preventDefault()},e._staticClick=function(t,i){this.isIgnoringMouseUp&&"mouseup"==t.type||(this.staticClick(t,i),"mouseup"!=t.type&&(this.isIgnoringMouseUp=!0,setTimeout(function(){delete this.isIgnoringMouseUp}.bind(this),400)))},e.staticClick=function(t,i){this.emitEvent("staticClick",[t,i])},i.getPointerPoint=t.getPointerPoint,i}),function(e,n){"function"==typeof define&&define.amd?define(["get-size/get-size","unidragger/unidragger"],function(t,i){return n(e,t,i)}):"object"==typeof module&&module.exports?module.exports=n(e,require("get-size"),require("unidragger")):e.Draggabilly=n(e,e.getSize,e.Unidragger)}(window,function(r,a,t){function e(t,i){for(var e in i)t[e]=i[e];return t}var n=r.jQuery;function i(t,i){this.element="string"==typeof t?document.querySelector(t):t,n&&(this.$element=n(this.element)),this.options=e({},this.constructor.defaults),this.option(i),this._create()}var o=i.prototype=Object.create(t.prototype);i.defaults={},o.option=function(t){e(this.options,t)};var s={relative:!0,absolute:!0,fixed:!0};function d(t,i,e){return e=e||"round",i?Math[e](t/i)*i:t}return o._create=function(){this.position={},this._getPosition(),this.startPoint={x:0,y:0},this.dragPoint={x:0,y:0},this.startPosition=e({},this.position);var t=getComputedStyle(this.element);s[t.position]||(this.element.style.position="relative"),this.on("pointerDown",this.onPointerDown),this.on("pointerMove",this.onPointerMove),this.on("pointerUp",this.onPointerUp),this.enable(),this.setHandles()},o.setHandles=function(){this.handles=this.options.handle?this.element.querySelectorAll(this.options.handle):[this.element],this.bindHandles()},o.dispatchEvent=function(t,i,e){var n=[i].concat(e);this.emitEvent(t,n),this.dispatchJQueryEvent(t,i,e)},o.dispatchJQueryEvent=function(t,i,e){var n=r.jQuery;if(n&&this.$element){var o=n.Event(i);o.type=t,this.$element.trigger(o,e)}},o._getPosition=function(){var t=getComputedStyle(this.element),i=this._getPositionCoord(t.left,"width"),e=this._getPositionCoord(t.top,"height");this.position.x=isNaN(i)?0:i,this.position.y=isNaN(e)?0:e,this._addTransformPosition(t)},o._getPositionCoord=function(t,i){if(-1!=t.indexOf("%")){var e=a(this.element.parentNode);return e?parseFloat(t)/100*e[i]:0}return parseInt(t,10)},o._addTransformPosition=function(t){var i=t.transform;if(0===i.indexOf("matrix")){var e=i.split(","),n=0===i.indexOf("matrix3d")?12:4,o=parseInt(e[n],10),r=parseInt(e[n+1],10);this.position.x+=o,this.position.y+=r}},o.onPointerDown=function(t,i){this.element.classList.add("is-pointer-down"),this.dispatchJQueryEvent("pointerDown",t,[i])},o.dragStart=function(t,i){this.isEnabled&&(this._getPosition(),this.measureContainment(),this.startPosition.x=this.position.x,this.startPosition.y=this.position.y,this.setLeftTop(),this.dragPoint.x=0,this.dragPoint.y=0,this.element.classList.add("is-dragging"),this.dispatchEvent("dragStart",t,[i]),this.animate())},o.measureContainment=function(){var t=this.getContainer();if(t){var i=a(this.element),e=a(t),n=this.element.getBoundingClientRect(),o=t.getBoundingClientRect(),r=e.borderLeftWidth+e.borderRightWidth,s=e.borderTopWidth+e.borderBottomWidth,h=this.relativeStartPosition={x:n.left-(o.left+e.borderLeftWidth),y:n.top-(o.top+e.borderTopWidth)};this.containSize={width:e.width-r-h.x-i.width,height:e.height-s-h.y-i.height}}},o.getContainer=function(){var t=this.options.containment;if(t)return t instanceof HTMLElement?t:"string"==typeof t?document.querySelector(t):this.element.parentNode},o.onPointerMove=function(t,i,e){this.dispatchJQueryEvent("pointerMove",t,[i,e])},o.dragMove=function(t,i,e){if(this.isEnabled){var n=e.x,o=e.y,r=this.options.grid,s=r&&r[0],h=r&&r[1];n=d(n,s),o=d(o,h),n=this.containDrag("x",n,s),o=this.containDrag("y",o,h),n="y"==this.options.axis?0:n,o="x"==this.options.axis?0:o,this.position.x=this.startPosition.x+n,this.position.y=this.startPosition.y+o,this.dragPoint.x=n,this.dragPoint.y=o,this.dispatchEvent("dragMove",t,[i,e])}},o.containDrag=function(t,i,e){if(!this.options.containment)return i;var n="x"==t?"width":"height",o=d(-this.relativeStartPosition[t],e,"ceil"),r=this.containSize[n];return r=d(r,e,"floor"),Math.max(o,Math.min(r,i))},o.onPointerUp=function(t,i){this.element.classList.remove("is-pointer-down"),this.dispatchJQueryEvent("pointerUp",t,[i])},o.dragEnd=function(t,i){this.isEnabled&&(this.element.style.transform="",this.setLeftTop(),this.element.classList.remove("is-dragging"),this.dispatchEvent("dragEnd",t,[i]))},o.animate=function(){if(this.isDragging){this.positionDrag();var t=this;requestAnimationFrame(function(){t.animate()})}},o.setLeftTop=function(){this.element.style.left=this.position.x+"px",this.element.style.top=this.position.y+"px"},o.positionDrag=function(){this.element.style.transform="translate3d( "+this.dragPoint.x+"px, "+this.dragPoint.y+"px, 0)"},o.staticClick=function(t,i){this.dispatchEvent("staticClick",t,[i])},o.setPosition=function(t,i){this.position.x=t,this.position.y=i,this.setLeftTop()},o.enable=function(){this.isEnabled=!0},o.disable=function(){this.isEnabled=!1,this.isDragging&&this.dragEnd()},o.destroy=function(){this.disable(),this.element.style.transform="",this.element.style.left="",this.element.style.top="",this.element.style.position="",this.unbindHandles(),this.$element&&this.$element.removeData("draggabilly")},o._init=function(){},n&&n.bridget&&n.bridget("draggabilly",i),i});+import BasicWidget from "../widgets/basic_widget.js";+import contextMenuService from "./context_menu.js";++!function(i, e){"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(t){return e(i,t)}):"object"==typeof module&&module.exports?module.exports=e(i,require("jquery")):i.jQueryBridget=e(i,i.jQuery)}(window,function(t, i){"use strict";var c=Array.prototype.slice,e=t.console,p=void 0===e?function(){}:function(t){e.error(t)};function n(d, o, u){(u=u||i||t.jQuery)&&(o.prototype.option||(o.prototype.option=function(t){u.isPlainObject(t)&&(this.options=u.extend(!0,this.options,t))}),u.fn[d]=function(t){if("string"==typeof t){var i=c.call(arguments,1);return s=i,a="$()."+d+'("'+(r=t)+'")',(e=this).each(function(t, i){var e=u.data(i,d);if(e){var n=e[r];if(n&&"_"!=r.charAt(0)){var o=n.apply(e,s);h=void 0===h?o:h}else p(a+" is not a valid method")}else p(d+" not initialized. Cannot call methods, i.e. "+a)}),void 0!==h?h:e}var e,r,s,h,a,n;return n=t,this.each(function(t, i){var e=u.data(i,d);e?(e.option(n),e._init()):(e=new o(i,n),u.data(i,d,e))}),this},r(u))}function r(t){!t||t&&t.bridget||(t.bridget=n)}return r(i||t.jQuery),n}),function(t, i){"use strict";"function"==typeof define&&define.amd?define("get-size/get-size",[],function(){return i()}):"object"==typeof module&&module.exports?module.exports=i():t.getSize=i()}(window,function(){"use strict";function m(t){var i=parseFloat(t);return-1==t.indexOf("%")&&!isNaN(i)&&i}var e="undefined"==typeof console?function(){}:function(t){console.error(t)},y=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],b=y.length;function E(t){var i=getComputedStyle(t);return i||e("Style returned "+i+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),i}var _,x=!1;function P(t){if(function(){if(!x){x=!0;var t=document.createElement("div");t.style.width="200px",t.style.padding="1px 2px 3px 4px",t.style.borderStyle="solid",t.style.borderWidth="1px 2px 3px 4px",t.style.boxSizing="border-box";var i=document.body||document.documentElement;i.appendChild(t);var e=E(t);P.isBoxSizeOuter=_=200==m(e.width),i.removeChild(t)}}(),"string"==typeof t&&(t=document.querySelector(t)),t&&"object"==typeof t&&t.nodeType){var i=E(t);if("none"==i.display)return function(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},i=0; i<b; i++)t[y[i]]=0;return t}();var e={};e.width=t.offsetWidth,e.height=t.offsetHeight;for(var n=e.isBorderBox="border-box"==i.boxSizing,o=0; o<b; o++){var r=y[o],s=i[r],h=parseFloat(s);e[r]=isNaN(h)?0:h}var a=e.paddingLeft+e.paddingRight,d=e.paddingTop+e.paddingBottom,u=e.marginLeft+e.marginRight,c=e.marginTop+e.marginBottom,p=e.borderLeftWidth+e.borderRightWidth,f=e.borderTopWidth+e.borderBottomWidth,g=n&&_,l=m(i.width);!1!==l&&(e.width=l+(g?0:a+p));var v=m(i.height);return!1!==v&&(e.height=v+(g?0:d+f)),e.innerWidth=e.width-(a+p),e.innerHeight=e.height-(d+f),e.outerWidth=e.width+u,e.outerHeight=e.height+c,e}}return P}),function(t, i){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",i):"object"==typeof module&&module.exports?module.exports=i():t.EvEmitter=i()}("undefined"!=typeof window?window:this,function(){function t(){}var i=t.prototype;return i.on=function(t, i){if(t&&i){var e=this._events=this._events||{},n=e[t]=e[t]||[];return-1==n.indexOf(i)&&n.push(i),this}},i.once=function(t, i){if(t&&i){this.on(t,i);var e=this._onceEvents=this._onceEvents||{};return(e[t]=e[t]||{})[i]=!0,this}},i.off=function(t, i){var e=this._events&&this._events[t];if(e&&e.length){var n=e.indexOf(i);return-1!=n&&e.splice(n,1),this}},i.emitEvent=function(t, i){var e=this._events&&this._events[t];if(e&&e.length){e=e.slice(0),i=i||[];for(var n=this._onceEvents&&this._onceEvents[t],o=0; o<e.length; o++){var r=e[o];n&&n[r]&&(this.off(t,r),delete n[r]),r.apply(this,i)}return this}},i.allOff=function(){delete this._events,delete this._onceEvents},t}),function(i, e){"function"==typeof define&&define.amd?define("unipointer/unipointer",["ev-emitter/ev-emitter"],function(t){return e(i,t)}):"object"==typeof module&&module.exports?module.exports=e(i,require("ev-emitter")):i.Unipointer=e(i,i.EvEmitter)}(window,function(o, t){function i(){}var e=i.prototype=Object.create(t.prototype);e.bindStartEvent=function(t){this._bindStartEvent(t,!0)},e.unbindStartEvent=function(t){this._bindStartEvent(t,!1)},e._bindStartEvent=function(t, i){var e=(i=void 0===i||i)?"addEventListener":"removeEventListener",n="mousedown";o.PointerEvent?n="pointerdown":"ontouchstart"in o&&(n="touchstart"),t[e](n,this)},e.handleEvent=function(t){var i="on"+t.type;this[i]&&this[i](t)},e.getTouch=function(t){for(var i=0; i<t.length; i++){var e=t[i];if(e.identifier==this.pointerIdentifier)return e}},e.onmousedown=function(t){var i=t.button;i&&0!==i&&1!==i||this._pointerDown(t,t)},e.ontouchstart=function(t){this._pointerDown(t,t.changedTouches[0])},e.onpointerdown=function(t){this._pointerDown(t,t)},e._pointerDown=function(t, i){t.button||this.isPointerDown||(this.isPointerDown=!0,this.pointerIdentifier=void 0!==i.pointerId?i.pointerId:i.identifier,this.pointerDown(t,i))},e.pointerDown=function(t, i){this._bindPostStartEvents(t),this.emitEvent("pointerDown",[t,i])};var n={mousedown:["mousemove","mouseup"],touchstart:["touchmove","touchend","touchcancel"],pointerdown:["pointermove","pointerup","pointercancel"]};return e._bindPostStartEvents=function(t){if(t){var i=n[t.type];i.forEach(function(t){o.addEventListener(t,this)},this),this._boundPointerEvents=i}},e._unbindPostStartEvents=function(){this._boundPointerEvents&&(this._boundPointerEvents.forEach(function(t){o.removeEventListener(t,this)},this),delete this._boundPointerEvents)},e.onmousemove=function(t){this._pointerMove(t,t)},e.onpointermove=function(t){t.pointerId==this.pointerIdentifier&&this._pointerMove(t,t)},e.ontouchmove=function(t){var i=this.getTouch(t.changedTouches);i&&this._pointerMove(t,i)},e._pointerMove=function(t, i){this.pointerMove(t,i)},e.pointerMove=function(t, i){this.emitEvent("pointerMove",[t,i])},e.onmouseup=function(t){this._pointerUp(t,t)},e.onpointerup=function(t){t.pointerId==this.pointerIdentifier&&this._pointerUp(t,t)},e.ontouchend=function(t){var i=this.getTouch(t.changedTouches);i&&this._pointerUp(t,i)},e._pointerUp=function(t, i){this._pointerDone(),this.pointerUp(t,i)},e.pointerUp=function(t, i){this.emitEvent("pointerUp",[t,i])},e._pointerDone=function(){this._pointerReset(),this._unbindPostStartEvents(),this.pointerDone()},e._pointerReset=function(){this.isPointerDown=!1,delete this.pointerIdentifier},e.pointerDone=function(){},e.onpointercancel=function(t){t.pointerId==this.pointerIdentifier&&this._pointerCancel(t,t)},e.ontouchcancel=function(t){var i=this.getTouch(t.changedTouches);i&&this._pointerCancel(t,i)},e._pointerCancel=function(t, i){this._pointerDone(),this.pointerCancel(t,i)},e.pointerCancel=function(t, i){this.emitEvent("pointerCancel",[t,i])},i.getPointerPoint=function(t){return{x:t.pageX,y:t.pageY}},i}),function(i, e){"function"==typeof define&&define.amd?define("unidragger/unidragger",["unipointer/unipointer"],function(t){return e(i,t)}):"object"==typeof module&&module.exports?module.exports=e(i,require("unipointer")):i.Unidragger=e(i,i.Unipointer)}(window,function(r, t){function i(){}var e=i.prototype=Object.create(t.prototype);e.bindHandles=function(){this._bindHandles(!0)},e.unbindHandles=function(){this._bindHandles(!1)},e._bindHandles=function(t){for(var i=(t=void 0===t||t)?"addEventListener":"removeEventListener",e=t?this._touchActionValue:"",n=0; n<this.handles.length; n++){var o=this.handles[n];this._bindStartEvent(o,t),o[i]("click",this),r.PointerEvent&&(o.style.touchAction=e)}},e._touchActionValue="none",e.pointerDown=function(t, i){this.okayPointerDown(t)&&(this.pointerDownPointer=i,t.preventDefault(),this.pointerDownBlur(),this._bindPostStartEvents(t),this.emitEvent("pointerDown",[t,i]))};var o={TEXTAREA:!0,INPUT:!0,SELECT:!0,OPTION:!0},s={radio:!0,checkbox:!0,button:!0,submit:!0,image:!0,file:!0};return e.okayPointerDown=function(t){var i=o[t.target.nodeName],e=s[t.target.type],n=!i||e;return n||this._pointerReset(),n},e.pointerDownBlur=function(){var t=document.activeElement;t&&t.blur&&t!=document.body&&t.blur()},e.pointerMove=function(t, i){var e=this._dragPointerMove(t,i);this.emitEvent("pointerMove",[t,i,e]),this._dragMove(t,i,e)},e._dragPointerMove=function(t, i){var e={x:i.pageX-this.pointerDownPointer.pageX,y:i.pageY-this.pointerDownPointer.pageY};return!this.isDragging&&this.hasDragStarted(e)&&this._dragStart(t,i),e},e.hasDragStarted=function(t){return 3<Math.abs(t.x)||3<Math.abs(t.y)},e.pointerUp=function(t, i){this.emitEvent("pointerUp",[t,i]),this._dragPointerUp(t,i)},e._dragPointerUp=function(t, i){this.isDragging?this._dragEnd(t,i):this._staticClick(t,i)},e._dragStart=function(t, i){this.isDragging=!0,this.isPreventingClicks=!0,this.dragStart(t,i)},e.dragStart=function(t, i){this.emitEvent("dragStart",[t,i])},e._dragMove=function(t, i, e){this.isDragging&&this.dragMove(t,i,e)},e.dragMove=function(t, i, e){t.preventDefault(),this.emitEvent("dragMove",[t,i,e])},e._dragEnd=function(t, i){this.isDragging=!1,setTimeout(function(){delete this.isPreventingClicks}.bind(this)),this.dragEnd(t,i)},e.dragEnd=function(t, i){this.emitEvent("dragEnd",[t,i])},e.onclick=function(t){this.isPreventingClicks&&t.preventDefault()},e._staticClick=function(t, i){this.isIgnoringMouseUp&&"mouseup"==t.type||(this.staticClick(t,i),"mouseup"!=t.type&&(this.isIgnoringMouseUp=!0,setTimeout(function(){delete this.isIgnoringMouseUp}.bind(this),400)))},e.staticClick=function(t, i){this.emitEvent("staticClick",[t,i])},i.getPointerPoint=t.getPointerPoint,i}),function(e, n){"function"==typeof define&&define.amd?define(["get-size/get-size","unidragger/unidragger"],function(t, i){return n(e,t,i)}):"object"==typeof module&&module.exports?module.exports=n(e,require("get-size"),require("unidragger")):e.Draggabilly=n(e,e.getSize,e.Unidragger)}(window,function(r, a, t){function e(t, i){for(var e in i)t[e]=i[e];return t}var n=r.jQuery;function i(t, i){this.element="string"==typeof t?document.querySelector(t):t,n&&(this.$element=n(this.element)),this.options=e({},this.constructor.defaults),this.option(i),this._create()}var o=i.prototype=Object.create(t.prototype);i.defaults={},o.option=function(t){e(this.options,t)};var s={relative:!0,absolute:!0,fixed:!0};function d(t, i, e){return e=e||"round",i?Math[e](t/i)*i:t}return o._create=function(){this.position={},this._getPosition(),this.startPoint={x:0,y:0},this.dragPoint={x:0,y:0},this.startPosition=e({},this.position);var t=getComputedStyle(this.element);s[t.position]||(this.element.style.position="relative"),this.on("pointerDown",this.onPointerDown),this.on("pointerMove",this.onPointerMove),this.on("pointerUp",this.onPointerUp),this.enable(),this.setHandles()},o.setHandles=function(){this.handles=this.options.handle?this.element.querySelectorAll(this.options.handle):[this.element],this.bindHandles()},o.dispatchEvent=function(t, i, e){var n=[i].concat(e);this.emitEvent(t,n),this.dispatchJQueryEvent(t,i,e)},o.dispatchJQueryEvent=function(t, i, e){var n=r.jQuery;if(n&&this.$element){var o=n.Event(i);o.type=t,this.$element.trigger(o,e)}},o._getPosition=function(){var t=getComputedStyle(this.element),i=this._getPositionCoord(t.left,"width"),e=this._getPositionCoord(t.top,"height");this.position.x=isNaN(i)?0:i,this.position.y=isNaN(e)?0:e,this._addTransformPosition(t)},o._getPositionCoord=function(t, i){if(-1!=t.indexOf("%")){var e=a(this.element.parentNode);return e?parseFloat(t)/100*e[i]:0}return parseInt(t,10)},o._addTransformPosition=function(t){var i=t.transform;if(0===i.indexOf("matrix")){var e=i.split(","),n=0===i.indexOf("matrix3d")?12:4,o=parseInt(e[n],10),r=parseInt(e[n+1],10);this.position.x+=o,this.position.y+=r}},o.onPointerDown=function(t, i){this.element.classList.add("is-pointer-down"),this.dispatchJQueryEvent("pointerDown",t,[i])},o.dragStart=function(t, i){this.isEnabled&&(this._getPosition(),this.measureContainment(),this.startPosition.x=this.position.x,this.startPosition.y=this.position.y,this.setLeftTop(),this.dragPoint.x=0,this.dragPoint.y=0,this.element.classList.add("is-dragging"),this.dispatchEvent("dragStart",t,[i]),this.animate())},o.measureContainment=function(){var t=this.getContainer();if(t){var i=a(this.element),e=a(t),n=this.element.getBoundingClientRect(),o=t.getBoundingClientRect(),r=e.borderLeftWidth+e.borderRightWidth,s=e.borderTopWidth+e.borderBottomWidth,h=this.relativeStartPosition={x:n.left-(o.left+e.borderLeftWidth),y:n.top-(o.top+e.borderTopWidth)};this.containSize={width:e.width-r-h.x-i.width,height:e.height-s-h.y-i.height}}},o.getContainer=function(){var t=this.options.containment;if(t)return t instanceof HTMLElement?t:"string"==typeof t?document.querySelector(t):this.element.parentNode},o.onPointerMove=function(t, i, e){this.dispatchJQueryEvent("pointerMove",t,[i,e])},o.dragMove=function(t, i, e){if(this.isEnabled){var n=e.x,o=e.y,r=this.options.grid,s=r&&r[0],h=r&&r[1];n=d(n,s),o=d(o,h),n=this.containDrag("x",n,s),o=this.containDrag("y",o,h),n="y"==this.options.axis?0:n,o="x"==this.options.axis?0:o,this.position.x=this.startPosition.x+n,this.position.y=this.startPosition.y+o,this.dragPoint.x=n,this.dragPoint.y=o,this.dispatchEvent("dragMove",t,[i,e])}},o.containDrag=function(t, i, e){if(!this.options.containment)return i;var n="x"==t?"width":"height",o=d(-this.relativeStartPosition[t],e,"ceil"),r=this.containSize[n];return r=d(r,e,"floor"),Math.max(o,Math.min(r,i))},o.onPointerUp=function(t, i){this.element.classList.remove("is-pointer-down"),this.dispatchJQueryEvent("pointerUp",t,[i])},o.dragEnd=function(t, i){this.isEnabled&&(this.element.style.transform="",this.setLeftTop(),this.element.classList.remove("is-dragging"),this.dispatchEvent("dragEnd",t,[i]))},o.animate=function(){if(this.isDragging){this.positionDrag();var t=this;requestAnimationFrame(function(){t.animate()})}},o.setLeftTop=function(){this.element.style.left=this.position.x+"px",this.element.style.top=this.position.y+"px"},o.positionDrag=function(){this.element.style.transform="translate3d( "+this.dragPoint.x+"px, "+this.dragPoint.y+"px, 0)"},o.staticClick=function(t, i){this.dispatchEvent("staticClick",t,[i])},o.setPosition=function(t, i){this.position.x=t,this.position.y=i,this.setLeftTop()},o.enable=function(){this.isEnabled=!0},o.disable=function(){this.isEnabled=!1,this.isDragging&&this.dragEnd()},o.destroy=function(){this.disable(),this.element.style.transform="",this.element.style.left="",this.element.style.top="",this.element.style.position="",this.unbindHandles(),this.$element&&this.$element.removeData("draggabilly")},o._init=function(){},n&&n.bridget&&n.bridget("draggabilly",i),i});const Draggabilly = window.Draggabilly;@@ -32,12 +35,19 @@ const fillerTemplate = `<div class="tab-row-filler"><div class="tab-row-border"></div></div>`;-class TabRow {- constructor(el) {+const TPL = `+<div class="note-tab-row">+ <div class="note-tab-row-content"></div>+</div>`;++export default class TabRowWidget extends BasicWidget {+ async doRender($widget) {+ $widget.append($(TPL));+this.draggabillies = [];this.eventListeners = {};- this.el = el;+ this.el = $widget.find(".note-tab-row")[0];this.setupStyleEl();this.setupEvents();@@ -46,17 +56,28 @@ class TabRow {this.setupFiller();this.layoutTabs();this.setVisibility();- }-- addListener(eventName, callback) {- this.eventListeners[eventName] = this.eventListeners[eventName] || [];- this.eventListeners[eventName].push(callback);- }- async emit(eventName, data) {- for (const listener of this.eventListeners[eventName]) {- await listener({ detail: data });- }+ $(this.el).on('contextmenu', '.note-tab', e => {+ e.preventDefault();++ const tab = $(e.target).closest(".note-tab");++ contextMenuService.initContextMenu(e, {+ getContextMenuItems: () => {+ return [+ {title: "Close all tabs", cmd: "removeAllTabs", uiIcon: "empty"},+ {title: "Close all tabs except for this", cmd: "removeAllTabsExceptForThis", uiIcon: "empty"}+ ];+ },+ selectContextMenuItem: (e, cmd) => {+ if (cmd === 'removeAllTabs') {+ this.removeAllTabs();+ } else if (cmd === 'removeAllTabsExceptForThis') {+ this.removeAllTabsExceptForThis(tab[0]);+ }+ }+ });+ })}setupStyleEl() {@@ -250,7 +271,7 @@ class TabRow {if (activeTabEl === tabEl) return;if (activeTabEl) activeTabEl.removeAttribute('active');tabEl.setAttribute('active', '');- await this.emit('activeTabChange', { tabEl });+ await this.trigger('activeTabChanged', { tabEl });}async removeTab(tabEl) {@@ -262,7 +283,7 @@ class TabRow {}}tabEl.parentNode.removeChild(tabEl);- await this.emit('tabRemove', { tabEl });+ await this.trigger('tabRemove', { tabEl });this.cleanUpPreviouslyDraggedTabs();this.layoutTabs();this.setupDraggabilly();@@ -380,7 +401,7 @@ class TabRow {tabEl.parentNode.insertBefore(tabEl, beforeEl);}- await this.emit('tabReorder', { tabEl, originIndex, destinationIndex });+ await this.trigger('tabReorder', { tabEl, originIndex, destinationIndex });this.layoutTabs();}@@ -391,7 +412,7 @@ class TabRow {this.tabContentEl.appendChild(this.newTabEl);- this.newTabEl.addEventListener('click', _ => this.emit('newTab'));+ this.newTabEl.addEventListener('click', _ => this.trigger('newTab'));}setupFiller() {@@ -415,9 +436,4 @@ class TabRow {return closestIndex;};-}--const noteTabRowEl = document.querySelector('.note-tab-row');-const tabRow = new TabRow(noteTabRowEl);--export default tabRow;\ No newline at end of file+}\ No newline at end of filediff --git a/src/public/javascripts/widgets/note_title.js b/src/public/javascripts/widgets/note_title.jsnew file mode 100644index 0000000000..ea7bb9392f--- /dev/null+++ b/src/public/javascripts/widgets/note_title.js@@ -0,0 +1,219 @@+import TabAwareWidget from "./tab_aware_widget.js";+import treeService from "../services/tree.js";+import utils from "../services/utils.js";+import protectedSessionService from "../services/protected_session.js";+import treeUtils from "../services/tree_utils.js";+import linkService from "../services/link.js";+import protectedSessionHolder from "../services/protected_session_holder.js";+import NoteTypeWidget from "./note_type.js";++const TPL = `+<style>+.note-title-row {+ flex-grow: 0;+ flex-shrink: 0;+ padding-top: 2px;+}++.note-title {+ margin-left: 15px;+ margin-right: 10px;+ font-size: 150%;+ border: 0;+ width: 5em;+ flex-grow: 100;+}+</style>++<div class="note-title-row">+ <div style="display: flex; align-items: center;">+ <div class="dropdown hide-in-zen-mode">+ <button class="btn btn-sm dropdown-toggle note-path-list-button" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">+ <span class="note-path-count">1 path</span>++ <span class="caret"></span>+ </button>+ <ul class="note-path-list dropdown-menu" aria-labelledby="note-path-list-button">+ </ul>+ </div>++ <input autocomplete="off" value="" class="note-title" tabindex="1">++ <span class="saved-indicator hide-in-zen-mode bx bx-check" title="All changes have been saved"></span>++ <div class="hide-in-zen-mode" style="display: flex; align-items: center;">+ <button class="btn btn-sm icon-button bx bx-play-circle render-button"+ style="display: none; margin-right: 10px;"+ title="Render"></button>++ <button class="btn btn-sm icon-button bx bx-play-circle execute-script-button"+ style="display: none; margin-right: 10px;"+ title="Execute (Ctrl+Enter)"></button>++ <div class="btn-group btn-group-xs">+ <button type="button"+ class="btn btn-sm icon-button bx bx-check-shield protect-button"+ title="Protected note can be viewed and edited only after entering password">+ </button>++ <button type="button"+ class="btn btn-sm icon-button bx bx-shield unprotect-button"+ title="Not protected note can be viewed without entering password">+ </button>+ </div>++ ++ <div style="display: flex;">+ <!-- note type here -->++ <div class="dropdown note-actions">+ <button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle">+ Note actions+ <span class="caret"></span>+ </button>+ <div class="dropdown-menu dropdown-menu-right">+ <a class="dropdown-item show-note-revisions-button" data-bind="css: { disabled: type() == 'file' || type() == 'image' }">Revisions</a>+ <a class="dropdown-item show-attributes-button"><kbd data-kb-action="ShowAttributes"></kbd> Attributes</a>+ <a class="dropdown-item show-link-map-button"><kbd data-kb-action="ShowLinkMap"></kbd> Link map</a>+ <a class="dropdown-item show-source-button" data-bind="css: { disabled: type() != 'text' && type() != 'code' && type() != 'relation-map' && type() != 'search' }">+ <kbd data-kb-action="ShowNoteSource"></kbd>+ Note source+ </a>+ <a class="dropdown-item import-files-button">Import files</a>+ <a class="dropdown-item export-note-button" data-bind="css: { disabled: type() != 'text' }">Export note</a>+ <a class="dropdown-item print-note-button"><kbd data-kb-action="PrintActiveNote"></kbd> Print note</a>+ <a class="dropdown-item show-note-info-button"><kbd data-kb-action="ShowNoteInfo"></kbd> Note info</a>+ </div>+ </div>+ </div>+ </div>+ </div>+</div>`;++export default class NoteTitleWidget extends TabAwareWidget {+ constructor(appContext) {+ super(appContext);++ this.tree = null;+ }++ async doRender($widget) {+ $widget.append($(TPL));++ this.$noteTitle = this.$tabContent.find(".note-title");+ this.$noteTitleRow = this.$tabContent.find(".note-title-row");+ this.$notePathList = this.$tabContent.find(".note-path-list");+ this.$notePathCount = this.$tabContent.find(".note-path-count");++ this.$protectButton = this.$tabContent.find(".protect-button");+ this.$protectButton.on('click', protectedSessionService.protectNoteAndSendToServer);++ this.$unprotectButton = this.$tabContent.find(".unprotect-button");+ this.$unprotectButton.on('click', protectedSessionService.unprotectNoteAndSendToServer);++ this.$savedIndicator = this.$tabContent.find(".saved-indicator");++ this.noteType = new NoteTypeWidget(this);++ this.$noteTitle.on('input', () => {+ if (!this.note) {+ return;+ }++ // FIXME event not used+ this.trigger(`activeNoteChanged`);++ this.note.title = this.$noteTitle.val();++ this.tabRow.updateTab(this.$tab[0], {title: this.note.title});+ treeService.setNoteTitle(this.note.noteId, this.note.title);++ this.setTitleBar();+ });++ if (utils.isDesktop()) {+ // keyboard plugin is not loaded in mobile+ utils.bindElShortcut(this.$noteTitle, 'return', () => {+ this.getComponent().focus();++ return false; // to not propagate the enter into the editor (causes issues with codemirror)+ });+ }+ }++ async activeTabChanged() {+ const note = this.tabContext.note;++ this.$noteTitle.val(this.note.title);++ this.$protectButton.toggleClass("active", note.isProtected);+ this.$protectButton.prop("disabled", note.isProtected);+ this.$unprotectButton.toggleClass("active", !note.isProtected);+ this.$unprotectButton.prop("disabled", !note.isProtected || !protectedSessionHolder.isProtectedSessionAvailable());++ await this.showPaths();+ }++ async showPaths() {+ const note = this.tabContext.note;++ if (note.noteId === 'root') {+ // root doesn't have any parent, but it's still technically 1 path++ this.$notePathCount.html("1 path");++ this.$notePathList.empty();++ await this.addPath('root', true);+ }+ else {+ const parents = await note.getParentNotes();++ this.$notePathCount.html(parents.length + " path" + (parents.length > 1 ? "s" : ""));+ this.$notePathList.empty();++ const pathSegments = this.notePath.split("/");+ const activeNoteParentNoteId = pathSegments[pathSegments.length - 2]; // we know this is not root so there must be a parent++ for (const parentNote of parents) {+ const parentNotePath = await treeService.getSomeNotePath(parentNote);+ // this is to avoid having root notes leading '/'+ const notePath = parentNotePath ? (parentNotePath + '/' + note.noteId) : note.noteId;+ const isCurrent = activeNoteParentNoteId === parentNote.noteId;++ await this.addPath(notePath, isCurrent);+ }++ const cloneLink = $("<div>")+ .addClass("dropdown-item")+ .append(+ $('<button class="btn btn-sm">')+ .text('Clone note to new location...')+ .on('click', () => import("../dialogs/clone_to.js").then(d => d.showDialog([note.noteId])))+ );++ this.$notePathList.append(cloneLink);+ }+ }++ async addPath(notePath, isCurrent) {+ const title = await treeUtils.getNotePathTitle(notePath);++ const noteLink = await linkService.createNoteLink(notePath, {title});++ noteLink+ .addClass("no-tooltip-preview")+ .addClass("dropdown-item");++ if (isCurrent) {+ noteLink.addClass("current");+ }++ this.$notePathList.append(noteLink);+ }++ noteSavedListener() {+ this.$savedIndicator.fadeIn();+ }+}\ No newline at end of filediff --git a/src/public/javascripts/services/note_type.js b/src/public/javascripts/widgets/note_type.jssimilarity index 75%rename from src/public/javascripts/services/note_type.jsrename to src/public/javascripts/widgets/note_type.jsindex 4decff9104..f5264183b0 100644--- a/src/public/javascripts/services/note_type.js+++ b/src/public/javascripts/widgets/note_type.js@@ -1,7 +1,8 @@-import treeService from './tree.js';-import noteDetailService from './note_detail.js';-import server from './server.js';-import mimeTypesService from './mime_types.js';+import treeService from '../services/tree.js';+import noteDetailService from '../services/note_detail.js';+import server from '../services/server.js';+import mimeTypesService from '../services/mime_types.js';+import TabAwareWidget from "./tab_aware_widget.js";const NOTE_TYPES = [{ type: "file", title: "File", selectable: false },@@ -15,20 +16,37 @@ const NOTE_TYPES = [{ type: "code", mime: 'text/plain', title: "Code", selectable: true }];-export default class NoteTypeContext {- /**- * @param {TabContext} ctx- */- constructor(ctx) {- this.ctx = ctx;-- ctx.$tabContent.find('.note-type').on('show.bs.dropdown', () => this.renderDropdown());-- this.$noteTypeDropdown = ctx.$tabContent.find(".note-type-dropdown");- this.$noteTypeButton = ctx.$tabContent.find(".note-type-button");- this.$noteTypeDesc = ctx.$tabContent.find(".note-type-desc");- this.$executeScriptButton = ctx.$tabContent.find(".execute-script-button");- this.$renderButton = ctx.$tabContent.find('.render-button');+const TPL = `+<style>+.note-type-dropdown {+ max-height: 500px;+ overflow-y: auto;+ overflow-x: hidden;+}+</style>++<div class="dropdown note-type">+ <button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle note-type-button">+ Type: <span class="note-type-desc"></span>+ <span class="caret"></span>+ </button>+ <div class="note-type-dropdown dropdown-menu dropdown-menu-right"></div>+</div>+`;++export default class NoteTypeWidget extends TabAwareWidget {+ async doRender($widget) {+ $widget.append($(TPL));++ $widget.find('.note-type').on('show.bs.dropdown', () => this.renderDropdown());++ this.$noteTypeDropdown = $widget.find(".note-type-dropdown");+ this.$noteTypeButton = $widget.find(".note-type-button");+ this.$noteTypeDesc = $widget.find(".note-type-desc");+ this.$executeScriptButton = $widget.find(".execute-script-button");+ this.$renderButton = $widget.find('.render-button');++ return $widget;}async update() {@@ -41,6 +59,10 @@ export default class NoteTypeContext {this.$renderButton.toggle(this.ctx.note.type === 'render');}+ async activeTabChanged() {+ this.update();+ }+/** actual body is rendered lazily on note-type button click */async renderDropdown() {this.$noteTypeDropdown.empty();diff --git a/src/public/javascripts/widgets/tab_aware_widget.js b/src/public/javascripts/widgets/tab_aware_widget.jsnew file mode 100644index 0000000000..c6d253067d--- /dev/null+++ b/src/public/javascripts/widgets/tab_aware_widget.js@@ -0,0 +1,19 @@+import BasicWidget from "./basic_widget.js";++export default class TabAwareWidget extends BasicWidget {+ constructor(appContext) {+ super(appContext);++ /** @var {TabContext} */+ this.tabContext = null;+ }++ // to override+ activeTabChanged() {}++ activeTabChangedListener() {+ this.tabContext = this.appContext.getActiveTabContext();++ this.activeTabChanged();+ }+}\ No newline at end of filediff --git a/src/public/stylesheets/desktop.css b/src/public/stylesheets/desktop.cssindex 0545cb3109..2e58b3cfbd 100644--- a/src/public/stylesheets/desktop.css+++ b/src/public/stylesheets/desktop.css@@ -175,21 +175,6 @@ body {border-color: var(--button-border-color);}-.note-title-row {- flex-grow: 0;- flex-shrink: 0;- padding-top: 2px;-}--.note-title {- margin-left: 15px;- margin-right: 10px;- font-size: 150%;- border: 0;- width: 5em;- flex-grow: 100;-}-.note-tab-row {box-sizing: border-box;position: relative;diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.cssindex 44db067589..cfb68cd109 100644--- a/src/public/stylesheets/style.css+++ b/src/public/stylesheets/style.css@@ -381,12 +381,6 @@ div.ui-tooltip {border-right: none;}-.note-type-dropdown {- max-height: 500px;- overflow-y: auto;- overflow-x: hidden;-}-.cm-matchhighlight {background-color: #eeeeee}diff --git a/src/views/center.ejs b/src/views/center.ejsindex 97ade9a511..69cc9ed49f 100644--- a/src/views/center.ejs+++ b/src/views/center.ejs@@ -2,8 +2,6 @@<div id="note-tab-container"><div class="note-tab-content note-tab-content-template"><div class="note-detail-content">- <% include title.ejs %>-<div class="note-detail-script-area"></div><table class="note-detail-promoted-attributes"></table>diff --git a/src/views/desktop.ejs b/src/views/desktop.ejsindex fdf8014aa7..2a804379a7 100644--- a/src/views/desktop.ejs+++ b/src/views/desktop.ejs@@ -85,9 +85,7 @@</div></div>- <div class="note-tab-row">- <div class="note-tab-row-content"></div>- </div>+ <div id="tab-row-container"></div><div id="title-bar-buttons" style="display: none;"><button class="btn icon-action bx bx-minus" id="minimize-btn"></button>diff --git a/src/views/title.ejs b/src/views/title.ejsdeleted file mode 100644index 45c4a1f553..0000000000--- a/src/views/title.ejs+++ /dev/null@@ -1,71 +0,0 @@-<div class="note-title-row">- <div style="display: flex; align-items: center;">- <div class="dropdown hide-in-zen-mode">- <button class="btn btn-sm dropdown-toggle note-path-list-button" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">- <span class="note-path-count">1 path</span>-- <span class="caret"></span>- </button>- <ul class="note-path-list dropdown-menu" aria-labelledby="note-path-list-button">- </ul>- </div>-- <input autocomplete="off" value="" class="note-title" tabindex="1">-- <span class="saved-indicator hide-in-zen-mode bx bx-check" title="All changes have been saved"></span>-- <div class="hide-in-zen-mode" style="display: flex; align-items: center;">- <button class="btn btn-sm icon-button bx bx-play-circle render-button"- style="display: none; margin-right: 10px;"- title="Render"></button>-- <button class="btn btn-sm icon-button bx bx-play-circle execute-script-button"- style="display: none; margin-right: 10px;"- title="Execute (Ctrl+Enter)"></button>-- <div class="btn-group btn-group-xs">- <button type="button"- class="btn btn-sm icon-button bx bx-check-shield protect-button"- title="Protected note can be viewed and edited only after entering password">- </button>-- <button type="button"- class="btn btn-sm icon-button bx bx-shield unprotect-button"- title="Not protected note can be viewed without entering password">- </button>- </div>-- -- <div style="display: flex;">- <div class="dropdown note-type">- <button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle note-type-button">- Type: <span class="note-type-desc"></span>- <span class="caret"></span>- </button>- <div class="note-type-dropdown dropdown-menu dropdown-menu-right"></div>- </div>-- <div class="dropdown note-actions">- <button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle">- Note actions- <span class="caret"></span>- </button>- <div class="dropdown-menu dropdown-menu-right">- <a class="dropdown-item show-note-revisions-button" data-bind="css: { disabled: type() == 'file' || type() == 'image' }">Revisions</a>- <a class="dropdown-item show-attributes-button"><kbd data-kb-action="ShowAttributes"></kbd> Attributes</a>- <a class="dropdown-item show-link-map-button"><kbd data-kb-action="ShowLinkMap"></kbd> Link map</a>- <a class="dropdown-item show-source-button" data-bind="css: { disabled: type() != 'text' && type() != 'code' && type() != 'relation-map' && type() != 'search' }">- <kbd data-kb-action="ShowNoteSource"></kbd>- Note source- </a>- <a class="dropdown-item import-files-button">Import files</a>- <a class="dropdown-item export-note-button" data-bind="css: { disabled: type() != 'text' }">Export note</a>- <a class="dropdown-item print-note-button"><kbd data-kb-action="PrintActiveNote"></kbd> Print note</a>- <a class="dropdown-item show-note-info-button"><kbd data-kb-action="ShowNoteInfo"></kbd> Note info</a>- </div>- </div>- </div>- </div>- </div>-</div>\ No newline at end of file