initial commit
This commit is contained in:
commit
fbd12d4a8e
320 files changed
+124298
No files matched your search
+505
@@ -0,0 +1,505 @@
|
||||
/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
if you want to view the source, please visit the github repository of this plugin
|
||||
*/
|
||||
|
||||
var nr=Object.defineProperty,qa=Object.defineProperties,ja=Object.getOwnPropertyDescriptor,Za=Object.getOwnPropertyDescriptors,Xa=Object.getOwnPropertyNames,qi=Object.getOwnPropertySymbols;var ji=Object.prototype.hasOwnProperty,Wa=Object.prototype.propertyIsEnumerable;var pn=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t);var un=(t,e,r)=>e in t?nr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,oe=(t,e)=>{for(var r in e||(e={}))ji.call(e,r)&&un(t,r,e[r]);if(qi)for(var r of qi(e))Wa.call(e,r)&&un(t,r,e[r]);return t},ye=(t,e)=>qa(t,Za(e));var Va=(t,e)=>{for(var r in e)nr(t,r,{get:e[r],enumerable:!0})},Ia=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Xa(e))!ji.call(t,i)&&i!==r&&nr(t,i,{get:()=>e[i],enumerable:!(n=ja(e,i))||n.enumerable});return t};var Ma=t=>Ia(nr({},"__esModule",{value:!0}),t);var Zi=(t,e,r)=>(un(t,typeof e!="symbol"?e+"":e,r),r);var v=(t,e,r)=>new Promise((n,i)=>{var s=l=>{try{a(r.next(l))}catch(c){i(c)}},o=l=>{try{a(r.throw(l))}catch(c){i(c)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,o);a((r=r.apply(t,e)).next())}),Ga=function(t,e){this[0]=t,this[1]=e};var Xi=t=>{var e=t[pn("asyncIterator")],r=!1,n,i={};return e==null?(e=t[pn("iterator")](),n=s=>i[s]=o=>e[s](o)):(e=e.call(t),n=s=>i[s]=o=>{if(r){if(r=!1,s==="throw")throw o;return o}return r=!0,{done:!1,value:new Ga(new Promise(a=>{var l=e[s](o);if(!(l instanceof Object))throw TypeError("Object expected");a(l)}),1)}}),i[pn("iterator")]=()=>i,n("next"),"throw"in e?n("throw"):i.throw=s=>{throw s},"return"in e&&n("return"),i};var au={};Va(au,{default:()=>on});module.exports=Ma(au);var er=require("@codemirror/state"),ge=require("obsidian");var te=require("obsidian");var Ba=class extends Error{constructor(e){super(e[0].message);Zi(this,"issues");this.name="ValiError",this.issues=e}},cu=Symbol("brand");function Da(t){return typeof t=="function"?t():t}function at(t,e){return Array.isArray(t)?[void 0,t]:[t,e]}function ir(t,e,r){return{typed:t,output:e,issues:r}}function za(t,e,r){if(!t||typeof t=="object"&&!Array.isArray(t)){let[s,o]=at(e,r);return[t,s,o]}let[n,i]=at(t,e);return[void 0,n,i]}function La(t,e){return{reason:t==null?void 0:t.reason,validation:e.validation,origin:(t==null?void 0:t.origin)||"value",message:e.message,input:e.input,requirement:e==null?void 0:e.requirement,path:e.path,abortEarly:t==null?void 0:t.abortEarly,abortPipeEarly:t==null?void 0:t.abortPipeEarly,skipPipe:t==null?void 0:t.skipPipe}}function Ua(t,e){return{reason:e,origin:t==null?void 0:t.origin,abortEarly:t==null?void 0:t.abortEarly,abortPipeEarly:t==null?void 0:t.abortPipeEarly,skipPipe:t==null?void 0:t.skipPipe}}function _t(t,e,r,n,i){let s,o=t;if(e!=null&&e.length&&!(r!=null&&r.skipPipe))for(let a of e){let l=a._parse(o);if(l.issues){s=s||Ua(r,n);for(let c of l.issues){let p=La(s,c);i?i.push(p):i=[p]}if(s.abortEarly||s.abortPipeEarly)break}else o=l.output}return ir(!0,o,i)}function lt(t,e,r,n,i,s){return{typed:!1,output:i,issues:[{reason:e,validation:r,origin:(t==null?void 0:t.origin)||"value",message:Da(n),input:i,issues:s,abortEarly:t==null?void 0:t.abortEarly,abortPipeEarly:t==null?void 0:t.abortPipeEarly,skipPipe:t==null?void 0:t.skipPipe}]}}function Na(t){return typeof t.default=="function"?t.default():t.default}function Wi(t,e,r){let[n="Invalid type",i]=at(e,r);return{type:"instance",async:!1,class:t,message:n,pipe:i,_parse(s,o){return s instanceof this.class?_t(s,this.pipe,o,"instance"):lt(o,"type","instance",this.message,s)}}}function Vi(t,e){let[r="Invalid type",n]=at(t,e);return{type:"number",async:!1,message:r,pipe:n,_parse(i,s){return typeof i!="number"||isNaN(i)?lt(s,"type","number",this.message,i):_t(i,this.pipe,s,"number")}}}function Ii(t,e,r,n){let[i,s="Invalid type",o]=za(e,r,n),a;return{type:"object",async:!1,entries:t,rest:i,message:s,pipe:o,_parse(l,c){if(!l||typeof l!="object")return lt(c,"type","object",this.message,l);a=a||Object.entries(this.entries);let p=!0,u,d={};for(let[O,h]of a){let f=l[O],g=h._parse(f,c);if(g.issues){let b={type:"object",input:l,key:O,value:f};for(let y of g.issues)y.path?y.path.unshift(b):y.path=[b],u==null||u.push(y);if(u||(u=g.issues),c!=null&&c.abortEarly){p=!1;break}}g.typed||(p=!1),(g.output!==void 0||O in l)&&(d[O]=g.output)}if(this.rest&&!(c!=null&&c.abortEarly&&u)){for(let O in l)if(!(O in this.entries)){let h=l[O],f=this.rest._parse(h,c);if(f.issues){let g={type:"object",input:l,key:O,value:h};for(let b of f.issues)b.path?b.path.unshift(g):b.path=[g],u==null||u.push(b);if(u||(u=f.issues),c!=null&&c.abortEarly){p=!1;break}}f.typed||(p=!1),d[O]=f.output}}return p?_t(d,this.pipe,c,"object",u):ir(!1,d,u)}}}function ct(t,e){return{type:"optional",async:!1,wrapped:t,default:e,_parse(r,n){if(r===void 0){let i=Na(this);if(i===void 0)return ir(!0,r);r=i}return this.wrapped._parse(r,n)}}}function Xe(t,e){let[r="Invalid type",n]=at(t,e);return{type:"string",async:!1,message:r,pipe:n,_parse(i,s){return typeof i!="string"?lt(s,"type","string",this.message,i):_t(i,this.pLine truncated
|
||||
Erroring snippet:
|
||||
${lr(s)}`}})}catch(i){throw`Invalid snippet format: ${i}`}return n=pr(n),n})}function Li(t){return v(this,null,function*(){let e;try{e=yield import(t)}catch(r){throw`failed to import module ${t}`}if(!("default"in e))throw`No default export provided for module ${t}`;return e.default})}var cl=Ii({trigger:On([Xe(),Wi(RegExp)]),replacement:On([Xe(),Mi(t=>typeof t=="function")]),options:Xe(),flags:ct(Xe(),""),priority:ct(Vi(),0),description:ct(Xe(),"no description provided"),triggerKey:ct(Xe(),""),language:ct(Xe())});function pl(t){if(!Array.isArray(t))throw"Expected snippets to be an array";return t.flat().map(e=>{try{return Gi(cl,e)}catch(r){throw`Value does not resemble snippet.
|
||||
Erroring snippet:
|
||||
${lr(e)}`}})}function ul(t,e){let{replacement:r,priority:n,description:i}=t,s=cr.fromSource(t.options,t.language),o,a,l=gn(t.triggerKey);if(s.regex||t.trigger instanceof RegExp){let c,p=t.flags;t.trigger instanceof RegExp?(c=t.trigger.source,p=`${t.trigger.flags}${p}`):c=t.trigger,p=Ol(p),c=Ui(c,e),a=Ni(c),c=`(?:${c})$`,o=new RegExp(c,p),s.regex=!0;let u={trigger:o,replacement:r,options:s,priority:n,description:i,excludedEnvironments:a,triggerKey:l};return new or(u)}else{let c=t.trigger;c=Ui(c,e),a=Ni(c),typeof r=="string"&&r.includes(fn)&&(s.visual=!0);let p={trigger:c,replacement:r,options:s,priority:n,description:i,excludedEnvironments:a,triggerKey:l};return s.visual?new sr(p):new ar(p)}}function Ol(t){let e=["i","m","s","u","v"];return Array.from(new Set(t.split(""))).filter(r=>e.includes(r)).join("")}function Ui(t,e){for(let[r,n]of Object.entries(e))t=t.replaceAll(r,n);return t}function Ni(t){let e=[];return mn.hasOwnProperty(t)&&e.push(...mn[t]),e}function gn(t){return t.split(/ (?!$)/).map(e=>hl(e)).join(" ")}function hl(t){let e=t.split(/-(?!$)/),r=e[e.length-1];r==="Space"&&(r=" ");let n,i,s,o;for(let a=0;a<e.length-1;++a){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))Fi.Platform.isMacOS?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return n&&(r="Alt-"+r),i&&(r="Ctrl-"+r),o&&(r="Meta-"+r),s&&(r="Shift-"+r),r}var dl=(t,e)=>{let r=t.keys(),n=e.keys(),i=[];for(let s of r)e.has(s)||i.push(s);for(let s of n)t.has(s)||i.push(s);return new Set(i)},fl=(t,e)=>{let r=t.keys(),n=[];for(let i of r)e.has(i)&&n.push(i);return new Set(n)},Hi,ml=((Hi=Set.prototype)==null?void 0:Hi.difference)&&((t,e)=>t.difference(e)),Ki,gl=((Ki=Set.prototype)==null?void 0:Ki.intersection)&&((t,e)=>t.intersection(e)),bn=ml||dl,ur=gl||fl;function bl(t,e){let r=t.parent,n=0;for(;r&&!r.isRoot()&&n<100;){if(r.path===e.path)return!0;r=r.parent,n++}return!1}function Or(t,e,r){let n=t.app.vault.getAbstractFileByPath(e);return n instanceof te.TFolder&&bl(r,n)}var yn=(0,te.debounce)(t=>v(void 0,null,function*(){(t.settings.loadSnippetVariablesFromFile||t.settings.loadSnippetsFromFile)&&(yield t.processSettings(!1,!0))}),500,!0),es=(t,e)=>v(void 0,null,function*(){e instanceof te.TFile&&(t.settings.loadSnippetVariablesFromFile&&e.path===t.settings.snippetVariablesFileLocation||t.settings.loadSnippetsFromFile&&e.path===t.settings.snippetsFileLocation||Or(t,t.settings.snippetVariablesFileLocation,e)||Or(t,t.settings.snippetsFileLocation,e))&&yn(t)}),ts=(t,e)=>{e instanceof te.TFile&&(t.settings.loadSnippetVariablesFromFile&&Or(t,t.settings.snippetVariablesFileLocation,e)||t.settings.loadSnippetsFromFile&&Or(t,t.settings.snippetsFileLocation,e))&&yn(t)},rs=(t,e)=>{if(!(e instanceof te.TFile))return;let r=t.app.vault.getAbstractFileByPath(t.settings.snippetVariablesFileLocation),n=t.app.vault.getAbstractFileByPath(t.settings.snippetsFileLocation);(t.settings.loadSnippetVariablesFromFile&&r instanceof te.TFolder&&e.path.contains(r.path)||t.settings.loadSnippetsFromFile&&n instanceof te.TFolder&&e.path.contains(n.path))&&yn(t)};function*ns(t){if(t instanceof te.TFile)yield t;else if(t instanceof te.TFolder)for(let e of t.children)yield*Xi(ns(e))}function Ji(t,e){let r=t.getAbstractFileByPath(e);if(!r)return console.warn(`Could not find file or folder at path ${e}`),new Set;let n=ns(r);return new Set(n)}function is(t){let e=t.settings.loadSnippetVariablesFromFile?Ji(t.app.vault,t.settings.snippetVariablesFileLocation):new Set,r=t.settings.loadSnippetsFromFile?Ji(t.app.vault,t.settings.snippetsFileLocation):new Set,n=bn(e,r),i=bn(r,e),s=ur(e,r);return{definitelyVariableFiles:n,definitelySnippetFiles:i,snippetOrVariableFiles:s}}function ss(t,e){return v(this,null,function*(){let r={};for(let n of e.definitelyVariableFiles){let i=yield t.app.vault.cachedRead(n);try{Object.assign(r,yield ze(i))}catch(s){new te.Notice(`Failed to parse variable file ${n.name}: ${s}`),console.error(`Failed to parse variable file ${n.name}: ${s}`),e.definitelyVariableFiles.delete(n)}}return r})}function os(t,e){return v(this,null,function*(){let r={};for(let n of e.snippetOrVariableFiles){let i=yield t.app.vault.cachedRead(n);try{Object.assign(r,yield ze(i)),e.definitelyVariableFiles.add(n)}catch(s){e.definitelySnippetFiles.add(n)}e.snippetOrVariableFiles.delete(n)}return r})}function as(t,e,r){return v(this,null,function*(){let n=[];for(let i of e.definitelySnippetFiles){let s=yield t.app.vault.cachedRead(i);try{n.push(...yield ut(s,r))}catch(o){new te.Notice(`Failed to parse snippet file ${i.name}: ${o}`),console.error(`Failed to parse snippet file ${i.name}: ${o}`),e.definitelySnippetFiles.delete(i)}}return pr(n)})}var ls=`export default [
|
||||
// Math mode
|
||||
{trigger: "mk", replacement: "$$0$", options: "tA"},
|
||||
{trigger: "dm", replacement: "$$\\n\\t$0\\n$$", options: "tAw"},
|
||||
{trigger: /(?<=\\S.*)dm/, replacement: "\\n$$\\n\\t$0\\n$$", options: "tAw", priority: 1},
|
||||
|
||||
{trigger: /([^\\\\])beg/, replacement: "[[0]]\\\\begin{$0}\\n\\t$1\\n\\\\end{$0}", options: "MA"},
|
||||
{trigger: /([^\\\\])beg/, replacement: "[[0]]\\\\begin{$0} $1 \\\\end{$0}", options: "nA"},
|
||||
|
||||
// Dashes
|
||||
// {trigger: "--", replacement: "\u2013", options: "tA"},
|
||||
// {trigger: "\u2013-", replacement: "\u2014", options: "tA"},
|
||||
// {trigger: "\u2014-", replacement: "---", options: "tA"},
|
||||
|
||||
// Greek letters
|
||||
{trigger: "@a", replacement: "\\\\alpha", options: "mA"},
|
||||
{trigger: "@b", replacement: "\\\\beta", options: "mA"},
|
||||
{trigger: "@g", replacement: "\\\\gamma", options: "mA"},
|
||||
{trigger: "@G", replacement: "\\\\Gamma", options: "mA"},
|
||||
{trigger: "@d", replacement: "\\\\delta", options: "mA"},
|
||||
{trigger: "@D", replacement: "\\\\Delta", options: "mA"},
|
||||
{trigger: "@e", replacement: "\\\\epsilon", options: "mA"},
|
||||
{trigger: ":e", replacement: "\\\\varepsilon", options: "mA"},
|
||||
{trigger: "@z", replacement: "\\\\zeta", options: "mA"},
|
||||
{trigger: "@t", replacement: "\\\\theta", options: "mA"},
|
||||
{trigger: "@T", replacement: "\\\\Theta", options: "mA"},
|
||||
{trigger: ":t", replacement: "\\\\vartheta", options: "mA"},
|
||||
{trigger: "@i", replacement: "\\\\iota", options: "mA"},
|
||||
{trigger: "@k", replacement: "\\\\kappa", options: "mA"},
|
||||
{trigger: "@l", replacement: "\\\\lambda", options: "mA"},
|
||||
{trigger: "@L", replacement: "\\\\Lambda", options: "mA"},
|
||||
{trigger: "@s", replacement: "\\\\sigma", options: "mA"},
|
||||
{trigger: "@S", replacement: "\\\\Sigma", options: "mA"},
|
||||
{trigger: "@u", replacement: "\\\\upsilon", options: "mA"},
|
||||
{trigger: "@U", replacement: "\\\\Upsilon", options: "mA"},
|
||||
{trigger: "@o", replacement: "\\\\omega", options: "mA"},
|
||||
{trigger: "@O", replacement: "\\\\Omega", options: "mA"},
|
||||
{trigger: "ome", replacement: "\\\\omega", options: "mA"},
|
||||
{trigger: "Ome", replacement: "\\\\Omega", options: "mA"},
|
||||
|
||||
// Text environment
|
||||
{trigger: "text", replacement: "\\\\text{$0}$1", options: "mA"},
|
||||
{trigger: "\\"", replacement: "\\\\text{$0}$1", options: "mA"},
|
||||
|
||||
// Basic operations
|
||||
{trigger: "sr", replacement: "^{2}", options: "mA"},
|
||||
{trigger: "cb", replacement: "^{3}", options: "mA"},
|
||||
{trigger: "rd", replacement: "^{$0}$1", options: "mA"},
|
||||
{trigger: "_", replacement: "_{$0}$1", options: "mA"},
|
||||
{trigger: "sts", replacement: "_\\\\text{$0}", options: "mA"},
|
||||
{trigger: "sq", replacement: "\\\\sqrt{ $0 }$1", options: "mA"},
|
||||
{trigger: "//", replacement: "\\\\frac{$0}{$1}$2", options: "mA"},
|
||||
{trigger: "ee", replacement: "e^{ $0 }$1", options: "mA"},
|
||||
{trigger: "invs", replacement: "^{-1}", options: "mA"},
|
||||
|
||||
{trigger: /([^\\\\])(exp|log|ln)/, replacement: "[[0]]\\\\[[1]]", options: "rmA"},
|
||||
{trigger: "conj", replacement: "^{*}", options: "mA"},
|
||||
{trigger: "Re", replacement: "\\\\mathrm{Re}", options: "mA"},
|
||||
{trigger: "Im", replacement: "\\\\mathrm{Im}", options: "mA"},
|
||||
{trigger: "bf", replacement: "\\\\mathbf{$0}", options: "mA"},
|
||||
{trigger: "rm", replacement: "\\\\mathrm{$0}$1", options: "mA"},
|
||||
|
||||
// Linear algebra
|
||||
{trigger: /([^\\\\])(det)/, replacement: "[[0]]\\\\[[1]]", options: "rmA"},
|
||||
{trigger: "trace", replacement: "\\\\mathrm{Tr}", options: "mA"},
|
||||
|
||||
// More operations
|
||||
{trigger: "([a-zA-Z])hat", replacement: "\\\\hat{[[0]]}", options: "rmA"},
|
||||
{trigger: "([a-zA-Z])bar", replacement: "\\\\bar{[[0]]}", options: "rmA"},
|
||||
{trigger: "([a-zA-Z])dot", replacement: "\\\\dot{[[0]]}", options: "rmA", priority: -1},
|
||||
{trigger: "([a-zA-Z])ddot", replacement: "\\\\ddot{[[0]]}", options: "rmA", priority: 1},
|
||||
{trigger: "([a-zA-Z])tilde", replacement: "\\\\tilde{[[0]]}", options: "rmA"},
|
||||
{trigger: "([a-zA-Z])und", replacement: "\\\\underline{[[0]]}", options: "rmA"},
|
||||
{trigger: "([a-zA-Z])vec", replacement: "\\\\vec{[[0]]}", options: "rmA"},
|
||||
{trigger: "([a-zA-Z]),\\\\.", replacement: "\\\\mathbf{[[0]]}", options: "rmA"},
|
||||
{trigger: "([a-zA-Z])\\\\.,", replacement: "\\\\mathbf{[[0]]}", options: "rmA"},
|
||||
{trigger: "\\\\\\\\(\${GREEK}),\\\\.", replacement: "\\\\boldsymbol{\\\\[[0]]}", options: "rmA"},
|
||||
{trigger: "\\\\\\\\(\${GREEK})\\\\.,", replacement: "\\\\boldsymbol{\\\\[[0]]}", options: "rmA"},
|
||||
|
||||
{trigger: "hat", replacement: "\\\\hat{$0}$1", options: "mA"},
|
||||
{trigger: "bar", replacement: "\\\\bar{$0}$1", options: "mA"},
|
||||
{trigger: "dot", replacement: "\\\\dot{$0}$1", options: "mA", priority: -1},
|
||||
{trigger: "ddot", replacement: "\\\\ddot{$0}$1", options: "mA"},
|
||||
{trigger: "cdot", replacement: "\\\\cdot", options: "mA"},
|
||||
{trigger: "tilde", replacement: "\\\\tilde{$0}$1", options: "mA"},
|
||||
{trigger: "und", replacement: "\\\\underline{$0}$1", options: "mA"},
|
||||
{trigger: "vec", replacement: "\\\\vec{$0}$1", options: "mA"},
|
||||
{
|
||||
trigger: "pmod",
|
||||
replacement: "\\\\pmod{\${0:n}}$1",
|
||||
options: "mA",
|
||||
description: "Parenthesized modulo (\\\\pmod{n})",
|
||||
},
|
||||
|
||||
// Auto letter subscript
|
||||
//
|
||||
// x3 -> x_{3}, \\alpha3 -> \\alpha_{3}
|
||||
{
|
||||
trigger: "(\\\\\\\\\${GREEK}|[A-Za-z])(\\\\d)",
|
||||
replacement: "[[0]]_{[[1]]}",
|
||||
options: "rmA",
|
||||
priority: -1,
|
||||
},
|
||||
// x_{3}4 -> x_{34}, \\alpha_{3}4 -> \\alpha_{34}
|
||||
{
|
||||
trigger: "(\\\\\\\\\${GREEK}|[A-Za-z])_{(\\\\d+)}(\\\\d)",
|
||||
replacement: "[[0]]_{[[1]][[2]]}",
|
||||
options: "rmA",
|
||||
priority: -1,
|
||||
},
|
||||
|
||||
// \\dot{x}3 -> \\dot{x}_{3}, \\dot{\\alpha}3 -> \\dot{\\alpha}_{3}
|
||||
{
|
||||
trigger: "\\\\\\\\(\${ACCENT})\\\\{(\\\\\\\\\${GREEK}|[A-Za-z])\\\\}(\\\\d)",
|
||||
replacement: "\\\\[[0]]{[[1]]}_{[[2]]}",
|
||||
options: "rmA",
|
||||
priority: -1,
|
||||
},
|
||||
|
||||
// \\dot{x}_{3}4 -> \\dot{x}_{34}
|
||||
{
|
||||
trigger: "\\\\\\\\(\${ACCENT})\\\\{(\\\\\\\\\${GREEK}|[A-Za-z])\\\\}_\\\\{(\\\\d+)\\\\}(\\\\d)",
|
||||
replacement: "\\\\[[0]]{[[1]]}_{[[2]][[3]]}",
|
||||
options: "rmA",
|
||||
priority: -1,
|
||||
},
|
||||
// \\dot{\\vec{a}}3 -> \\dot{\\vec{a}}_{3}
|
||||
{
|
||||
trigger: "\\\\\\\\(\${ACCENT})\\\\{\\\\\\\\(\${ACCENT})\\\\{(\\\\\\\\\${GREEK}|[A-Za-z])\\\\}\\\\}(\\\\d)",
|
||||
replacement: "\\\\[[0]]{\\\\[[1]]{[[2]]}}_{[[3]]}",
|
||||
options: "rmA",
|
||||
priority: -1,
|
||||
},
|
||||
// \\dot{\\vec{a}}_{3}4 -> \\dot{\\vec{a}}_{34}
|
||||
{
|
||||
trigger: "\\\\\\\\(\${ACCENT})\\\\{\\\\\\\\(\${ACCENT})\\\\{(\\\\\\\\\${GREEK}|[A-Za-z])\\\\}\\\\}_\\\\{(\\\\d+)\\\\}(\\\\d)",
|
||||
replacement: "\\\\[[0]]{\\\\[[1]]{[[2]]}}_{[[3]][[4]]}",
|
||||
options: "rmA",
|
||||
priority: -1,
|
||||
},
|
||||
|
||||
{trigger: "xnn", replacement: "x_{n}", options: "mA"},
|
||||
{trigger: "\\\\xii", replacement: "x_{i}", options: "mA", priority: 1},
|
||||
{trigger: "xjj", replacement: "x_{j}", options: "mA"},
|
||||
{trigger: "xp1", replacement: "x_{n+1}", options: "mA"},
|
||||
{trigger: "ynn", replacement: "y_{n}", options: "mA"},
|
||||
{trigger: "yii", replacement: "y_{i}", options: "mA"},
|
||||
{trigger: "yjj", replacement: "y_{j}", options: "mA"},
|
||||
|
||||
// Symbols
|
||||
{trigger: "ooo", replacement: "\\\\infty", options: "mA"},
|
||||
{trigger: "sum", replacement: "\\\\sum", options: "mA"},
|
||||
{trigger: "prod", replacement: "\\\\prod", options: "mA"},
|
||||
{trigger: "\\\\sum", replacement: "\\\\sum_{\${0:i}=\${1:1}}^{\${2:N}} $3", options: "m"},
|
||||
{trigger: "\\\\prod", replacement: "\\\\prod_{\${0:i}=\${1:1}}^{\${2:N}} $3", options: "m"},
|
||||
{trigger: "lim", replacement: "\\\\lim_{ \${0:n} \\\\to \${1:\\\\infty} } $2", options: "mA"},
|
||||
{trigger: "+-", replacement: "\\\\pm", options: "mA"},
|
||||
{trigger: "-+", replacement: "\\\\mp", options: "mA"},
|
||||
{trigger: "...", replacement: "\\\\dots", options: "mA"},
|
||||
{trigger: "nabl", replacement: "\\\\nabla", options: "mA"},
|
||||
// The operator nabla is also called del, but using "del" as a trigger conflicts with the greek letter delta.
|
||||
// {trigger: "del", replacement: "\\\\nabla", options: "mA"},
|
||||
{trigger: "xx", replacement: "\\\\times", options: "mA"},
|
||||
{trigger: "**", replacement: "\\\\cdot", options: "mA"},
|
||||
{trigger: "para", replacement: "\\\\parallel", options: "mA"},
|
||||
|
||||
{trigger: "===", replacement: "\\\\equiv", options: "mA"},
|
||||
{trigger: "!=", replacement: "\\\\neq", options: "mA"},
|
||||
{trigger: ">=", replacement: "\\\\geq", options: "mA"},
|
||||
{trigger: "<=", replacement: "\\\\leq", options: "mA"},
|
||||
{trigger: ">>", replacement: "\\\\gg", options: "mA"},
|
||||
{trigger: "<<", replacement: "\\\\ll", options: "mA"},
|
||||
{trigger: "simm", replacement: "\\\\sim", options: "mA"},
|
||||
{trigger: "sim=", replacement: "\\\\simeq", options: "mA"},
|
||||
{trigger: "prop", replacement: "\\\\propto", options: "mA"},
|
||||
|
||||
|
||||
{trigger: "<->", replacement: "\\\\leftrightarrow ", options: "mA"},
|
||||
{trigger: "->", replacement: "\\\\to", options: "mA"},
|
||||
{trigger: "!>", replacement: "\\\\mapsto", options: "mA"},
|
||||
{trigger: "=>", replacement: "\\\\implies", options: "mA"},
|
||||
{trigger: "=<", replacement: "\\\\impliedby", options: "mA"},
|
||||
|
||||
{trigger: "and", replacement: "\\\\cap", options: "mA"},
|
||||
{trigger: "orr", replacement: "\\\\cup", options: "mA"},
|
||||
{trigger: "inn", replacement: "\\\\in", options: "mA"},
|
||||
{trigger: "notin", replacement: "\\\\not\\\\in", options: "mA"},
|
||||
{trigger: "\\\\\\\\\\\\", replacement: "\\\\setminus", options: "mA"},
|
||||
{trigger: "sub=", replacement: "\\\\subseteq", options: "mA"},
|
||||
{trigger: "sup=", replacement: "\\\\supseteq", options: "mA"},
|
||||
{trigger: "eset", replacement: "\\\\emptyset", options: "mA"},
|
||||
{trigger: "set", replacement: "\\\\{ $0 \\\\}$1", options: "mA"},
|
||||
{trigger: "e\\\\xi sts", replacement: "\\\\exists", options: "mA", priority: 1},
|
||||
|
||||
{trigger: "LL", replacement: "\\\\mathcal{L}", options: "mA"},
|
||||
{trigger: "HH", replacement: "\\\\mathcal{H}", options: "mA"},
|
||||
{trigger: "CC", replacement: "\\\\mathbb{C}", options: "mA"},
|
||||
{trigger: "RR", replacement: "\\\\mathbb{R}", options: "mA"},
|
||||
{trigger: "ZZ", replacement: "\\\\mathbb{Z}", options: "mA"},
|
||||
{trigger: "NN", replacement: "\\\\mathbb{N}", options: "mA"},
|
||||
|
||||
// Handle spaces and backslashes
|
||||
|
||||
// Snippet variables can be used as shortcuts when writing snippets.
|
||||
// For example, \${GREEK} below is shorthand for "alpha|beta|gamma|Gamma|delta|..."
|
||||
// You can edit snippet variables under the Advanced snippet settings section.
|
||||
|
||||
{trigger: "([^\\\\\\\\])(\${GREEK})", replacement: "[[0]]\\\\[[1]]", options: "rmA", description: "Add backslash before Greek letters"},
|
||||
{trigger: "([^\\\\\\\\])(\${SYMBOL})", replacement: "[[0]]\\\\[[1]]", options: "rmA", description: "Add backslash before symbols"},
|
||||
|
||||
// Insert space after Greek letters and symbols
|
||||
{trigger: "\\\\\\\\(\${GREEK}|\${SYMBOL}|\${MORE_SYMBOLS})([A-Za-z])", replacement: "\\\\[[0]] [[1]]", options: "rmA"},
|
||||
{trigger: "\\\\\\\\(\${GREEK}|\${SYMBOL}) sr", replacement: "\\\\[[0]]^{2}", options: "rmA"},
|
||||
{trigger: "\\\\\\\\(\${GREEK}|\${SYMBOL}) cb", replacement: "\\\\[[0]]^{3}", options: "rmA"},
|
||||
{trigger: "\\\\\\\\(\${GREEK}|\${SYMBOL}) rd", replacement: "\\\\[[0]]^{$0}$1", options: "rmA"},
|
||||
{trigger: "\\\\\\\\(\${GREEK}) hat", replacement: "\\\\hat{\\\\[[0]]}", options: "rmA"},
|
||||
{trigger: "\\\\\\\\(\${GREEK}) dot", replacement: "\\\\dot{\\\\[[0]]}", options: "rmA"},
|
||||
{trigger: "\\\\\\\\(\${GREEK}) bar", replacement: "\\\\bar{\\\\[[0]]}", options: "rmA"},
|
||||
{trigger: "\\\\\\\\(\${GREEK}) vec", replacement: "\\\\vec{\\\\[[0]]}", options: "rmA"},
|
||||
{trigger: "\\\\\\\\(\${GREEK}) tilde", replacement: "\\\\tilde{\\\\[[0]]}", options: "rmA"},
|
||||
{trigger: "\\\\\\\\(\${GREEK}) und", replacement: "\\\\underline{\\\\[[0]]}", options: "rmA"},
|
||||
|
||||
|
||||
// Derivatives and integrals
|
||||
{trigger: "par", replacement: "\\\\frac{ \\\\partial \${0:y} }{ \\\\partial \${1:x} } $2", options: "m"},
|
||||
{trigger: /pa([A-Za-z])([A-Za-z])/, replacement: "\\\\frac{ \\\\partial [[0]] }{ \\\\partial [[1]] } ", options: "rm"},
|
||||
{trigger: "ddt", replacement: "\\\\frac{d}{dt} ", options: "mA"},
|
||||
|
||||
{trigger: /([^\\\\])int/, replacement: "[[0]]\\\\int", options: "mA", priority: -1},
|
||||
{trigger: "\\\\int", replacement: "\\\\int $0 \\\\, d\${1:x} $2", options: "m"},
|
||||
{trigger: "dint", replacement: "\\\\int_{\${0:0}}^{\${1:1}} $2 \\\\, d\${3:x} $4", options: "mA"},
|
||||
{trigger: "oint", replacement: "\\\\oint", options: "mA"},
|
||||
{trigger: "iint", replacement: "\\\\iint", options: "mA"},
|
||||
{trigger: "iiint", replacement: "\\\\iiint", options: "mA"},
|
||||
{trigger: "oinf", replacement: "\\\\int_{0}^{\\\\infty} $0 \\\\, d\${1:x} $2", options: "mA"},
|
||||
{trigger: "infi", replacement: "\\\\int_{-\\\\infty}^{\\\\infty} $0 \\\\, d\${1:x} $2", options: "mA"},
|
||||
|
||||
|
||||
// Trigonometry
|
||||
{trigger: /([^\\\\])(arcsin|sin|arccos|cos|arctan|tan|csc|sec|cot)/, replacement: "[[0]]\\\\[[1]]", options: "rmA", description: "Add backslash before trig funcs"},
|
||||
|
||||
{trigger: /\\\\(arcsin|sin|arccos|cos|arctan|tan|csc|sec|cot)([A-Za-gi-z])/,
|
||||
replacement: "\\\\[[0]] [[1]]", options: "rmA",
|
||||
description: "Add space after trig funcs. Skips letter h to allow sinh, cosh, etc."},
|
||||
|
||||
{trigger: /\\\\(sinh|cosh|tanh|coth)([A-Za-z])/,
|
||||
replacement: "\\\\[[0]] [[1]]", options: "rmA",
|
||||
description: "Add space after hyperbolic trig funcs"},
|
||||
|
||||
{
|
||||
trigger: /(arccsc|arcsec|arccot)/,
|
||||
replacement: "\\\\operatorname{[[0]]}$0",
|
||||
options: "mA",
|
||||
description: "Inverse trig functions, Are not built-in MathJax functions",
|
||||
priority: 1,
|
||||
},
|
||||
|
||||
// Visual operations
|
||||
{trigger: "U", replacement: "\\\\underbrace{ \${VISUAL} }_{ $0 }", options: "mA"},
|
||||
{trigger: "O", replacement: "\\\\overbrace{ \${VISUAL} }^{ $0 }", options: "mA"},
|
||||
{trigger: "B", replacement: "\\\\underset{ $0 }{ \${VISUAL} }", options: "mA"},
|
||||
{trigger: "C", replacement: "\\\\cancel{ \${VISUAL} }", options: "mA"},
|
||||
{trigger: "K", replacement: "\\\\cancelto{ $0 }{ \${VISUAL} }", options: "mA"},
|
||||
{trigger: "S", replacement: "\\\\sqrt{ \${VISUAL} }", options: "mA"},
|
||||
|
||||
|
||||
// Physics
|
||||
{trigger: "kbt", replacement: "k_{B}T", options: "mA"},
|
||||
{trigger: "msun", replacement: "M_{\\\\odot}", options: "mA"},
|
||||
|
||||
// Quantum mechanics
|
||||
{trigger: "dag", replacement: "^{\\\\dagger}", options: "mA"},
|
||||
{trigger: "o+", replacement: "\\\\oplus ", options: "mA"},
|
||||
{trigger: "ox", replacement: "\\\\otimes ", options: "mA"},
|
||||
{trigger: "bra", replacement: "\\\\bra{$0} $1", options: "mA"},
|
||||
{trigger: "ket", replacement: "\\\\ket{$0} $1", options: "mA"},
|
||||
{trigger: "brk", replacement: "\\\\braket{ $0 | $1 } $2", options: "mA"},
|
||||
{trigger: "outer", replacement: "\\\\ket{\${0:\\\\psi}} \\\\bra{\${0:\\\\psi}} $1", options: "mA"},
|
||||
|
||||
// Chemistry
|
||||
{trigger: "pu", replacement: "\\\\pu{ $0 }", options: "mA"},
|
||||
{trigger: "cee", replacement: "\\\\ce{ $0 }", options: "mA"},
|
||||
{trigger: "he4", replacement: "{}^{4}_{2}He ", options: "mA"},
|
||||
{trigger: "he3", replacement: "{}^{3}_{2}He ", options: "mA"},
|
||||
{trigger: "iso", replacement: "{}^{\${0:4}}_{\${1:2}}\${2:He}", options: "mA"},
|
||||
|
||||
|
||||
// Environments
|
||||
// Here the regex syntax [pbBvV]mat is used to match pmat, bmat, Bmat, vmat, Vmat
|
||||
{
|
||||
trigger: /([pbBvV]mat)/,
|
||||
replacement: "\\\\begin{[[0]]rix}\\n$0\\n\\\\end{[[0]]rix}",
|
||||
options: "rMA",
|
||||
description: "Matrix environments with new lines",
|
||||
},
|
||||
{
|
||||
trigger: /(matrix|cases|align|array)/,
|
||||
replacement: "\\\\begin{[[0]]}\\n$0\\n\\\\end{[[0]]}",
|
||||
options: "rMA",
|
||||
description: "Miscellaneous environments with new lines",
|
||||
},
|
||||
{
|
||||
trigger: /([pbBvV]mat)/,
|
||||
replacement: "\\\\begin{[[0]]rix}$0\\\\end{[[0]]rix}",
|
||||
options: "rnA",
|
||||
},
|
||||
{
|
||||
trigger: /(matrix|cases|align|array)/,
|
||||
replacement: "\\\\begin{[[0]]}$0\\\\end{[[0]]}",
|
||||
options: "rnA",
|
||||
},
|
||||
|
||||
// Brackets
|
||||
{trigger: "avg", replacement: "\\\\langle $0 \\\\rangle $1", options: "mA"},
|
||||
{trigger: "norm", replacement: "\\\\lvert $0 \\\\rvert $1", options: "mA", priority: 1},
|
||||
{trigger: "Norm", replacement: "\\\\lVert $0 \\\\rVert $1", options: "mA", priority: 1},
|
||||
{trigger: "ceil", replacement: "\\\\lceil $0 \\\\rceil $1", options: "mA"},
|
||||
{trigger: "floor", replacement: "\\\\lfloor $0 \\\\rfloor $1", options: "mA"},
|
||||
// For the modulo operator, see the section "More operations" above
|
||||
{trigger: "mod", replacement: "|$0|$1", options: "mA"},
|
||||
{trigger: "(", replacement: "(\${VISUAL})", options: "mA"},
|
||||
{trigger: "[", replacement: "[\${VISUAL}]", options: "mA"},
|
||||
{trigger: "{", replacement: "{\${VISUAL}}", options: "mA"},
|
||||
{trigger: "(", replacement: "($0)$1", options: "mA"},
|
||||
{trigger: "{", replacement: "{$0}$1", options: "mA"},
|
||||
{trigger: "[", replacement: "[$0]$1", options: "mA"},
|
||||
{trigger: "lr(", replacement: "\\\\left( $0 \\\\right) $1", options: "mA"},
|
||||
{trigger: "lr{", replacement: "\\\\left\\\\{ $0 \\\\right\\\\} $1", options: "mA"},
|
||||
{trigger: "lr[", replacement: "\\\\left[ $0 \\\\right] $1", options: "mA"},
|
||||
{trigger: "lr|", replacement: "\\\\left| $0 \\\\right| $1", options: "mA"},
|
||||
{trigger: "lra", replacement: "\\\\left< $0 \\\\right> $1", options: "mA"},
|
||||
|
||||
|
||||
// Misc
|
||||
|
||||
// Automatically convert standalone letters in text to math (except a, A, I).
|
||||
// (Un-comment to enable)
|
||||
// {trigger: /([^'])\\b([B-HJ-Zb-z])\\b([\\n\\s.,?!:'])/, replacement: "[[0]]$[[1]]$[[2]]", options: "tA"},
|
||||
|
||||
// Automatically convert Greek letters in text to math.
|
||||
// {trigger: "(\${GREEK})([\\\\n\\\\s.,?!:'])", replacement: "$\\\\[[0]]$[[1]]", options: "rtAw"},
|
||||
|
||||
// Automatically convert text of the form "x=2" and "x=n+1" to math.
|
||||
// {trigger: /([A-Za-z]=\\d+)([\\n\\s.,?!:'])/, replacement: "$[[0]]$[[1]]", options: "rtAw"},
|
||||
// {trigger: /([A-Za-z]=[A-Za-z][+-]\\d+)([\\n\\s.,?!:'])/, replacement: "$[[0]]$[[1]]", options: "tAw"},
|
||||
|
||||
|
||||
// Snippet replacements can have placeholders.
|
||||
{trigger: "tayl", replacement: "\${0:f}(\${1:x} + \${2:h}) = \${0:f}(\${1:x}) + \${0:f}'(\${1:x})\${2:h} + \${0:f}''(\${1:x}) \\\\frac{\${2:h}^{2}}{2!} + \\\\dots$3", options: "mA", description: "Taylor expansion"},
|
||||
|
||||
// Snippet replacements can also be JavaScript functions.
|
||||
// See the documentation for more information.
|
||||
{trigger: /iden(\\d)/, replacement: (match) => {
|
||||
const n = match[1];
|
||||
|
||||
let arr = [];
|
||||
for (let j = 0; j < n; j++) {
|
||||
arr[j] = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
arr[j][i] = (i === j) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
let output = arr.map(el => el.join(" & ")).join(" \\\\\\\\\\n");
|
||||
output = \`\\\\begin{pmatrix}\\n\${output}\\n\\\\end{pmatrix}\`;
|
||||
return output;
|
||||
}, options: "mA", description: "N x N identity matrix"},
|
||||
{
|
||||
trigger: /(?<=(?:\\n|^)[ \\t]*>*)(?<marker>\\d+[.)]|[-*+])(?<whitespace>[ \\t]+)(?<text>.*)dm/,
|
||||
replacement: (m) => {
|
||||
const { whitespace, text, marker } = m.groups;
|
||||
const firstLine = marker + whitespace + text;
|
||||
const indent = " ".repeat(marker.length) + whitespace;
|
||||
return \`\${firstLine}\\n\${indent}$$\\n\${indent}\\t$0\\n\${indent}$$\`;
|
||||
},
|
||||
options: "rtA",
|
||||
priority: 2,
|
||||
description: "Display math when in a list"
|
||||
},
|
||||
]
|
||||
`;var At=ls;var cs=`export default {
|
||||
"\${GREEK}": "(?:alpha|beta|gamma|Gamma|delta|Delta|epsilon|varepsilon|zeta|eta|theta|vartheta|Theta|iota|kappa|lambda|Lambda|mu|nu|xi|omicron|pi|rho|varrho|sigma|Sigma|tau|upsilon|Upsilon|phi|varphi|Phi|chi|psi|omega|Omega)",
|
||||
"\${SYMBOL}": "(?:parallel|perp|partial|nabla|hbar|ell|infty|oplus|ominus|otimes|oslash|square|star|dagger|vee|wedge|subseteq|subset|supseteq|supset|emptyset|exists|nexists|forall|implies|impliedby|iff|setminus|neg|lor|land|bigcup|bigcap|cdot|times|simeq|approx)",
|
||||
"\${MORE_SYMBOLS}": "(?:leq|geq|neq|gg|ll|equiv|sim|propto|rightarrow|leftarrow|Rightarrow|Leftarrow|leftrightarrow|to|mapsto|cap|cup|in|sum|prod|exp|ln|log|det|dots|vdots|ddots|pm|mp|int|iint|iiint|oint)",
|
||||
"\${ACCENT}": "(?:dot|ddot|hat|bar|tilde|vec|underline|overline|mathbf|mathcal|mathrm|mathbb)",
|
||||
}
|
||||
`;var ps=cs;var W={snippets:At,snippetVariables:ps,snippetsEnabled:!0,snippetsTrigger:"Tab",snippetNextTabstopTrigger:"Tab",snippetPreviousTabstopTrigger:"Shift-Tab",suppressSnippetTriggerOnIME:!0,suppressIMEWarning:!1,removeSnippetWhitespace:!0,autoDelete$:!0,loadSnippetsFromFile:!1,loadSnippetVariablesFromFile:!1,snippetsFileLocation:"",snippetVariablesFileLocation:"",concealEnabled:!1,concealRevealTimeout:0,colorPairedBracketsEnabled:!0,highlightCursorBracketsEnabled:!0,mathPreviewEnabled:!0,mathPreviewPositionIsAbove:!0,mathPreviewCursor:"\u25B6",mathPreviewBracketHighlighting:!1,autofractionEnabled:!0,autofractionSymbol:"\\frac",autofractionBreakingChars:"+-= ",matrixShortcutsEnabled:!0,taboutEnabled:!0,taboutTrigger:"Tab",autoEnlargeBrackets:!0,wordDelimiters:"., +-\\n :;!?\\/{}[]()=~$'\"|`<>*^%#@&",autofractionExcludedEnvs:`[
|
||||
["^{", "}"],
|
||||
["\\\\pu{", "}"]
|
||||
]`,matrixShortcutsEnvNames:"pmatrix, cases, align, gather, bmatrix, Bmatrix, vmatrix, Vmatrix, array, matrix",taboutClosingSymbols:"), ], \\rbrack, \\}, \\rbrace, \\rangle, \\rvert, \\rVert, \\rfloor, \\rceil, \\urcorner, }",autoEnlargeBracketsTriggers:"sum, int, frac, prod, bigcup, bigcap",forceMathLanguages:"math",snippetDebug:"off",vimEnabled:!1,vimSelectMode:"<C-g>",vimVisualMode:"<C-g>",vimMatrixEnter:"o"};function qt(t,e){function r(i){return i.replace(/\s/g,"").split(",")}function n(i){let s=[];try{s=JSON.parse(i).map(function(a){return{openSymbol:a[0],closeSymbol:a[1]}})}catch(o){console.error(o)}return s}return ye(oe({},e),{snippets:t,autofractionExcludedEnvs:n(e.autofractionExcludedEnvs),matrixShortcutsEnvNames:r(e.matrixShortcutsEnvNames),taboutClosingSymbols:new Set(r(e.taboutClosingSymbols)),autoEnlargeBracketsTriggers:r(e.autoEnlargeBracketsTriggers).map(i=>/[A-Za-z]+/.test(i)?`\\${i}`:i),forceMathLanguages:r(e.forceMathLanguages)})}var Ur=require("@codemirror/state"),gi=require("@codemirror/view"),w=require("obsidian");var As=require("obsidian");var V="top",U="bottom",D="right",M="left",hr="auto",We=[V,U,D,M],_e="start",Le="end",us="clippingParents",dr="viewport",Ot="popper",Os="reference",xn=We.reduce(function(t,e){return t.concat([e+"-"+_e,e+"-"+Le])},[]),fr=[].concat(We,[hr]).reduce(function(t,e){return t.concat([e,e+"-"+_e,e+"-"+Le])},[]),Ql="beforeRead",Sl="read",$l="afterRead",vl="beforeMain",Tl="main",wl="afterMain",kl="beforeWrite",Pl="write",El="afterWrite",hs=[Ql,Sl,$l,vl,Tl,wl,kl,Pl,El];function F(t){return t?(t.nodeName||"").toLowerCase():null}function G(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function Te(t){var e=G(t).Element;return t instanceof e||t instanceof Element}function N(t){var e=G(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function ht(t){if(typeof ShadowRoot=="undefined")return!1;var e=G(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function _l(t){var e=t.state;Object.keys(e.elements).forEach(function(r){var n=e.styles[r]||{},i=e.attributes[r]||{},s=e.elements[r];!N(s)||!F(s)||(Object.assign(s.style,n),Object.keys(i).forEach(function(o){var a=i[o];a===!1?s.removeAttribute(o):s.setAttribute(o,a===!0?"":a)}))})}function Cl(t){var e=t.state,r={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,r.popper),e.styles=r,e.elements.arrow&&Object.assign(e.elements.arrow.style,r.arrow),function(){Object.keys(e.elements).forEach(function(n){var i=e.elements[n],s=e.attributes[n]||{},o=Object.keys(e.styles.hasOwnProperty(n)?e.styles[n]:r[n]),a=o.reduce(function(l,c){return l[c]="",l},{});!N(i)||!F(i)||(Object.assign(i.style,a),Object.keys(s).forEach(function(l){i.removeAttribute(l)}))})}}var ds={name:"applyStyles",enabled:!0,phase:"write",fn:_l,effect:Cl,requires:["computeStyles"]};function Y(t){return t.split("-")[0]}var xe=Math.max,Ue=Math.min,Ce=Math.round;function Oe(t,e){e===void 0&&(e=!1);var r=t.getBoundingClientRect(),n=1,i=1;if(N(t)&&e){var s=t.offsetHeight,o=t.offsetWidth;o>0&&(n=Ce(r.width)/o||1),s>0&&(i=Ce(r.height)/s||1)}return{width:r.width/n,height:r.height/i,top:r.top/i,right:r.right/n,bottom:r.bottom/i,left:r.left/n,x:r.left/n,y:r.top/i}}function Ne(t){var e=Oe(t),r=t.offsetWidth,n=t.offsetHeight;return Math.abs(e.width-r)<=1&&(r=e.width),Math.abs(e.height-n)<=1&&(n=e.height),{x:t.offsetLeft,y:t.offsetTop,width:r,height:n}}function jt(t,e){var r=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(r&&ht(r)){var n=e;do{if(n&&t.isSameNode(n))return!0;n=n.parentNode||n.host}while(n)}return!1}function re(t){return G(t).getComputedStyle(t)}function Qn(t){return["table","td","th"].indexOf(F(t))>=0}function K(t){return((Te(t)?t.ownerDocument:t.document)||window.document).documentElement}function Re(t){return F(t)==="html"?t:t.assignedSlot||t.parentNode||(ht(t)?t.host:null)||K(t)}function fs(t){return!N(t)||re(t).position==="fixed"?null:t.offsetParent}function Rl(t){var e=navigator.userAgent.toLowerCase().indexOf("firefox")!==-1,r=navigator.userAgent.indexOf("Trident")!==-1;if(r&&N(t)){var n=re(t);if(n.position==="fixed")return null}var i=Re(t);for(ht(i)&&(i=i.host);N(i)&&["html","body"].indexOf(F(i))<0;){var s=re(i);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return i;i=i.parentNode}return null}function Qe(t){for(var e=G(t),r=fs(t);r&&Qn(r)&&re(r).position==="static";)r=fs(r);return r&&(F(r)==="html"||F(r)==="body"&&re(r).position==="static")?e:r||Rl(t)||e}function Fe(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function Ye(t,e,r){return xe(t,Ue(e,r))}function ms(t,e,r){var n=Ye(t,e,r);return n>r?r:n}function Zt(){return{top:0,right:0,bottom:0,left:0}}function Xt(t){return Object.assign({},Zt(),t)}functio
Line truncated
|
||||
\${}
|
||||
} catch (\${error}) {
|
||||
\${}
|
||||
}`,{label:"try",detail:"/ catch block",type:"keyword"}),(0,ee.snippetCompletion)("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),(0,ee.snippetCompletion)(`if (\${}) {
|
||||
\${}
|
||||
} else {
|
||||
\${}
|
||||
}`,{label:"if",detail:"/ else block",type:"keyword"}),(0,ee.snippetCompletion)(`class \${name} {
|
||||
constructor(\${params}) {
|
||||
\${}
|
||||
}
|
||||
}`,{label:"class",detail:"definition",type:"keyword"}),(0,ee.snippetCompletion)('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),(0,ee.snippetCompletion)('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],Js=new vr,no=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Dt(t){return(e,r)=>{let n=e.node.getChild("VariableDefinition");return n&&r(n,t),!0}}var Xc=["FunctionDeclaration"],Wc={FunctionDeclaration:Dt("function"),ClassDeclaration:Dt("class"),ClassExpression:()=>!0,EnumDeclaration:Dt("constant"),TypeAliasDeclaration:Dt("type"),NamespaceDeclaration:Dt("namespace"),VariableDefinition(t,e){t.matchContext(Xc)||e(t,"variable")},TypeDefinition(t,e){e(t,"type")},__proto__:null};function io(t,e){let r=Js.get(e);if(r)return r;let n=[],i=!0;function s(o,a){let l=t.sliceString(o.from,o.to);n.push({label:l,type:a})}return e.cursor(z.IncludeAnonymous).iterate(o=>{if(i)i=!1;else if(o.name){let a=Wc[o.name];if(a&&a(o,s)||no.has(o.name))return!1}else if(o.to-o.from>8192){for(let a of io(t,o.node))n.push(a);return!1}}),Js.set(e,n),n}var eo=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,so=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName"];function Vc(t){let e=(0,B.syntaxTree)(t.state).resolveInner(t.pos,-1);if(so.indexOf(e.name)>-1)return null;let r=e.to-e.from<20&&eo.test(t.state.sliceDoc(e.from,e.to));if(!r&&!t.explicit)return null;let n=[];for(let i=e;i;i=i.parent)no.has(i.name)&&(n=n.concat(io(t.state.doc,i)));return{options:n,from:r?e.from:t.pos,validFor:eo}}var rt=B.LRLanguage.define({parser:Ks.configure({props:[B.indentNodeProp.add({IfStatement:(0,B.continuedIndent)({except:/^\s*({|else\b)/}),TryStatement:(0,B.continuedIndent)({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:B.flatIndent,SwitchBody:t=>{let e=t.textAfter,r=/^\s*\}/.test(e),n=/^\s*(case|default)\b/.test(e);return t.baseIndent+(r?0:n?1:2)*t.unit},Block:(0,B.delimitedIndent)({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":(0,B.continuedIndent)({except:/^{/}),JSXElement(t){let e=/^\s*<\//.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},JSXEscape(t){let e=/\s*\}/.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},"JSXOpenTag JSXSelfClosingTag"(t){return t.column(t.node.from)+t.unit}}),B.foldNodeProp.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression":B.foldInside,BlockComment(t){return{from:t.from+2,to:t.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Ic=rt.configure({dialect:"ts"}),Mc=rt.configure({dialect:"jsx"}),Gc=rt.configure({dialect:"jsx ts"}),Bc="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(t=>({label:t,type:"keyword"}));function oo(t={}){let e=t.jsx?t.typescript?Gc:Mc:t.typescript?Ic:rt;return new B.LanguageSupport(e,[rt.data.of({autocomplete:(0,ee.ifNotIn)(so,(0,ee.completeFromList)(Zc.concat(Bc)))}),rt.data.of({autocomplete:Vc}),t.jsx?zc:[]])}function to(t,e,r=t.length){if(!e)return"";let n=e.getChild("JSXIdentifier");return n?t.sliceString(n.from,Math.min(n.to,r)):""}var Dc=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),zc=ro.EditorView.inputHandler.of((t,e,r,n)=>{if((Dc?t.composing:t.compositionStarted)||t.state.readOnly||e!=r||n!=">"&&n!="/"||!rt.isActiveAt(t.state,e,-1))return!1;let{state:i}=t,s=i.changeByRange(o=>{var a,l,c;let{head:p}=o,u=(0,B.syntaxTree)(i).resolveInner(p,-1),d;if(u.name=="JSXStartTag"&&(u=u.parent),n==">"&&u.name=="JSXFragmentTag")return{range:Cr.EditorSelection.cursor(p+1),changes:{from:p,insert:"><>"}};if(n==">"&&u.name=="JSXIdentifier"){if(((l=(a=u.parent)===null||a===void 0?void 0:a.lastChild)===null||l===void 0?void 0:l.name)!="JSXEndTag"&&(d=to(i.doc,u.parent,p)))return{range:Cr.EditorSelection.cursor(p+1),changes:{from:p,insert:`></${d}>`}}}else if(n=="/"&&u.name=="JSXFragmentTag"){let O=u.parent,h=O==null?void 0:O.parent;if(O.from==p-1&&((c=h.lastChild)===null||c===void 0?void 0:c.name)!="JSXEndTag"&&(d=to(i.doc,h==null?void 0:h.firstChild,p))){let f=`/${d}>`;return{range:Cr.EditorSelection.cursor(p+f.length),changes:{from:p,insert:f}}}}return{range:o}});return s.changes.empty?!1:(t.dispatch(s,{userEvent:"input.type",scrollIntoView:!0}),!0)});var we=require("@codemirror/language"),Me=require("@codemirror/commands"),Ar=require("@codemirror/autocomplete"),qr=require("@codemirror/search"),po=require("@codemirror/lint");var ao=require("@codemirror/view"),Rr=require("@codemirror/language"),_=require("@lezer
Line truncated
|
||||
["${t}", "}"]`)}
|
||||
]`;var ri="formatting_formatting-math_formatting-math-begin_keyword_math",Yc="formatting_formatting-math_formatting-math-end_keyword_math_math-",$o="formatting_formatting-math_formatting-math-begin_keyword_math_math-block",Hc="formatting_formatting-math_formatting-math-end_keyword_math_math-",Zr=new Set([ri,$o]),Xr=new Set([Yc,Hc]),So="HyperMD-codeblock_HyperMD-codeblock-begin_HyperMD-codeblock-begin-bg_HyperMD-codeblock-bg",ti="HyperMD-codeblock_HyperMD-codeblock-bg_HyperMD-codeblock-end_HyperMD-codeblock-end-bg",ii=ni.ViewPlugin.fromClass(class{constructor(e){this.codeblockLanguage=null;this.shouldUpdate=!1;this.updateFromView(e)}init(e){return this.shouldUpdate&&(this.updateFromView(e),this.shouldUpdate=!1),this}update(e){(e.docChanged||e.selectionSet||e.viewportChanged)&&(this.shouldUpdate=!0)}updateFromView(e){var u;let r=e.state,n=r.selection;this.view=e,this.state=r,this.pos=n.main.to,this.ranges=Array.from(n.ranges).reverse(),this.mode=new pt,this.boundsCache=new Map,this.innerBoundsCache=new Map,this.codeblockLanguage=null;let i=ep(r),s=(u=i==null?void 0:i.codeblockLanguage)!=null?u:null,o=s!==null,a=X(r),l=o&&a.forceMathLanguages.contains(s);this.mode.codeMath=l,this.mode.code=o&&!l?s:!1,o&&this.mode.code!==!1&&(this.codeblockLanguage=s,this.boundsCache.set(this.pos,i));let c=nt(e),p=l||c.inMathBound(r,this.pos);if(p!==!0&&p!==null){let d=p.mode===0;this.mode.blockMath=!d,this.mode.inlineMath=d,this.boundsCache.set(this.pos,p)}if(p){let d=this.inTextEnvironment();d==="text"?this.mode.textEnv=!0:d==="none"&&(this.mode.inlineMath=!1,this.mode.blockMath=!1,this.mode.codeMath=!1)}this.mode.text=!o&&!p}isWithinEnvironment(e,r){if(!this.mode.inMath())return null;let n=this.getInnerBounds();if(!n)return null;let{inner_start:i,inner_end:s}=n,o=this.state.sliceDoc(i,s);e-=i,Array.isArray(r)||(r=[r]);e:for(let a of r){let l=a.openSymbol.slice(-1),c=xt(l),p,u;["{","[","("].contains(l)&&a.closeSymbol===c?(p=a.openSymbol.length-1,u=l):(p=0,u=a.openSymbol);let d=o.lastIndexOf(a.openSymbol,e-1);for(;d!=-1;){let O=J(o,d+p,u,a.closeSymbol,!1);if(O===-1)continue e;if(O>=e&&e>=d+a.openSymbol.length)return ye(oe({},a),{inner_start:d+a.openSymbol.length+i,inner_end:O+i,outer_start:d+i,outer_end:O+a.closeSymbol.length+i});if(d<=0)continue e;d=o.lastIndexOf(a.openSymbol,d-1)}}return null}inTextEnvironment(){let e=this.isWithinEnvironment(this.pos,Qo);if(!e)return null;let r=e.openSymbol.slice(1,-1);return ei.includes(r)?"none":"text"}getBounds(e=this.pos){let r=this.boundsCache.get(e);if(r!==void 0)return r;let n;return this.mode.codeMath?n=Jc(this.state,e):n=nt(this.view).inMathBound(this.state,e),this.boundsCache.set(e,n),n}getInnerBounds(e=this.pos){let r,n=this.innerBoundsCache.get(e);return n!==void 0?n:(this.mode.codeMath?r=this.getBounds(e):r=Kc(this.view),this.innerBoundsCache.set(e,r),r)}}),I=t=>{let e=t.plugin(ii);if(!e)throw new Error("Context plugin not found, something went wrong with the plugin initialization");return e.init(t)};var Kc=(t,e)=>{e||(e=t.state.selection.main.to);let r=nt(t).inMathBound(t.state,e);if(!r)return null;let n=t.state.sliceDoc(r.inner_start,r.inner_end);n=n.replaceAll("\\$","\\R");let i=n.lastIndexOf("$",e-1),s=n.indexOf("$",e);return i===-1||s===-1?r:{inner_start:i+1,inner_end:s,outer_start:i,outer_end:s+1}},Jc=(t,e=t.selection.main.from)=>{let r=vo(t,e);if(!r)return null;let{begin:n,end:i}=r;return{inner_start:n.to,inner_end:i.from,outer_start:n.from,outer_end:i.to}},vo=(t,e=t.selection.main.from)=>{let n=(0,Wr.syntaxTree)(t).cursor();if(n.childBefore(e),!n.name.contains("codeblock")||n.name===So&&e<=n.to||n.name===ti)return null;do if(n.name===So)break;while(n.prev());let i=n.node;if(!i)return null;n.childAfter(e);do if(n.name===ti)break;while(n.next());let s=n.node;return!s||s.name!==ti?null:{begin:i,end:s}},ep=t=>{let e=t.selection.ranges[0].from,r=vo(t,e);if(!r)return null;let{begin:n,end:i}=r,s=t.sliceDoc(n.from,n.to).replace(/`+|~+/g,"");return{inner_start:n.to,inner_end:i.from,outer_start:n.from,outer_end:i.to,codeblockLanguage:s}},si=ni.ViewPlugin.fromClass(class{constructor(e){this.mathBounds=[];this.equations=null;this.shouldUpdate=!1;this.inMathBound=(e,r)=>{var o,a;let n=this.mathBounds;if(r<=((o=n[0])==null?void 0:o.outer_start)||r>=((a=n[n.length-1])==null?void 0:a.outer_end))return this.getEquationBounds(e,r);let i=0,s=n.length-1;for(;i<=s;){let l=i+s>>1,c=n[l];if(r<c.outer_start)s=l-1;else if(r>=c.outer_end)i=l+1;else{if(r<=c.inner_start||r>=c.inner_end)break;return c}}return this.getEquationBounds(e,r)};this.computeEquationBounds=(e,r)=>{r===void 0&&(r=e.selection.main.to);let i=(0,Wr.syntaxTree)(e).cursor();if(i.childBefore(r),i.node.firstChild&&i.name!=="Document"){let l=r;for(;e.sliceDoc(l,l+1)===`
|
||||
`&&l>0;)l-=1;i.moveTo(l,-1)}if(!(i.name.contains("math")&&!i.name.startsWith("hashtag_hashtag-end_meta_tag"))||Xr.has(i.name)&&r>=i.to)return null;do if(Zr.has(i.name))break;while(i.prev());let s=i.node;if(!s)return null;i.childAfter(r);do if(Xr.has(i.name))break;while(i.next());let o=i.node;return o?s.to>r&&s.from<r&&s.name===$o?{inner_start:r,inner_end:r,outer_start:s.from,outer_end:s.to,mode:0}:o.from<r||s.to>r?null:{inner_start:s.to,inner_end:o.from,outer_start:s.from,outer_end:o.to,mode:s.name===ri?0:1}:null};this.addMathBound=e=>{if(this.mathBounds.length===0)this.mathBounds.push(e);else if(e.outer_end<=this.mathBounds[0].outer_start)this.mathBounds.unshift(e);else if(e.outer_start>=this.mathBounds[this.mathBounds.length-1].outer_end)this.mathBounds.push(e);else{let r=0,n=this.mathBounds.length-1;for(;r<=n;){let i=r+n>>1;e.outer_start<this.mathBounds[i].outer_start?n=i-1:r=i+1}this.mathBounds.splice(r,0,e)}return e};this.updateMathBounds(e)}init(e){return this.shouldUpdate&&(this.equations=null,this.updateMathBounds(e),this.shouldUpdate=!1),this}update(e){(e.docChanged||e.viewportChanged)&&(this.shouldUpdate=!0)}updateMathBounds(e){var s,o,a;let r=(0,Wr.syntaxTree)(e.state),n=[];e.visibleRanges.forEach(({from:l,to:c},p)=>{n.push([]),r.iterate({from:l,to:c,enter:u=>{(Zr.has(u.name)&&u.to<c||Xr.has(u.name)&&u.from>l)&&n[p].push(u.node)}})});let i=[];for(let l of n){if(Xr.has((s=l[0])==null?void 0:s.name)){let p=this.computeEquationBounds(e.state,l[0].from);p&&i.push(p)}let c=Zr.has((o=l[0])==null?void 0:o.name)?0:1;for(let p=c;p<l.length-1;p+=2){let u=l[p],d=l[p+1];i.push({inner_start:u.to,inner_end:d.from,outer_start:u.from,outer_end:d.to,mode:u.name===ri?0:1})}if(Zr.has((a=l[l.length-1])==null?void 0:a.name)){let p=l[l.length-1],u=this.computeEquationBounds(e.state,p.to);u&&i.push(u)}}this.mathBounds=i.filter((l,c)=>{if(c===0)return!0;let p=i[c-1];return!(p.outer_start===l.outer_start&&p.outer_end===l.outer_end)})}getEquationBounds(e,r){r||(r=e.selection.main.to);let n=this.computeEquationBounds(e,r);return n?(this.addMathBound(n),n):null}getEquations(e){return this.equations?this.equations:(this.equations=new Map(this.mathBounds.map(r=>[r.inner_start,e.sliceDoc(r.inner_start,r.inner_end)])),this.equations)}}),nt=t=>{let e=t.plugin(si);if(!e)throw new Error("MathBoundsPlugin not found, something went wrong with the plugin initialization");return e.init(t)};var To=require("@codemirror/view");var Ut=class{constructor(e,r,n,i){this.from=e,this.to=r,this.insert=n,this.keyPressed=i}getTabstops(e,r){let n=[];for(let i=r;i<r+this.insert.length;i++){if(e.charAt(i)!=="$")continue;let s=parseInt(e.charAt(i+1)),o=i,a=o+2,l="";if(isNaN(s)){if(e.charAt(i+1)!=="{")continue;let p=J(e,i+1,"{","}",!1,r+this.insert.length),u=e.slice(i,p+1);if(!u.includes(":"))continue;let d=u.indexOf(":");if(s=parseInt(u.slice(2,d)),isNaN(s)||p===-1)continue;l=e.slice(i+d+1,p),a=p+1,i=p}let c={number:s,from:o,to:a,replacement:l};n.push(c)}return n}toChangeSpec(){return this}};var Vr=require("@codemirror/language"),wo=require("@codemirror/state"),oi=To.ViewPlugin.fromClass(class{constructor(){this.snippetQueue=[]}clearSnippetQueue(){this.snippetQueue=[]}QueueSnippets(t){this.snippetQueue=this.snippetQueue.concat(t)}get snippetQueueValue(){return this.snippetQueue.map(t=>new Ut(t.from,t.to,t.insert,t.keyPressed))}});function Ir(t){let e=t.plugin(oi);if(!e)throw new Error("SnippetQueue plugin not found, something went wrong with the plugin initialization");return e}function qe(t,e,r,n,i){let s=new Ut(e,r,tp(t.state,e,r,n),i);Ir(t).QueueSnippets([s])}var tp=(t,e,r,n)=>{let o=t.doc.lineAt(r).text.match(/^(>*)(\s*)/);if(!o)return n;let a=o[1],l=o[2],c=(0,wo.countColumn)(l,t.tabSize),p=(0,Vr.getIndentUnit)(t),u=c%p;return n=n.replace(/\n(\t*)/g,(d,O)=>{let h=O.length*p+c-(O.length&&u),f=(0,Vr.indentString)(t,h);return`
|
||||
`+a+f}),n};function Qt(t){Ir(t).clearSnippetQueue()}var Kt=require("@codemirror/state");var Yt=require("@codemirror/state"),Ro=require("@codemirror/commands");var Mr=require("@codemirror/view"),Nt=require("@codemirror/state"),ko=Nt.StateEffect.define(),Po=Nt.StateEffect.define(),St=Nt.StateField.define({create(){return{index:0,tabstopGroups:[],color:0}},update(t,e){let r=t.tabstopGroups,n=t.color;r.forEach(s=>s.map(e.changes));for(let s of e.effects)s.is(ko)?r.splice(t.index,1,...s.value):s.is(Po)&&(r=[],n=0);let i=t.index;return e.selection&&(i=rp(r,e.selection),r.length<=1||i>=r.length-1?(r=[],i=0,n=0):r[0].hideFromEditor()),{index:i,tabstopGroups:r,color:n}},provide:t=>Mr.EditorView.decorations.of(e=>{let r=e.state.field(t).tabstopGroups,n=[];for(let i of r)i.hidden||n.push(...i.getRanges());return Mr.Decoration.set(n,!0)})});function rp(t,e){for(let r=0;r<t.length;r++)if(t[r].containsSelection(e))return r;return t.length}function Gr(t){return{effects:[ko.of(t)]}}function Br(t){t.dispatch({effects:[Po.of(null)]})}var np=3;function Eo(t){return t.state.field(St).color++%np}var Ft=Yt.StateEffect.define(),$t=Yt.StateEffect.define(),_o=Yt.StateEffect.define(),Co=Yt.StateEffect.define(),Ao=Ro.invertedEffects.of(t=>{let e=[];for(let r of t.effects)r.is(Ft)?e.push(_o.of(r.value)):r.is(_o)?e.push(Ft.of(r.value)):r.is($t)?e.push(Co.of(null)):r.is(Co)&&e.push($t.of(null));return e}),qo=t=>{let e=t.transactions.find(n=>n.isUserEvent("undo")),r=t.transactions.find(n=>n.isUserEvent("redo"));for(let n of t.transactions)for(let i of n.effects)i.is(Ft)&&r&&t.view.dispatch({effects:Gr(i.value).effects});e&&Br(t.view)};var Xo=require("@codemirror/commands");var Ht=require("@codemirror/state"),vt=require("@codemirror/view");var jo="latex-suite-snippet-placeholder";function ip(t,e,r){let n=`${jo} ${jo}-${r}`;return vt.Decoration.mark({inclusive:!0,color:r,class:n}).range(t,e)}var ai=class{constructor(e,r){let n=e.map(i=>ip(i.from,i.to,r));this.decos=vt.Decoration.set(n,!0),this.color=r,this.hidden=!1}select(e,r,n){let i=this.toEditorSelection(),s=r?Zo(i):i;e.dispatch({selection:s,effects:n?$t.of(null):void 0}),yt(),this.hideFromEditor()}toSelectionRanges(){let e=[],r=this.decos.iter();for(;r.value!=null;)e.push(Ht.EditorSelection.range(r.from,r.to)),r.next();return e}toEditorSelection(e=!1){let r=Ht.EditorSelection.create(this.toSelectionRanges());return e&&(r=Zo(r)),r}containsSelection(e){function r(s,o){for(let a of o)if(a.from<=s.from&&a.to>=s.to)return!0;return!1}let n=this.toSelectionRanges(),i=!0;for(let s of e.ranges)if(!r(s,n)){i=!1;break}return i}hideFromEditor(){this.hidden=!0}map(e){this.decos=this.decos.map(e)}getRanges(){let e=[],r=this.decos.iter();for(;r.value!=null;)r.from!=r.to?e.push(r.value.range(r.from,r.to)):e.push(op(r.from,r.to)),r.next();return e}};function li(t,e){let r={};for(let s of t){let o=String(s.number);r[o]?r[o].push(s):r[o]=[s]}let n=[],i=Object.keys(r);i.sort((s,o)=>parseInt(s)-parseInt(o));for(let s of i){let o=new ai(r[s],e);n.push(o)}return n}function Zo(t){let e=t.ranges.map(r=>Ht.EditorSelection.range(r.to,r.to));return Ht.EditorSelection.create(e)}var sp=vt.Decoration.widget({widget:new class extends vt.WidgetType{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}});function op(t,e){return sp.range(t,e)}function Ge(t){let e=Ir(t).snippetQueueValue;if(e.length===0)return!1;let r=t.state.doc.length,n=ap(t,e),i=t.state.selection.map(n,1),s=n.apply(t.state.doc).toString(),o=lp(s,e,r),a={changes:n,selection:i};return o.length===0?(t.dispatch(a),Qt(t),!0):(cp(t,o,a,s.length),Qt(t),!0)}function ap(t,e){let r=t.state.doc,n=r.length,i=[];for(let l of e)if(l.keyPressed&&l.keyPressed.length===1){let c=t.state.doc.sliceString(l.to-1,l.to),p=l.to===0?0:l.to-1;i.push({from:p,to:l.to,insert:c+l.keyPressed})}i.length>0&&t.dispatch({changes:i,annotations:Xo.isolateHistory.of("full")});let s=Kt.ChangeSet.of(i,n).invert(r),o=Kt.ChangeSet.of(e,n);return s.compose(o)}function lp(t,e,r){let n=Kt.ChangeSet.of(e,r),s=e.map(a=>a.from).map(a=>n.mapPos(a)),o=[];for(let a=0;a<e.length;a++)o.push(...e[a].getTabstops(t,s[a]));return o}function cp(t,e,r,n){let i=Kt.ChangeSet.of(e.map(d=>({from:d.from,to:d.to,insert:d.replacement})),n),s=Eo(t),o=li(e,s);o.forEach(d=>d.map(i));let a=li(e,s);a.forEach(d=>d.map(i));let l=Gr(o).effects,u={selection:o[0].toEditorSelection(),effects:$t.of(null),sequential:!0};t.dispatch({effects:[...l,Ft.of(a)],changes:r.changes.compose(i),selection:r.selection},u)}function ci(t,e){let r=t.state.field(St).tabstopGroups,n=t.state.field(St).index;function i(o,a){let l=r[o];if(!l)return!1;let c=t.state.selection,p=l.toEditorSelection();return l.containsSelection(c)&&(p=l.toEditorSelection(!0)),c.eq(p)?i(o+a,a):(t.dispatch({selection:p}),yt(),!0)}let s=e?-1:1;return i(n+s,s)}var pi=t=>{let e=[],r=0;for(;r<t.length;){let n=t[r];if(/\s/.test(n)){r++;continue}let{token:i,nextIndex:s}=pp(t,r);e.push(i),r=s}return e},pp=(t,e)=>{s
Line truncated
|
||||
`;)n++;return{token:{start:e,end:n,text:t.slice(e,n)},nextIndex:n}},Op=(t,e)=>{let r=t.length,n=e+1,i=t[n];if(/[A-Za-z]/.test(i))do n++;while(n<r&&/[A-Za-z]/.test(t[n]));else n++;return{token:{start:e,end:n,text:t.slice(e,n)},nextIndex:n}},hp=(t,e)=>{let r=e+1;return{token:{start:e,end:r,text:t.slice(e,r)},nextIndex:r}};var dp=new Set(["\\left","\\bigl","\\Bigl","\\biggl","\\Biggl"]),fp=new Set(["\\right","\\bigr","\\Bigr","\\biggr","\\Biggr"]),mp=new Set(["(",")","[","]","\\lbrack","\\rbrack","\\{","\\}","\\lbrace","\\rbrace","<",">","\\langle","\\rangle","\\lt","\\gt","|","\\vert","\\lvert","\\rvert","\\|","\\Vert","\\lVert","\\rVert","\\lfloor","\\rfloor","\\lceil","\\rceil","\\ulcorner","\\urcorner","/","\\\\","\\backslash","\\uparrow","\\downarrow","\\Uparrow","\\Downarrow","."]),ui={"(":")","[":"]","{":"}","\\lbrack":"\\rbrack","\\lbrace":"\\rbrace","\\langle":"\\rangle","\\lvert":"\\rvert","\\lVert":"\\rVert","\\lfloor":"\\rfloor","\\lceil":"\\rceil","\\ulcorner":"\\urcorner","<":">"},gp=t=>dp.has(t.text),Wo=t=>fp.has(t.text),Oi=t=>mp.has(t.text),bp=(t,e)=>e.has(t.text),yp=(t,e,r)=>{let n=t[e];if(e>0){let i=t[e-1];if(Wo(i)&&Oi(n))return!0;if(gp(i)&&Oi(n))return!1}return bp(n,r)},xp=(t,e)=>{let r=t[e];if(!Wo(r))return!1;if(e+1>=t.length)return!0;let n=t[e+1];return!Oi(n)},hi=(t,e)=>{var b;if(!e.mode.inMath())return!1;let r=e.getBounds();if(!r)return!1;let{inner_start:n,inner_end:i,outer_end:s,outer_start:o}=r;if(s<=e.pos)return!1;let a=t.state.doc,l=t.state.selection.main.to,c=l-n,p=a.sliceString(n,i),u=pi(p),d=X(t).taboutClosingSymbols,O=u.findIndex(y=>y.end>c),h=O===-1?u.length:O;for(let y=h;y<u.length;y++){if(yp(u,y,d))return ke(t,n+u[y].end),!0;if(xp(u,y))return console.warn("[tabout] Found right command without following delimiter:",u[y].text,"at index",n+u[y].start),ke(t,n+u[y].end),!0}if(!(a.sliceString(l,i).trim().length===0))return!1;if(e.mode.inlineMath||e.mode.codeMath)ke(t,s);else{let y=a.lineAt(s),x=[],S=((b=a.lineAt(o).text.match(/^\s*/))==null?void 0:b[0])||"";if(y.number===a.lines)x.push({changes:{from:y.to,to:y.to,insert:`
|
||||
`+S},selection:{anchor:y.to+1+S.length}});else{let m=a.lineAt(y.to+1);m.text.trim()===""?x.push({changes:{from:m.from,to:m.to,insert:S},selection:{anchor:y.to+1+S.length}}):x.push({selection:{anchor:y.to+1}})}let Q=a.lineAt(l);Q.text.trimEnd()!==Q.text&&x.push({changes:{from:Q.from,to:Q.to,insert:Q.text.trimEnd()}}),t.dispatch(...x)}return!0},Vo=(t,e)=>{let r=pi(e),n=X(t).taboutClosingSymbols,i=[],s=ur(new Set(Object.values(ui)),n),o=new Set(Object.keys(ui).filter(a=>s.has(ui[a])));for(let a=0;a<r.length;a++){let l=r[a];if(s.has(l.text)){if(i.length===0)return l.end;i.pop()}else o.has(l.text)&&i.push(l.text)}return null},Io=(t,e)=>{let r=t.state.selection.main;if(!r.empty)return!1;let n=r.from,i=zt(t,n);return i===e&&[")","]","}"].includes(i)};var Qp=t=>{var s;let e=I(t),n=t.state.doc.lineAt(e.pos).text.match(new RegExp("(?<=\\\\begin{[^]]*}|\\\\\\\\|^)(\\s|\\&)+")),i=(s=n==null?void 0:n[0].trimStart())!=null?s:"";return e.mode.blockMath?(qe(t,e.pos,e.pos,` \\\\
|
||||
${i}$0`),Ge(t)):t.dispatch(t.state.replaceSelection(` \\\\ ${i}`)),!0},Sp=(t,e)=>{let r=I(t);if(r.mode.blockMath){let n=t.state.doc,i=n.lineAt(r.pos).number+1,s=n.line(i);ke(t,s.to)}else r.mode.inlineMath&&ke(t,e.outer_end);return!0},$p=t=>t.state.selection.main.empty?(t.dispatch(t.state.replaceSelection(" & ")),!0):!1,Dr=t=>e=>{let r=I(e);if(!r.mode.strictlyInMath())return!1;let i=X(e).matrixShortcutsEnvNames.map(o=>({openSymbol:"\\begin{"+o+"}",closeSymbol:"\\end{"+o+"}"})),s=r.isWithinEnvironment(r.pos,i);return s?t(e,s):!1},vp=t=>{let e=I(t),r=t.state.doc.lineAt(e.pos),n=r.text.slice(e.pos-r.from),i=Vo(t,n);return i!==null?(ke(t,e.pos+i),!0):!1},zr=Dr(Qp),Mo=Dr(Sp),Go=Dr($p),Bo=Dr(vp);var zo=require("@codemirror/commands");function Tp(t){let r=I(t).getBounds();if(!r)return!1;let{inner_start:n,inner_end:i}=r,s="\\boxed{"+t.state.sliceDoc(n,i)+"}",o=t.state.sliceDoc(n-2,n)==="$$"&&t.state.sliceDoc(i,i+2)==="$$";o&&(s=`
|
||||
`+s+`
|
||||
`);let a=t.state.selection.main.to;jr(t,n,i,s),ke(t,a+7+(o?1:0))}function wp(){return{id:"latex-suite-box-equation",name:"Box current equation",editorCheckCallback:(t,e)=>{let r=e.cm,i=I(r).mode.inMath();if(t)return i;i&&Tp(r)}}}function kp(){return{id:"latex-suite-select-equation",name:"Select current equation",editorCheckCallback:(t,e)=>{let r=e.cm,n=I(r),i=n.mode.inMath();if(t)return i;if(!i)return;let s=n.getBounds();if(!s)return!1;let{inner_start:o,inner_end:a}=s,l=r.state.doc.toString();l.charAt(o)===`
|
||||
`&&o++,l.charAt(a-1)===`
|
||||
`&&a--,fo(r,o,a)}}}function Pp(t){return{id:"latex-suite-enable-all-features",name:"Enable all features",callback:()=>v(this,null,function*(){t.settings.snippetsEnabled=!0,t.settings.autofractionEnabled=!0,t.settings.matrixShortcutsEnabled=!0,t.settings.taboutEnabled=!0,t.settings.autoEnlargeBrackets=!0,yield t.saveSettings()})}}function Ep(t){return{id:"latex-suite-disable-all-features",name:"Disable all features",callback:()=>v(this,null,function*(){t.settings.snippetsEnabled=!1,t.settings.autofractionEnabled=!1,t.settings.matrixShortcutsEnabled=!1,t.settings.taboutEnabled=!1,t.settings.autoEnlargeBrackets=!1,yield t.saveSettings()})}}function _p(t){return{id:"latex-suite-toggle-all-features",name:"Toggle all features",callback:()=>v(this,null,function*(){let e=t.settings.snippetsEnabled||t.settings.autofractionEnabled||t.settings.matrixShortcutsEnabled||t.settings.taboutEnabled||t.settings.autoEnlargeBrackets;t.settings.snippetsEnabled=!e,t.settings.autofractionEnabled=!e,t.settings.matrixShortcutsEnabled=!e,t.settings.taboutEnabled=!e,t.settings.autoEnlargeBrackets=!e,yield t.saveSettings()})}}function Cp(t){return{id:"latex-suite-toggle-conceal",name:"Toggle conceal",callback:()=>v(this,null,function*(){t.settings.concealEnabled=!t.settings.concealEnabled,yield t.saveSettings()})}}var Lo=t=>[wp(),kp(),Pp(t),Ep(t),Cp(t),_p(t)];function di(t){return{id:"latex-suite-vim-select-mode",defineType:"defineAction",type:"action",action:e=>{var i;let r=(i=window==null?void 0:window.CodeMirrorAdapter)==null?void 0:i.Vim;if(!r)return;let n=e.listSelections();r.enterInsertMode(e),e.setSelections(n)},key:t.vimSelectMode,context:"visual"}}function fi(t){return{id:"latex-suite-vim-visual-mode",defineType:"defineAction",type:"action",action:e=>{var i;if(!e.somethingSelected())return;let r=e.listSelections(),n=(i=window==null?void 0:window.CodeMirrorAdapter)==null?void 0:i.Vim;n&&(n.exitInsertMode(e),e.setSelections(r))},key:t.vimVisualMode,context:"insert"}}function mi(t){return{id:"latex-suite-vim-special-enter",defineType:"defineAction",type:"action",action:e=>{var a;let r=(a=window==null?void 0:window.CodeMirrorAdapter)==null?void 0:a.Vim;if(!r)return;let n=e.getCursor().line,i=e.getLine(n);e.setCursor({line:n,ch:i.length+1});let s=Do.EditorView.findFromDOM(e.getWrapperElement());if(!s)return;if(zr(s)){r.enterInsertMode(e);return}(0,zo.insertNewlineAndIndent)({state:e.cm6.state,dispatch:l=>{let c=e.cm6;if(c.state.readOnly)return;let p="input.type.compose";if(e.curOp&&!e.curOp.lastChange&&(p="input.type.compose.start"),Array.isArray(l.annotations))try{l.annotations.forEach(u=>{u.value==="input"&&(u.value=p)})}catch(u){console.error(u)}else l.userEvent=p;c.dispatch(l)}})||console.error("Failed to insert newline and indent latex-suite-insert-newline-and-indent"),r.enterInsertMode(e)},key:t.vimMatrixEnter,context:"normal"}}function Lr(t){return[di(t),fi(t),mi(t)]}var Nr=class extends w.PluginSettingTab{constructor(e,r){super(e,r),this.plugin=r}hide(){var e;(e=this.snippetsEditor)==null||e.destroy()}addHeading(e,r,n="math"){let s=new w.Setting(e).setName(r).setHeading().settingEl,o=s.createDiv();(0,w.setIcon)(o,n),o.addClass("latex-suite-settings-icon"),s.prepend(o)}display(){let{containerEl:e}=this;e.empty(),this.displaySnippetSettings(),this.displayConcealSettings(),this.displayColorHighlightBracketsSettings(),this.displayPopupPreviewSettings(),this.displayAutofractionSettings(),this.displayMatrixShortcutsSettings(),this.displayTaboutSettings(),this.displayAutoEnlargeBracketsSettings(),this.displayAdvancedSnippetSettings()}displaySnippetSettings(){let e=this.containerEl;this.addHeading(e,"Snippets","ballpen"),new w.Setting(e).setName("Enabled").setDesc("Whether snippets are enabled.").addToggle(a=>a.setValue(this.plugin.settings.snippetsEnabled).onChange(l=>v(this,null,function*(){this.plugin.settings.snippetsEnabled=l,yield this.plugin.saveSettings()})));let r=new w.Setting(e).setName("Snippets").setDesc('Enter snippets here. Remember to add a comma after each snippet, and escape all backslashes with an extra \\. Lines starting with "//" will be treated as comments and ignored.').setClass("snippets-text-area");this.createSnippetsEditor(r),new w.Setting(e).setName("Load snippets from file or folder").setDesc("Whether to load snippets from a specified file, or from all files within a folder (instead of from the plugin settings).").addToggle(a=>a.setValue(this.plugin.settings.loadSnippetsFromFile).onChange(l=>v(this,null,function*(){this.plugin.settings.loadSnippetsFromFile=l,r.settingEl.toggleClass("hidden",l),this.snippetsFileLocEl!=null&&this.snippetsFileLocEl.toggleClass("hidden",!l),yield this.plugin.saveSettings()})));let n=new DocumentFragment;n.createDiv({},a=>{a.innerHTML=`
|
||||
The file or folder to load snippets from. The file or folder must be within your vault, and not within a hidden folder (such as <code>.obsidian/</code>).`});let i=new w.Setting(e).setName("Snippets file or folder location").setDesc(n),s;i.addSearch(a=>{a.setPlaceholder(W.snippetsFileLocation).setValue(this.plugin.settings.snippetsFileLocation).onChange((0,w.debounce)(l=>v(this,null,function*(){this.plugin.settings.snippetsFileLocation=l,yield this.plugin.saveSettings(!0)}),500,!0)),s=a.inputEl,s.addClass("latex-suite-location-input-el"),new It(this.app,s)}),this.snippetsFileLocEl=i.settingEl;let o=this.plugin.settings.loadSnippetsFromFile;r.settingEl.toggleClass("hidden",o),this.snippetsFileLocEl.toggleClass("hidden",!o),this.createTriggerSetting(e,"non-auto snippets","snippetsTrigger"),this.createTriggerSetting(e,"next tabstop","snippetNextTabstopTrigger"),this.createTriggerSetting(e,"previous tabstop","snippetPreviousTabstopTrigger")}displayConcealSettings(){let e=this.containerEl;this.addHeading(e,"Conceal","math-integral-x");let r=new DocumentFragment;r.createDiv({},i=>i.setText("Make equations more readable by hiding LaTeX syntax and instead displaying it in a pretty format.")),r.createDiv({},i=>i.innerHTML=`
|
||||
e.g. <code>\\dot{x}^{2} + \\dot{y}^{2}</code> will display as \u1E8B\xB2 + \u1E8F\xB2, and <code>\\sqrt{ 1-\\beta^{2} }</code> will display as \u221A{ 1-\u03B2\xB2 }.
|
||||
`),r.createDiv({},i=>i.setText("LaTeX beneath the cursor will be revealed.")),r.createEl("br"),r.createDiv({},i=>i.setText("Disabled by default to not confuse new users. However, I recommend turning this on once you are comfortable with the plugin!")),new w.Setting(e).setName("Enabled").setDesc(r).addToggle(i=>i.setValue(this.plugin.settings.concealEnabled).onChange(s=>v(this,null,function*(){this.plugin.settings.concealEnabled=s,yield this.plugin.saveSettings()})));let n=new DocumentFragment;n.createDiv({},i=>i.setText("How long to delay the reveal of LaTeX for, in milliseconds, when the cursor moves over LaTeX. Defaults to 0 (LaTeX under the cursor is revealed immediately).")),n.createEl("br"),n.createDiv({},i=>i.setText("Can be set to a positive number, e.g. 300, to delay the reveal of LaTeX, making it much easier to navigate equations using arrow keys.")),n.createEl("br"),n.createDiv({},i=>i.setText("Must be an integer \u2265 0.")),new w.Setting(e).setName("Reveal delay (ms)").setDesc(n).addText(i=>i.setPlaceholder(String(W.concealRevealTimeout)).setValue(String(this.plugin.settings.concealRevealTimeout)).onChange(s=>{/^\d+$/.test(s)&&(this.plugin.settings.concealRevealTimeout=Number(s),this.plugin.saveSettings())}))}displayColorHighlightBracketsSettings(){let e=this.containerEl;this.addHeading(e,"Highlight and color brackets","parentheses"),new w.Setting(e).setName("Color paired brackets").setDesc("Whether to colorize matching brackets.").addToggle(r=>r.setValue(this.plugin.settings.colorPairedBracketsEnabled).onChange(n=>v(this,null,function*(){this.plugin.settings.colorPairedBracketsEnabled=n,yield this.plugin.saveSettings()}))),new w.Setting(e).setName("Highlight matching bracket beneath cursor").setDesc("When the cursor is adjacent to a bracket, highlight the matching bracket.").addToggle(r=>r.setValue(this.plugin.settings.highlightCursorBracketsEnabled).onChange(n=>v(this,null,function*(){this.plugin.settings.highlightCursorBracketsEnabled=n,yield this.plugin.saveSettings()})))}displayPopupPreviewSettings(){let e=this.containerEl;this.addHeading(e,"Math popup preview","superscript");let r=document.createDocumentFragment(),n=document.createElement("div");n.setText("When inside an equation, show a popup preview window of the rendered math.");let i=document.createElement("br"),s=document.createElement("div");s.setText("The popup preview will be shown for all inline math equations, as well as for block math equations in Source mode."),r.append(n,i,s);let o=new w.Setting(e).setName("Enabled").setDesc(r),a=new w.Setting(e).setName("Position").setDesc("Where to display the popup preview relative to the equation source.").addDropdown(u=>u.addOption("Above","Above").addOption("Below","Below").setValue(this.plugin.settings.mathPreviewPositionIsAbove?"Above":"Below").onChange(d=>v(this,null,function*(){this.plugin.settings.mathPreviewPositionIsAbove=d==="Above",yield this.plugin.saveSettings()}))),l=new w.Setting(e).setName("Cursor symbol").setDesc(`The symbol to use as the cursor in the popup preview such as ${W.mathPreviewCursor}. Leave it blank to turn it off.`).addText(u=>{u.setPlaceholder(W.mathPreviewCursor).setValue(this.plugin.settings.mathPreviewCursor).onChange(O=>v(this,null,function*(){this.plugin.settings.mathPreviewCursor=O,yield this.plugin.saveSettings()}));let d=e.createEl("datalist",{attr:{id:"math-preview-cursor-list"}});return["\u25B6","\u2503","|","\\_","{\\mid}","{\\triangle}"].forEach(O=>d.createEl("option",{value:O})),u.inputEl.setAttribute("list","math-preview-cursor-list"),u}),c=new w.Setting(e).setName("Highlight brackets in preview").setDesc("Whether to highlight the area within the nearest pair of brackets around the cursor in the popup preview.").addToggle(u=>u.setValue(this.plugin.settings.mathPreviewBracketHighlighting).onChange(d=>v(this,null,function*(){this.plugin.settings.mathPreviewBracketHighlighting=d,yield this.plugin.saveSettings()}))),p=[a,l,c];p.forEach(u=>u.settingEl.toggleClass("hidden",!this.plugin.settings.mathPreviewEnabled)),o.addToggle(u=>u.setValue(this.plugin.settings.mathPreviewEnabled).onChange(d=>v(this,null,function*(){this.plugin.settings.mathPreviewEnabled=d,p.forEach(O=>O.settingEl.toggleClass("hidden",!d)),yield this.plugin.saveSettings()})))}displayAutofractionSettings(){let e=this.containerEl;this.addHeading(e,"Auto-fraction","math-x-divide-y-2"),new w.Setting(e).setName("Enabled").setDesc("Whether auto-fraction is enabled.").addToggle(r=>r.setValue(this.plugin.settings.autofractionEnabled).onChange(n=>v(this,null,function*(){this.plugin.settings.autofractionEnabled=n,yield this.plugin.saveSettings()}))),new w.Setting(e).setName("Fraction symbol").setDesc("The fraction symbol to use in the replacement. e.g. \\frac, \\dfrac, \\tfrac").addText(r=>{r.setPlaceholder(W.autofractionSymbol).setValue(this.plugin.settings.autofractionSymbol).onChange(i=>v(this,null,function*(){this.plugin.settings.autofractionSymbol=i,yield this.plugin.saveSettings()}))
Line truncated
|
||||
The file or folder to load snippet variables from. The file or folder must be within your vault, and not within a hidden folder (such as <code>.obsidian/</code>).`});let i=new w.Setting(e).setName("Snippet variables file or folder location").setDesc(n);i.addSearch(O=>{O.setPlaceholder(W.snippetVariablesFileLocation).setValue(this.plugin.settings.snippetVariablesFileLocation).onChange((0,w.debounce)(f=>v(this,null,function*(){this.plugin.settings.snippetVariablesFileLocation=f,yield this.plugin.saveSettings(!0)}),500,!0));let h=O.inputEl;h.addClass("latex-suite-location-input-el"),new It(this.app,h)}),this.snippetVariablesFileLocEl=i.settingEl;let s=this.plugin.settings.loadSnippetVariablesFromFile;r.settingEl.toggleClass("hidden",s),this.snippetVariablesFileLocEl.toggleClass("hidden",!s),new w.Setting(e).setName("Word delimiters").setDesc('Symbols that will be treated as word delimiters, for use with the "w" snippet option.').addText(O=>O.setPlaceholder(W.wordDelimiters).setValue(this.plugin.settings.wordDelimiters).onChange(h=>v(this,null,function*(){this.plugin.settings.wordDelimiters=h,yield this.plugin.saveSettings()}))),new w.Setting(e).setName("Remove trailing whitespaces in snippets in inline math").setDesc("Whether to remove trailing whitespaces when expanding snippets at the end of inline math blocks.").addToggle(O=>O.setValue(this.plugin.settings.removeSnippetWhitespace).onChange(h=>v(this,null,function*(){this.plugin.settings.removeSnippetWhitespace=h,yield this.plugin.saveSettings()}))),new w.Setting(e).setName("Remove closing $ when backspacing inside blank inline math").setDesc("Whether to also remove the closing $ when you delete the opening $ symbol inside blank inline math.").addToggle(O=>O.setValue(this.plugin.settings.autoDelete$).onChange(h=>v(this,null,function*(){this.plugin.settings.autoDelete$=h,yield this.plugin.saveSettings()})));let o=new w.Setting(e).setName("Don't trigger snippets when IME is active").setDesc("Whether to suppress snippets triggering when an IME is active."),a=new w.Setting(e).setName("Suppress IME warning").setDesc("Whether a warning is shown on startup if `Don't trigger snippets when IME is active` is enabled. Disable that setting if you are aware of the IME limitations. Currently only ios and android touch/swipe keyboards like gboard have support for IME. See https://github.com/artisticat1/obsidian-latex-suite/blob/main/DOCS.md#IME-keyboards for more info.").addToggle(O=>O.setValue(this.plugin.settings.suppressIMEWarning).onChange(h=>v(this,null,function*(){this.plugin.settings.suppressIMEWarning=h,yield this.plugin.saveSettings()})));a.settingEl.toggleClass("hidden",!(this.plugin.settings.suppressSnippetTriggerOnIME&&Yr())),o.addToggle(O=>O.setValue(this.plugin.settings.suppressSnippetTriggerOnIME).onChange(h=>v(this,null,function*(){this.plugin.settings.suppressSnippetTriggerOnIME=h,a.settingEl.toggleClass("hidden",!(h&&Yr())),yield this.plugin.saveSettings()}))),new w.Setting(e).setName("Code languages to interpret as math mode").setDesc("Codeblock languages where the whole code block should be treated like a math block, separated by commas.").addText(O=>O.setPlaceholder(W.forceMathLanguages).setValue(this.plugin.settings.forceMathLanguages).onChange(h=>v(this,null,function*(){this.plugin.settings.forceMathLanguages=h,yield this.plugin.saveSettings()}))),new w.Setting(e).setName("Snippet debug mode").setDesc('Set the level of debug information to log about snippet expansion. Set to "info" or "verbose" to help identify issues with snippet syntax or why a snippet is not expanding. Verbose mode will log most information to the developer console on debug level.').addDropdown(O=>O.addOption("off","Off").addOption("info","Info").addOption("verbose","Verbose").setValue(this.plugin.settings.snippetDebug).onChange(h=>v(this,null,function*(){this.plugin.settings.snippetDebug=h,yield this.plugin.saveSettings()})));let l=new w.Setting(e).setName("Vim key bindings").setDesc("turn on/off vim keybindings. Note vim needs to be enabled in obsidian itself."),c=[],p=new w.Setting(e).setName("Vim: Switch from visual mode to select mode").setDesc(`maps the key to switch from visual mode to select mode.
|
||||
Keymap must be a vim keymap and can't contain any spaces. Use empty string to disable this feature.
|
||||
(select mode=insert keybindings)`).addText(O=>O.setPlaceholder(W.vimSelectMode).setValue(this.plugin.settings.vimSelectMode).onChange(h=>v(this,null,function*(){var y;let f=this.plugin.settings.vimSelectMode;this.plugin.settings.vimSelectMode=h,yield this.plugin.saveSettings();let g=(y=window==null?void 0:window.CodeMirrorAdapter)==null?void 0:y.Vim;if(!g)return;let b=di(this.plugin.settings);g[b.defineType](b.id,b.action),g.mapCommand(b.key,b.type,b.id,{},{context:b.context}),g.unmap(f,b.context)})));c.push(p);let u=new w.Setting(e).setName("Vim: Switch from select mode to visual mode").setDesc(`maps the key to switch from select mode to visual mode.
|
||||
must be a vim keymap and can't contain any spaces. Example <C-g><C-A-i> = Ctrl-g + Ctrl-Alt-i.
|
||||
Please check the vim keybinding first on another command like w before reporting it. Some keybindings like shift don't work due to the original vim plugin. Use empty string to disable this feature.
|
||||
(select mode=insert keybindings)`).addText(O=>{O.setPlaceholder(W.vimVisualMode).setValue(this.plugin.settings.vimVisualMode).onChange(h=>v(this,null,function*(){var y;let f=this.plugin.settings.vimVisualMode;this.plugin.settings.vimVisualMode=h,yield this.plugin.saveSettings();let g=fi(this.plugin.settings),b=(y=window==null?void 0:window.CodeMirrorAdapter)==null?void 0:y.Vim;b&&(b[g.defineType](g.id,g.action),b.mapCommand(g.key,g.type,g.id,{},{context:g.context}),b.unmap(f,g.context))}))});c.push(u);let d=new w.Setting(e).setName("Vim: run matrix enter").setDesc(`maps the key to the action of inserting a new line below while appending \\\\ to the current line in a matrix environment.
|
||||
Use empty string to disable this feature.`).addText(O=>{O.setPlaceholder(W.vimMatrixEnter).setValue(this.plugin.settings.vimMatrixEnter).onChange(h=>v(this,null,function*(){var y;let f=this.plugin.settings.vimMatrixEnter;this.plugin.settings.vimMatrixEnter=h,yield this.plugin.saveSettings();let g=(y=window==null?void 0:window.CodeMirrorAdapter)==null?void 0:y.Vim;if(!g)return;g.unmap(f,"normal");let b=mi(this.plugin.settings);g[b.defineType](b.id,b.action),g.mapCommand(b.key,b.type,b.id,{},{context:b.context}),g.unmap(f,b.context)}))});c.push(d),l.addToggle(O=>{let h=this.plugin.settings.vimEnabled&&(app==null?void 0:app.isVimEnabled());c.forEach(f=>f.settingEl.toggleClass("hidden",!h)),O.setValue(this.plugin.settings.vimEnabled&&(app==null?void 0:app.isVimEnabled())).onChange(f=>v(this,null,function*(){var b;this.plugin.settings.vimEnabled=f,yield this.plugin.saveSettings(),c.forEach(y=>y.settingEl.toggleClass("hidden",!f));let g=(b=window==null?void 0:window.CodeMirrorAdapter)==null?void 0:b.Vim;if(g)for(let y of Lr(this.plugin.settings))g.unmap(y.key,y.context)}))})}createSnippetsEditor(e){let r=e.controlEl.createDiv("snippets-editor-wrapper"),n=e.controlEl.createDiv("snippets-footer"),i=n.createDiv("snippets-editor-validity"),s=new w.ExtraButtonComponent(i);s.setIcon("checkmark").extraSettingsEl.addClass("snippets-editor-validity-indicator");let o=i.createDiv("snippets-editor-validity-text");o.addClass("setting-item-description"),o.style.padding="0";function a(O){s.setIcon(O?"checkmark":"cross"),s.extraSettingsEl.removeClass(O?"invalid":"valid"),s.extraSettingsEl.addClass(O?"valid":"invalid"),o.setText(O?"Saved":"Invalid syntax. Changes not saved")}let l=uo,c=gi.EditorView.updateListener.of(O=>v(this,null,function*(){if(O.docChanged){let h=O.state.doc.toString(),f=!0,g;try{g=yield ze(this.plugin.settings.snippetVariables),yield ut(h,g)}catch(b){f=!1}if(a(f),!f)return;this.plugin.settings.snippets=h,yield this.plugin.saveSettings()}}));l.push(c),this.snippetsEditor=Rp(this.plugin.settings.snippets,l),r.appendChild(this.snippetsEditor.dom);let p=n.createDiv("snippets-editor-buttons");new w.ButtonComponent(p).setIcon("switch").setTooltip("Reset to default snippets").onClick(()=>v(this,null,function*(){new Fr(this.plugin.app,"Are you sure? This will delete any custom snippets you have written.",O=>O.setButtonText("Reset to default snippets").setWarning(),()=>v(this,null,function*(){this.snippetsEditor.setState(Ur.EditorState.create({doc:At,extensions:l})),a(!0),this.plugin.settings.snippets=At,yield this.plugin.saveSettings()})).open()})),new w.ButtonComponent(p).setIcon("trash").setTooltip("Remove all snippets").onClick(()=>v(this,null,function*(){new Fr(this.plugin.app,"Are you sure? This will delete any custom snippets you have written.",O=>O.setButtonText("Remove all snippets").setWarning(),()=>v(this,null,function*(){let O=`[
|
||||
|
||||
]`;this.snippetsEditor.setState(Ur.EditorState.create({doc:O,extensions:l})),a(!0),this.plugin.settings.snippets=O,yield this.plugin.saveSettings()})).open()}))}createTriggerSetting(e,r,n){return new w.Setting(e).setName(`Key trigger for ${r}`).setDesc(Ap(r)).addText(i=>i.setValue(this.plugin.settings[n]).setPlaceholder(W[n]).onChange(s=>v(this,null,function*(){gn(s),this.plugin.settings[n]=s,yield this.plugin.saveSettings()})))}},Fr=class extends w.Modal{constructor(e,r,n,i){super(e),this.contentEl.addClass("latex-suite-confirmation-modal"),this.contentEl.createEl("p",{text:r}),new w.Setting(this.contentEl).addButton(s=>{n(s),s.onClick(()=>v(this,null,function*(){yield i(),this.close()}))}).addButton(s=>s.setButtonText("Cancel").onClick(()=>this.close()))}};function Rp(t,e){return new gi.EditorView({state:Ur.EditorState.create({doc:t,extensions:e})})}function Yr(){return w.Platform.isMobileApp}function Ap(t){let e=new DocumentFragment,r=e.createDiv();return r.innerHTML=`What key to press to trigger ${t}. Should follow codemirror keymap syntax such as "Ctrl-k Ctrl-a". For more info see <a href="https://codemirror.net/docs/ref/#view.KeyBinding">codemirror keymap documentation</a>.`,e}var Uo={math:`<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-math" width="100" height="100" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M19 5h-7l-4 14l-3 -6h-2"></path>
|
||||
<path d="M14 13l6 6"></path>
|
||||
<path d="M14 19l6 -6"></path>
|
||||
</svg>`,"math-x-divide-y-2":`<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-math-x-divide-y-2" width="100" height="100" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M3 21l18 -18"></path>
|
||||
<path d="M15 14l3 4.5"></path>
|
||||
<path d="M21 14l-4.5 7"></path>
|
||||
<path d="M3 4l6 6"></path>
|
||||
<path d="M3 10l6 -6"></path>
|
||||
</svg>`,parentheses:`<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-parentheses" width="100" height="100" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M7 4a12.25 12.25 0 0 0 0 16"></path>
|
||||
<path d="M17 4a12.25 12.25 0 0 1 0 16"></path>
|
||||
</svg>`,"math-function":`<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-math-function" width="100" height="100" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M3 19a2 2 0 0 0 2 2c2 0 2 -4 3 -9s1 -9 3 -9a2 2 0 0 1 2 2"></path>
|
||||
<path d="M5 12h6"></path>
|
||||
<path d="M15 12l6 6"></path>
|
||||
<path d="M15 18l6 -6"></path>
|
||||
</svg>`,"math-integral-x":`<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-math-integral-x" width="100" height="100" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M3 19a2 2 0 0 0 2 2c2 0 2 -4 3 -9s1 -9 3 -9a2 2 0 0 1 2 2"></path>
|
||||
<path d="M14 12l6 6"></path>
|
||||
<path d="M14 18l6 -6"></path>
|
||||
</svg>`,"brackets-contain":`<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brackets-contain" width="100" height="100" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M7 4h-4v16h4"></path>
|
||||
<path d="M17 4h4v16h-4"></path>
|
||||
<path d="M8 16h.01"></path>
|
||||
<path d="M12 16h.01"></path>
|
||||
<path d="M16 16h.01"></path>
|
||||
</svg>`,"code-dots":`<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-code-dots" width="100" height="100" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M15 12h.01"></path>
|
||||
<path d="M12 12h.01"></path>
|
||||
<path d="M9 12h.01"></path>
|
||||
<path d="M6 19a2 2 0 0 1 -2 -2v-4l-1 -1l1 -1v-4a2 2 0 0 1 2 -2"></path>
|
||||
<path d="M18 19a2 2 0 0 0 2 -2v-4l1 -1l-1 -1v-4a2 2 0 0 0 -2 -2"></path>
|
||||
</svg>`,ballpen:`<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-ballpen" width="100" height="100" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M14 6l7 7l-4 4"></path>
|
||||
<path d="M5.828 18.172a2.828 2.828 0 0 0 4 0l10.586 -10.586a2 2 0 0 0 0 -2.829l-1.171 -1.171a2 2 0 0 0 -2.829 0l-10.586 10.586a2.828 2.828 0 0 0 0 4z"></path>
|
||||
<path d="M4 20l1.768 -1.768"></path>
|
||||
</svg>`,superscript:`<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-superscript" width="100" height="100" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M5 7l8 10m-8 0l8 -10"></path>
|
||||
<path d="M21 11h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"></path>
|
||||
</svg>`,tabout:`<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 10.583 10.583">
|
||||
<g style="fill:none;stroke:currentColor;stroke-width:3.22892904;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none">
|
||||
<path d="M14.818 22.164h-.688c-1.52 0-3.983-1.82-3.983-4.066V-.612c0-2.245 2.462-4.065 3.983-4.065h.688" style="stroke-width:3.22892904;stroke-miterlimit:4;stroke-dasharray:none" transform="translate(6.566 2.931) scale(.24373)"/>
|
||||
<path d="M5.605 22.16h.662c1.462 0 3.88-1.906 3.88-4.258v-1.065M5.605-4.674h.662c1.462 0 3.88 1.907 3.88 4.259V.65" style="stroke-width:3.22892904;stroke-miterlimit:4;stroke-dasharray:none" transform="translate(6.566 2.931) scale(.24373)"/>
|
||||
</g>
|
||||
<g style="fill:none;stroke:currentColor;stroke-width:3.22892904;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none">
|
||||
<path d="M0 0h24v24H0Z" style="fill:none;stroke:none;stroke-width:3.22892904;stroke-miterlimit:4;stroke-dasharray:none" transform="translate(2.662 4.719) scale(.24373)" stroke="none"/>
|
||||
<path d="M-9.136 8.694v5.17a1 1 0 0 0 1 1h23.658a1 1 0 0 0 1-1v-5.17" style="stroke-width:3.22892904;stroke-miterlimit:4;stroke-dasharray:none" transform="translate(2.662 4.719) scale(.24373)"/>
|
||||
</g>
|
||||
</svg>
|
||||
`};var nn=require("@codemirror/view");var me=require("@codemirror/view"),it=require("@codemirror/state");var Hr=require("obsidian");function H(...t){return t}var bi=class extends me.WidgetType{constructor(r,n,i){super();this.symbol=r;this.className=n||"",this.elementType=i||"span"}eq(r){return r.symbol==this.symbol&&r.className===this.className&&r.elementType===this.elementType}toDOM(){let r=document.createElement(this.elementType);return r.className="cm-math "+this.className,r.textContent=this.symbol,r}ignoreEvent(){return!1}},yi=class extends me.WidgetType{constructor(r){super();this.symbol=r}eq(r){return r.symbol==this.symbol}toDOM(){let r=document.createElement("span");return r.className="cm-math",r.textContent=this.symbol,r}ignoreEvent(){return!1}};function qp(t,e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;++n){let i=t.changes.mapPos(e[n].start,1),s=t.changes.mapPos(e[n].end,-1);if(!(i==r[n].start&&s==r[n].end))return!1}return!0}function jp(t,e){let r="apart";for(let n of t.ranges)for(let i of e){let s=Math.max(n.from,i.start),o=Math.min(n.to,i.end);if(s===o&&(s===i.start||s===i.end)){r="edge";continue}if(s<=o)return"within"}return r}function Zp(t,e,r,n){return r||e==="apart"?"conceal":e==="within"||!n||!t||t==="within"?"reveal":"delay"}function No(t){let e=[];for(let r of t)if(r.enable)for(let n of r.spec)if(n.start===n.end)e.push(me.Decoration.widget({widget:new yi(n.text),block:!1}).range(n.start,n.end));else{let i=n.text==="";e.push(me.Decoration.replace({widget:new bi(n.text,n.class,n.elementType),inclusiveStart:i,inclusiveEnd:!1,block:!1}).range(n.start,n.end))}return me.Decoration.set(e,!0)}function Fo(t){let e=t.filter(i=>i.enable).flatMap(i=>i.spec).sort((i,s)=>i.start-s.start),r=new class extends it.RangeValue{},n=new it.RangeSetBuilder;for(let i=0;i<e.length;i++)e[i].text===""?i+1!=e.length&&e[i].end==e[i+1].start?(n.add(e[i].start,e[i+1].end,r),i++):n.add(e[i].start,e[i].end+1,r):n.add(e[i].start,e[i].end,r);return n.finish()}var Yo=me.ViewPlugin.fromClass(class{constructor(t){this.delayedRevealCallback=(t,e)=>{var r;for(let n of t)n.enable=!1;this.decorations=No(this.concealments),this.atomicRanges=Fo(this.concealments),e.dispatch(),(r=e==null?void 0:e.cm)==null||r.signal("vim-command-done")};this.concealments=[],this.decorations=me.Decoration.none,this.atomicRanges=it.RangeSet.empty;let e=X(t).concealRevealTimeout;this.delayEnabled=e>0,this.cached_equations={},this.concealSpecs=[],this.delayedReveal=(0,Hr.debounce)(this.delayedRevealCallback,e,!0),this.update({view:t,state:t.state,docChanged:!0})}update(t){if(t.docChanged||t.viewportChanged||t.selectionSet)if(this.delayedReveal.cancel(),!t.docChanged&&!t.viewportChanged)this.updateFromConcealSpecs(this.concealSpecs,t);else{let{specs:e,cached_equations:r}=Ho(t.view,this.cached_equations);this.cached_equations=r,this.concealSpecs=e,this.updateFromConcealSpecs(e,t)}}updateFromConcealSpecs(t,e){var o,a;let r=e.state.selection,n=(a=(o=e.view.plugin(Hr.livePreviewState))==null?void 0:o.mousedown)!=null?a:!1,i=[],s=[];for(let l of t){let c=jp(r,l),p=this.concealments.find(O=>qp(e,O.spec,l)),u=Zp(p==null?void 0:p.cursorPosType,c,n,this.delayEnabled),d={spec:l,cursorPosType:c,enable:u!=="reveal"};u==="delay"&&s.push(d),i.push(d)}s.length>0&&this.delayedReveal(s,e.view),this.concealments=i,this.decorations=No(this.concealments),this.atomicRanges=Fo(this.concealments)}},{decorations:t=>t.decorations,provide:t=>me.EditorView.atomicRanges.of(e=>{var r,n;return(n=(r=e.plugin(t))==null?void 0:r.atomicRanges)!=null?n:it.RangeSet.empty})});var Ko={aleph:"\u2135",amalg:"\u2A3F",And:"&",angle:"\u2220",approx:"\u2248",approxeq:"\u224A",ast:"\u2217",asymp:"\u224D",backepsilon:"\u220D",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",backslash:"\u2216",barwedge:"\u22BC",Bbbk:"k",because:"\u2235",beth:"\u2136",between:"\u226C",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",blacklozenge:"\u29EB",blacksquare:"\u25FC",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",bot:"\u22A5",bowtie:"\u22C8",Box:"\u25FB",boxdot:"\u22A1",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",bullet:"\u2219",bumpeq:"\u224F",Bumpeq:"\u224E",Cap:"\u22D2",cap:"\u2229",cdot:"\u22C5",cdotp:"\u22C5",cdots:"\u22EF",celsius:"\u2103",centerdot:"\u22C5",checkmark:"\u2713",circ:"\u2218",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",circledR:"\xAE",circledS:"\u24C8",clubsuit:"\u2663",complement:"\u2201",cong:"\u2245",coprod:"\u2210",copyright:"\xA9",cp:"\xD7",cross:"\xD7",crossproduct:"\xD7",Cup:"\u22D3",cup:"\u222A",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",da
Line truncated
|
||||
`),o=r[0][0]===`
|
||||
`?" ":"",a=r.index+r[0].length-1,l=n+1;e.push(H({start:s,end:a,text:o},{start:a,end:a+1,text:"(",class:"cm-bracket"},{start:n,end:n+1,text:")",class:"cm-bracket"},{start:n+1,end:n+1,text:"/",class:"cm-bracket"},{start:l,end:l+1,text:"(",class:"cm-bracket"},{start:i,end:i+1,text:")",class:"cm-bracket"}))}return e}function Up(t){let e="\\\\operatorname{([A-Za-z]+)}",r=new RegExp(e,"g"),n=[...t.matchAll(r)],i=[];for(let s of n){let o=s[1],a=s.index,l=a+s[0].length;i.push(H({start:a,end:l,text:o,class:"cm-concealed-mathrm cm-variable-2"}))}return i}function Ho(t,e){let r=nt(t).getEquations(t.state),n={};for(let s of r.values()){if(s in e){n[s]=e[s];continue}let o=[...Tt(s,"\\^","",ra),...Tt(s,"_","",na),...Tt(s,"\\\\frac","",ta),...Wp(s,Qi,Xp),...aa(s,!0,Qi),...aa(s,!1,Qi),...st(s,"hat","\u0302"),...st(s,"dot","\u0307"),...st(s,"ddot","\u0308"),...st(s,"overline","\u0304"),...st(s,"bar","\u0304"),...st(s,"tilde","\u0303"),...st(s,"vec","\u20D7"),...Tt(s,"\\\\","",ia,"cm-bracket"),...Bp(s,"\\\\mathcal{","}",oa),...Ip(s,xi),...Vp(s,sa),...Mp(s),...Dp(s),...zp(s),...Lp(s),...Gp(s,ea),...Up(s)];n[s]=o}e=n;let i=[];for(let[s,o]of r.entries())for(let a of n[o])i.push(a.map(l=>ye(oe({},l),{start:l.start+s,end:l.end+s})));return{specs:i,cached_equations:e}}function Si(t,e){return t.includes(e)}function ca(t,e){return e in t}var ua=["\\big","\\Big","\\bigg","\\Bigg","\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\left","\\right"],Oa=["{","}"],Kr={"(":")","[":"]","\\{":"\\}","\\langle":"\\rangle","\\lvert":"\\rvert","\\lVert":"\\rVert","\\lceil":"\\rceil","\\lfloor":"\\rfloor"},Np=[...ua,...Object.keys(Kr),...Object.values(Kr)],Fp=[...Np.map(wt).sort((t,e)=>t.length-e.length),...Oa.map(wt)].join("|"),pa=new RegExp(Fp,"g"),Yp=Object.fromEntries(Object.entries(Kr).map(([t,e])=>[e,t])),Jr=t=>{let e=X(t);if(!e.autoEnlargeBrackets)return;let n=I(t).getBounds();if(!n)return!1;let{inner_start:i,inner_end:s}=n,o=t.state.sliceDoc(i,s),a="\\left",l="\\right",c=[],p,u=null;pa.lastIndex=0;let d=0,O=[d];for(;(p=pa.exec(o))!==null;){let h=p[0],f=p.index;if(Si(ua,h)){u=f+h.length;continue}else if(Si(Oa,h)){h==="{"?O.push(++d):O.length>1&&O.pop();continue}else if(ca(Kr,h)){u===null||/\S/.test(o.slice(u,f))?c.push({index:f,match:h,level:O[O.length-1]}):u!==null&&c.push({match:h,ignore:!0,level:O[O.length-1]}),u=null;continue}let g=u!==null&&!/\S/.test(o.slice(u,f));u=null;let b=Yp[h];for(let y=c.length-1;y>=0;y--){let x=c[y];if(x.match===b&&("ignore"in x||g)){c.splice(y,1);break}if("ignore"in x||x.level!==O[O.length-1]||x.match!==b)continue;let S=x.index,Q=x.match,m=S+Q.length,T=p.index,C=o.slice(m,T);if(!e.autoEnlargeBracketsTriggers.some(k=>C.contains(k)))break;qe(t,i+S,i+m,a+Q+" "),qe(t,i+T,i+T+h.length," "+l+h),c.splice(y,1);break}}Ge(t)};var ha=require("obsidian"),en=null,$i=(t,e,r,n)=>{let i=!1;for(let o of e.ranges)Hp(t,e,r,o,n).shouldAutoEnlargeBrackets&&(i=!0);let s=Ge(t);return i&&Jr(t),s},Hp=(t,e,r,n,i)=>{var d;let s=X(t),{from:o,to:a}=n,l=t.state.sliceDoc(o,a),c=t.state.sliceDoc(0,a),p=(d=r.key)!=null?d:"";if(r.key&&r.key.length!==1)return{success:!1,shouldAutoEnlargeBrackets:!1};let u=c+p;for(let O=0;O<r.snippets.length;O++){let h=r.snippets[O];if(!Kp(h.options,e.mode))continue;let f=h.process(u,n,l);if(f===null)continue;let g=!1;for(let m of h.excludedEnvironments)e.isWithinEnvironment(a,m)&&(g=!0);if(g)continue;let b=f.triggerPos;if(h.options.onWordBoundary&&!Jp(t.state,b,a,s.wordDelimiters))continue;let y=f.replacement;e.mode.inlineMath&&s.removeSnippetWhitespace&&(y=eu(y,e));let x=b,S=h.options.automatic&&h.type!=="visual"?p:void 0;qe(t,x,a,y,S);let Q=s.autoEnlargeBracketsTriggers.some(m=>y.contains(m));if(i==="info"||i==="verbose"){let m=h.trigger.toString(),T=h.triggerKey?`<li>Trigger key: ${new Option(h.triggerKey).innerHTML}
|
||||
</li>`:"",C=h.description,E=`Latex Suite: <br><ul><li>Description: ${new Option(C).innerHTML}
|
||||
</li><li>Parsed trigger: <code>${new Option(m).innerHTML}</code>
|
||||
</li>`+T+`<li>Replacement: <code>${new Option(y).innerHTML}</code>
|
||||
</li><li>Auto-enlarge brackets: ${Q}
|
||||
</li></ul>`,k=new DocumentFragment,P=k.createDiv();P.innerHTML=E,en==null||en.hide(),en=new ha.Notice(k,5e3),console.info(P.textContent)}return i==="verbose"&&console.debug({snippets_unexpanded:r.snippets.slice(0,O).map(m=>({description:m.description,trigger:m.trigger,options:m.options,replacement:m.replacement})),current_mode:e.mode,updatedLine:u}),{success:!0,shouldAutoEnlargeBrackets:Q}}return{success:!1,shouldAutoEnlargeBrackets:!1}},Kp=(t,e)=>{if((t.mode.inlineMath&&e.inlineMath||t.mode.blockMath&&e.blockMath||(t.mode.inlineMath||t.mode.blockMath)&&e.codeMath)&&!e.textEnv||e.inMath()&&e.textEnv&&t.mode.text||t.mode.text&&e.text||t.mode.code===e.code&&e.code!==!1||t.mode.code===!0&&e.code!==!1)return!0},Jp=(t,e,r,n)=>{let i=t.sliceDoc(e-1,e),s=t.sliceDoc(r,r+1);return n=n.replace("\\n",`
|
||||
`),n.contains(i)&&n.contains(s)},eu=(t,e)=>{let r=0;if(t.endsWith(" "))r=-1;else{let n=t.slice(-3),i=n.slice(-1);n.slice(0,2)===" $"&&!isNaN(parseInt(i))&&(r=-3)}return r!=0&&(r===-1?t=t.trimEnd():r===-3&&(t=t.slice(0,-3)+t.slice(-2))),t};var da=(t,e)=>{for(let n of e.ranges)tu(t,e,n);let r=Ge(t);return r&&Jr(t),r},tu=(t,e,r)=>{let n=X(t),{from:i,to:s}=r;for(let O of n.autofractionExcludedEnvs)if(e.isWithinEnvironment(s,O))return!1;let o=e.getBounds();if(!o)return!1;let a=o.inner_start,l=t.state.sliceDoc(0,s),c=a;if(i!=s)c=i;else{let O="alpha|beta|gamma|Gamma|delta|Delta|epsilon|varepsilon|zeta|eta|theta|Theta|iota|kappa|lambda|Lambda|mu|nu|omicron|xi|Xi|pi|Pi|rho|sigma|Sigma|tau|upsilon|Upsilon|varphi|phi|Phi|chi|psi|Psi|omega|Omega",h=new RegExp("("+O+") ([^ ])","g");l=l.replace(h,"$1#$2");for(let f=l.length-1;f>=a;f--){let g=l.charAt(f);if([")","]","}"].contains(g)){let b=g,y=Lt(b),x=J(l,f,y,b,!0);if(x===-1)return!1;if(f=x,f<a){c=a;break}}if(` $([{
|
||||
`.concat(n.autofractionBreakingChars).contains(g)){c=f+1;break}}}if(c===s)return!1;let p=t.state.sliceDoc(c,s);p.at(0)==="("&&p.at(-1)===")"&&J(p,0,"(",")",!1)===p.length-1&&(p=p.slice(1,-1));let u=p===""?`${n.autofractionSymbol}{$0}{$1}$2`:`${n.autofractionSymbol}{${p}}{$0}$1`,d=i!=s?void 0:"/";return qe(t,c,s,u,d),!0};var rn=require("@codemirror/view"),kt=require("@codemirror/state"),Pt=require("obsidian");var fa=require("@codemirror/language"),vi=kt.StateEffect.define(),tn=kt.StateField.define({create:()=>[],update(t,e){for(let r of e.effects)if(r.is(vi))return r.value;return t},provide:t=>rn.showTooltip.computeN([t],e=>e.field(t).map(r=>r.tooltip))}),ru=(t,e,r,n)=>{let i=(l,c,p,u,d)=>{let O=0;for(let h=c;h>=0&&h<l.length;h+=d)if(l[h]===p&&O++,l[h]===u){if(O===0)return h;O--}return-1},s=t[e]===n?e-1:e,o=i(t,s,n,r,-1),a=i(t,e,r,n,1);return{left:o,right:a}};function ma(t){if(!(t.docChanged||t.selectionSet))return;let r=X(t.state),n=I(t.view),i=nu(t.state,n);if(!i){t.state.field(tn).length>0&&t.view.dispatch({effects:[vi.of([])]});return}let s=t.state.sliceDoc(i.inner_start,i.inner_end),o=n.pos,l=(0,fa.syntaxTree)(t.state).cursor();l.moveTo(o,-1);let c;l.name==="math_tag"&&l.from<o&&l.to>=o?c=l.from:c=o;let p=c-i.inner_start,u,d=s.replaceAll(/\\[\\{}]/g,"\\R"),{left:O,right:h}=r.mathPreviewBracketHighlighting?ru(d,p,"{","}"):{left:-1,right:-1};if(h!==-1&&O!==-1){let x=Math.max(O+1,p);u=s.slice(0,O+1)+"\\style{background-color: var(--latex-suite-math-preview-highlight);}{"+s.slice(O+1,x)+r.mathPreviewCursor+s.slice(x,h)+"}"+s.slice(h)}else u=s.slice(0,p)+r.mathPreviewCursor+s.slice(p);let f=t.state.field(tn);if(f.length===1&&f[0].equation===u&&f[0].bounds.inner_start===i.inner_start&&f[0].bounds.inner_end===i.inner_end)return;let g=r.mathPreviewPositionIsAbove,b=()=>{var S;let x=document.createElement("div");if(x.addClass("cm-tooltip-cursor"),x.addClass(g?"cm-tooltip-above":"cm-tooltip-below"),n.mode.blockMath){let Q=(S=t.state.doc.lineAt(i.inner_start).text.match(/^ {0,3}(>+)/))==null?void 0:S[1].length;if(Q){let m=new RegExp(`^ {0,3}>{${Q}}`,"gm");m.test(s)&&(u=u.replaceAll(m,""))}}try{let Q=(0,Pt.renderMath)(u,n.mode.blockMath||n.mode.codeMath),m=Q.querySelector('[style*="background-color: var(--latex-suite-math-preview-highlight)"]');m==null||m.addClass("latex-suite-math-preview-highlight"),m==null||m.style.removeProperty("background-color"),x.appendChild(Q),(0,Pt.finishRenderMath)()}catch(Q){console.error("Error rendering math in tooltip:",Q),x.textContent=s}return{dom:x}},y=[];if(n.mode.blockMath||n.mode.codeMath)y=[{pos:g?i.inner_start:i.inner_end,above:g,strictSide:!0,arrow:!0,create:b}];else if(n.mode.inlineMath&&g)y=[{pos:i.inner_start,above:!0,strictSide:!0,arrow:!0,create:b}];else if(n.mode.inlineMath&&!g){let x=kt.EditorSelection.range(i.inner_end,i.inner_end);y=[{pos:Math.max(i.inner_start,t.view.moveToLineBoundary(x,!1).anchor),above:!1,strictSide:!0,arrow:!0,create:b}]}t.view.dispatch({effects:[vi.of(y.map(x=>({equation:u,bounds:i,pos:x.pos,tooltip:x})))]})}function nu(t,e){if(!e.mode.inMath())return null;let r=t.field(Pt.editorLivePreviewField);if(e.mode.blockMath&&r)return null;let n=e.getBounds();return!n||t.sliceDoc(n.inner_start,n.inner_end).trim()===""?null:n}var ga=rn.EditorView.baseTheme({".cm-tooltip.cm-tooltip-cursor":{backgroundColor:"var(--background-secondary)",color:"var(--text-normal)",border:"1px solid var(--background-modifier-border-hover)",padding:"4px 6px",borderRadius:"6px","& .cm-tooltip-arrow:before":{borderTopColor:"var(--background-modifier-border-hover)",borderBottomColor:"var(--background-modifier-border-hover)"},"& .cm-tooltip-arrow:after":{borderTopColor:"var(--background-secondary)",borderBottomColor:"var(--background-secondary)"},"& p":{margin:"0px"},"& mjx-container":{padding:"2px !important"}}});var ba=t=>{X(t.state).mathPreviewEnabled&&ma(t),qo(t)},sn=nn.ViewPlugin.fromClass(class{constructor(){this.lastKeyboardEvent=null}onKeydown(t,e){if(t.key=="Unidentified"||t.key=="Process"||t.key=="Dead"){this.lastKeyboardEvent=t;return}else this.lastKeyboardEvent=null;(xa(t.key,t.ctrlKey||t.metaKey,Jn(e,t),e)||(0,nn.runScopeHandlers)(e,t,"latex-suite"))&&t.preventDefault()}},{eventHandlers:{keydown(t,e){e.plugin(sn).onKeydown(t,e)}}}),ya=(t,e,r,n)=>{var s;let i=(s=t.plugin(sn))==null?void 0:s.lastKeyboardEvent;return n==="\0\0"?!0:n.length==1&&i&&(n===" "&&(n="Tab"),xa(n,i.ctrlKey||i.metaKey,Jn(t,i),t))?(mo(t),!0):!1},xa=(t,e,r,n)=>{if(t.length>1)return!1;let i=X(n),s=I(n);if(!i.snippetsEnabled||i.suppressSnippetTriggerOnIME&&r||e)return!1;let o=i.snippets.filter(a=>a.options.automatic);try{if($i(n,s,{snippets:o,key:t},i.snippetDebug))return!0}catch(a){Qt(n),console.error(a)}return!1};function Qa(t){let e=[];t.autoDelete$&&e.push({key:"Backspace",run:function(a){if(!X(a).autoDelete$)return!1;let l=I(a);if(!l.mode.strictlyInMath())return!1;let c=zt(a,l.pos),p=zt(a,l.pos-1);return c==="$"&&p==="$"?(jr(a,l.pos-1,l.pos+1,""),Br(a),!0):!1}});let r=new Set(t.snippets.map(o=
Line truncated
|
||||
|
||||
/* nosourcemap */
|
||||
Reference in new issue
Block a user