fix: unmount application view when ephemeral identifier changes

This commit is contained in:
Mo
2022-02-04 12:00:03 -06:00
parent cc2169152e
commit b549cc38bf
23 changed files with 98 additions and 101 deletions

View File

@@ -1,2 +1,2 @@
document.addEventListener("DOMContentLoaded",(function(){const e=CodeMirror.modeInfo.reduce((function(e,t){return e[t.mode]?e[t.mode].push(t):e[t.mode]=[t],e}),{}),t=CodeMirror.modeInfo.reduce((function(e,t){return e[t.name]={mode:t.mode,mime:t.mime},e}),{}),n=Object.keys(t);let o,a,i,d,m,r,c,s=!1,u=!0;function l(){if(a){let e=a;o.saveItemWithPresave(e,(()=>{d=r.getValue(),e.content.text=d,e.clientData=i,e.content.preview_plain=null,e.content.preview_html=null}))}}function f(o){if(!o)return;const a=function(n){const o=function(e){return e?{name:e.name,mode:e.mode,mime:e.mime}:null},a=/.+\.([^.]+)$/.exec(n),i=/\//.test(n);if(a)return o(CodeMirror.findModeByExtension(a[1]));if(i)return o(CodeMirror.findModeByMIME(i[1]));if(t[n])return{name:n,mode:t[n].mode,mime:t[n].mime};if(e[n]){const t=e[n][0];return{name:t.name,mode:t.mode,mime:t.mime}}return{name:n,mode:n,mime:n}}(o);a?(r.setOption("mode",a.mime),CodeMirror.autoLoadMode(r,a.mode),i&&(i.mode=a.name),document.getElementById("language-select").selectedIndex=n.indexOf(a.name)):console.error("Could not find a mode corresponding to "+o)}function g(e){const t=document.getElementById("toggle-vim-mode-button"),n="vim"===e?"Disable":"Enable",o="vim"===e?"danger":"success";t.innerHTML=`${n} Vim mode`,t.classList.remove("danger"),t.classList.remove("success"),t.classList.add(o)}window.setKeyMap=function(e){r.setOption("keyMap",e)},window.onLanguageSelect=function(){f(n[c.selectedIndex]),l()},window.setDefaultLanguage=function(){const e=n[c.selectedIndex];o.setComponentDataValueForKey("language",e);const t=document.getElementById("default-label"),a=t.innerHTML;t.innerHTML="Success",t.classList.add("success"),setTimeout((function(){t.classList.remove("success"),t.innerHTML=a}),750)},window.toggleVimMode=function(){let e;e="default"===(o.getComponentDataValueForKey("keyMap")??"default")?"vim":"default",window.setKeyMap(e),o.setComponentDataValueForKey("keyMap",e),g(e)},CodeMirror.commands.save=function(){l()},r=CodeMirror.fromTextArea(document.getElementById("code"),{extraKeys:{"Alt-F":"findPersistent"},lineNumbers:!0,styleSelectedText:!0,lineWrapping:!0}),r.setSize("100%","100%"),setTimeout((function(){f("JavaScript")}),1),function(){c=document.getElementById("language-select");for(let e=0;e<n.length;e++){const t=document.createElement("option");t.value=e,t.innerHTML=n[e],c.appendChild(t)}}(),r.on("change",(function(){s||l()})),o=new ComponentRelay({targetWindow:window,onReady:()=>{const e=o.platform;e&&document.body.classList.add(e);const t=o.getComponentDataValueForKey("keyMap")??"default";window.setKeyMap(t),g(t)}}),o.streamContextItem((e=>{!function(e){if(e.uuid!==m&&(d=null,u=!0,m=e.uuid),a=e,e.isMetadataUpdate)return;i=e.clientData;f(i.mode||o.getComponentDataValueForKey("language")),r&&(e.content.text!==d&&(s=!0,r.getDoc().setValue(a.content.text),s=!1),u&&(u=!1,r.getDoc().clearHistory()))}(e)}))}));
document.addEventListener("DOMContentLoaded",(function(){const e=CodeMirror.modeInfo.reduce((function(e,t){return e[t.mode]?e[t.mode].push(t):e[t.mode]=[t],e}),{}),t=CodeMirror.modeInfo.reduce((function(e,t){return e[t.name]={mode:t.mode,mime:t.mime},e}),{}),n=Object.keys(t);let o,i,a,d,m,c,r;let s=!1,u=!0;function l(){if(i){let e=i;o.saveItemWithPresave(e,(()=>{d=c.getValue(),e.content.text=d,e.clientData=a,e.content.preview_plain=null,e.content.preview_html=null}))}}function f(o){if(!o)return;const i=function(n){const o=function(e){return e?{name:e.name,mode:e.mode,mime:e.mime}:null},i=/.+\.([^.]+)$/.exec(n),a=/\//.test(n);if(i)return o(CodeMirror.findModeByExtension(i[1]));if(a)return o(CodeMirror.findModeByMIME(a[1]));if(t[n])return{name:n,mode:t[n].mode,mime:t[n].mime};if(e[n]){const t=e[n][0];return{name:t.name,mode:t.mode,mime:t.mime}}return{name:n,mode:n,mime:n}}(o);i?(c.setOption("mode",i.mime),CodeMirror.autoLoadMode(c,i.mode),a&&(a.mode=i.name),document.getElementById("language-select").selectedIndex=n.indexOf(i.name)):console.error("Could not find a mode corresponding to "+o)}function g(e){const t=document.getElementById("toggle-vim-mode-button"),n="vim"===e?"Disable":"Enable",o="vim"===e?"danger":"success";t.innerHTML=`${n} Vim mode`,t.classList.remove("danger"),t.classList.remove("success"),t.classList.add(o)}window.setKeyMap=function(e){c.setOption("keyMap",e)},window.onLanguageSelect=function(){f(n[r.selectedIndex]),l()},window.setDefaultLanguage=function(){const e=n[r.selectedIndex];o.setComponentDataValueForKey("language",e);const t=document.getElementById("default-label"),i=t.innerHTML;t.innerHTML="Success",t.classList.add("success"),setTimeout((function(){t.classList.remove("success"),t.innerHTML=i}),750)},window.toggleVimMode=function(){let e;e="default"===(o.getComponentDataValueForKey("keyMap")??"default")?"vim":"default",window.setKeyMap(e),o.setComponentDataValueForKey("keyMap",e),g(e)},o=new ComponentRelay({targetWindow:window,onReady:()=>{const e=o.platform;e&&document.body.classList.add(e),CodeMirror.commands.save=function(){l()},c=CodeMirror.fromTextArea(document.getElementById("code"),{extraKeys:{"Alt-F":"findPersistent"},lineNumbers:!0,styleSelectedText:!0,lineWrapping:!0,inputStyle:"mobile"===(o.environment??"web")?"textarea":"contenteditable"}),c.setSize("100%","100%"),setTimeout((function(){f("JavaScript")}),1),function(){r=document.getElementById("language-select");for(let e=0;e<n.length;e++){const t=document.createElement("option");t.value=e,t.innerHTML=n[e],r.appendChild(t)}}(),c.on("change",(function(){s||l()}));const t=o.getComponentDataValueForKey("keyMap")??"default";window.setKeyMap(t),g(t)}}),o.streamContextItem((e=>{!function(e){if(e.uuid!==m&&(d=null,u=!0,m=e.uuid),i=e,e.isMetadataUpdate)return;a=e.clientData;f(a.mode||o.getComponentDataValueForKey("language")),c&&(e.content.text!==d&&(s=!0,c.getDoc().setValue(i.content.text),s=!1),u&&(u=!1,c.getDoc().clearHistory()),c.setOption("spellcheck",i.content.spellcheck))}(e)}))}));
//# sourceMappingURL=main.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,13 +1,13 @@
{
"name": "sn-code-editor",
"version": "1.3.9",
"version": "1.3.10",
"description": "A code editor for Standard Notes",
"main": "dist/main.js",
"author": "Standard Notes <hello@standardnotes.org>",
"license": "AGPL-3.0",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "http-server . --cors & webpack --progress --config webpack.dev.js",
"start": "http-server . --cors -p8001 & webpack --progress --config webpack.dev.js",
"build": "webpack --config webpack.prod.js",
"lint": "eslint src --ext .js",
"lint:fix": "yarn lint --fix"