-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
executable file
·93 lines (63 loc) · 19.4 KB
/
main.js
File metadata and controls
executable file
·93 lines (63 loc) · 19.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
"use strict";var N=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var ge=(e,t)=>{for(var n in t)N(e,n,{get:t[n],enumerable:!0})},me=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of de(t))!pe.call(e,i)&&i!==n&&N(e,i,{get:()=>t[i],enumerable:!(r=fe(t,i))||r.enumerable});return e};var he=e=>me(N({},"__esModule",{value:!0}),e);var ct={};ge(ct,{default:()=>C});module.exports=he(ct);var f=require("obsidian");function ve(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}function S(e,t){return Array(t+1).join(e)}function O(e){return e.replace(/^\n*/,"")}function I(e){for(var t=e.length;t>0&&e[t-1]===`
`;)t--;return e.substring(0,t)}function M(e){return I(O(e))}var Te=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function k(e){return A(e,Te)}var H=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function $(e){return A(e,H)}function Ee(e){return F(e,H)}var _=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function Ce(e){return A(e,_)}function Ne(e){return F(e,_)}function A(e,t){return t.indexOf(e.nodeName)>=0}function F(e,t){return e.getElementsByTagName&&t.some(function(n){return e.getElementsByTagName(n).length})}var c={};c.paragraph={filter:"p",replacement:function(e){return`
`+e+`
`}};c.lineBreak={filter:"br",replacement:function(e,t,n){return n.br+`
`}};c.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(e,t,n){var r=Number(t.nodeName.charAt(1));if(n.headingStyle==="setext"&&r<3){var i=S(r===1?"=":"-",e.length);return`
`+e+`
`+i+`
`}else return`
`+S("#",r)+" "+e+`
`}};c.blockquote={filter:"blockquote",replacement:function(e){return e=M(e).replace(/^/gm,"> "),`
`+e+`
`}};c.list={filter:["ul","ol"],replacement:function(e,t){var n=t.parentNode;return n.nodeName==="LI"&&n.lastElementChild===t?`
`+e:`
`+e+`
`}};c.listItem={filter:"li",replacement:function(e,t,n){var r=n.bulletListMarker+" ",i=t.parentNode;if(i.nodeName==="OL"){var a=i.getAttribute("start"),s=Array.prototype.indexOf.call(i.children,t);r=(a?Number(a)+s:s+1)+". "}var l=/\n$/.test(e);return e=M(e)+(l?`
`:""),e=e.replace(/\n/gm,`
`+" ".repeat(r.length)),r+e+(t.nextSibling?`
`:"")}};c.indentedCodeBlock={filter:function(e,t){return t.codeBlockStyle==="indented"&&e.nodeName==="PRE"&&e.firstChild&&e.firstChild.nodeName==="CODE"},replacement:function(e,t,n){return`
`+t.firstChild.textContent.replace(/\n/g,`
`)+`
`}};c.fencedCodeBlock={filter:function(e,t){return t.codeBlockStyle==="fenced"&&e.nodeName==="PRE"&&e.firstChild&&e.firstChild.nodeName==="CODE"},replacement:function(e,t,n){for(var r=t.firstChild.getAttribute("class")||"",i=(r.match(/language-(\S+)/)||[null,""])[1],a=t.firstChild.textContent,s=n.fence.charAt(0),l=3,o=new RegExp("^"+s+"{3,}","gm"),u;u=o.exec(a);)u[0].length>=l&&(l=u[0].length+1);var p=S(s,l);return`
`+p+i+`
`+a.replace(/\n$/,"")+`
`+p+`
`}};c.horizontalRule={filter:"hr",replacement:function(e,t,n){return`
`+n.hr+`
`}};c.inlineLink={filter:function(e,t){return t.linkStyle==="inlined"&&e.nodeName==="A"&&e.getAttribute("href")},replacement:function(e,t){var n=t.getAttribute("href");n&&(n=n.replace(/([()])/g,"\\$1"));var r=v(t.getAttribute("title"));return r&&(r=' "'+r.replace(/"/g,'\\"')+'"'),"["+e+"]("+n+r+")"}};c.referenceLink={filter:function(e,t){return t.linkStyle==="referenced"&&e.nodeName==="A"&&e.getAttribute("href")},replacement:function(e,t,n){var r=t.getAttribute("href"),i=v(t.getAttribute("title"));i&&(i=' "'+i+'"');var a,s;switch(n.linkReferenceStyle){case"collapsed":a="["+e+"][]",s="["+e+"]: "+r+i;break;case"shortcut":a="["+e+"]",s="["+e+"]: "+r+i;break;default:var l=this.references.length+1;a="["+e+"]["+l+"]",s="["+l+"]: "+r+i}return this.references.push(s),a},references:[],append:function(e){var t="";return this.references.length&&(t=`
`+this.references.join(`
`)+`
`,this.references=[]),t}};c.emphasis={filter:["em","i"],replacement:function(e,t,n){return e.trim()?n.emDelimiter+e+n.emDelimiter:""}};c.strong={filter:["strong","b"],replacement:function(e,t,n){return e.trim()?n.strongDelimiter+e+n.strongDelimiter:""}};c.code={filter:function(e){var t=e.previousSibling||e.nextSibling,n=e.parentNode.nodeName==="PRE"&&!t;return e.nodeName==="CODE"&&!n},replacement:function(e){if(!e)return"";e=e.replace(/\r?\n|\r/g," ");for(var t=/^`|^ .*?[^ ].* $|`$/.test(e)?" ":"",n="`",r=e.match(/`+/gm)||[];r.indexOf(n)!==-1;)n=n+"`";return n+t+e+t+n}};c.image={filter:"img",replacement:function(e,t){var n=v(t.getAttribute("alt")),r=t.getAttribute("src")||"",i=v(t.getAttribute("title")),a=i?' "'+i+'"':"";return r?"":""}};function v(e){return e?e.replace(/(\n+\s*)+/g,`
`):""}function V(e){this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[];for(var t in e.rules)this.array.push(e.rules[t])}V.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return""}})},forNode:function(e){if(e.isBlank)return this.blankRule;var t;return(t=b(this.array,e,this.options))||(t=b(this._keep,e,this.options))||(t=b(this._remove,e,this.options))?t:this.defaultRule},forEach:function(e){for(var t=0;t<this.array.length;t++)e(this.array[t],t)}};function b(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(be(i,t,n))return i}}function be(e,t,n){var r=e.filter;if(typeof r=="string"){if(r===t.nodeName.toLowerCase())return!0}else if(Array.isArray(r)){if(r.indexOf(t.nodeName.toLowerCase())>-1)return!0}else if(typeof r=="function"){if(r.call(e,t,n))return!0}else throw new TypeError("`filter` needs to be a string, array, or function")}function xe(e){var t=e.element,n=e.isBlock,r=e.isVoid,i=e.isPre||function(ue){return ue.nodeName==="PRE"};if(!(!t.firstChild||i(t))){for(var a=null,s=!1,l=null,o=B(l,t,i);o!==t;){if(o.nodeType===3||o.nodeType===4){var u=o.data.replace(/[ \r\n\t]+/g," ");if((!a||/ $/.test(a.data))&&!s&&u[0]===" "&&(u=u.substr(1)),!u){o=x(o);continue}o.data=u,a=o}else if(o.nodeType===1)n(o)||o.nodeName==="BR"?(a&&(a.data=a.data.replace(/ $/,"")),a=null,s=!1):r(o)||i(o)?(a=null,s=!0):a&&(s=!1);else{o=x(o);continue}var p=B(l,o,i);l=o,o=p}a&&(a.data=a.data.replace(/ $/,""),a.data||x(a))}}function x(e){var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function B(e,t,n){return e&&e.parentNode===t||n(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode}var P=typeof window!="undefined"?window:{};function ye(){var e=P.DOMParser,t=!1;try{new e().parseFromString("","text/html")&&(t=!0)}catch(n){}return t}function Se(){var e=function(){};return ke()?e.prototype.parseFromString=function(t){var n=new window.ActiveXObject("htmlfile");return n.designMode="on",n.open(),n.write(t),n.close(),n}:e.prototype.parseFromString=function(t){var n=document.implementation.createHTMLDocument("");return n.open(),n.write(t),n.close(),n},e}function ke(){var e=!1;try{document.implementation.createHTMLDocument("").open()}catch(t){P.ActiveXObject&&(e=!0)}return e}var Ae=ye()?P.DOMParser:Se();function Pe(e,t){var n;if(typeof e=="string"){var r=we().parseFromString('<x-turndown id="turndown-root">'+e+"</x-turndown>","text/html");n=r.getElementById("turndown-root")}else n=e.cloneNode(!0);return xe({element:n,isBlock:k,isVoid:$,isPre:t.preformattedCode?Re:null}),n}var y;function we(){return y=y||new Ae,y}function Re(e){return e.nodeName==="PRE"||e.nodeName==="CODE"}function Le(e,t){return e.isBlock=k(e),e.isCode=e.nodeName==="CODE"||e.parentNode.isCode,e.isBlank=Be(e),e.flankingWhitespace=De(e,t),e}function Be(e){return!$(e)&&!Ce(e)&&/^\s*$/i.test(e.textContent)&&!Ee(e)&&!Ne(e)}function De(e,t){if(e.isBlock||t.preformattedCode&&e.isCode)return{leading:"",trailing:""};var n=Oe(e.textContent);return n.leadingAscii&&D("left",e,t)&&(n.leading=n.leadingNonAscii),n.trailingAscii&&D("right",e,t)&&(n.trailing=n.trailingNonAscii),{leading:n.leading,trailing:n.trailing}}function Oe(e){var t=e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);return{leading:t[1],leadingAscii:t[2],leadingNonAscii:t[3],trailing:t[4],trailingNonAscii:t[5],trailingAscii:t[6]}}function D(e,t,n){var r,i,a;return e==="left"?(r=t.previousSibling,i=/ $/):(r=t.nextSibling,i=/^ /),r&&(r.nodeType===3?a=i.test(r.nodeValue):n.preformattedCode&&r.nodeName==="CODE"?a=!1:r.nodeType===1&&!k(r)&&(a=i.test(r.textContent))),a}var Ie=Array.prototype.reduce,Me=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function T(e){if(!(this instanceof T))return new T(e);var t={rules:c,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:!1,blankReplacement:function(n,r){return r.isBlock?`
`:""},keepReplacement:function(n,r){return r.isBlock?`
`+r.outerHTML+`
`:r.outerHTML},defaultReplacement:function(n,r){return r.isBlock?`
`+n+`
`:n}};this.options=ve({},t,e),this.rules=new V(this.options)}T.prototype={turndown:function(e){if(!_e(e))throw new TypeError(e+" is not a string, or an element/document/fragment node.");if(e==="")return"";var t=U.call(this,new Pe(e,this.options));return He.call(this,t)},use:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.use(e[t]);else if(typeof e=="function")e(this);else throw new TypeError("plugin must be a Function or an Array of Functions");return this},addRule:function(e,t){return this.rules.add(e,t),this},keep:function(e){return this.rules.keep(e),this},remove:function(e){return this.rules.remove(e),this},escape:function(e){return Me.reduce(function(t,n){return t.replace(n[0],n[1])},e)}};function U(e){var t=this;return Ie.call(e.childNodes,function(n,r){r=new Le(r,t.options);var i="";return r.nodeType===3?i=r.isCode?r.nodeValue:t.escape(r.nodeValue):r.nodeType===1&&(i=$e.call(t,r)),z(n,i)},"")}function He(e){var t=this;return this.rules.forEach(function(n){typeof n.append=="function"&&(e=z(e,n.append(t.options)))}),e.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function $e(e){var t=this.rules.forNode(e),n=U.call(this,e),r=e.flankingWhitespace;return(r.leading||r.trailing)&&(n=n.trim()),r.leading+t.replacement(n,e,this.options)+r.trailing}function z(e,t){var n=I(e),r=O(t),i=Math.max(e.length-n.length,t.length-r.length),a=`
`.substring(0,i);return n+a+r}function _e(e){return e!=null&&(typeof e=="string"||e.nodeType&&(e.nodeType===1||e.nodeType===9||e.nodeType===11))}var W=T;var j=/highlight-(?:text|source)-([a-z0-9]+)/;function Fe(e){e.addRule("highlightedCodeBlock",{filter:function(t){var n=t.firstChild;return t.nodeName==="DIV"&&j.test(t.className)&&n&&n.nodeName==="PRE"},replacement:function(t,n,r){var i=n.className||"",a=(i.match(j)||[null,""])[1];return`
`+r.fence+a+`
`+n.firstChild.textContent+`
`+r.fence+`
`}})}function Ve(e){e.addRule("strikethrough",{filter:["del","s","strike"],replacement:function(t){return"~"+t+"~"}})}var Ue=Array.prototype.indexOf,ze=Array.prototype.every,g={};g.tableCell={filter:["th","td"],replacement:function(e,t){return G(e,t)}};g.tableRow={filter:"tr",replacement:function(e,t){var n="",r={left:":--",right:"--:",center:":-:"};if(w(t))for(var i=0;i<t.childNodes.length;i++){var a="---",s=(t.childNodes[i].getAttribute("align")||"").toLowerCase();s&&(a=r[s]||a),n+=G(a,t.childNodes[i])}return`
`+e+(n?`
`+n:"")}};g.table={filter:function(e){return e.nodeName==="TABLE"&&w(e.rows[0])},replacement:function(e){return e=e.replace(`
`,`
`),`
`+e+`
`}};g.tableSection={filter:["thead","tbody","tfoot"],replacement:function(e){return e}};function w(e){var t=e.parentNode;return t.nodeName==="THEAD"||t.firstChild===e&&(t.nodeName==="TABLE"||We(t))&&ze.call(e.childNodes,function(n){return n.nodeName==="TH"})}function We(e){var t=e.previousSibling;return e.nodeName==="TBODY"&&(!t||t.nodeName==="THEAD"&&/^\s*$/i.test(t.textContent))}function G(e,t){var n=Ue.call(t.parentNode.childNodes,t),r=" ";return n===0&&(r="| "),r+e+" |"}function je(e){e.keep(function(n){return n.nodeName==="TABLE"&&!w(n.rows[0])});for(var t in g)e.addRule(t,g[t])}function Ge(e){e.addRule("taskListItems",{filter:function(t){return t.type==="checkbox"&&t.parentNode.nodeName==="LI"},replacement:function(t,n){return(n.checked?"[x]":"[ ]")+" "}})}function K(e){e.use([Fe,Ve,je,Ge])}var Ke=/```[\s\S]*?```/g,Xe=/`[^`\n]+`/g,q="__CLEAN_PASTE_TOKEN_",Ye=/<\/?[a-z][^>]*>/gi,qe=/<br\s*\/?>/gi,Qe={" ":" ","&":"&","<":"<",">":">",""":'"',"'":"'"};function Q(e){let t=[],n=Ze(e),r=e;for(let i of[Ke,Xe])r=r.replace(i,a=>{let s=`${n}${t.length}__`;return t.push(a),s});return{tokenPrefix:n,text:r,tokens:t}}function J(e,t,n=q){return t.reduce((r,i,a)=>r.replace(`${n}${a}__`,i),e)}function Z(e){return e.replace(/\r\n?/g,`
`)}function ee(e){return e.split(`
`).map(t=>t.replace(/[ \t]+$/g,"")).join(`
`).trim()}function te(e){let t=e.replace(qe,`
`);for(let[n,r]of Object.entries(Qe))t=t.split(n).join(r);return t.replace(Ye,"")}function ne(e){return e.replace(/\u00A0|\u2007|\u202F/g," ").replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[“”]/g,'"').replace(/[‘’]/g,"'").replace(/[ \t]{2,}/g," ")}function re(e){return e.split(`
`).map(t=>{let r=t.trim().split(" ");if(r.length>1&&r.every(s=>/^#[^#]/.test(s)))return t;let a=t.match(/^(\s{0,3}#{1,6})([^\s#].*)$/);return a?`${a[1]} ${a[2].trim()}`:t}).join(`
`)}function ie(e,t){var i,a;let n=e.split(`
`),r=[];for(let s of n){let l=s.match(/^(\s*)([-*+•◦▪●])(?:\s+(.*))?$/);if(l){let u=X(l[1]),p=t?"-":l[2];r.push(`${u}${p} ${((i=l[3])!=null?i:"").trim()}`.trimEnd());continue}let o=s.match(/^(\s*)(\d+)([.)])(?:\s+(.*))?$/);if(o){let u=X(o[1]);r.push(`${u}${o[2]}. ${((a=o[4])!=null?a:"").trim()}`.trimEnd());continue}r.push(s)}return Je(r).join(`
`)}function ae(e,t){let n=t?2:1,r=e.split(`
`),i=[],a=0;for(let s of r){if(s.trim()===""){a+=1,a<=n&&i.push("");continue}a=0,i.push(s)}return i.join(`
`).trim()}function X(e){let t=e.replace(/\t/g," ").length,n=Math.floor(t/2)*2;return" ".repeat(n)}function Je(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n],i=t[t.length-1],a=e[n+1];r.trim()===""&&Y(i)&&Y(a)||t.push(r)}return t}function Y(e){return e?/^(\s*)([-*+•◦▪●]|\d+[.)])\s+/.test(e):!1}function Ze(e){let t=q;for(;e.includes(t);)t=`_${t}`;return t}function m(e,t){let n=Q(e),r=[Z,i=>t.stripHtmlArtifacts?te(i):i,ne,ee,re,i=>ie(i,t.normalizeBulletsToDash),i=>ae(i,t.preserveExtraBlankLinesInParagraphs)].reduce((i,a)=>a(i),n.text);return J(r,n.tokens,n.tokenPrefix)}function se(e,t){let{frontmatter:n,body:r}=et(e),i=m(r,t);return`${n}${i}`}function et(e){if(!e.startsWith(`---
`)&&!e.startsWith(`---\r
`))return{frontmatter:"",body:e};let t=e.match(/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/);return t?{frontmatter:t[0],body:e.slice(t[0].length)}:{frontmatter:"",body:e}}var h={preserveExtraBlankLinesInParagraphs:!1,normalizeBulletsToDash:!0,stripHtmlArtifacts:!0};var tt=it();async function oe(e=h,t=navigator.clipboard){let n=await nt(t);return m(n,e)}async function nt(e=navigator.clipboard){if(typeof e.read=="function")try{let t=await e.read();for(let n of t){let r=await R(n,"text/markdown");if(r)return r;let i=await R(n,"text/html");if(i)return rt(i);let a=await R(n,"text/plain");if(a)return a}}catch(t){console.warn("Falling back to plain clipboard text",t)}return typeof e.readText=="function"?e.readText():""}function rt(e){return tt.turndown(e)}async function R(e,t){if(!e.types.includes(t))return null;try{let n=await e.getType(t);return at(n)}catch(n){return null}}function it(){let e=new W({bulletListMarker:"-",codeBlockStyle:"fenced",emDelimiter:"*",headingStyle:"atx",strongDelimiter:"**"});return e.use(K),e}async function at(e){return typeof e.text=="function"?e.text():""}function le(e,t){let n=e.listSelections().filter(r=>!st(r)).sort(ot);if(n.length===0)return!1;for(let r of n){let i=L(r.anchor,r.head),a=lt(r.anchor,r.head),s=e.getRange(i,a),l=m(s,t);e.replaceRange(l,i,a)}return!0}function ce(e,t){let n=e.getValue(),r=se(n,t);return r===n?!1:(e.setValue(r),!0)}function st(e){return e.anchor.line===e.head.line&&e.anchor.ch===e.head.ch}function ot(e,t){let n=L(e.anchor,e.head),r=L(t.anchor,t.head);return n.line!==r.line?r.line-n.line:r.ch-n.ch}function L(e,t){return e.line!==t.line?e.line<t.line?e:t:e.ch<=t.ch?e:t}function lt(e,t){return e.line!==t.line?e.line>t.line?e:t:e.ch>=t.ch?e:t}var d=require("obsidian"),E=class extends d.PluginSettingTab{constructor(n,r){super(n,r);this.plugin=r}display(){let{containerEl:n}=this;n.empty(),new d.Setting(n).setName("General").setHeading(),new d.Setting(n).setName("Preserve extra blank lines in paragraphs").setDesc("Keep larger paragraph gaps instead of collapsing them.").addToggle(r=>r.setValue(this.plugin.settings.preserveExtraBlankLinesInParagraphs).onChange(async i=>{this.plugin.settings.preserveExtraBlankLinesInParagraphs=i,await this.plugin.saveSettings()})),new d.Setting(n).setName("Normalize bullets to -").setDesc("Convert fancy bullets and mixed bullet markers into dashes.").addToggle(r=>r.setValue(this.plugin.settings.normalizeBulletsToDash).onChange(async i=>{this.plugin.settings.normalizeBulletsToDash=i,await this.plugin.saveSettings()})),new d.Setting(n).setName("Strip HTML artifacts").setDesc("Remove leftover tags, line break tags, and common HTML entities.").addToggle(r=>r.setValue(this.plugin.settings.stripHtmlArtifacts).onChange(async i=>{this.plugin.settings.stripHtmlArtifacts=i,await this.plugin.saveSettings()}))}};var C=class extends f.Plugin{constructor(){super(...arguments);this.settings=h}async onload(){await this.loadSettings(),this.addRibbonIcon("wand","Clean current note",()=>{this.cleanActiveNote()}),this.addCommand({id:"clean-selected-text",name:"Clean selected text",editorCallback:n=>{let r=le(n,this.settings);new f.Notice(r?"Paste cleaned":"Select text to clean")}}),this.addCommand({id:"paste-clean-from-clipboard",name:"Paste clean from clipboard",editorCallback:n=>void this.pasteCleanFromClipboard(n)}),this.addCommand({id:"clean-current-note",name:"Clean current note",editorCallback:n=>this.cleanNoteInEditor(n)}),this.addSettingTab(new E(this.app,this))}async saveSettings(){await this.saveData(this.settings)}async loadSettings(){let n=await this.loadData();this.settings={...h,...n}}async pasteCleanFromClipboard(n){try{let r=await oe(this.settings);if(!r){new f.Notice("Clipboard is empty");return}n.replaceSelection(r),new f.Notice("Paste cleaned")}catch(r){console.error("Failed to read clipboard",r),new f.Notice("Unable to read clipboard")}}cleanActiveNote(){let n=this.getActiveEditor();if(!n){new f.Notice("Open a note to clean");return}this.cleanNoteInEditor(n)}cleanNoteInEditor(n){let r=ce(n,this.settings);new f.Notice(r?"Note cleaned":"Nothing to clean")}getActiveEditor(){var n,r;return(r=(n=this.app.workspace.getActiveViewOfType(f.MarkdownView))==null?void 0:n.editor)!=null?r:null}};