Affected files: .obsidian/community-plugins.json .obsidian/plugins/darlal-switcher-plus/manifest.json .obsidian/plugins/mrj-jump-to-link/main.js .obsidian/plugins/mrj-jump-to-link/manifest.json .obsidian/plugins/obsidian-git/main.js .obsidian/plugins/obsidian-git/manifest.json .obsidian/plugins/obsidian-git/styles.css .obsidian/plugins/url-into-selection/main.js .obsidian/plugins/url-into-selection/manifest.json flashcards anglais.md
10 lines
7.9 KiB
JavaScript
10 lines
7.9 KiB
JavaScript
/*
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
if you want to view the source visit the plugins github repository
|
|
*/
|
|
|
|
var T=Object.create;var u=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var B=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),N=(e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},R=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of F(t))!z.call(e,i)&&i!==n&&u(e,i,{get:()=>t[i],enumerable:!(r=_(t,i))||r.enumerable});return e};var w=(e,t,n)=>(n=e!=null?T(W(e)):{},R(t||!e||!e.__esModule?u(n,"default",{value:e,enumerable:!0}):n,e)),Z=e=>R(u({},"__esModule",{value:!0}),e);var U=B(c=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});c.assertNever=k;function k(e,t){if(typeof t=="string")throw new Error(t);if(typeof t=="function")throw new Error(t(e));if(t)return e;throw new Error("Unhandled discriminated union member: ".concat(JSON.stringify(e)))}c.default=k});var te={};N(te,{default:()=>m});module.exports=Z(te);var L=require("obsidian");var D=w(U());var y=w(require("path"),1);function h(e,t={}){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);let{resolve:n=!0}=t,r=e;return n&&(r=y.default.resolve(e)),r=r.replace(/\\/g,"/"),r[0]!=="/"&&(r=`/${r}`),encodeURI(`file://${r}`).replace(/[?#]/g,encodeURIComponent)}var b=class{constructor(){this.fallbackUrlRegex=null;this.fallbackUrlRegexString="";this.imgEmbedRegexes=[];this.imgEmbedRegexString=""}getFallbackUrlRegex(t){if(this.fallbackUrlRegex===null||this.fallbackUrlRegexString!==t)try{this.fallbackUrlRegex=new RegExp(t),this.fallbackUrlRegexString=t}catch(n){console.warn("Invalid regex pattern in settings, using fallback:",n),this.fallbackUrlRegex=/^[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/,this.fallbackUrlRegexString=t}return this.fallbackUrlRegex}getImgEmbedRegexes(t){return this.imgEmbedRegexString!==t&&(this.imgEmbedRegexes=t.split(`
|
|
`).filter(n=>n.length>0).map(n=>{try{return new RegExp(n)}catch(r){return console.warn("Invalid image embed regex pattern:",n,r),/$.^/}}),this.imgEmbedRegexString=t),this.imgEmbedRegexes}clear(){this.fallbackUrlRegex=null,this.fallbackUrlRegexString="",this.imgEmbedRegexes=[],this.imgEmbedRegexString=""}},E=new b;var V=/^[a-z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$/i,H=/^(?:\/[^/]+)+\/?$/i;function S(e){return/^\/\w+\s/.test(e)?!1:V.test(e)||H.test(e)}function x(e){return/^\[\[.+\]\]$/.test(e.trim())}var M=new Set(["http","https","ftp","ftps","file","mailto","tel","sms","data","blob","obsidian","zotero","notion","slack","discord","teams","ssh","git","svn","ldap","ldaps","ws","wss","magnet"]);function f(e,t){if(e==="")return!1;if(x(e))return!0;try{let r=new URL(e).protocol.slice(0,-1);return/^[a-z]$/i.test(r)?S(e):M.has(r)}catch(n){return S(e)||E.getFallbackUrlRegex(t.regex).test(e)}}function j(e){return e.replace(/</g,"%3C").replace(/>/g,"%3E")}function G(e){return/[\(\) ]/.test(e)}function Q(e){return/^<.*>$/.test(e)}function C(e){let t;return S(e)?t=h(e,{resolve:!1}):t=e,Q(t)?t:(/[<>]/.test(t)&&(t=j(t)),G(t)?`<${t}>`:t)}function I(e,t){let n=E.getImgEmbedRegexes(t.listForImgEmbed);for(let r of n)if(r.test(e))return!0;return!1}function v(e,t){let n=e.getLine(t.from.line),r=t.from.ch,i=-1,o=0;for(let s=r-1;s>=0;s--)if(n[s]===")"&&s<r)o++;else if(n[s]==="("){if(o===0){i=s;break}o--}if(i===-1)return!1;if(i>0&&n[i-1]==="]"){let s=0;for(let l=i-2;l>=0;l--)if(n[l]==="]")s++;else if(n[l]==="["){if(s===0)return l>0&&n[l-1]==="!",!0;s--}}return!1}function P(e){if(e.length<2)return e;let t=e[0],n=e[e.length-1];return t===n&&(t==='"'||t==="'")?e.slice(1,-1):e}function d(e,t,n){if(!e.somethingSelected()&&n.nothingSelected===0)return;if(typeof t!="string"&&!t.clipboardData){console.error("empty clipboardData in ClipboardEvent");return}let r=q(t);if(r===null)return;let{selectedText:i,replaceRange:o}=J(e,n),s=o||{from:e.getCursor(),to:e.getCursor()},l=v(e,s),a=O(r,i,n,l);a!==null&&(typeof t!="string"&&t.preventDefault(),ee(e,a,o),i===""&&n.nothingSelected===2&&e.setCursor({ch:o.from.ch+1,line:o.from.line}))}function J(e,t){let n,r;if(e.somethingSelected())n=e.getSelection(),r=null;else switch(t.nothingSelected){case 1:r=K(e,t),n=e.getRange(r.from,r.to);break;case 2:case 3:r=Y(e),n="";break;case 0:throw new Error("should be skipped");default:(0,D.default)(t.nothingSelected)}return{selectedText:n,replaceRange:r}}function O(e,t,n,r){let i,o;if(f(e.trim(),n))i=t,o=e.trim();else if(f(t.trim(),n))i=e,o=t.trim();else return null;let s=I(e.trim(),n)?"!":"";return r?o:x(o)?t===""&&n.nothingSelected===3||i===""?o:`[[${o.slice(2,-2)}|${i}]]`:(o=C(o),t===""&&n.nothingSelected===3?/^<.*>$/.test(o)?o:`<${o}>`:s+`[${i}](${o})`)}function q(e){let t;if(typeof e=="string")t=e;else if(e.clipboardData)t=e.clipboardData.getData("text");else return console.error("empty clipboardData in ClipboardEvent"),null;return P(t.trim())}function K(e,t){let n=e.getCursor(),r=e.getLine(n.line),i=X(r,n),o=i.from.ch,s=i.to.ch;for(;o>0&&!/\s/.test(r.charAt(o-1));)--o;for(;s<r.length&&!/\s/.test(r.charAt(s));)++s;let l=r.slice(o,s);return/^\[.*]\(.*\)$/.test(l)||f(l,t)&&(i.from.ch=o,i.to.ch=s),i}var X=(()=>{let e=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function t(n){return/\w/.test(n)||n>"\x80"&&(n.toUpperCase()!=n.toLowerCase()||e.test(n))}return(n,r)=>{let i,o=r.ch,s=r.ch;s===n.length?--o:++s;let l=n.charAt(r.ch);for(t(l)?i=a=>t(a):/\s/.test(l)?i=a=>/\s/.test(a):i=a=>!/\s/.test(a)&&!t(a);o>0&&i(n.charAt(o-1));)--o;for(;s<n.length&&i(n.charAt(s));)++s;return{from:{line:r.line,ch:o},to:{line:r.line,ch:s}}}})();function Y(e){return{from:e.getCursor(),to:e.getCursor()}}function ee(e,t,n=null){n&&n.from&&n.to?e.replaceRange(t,n.from,n.to):e.replaceSelection(t)}var g=require("obsidian");var $={regex:/^[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/.source,nothingSelected:0,listForImgEmbed:""},p=class extends g.PluginSettingTab{display(){let{containerEl:t}=this,n=this.plugin;t.empty(),t.createEl("h2",{text:"URL-into-selection Settings"}),new g.Setting(t).setName("Fallback Regular expression").setDesc("Regular expression used to match URLs when default match fails.").addText(r=>r.setPlaceholder("Enter regular expression here..").setValue(n.settings.regex).onChange(async i=>{i.length>0&&(n.settings.regex=i,await n.saveSettings())})),new g.Setting(t).setName("Behavior on pasting URL when nothing is selected").setDesc("Auto Select: Automatically select word surrounding the cursor.").addDropdown(r=>{let i={0:"Do nothing",1:"Auto Select",2:"Insert [](url)",3:"Insert <url>"};r.addOptions(i).setValue(n.settings.nothingSelected.toString()).onChange(async o=>{n.settings.nothingSelected=+o,await n.saveSettings(),this.display()})}),new g.Setting(t).setName("Whitelist for image embed syntax").setDesc(createFragment(r=>{r.appendText(" will be used for URL that matches the following list."),r.createEl("br"),r.appendText("Rules are regex-based, split by line break.")})).addTextArea(r=>{r.setPlaceholder(`Example:
|
|
youtu.?be|vimeo`).setValue(n.settings.listForImgEmbed).onChange(i=>(n.settings.listForImgEmbed=i,n.saveData(n.settings),r)),r.inputEl.rows=6,r.inputEl.cols=25})}};var m=class extends L.Plugin{constructor(){super(...arguments);this.pasteHandler=(n,r)=>d(r,n,this.settings)}async onload(){console.log("loading url-into-selection"),await this.loadSettings(),this.addSettingTab(new p(this.app,this)),this.addCommand({id:"paste-url-into-selection",name:"",editorCallback:async n=>{let r=await navigator.clipboard.readText();d(n,r,this.settings)}}),this.app.workspace.on("editor-paste",this.pasteHandler)}onunload(){console.log("unloading url-into-selection"),this.app.workspace.off("editor-paste",this.pasteHandler)}async loadSettings(){this.settings=Object.assign({},$,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}};
|
|
|
|
/* nosourcemap */ |