From 3d435a37cf9002de617b6df5fef93acbbc3cfa50 Mon Sep 17 00:00:00 2001 From: JP Cen Date: Tue, 7 Jan 2025 00:12:52 -0500 Subject: [PATCH] 0.1.1 fixed issue resolving path --- main.js | 2 +- manifest.json | 2 +- package.json | 2 +- src/basics/enactor/obsidian.tsx | 9 +++++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 68adbf3..6447213 100644 --- a/main.js +++ b/main.js @@ -610,7 +610,7 @@ Error generating stack: `+o.message+` > Content`,offset:[-7,12],icon:"mk-make-callout"},{label:"internal",value:"link",icon:"mk-make-note",onSelect:(t,n,r,f,o,s,u,d)=>{n.enactor.selectLink(t,m=>{f.replaceRange(`[[${m}]]`,{...o,ch:s},u),d()})}},{label:"link",value:"",offset:[-1,1],icon:"mk-make-link"},{label:"flow",value:"note",offset:[-2,4],icon:"mk-make-flow",onSelect:(t,n,r,f,o,s,u,d)=>{n.enactor.selectLink(t,m=>{f.replaceRange(`![![${m}]]`,{...o,ch:s},u),d()})}},{label:"table",value:`| | | | --- | --- | | | | -`,icon:"mk-make-table"},{label:"tag",value:"#tag",offset:[0,1],icon:"mk-make-tag"}]}async convertSpaceFragmentToMarkdown(t,n){n("")}selectLink(t,n){new Ju(this.plugin.app,n).open()}selectSpace(t,n){return this.notify("Not implemented")}pathExists(t){return this.plugin.app.vault.adapter.exists(t)}selectImage(t,n){return this.notify("Not implemented")}isSpace(t){return!1}spaceNotePath(t){return null}spaceFolderPath(t){return t}parentPath(t){return this.plugin.app.vault.getAbstractFileByPath(t)?.parent?.path}loadExtensions(t){let n=Jo(this.plugin,this.plugin.isTouchScreen());this.plugin.settings.editorFlow&&n.push(nv(this.plugin)),this.plugin.extensions=n,t?this.plugin.registerEditorExtension(this.plugin.extensions):this.plugin.app.workspace.updateOptions()}createNote(t,n,r){return this.plugin.app.fileManager.createNewMarkdownFile(this.plugin.app.vault.getAbstractFileByPath(t),n).then(f=>f.path)}createRoot(t){return(0,Om.createRoot)(t)}notify(t){new lr.Notice(t)}uriByString(t,n){return Fm(t)}spaceFragmentSchema(t){return Promise.resolve(null)}saveSettings(){this.plugin.saveData(this.plugin.settings)}resolvePath(t,n){return this.plugin.app.metadataCache.getFirstLinkpathDest(t,n)?.path}openMenu(t,n){let r=new lr.Menu;for(let f of n)r.addItem(o=>{o.setTitle(f.name),o.onClick(s=>f.onClick(s))});r.showAtMouseEvent(t)}openPath(t,n){let r=this.uriByString(t);bs(this.plugin.app,this.plugin.app.workspace.getLeaf(),n,null,async f=>{let o=f.attachLeaf();if(this.plugin.app.vault.getAbstractFileByPath(r.basePath)instanceof lr.TFile){await o.openFile(this.plugin.app.vault.getAbstractFileByPath(r.basePath));let s=ks(r.basePath,r.refStr,this.plugin.app);if(!o.view?.editor)return;s[0]&&s[1]&&o.view.editor?.cm.dispatch({annotations:[jt.of(s)]})}})}addActiveStateListener(t){}removeActiveStateListener(t){}};var Im=e=>{e.addCommand({id:"mk-open-flow",name:I.commandPalette.openFlow,callback:()=>e.openFlow()}),e.addCommand({id:"mk-close-flow",name:I.commandPalette.closeFlow,callback:()=>e.closeFlow()})};var ed=Ie(et()),rv=(e,t)=>{let n=e;for(;!n.hasClass("cm-editor")&&n.parentElement;)n=n.parentElement;if(!n.hasClass("cm-editor"))return;let r;return t.workspace.iterateLeaves(f=>{let o=f.view.editor?.cm;if(o&&n==o.dom)return r=o,!0},t.workspace.rootSplit),r},Am=(e,t,n)=>{t.querySelectorAll("p").forEach(r=>{for(let f of r.textContent.matchAll(/(?:!\[!\[|!!\[\[)([^\]]+)\]\]/g)){let o=f[1];r.style.display="none",e.enactor.createRoot(r.parentElement).render(ed.default.createElement(ri,{load:!0,plugin:e,path:o,source:n.sourcePath}))}})},fv=(e,t)=>{let n=e;setTimeout(async()=>{let r=0;for(;!e.parentElement&&r++<=50;)await sleep(50);if(!!e.parentElement){for(;!n.hasClass("markdown-embed")&&n.parentElement;)n=n.parentElement;n&&t(n)}})};var Vm=(e,t,n,r)=>{fv(e,async f=>{let o=f.querySelectorAll(".markdown-embed-link");for(let s=0;siv(e,r,t[r]));return n.length===1?n[0]:function(){n.forEach(r=>r())}}function iv(e,t,n){let r=e[t],f=e.hasOwnProperty(t),o=n(r);return r&&Object.setPrototypeOf(o,r),Object.setPrototypeOf(s,o),e[t]=s,u;function s(...d){return o===r&&e[t]===s&&u(),o.apply(this,d)}function u(){e[t]===s&&(f?e[t]=r:delete e[t]),o!==r&&(o=r,Object.setPrototypeOf(s,r||Function))}}var ur=require("obsidian");var Hm=e=>{let t=!1,n=Ms(ur.Workspace.prototype,{changeLayout(r){return async function(f){t=!0;try{await r.call(this,f)}finally{t=!1}}},getLeaf(r){return function(f){let o=r.call(this,f);if(o.isFlowBlock){let s=o.id,u=!1;e.app.workspace.iterateLeaves(d=>{d.flowEditors&&!u&&d.flowEditors.forEach(m=>{m.leaves().forEach(y=>{if(y.id==s){u=!0,o=d;return}})})},e.app.workspace.rootSplit)}return o}},setActiveLeaf(r){return function(o,s){return o.view.getViewType()=="markdown"&&(this.activeEditor=o.view,o.view.file),r.call(this,o,s)}},getDropLocation(r){return function(o){for(let s of dn.activePopovers(e.app)){let u=this.recursiveGetTarget(o,s.rootSplit);if(u)return u}return r.call(this,o)}},onDragLeaf(r){return function(f,o){let s=dn.forLeaf(o);return r.call(this,f,o)}}});e.register(n)},Bm=e=>{e.register(Ms(ur.WorkspaceLeaf.prototype,{getRoot(t){return function(){let n=t.call(this);return n.getRoot===this.getRoot?n:n.getRoot()}},setViewState(t){return async function(n,r){let f=await t.call(this,n,r);try{if(this.flowEditors)for(let o of this.flowEditors)o.hide();this.flowEditors=[]}catch{}return f}},setEphemeralState(t){return function(n){t.call(this,n),n.focus&&this.view?.getViewType()==="empty"&&(this.view.contentEl.tabIndex=-1,this.view.contentEl.focus())}}})),e.register(Ms(ur.WorkspaceItem.prototype,{getContainer(t){return function(){if(!!t)return!this.parentSplit||this instanceof ur.WorkspaceContainer?t.call(this):this.parentSplit.getContainer()}}}))};var ct=require("obsidian");var Ts=class extends ct.PluginSettingTab{constructor(n,r){super(n,r);this.app=n,this.plugin=r}refreshObsidian(){this.app.commands.executeCommandById("app:reload")}refreshView(){}display(){let{containerEl:n}=this;n.innerHTML="",n.createEl("h3",{text:I.settings.sectionFlow}),new ct.Setting(n).setName(I.settings.editorFlowReplace.name).setDesc(I.settings.editorFlowReplace.desc).addToggle(r=>r.setValue(this.plugin.settings.editorFlow).onChange(f=>{this.plugin.settings.editorFlow=f,this.plugin.enactor.saveSettings(),this.refreshView()})),new ct.Setting(n).setName(I.settings.internalLinkFlowEditor.name).setDesc(I.settings.internalLinkFlowEditor.desc).addToggle(r=>r.setValue(this.plugin.settings.internalLinkClickFlow).onChange(async f=>{this.plugin.settings.internalLinkClickFlow=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),new ct.Setting(n).setName(I.settings.internalLinkSticker.name).setDesc(I.settings.internalLinkSticker.desc).addToggle(r=>r.setValue(this.plugin.settings.internalLinkSticker).onChange(async f=>{this.plugin.settings.internalLinkSticker=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),new ct.Setting(n).setName(I.settings.editorFlowStyle.name).setDesc(I.settings.editorFlowStyle.desc).addDropdown(r=>{r.addOption("seamless",I.settings.editorFlowStyle.seamless),r.addOption("minimal",I.settings.editorFlowStyle.minimal),r.setValue(this.plugin.settings.editorFlowStyle).onChange(async f=>{this.plugin.settings.editorFlowStyle=f,document.body.classList.toggle("mk-flow-minimal",!1),document.body.classList.toggle("mk-flow-seamless",!1),f=="seamless"&&document.body.classList.toggle("mk-flow-seamless",!0),f=="classic"&&document.body.classList.toggle("mk-flow-minimal",!0),f=="minimal"&&document.body.classList.toggle("mk-flow-minimal",!0)})}),n.createEl("h3",{text:I.settings.sectionFlowMenu}),new ct.Setting(n).setName(I.settings.editorMakeMenu.name).setDesc(I.settings.editorMakeMenu.desc).addToggle(r=>r.setValue(this.plugin.settings.flowMenuEnabled).onChange(async f=>{this.plugin.settings.flowMenuEnabled=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),new ct.Setting(n).setName(I.settings.makeChar.name).setDesc(I.settings.makeChar.desc).addText(r=>{r.setValue(this.plugin.settings.menuTriggerChar).onChange(async f=>{if(f.length<1){r.setValue(this.plugin.settings.menuTriggerChar);return}let o=f[0];f.length===2&&(o=f.replace(this.plugin.settings.menuTriggerChar,"")),r.setValue(o),this.plugin.settings.menuTriggerChar=o,await this.plugin.enactor.saveSettings()})}),new ct.Setting(n).setName(I.settings.editorMakePlacholder.name).setDesc(I.settings.editorMakePlacholder.desc).addToggle(r=>r.setValue(this.plugin.settings.makeMenuPlaceholder).onChange(async f=>{this.plugin.settings.makeMenuPlaceholder=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),n.createEl("h3",{text:I.settings.sectionFlowStyler}),new ct.Setting(n).setName(I.settings.inlineStyler.name).setDesc(I.settings.inlineStyler.desc).addToggle(r=>r.setValue(this.plugin.settings.inlineStyler).onChange(async f=>{this.plugin.settings.inlineStyler=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),new ct.Setting(n).setName(I.settings.inlineStickerMenu.name).setDesc(I.settings.inlineStickerMenu.desc).addToggle(r=>r.setValue(this.plugin.settings.inlineStickerMenu).onChange(async f=>{this.plugin.settings.inlineStickerMenu=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),new ct.Setting(n).setName(I.settings.inlineStylerColor.name).setDesc(I.settings.inlineStylerColor.desc).addToggle(r=>r.setValue(this.plugin.settings.inlineStylerColors).onChange(f=>{this.plugin.settings.inlineStylerColors=f,this.plugin.enactor.saveSettings(),this.refreshView()})),new ct.Setting(n).setName(I.settings.mobileMakeBar.name).setDesc(I.settings.mobileMakeBar.desc).addToggle(r=>r.setValue(this.plugin.settings.mobileMakeBar).onChange(f=>{this.plugin.settings.mobileMakeBar=f,this.plugin.enactor.saveSettings(),this.refreshView()}))}};var Ds=require("@codemirror/state"),dr=require("@codemirror/view");var Rm=Ie(Ol()),jm=require("obsidian"),Ce=Ie(et());var Ot=e=>e.defaultView||window;var zm=(e,t)=>{if(e.isTouchScreen()){let n=e.app.workspace.containerEl.querySelector(t.settings.spacesRightSplit?".workspace-drawer.mod-right .workspace-drawer-header-left":".workspace-drawer.mod-left .workspace-drawer-header-left");n.innerHTML="",e.enactor.createRoot(n).render(Ce.default.createElement(ov,{superstate:t,plugin:e}))}},ov=e=>{let t=(0,Ce.useRef)(),[n,r]=Ce.default.useState([]);(0,Ce.useEffect)(()=>{setTimeout(()=>{e.superstate.ui.getWarnings().filter(o=>!e.superstate.settings.suppressedWarnings.some(s=>o.id==s))},1e3)},[]);let f=()=>{r(e.superstate.ui.getWarnings().filter(o=>!e.superstate.settings.suppressedWarnings.some(s=>o.id==s)))};return(0,Ce.useEffect)(()=>(e.superstate.eventsDispatcher.addListener("superstateUpdated",f),e.superstate.eventsDispatcher.addListener("settingsChanged",f),e.superstate.eventsDispatcher.addListener("warningsChanged",f),()=>{e.superstate.eventsDispatcher.removeListener("superstateUpdated",f),e.superstate.eventsDispatcher.removeListener("settingsChanged",f),e.superstate.eventsDispatcher.removeListener("warningsChanged",f)}),[]),Ce.default.createElement("div",{className:"mk-main-menu-container"},Ce.default.createElement("div",{className:"mk-main-menu-inner"},Ce.default.createElement("div",{className:(0,Rm.default)("mk-main-menu")},Ce.default.createElement("div",{className:"mk-main-menu-button mk-main-menu-button-primary",ref:t,onClick:o=>{e.superstate.ui.mainMenu(t.current,e.superstate)}},e.superstate.settings.systemName,n.length>0&&Ce.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:J.warning}}),Ce.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:J["chevrons-up-down"]}})),e.superstate.settings.blinkEnabled&&Ce.default.createElement("div",{className:"mk-main-menu-button",onClick:o=>e.superstate.ui.quickOpen()},Ce.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:J.search}}))),Ce.default.createElement("button",{"aria-label":I.buttons.newNote,className:"mk-main-menu-button",onClick:o=>e.superstate.ui.defaultAdd(null,Ot(o.view.document),o.metaKey?"tab":!1)},Ce.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:J["new-note"]}})),jm.Platform.isTablet&&Ce.default.createElement("div",{"aria-label":I.buttons.togglePin,className:"mk-main-menu-button",onClick:o=>e.superstate.settings.spacesRightSplit?e.plugin.app.workspace.rightSplit.togglePinned():e.plugin.app.workspace.leftSplit.togglePinned()},Ce.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:J.pin}}))))};var Ym=Ie(et());var Wm=e=>Ym.default.createElement("button",{className:`mk-collapse ${e.collapsed?"mk-collapsed":""}`,onClick:t=>{!e.onToggle||(t.stopPropagation(),e.onToggle(!e.collapsed,t))},dangerouslySetInnerHTML:{__html:J.collapse}});var ht=Ie(et());var K=Ie(et());var av=e=>{let[t,n]=(0,K.useState)(""),[r,f]=(0,K.useState)([]),[o,s]=(0,K.useState)([]),[u,d]=(0,K.useState)(null),m=S=>S.type=="emoji"?oi(S.html):S.html;(0,K.useEffect)(()=>{let S=[];S.push(...e.ui.allStickers()),f(S)},[]);let y=(0,K.useMemo)(()=>new Set(r.map(S=>S.type)),[r]),[w,b]=(0,K.useState)(1),C=(0,K.useCallback)(()=>{b(S=>S+1)},[w]),x=(0,K.useRef)(null);(0,K.useEffect)(()=>{let S=new IntersectionObserver(T=>{T[0].isIntersecting&&C()});return x.current&&S.observe(x.current),()=>{x.current&&S.unobserve(x.current)}},[C]);let[P,F]=(0,K.useState)(null);(0,K.useEffect)(()=>{s(r.filter(S=>S.name.includes(t)&&(P==null||S.type==P)).slice(0,w*250))},[t,r,w,P]);let g=S=>{n(S.target.value)},p=S=>{let T=u;S.key==="ArrowUp"&&T>0?d(T-1):S.key==="ArrowDown"&&T{v.current&&v.current.focus()},[v.current]),K.default.createElement(K.default.Fragment,null,K.default.createElement("div",{className:"mk-palette-search"},K.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:e.ui.getSticker("ui//search")}}),K.default.createElement("input",{value:t,onChange:g,onKeyDown:p,placeholder:I.labels.findStickers,ref:v}),K.default.createElement("button",{className:"mk-toolbar-button"})),K.default.createElement("div",{className:"mk-menu-sections"},K.default.createElement("div",{onClick:()=>F(null),className:`${P==null?"is-active":""} mk-menu-section`},"All"),[...y].map(S=>K.default.createElement("div",{key:S,onClick:()=>F(S),className:`${P==S?"is-active":""} mk-menu-section`},S))),K.default.createElement("div",{className:"mk-layout-row mk-layout-wrap mk-gap-4 mk-padding-12 mk-layout-scroll"},o.map((S,T)=>K.default.createElement("div",{key:T,onClick:()=>{e.selectedSticker(o[T].type+"//"+o[T].value),e.hide()},className:u===T?"selected mk-padding-4 mk-border-radius-4 mk-hover":"mk-padding-4 mk-border-radius-4 mk-hover"},K.default.createElement("div",{dangerouslySetInnerHTML:{__html:m(S)},className:"mk-sticker"}))),K.default.createElement("div",{ref:x})))},Es=av;var no=async(e,t,n)=>{e.spaceManager.saveLabel(t,e.settings.fmKeySticker,n)},Um=(e,t)=>{t.forEach(n=>{no(e,n,"")})};var sv=e=>{let{pathState:t}=e,n=t?.label?.sticker,r=t?.label?.color,f=d=>{if(!t)return;d.preventDefault(),d.stopPropagation();let m=[];return m.push({name:I.buttons.changeIcon,icon:"ui//sticker",onClick:y=>{e.superstate.ui.openPalette(ht.default.createElement(Es,{ui:e.superstate.ui,selectedSticker:w=>no(e.superstate,t?.path,w)}),Ot(y.view.document))}}),m.push({name:I.buttons.removeIcon,icon:"ui//file-minus",onClick:()=>{Um(e.superstate,[t.path])}}),e.superstate.ui.openMenu(d.target.getBoundingClientRect(),{ui:e.superstate.ui,multi:!1,value:[],editable:!1,options:m,searchable:!1,showAll:!0},Ot(d.view.document)),!1},o=d=>{if(d.stopPropagation(),t?.type=="space"){e.superstate.ui.openPalette(ht.default.createElement(Es,{ui:e.superstate.ui,selectedSticker:m=>no(e.superstate,t.path,m)}),Ot(d.view.document));return}e.superstate.ui.openPalette(ht.default.createElement(Es,{ui:e.superstate.ui,selectedSticker:m=>no(e.superstate,t.path,m)}),Ot(d.view.document))},[s,u]=R0(n);return ht.default.createElement("div",{className:`mk-path-icon ${n?"":"mk-path-icon-placeholder"}`},s=="image"?ht.default.createElement("img",{src:e.superstate.ui.getUIPath(e.superstate.imagesCache.get(u))}):ht.default.createElement("button",{"aria-label":I.buttons.changeIcon,onContextMenu:f,style:r?.length>0?{"--label-color":`${r}`,"--icon-color":"#ffffff"}:{"--icon-color":"var(--mk-ui-text-secondary)"},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker(n)},onClick:d=>e.editable&&o(d)}))},$m=e=>{let[t,n]=(0,ht.useState)(null),r=()=>{n(e.superstate.pathsIndex.get(e.path))},f=o=>{o.path==e.path&&r()};return(0,ht.useEffect)(()=>(r(),e.superstate.eventsDispatcher.addListener("pathStateUpdated",f),()=>{e.superstate.eventsDispatcher.removeListener("pathStateUpdated",f)}),[e.path]),t?ht.default.createElement(sv,{superstate:e.superstate,pathState:t,editable:!0}):ht.default.createElement(ht.default.Fragment,null)};var lv=(e,t)=>e.type=="folder"?`${e.path}/#*${t}`:e.type=="vault"?`/#*${t}`:`${e.path}/#*${t}`;var uv=(e,t)=>e.type=="folder"?`${e.path}/#^${t}`:e.type=="vault"?`/#^${t}`:`${e.path}/#^${t}`,td=(e,t)=>`![![${lv(e,t)}]]`,Zm=(e,t)=>`![![${uv(e,t)}]]`;var _s="files";var Ps="File";var qm={uniques:["name,schemaId"],cols:["name","schemaId","type","value","attrs","hidden","unique","primary"]},d7={...qm,rows:[{name:Ps,schemaId:_s,type:"file",primary:"true",hidden:"",unique:"",attrs:"",value:""},{name:"Created",schemaId:_s,type:"fileprop",value:Ps+".ctime",hidden:"",unique:"",attrs:"",primary:"true"}]};var Gm=[{name:"Name",schemaId:"",type:"text",primary:"true"}],c7={...qm,rows:[{name:Ps,schemaId:_s,type:"file",primary:"true",hidden:"",unique:"",attrs:"",value:""}]};var nd=(e,t)=>{let n=e;if(t.includes(n)){let r=1;for(;t.includes(n);)n=e+r.toString(),r+=1}return n};var Qm={view:"list",filters:[],listView:"",listItem:"",listGroup:"",listGroupProps:{},listViewProps:{},listItemProps:{},sort:[],groupBy:[],colsOrder:[],colsHidden:[],colsSize:{},colsCalc:{}};var dv=e=>{if(e=="table")return{view:"table",listView:"",listGroup:"",listItem:""};if(e=="flow")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*flowListItem"};if(e=="list")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*rowItem"};if(e=="details")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*detailItem"};if(e=="board")return{view:"list",listView:"spaces://$kit/#*columnView",listGroup:"spaces://$kit/#*columnGroup",listItem:"spaces://$kit/#*cardListItem"};if(e=="cards")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*gridGroup",listItem:"spaces://$kit/#*cardsListItem"};if(e=="catalog")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*rowGroup",listItem:"spaces://$kit/#*coverListItem"};if(e=="gallery")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*masonryGroup",listItem:"spaces://$kit/#*imageListItem"};if(e=="calendar")return{view:"list",listView:"spaces://$kit/#*calendarView",listGroup:"spaces://$kit/#*dateGroup",listItem:"spaces://$kit/#*eventItem"}},rd=async(e,t,n)=>{let r=n=="board"?"Board":"Table",f=await e.spaceManager.tablesForSpace(t);return f&&(r=nd(r,f.map(s=>s.id))),await e.spaceManager.createTable(t,{id:r,name:r,type:"db"}).then(s=>e.spaceManager.addSpaceProperty(t,{...Gm[0],schemaId:r})).then(async s=>{let u=await e.spaceManager.framesForSpace(t),d={id:nd(r,u?.map(m=>m.id)??[]),name:r,type:"view",predicate:JSON.stringify({...Qm,...n?dv(n):{view:"table"}}),def:JSON.stringify({db:r,icon:n=="board"?"ui//square-kanban":"ui//table"})};return await e.spaceManager.createFrame(t,d),d.id})};var Km=e=>{let t;try{t=JSON.parse(e)}catch{}return t};var Ls=e=>e?{...e,def:Km(e.def)}:null;var Nf=require("obsidian"),od=Ie(et());var Xm=async(e,t)=>{let n=e.spaceManager.uriByString(t);if(n.refType=="context"){let r=e.contextsIndex.get(n.basePath)?.schemas.find(f=>f.id==n.ref);if(r)return{id:r.id,name:r.name,type:"context",path:n.basePath}}if(n.refType=="frame")return e.spaceManager.readFrame(n.basePath,n.ref).then(r=>{let f=r?.schema;if(f){let o=Ls(f);return{id:f.id,name:o.name,sticker:o.def?.icon,type:"frame",frameType:o.type,path:n.basePath}}return null});if(n.refType=="action"){let r=e.actionsIndex.get(n.path)?.find(f=>f.schema.id==n.ref)?.schema;if(r)return{id:r.id,name:r.name,sticker:r.def?.icon,type:"action",path:n.basePath}}return null};var Jm=(e,t)=>{let n=t.map(o=>o.name),r="|",f=r+n.join(r)+`| +`,icon:"mk-make-table"},{label:"tag",value:"#tag",offset:[0,1],icon:"mk-make-tag"}]}async convertSpaceFragmentToMarkdown(t,n){n("")}selectLink(t,n){new Ju(this.plugin.app,n).open()}selectSpace(t,n){return this.notify("Not implemented")}pathExists(t){return this.plugin.app.vault.adapter.exists(t)}selectImage(t,n){return this.notify("Not implemented")}isSpace(t){return!1}spaceNotePath(t){return null}spaceFolderPath(t){return t}parentPath(t){return this.plugin.app.vault.getAbstractFileByPath(t)?.parent?.path}loadExtensions(t){let n=Jo(this.plugin,this.plugin.isTouchScreen());this.plugin.settings.editorFlow&&n.push(nv(this.plugin)),this.plugin.extensions=n,t?this.plugin.registerEditorExtension(this.plugin.extensions):this.plugin.app.workspace.updateOptions()}createNote(t,n,r){return this.plugin.app.fileManager.createNewMarkdownFile(this.plugin.app.vault.getAbstractFileByPath(t),n).then(f=>f.path)}createRoot(t){return(0,Om.createRoot)(t)}notify(t){new lr.Notice(t)}uriByString(t,n){return!t||n&&(t=this.resolvePath(t,n),!t)?null:Fm(t)}spaceFragmentSchema(t){return Promise.resolve(null)}saveSettings(){this.plugin.saveData(this.plugin.settings)}resolvePath(t,n){return!t||!n?null:this.plugin.app.metadataCache.getFirstLinkpathDest(t,n)?.path}openMenu(t,n){let r=new lr.Menu;for(let f of n)r.addItem(o=>{o.setTitle(f.name),o.onClick(s=>f.onClick(s))});r.showAtMouseEvent(t)}openPath(t,n){let r=this.uriByString(t);bs(this.plugin.app,this.plugin.app.workspace.getLeaf(),n,null,async f=>{let o=f.attachLeaf();if(this.plugin.app.vault.getAbstractFileByPath(r.basePath)instanceof lr.TFile){await o.openFile(this.plugin.app.vault.getAbstractFileByPath(r.basePath));let s=ks(r.basePath,r.refStr,this.plugin.app);if(!o.view?.editor)return;s[0]&&s[1]&&o.view.editor?.cm.dispatch({annotations:[jt.of(s)]})}})}addActiveStateListener(t){}removeActiveStateListener(t){}};var Im=e=>{e.addCommand({id:"mk-open-flow",name:I.commandPalette.openFlow,callback:()=>e.openFlow()}),e.addCommand({id:"mk-close-flow",name:I.commandPalette.closeFlow,callback:()=>e.closeFlow()})};var ed=Ie(et()),rv=(e,t)=>{let n=e;for(;!n.hasClass("cm-editor")&&n.parentElement;)n=n.parentElement;if(!n.hasClass("cm-editor"))return;let r;return t.workspace.iterateLeaves(f=>{let o=f.view.editor?.cm;if(o&&n==o.dom)return r=o,!0},t.workspace.rootSplit),r},Am=(e,t,n)=>{t.querySelectorAll("p").forEach(r=>{for(let f of r.textContent.matchAll(/(?:!\[!\[|!!\[\[)([^\]]+)\]\]/g)){let o=f[1];r.style.display="none",e.enactor.createRoot(r.parentElement).render(ed.default.createElement(ri,{load:!0,plugin:e,path:o,source:n.sourcePath}))}})},fv=(e,t)=>{let n=e;setTimeout(async()=>{let r=0;for(;!e.parentElement&&r++<=50;)await sleep(50);if(!!e.parentElement){for(;!n.hasClass("markdown-embed")&&n.parentElement;)n=n.parentElement;n&&t(n)}})};var Vm=(e,t,n,r)=>{fv(e,async f=>{let o=f.querySelectorAll(".markdown-embed-link");for(let s=0;siv(e,r,t[r]));return n.length===1?n[0]:function(){n.forEach(r=>r())}}function iv(e,t,n){let r=e[t],f=e.hasOwnProperty(t),o=n(r);return r&&Object.setPrototypeOf(o,r),Object.setPrototypeOf(s,o),e[t]=s,u;function s(...d){return o===r&&e[t]===s&&u(),o.apply(this,d)}function u(){e[t]===s&&(f?e[t]=r:delete e[t]),o!==r&&(o=r,Object.setPrototypeOf(s,r||Function))}}var ur=require("obsidian");var Hm=e=>{let t=!1,n=Ms(ur.Workspace.prototype,{changeLayout(r){return async function(f){t=!0;try{await r.call(this,f)}finally{t=!1}}},getLeaf(r){return function(f){let o=r.call(this,f);if(o.isFlowBlock){let s=o.id,u=!1;e.app.workspace.iterateLeaves(d=>{d.flowEditors&&!u&&d.flowEditors.forEach(m=>{m.leaves().forEach(y=>{if(y.id==s){u=!0,o=d;return}})})},e.app.workspace.rootSplit)}return o}},setActiveLeaf(r){return function(o,s){return o.view.getViewType()=="markdown"&&(this.activeEditor=o.view,o.view.file),r.call(this,o,s)}},getDropLocation(r){return function(o){for(let s of dn.activePopovers(e.app)){let u=this.recursiveGetTarget(o,s.rootSplit);if(u)return u}return r.call(this,o)}},onDragLeaf(r){return function(f,o){let s=dn.forLeaf(o);return r.call(this,f,o)}}});e.register(n)},Bm=e=>{e.register(Ms(ur.WorkspaceLeaf.prototype,{getRoot(t){return function(){let n=t.call(this);return n.getRoot===this.getRoot?n:n.getRoot()}},setViewState(t){return async function(n,r){let f=await t.call(this,n,r);try{if(this.flowEditors)for(let o of this.flowEditors)o.hide();this.flowEditors=[]}catch{}return f}},setEphemeralState(t){return function(n){t.call(this,n),n.focus&&this.view?.getViewType()==="empty"&&(this.view.contentEl.tabIndex=-1,this.view.contentEl.focus())}}})),e.register(Ms(ur.WorkspaceItem.prototype,{getContainer(t){return function(){if(!!t)return!this.parentSplit||this instanceof ur.WorkspaceContainer?t.call(this):this.parentSplit.getContainer()}}}))};var ct=require("obsidian");var Ts=class extends ct.PluginSettingTab{constructor(n,r){super(n,r);this.app=n,this.plugin=r}refreshObsidian(){this.app.commands.executeCommandById("app:reload")}refreshView(){}display(){let{containerEl:n}=this;n.innerHTML="",n.createEl("h3",{text:I.settings.sectionFlow}),new ct.Setting(n).setName(I.settings.editorFlowReplace.name).setDesc(I.settings.editorFlowReplace.desc).addToggle(r=>r.setValue(this.plugin.settings.editorFlow).onChange(f=>{this.plugin.settings.editorFlow=f,this.plugin.enactor.saveSettings(),this.refreshView()})),new ct.Setting(n).setName(I.settings.internalLinkFlowEditor.name).setDesc(I.settings.internalLinkFlowEditor.desc).addToggle(r=>r.setValue(this.plugin.settings.internalLinkClickFlow).onChange(async f=>{this.plugin.settings.internalLinkClickFlow=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),new ct.Setting(n).setName(I.settings.internalLinkSticker.name).setDesc(I.settings.internalLinkSticker.desc).addToggle(r=>r.setValue(this.plugin.settings.internalLinkSticker).onChange(async f=>{this.plugin.settings.internalLinkSticker=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),new ct.Setting(n).setName(I.settings.editorFlowStyle.name).setDesc(I.settings.editorFlowStyle.desc).addDropdown(r=>{r.addOption("seamless",I.settings.editorFlowStyle.seamless),r.addOption("minimal",I.settings.editorFlowStyle.minimal),r.setValue(this.plugin.settings.editorFlowStyle).onChange(async f=>{this.plugin.settings.editorFlowStyle=f,document.body.classList.toggle("mk-flow-minimal",!1),document.body.classList.toggle("mk-flow-seamless",!1),f=="seamless"&&document.body.classList.toggle("mk-flow-seamless",!0),f=="classic"&&document.body.classList.toggle("mk-flow-minimal",!0),f=="minimal"&&document.body.classList.toggle("mk-flow-minimal",!0)})}),n.createEl("h3",{text:I.settings.sectionFlowMenu}),new ct.Setting(n).setName(I.settings.editorMakeMenu.name).setDesc(I.settings.editorMakeMenu.desc).addToggle(r=>r.setValue(this.plugin.settings.flowMenuEnabled).onChange(async f=>{this.plugin.settings.flowMenuEnabled=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),new ct.Setting(n).setName(I.settings.makeChar.name).setDesc(I.settings.makeChar.desc).addText(r=>{r.setValue(this.plugin.settings.menuTriggerChar).onChange(async f=>{if(f.length<1){r.setValue(this.plugin.settings.menuTriggerChar);return}let o=f[0];f.length===2&&(o=f.replace(this.plugin.settings.menuTriggerChar,"")),r.setValue(o),this.plugin.settings.menuTriggerChar=o,await this.plugin.enactor.saveSettings()})}),new ct.Setting(n).setName(I.settings.editorMakePlacholder.name).setDesc(I.settings.editorMakePlacholder.desc).addToggle(r=>r.setValue(this.plugin.settings.makeMenuPlaceholder).onChange(async f=>{this.plugin.settings.makeMenuPlaceholder=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),n.createEl("h3",{text:I.settings.sectionFlowStyler}),new ct.Setting(n).setName(I.settings.inlineStyler.name).setDesc(I.settings.inlineStyler.desc).addToggle(r=>r.setValue(this.plugin.settings.inlineStyler).onChange(async f=>{this.plugin.settings.inlineStyler=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),new ct.Setting(n).setName(I.settings.inlineStickerMenu.name).setDesc(I.settings.inlineStickerMenu.desc).addToggle(r=>r.setValue(this.plugin.settings.inlineStickerMenu).onChange(async f=>{this.plugin.settings.inlineStickerMenu=f,await this.plugin.enactor.saveSettings(),this.plugin.reloadExtensions(!1)})),new ct.Setting(n).setName(I.settings.inlineStylerColor.name).setDesc(I.settings.inlineStylerColor.desc).addToggle(r=>r.setValue(this.plugin.settings.inlineStylerColors).onChange(f=>{this.plugin.settings.inlineStylerColors=f,this.plugin.enactor.saveSettings(),this.refreshView()})),new ct.Setting(n).setName(I.settings.mobileMakeBar.name).setDesc(I.settings.mobileMakeBar.desc).addToggle(r=>r.setValue(this.plugin.settings.mobileMakeBar).onChange(f=>{this.plugin.settings.mobileMakeBar=f,this.plugin.enactor.saveSettings(),this.refreshView()}))}};var Ds=require("@codemirror/state"),dr=require("@codemirror/view");var Rm=Ie(Ol()),jm=require("obsidian"),Ce=Ie(et());var Ot=e=>e.defaultView||window;var zm=(e,t)=>{if(e.isTouchScreen()){let n=e.app.workspace.containerEl.querySelector(t.settings.spacesRightSplit?".workspace-drawer.mod-right .workspace-drawer-header-left":".workspace-drawer.mod-left .workspace-drawer-header-left");n.innerHTML="",e.enactor.createRoot(n).render(Ce.default.createElement(ov,{superstate:t,plugin:e}))}},ov=e=>{let t=(0,Ce.useRef)(),[n,r]=Ce.default.useState([]);(0,Ce.useEffect)(()=>{setTimeout(()=>{e.superstate.ui.getWarnings().filter(o=>!e.superstate.settings.suppressedWarnings.some(s=>o.id==s))},1e3)},[]);let f=()=>{r(e.superstate.ui.getWarnings().filter(o=>!e.superstate.settings.suppressedWarnings.some(s=>o.id==s)))};return(0,Ce.useEffect)(()=>(e.superstate.eventsDispatcher.addListener("superstateUpdated",f),e.superstate.eventsDispatcher.addListener("settingsChanged",f),e.superstate.eventsDispatcher.addListener("warningsChanged",f),()=>{e.superstate.eventsDispatcher.removeListener("superstateUpdated",f),e.superstate.eventsDispatcher.removeListener("settingsChanged",f),e.superstate.eventsDispatcher.removeListener("warningsChanged",f)}),[]),Ce.default.createElement("div",{className:"mk-main-menu-container"},Ce.default.createElement("div",{className:"mk-main-menu-inner"},Ce.default.createElement("div",{className:(0,Rm.default)("mk-main-menu")},Ce.default.createElement("div",{className:"mk-main-menu-button mk-main-menu-button-primary",ref:t,onClick:o=>{e.superstate.ui.mainMenu(t.current,e.superstate)}},e.superstate.settings.systemName,n.length>0&&Ce.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:J.warning}}),Ce.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:J["chevrons-up-down"]}})),e.superstate.settings.blinkEnabled&&Ce.default.createElement("div",{className:"mk-main-menu-button",onClick:o=>e.superstate.ui.quickOpen()},Ce.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:J.search}}))),Ce.default.createElement("button",{"aria-label":I.buttons.newNote,className:"mk-main-menu-button",onClick:o=>e.superstate.ui.defaultAdd(null,Ot(o.view.document),o.metaKey?"tab":!1)},Ce.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:J["new-note"]}})),jm.Platform.isTablet&&Ce.default.createElement("div",{"aria-label":I.buttons.togglePin,className:"mk-main-menu-button",onClick:o=>e.superstate.settings.spacesRightSplit?e.plugin.app.workspace.rightSplit.togglePinned():e.plugin.app.workspace.leftSplit.togglePinned()},Ce.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:J.pin}}))))};var Ym=Ie(et());var Wm=e=>Ym.default.createElement("button",{className:`mk-collapse ${e.collapsed?"mk-collapsed":""}`,onClick:t=>{!e.onToggle||(t.stopPropagation(),e.onToggle(!e.collapsed,t))},dangerouslySetInnerHTML:{__html:J.collapse}});var ht=Ie(et());var K=Ie(et());var av=e=>{let[t,n]=(0,K.useState)(""),[r,f]=(0,K.useState)([]),[o,s]=(0,K.useState)([]),[u,d]=(0,K.useState)(null),m=S=>S.type=="emoji"?oi(S.html):S.html;(0,K.useEffect)(()=>{let S=[];S.push(...e.ui.allStickers()),f(S)},[]);let y=(0,K.useMemo)(()=>new Set(r.map(S=>S.type)),[r]),[w,b]=(0,K.useState)(1),C=(0,K.useCallback)(()=>{b(S=>S+1)},[w]),x=(0,K.useRef)(null);(0,K.useEffect)(()=>{let S=new IntersectionObserver(T=>{T[0].isIntersecting&&C()});return x.current&&S.observe(x.current),()=>{x.current&&S.unobserve(x.current)}},[C]);let[P,F]=(0,K.useState)(null);(0,K.useEffect)(()=>{s(r.filter(S=>S.name.includes(t)&&(P==null||S.type==P)).slice(0,w*250))},[t,r,w,P]);let g=S=>{n(S.target.value)},p=S=>{let T=u;S.key==="ArrowUp"&&T>0?d(T-1):S.key==="ArrowDown"&&T{v.current&&v.current.focus()},[v.current]),K.default.createElement(K.default.Fragment,null,K.default.createElement("div",{className:"mk-palette-search"},K.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:e.ui.getSticker("ui//search")}}),K.default.createElement("input",{value:t,onChange:g,onKeyDown:p,placeholder:I.labels.findStickers,ref:v}),K.default.createElement("button",{className:"mk-toolbar-button"})),K.default.createElement("div",{className:"mk-menu-sections"},K.default.createElement("div",{onClick:()=>F(null),className:`${P==null?"is-active":""} mk-menu-section`},"All"),[...y].map(S=>K.default.createElement("div",{key:S,onClick:()=>F(S),className:`${P==S?"is-active":""} mk-menu-section`},S))),K.default.createElement("div",{className:"mk-layout-row mk-layout-wrap mk-gap-4 mk-padding-12 mk-layout-scroll"},o.map((S,T)=>K.default.createElement("div",{key:T,onClick:()=>{e.selectedSticker(o[T].type+"//"+o[T].value),e.hide()},className:u===T?"selected mk-padding-4 mk-border-radius-4 mk-hover":"mk-padding-4 mk-border-radius-4 mk-hover"},K.default.createElement("div",{dangerouslySetInnerHTML:{__html:m(S)},className:"mk-sticker"}))),K.default.createElement("div",{ref:x})))},Es=av;var no=async(e,t,n)=>{e.spaceManager.saveLabel(t,e.settings.fmKeySticker,n)},Um=(e,t)=>{t.forEach(n=>{no(e,n,"")})};var sv=e=>{let{pathState:t}=e,n=t?.label?.sticker,r=t?.label?.color,f=d=>{if(!t)return;d.preventDefault(),d.stopPropagation();let m=[];return m.push({name:I.buttons.changeIcon,icon:"ui//sticker",onClick:y=>{e.superstate.ui.openPalette(ht.default.createElement(Es,{ui:e.superstate.ui,selectedSticker:w=>no(e.superstate,t?.path,w)}),Ot(y.view.document))}}),m.push({name:I.buttons.removeIcon,icon:"ui//file-minus",onClick:()=>{Um(e.superstate,[t.path])}}),e.superstate.ui.openMenu(d.target.getBoundingClientRect(),{ui:e.superstate.ui,multi:!1,value:[],editable:!1,options:m,searchable:!1,showAll:!0},Ot(d.view.document)),!1},o=d=>{if(d.stopPropagation(),t?.type=="space"){e.superstate.ui.openPalette(ht.default.createElement(Es,{ui:e.superstate.ui,selectedSticker:m=>no(e.superstate,t.path,m)}),Ot(d.view.document));return}e.superstate.ui.openPalette(ht.default.createElement(Es,{ui:e.superstate.ui,selectedSticker:m=>no(e.superstate,t.path,m)}),Ot(d.view.document))},[s,u]=R0(n);return ht.default.createElement("div",{className:`mk-path-icon ${n?"":"mk-path-icon-placeholder"}`},s=="image"?ht.default.createElement("img",{src:e.superstate.ui.getUIPath(e.superstate.imagesCache.get(u))}):ht.default.createElement("button",{"aria-label":I.buttons.changeIcon,onContextMenu:f,style:r?.length>0?{"--label-color":`${r}`,"--icon-color":"#ffffff"}:{"--icon-color":"var(--mk-ui-text-secondary)"},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker(n)},onClick:d=>e.editable&&o(d)}))},$m=e=>{let[t,n]=(0,ht.useState)(null),r=()=>{n(e.superstate.pathsIndex.get(e.path))},f=o=>{o.path==e.path&&r()};return(0,ht.useEffect)(()=>(r(),e.superstate.eventsDispatcher.addListener("pathStateUpdated",f),()=>{e.superstate.eventsDispatcher.removeListener("pathStateUpdated",f)}),[e.path]),t?ht.default.createElement(sv,{superstate:e.superstate,pathState:t,editable:!0}):ht.default.createElement(ht.default.Fragment,null)};var lv=(e,t)=>e.type=="folder"?`${e.path}/#*${t}`:e.type=="vault"?`/#*${t}`:`${e.path}/#*${t}`;var uv=(e,t)=>e.type=="folder"?`${e.path}/#^${t}`:e.type=="vault"?`/#^${t}`:`${e.path}/#^${t}`,td=(e,t)=>`![![${lv(e,t)}]]`,Zm=(e,t)=>`![![${uv(e,t)}]]`;var _s="files";var Ps="File";var qm={uniques:["name,schemaId"],cols:["name","schemaId","type","value","attrs","hidden","unique","primary"]},d7={...qm,rows:[{name:Ps,schemaId:_s,type:"file",primary:"true",hidden:"",unique:"",attrs:"",value:""},{name:"Created",schemaId:_s,type:"fileprop",value:Ps+".ctime",hidden:"",unique:"",attrs:"",primary:"true"}]};var Gm=[{name:"Name",schemaId:"",type:"text",primary:"true"}],c7={...qm,rows:[{name:Ps,schemaId:_s,type:"file",primary:"true",hidden:"",unique:"",attrs:"",value:""}]};var nd=(e,t)=>{let n=e;if(t.includes(n)){let r=1;for(;t.includes(n);)n=e+r.toString(),r+=1}return n};var Qm={view:"list",filters:[],listView:"",listItem:"",listGroup:"",listGroupProps:{},listViewProps:{},listItemProps:{},sort:[],groupBy:[],colsOrder:[],colsHidden:[],colsSize:{},colsCalc:{}};var dv=e=>{if(e=="table")return{view:"table",listView:"",listGroup:"",listItem:""};if(e=="flow")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*flowListItem"};if(e=="list")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*rowItem"};if(e=="details")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*detailItem"};if(e=="board")return{view:"list",listView:"spaces://$kit/#*columnView",listGroup:"spaces://$kit/#*columnGroup",listItem:"spaces://$kit/#*cardListItem"};if(e=="cards")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*gridGroup",listItem:"spaces://$kit/#*cardsListItem"};if(e=="catalog")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*rowGroup",listItem:"spaces://$kit/#*coverListItem"};if(e=="gallery")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*masonryGroup",listItem:"spaces://$kit/#*imageListItem"};if(e=="calendar")return{view:"list",listView:"spaces://$kit/#*calendarView",listGroup:"spaces://$kit/#*dateGroup",listItem:"spaces://$kit/#*eventItem"}},rd=async(e,t,n)=>{let r=n=="board"?"Board":"Table",f=await e.spaceManager.tablesForSpace(t);return f&&(r=nd(r,f.map(s=>s.id))),await e.spaceManager.createTable(t,{id:r,name:r,type:"db"}).then(s=>e.spaceManager.addSpaceProperty(t,{...Gm[0],schemaId:r})).then(async s=>{let u=await e.spaceManager.framesForSpace(t),d={id:nd(r,u?.map(m=>m.id)??[]),name:r,type:"view",predicate:JSON.stringify({...Qm,...n?dv(n):{view:"table"}}),def:JSON.stringify({db:r,icon:n=="board"?"ui//square-kanban":"ui//table"})};return await e.spaceManager.createFrame(t,d),d.id})};var Km=e=>{let t;try{t=JSON.parse(e)}catch{}return t};var Ls=e=>e?{...e,def:Km(e.def)}:null;var Nf=require("obsidian"),od=Ie(et());var Xm=async(e,t)=>{let n=e.spaceManager.uriByString(t);if(n.refType=="context"){let r=e.contextsIndex.get(n.basePath)?.schemas.find(f=>f.id==n.ref);if(r)return{id:r.id,name:r.name,type:"context",path:n.basePath}}if(n.refType=="frame")return e.spaceManager.readFrame(n.basePath,n.ref).then(r=>{let f=r?.schema;if(f){let o=Ls(f);return{id:f.id,name:o.name,sticker:o.def?.icon,type:"frame",frameType:o.type,path:n.basePath}}return null});if(n.refType=="action"){let r=e.actionsIndex.get(n.path)?.find(f=>f.schema.id==n.ref)?.schema;if(r)return{id:r.id,name:r.name,sticker:r.def?.icon,type:"action",path:n.basePath}}return null};var Jm=(e,t)=>{let n=t.map(o=>o.name),r="|",f=r+n.join(r)+`| `;return t.forEach(o=>{f+=r+"----"}),f+=r+` `,e.forEach(o=>{f+=n.map(s=>r+o[s]).join("")+`| `}),f},fd=class extends dr.WidgetType{constructor(n,r){super();this.info=n;this.flowInfo=n,this.superstate=r}eq(n){return n.info.id===this.info.id}toDOM(n){let r=document.createElement("div");r.classList.add("mk-floweditor-sticker");let f=this.superstate.ui.createRoot(r);if(this.info.link&&n.state.field(Nf.editorInfoField,!1)){let s=n.state.field(Nf.editorInfoField,!1).file,u=this.superstate.spaceManager.uriByString(this.info.link,s?.path);f.render(od.default.createElement($m,{superstate:this.superstate,path:u.basePath}))}return r}},id=class extends dr.WidgetType{constructor(n,r){super();this.info=n;this.flowInfo=n,this.superstate=r}eq(n){return n.info.id===this.info.id&&n.info.expandedState==this.info.expandedState}toDOM(n){let r=document.createElement("div");r.classList.add("mk-floweditor-toggle");let f=this.superstate.ui.createRoot(r);return this.info.link&&n.state.field(Nf.editorInfoField,!1)&&f.render(od.default.createElement(Wm,{collapsed:this.info.expandedState==0,onToggle:o=>{n.dispatch({annotations:gt.of([this.info.id,o?2:0])})}})),r}},ep=(e,t,n)=>{let r=new Ds.RangeSetBuilder,f=e.field(ot,!1),o=[];for(let u of f){let{from:d,to:m,type:y,expandedState:w}=u,b=d-3==e.doc.lineAt(d).from&&m+2==e.doc.lineAt(d).to;y==0?(t.settings.internalLinkSticker&&o.push({start:d-2,end:d-2,decoration:dr.Decoration.widget({widget:new fd(u,n),side:-1})}),t.settings.internalLinkClickFlow&&o.push({start:m+2,end:m+2,decoration:dr.Decoration.widget({widget:new id(u,n),side:-1})}),w==2&&o.push({start:m+2,end:m+2,decoration:ef(u,t)})):w==2&&y==1&&(e.selection.main.from==d-4&&e.selection.main.to==m+2||e.selection.main.from>=d-3&&e.selection.main.to<=m+1||(o.push({start:d-4,end:d-3,decoration:Yo(u,t)}),b?o.push({start:d-3,end:m+2,decoration:Wo(u,t)}):o.push({start:d-3,end:m+2,decoration:ef(u,t)})))}o.sort(Xr("start",!0));for(let u of o)r.add(u.start,u.end,u.decoration);return r.finish()},cv=(e,t)=>Ds.StateField.define({create(n){return ep(n,e,t)},update(n,r){return ep(r.state,e,t)},provide:n=>dr.EditorView.decorations.from(n)}),Fs=class{constructor(t,n){this.makemd=t;this.plugin=n;this.name="MakeMD"}load(){this.plugin.settings=Object.assign({},Df,this.makemd.superstate.settings,this.makemd.superstate.settings.basicsSettings),this.plugin.settings.mobileSidepanel&&this.plugin.app.workspace.onLayoutReady(async()=>{zm(this.plugin,this.makemd.superstate)}),this.plugin.commands=this.loadCommands()}loadCommands(){return[{label:"todo",value:"- [ ] ",icon:"mk-make-todo"},{label:"list",value:"- ",icon:"mk-make-list"},{label:"ordered-list",value:"1. ",icon:"mk-make-ordered"},{label:"h1",value:"# ",icon:"mk-make-h1"},{label:"h2",value:"## ",icon:"mk-make-h2"},{label:"h3",value:"### ",icon:"mk-make-h3"},{label:"quote",value:"> ",icon:"mk-make-quote"},{label:"divider",value:` diff --git a/manifest.json b/manifest.json index 89dc805..c5ca24a 100755 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "make-basics", "name": "Basics", - "version": "0.1.0", + "version": "0.1.1", "minAppVersion": "0.16.0", "description": "Editable embeds and inline styling and other basic improvements to the markdown editor to your workflow.", "author": "MAKE.md", diff --git a/package.json b/package.json index 82b3956..533b586 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "basics", - "version": "0.1.0", + "version": "0.1.1", "description": "basics", "main": "main.js", "scripts": { diff --git a/src/basics/enactor/obsidian.tsx b/src/basics/enactor/obsidian.tsx index 18ac6da..4485a50 100644 --- a/src/basics/enactor/obsidian.tsx +++ b/src/basics/enactor/obsidian.tsx @@ -367,6 +367,12 @@ export class ObsidianEnactor implements Enactor { new Notice(message); } uriByString(uri: string, source?: string) { + if (!uri) return null; + + if (source) { + uri = this.resolvePath(uri, source); + if (!uri) return null; + } return parseURI(uri); } spaceFragmentSchema(uri: string) { @@ -377,6 +383,9 @@ export class ObsidianEnactor implements Enactor { this.plugin.saveData(this.plugin.settings); } resolvePath(path: string, source?: string) { + if (!path || !source) { + return null; + } return this.plugin.app.metadataCache.getFirstLinkpathDest(path, source) ?.path; }