Files

138 lines
9.5 KiB
JavaScript

import{R as b,S as n,V as p,$ as u,a0 as m,a1 as w,a2 as f,a3 as x,a4 as S,a5 as v,a6 as y,a7 as E,a8 as k,a9 as T,aa as C,ab as N,ac as _,ad as A,ae as L,af as R,ag as z,ah as B,ai as W}from"./layout_commons.js";import{B as g,a as l,c as M,n as P,t as I,N as D}from"./app_context.js";import{t as c}from"./syntax_highlight.js";import{i as X}from"./utils.js";import"./_commonjsHelpers.js";import"./preload-helper.js";import"./jquery.js";import"./index_jquery.js";import"./ckeditor5.js";import"./auto-render.js";import"./marked.esm.js";const G=`
<button type="button" class="action-button bx bx-sidebar"></button>`;class H extends g{doRender(){this.$widget=$(G),this.$widget.on("click",()=>this.triggerCommand("setActiveScreen",{screen:"tree"}))}}const O='<button type="button" class="action-button bx"></button>';class F extends g{isHorizontalLayout;constructor(t){super(),this.isHorizontalLayout=t}doRender(){this.$widget=$(O),this.$widget.addClass(this.isHorizontalLayout?"bx-dots-vertical-rounded":"bx-menu"),this.$widget.on("click",async t=>{const e=l.tabManager.getActiveContextNote();M.show({x:t.pageX,y:t.pageY,items:[{title:c("mobile_detail_menu.insert_child_note"),command:"insertChildNote",uiIcon:"bx bx-plus",enabled:e?.type!=="search"},{title:c("mobile_detail_menu.delete_this_note"),command:"delete",uiIcon:"bx bx-trash",enabled:e?.noteId!=="root"},{title:"----"},{title:"Note revisions",command:"showRevisions",uiIcon:"bx bx-history"}],selectMenuItemHandler:async({command:i})=>{if(i==="insertChildNote")P.createNote(l.tabManager.getActiveContextNotePath()??void 0);else if(i==="delete"){const a=l.tabManager.getActiveContextNotePath();if(!a)throw new Error("Cannot get note path to delete.");const r=await I.getBranchIdFromUrl(a);if(!r)throw new Error(c("mobile_detail_menu.error_cannot_get_branch_id",{notePath:a}));await b.deleteNotes([r])&&this.triggerCommand("setActiveScreen",{screen:"tree"})}else i&&this.triggerCommand(i)},forcePositionOnMobile:!0})})}}class V extends n{screenName;constructor(t,e){super(e),this.screenName=t}activeScreenChangedEvent({activeScreen:t}){}}const o=0,d=1,h=2,q=10;class U extends n{screenName;activeScreenName;currentTranslate;dragState;startX;translatePercentage;sidebarEl;backdropEl;originalSidebarTransition;originalBackdropTransition;constructor(t,e){super(e),this.screenName=t,this.currentTranslate=-100,this.translatePercentage=0,this.dragState=o,this.originalSidebarTransition="",this.originalBackdropTransition=""}doRender(){super.doRender(),document.addEventListener("touchstart",t=>this.#t(t)),document.addEventListener("touchmove",t=>this.#e(t),{passive:!1}),document.addEventListener("touchend",t=>this.#i(t))}#t(t){const e="touches"in t?t.touches[0].clientX:t.clientX;this.startX=e,!(e>30&&this.currentTranslate===-100)&&(this.#n(),this.dragState=d,this.translatePercentage=0)}#e(t){if(this.dragState===o||!this.startX)return;const i=("touches"in t?t.touches[0].clientX:t.clientX)-this.startX;if(this.dragState===d){if((this.currentTranslate===-100?i>q:i<-80)&&(this.sidebarEl.style.transition="none",this.backdropEl.style.transition="none",this.backdropEl.style.opacity=String(this.currentTranslate===-100?0:1),this.backdropEl.classList.add("show"),this.dragState=h),this.currentTranslate!==-100)return}else if(this.dragState===h){const a=this.sidebarEl.offsetWidth,r=Math.min(0,Math.max(this.currentTranslate+i/a*100,-100));this.translatePercentage=r,this.sidebarEl.style.transform=`translateX(${r}%)`,this.backdropEl.style.opacity=String(Math.max(0,1+r/100))}t.preventDefault()}#i(t){if(this.dragState===o)return;if(this.dragState===d){this.dragState=o;return}const e=this.currentTranslate===-100&&this.translatePercentage>-90,i=e?"tree":"detail";this.activeScreenName!==i?this.triggerCommand("setActiveScreen",{screen:i}):this.#a(e)}#n(){if(this.sidebarEl)return;const t=document.getElementById("mobile-sidebar-wrapper"),e=document.getElementById("mobile-sidebar-container");if(e?.addEventListener("click",()=>{this.triggerCommand("setActiveScreen",{screen:"detail"})}),!t||!e)throw new Error("Unable to find the sidebar or backdrop.");this.sidebarEl=t,this.backdropEl=e,this.originalSidebarTransition=this.sidebarEl.style.transition,this.originalBackdropTransition=this.backdropEl.style.transition}#a(t){this.sidebarEl&&(this.sidebarEl.classList.toggle("show",t),this.sidebarEl.style.transform=t?"translateX(0)":"translateX(-100%)",this.sidebarEl.style.transition=this.originalSidebarTransition,this.backdropEl.classList.toggle("show",t),this.backdropEl.style.transition=this.originalBackdropTransition,this.backdropEl.style.opacity=String(t?1:0),this.currentTranslate=t?0:-100,this.dragState=o)}activeScreenChangedEvent({activeScreen:t}){this.activeScreenName=t,this.#n(),this.#a(t===this.screenName)}}const Y=`<div class="classic-toolbar-outer-container">
<div class="classic-toolbar-widget"></div>
</div>
<style>
.classic-toolbar-outer-container.visible {
height: 38px;
background-color: var(--main-background-color);
position: relative;
overflow: visible;
flex-shrink: 0;
}
#root-widget.virtual-keyboard-opened .classic-toolbar-outer-container.ios {
position: absolute;
left: 0;
right: 0;
bottom: 0;
}
.classic-toolbar-widget {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 38px;
overflow: scroll;
display: flex;
align-items: flex-end;
user-select: none;
}
.classic-toolbar-widget::-webkit-scrollbar {
height: 0 !important;
width: 0 !important;
}
.classic-toolbar-widget.dropdown-active {
height: 50vh;
}
.classic-toolbar-widget .ck.ck-toolbar {
--ck-color-toolbar-background: transparent;
--ck-color-button-default-background: transparent;
--ck-color-button-default-disabled-background: transparent;
position: absolute;
background-color: transparent;
border: none;
}
.classic-toolbar-widget .ck.ck-button.ck-disabled {
opacity: 0.3;
}
</style>
`;class j extends D{observer;$innerWrapper;constructor(){super(),this.observer=new MutationObserver(t=>this.#e(t))}get name(){return"classicEditor"}doRender(){this.$widget=$(Y),this.$innerWrapper=this.$widget.find(".classic-toolbar-widget"),this.contentSized(),this.observer.disconnect(),this.observer.observe(this.$widget[0],{attributeFilter:["aria-expanded"],subtree:!0}),X()&&this.#t()}#t(){const t=()=>{let e=window.innerHeight-(window.visualViewport?.height||0);this.$widget.css("bottom",`${e}px`)};this.$widget.addClass("ios"),window.visualViewport?.addEventListener("resize",t),window.addEventListener("scroll",t)}#e(t){const e=t.map(i=>i.target.ariaExpanded==="true").reduce((i,a)=>i&&a);this.$innerWrapper.toggleClass("dropdown-active",e)}async#i(){return!(!this.note||this.note.type!=="text"||await this.noteContext?.isReadOnly())}async refreshWithNote(){this.toggleExt(await this.#i())}}const Q=`
<style>
kbd {
display: none;
}
.dropdown-menu {
font-size: larger;
}
.action-button {
background: none;
border: none;
cursor: pointer;
font-size: 1.25em;
padding-left: 0.5em;
padding-right: 0.5em;
color: var(--main-text-color);
}
.quick-search {
margin: 0;
}
.quick-search .dropdown-menu {
max-width: 350px;
}
</style>`,J=`
<style>
.tree-wrapper {
max-height: 100%;
margin-top: 0px;
overflow-y: auto;
contain: content;
padding-left: 10px;
}
.fancytree-custom-icon {
font-size: 2em;
}
.fancytree-title {
font-size: 1.5em;
margin-left: 0.6em !important;
}
.fancytree-node {
padding: 5px;
}
.fancytree-node .fancytree-expander:before {
font-size: 2em !important;
}
span.fancytree-expander {
width: 24px !important;
margin-right: 5px;
}
.fancytree-loading span.fancytree-expander {
width: 24px;
height: 32px;
}
.fancytree-loading span.fancytree-expander:after {
width: 20px;
height: 20px;
margin-top: 4px;
border-width: 2px;
border-style: solid;
}
.tree-wrapper .collapse-tree-button,
.tree-wrapper .scroll-to-active-note-button,
.tree-wrapper .tree-settings-button {
position: fixed;
margin-right: 16px;
display: none;
}
.tree-wrapper .unhoist-button {
font-size: 200%;
}
</style>`;class ct{getRootWidget(t){const e=new p(!0).setParent(t).class("horizontal-layout").cssBlock(Q).child(new n("column").id("mobile-sidebar-container")).child(new n("row").filling().id("mobile-rest-container").child(new U("tree","column").class("d-md-flex d-lg-flex d-xl-flex col-12 col-sm-5 col-md-4 col-lg-3 col-xl-3").id("mobile-sidebar-wrapper").css("max-height","100%").css("padding-left","0").css("padding-right","0").css("contain","content").child(new n("column").filling().id("mobile-sidebar-wrapper").child(new u).child(new m().cssBlock(J)))).child(new V("detail","column").id("detail-container").class("d-sm-flex d-md-flex d-lg-flex d-xl-flex col-12 col-sm-7 col-md-8 col-lg-9").child(new n("row").contentSized().css("font-size","larger").css("align-items","center").child(new H().contentSized()).child(new w().contentSized().css("position","relative").css("padding-left","0.5em")).child(new F(!0).contentSized())).child(new f).child(new x().child(new S).child(new v).child(new y).child(new E).child(new k).child(new T)).child(new C).child(new N().filling().contentSized().child(new _).child(new A).child(new L().css("font-size","smaller"))).child(new j))).child(new n("column").contentSized().id("mobile-bottom-bar").child(new R().css("height","40px")).child(new n("row").class("horizontal").css("height","53px").child(new z(!0)).child(new B(!0)).id("launcher-pane")));return W(e),e}}export{ct as default};