From 83825ed5b0a24ace46ee760fd8c5e438461aef3d Mon Sep 17 00:00:00 2001 From: blurymind Date: Fri, 30 Aug 2024 21:21:31 +0100 Subject: [PATCH] Updates --- index.html | 4 ++-- js/main.31d0930fccf136698d6b.js | 1 - js/main.6aa160b67d8f00407041.js | 1 + ...ccf136698d6b.js => runtime.6aa160b67d8f00407041.js} | 0 ...fccf136698d6b.js => vendor.6aa160b67d8f00407041.js} | 0 public/plugins/index.js | 2 +- public/plugins/plugin-editor.js | 10 +++++----- sw.js | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 js/main.31d0930fccf136698d6b.js create mode 100644 js/main.6aa160b67d8f00407041.js rename js/{runtime.31d0930fccf136698d6b.js => runtime.6aa160b67d8f00407041.js} (100%) rename js/{vendor.31d0930fccf136698d6b.js => vendor.6aa160b67d8f00407041.js} (100%) diff --git a/index.html b/index.html index a2d20f518..77ee2496b 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ -Yarn
 
\n

\n + add\n
\n
\n\n ';var n=e("#table"),o=e("#save-btn");this.table=n,this.rows=n.find("tr:not(:hidden)"),e("#save-btn").addClass("hide"),e(".table-add").on("click",this.tableAdd),e(".table-remove").on("click",(function(){console.log({removeThis:this}),e(this).parents("tr").detach()})),i.fn.pop=[].pop,i.fn.shift=[].shift,o.on("click",this.getValue)},this.init(),this.setValue=(e=[])=>{e.forEach(this.tableAdd)}}}.call(this,n("EVdn"),n("EVdn"))},LaP9:function(e,t){function n(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}n.keys=function(){return[]},n.resolve=n,e.exports=n,n.id="LaP9"},P0sH:function(e,t,n){"use strict";(function(e,i){n.d(t,"a",(function(){return h}));var o=n("owJe"),s=n("W2Rx"),a=n("5dEm"),r=n("INAQ"),l=n("pYPP"),d=n("fkuv"),c=n("2Qx2"),p=n("oj90"),u=n("l8+o"),h=(n("+NoZ"),function(t,h){const g=this;this.utils=p.Utils,this.setTheme=function(t,n){let i=n?n.target.value:t;setTimeout(g.initGrid,50),setTimeout(g.workspace.updateArrows,50),e("#theme-stylesheet").attr("href",p.Utils.getPublicPath(`themes/${i}.css`))},this.setLanguage=function(e,t){const n=t?t.target.value:e;Object(o.load_dictionary)(g.settings.language().split("-")[0]);const i=new CustomEvent("yarnSetLanguage");i.language=n,window.dispatchEvent(i),window.parent.dispatchEvent(i)},this.log=function(e){g.settings.developmentModeEnabled()&&console.log(e)},this.setDocumentType=function(e,t){const n=t?t.target.value:e;g.settings.documentType(n),g.log("Set doc type",e,app.data.inkCompiler),"ink"===n?(null===app.data.inkCompiler&&(app.data.inkCompiler=new app.data.InkCompiler),c.a.addGlobalScopeToInkDoc(),app.setMarkupLanguage("html")):app.data.inkCompiler=null,app.updateNodeLinks();const i=new CustomEvent("yarnSetDocumentType");i.language=n,window.dispatchEvent(i),window.parent.dispatchEvent(i)},this.setMarkupLanguage=function(e,t){const n=t?t.target.value:e;app.settings.markupLanguage(n),g.richTextFormatter=new u.a(g),g.mustRefreshNodes.notifySubscribers()},this.setGistPluginsFile=function(e,t){const n=t?t.target.value:e;app.settings.gistPluginsFile(n)},this.setFiletypeVersion=function(e,t){const n=t?t.target.value:e;g.filetypeVersion=n},this.setGistCredentials=function(e,t){const{token:n,file:i}=e;c.a.storage.setCredentials(n,i)},this.input=new r.a(g),this.settings=new l.a(g),this.workspace=new a.a(g),this.ui=new d.a(g),this.richTextFormatter=new u.a(g),this.data=c.a,this.name=i.observable(t),this.version=i.observable(h),this.editing=i.observable(null),this.nodes=i.observableArray([]),this.tags=i.observableArray([]),this.mustRefreshNodes=i.observable(),this.mustUpdateTags=!0,this.nodeHistory=[],this.nodeFuture=[],this.editingHistory=[],this.editingSaveHistoryTimeout=null,this.focusedNodeIdx=-1,this.isElectron=!1,this.editor=null,this.nodeVisitHistory=[],this.plugins={pluginStorage:{}},this.clipboard="",this.nodeClipboard=[],this.speachInstance=null,this.editingPath=i.observable(null),this.$searchField=e(".search-field"),this.isEditorInPreviewMode=!1,this.isEditorInPlayMode=i.observable(!1),this.isEditorSplit=!1,this.isEditorFocused=!1,this.editorResizeHandleOptions={handleSelector:"#editor-resize-handle",resizeHeight:!1,resizeWidthFrom:"right",onDragStart:function(){g.isSplitEditorInFocus=!0,e("#node-editor").removeClass("split-editor-out-of-focus")},onDragEnd:function(){g.editor.resize(),g.settings.editorSplitSize(e("#editor-form").width())}},this.inEditor=()=>(g.editing()||g.isEditorSplit&&g.isEditorFocused)&&!g.ui.isDialogOpen(),this.inWorkspace=()=>(!g.editing()||g.isEditorSplit&&!1===g.isEditorFocused)&&!g.ui.isDialogOpen(),this.run=function(){var t="Unknown OS";-1!=navigator.platform.indexOf("Win")&&(t="Windows"),-1!=navigator.platform.indexOf("Mac")&&(t="MacOS"),-1!=navigator.platform.indexOf("X11")&&(t="UNIX"),-1!=navigator.platform.indexOf("Linux")&&(t="Linux"),-1!=navigator.platform.indexOf("Linux")&&(t="Linux"),g.isElectron=navigator.userAgent.toLowerCase().includes("electron");var n=navigator.userAgent||navigator.vendor||window.opera;let o;/android|iPad|iPhone|iPod/.test(n.toLowerCase())&&!window.MSStream&&(t="mobile"),"Windows"==t&&(g.workspace.zoomSpeed=.1),window.addEventListener("beforeunload",e=>(this.data.saveAppStateToLocalStorage(),null)),window.addEventListener("DOMContentLoaded",e=>{if(g.electron){const e=g.electron.remote.process.argv.length>1?g.electron.remote.process.argv[1]:null;if(e&&app.fs.existsSync(e))return void this.data.openFileFromFilePath(e)}this.data.loadAppStateFromLocalStorage();const t=new URL(window.location),n=t.searchParams.get("text")||t.searchParams.get("url");null!==n&&g.insertTextAtCursor(n+"\n",!0)});const s=e("#addPwa")[0];s.style.display="none",window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),o=e,s.style.display="block",s.addEventListener("click",e=>{s.style.display="none",o.prompt(),o.userChoice.then(e=>{"accepted"===e.outcome?(g.log("User accepted the A2HS prompt"),s.style.display="none"):g.log("User dismissed the A2HS prompt"),o=null})})}),e("#app").show(),i.applyBindings(g,e("#app")[0]),g.editingVisualStudioCodeFile()||g.newNode().title("Start"),g.settings.apply(),e(".search-title input").click(g.updateSearch),e(".search-body input").click(g.updateSearch),e(".search-tags input").click(g.updateSearch),g.$searchField.on("input",g.updateSearch),g.$searchField.on("keyup",(function(e){27==e.keyCode?g.clearSearch():g.searchWarp()})),"mobile"===t&&g.workspace.setZoom(3),e(window).on("resize",(function(){g.ui.isScreenNarrow()&&g.editing()&&g.isEditorSplit&&g.toggleEditorView(),g.workspace.updateArrows(),g.initGrid()})),setTimeout(g.initGrid,50),this.guessPopUpHelper=function(){/color=#([a-zA-Z0-9]{3,6})$/.test(g.getTagBeforeCursor())&&g.insertColorCode()},this.insertEmoji=function(){this.emPicker.toggle(),g.togglePreviewMode(!0),e("#emojiPicker-container").css({left:g.input.mouse.x-200,top:g.input.mouse.y-125}),e("#emojiPicker-container").show()},this.insertColorCode=function(){e("#colorPicker-container").is(":visible")||(e("#colorPicker").spectrum("set",g.editor.getSelectedText()),e("#colorPicker").spectrum("toggle"),e("#colorPicker-container").css({left:g.input.mouse.x-70,top:g.input.mouse.y-50}),e("#colorPicker-container").show(),g.togglePreviewMode(!0),setTimeout(()=>{const t=e("#colorPicker").spectrum("get");g.applyPickerColorEditor(t)},100))},this.applyPickerColorEditor=function(e){const t=JSON.parse(JSON.stringify(g.editor.selection.getRange()));g.editor.selection.setRange(t);const n=e.toHexString().replace("#","");g.editor.session.replace(t,n),g.editor.selection.setRange({start:g.editor.getCursorPosition(),end:{row:g.editor.getCursorPosition().row,column:g.editor.getCursorPosition().column-n.length}}),g.togglePreviewMode(!0)},document.addEventListener("contextmenu",(function(e){g.editing()&&e.preventDefault()}),!1),document.ondragover=document.ondrop=e=>{e.preventDefault()},document.body.ondrop=e=>{e.preventDefault();for(var t=0;t{const t=e.data;switch(t.type){case"UpdateNode":g.nodes().forEach(e=>{e.title().trim()===t.payload.originalNodeTitle.trim()&&(e.title(t.payload.title),e.tags(t.payload.tags),e.body(t.payload.body),g.setYarnDocumentIsDirty())})}});var a=new CustomEvent("yarnReady");a.document=document,a.data=c.a,a.app=this,window.dispatchEvent(a),window.parent.dispatchEvent(a);const r=new URLSearchParams(window.location.href.split("?")[1]),l=r.get("gist"),d=r.get("fileName");l&&d&&fetch("https://api.github.com/gists/"+l).then(e=>e.json()).then(e=>{const t=e.files[d].content;c.a.openGist(t,d)})},this.limitNodesUpdate=function(e){g.nodes.extend({rateLimit:{method:"notifyWhenChangesStop",timeout:250}}),e(),g.nodes.limit(e=>()=>e())},this.getNodesConnectedTo=function(e){var t=[],n=g.nodes();for(var i in n)if(n[i]!=e&&n[i].isConnectedTo(e,!0)){var o=!1;for(var s in t)if(t[s]==n[i]){o=!0;break}o||t.push(n[i])}return t},this.matchConnectedColorID=function(e){var t=g.getNodesConnectedTo(e);for(var n in t)t[n].colorID(e.colorID())},this.quit=function(){g.isElectron},this.canEditNodeMeta=function(e){return"ink"!==app.settings.documentType()||e.trim()!==c.a.InkGlobalScopeNodeName},this.sanitiseNodeTitle=function(){"ink"===app.settings.documentType()&&(app.editing().title().startsWith("function ")||app.editing().title(app.editing().title().replace(/[ ]/g,"_")))},this.validateTitle=function(){var t=document.getElementById("editorTitle").value,n=e("#editorTitle");g.getOtherNodeTitles().includes(t)||g.titleExistsTwice(t)?(n.attr("class","title title-error"),n.attr("title","Another node has the same title")):"yarn"!==app.settings.documentType()||RegExp("^[a-z0-9]+$","i").test(t)?(n.removeAttr("title"),n.removeClass("title-error")):(n.attr("class","title title-error"),n.attr("title","Only upper or lower case letters and numbers are allowed in a node title."))},this.refreshWindowTitle=function(){let e="";"LOCAL"===app.settings.lastStorageHost()?e="Yarn - "+(c.a.editingPath()||c.a.editingName())+" "+(c.a.isDocumentDirty()?"*":""):"GIST"===app.settings.lastStorageHost()&&(e="Gist - "+(c.a.editingPath()||c.a.editingName())+" "+(c.a.isDocumentDirty()?"*":"")),g.electron?g.electron.remote.getCurrentWindow().setTitle(e):document.title=e},this.usingVisualStudioCodeExtension=function(){return!!window.vsCodeApi},this.editingVisualStudioCodeFile=function(){return!0===window.editingVsCodeFile},this.setYarnDocumentIsDirty=function(){g.usingVisualStudioCodeExtension()&&g.editingVisualStudioCodeFile()&&c.a.getSaveData(c.a.editingType()).then(e=>{window.vsCodeApi.postMessage({type:"DocumentEdit",payload:e})})},this.recordNodeAction=function(e,t){if(g.nodeFuture.length>0){for(var n=0;n=0&&g.nodes.splice(t,1),g.updateNodeLinks()}var n=null;if(n="undo"==e?g.nodeHistory.pop():g.nodeFuture.pop()){var i=n.action,o=n.node;"undo"==e?("created"==i?(n.lastX=o.x(),n.lastY=o.y(),t(o)):"removed"==i&&g.recreateNode(o,n.lastX,n.lastY),g.nodeFuture.push(n),g.setYarnDocumentIsDirty()):("created"==i?g.recreateNode(o,n.lastX,n.lastY):"removed"==i&&t(o),g.nodeHistory.push(n),g.setYarnDocumentIsDirty())}},this.recreateNode=function(e,t,n){g.nodes.push(e),e.moveTo(t,n),g.updateNodeLinks()},this.setSelectedColors=function(e){var t=g.workspace.getSelectedNodes();for(var n in t.splice(t.indexOf(e),1),t)t[n].colorID(e.colorID())},this.pasteNodes=function(){g.nodeClipboard.length&&(g.workspace.deselectAll(),g.nodeClipboard.forEach((function(e){var t=new s.a({title:g.getUniqueTitle(e.title()),body:e.body(),tags:e.tags(),colorID:e.colorID(),x:e.createX,y:e.createY});g.nodes.push(t),g.workspace.selectNodes(t),g.recordNodeAction("created",t)})),g.updateNodeLinks())},this.confirmDeleteNodes=function(e){const t=Array.isArray(e)?void 0:e,n=Array.isArray(e)?[...e]:t&&t.selected?[...g.workspace.getSelectedNodes()]:[e];n.length&&Swal.fire({title:"Are you sure?",text:`${n.length} ${1===n.length?"node":"nodes"} will be deleted.`,icon:"warning",showCancelButton:!0,confirmButtonText:"Yes, delete!",cancelButtonText:"No, cancel!",reverseButtons:!0}).then(e=>{e.value&&g.deleteNodes(n)})},this.deleteNodes=function(e){const t=Array.isArray(e)?e:[e],n=[];for(let e=t.length-1;e>=0;--e)n.push(t[e].remove());Promise.all(n).then(()=>{g.limitNodesUpdate(()=>{for(let e=t.length-1;e>=0;--e)g.inEditor()&&g.editing()===t[e]&&g.closeEditor(),g.deleteNode(t[e]);g.updateNodeLinks(),g.workspace.deselectNodes(t),g.workspace.updateArrows()})})},this.deleteNode=function(e){const t=g.nodes.indexOf(e);t>=0&&(g.recordNodeAction("removed",e),g.nodes.splice(t,1)),g.setYarnDocumentIsDirty()},this.cloneNodeArray=function(e){return e.map((function(e){return new s.a({title:e.title(),body:e.body(),tags:e.tags(),colorID:e.colorID(),x:e.x()+10,y:e.y()+10})}))},this.newNode=function(e=!0){var t=new s.a;return g.nodes.push(t),e&&g.updateNodeLinks(),g.recordNodeAction("created",t),t},this.newNodeAt=function(e,t){var n=new s.a({x:e-100,y:t-100});return g.nodes.push(n),g.updateNodeLinks(),g.recordNodeAction("created",n),n},this.searchTextInEditor=function(e=!0){e?g.editor.execCommand("find"):g.editor.searchBox&&g.editor.searchBox.hide()},this.showRandomQuote=function(){e.ajax({url:"https://api.forismatic.com/api/1.0/?",dataType:"jsonp",data:"method=getQuote&format=jsonp&lang=en&jsonp=?",success:function(e){Swal.fire({text:e.quoteText+"\n\n-"+e.quoteAuthor})}})},this.editNode=function(t,n=!0){if(!n&&!t.active())return;if(g.settings.alwaysOpenNodesInVisualStudioCodeEditor())return void g.editNodeInVisualStudioCodeEditor(t);g.editing()&&g.editing()!==t&&g.saveNode(!1),g.isEditorInPlayMode()&&g.togglePlayMode(!1),g.isEditorInPreviewMode&&g.togglePreviewMode(!1),t.oldTitle=t.title(),g.editing(t),g.mustUpdateTags=!0,e("#node-editor-background").css({opacity:0}).transition({opacity:1},250),e("#node-editor").css({y:"-100",opacity:0}).transition({y:"0",opacity:1},250),g.editor=ace.edit("editor"),g.editor.setOptions({scrollPastEnd:.5}),g.editor.focus(),g.editor.navigateFileEnd(),e("#colorPicker").spectrum({flat:!0,showButtons:!1,showInput:!0,showPalette:!0,preferredFormat:"hex",palette:[["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],["#f00","#f90","#ff0","#0f0","#0ff","#00f","#90f","#f0f"],["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"]],move:function(e){g.applyPickerColorEditor(e)},clickoutFiresChange:!0});const i=ace.require("ace/ext/language_tools"),s=p.Utils.createAutocompleter("ink"===app.settings.documentType()?["divert.target"]:["string.llink","string.rlink"],app.getOtherNodeTitles().map(e=>{const n=g.getNodeByTitle(e);return{word:e,title:e,about:`${n.tags().length>0?`tags: ${n.tags()}
`:""}Preview:
${n.clippedBody()}`,titleStyle:t.titleStyles[n.colorID()]}}),"Node Link");i.setCompleters([s,i.keyWordCompleter,i.textCompleter,i.snippetCompleter]);let a=void 0;g.editor.getSession().on("change",(function(e){const t=g.settings.autoCloseTags();if("insert"===e.action&&t){if(g.richTextFormatter.justInsertedAutoComplete)return void(g.richTextFormatter.justInsertedAutoComplete=!1);a&&clearTimeout(a),a=setTimeout(()=>{a=void 0,g.richTextFormatter.completableTags.forEach(e=>{if(g.getTagBeforeCursor()===e.Start){g.richTextFormatter.justInsertedAutoComplete=!0;let t=e.Completion,n=e.Offset;g.settings.autoCloseBrackets()&&e.BehaviorCompletion&&(t=e.BehaviorCompletion,n+=1),e.Completion&&g.insertTextAtCursor(t),e.Offset&&g.moveEditCursor(n),e.Func&&e.Func()}})},200)}})),this.emPicker=new EmojiPicker(document.getElementById("emojiPickerDom"),e=>{g.insertTextAtCursor(e.char),this.emPicker.toggle(),g.togglePreviewMode(!1)}),Object(o.enable_spellcheck)(),g.toggleInvertColors(),g.toggleShowCounter(),g.toggleSpellCheck(),g.validateTitle(),g.updateEditorStats(),g.updateEditorOptions(),g.$searchField.val().length>0&&e(".search-body input").is(":checked")&&g.editor.findAll(g.$searchField.val()),g.settings.editorSplit()&&(g.splitEditor(),g.workspace.warpToNodeByIdx(t.index()-1)),"right"===g.settings.editorSplitDirection()?(e("#editor-form").addClass("split-editor-right"),e("#editor-resize-handle").addClass("float-right")):(e("#editor-form").removeClass("split-editor-right"),e("#editor-resize-handle").removeClass("float-right")),e(".node-editor").on("pointerdown","> *",(function(e){g.isEditorSplit&&(g.focusEditor(!0),e.stopPropagation())})),e(".app-info").hide(),g.editor.resize(),null!=t.undoManager&&g.editor.session.setUndoManager(t.undoManager);var r=new CustomEvent("yarnEditorOpen");r.document=document,r.data=c.a,r.app=app,window.dispatchEvent(r),window.parent.dispatchEvent(r)},this.splitEditor=function(){g.isEditorSplit=!0,g.focusEditor(!0),g.settings.editorSplit(!0),g.editorResizeHandleOptions.resizeWidthFrom="right"===g.settings.editorSplitDirection()?"left":"right",e("#editor-form").width(g.settings.editorSplitSize()).addClass("split-editor").toggleClass("split-editor-right","right"===g.settings.editorSplitDirection()).resizable(g.editorResizeHandleOptions),e("#node-editor-background").addClass("hidden"),e("#node-editor").css({"z-index":10002}),e("#editor-resize-handle").removeClass("hidden").toggleClass("float-right","right"===g.settings.editorSplitDirection()),e("#split-editor-button").addClass("hidden"),e("#snap-editor-button").removeClass("hidden"),e("#exit-editor").removeClass("hidden"),e("#full-size-editor-button").removeClass("hidden"),e("#split-button-separator").removeClass("hidden"),g.ui.checkAndMoveAppButtons()},this.toggleEditorView=function(){g.settings.editorSplit(!g.settings.editorSplit()),g.reopenEditor()},this.reopenEditor=function(){g.saveNode();let e=g.editing();g.closeEditor(),setTimeout(()=>{g.editNode(e)},250)},this.editorSnapToggle=function(){g.settings.editorSplitDirection("right"===g.settings.editorSplitDirection()?"left":"right"),g.reopenEditor()},this.focusEditor=function(t){!0===t?(e("#node-editor").removeClass("split-editor-unfocused"),g.isEditorFocused=!0):(e("#node-editor").addClass("split-editor-unfocused"),g.isEditorFocused=!1)},this.getSplitEditorXOffset=function(){let t=0;return g.inEditor()&&g.settings.editorSplit()&&(t=e("#editor-form").width()/2,"right"===g.settings.editorSplitDirection()&&(t*=-1)),t},this.editNodeInVisualStudioCodeEditor=function(e){g.usingVisualStudioCodeExtension()?(g.setYarnDocumentIsDirty(),window.vsCodeApi.postMessage({type:"OpenNode",payload:{title:e.title().trim(),tags:e.tags().trim(),body:g.trimBodyLinks(e.body().trim())}})):console.error("Tried to open node in Visual Studio Code text editor but we're not in the Visual Studio Code extension")},this.chooseRelativePathImage=function(e){g.insertTextAtCursor(e)},this.getNodeByTitle=function(e){return g.nodes().find(t=>t.title().trim().toLowerCase()===e.trim().toLowerCase())},this.openNodeByTitle=function(e,t=""){g.isEditorInPlayMode()&&g.togglePlayMode(),g.makeNodeWithName(e);const n=g.nodes().find(t=>t.title().trim().toLowerCase()===e.trim().toLowerCase());n&&(g.editNode(n,!0),t&&setTimeout(()=>g.editor.find(t),200))},this.openLastEditedNode=function(){if(0===g.nodeVisitHistory.length)g.saveNode(),g.closeEditor();else{const e=g.nodeVisitHistory.pop();g.propagateUpdateFromNode(g.editing()),g.openNodeByTitle(e)}},this.getSpellCheckSuggestionItems=function(){var e=Object(o.suggest_word_for_misspelled)(g.editor.getSelectedText());if(e){var t={};return e.forEach(e=>{t[e]={name:e,icon:"edit",callback:e=>{g.insertTextAtCursor(e)}}}),t}return!1},this.getThesaurusItems=function(){var e=n("GLdW")(g.editor.getSelectedText());if(!e)return!1;var t=[];if(Object.keys(e).forEach((function(n){e[n].forEach((function(e){t.includes(e)||e===n||t.push(e)}))})),t.length>0){var i={};return t.forEach(e=>{i[e]={name:e,icon:"edit",callback:e=>{g.insertTextAtCursor(e)}}}),i}return!1},this.toggleSpellCheck=function(){setTimeout((function(){g.settings.spellcheckEnabled()?Object(o.enable_spellcheck)():Object(o.disable_spellcheck)()}),50)},this.toggleInvertColors=function(){const t=g.settings.invertColorsEnabled()?{filter:"invert(100%)"}:{filter:"invert(0%)"};e("#app").css(t),e("#app-bg").css(t),e(".tooltip").css(t),e(".node .body").css(t),e(".editor-container .editor-preview").css(t)},this.initGrid=function(){if(g.settings.snapGridEnabled()){var t=e(window).width(),n=e(window).height();e("#grid-canvas").attr("width",t),e("#grid-canvas").attr("height",n),e("#gridSize").attr("disabled",!1),g.workspace.gridContext.strokeStyle=g.workspace.gridContext.fillStyle=e(".grid-canvas").css("color")}else e("#gridSize").attr("disabled",!0);app.workspace.updateGrid()},this.toggleShowCounter=function(){g.settings.editorStatsEnabled()?e(".node-editor .form .editor-counter").css({display:"initial"}):e(".node-editor .form .editor-counter").css({display:"none"})},this.toggleAutocompleteSuggestions=function(){g.settings.autocompleteSuggestionsEnabled(!g.settings.autocompleteSuggestionsEnabled()),g.updateEditorOptions()},this.toggleAutoCloseBrackets=function(){g.settings.autoCloseBrackets(!g.settings.autoCloseBrackets()),g.updateEditorOptions()},this.updateEditorOptions=function(){g.editor.setOptions({enableBasicAutocompletion:app.settings.autocompleteSuggestionsEnabled(),enableLiveAutocompletion:app.settings.autocompleteSuggestionsEnabled(),behavioursEnabled:app.settings.autoCloseBrackets()})},this.togglePreviewMode=function(t){const n=e(".editor")[0],i=e("#editor-preview")[0];g.isEditorInPreviewMode=t,app.ui.dispatchEvent("yarnInPreviewMode"),t?(e(".bbcode-toolbar").addClass("hidden"),n.style.display="none",i.style.display="block",i.innerHTML=g.richTextFormatter.richTextToHtml(g.editing().body(),!0),i.scrollTop=g.editor.renderer.scrollTop):(e(".bbcode-toolbar").removeClass("hidden"),g.editor.session.setScrollTop(i.scrollTop),i.innerHTML="",i.style.display="none",n.style.display="flex",g.editor.focus(),g.editor.resize(),e("#colorPicker-container").is(":visible")&&e("#colorPicker-container").hide(),e("#emojiPicker-container").is(":visible")&&e("#emojiPicker-container").hide())},this.appendText=function(e){g.editing().body(g.editing().body()+e);const t=g.editor.session.getLength()-1,n=g.editor.session.getLine(t).length;g.editor.gotoLine(t+1,n)},this.moveEditCursor=function(e){const t=g.editor.getCursorPosition();g.editor.gotoLine(t.row+1,t.column+e),g.editor.focus()},this.insertTextAtCursor=function(e,t=!1){if(!g.editing())return;g.editor.session.replace(g.editor.selection.getRange(),"");const n=g.editor.getCursorPosition();if(g.editor.session.insert(n,e),t){const e=g.editor.getCursorPosition();editor.scrollToLine(e.row,!0,!0,(function(){})),g.editor.focus()}g.updateEditorStats(),g.editor.focus()},this.getTagBeforeCursor=function(){const e=g.editor.getSelectionRange(),t=e.start.row,n=g.editor.session.getLine(t).substring(e.start.column-2,e.start.column+2);if(!n)return"";if("ink"===app.settings.documentType()){if(["->"].includes(n.trim()))return n.trim()}else if(["[[","<<"].includes(n.trim())||n.includes("|"))return n.trim();return g.richTextFormatter.identifyTag(n)},this.saveNode=function(){const t=g.editing();if(t){const n=e("#editorTitle")[0],i=g.getFutureEditedNodeTitle();n.value=i,t.title(i),t.body(g.trimBodyLinks(t.body().trim())),g.makeNewNodesFromLinks(),g.propagateUpdateFromNode(t),g.workspace.updateArrows(),setTimeout(g.updateSearch,600),g.setYarnDocumentIsDirty(),app.ui.dispatchEvent("yarnSavedNode")}},this.closeEditor=function(){g.editing().undoManager=g.editor.session.getUndoManager(),e("#node-editor-background").transition({opacity:0},250),e("#node-editor").transition({y:"-100",opacity:0},250,(function(e){g.editing(null),g.editor.destroy(),g.editor=null,this.emPicker=null})),g.isEditorSplit=!1,g.isEditorFocused=!1,e(".app-info").show(),app.ui.resetAppButtonsLocation(),g.isEditorInPlayMode()&&g.togglePlayMode(!1),g.isEditorInPreviewMode&&g.togglePreviewMode(!1)},this.convertMarkup=function(){g.nodes().forEach(e=>{e.body(g.richTextFormatter.convert(e.body()))})},this.updateSearch=p.Utils.debounce((function(){const t=app.$searchField.val().toLowerCase();for(var n=0;n{n.includes(e)||t.push(e)}),e.linkedFrom().forEach(e=>{n.includes(e)||t.push(e)}))},this.updateTagsRepository=p.Utils.debounce((function(){if(!app.mustUpdateTags)return;app.mustUpdateTags=!1;g.tags().forEach(e=>e.count=0),g.nodes().forEach(e=>{p.Utils.uniqueSplit(e.tags()," ").forEach(e=>{const t=g.tags().find(t=>t.text==e);if(t)++t.count;else{const t=(()=>{const e=g.tags().map(e=>e.id);for(let t=1;;++t)if(!e.includes(t))return t})();g.tags.push({id:t,style:"tag-style-"+t,text:e,count:1})}})});let e=g.tags().length;for(;e--;)0===g.tags()[e].count&&g.tags().splice(e,1)}),500),this.makeNewNodesFromLinks=function(){if(!g.settings.createNodesEnabled())return console.info("Autocreate new nodes disabled");var e=g.editing().getLinksInNode();if(null!=e)for(var t=0;t0&&!n.includes(e)&&e!=g.editing().title()&&g.newNodeAt(g.editing().x()+t,g.editing().y()-120).title(e)},this.titleExistsTwice=function(e){return g.nodes().filter(t=>t.title().trim()===e.trim()).length>1},this.getFutureEditedNodeTitle=function(){const t=e("#editorTitle")[0];return g.getUniqueTitle(t.value.trim())},this.getOtherNodeTitles=function(){const e=[];return g.nodes().forEach(t=>{if(!g.editing()||t.title()!==g.editing().title()){if("ink"===app.settings.documentType()&&t.title().trim()===c.a.InkGlobalScopeNodeName)return;e.push(t.title().trim())}}),e},this.getHighlightedText=function(t){t=(t=(t=(t=(t=(t=(t=(t=t.replace(/\/g,">")).replace(/\<\<(.*?)\>\>/g,'

<<

$1

>>

')).replace(/\[\[([^\|]*?)\]\]/g,'

[[

$1

]]

')).replace(/\[\[([^\[\]]*?)\|([^\[\]]*?)\]\]/g,'

[[

$1

|

$2

]]

')).replace(/[^:]\/\/(.*)?($|\n)/g,'//$1\n')).replace(/\/\*((.|[\r\n])*)?\*\//gm,'/*$1*/')).replace(/\/\%((.|[\r\n])*)?\%\//gm,'/%$1%/');var n=e("
");return n[0].innerHTML=t,n.find(".comment").each((function(){e(this).find("p").each((function(){e(this).removeClass()}))})),n.find(".linkname").each((function(){var t=e(this).text(),n=!1;for(var i in g.nodes())if(g.nodes()[i].title().toLowerCase()==t.toLowerCase()){n=!0;break}n||e(this).removeClass("linkname")})),t=n[0].innerHTML},this.updateLineNumbers=function(t){for(var n=t.split("\n"),i="",o=0;o0)&&(i+=o+1+"
");e(".editor-container .lines").html(i)},this.moveNodes=function(e,t){for(var n in g.nodes()){var i=g.nodes()[n];i.moveTo(i.x()+e,i.y()+t)}},this.getFirstFoundNode=function(e){return g.nodes().find(t=>t.title().toLowerCase().trim()===e)},this.searchWarp=function(){var e=g.$searchField.val().toLowerCase().trim();if(""===e)g.workspace.warpToNodeByIdx(0);else{const t=g.getFirstFoundNode(e);g.workspace.warpToNodeByIdx(g.nodes.indexOf(t))}},this.clearSearch=function(){g.$searchField.val(""),g.updateSearch()},this.updateEditorStats=function(){var t=g.editor.getSession().getValue(),n=g.editor.getCursorPosition(),i=t.split("\n");e(".editor-counter .character-count").html(t.length),e(".editor-counter .line-count").html(i.length),e(".editor-counter .row-index").html(n.row),e(".editor-counter .column-index").html(n.column),c.a.saveAppStateToLocalStorage()},this.getUniqueTitle=function(e){var t=g.getOtherNodeTitles();if(e&&!t.includes(e))return e;var n=e||"Node",i=2;const o=n.match(/^(.*)(_([0-9]+))$/);if(o&&4===o.length&&(n=o[1],i=Number(o[3])),!t.includes(n))return n;for(;;++i){var s=n+"_"+i;if(!t.includes(s))return s}},this.navigateToNodeDuringPlayTest=function(e,t=""){g.openNodeByTitle(e,t),g.togglePlayMode(!0),app.workspace.warpToNode(app.getFirstFoundNode(e))}})}).call(this,n("EVdn"),n("Z1dp"))},"P85/":function(e,t,n){},W2Rx:function(e,t,n){"use strict";(function(e,i){n.d(t,"a",(function(){return a}));var o=n("oj90");let s=0;let a=function(t={}){const n=this;this.titleStyles=["title-style-1","title-style-2","title-style-3","title-style-4","title-style-5","title-style-6","title-style-7","title-style-8","title-style-9"],this.index=e.observable(s++),this.title=e.observable(t.title||app.getUniqueTitle()),this.tags=e.observable(t.tags||""),this.body=e.observable(t.body||""),this.active=e.observable(t.active||!0),this.width=200,this.height=200,this.tempOpacity=null,this.style=null,this.colorID=e.observable(t.colorID||0),this.checked=!1,this.selected=!1,this.createX=t.x||null,this.createY=t.y||null,this.undoManager=null,this.clippedTags=e.computed((function(){return app.updateTagsRepository(),o.Utils.uniqueSplit(n.tags()," ").map(e=>app.tags().find(t=>t.text===e)).filter(e=>e)}),this),this.clippedBody=e.computed((function(){if(app.ui.isScreenNarrow()&&app.editing())return;app.mustRefreshNodes();let e=app.getHighlightedText(this.body());return e=app.richTextFormatter.richTextToHtml(e),e=e.substr(0,225),e}),this),this.linkedTo=e.observableArray(),this.linkedFrom=e.observableArray(),this.element=null,this.canDoubleClick=!0,this.create=function(){if(n.style=window.getComputedStyle(i(n.element).get(0)),n.createX&&n.createY)n.x(n.createX),n.y(n.createY);else{let e=i(n.element).parent();n.x((-e.offset().left+i(window).width()/2-100)/app.workspace.scale),n.y((-e.offset().top+i(window).height()/2-100)/app.workspace.scale)}app.workspace.bringToFront(n.element),app.workspace.startUpdatingArrows(),i(n.element).css({opacity:0,scale:.8,y:"-=80px",rotate:"45deg"}).transition({opacity:1,scale:1,y:"+=80px",rotate:"0deg"},250,"easeInQuad",(function(){app.workspace.stopUpdatingArrows(),app.workspace.updateArrows()})),n.drag(),i(n.element).on("dblclick",(function(){n.canDoubleClick&&app.editNode(n)})),o.Utils.addDoubleTapDetector(n.element,(function(){n.canDoubleClick&&app.editNode(n)})),i(n.element).on("click",(function(e){e.ctrlKey&&(n.selected?app.workspace.deselectNodes(n):app.workspace.selectNodes(n))}))},this.setSelected=function(e){n.selected=e,n.selected?i(n.element).addClass("selected"):i(n.element).removeClass("selected")},this.toggleSelected=function(){n.setSelected(!n.selected)},this.x=function(e){if(null!=e&&i(n.element).css({x:Math.floor(e)}),n.style)return Math.floor(new WebKitCSSMatrix(n.style.webkitTransform).m41)},this.y=function(e){if(null!=e&&i(n.element).css({y:Math.floor(e)}),n.style)return Math.floor(new WebKitCSSMatrix(n.style.webkitTransform).m42)},this.resetDoubleClick=function(){n.canDoubleClick=!0},this.cycleColorDown=function(){n.doCycleColorDown(),setTimeout(n.resetDoubleClick,500),n.canDoubleClick=!1,app.input.isShiftDown&&app.matchConnectedColorID(n),n.selected&&app.setSelectedColors(n),app.setYarnDocumentIsDirty()},this.cycleColorUp=function(){n.doCycleColorUp(),setTimeout(n.resetDoubleClick,500),n.canDoubleClick=!1,app.input.isShiftDown&&app.matchConnectedColorID(n),n.selected&&app.setSelectedColors(n),app.setYarnDocumentIsDirty()},this.doCycleColorDown=function(){n.colorID(n.colorID()-1),n.colorID()<0&&n.colorID(8)},this.doCycleColorUp=function(){n.colorID(n.colorID()+1),n.colorID()>8&&n.colorID(0)},this.remove=async function(){return new Promise((e,t)=>{i(n.element).transition({opacity:0,scale:.8,y:"-=80px",rotate:"-45deg"},250,"easeInQuad",e)})},this.drag=function(){const e={x:0,y:0};let t=!1,o=!1;i(document.body).on("mousemove touchmove",(function(i){if(t){const t=app.input.isScreenTouched&&i.changedTouches?i.changedTouches[0].pageX:i.pageX,s=app.input.isScreenTouched&&i.changedTouches?i.changedTouches[0].pageY:i.pageY;let{x:a,y:r}=app.workspace.toWorkspaceCoordinates(t,s);a-=e.x,r-=e.y;let l=a-n.x(),d=r-n.y();const c=app.workspace.getSelectedNodes();if(("mousemove"===i.originalEvent.type||c.includes(n)&&"touchmove"===i.originalEvent.type)&&(n.x(a),n.y(r)),o&&(n.selected?c.splice(c.indexOf(n),1):c=app.getNodesConnectedTo(n),c.length>0))for(let e in c)c[e].active()&&(c[e].x(c[e].x()+l),c[e].y(c[e].y()+d));app.workspace.updateArrows()}})),i(n.element).on("pointerdown",(function(i){if(!t&&n.active()&&0===i.button){t=!0,(app.input.isShiftDown||n.selected)&&(o=!0);const{x:s,y:a}=app.workspace.toWorkspaceCoordinates(i.pageX,i.pageY);e.x=app.settings.snapGridEnabled()?app.workspace.stepify(s-n.x(),app.settings.gridSize()):s-n.x(),e.y=app.settings.snapGridEnabled()?app.workspace.stepify(a-n.y(),app.settings.gridSize()):a-n.y()}})),i(n.element).on("touchend",(function(e){app.workspace.selectNodes(n)})),i(document).on("pointerup touchend",(function(){(t||o)&&(t=!1,o=!1,app.setYarnDocumentIsDirty())}))},this.moveTo=function(e,t){app.workspace.startUpdatingArrows(),i(n.element).clearQueue(),i(n.element).transition({x:e,y:t},app.stopUpdatingArrows,500)},this.isConnectedTo=function(e,t){if(t&&e.isConnectedTo(n,!1))return!0;let i=n.linkedTo();for(let t in i){if(i[t]==e)return!0;if(i[t].isConnectedTo(e,!1))return!0;if(e.isConnectedTo(i[t],!1))return!0}return!1},this.getLinksInNode=function(e){const t="yarn"===app.settings.documentType();let i=(e||n).body().match(t?/\[\[(.*?)\]\]/g:/\-\>(.*)/g);if(null!=i){let e={};for(let n=i.length-1;n>=0;n--)t?(i[n]=i[n].substr(2,i[n].length-4).trim(),i[n].indexOf("|")>=0&&(i[n]=i[n].split("|")[1]),null!=e[i[n]]&&i.splice(n,1),e[i[n]]=!0):i[n]=i[n].substr(2,i[n].length).trim();return i}},this.updateLinks=function(){n.resetDoubleClick(),n.updateLinksFromParents(),n.updateLinksToChildren()},this.updateLinksFromParents=function(){n.oldTitle&&n.oldTitle!==n.title()&&(n.linkedFrom.removeAll(),app.nodes().forEach(e=>{const t=n.getLinksInNode(e);if(t)if(t.includes(n.oldTitle)){const t=RegExp("\\|\\s*"+n.oldTitle+"\\s*\\]\\]","g"),i=RegExp("\\[\\[\\s*"+n.oldTitle+"\\s*\\]\\]","g");let o=e.body().replace(t,"|"+n.title()+"]]");o=o.replace(i,"[["+n.title()+"]]"),e.body(o),n.linkedFrom.push(e)}else t.includes(n.title())&&n.linkedFrom.push(e)}),n.oldTitle=void 0)},this.updateLinksToChildren=function(){n.linkedTo.removeAll();let e=n.getLinksInNode();if(e)for(let t in app.nodes()){let i=app.nodes()[t];for(let t=0;tfetch(e))).then(e=>Promise.all(e.map(e=>e.text()))).then(e=>{r.ink=e[0],r.yarn=e[1]});var l=function(t){const n=this,o=e=>(n.pluginStorage||(n.pluginStorage={}),n.pluginStorage[e]||(n.pluginStorage={...n.pluginStorage,[e]:{}}),this.pluginStorage[e]);window.addEventListener("yarnLoadedData",e=>{if(null!==t.data.documentHeader()){const e=t.data.documentHeader();"pluginStorage"in e&&(n.pluginStorage=e.pluginStorage)}}),window.addEventListener("newYarnFileStarted",e=>{n.pluginStorage={}});const s=t.data.db,l=()=>s.getDbValue("volatilePlugins"),d=e=>s.save("volatilePlugins",e),c=new URLSearchParams(window.location.href.split("?")[1]),p=c.get("gistPlugins"),u=c.get("pluginFile"),h=c.get("mode");this.rawUrls={};const g=()=>new Promise(e=>{const n=p||t.settings.gistPluginsFile();t.data.storage.getGist(n).then(({filesInGist:n})=>{const i=Object.values(n).filter(e=>"JavaScript"===e.language||e.filename.endsWith(".js")).map(e=>(this.rawUrls[e.filename]=e.raw_url,t.data.storage.getContentOrRaw(e.content,e.raw_url).then(t=>({...e,content:t}))));e(Promise.all(i))})}),f=(e=!1)=>new Promise(t=>l().then(n=>e?(console.log("---- fetching from gist files ----"),g().then(e=>{const i={};e.forEach(e=>{i[e.filename]=e}),t({...i,...n})}).catch(()=>t(n))):t(n))),m=e=>{try{const t=new Function("parameters","return "+e);if("function"==typeof t){const n=t();if(n){const t=e.indexOf("script:"),i=n()||{},o=e.substring(0,t).split("\n").length;return[{console:!1,...i,scriptStartLn:o},e]}}}catch(t){return console.log({e:t,fileContents:e}),[null,e,t]}return[null,e]},y={app:t,createButton:(e,{name:t,iconName:n,onClick:i,attachTo:o,className:s="item bbcode-button",title:a,onPointerDown:r,onDoubleClick:l,id:d,as:c="span",style:p=""})=>{const u=d||t||a||n;if(null!==document.getElementById(u))return void console.error(`Plugin button creation: Button with the id ${u} already exists. Skip creating it.`);const h=document.createElement(c);return h.id=u,h.innerHTML=`\n \n \n ${t||""}\n \n `,document.getElementById(o).appendChild(h),h},createToggle:(e,{id:t,attachTo:n,className:i,title:o,tooltipId:s,toggleValueKey:a,onToggle:r,enableKey:l,iconName:d,name:c})=>{const p=t||c||o||d;if(null!==document.getElementById(p))return void console.error(`Plugin button creation: Button with the id ${p} already exists. Skip creating it.`);const u=document.createElement("span");return u.id=p,u.className="styled-checkbox",u.innerHTML=`\n \n \n `,document.getElementById(n).appendChild(u),u},getPluginStore:o,setPluginStore:(e,t,i)=>{const s={...o(e),[t]:i};n.pluginStorage={...n.pluginStorage,[e]:s}},addSettingsItem:({title:n,valueKey:i,defaultValue:o,optionsKey:s,options:a,setterKey:r,settingsColumn:l})=>{t.settings[i]=e.observable(t.settings.storage.getItem(i)||o).extend({persist:i}),t.ui[s]=a,t[r]=function(e,n){const o=n?n.target.value:e;t.settings[i](o)},window.addEventListener("settingsOpened",()=>{const e=t.ui[s].map(e=>``).join(""),o=`\n \n
\n \n
\n `,a=document.createElement("div");a.className="settings-item",a.innerHTML=o,document.getElementById("settingsColumn"+(l||"A")).appendChild(a),document.getElementById("mySelect").addEventListener("change",e=>{t[r](!1,e)})})},onYarnLoadedData:e=>{window.addEventListener("yarnLoadedData",t=>{e(t)})},onYarnEditorOpen:e=>{window.addEventListener("yarnEditorOpen",t=>{e(t)})},onYarnInPreviewMode:e=>{window.addEventListener("yarnSavedNode",t=>{e(t)})},onYarnSavedNode:e=>{window.addEventListener("yarnInPreviewMode",t=>{e(t)})},onYarnSetLanguage:e=>{window.addEventListener("yarnSetLanguage",t=>{e(t)})},onYarnLoadedStateFromLocalStorage:e=>{window.addEventListener("yarnLoadedStateFromLocalStorage",t=>{e(t)})},onYarnSavedStateToLocalStorage:e=>{window.addEventListener("yarnSavedStateToLocalStorage",t=>{e(t)})},onYarnSetDocumentType:e=>{window.addEventListener("yarnSetDocumentType",t=>{e(t)})},onKeyUp:e=>{i(document).on("keyup",t=>{e(t)})},onKeyDown:e=>{i(document).on("keydown",t=>{e(t)})},onLoad:e=>{window.addEventListener("DOMContentLoaded",t=>{e(t)})},getVloatilePlugins:l,setVloatilePlugin:(e,t)=>l().then(n=>(n=n||{},s.save("volatilePlugins",{...n,[e]:{...n[e],...t}}))),setVloatilePlugins:d,getGistPluginFiles:g,getGistPluginFile:e=>{p||t.settings.gistPluginsFile();const n=this.rawUrls[e];return n?t.data.storage.getGistFileFromRawUrl(n):Promise.resolve("")},saveGistPlugin:(e,n)=>(console.log({gistId:t.settings.gistPluginsFile(),fileName:e,contents:n}),t.data.storage.editGist(t.settings.gistPluginsFile(),e,n).then(t=>(this.rawUrls[e]=t.file.raw_url,t))),isGistTokenInvalid:()=>t.data.storage.getIsTokenInvalid(),urlParams:c,updateUrlParams:(e,t)=>{const n=new URL(window.location.href);t?n.searchParams.set(e,t):n.searchParams.delete(e),window.history.replaceState(null,null,n)},gistPluginsFileUrl:u,pluginModeUrl:h,getPluginsList:f,deleteGistPlugin:e=>t.data.storage.deleteGistFile(p||t.settings.gistPluginsFile(),e),deleteVolatilePlugin:e=>l().then(t=>(e in t&&delete t[e],s.save("volatilePlugins",{...t}))),getExtensionScriptData:m,getPreviewHtml:(e,t,n={})=>{const i=(e.modules||[]).filter(e=>!e.includes("/")&&e in t&&t[e].content).map(e=>{try{const[n,i]=m(t[e].content);if(console.log(e,"----\x3e",{includeData:n}),n&&"script"in n){const t=n.script.toString();return{id:e,body:t.startsWith("function ")?""+t:((e=(()=>{}))=>{const t=e.toString();return e.toString().slice(t.indexOf("{")+1,t.lastIndexOf("}"))})(n.script)}}if(i)return{id:e,body:i}}catch(e){return!1}}).filter(Boolean),o=(e.modules||[]).filter(e=>e.includes("/"));return console.log({data:e,otherFiles:t,localModules:i,remoteModules:o}),`\n \n \n \n \n