47 lines
268 KiB
JavaScript
47 lines
268 KiB
JavaScript
|
/*
|
||
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||
|
if you want to view the source visit the plugins github repository (https://github.com/phibr0/obsidian-dictionary)
|
||
|
*/
|
||
|
|
||
|
var vr=Object.create;var qe=Object.defineProperty;var xr=Object.getOwnPropertyDescriptor;var wr=Object.getOwnPropertyNames;var br=Object.getPrototypeOf,Sr=Object.prototype.hasOwnProperty;var $t=n=>qe(n,"__esModule",{value:!0});var Ye=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Cr=(n,e)=>{$t(n);for(var t in e)qe(n,t,{get:e[t],enumerable:!0})},jr=(n,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of wr(e))!Sr.call(n,i)&&i!=="default"&&qe(n,i,{get:()=>e[i],enumerable:!(t=xr(e,i))||t.enumerable});return n},G=n=>jr($t(qe(n!=null?vr(br(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var M=(n,e,t)=>new Promise((i,r)=>{var o=l=>{try{s(t.next(l))}catch(c){r(c)}},a=l=>{try{s(t.throw(l))}catch(c){r(c)}},s=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,a);s((t=t.apply(n,e)).next())});var fi=Ye((_a,rt)=>{var $n,Gn,qn,Yn,Jn,Kn,Qn,Xn,Zn,nt,Dt,ei,ti,ni,Ee,ii,ri,oi,ai,si,li,ci,ui,di,it;(function(n){var e=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(i){n(t(e,t(i)))}):typeof rt=="object"&&typeof rt.exports=="object"?n(t(e,t(rt.exports))):n(t(e));function t(i,r){return i!==e&&(typeof Object.create=="function"?Object.defineProperty(i,"__esModule",{value:!0}):i.__esModule=!0),function(o,a){return i[o]=r?r(o,a):a}}})(function(n){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(i[o]=r[o])};$n=function(i,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(i,r);function o(){this.constructor=i}i.prototype=r===null?Object.create(r):(o.prototype=r.prototype,new o)},Gn=Object.assign||function(i){for(var r,o=1,a=arguments.length;o<a;o++){r=arguments[o];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])}return i},qn=function(i,r){var o={};for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&r.indexOf(a)<0&&(o[a]=i[a]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,a=Object.getOwnPropertySymbols(i);s<a.length;s++)r.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(i,a[s])&&(o[a[s]]=i[a[s]]);return o},Yn=function(i,r,o,a){var s=arguments.length,l=s<3?r:a===null?a=Object.getOwnPropertyDescriptor(r,o):a,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(i,r,o,a);else for(var u=i.length-1;u>=0;u--)(c=i[u])&&(l=(s<3?c(l):s>3?c(r,o,l):c(r,o))||l);return s>3&&l&&Object.defineProperty(r,o,l),l},Jn=function(i,r){return function(o,a){r(o,a,i)}},Kn=function(i,r){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,r)},Qn=function(i,r,o,a){function s(l){return l instanceof o?l:new o(function(c){c(l)})}return new(o||(o=Promise))(function(l,c){function u(y){try{p(a.next(y))}catch(g){c(g)}}function f(y){try{p(a.throw(y))}catch(g){c(g)}}function p(y){y.done?l(y.value):s(y.value).then(u,f)}p((a=a.apply(i,r||[])).next())})},Xn=function(i,r){var o={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,s,l,c;return c={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(p){return function(y){return f([p,y])}}function f(p){if(a)throw new TypeError("Generator is already executing.");for(;c&&(c=0,p[0]&&(o=0)),o;)try{if(a=1,s&&(l=p[0]&2?s.return:p[0]?s.throw||((l=s.return)&&l.call(s),0):s.next)&&!(l=l.call(s,p[1])).done)return l;switch(s=0,l&&(p=[p[0]&2,l.value]),p[0]){case 0:case 1:l=p;break;case 4:return o.label++,{value:p[1],done:!1};case 5:o.label++,s=p[1],p=[0];continue;case 7:p=o.ops.pop(),o.trys.pop();continue;default:if(l=o.trys,!(l=l.length>0&&l[l.length-1])&&(p[0]===6||p[0]===2)){o=0;continue}if(p[0]===3&&(!l||p[1]>l[0]&&p[1]<l[3])){o.label=p[1];break}if(p[0]===6&&o.label<l[1]){o.label=l[1],l=p;break}if(l&&o.label<l[2]){o.label=l[2],o.ops.push(p);break}l[2
|
||
|
# {{notice}}
|
||
|
aliases: ["{{word}}"]
|
||
|
---
|
||
|
|
||
|
# {{word}}
|
||
|
|
||
|
## {{pronunciationHeader}}
|
||
|
|
||
|
{{phoneticList}}
|
||
|
|
||
|
## {{meaningHeader}}
|
||
|
|
||
|
{{meanings}}
|
||
|
|
||
|
## {{originHeader}}
|
||
|
|
||
|
{{origin}}
|
||
|
`,languageSpecificSubFolders:!1};function T(){}var _e=n=>n;function Dr(n){return n&&typeof n=="object"&&typeof n.then=="function"}function yt(n){return n()}function xn(){return Object.create(null)}function de(n){n.forEach(yt)}function ge(n){return typeof n=="function"}function Q(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}var Je;function mt(n,e){return Je||(Je=document.createElement("a")),Je.href=e,n===Je.href}function wn(n){return Object.keys(n).length===0}function bn(n){return n&&ge(n.destroy)?n.destroy:T}var Sn=typeof window!="undefined",Cn=Sn?()=>window.performance.now():()=>Date.now(),gt=Sn?n=>requestAnimationFrame(n):T;var Oe=new Set;function jn(n){Oe.forEach(e=>{e.c(n)||(Oe.delete(e),e.f())}),Oe.size!==0&>(jn)}function An(n){let e;return Oe.size===0&>(jn),{promise:new Promise(t=>{Oe.add(e={c:n,f:t})}),abort(){Oe.delete(e)}}}var Dn=!1;function Ir(){Dn=!0}function Mr(){Dn=!1}function S(n,e){n.appendChild(e)}function X(n,e,t){let i=vt(n);if(!i.getElementById(e)){let r=A("style");r.id=e,r.textContent=t,In(i,r)}}function vt(n){if(!n)return document;let e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function Or(n){let e=A("style");return In(vt(n),e),e.sheet}function In(n,e){return S(n.head||n,e),e.sheet}function N(n,e,t){n.insertBefore(e,t||null)}function P(n){n.parentNode&&n.parentNode.removeChild(n)}function ee(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function A(n){return document.createElement(n)}function R(n){return document.createTextNode(n)}function F(){return R(" ")}function ce(){return R("")}function Y(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function b(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Pr(n){return Array.from(n.childNodes)}function W(n,e){e=""+e,n.wholeText!==e&&(n.data=e)}function xt(n,e){n.value=e==null?"":e}function ze(n,e,t,i){t===null?n.style.removeProperty(e):n.style.setProperty(e,t,i?"important":"")}function re(n,e,t){n.classList[t?"add":"remove"](e)}function Nr(n,e,{bubbles:t=!1,cancelable:i=!1}={}){let r=document.createEvent("CustomEvent");return r.initCustomEvent(n,t,i,e),r}var Ke=new Map,Qe=0;function Er(n){let e=5381,t=n.length;for(;t--;)e=(e<<5)-e^n.charCodeAt(t);return e>>>0}function Fr(n,e){let t={stylesheet:Or(e),rules:{}};return Ke.set(n,t),t}function wt(n,e,t,i,r,o,a,s=0){let l=16.666/i,c=`{
|
||
|
`;for(let m=0;m<=1;m+=l){let x=e+(t-e)*o(m);c+=m*100+`%{${a(x,1-x)}}
|
||
|
`}let u=c+`100% {${a(t,1-t)}}
|
||
|
}`,f=`__svelte_${Er(u)}_${s}`,p=vt(n),{stylesheet:y,rules:g}=Ke.get(p)||Fr(p,n);g[f]||(g[f]=!0,y.insertRule(`@keyframes ${f} ${u}`,y.cssRules.length));let v=n.style.animation||"";return n.style.animation=`${v?`${v}, `:""}${f} ${i}ms linear ${r}ms 1 both`,Qe+=1,f}function bt(n,e){let t=(n.style.animation||"").split(", "),i=t.filter(e?o=>o.indexOf(e)<0:o=>o.indexOf("__svelte")===-1),r=t.length-i.length;r&&(n.style.animation=i.join(", "),Qe-=r,Qe||kr())}function kr(){gt(()=>{Qe||(Ke.forEach(n=>{let{ownerNode:e}=n.stylesheet;e&&P(e)}),Ke.clear())})}var Ve;function fe(n){Ve=n}function Mn(){if(!Ve)throw new Error("Function called outside component initialization");return Ve}function Re(n){Mn().$$.on_mount.push(n)}var Ue=[];var ve=[],Xe=[],On=[],Lr=Promise.resolve(),St=!1;function Tr(){St||(St=!0,Lr.then(jt))}function oe(n){Xe.push(n)}var Ct=new Set,Ze=0;function jt(){let n=Ve;do{for(;Ze<Ue.length;){let e=Ue[Ze];Ze++,fe(e),_r(e.$$)}for(fe(null),Ue.length=0,Ze=0;ve.length;)ve.pop()();for(let e=0;e<Xe.length;e+=1){let t=Xe[e];Ct.has(t)||(Ct.add(t),t())}Xe.length=0}while(Ue.length);for(;On.length;)On.pop()();St=!1,Ct.clear(),fe(n)}function _r(n){if(n.fragment!==null){n.update(),de(n.before_update);let e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(oe)}}var He;function Pn(){return He||(He=Promise.resolve(),He.then(()=>{He=null})),He}function Be(n,e,t){n.dispatchEvent(Nr(`${e?"intro":"outro"}${t}`))}var et=new Set,pe;function ae(){pe={r:0,c:[],p:pe}}function se(){pe.r||de(pe.c),pe=pe.p}function _(n,e){n&&n.i&&(et.delete(n),n.i(e))}function H(n,e,t,i){if(n&&n.o){if(et.has(n))return;et.add(n),pe.c.push(()=>{et.delete(n),i&&(t&&n.d(1),i())}),n.o(e)}else i&&i()}var Nn={duration:0};function En(n,e,t){let i=e(n,t),r=!1,o,a,s=0;function l(){o&&bt(n,o)}function c(){let{delay:f=0,duration:p=300,easing:y=_e,tick:g=T,css:v}=i||Nn;v&&(o=wt(n,0,1,p,f,y,v,s++)),g(0,1);let m=Cn()+f,x=m+p;a&&a.abort(),r=!0,oe(()=>Be(n,!0,"start")),a=An(C=>{if(r){if(C>=x)return g(1,0),Be(n,!0,"end"),l(),r=!1;if(C>=m){let E=y((C-m)/p);g(E,1-E)}}return r})}let u=!1;return{start(){u||(u=!0,bt(n),ge(i)?(i=i(),Pn().then(c)):c())},invalidate(){u=!1},end(){r&&(l(),r=!1)}}}function Pe(n,e,t,i){let r=e(n,t),o=i?0:1,a=null,s=null,l=null;function c(){l&&bt(n,l)}function u(p,y){let g=p.b-o;return y*=Math.abs(g),{a:o,b:p.b,d:g,duration:y,start:p.start,end:p.start+y,group:p.group}}function f(p){let{delay:y=0,duration:g=300,easing:v=_e,tick:m=T,css:x}=r||Nn,C={start:Cn()+y,b:p};p||(C.group=pe,pe.r+=1),a||s?s=C:(x&&(c(),l=wt(n,o,p,g,y,v,x)),p&&m(0,1),a=u(C,g),oe(()=>Be(n,p,"start")),An(E=>{if(s&&E>s.start&&(a=u(s,g),s=null,Be(n,a.b,"start"),x&&(c(),l=wt(n,o,a.b,a.duration,0,v,r.css))),a){if(E>=a.end)m(o=a.b,1-o),Be(n,a.b,"end"),s||(a.b?c():--a.group.r||de(a.group.c)),a=null;else if(E>=a.start){let D=E-a.start;o=a.a+a.d*v(D/a.duration),m(o,1-o)}}return!!(a||s)}))}return{run(p){ge(r)?Pn().then(()=>{r=r(),f(p)}):f(p)},end(){c(),a=s=null}}}function At(n,e){let t=e.token={};function i(r,o,a,s){if(e.token!==t)return;e.resolved=s;let l=e.ctx;a!==void 0&&(l=l.slice(),l[a]=s);let c=r&&(e.current=r)(l),u=!1;e.block&&(e.blocks?e.blocks.forEach((f,p)=>{p!==o&&f&&(ae(),H(f,1,1,()=>{e.blocks[p]===f&&(e.blocks[p]=null)}),se())}):e.block.d(1),c.c(),_(c,1),c.m(e.mount(),e.anchor),u=!0),e.block=c,e.blocks&&(e.blocks[o]=c),u&&jt()}if(Dr(n)){let r=Mn();if(n.then(o=>{fe(r),i(e.then,1,e.value,o),fe(null)},o=>{if(fe(r),i(e.catch,2,e.error,o),fe(null),!e.hasCatch)throw o}),e.current!==e.pending)return i(e.pending,0),!0}else{if(e.current!==e.then)return i(e.then,1,e.value,n),!0;e.resolved=n}}function Fn(n,e,t){let i=e.slice(),{resolved:r}=n;n.current===n.then&&(i[n.value]=r),n.current===n.catch&&(i[n.error]=r),n.block.p(i,t)}var Da=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;var Ia=new Set(["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","r
|
||
|
`),definitions:l.english_definitions.map(c=>({definition:c}))})),phonetics:[...new Set(a.japanese.map(l=>`${l.word} \u300C${l.reading}\u300D`))].map(l=>({text:l}))}})}};var ut=class{constructor(e){this.definitionProvider=[new kt,new Nt(this),new Le,new Rt];this.synonymProvider=[new Lt,new Tt,new _t,new zt];this.partOfSpeechProvider=[];this.plugin=e}requestDefinitions(e){return M(this,null,function*(){let t=this.getDefinitionAPI(),{cache:i,settings:r}=this.plugin;if(r.useCaching&&!t.name.toLowerCase().contains("offline")){let o=i.cachedDefinitions.find(a=>a.content.word.toLowerCase()==e.toLowerCase()&&a.lang==r.defaultLanguage&&a.api==t.name);if(o)return new Promise(a=>a(o.content));{let a=t.requestDefinitions(e,r.defaultLanguage),s=yield a;return s&&(i.cachedDefinitions.push({content:s,api:t.name,lang:r.defaultLanguage}),yield this.plugin.saveCache()),a}}else return t.requestDefinitions(e,this.plugin.settings.defaultLanguage)})}requestSynonyms(e,t){return M(this,null,function*(){let i=this.getSynonymAPI();if(!i)throw"No Synonym API selected/available";let{cache:r,settings:o}=this.plugin;if(o.useCaching&&!i.name.toLowerCase().contains("offline")){let a=r.cachedSynonyms.find(s=>s.word.toLowerCase()==e.toLowerCase()&&s.lang==o.defaultLanguage&&s.api==i.name);if(a)return new Promise(s=>s(a.content));{let s=i.requestSynonyms(e,o.defaultLanguage),l=yield s;return l&&(r.cachedSynonyms.push({content:l,api:i.name,word:e,lang:o.defaultLanguage}),yield this.plugin.saveCache()),s}}else return i.requestSynonyms(e,this.plugin.settings.defaultLanguage,t)})}requestPartOfSpeech(e,t,i){var r;return(r=this.getPartOfSpeechAPI())==null?void 0:r.requestPartOfSpeech(e,t,i,this.plugin.settings.defaultLanguage)}getDefinitionAPI(){let e=this.plugin.settings.defaultLanguage;return this.definitionProvider.find(t=>t.name==this.plugin.settings.apiSettings[e].definitionApiName)}getSynonymAPI(){let e=this.plugin.settings.defaultLanguage;return this.synonymProvider.find(t=>t.name==this.plugin.settings.apiSettings[e].synonymApiName)}getPartOfSpeechAPI(){return this.plugin.settings.advancedSynonymAnalysis?this.partOfSpeechProvider.find(e=>e.name==this.plugin.settings.partOfSpeechApiName):null}};function Do(n){X(n,"svelte-1j3cg25",".dict-s-popover.svelte-1j3cg25.svelte-1j3cg25{min-width:210px;max-width:250px;max-height:200px;background-color:var(--background-primary);border:1px solid var(--background-modifier-border);position:absolute;z-index:var(--layer-popover);border-radius:5px;box-shadow:0px 15px 25px rgba(0, 0, 0, 0.2);font-size:14px;overflow-y:auto;overflow-x:hidden;line-height:1.4}.dict-s-popover__select-option.svelte-1j3cg25.svelte-1j3cg25{cursor:pointer;padding:10px;border-bottom:1px solid var(--background-modifier-border)}.dict-s-popover__select-option.svelte-1j3cg25.svelte-1j3cg25:hover{background-color:var(--background-secondary)}.dict-s-popover.svelte-1j3cg25>.dict-s-popover__select-option.svelte-1j3cg25:last-child{border-bottom:none}.dict-s-popover__select-label.svelte-1j3cg25.svelte-1j3cg25{display:flex;justify-content:space-between;align-items:center}.dict-s-popover__meta-description.svelte-1j3cg25.svelte-1j3cg25,.dict-s-popover__meta-pos.svelte-1j3cg25.svelte-1j3cg25{font-size:12px;color:var(--text-muted)}.dict-s-popover__meta-pos.svelte-1j3cg25.svelte-1j3cg25{display:inline-block;margin-left:10px}")}function sr(n,e,t){let i=n.slice();return i[6]=e[t],i}function lr(n){let e,t=n[6].partsOfSpeech.join(", ")+"",i;return{c(){e=A("div"),i=R(t),b(e,"class","dict-s-popover__meta-pos svelte-1j3cg25")},m(r,o){N(r,e,o),S(e,i)},p(r,o){o&2&&t!==(t=r[6].partsOfSpeech.join(", ")+"")&&W(i,t)},d(r){r&&P(e)}}}function cr(n){let e,t=n[6].description+"",i;return{c(){e=A("div"),i=R(t),b(e,"class","dict-s-popover__meta-description svelte-1j3cg25")},m(r,o){N(r,e,o),S(e,i)},p(r,o){o&2&&t!==(t=r[6].description+"")&&W(i,t)},d(r){r&&P(e)}}}function ur(n){var g;let e,t,i,r=n[6].word+"",o,a,s,l,c,u,f=!!((g=n[6].partsOfSpeech)==null?void 0:g.length)&&lr(n),p=n[6].description&&cr(n);function y(){return n[5](n[6])}return{c(){e=A("div"),t=A("div"),i=A("div"),o=R(r),a=F(
|
||
|
`))});let a="";e.phonetics.forEach((p,y,g)=>{p.text&&(a+="- "+(p.audio?`<details><summary>${p.text}</summary><audio controls><source src="${p.audio.startsWith("http")?p.audio:"https:"+p.audio}"></audio></details>`:p.text),y!=g.length-1&&(a+=`
|
||
|
`))});let s="";e.meanings.forEach((p,y)=>{var g;s+="### "+this.cap((g=p.partOfSpeech)!=null?g:w("Meaning {{i}}").replace(/{{i}}/g,(y+1).toString()))+`
|
||
|
|
||
|
`,p.definitions.forEach((v,m,x)=>{s+=v.definition+`
|
||
|
|
||
|
`,v.example&&(s+="> "+v.example+`
|
||
|
|
||
|
`),v.synonyms&&v.synonyms.length!=0&&(v.synonyms.forEach((C,E,D)=>{s+=C,E!=D.length-1&&(s+=", ")}),s+=`
|
||
|
|
||
|
`),m!=x.length-1&&(s+=`---
|
||
|
|
||
|
`)})});let l,c=Ie[r.defaultLanguage],u=`${r.folder?r.folder+"/":""}${r.languageSpecificSubFolders?c+"/":""}${r.prefix.replace(/{{lang}}/ig,c)}${r.capitalizedFileName?this.cap(e.word):e.word}${r.suffix.replace(/{{lang}}/ig,c)}.md`,f=r.template.replace(/{{notice}}/ig,w("Autogenerated by Obsidian Dictionary Plugin")).replace(/{{word}}/ig,r.capitalizedFileName?this.cap(e.word):e.word).replace(/{{pronunciationheader}}/ig,w("Pronunciation")).replace(/{{phoneticlist}}/ig,a).replace(/{{meaningheader}}/ig,w("Meanings")).replace(/{{meanings}}/ig,s).replace(/{{lang}}/ig,c).replace(/{{audioLinks}}/ig,o);e.origin?f=f.replace(/{{originHeader}}/ig,w("Origin")).replace(/{{origin}}/ig,e.origin):f=f.replace(/{{originHeader}}/ig,"").replace(/{{origin}}/ig,"");try{if((yield i.app.vault.adapter.exists((0,he.normalizePath)(`${r.folder?r.folder+"/":""}${r.languageSpecificSubFolders?c+"/":""}`)))||(yield i.app.vault.createFolder((0,he.normalizePath)(`${r.folder?r.folder+"/":""}${r.languageSpecificSubFolders?c+"/":""}`))),l=yield i.app.vault.create((0,he.normalizePath)(u),f),t){let p=i.app.workspace.splitActiveLeaf();yield p.openFile(l),i.app.workspace.setActiveLeaf(p)}}catch(p){new mr(this.plugin,(0,he.normalizePath)(u),f,t).open()}})}},mr=class extends he.Modal{constructor(e,t,i,r){super(e.app);this.path=t,this.content=i,this.openNote=r}onOpen(){this.contentEl.appendChild(createEl("p",{text:w("A existing File with the same Name was found, do you want to overwrite it?"),cls:"dictionarycenter"}));let e=this.contentEl.appendChild(createDiv({cls:"dictionarybuttons"}));e.appendChild(createEl("button",{text:w("Yes, overwrite the old File."),cls:"mod-cta"})).onClickEvent(()=>M(this,null,function*(){this.app.vault.modify(this.app.vault.getAbstractFileByPath(this.path),this.content);let t=!1;if(this.app.workspace.iterateAllLeaves(i=>{i.view instanceof he.MarkdownView&&i.getViewState().state.file.endsWith(this.path)&&(t=!0,this.app.workspace.setActiveLeaf(i))}),!t&&this.openNote){let i=this.app.workspace.splitActiveLeaf();yield i.openFile(this.app.vault.getAbstractFileByPath(this.path)),this.app.workspace.setActiveLeaf(i)}this.close()})),e.appendChild(createEl("button",{text:w("No, keep the old File."),cls:"mod-cta"})).onClickEvent(()=>{this.close()})}};var gr=G(Ot()),Bt=class extends le.Plugin{constructor(){super(...arguments);this.synonymPopover=null;this.handleContextMenuHelper=(e,t,i)=>{Ht(e,t,this)};this.handlePointerUp=(0,le.debounce)(()=>{var t,i,r;let e=this.app.workspace.activeLeaf;if((e==null?void 0:e.view)instanceof le.MarkdownView){let o=e.view;if(o.getMode()==="source"){let a=o.editor,s=a.getSelection();if(!s||/\s/.test(s))return;let l=a.getCursor("from"),c=a.getLine(l.line),u;if(a.cursorCoords)u=a.cursorCoords(!0,"window");else if(a.coordsAtPos){let f=a.posToOffset(l);u=(r=(i=(t=a.cm).coordsAtPos)==null?void 0:i.call(t,f))!=null?r:a.coordsAtPos(f)}else return;this.synonymPopover=new Ut({apiManager:this.manager,advancedPoS:this.settings.advancedSynonymAnalysis,coords:u,cursor:l,line:c,selection:s,onSelect:f=>{a.replaceSelection(Gt(f,s))}})}}},300,!0)}onload(){return M(this,null,function*(){console.log("loading dictionary"),yield Promise.all([this.loadSettings(),this.loadCache()]),yr(),this.addSettingTab(new tt(this.app,this)),this.manager=new ut(this),this.registerView(ne,e=>new st(e,this)),this.addCommand({id:"dictionary-open-view",name:w("Open Dictionary View"),callback:()=>M(this,null,function*(){this.app.workspace.getLeavesOfType(ne).length==0&&(yield this.app.workspace.getRightLeaf(!1).setViewState({type:ne})),this.app.workspace.revealLeaf(this.app.workspace.getLeavesOfType(ne).first()),dispatchEvent(new Event("dictionary-focus-on-search"))})}),this.addCommand({id:"dictionary-open-language-switcher",name:w("Open Language Switcher"),callback:()=>{new ke(this.app,this).open()}}),this.registerDomEvent(document.body,"pointerup",()=>{!this.settings.shouldShowSynonymPopover||this.handlePointerUp()}),this.registerDomEvent(window,"keydown",()=>{this.synonymPopover&&(this.synonymPopover.destroy(),this.synonymPopover=null)}),this.registerDomEve
|
||
|
/*!
|
||
|
Copyright (c) 2016 Jed Watson.
|
||
|
Licensed under the MIT License (MIT), see
|
||
|
http://jedwatson.github.io/classnames
|
||
|
*/
|
||
|
|
||
|
/* nosourcemap */
|