MCPcopy Create free account
hub / github.com/Make-md/makemd / createNote

Method createNote

main.js:983–983  ·  view source on GitHub ↗
(t,r,n)

Source from the content-addressed store, hash-verified

981 ---
982 `,icon:"mk-make-hr",section:"Basic"},{label:"codeblock",value:"\n ```\n Type/Paste Your Code\n ```",offset:[-4,5],icon:"mk-make-codeblock"},{label:"callout",value:`> [!NOTE]
983 > Content`,offset:[-7,12],icon:"mk-make-callout"},{label:"internal",value:"link",icon:"mk-make-note",onSelect:(t,r,n,i,a,o,s,l)=>{r.enactor.selectLink(t,u=>{i.replaceRange(`[[${u}]]`,{...a,ch:o},s),l()})}},{label:"link",value:"<Paste Link>",offset:[-1,1],icon:"mk-make-link"},{label:"image",value:"image",icon:"mk-make-image",onSelect:(t,r,n,i,a,o,s,l)=>{r.enactor.selectImage(t,u=>{i.replaceRange(`![[${u}]]`,{...a,ch:o},s),l()})}},{label:"flow",value:"note",offset:[-2,4],icon:"mk-make-flow",onSelect:(t,r,n,i,a,o,s,l)=>{r.enactor.selectLink(t,u=>{i.replaceRange(`![![${u}]]`,{...a,ch:o},s),l()})}},{label:"context",value:"context",icon:"layout-list",onSelect:(t,r,n,i,a,o,s,l)=>{r.enactor.selectSpace(t,u=>{i.replaceRange(uz(r.enactor.makemd.superstate.spacesIndex.get(u),"files"),{...a,ch:o},s),i.setSelection({line:a.line,ch:0}),l()})}},{label:"table",value:"table",icon:"mk-make-table",onSelect:(t,r,n,i,a,o,s,l)=>{XM(r.enactor.makemd.superstate,n.parent.path,"table").then(u=>{i.replaceRange($M(r.enactor.makemd.superstate.spacesIndex.get(n.parent.path),u),{...a,ch:o},s),i.setSelection({line:a.line,ch:0}),l()})}},{label:"board",value:"board",icon:"square-kanban",onSelect:(t,r,n,i,a,o,s,l)=>{XM(r.enactor.makemd.superstate,n.parent.path,"board").then(u=>{i.replaceRange($M(r.enactor.makemd.superstate.spacesIndex.get(n.parent.path),u),{...a,ch:o},s),i.setSelection({line:a.line,ch:0}),l()})}},{label:"tag",value:"#tag",offset:[0,1],icon:"mk-make-tag"}]}loadExtensions(t){let r=KG(this.plugin,this.plugin.isTouchScreen());this.plugin.settings.editorFlow&&r.push(qMt(this.plugin,this.makemd.superstate)),this.plugin.extensions=r,t?this.plugin.plugin.registerEditorExtension(this.plugin.extensions):this.plugin.app.workspace.updateOptions()}async convertSpaceFragmentToMarkdown(t,r){if(t.type=="frame"){let n=await this.makemd.superstate.spaceManager.readFrame(t.path,t.id).then(i=>i?.schema);if(n){let i=Ni(n);this.makemd.superstate.spaceManager.readTable(t.path,i.def.db).then(a=>{if(!a)return;let o=Z$e(a.rows,a.cols);r(o)})}}else this.makemd.superstate.spaceManager.readTable(t.path,t.id).then(n=>{if(!n)return;let i=Z$e(n.rows,n.cols);r(i)})}selectLink(t,r){let n=t.target.getBoundingClientRect();return this.makemd.superstate.ui.quickOpen(2,n,je(t.view.document),r)}selectSpace(t,r){let n=t.target.getBoundingClientRect();return this.makemd.superstate.ui.quickOpen(3,n,je(t.view.document),r)}selectImage(t,r){let n=t.target.getBoundingClientRect();this.makemd.superstate.ui.quickOpen(4,n,je(t.view.document),r)}isSpace(t){return this.makemd.superstate.spacesIndex.has(t)}spaceNotePath(t){return this.makemd.superstate.spacesIndex.get(t)?.space.notePath}spaceFolderPath(t){return(this.makemd.superstate.spacesIndex.get(t)?.space).folderPath}parentPath(t){return this.makemd.superstate.spaceManager.parentPathForPath(t)}createNote(t,r,n){return this.makemd.superstate.spaceManager.createItemAtPath(t,"md",r,n)}createRoot(t){return this.makemd.superstate.ui.createRoot(t)}notify(t){return this.makemd.superstate.ui.notify(t)}uriByString(t,r){return this.makemd.superstate.spaceManager.uriByString(t,r)}spaceFragmentSchema(t){return IH(this.makemd.superstate,t)}saveSettings(){this.makemd.superstate.settings.basicsSettings=this.plugin.settings,this.plugin.plugin.saveSettings()}resolvePath(t,r){return this.makemd.superstate.spaceManager.resolvePath(t,r)}openMenu(t,r){let n=t.target.getBoundingClientRect();return this.makemd.superstate.ui.openMenu(n,{ui:this.makemd.superstate.ui,multi:!1,value:[],editable:!1,options:r,searchable:!1,showAll:!0},je(t.view.document))}pathExists(t){return this.makemd.superstate.spaceManager.pathExists(t)}openPath(t,r,n){let i=this.uriByString(t);BD(this.plugin.app,this.plugin.app.workspace.getLeaf(),r,null,async a=>{let o=a.attachLeaf();if(this.plugin.app.vault.getAbstractFileByPath(i.basePath)instanceof QD.TFile){await o.openFile(this.plugin.app.vault.getAbstractFileByPath(i.basePath));let s=LD(i.basePath,i.refStr,this.plugin.app);if(!o.view?.editor)return;n&&o.setViewState({type:"markdown",state:{mode:"preview"}}),s[0]&&s[1]&&o.view.editor?.cm.dispatch({annotations:[pp.of(s)]})}else await this.plugin.plugin.openPath(o,t,!0)})}addActiveStateListener(t){this.makemd.superstate.ui.eventsDispatch.addListener("activeStateChanged",t)}removeActiveStateListener(t){this.makemd.superstate.ui.eventsDispatch.removeListener("activeStateChanged",t)}};var tW=require("@codemirror/state"),rze=require("@codemirror/view");var xb=require("obsidian"),nze=ge(nG());var tze=(e,t)=>{let r=new tW.RangeSetBuilder,n=e.field(ud,!1),i=[];for(let o of n){let{from:s,to:l,type:u,expandedState:c}=o,f=s-3==e.doc.lineAt(s).from&&l+2==e.doc.lineAt(s).to;u==0?c==2&&i.push({start:l+2,end:l+2,decoration:GD(o,t)}):c==2&&u==1&&(e.selection.main.from==s-4&&e.selection.main.to==l+2||e.selection.main.from>=s-3&&e.selection.main.to<=l+1||(i.push({start:s-4,end:s-3,decoration:HG(o,t)}),f?i.push({start:s-3,end:l+2,decoration:VG(o,t)}):i.push({start:s-3,end:l+2,decoration:GD(o,t)})))}i.sort(VD("start",!0));for(let o of i)r.add(o.start,o.end,o.decoration);return r.finish()},$Mt=e=>tW.StateField.define({create(t){return tze(t,e)},update(t,r){return tze(r.state,e)},provide:t=>rze.EditorView.decorations.from(t)}),Gle=class extends xb.FuzzySuggestModal{constructor(r,n){super(r);this.EMPTY_TEXT="Files not found";this.selectedLink=n,this.init()}init(){this.files=this.app.vault.getMarkdownFiles(),this.emptyStateText=this.EMPTY_TEXT,this.setInstructions([{command:"\u2191\u2193",purpose:N.labels.toNavigate},{command:"\u21B5",purpose:N.labels.toAppendLinkToTheFile},{command:"esc",purpose:"to dismiss"}]),this.initNewNoteItem()}getItems(){return this.files}getItemText(r){return this.noSuggestion=!1,r.basename}onNoSuggestion(){this.noSuggestion=!0}onChooseItem(r,n){this.noSuggestion||this.selectedLink(r.path)}initNewNoteItem(){this.newNoteResult=document.createElement("div"),this.newNoteResult.addClasses(["suggestion-item","is-selected"]),this.suggestionEmpty=document.createElement("div"),this.suggestionEmpty.addClass("suggestion-empty"),this.suggestionEmpty.innerText=this.EMPTY_TEXT}itemInstructionMessage(r,n){let i=document.createElement("kbd");i.addClass("suggestion-hotkey"),i.innerText=n,r.appendChild(i)}},eW=class{constructor(t){this.plugin=t;this.name="Obsidian"}load(){this.plugin.settings=Object.assign({},OD,this.plugin.settings),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:`
984 ---
985 `,icon:"mk-make-hr",section:"Basic"},{label:"codeblock",value:"\n ```\n Type/Paste Your Code\n ```",offset:[-4,5],icon:"mk-make-codeblock"},{label:"callout",value:`> [!NOTE]
986 > Content`,offset:[-7,12],icon:"mk-make-callout"},{label:"internal",value:"link",icon:"mk-make-note",onSelect:(t,r,n,i,a,o,s,l)=>{r.enactor.selectLink(t,u=>{i.replaceRange(`[[${u}]]`,{...a,ch:o},s),l()})}},{label:"link",value:"<Paste Link>",offset:[-1,1],icon:"mk-make-link"},{label:"flow",value:"note",offset:[-2,4],icon:"mk-make-flow",onSelect:(t,r,n,i,a,o,s,l)=>{r.enactor.selectLink(t,u=>{i.replaceRange(`![![${u}]]`,{...a,ch:o},s),l()})}},{label:"table",value:`| | |

Callers

nothing calls this directly

Calls 1

createItemAtPathMethod · 0.65

Tested by

no test coverage detected