diff --git a/.obsidian/plugins/obsidian-style-settings/data.json b/.obsidian/plugins/obsidian-style-settings/data.json index abe830a..6425082 100644 --- a/.obsidian/plugins/obsidian-style-settings/data.json +++ b/.obsidian/plugins/obsidian-style-settings/data.json @@ -1,12 +1,11 @@ { "anuppuccin-theme-settings@@anp-alt-rainbow-style": "anp-full-rainbow-color-toggle", "anuppuccin-theme-settings@@anp-custom-checkboxes": true, - "anuppuccin-theme-settings@@anuppuccin-theme-light": "ctp-latte", "anuppuccin-theme-settings-extended@@anp-theme-ext-amoled": true, "anuppuccin-theme-settings-extended@@anp-theme-ext-dark": true, "anuppuccin-theme-settings-extended@@anp-theme-ext-light": true, "anuppuccin-theme-settings@@anp-codeblock-numbers": true, - "anuppuccin-theme-settings-extended@@catppuccin-theme-extended": "ctp-nord-light", - "anuppuccin-theme-settings-extended@@catppuccin-theme-dark-extended": "ctp-nord-dark", - "anuppuccin-theme-settings@@anp-pdf-blend-toggle": true + "anuppuccin-theme-settings@@anuppuccin-accent-toggle": true, + "anuppuccin-theme-settings@@anp-color-transition-toggle": false, + "anuppuccin-theme-settings-extended@@catppuccin-theme-extended": "ctp-nord-light" } \ No newline at end of file diff --git a/.obsidian/plugins/obsidian-style-settings/main.js b/.obsidian/plugins/obsidian-style-settings/main.js index dc19d1d..14324f0 100644 --- a/.obsidian/plugins/obsidian-style-settings/main.js +++ b/.obsidian/plugins/obsidian-style-settings/main.js @@ -32,6 +32,157 @@ function __awaiter(thisArg, _arguments, P, generator) { }); } +class ExportModal extends obsidian.Modal { + constructor(app, plugin, section, config) { + super(app); + this.plugin = plugin; + this.config = config; + this.section = section; + } + onOpen() { + const { contentEl, modalEl } = this; + modalEl.addClass('modal-style-settings'); + new obsidian.Setting(contentEl) + .setName(`Export settings for: ${this.section}`) + .then((setting) => { + const output = JSON.stringify(this.config, null, 2); + // Build a copy to clipboard link + setting.controlEl.createEl('a', { + cls: 'style-settings-copy', + text: 'Copy to clipboard', + href: '#', + }, (copyButton) => { + new obsidian.TextAreaComponent(contentEl) + .setValue(output) + .then((textarea) => { + copyButton.addEventListener('click', (e) => { + e.preventDefault(); + // Select the textarea contents and copy them to the clipboard + textarea.inputEl.select(); + textarea.inputEl.setSelectionRange(0, 99999); + document.execCommand('copy'); + copyButton.addClass('success'); + setTimeout(() => { + // If the button is still in the dom, remove the success class + if (copyButton.parentNode) { + copyButton.removeClass('success'); + } + }, 2000); + }); + }); + }); + // Build a download link + setting.controlEl.createEl('a', { + cls: 'style-settings-download', + text: 'Download', + attr: { + download: 'style-settings.json', + href: `data:application/json;charset=utf-8,${encodeURIComponent(output)}`, + }, + }); + }); + } + onClose() { + const { contentEl } = this; + contentEl.empty(); + } +} + +class ImportModal extends obsidian.Modal { + constructor(app, plugin) { + super(app); + this.plugin = plugin; + } + onOpen() { + const { contentEl, modalEl } = this; + modalEl.addClass('modal-style-settings'); + new obsidian.Setting(contentEl) + .setName('Import style setting') + .setDesc('Import an entire or partial configuration. Warning: this may override existing settings'); + new obsidian.Setting(contentEl).then((setting) => { + // Build an error message container + const errorSpan = createSpan({ + cls: 'style-settings-import-error', + text: 'Error importing config', + }); + setting.nameEl.appendChild(errorSpan); + // Attempt to parse the imported data and close if successful + const importAndClose = (str) => __awaiter(this, void 0, void 0, function* () { + if (str) { + try { + const importedSettings = JSON.parse(str); + yield this.plugin.settingsManager.setSettings(importedSettings); + this.plugin.settingsTab.display(); + this.close(); + } + catch (e) { + errorSpan.addClass('active'); + errorSpan.setText(`Error importing style settings: ${e}`); + } + } + else { + errorSpan.addClass('active'); + errorSpan.setText(`Error importing style settings: config is empty`); + } + }); + // Build a file input + setting.controlEl.createEl('input', { + cls: 'style-settings-import-input', + attr: { + id: 'style-settings-import-input', + name: 'style-settings-import-input', + type: 'file', + accept: '.json', + }, + }, (importInput) => { + // Set up a FileReader so we can parse the file contents + importInput.addEventListener('change', (e) => { + const reader = new FileReader(); + reader.onload = (e) => __awaiter(this, void 0, void 0, function* () { + yield importAndClose(e.target.result.toString().trim()); + }); + reader.readAsText(e.target.files[0]); + }); + }); + // Build a label we will style as a link + setting.controlEl.createEl('label', { + cls: 'style-settings-import-label', + text: 'Import from file', + attr: { + for: 'style-settings-import-input', + }, + }); + new obsidian.TextAreaComponent(contentEl) + .setPlaceholder('Paste config here...') + .then((ta) => { + new obsidian.ButtonComponent(contentEl) + .setButtonText('Save') + .onClick(() => __awaiter(this, void 0, void 0, function* () { + yield importAndClose(ta.getValue().trim()); + })); + }); + }); + } + onClose() { + const { contentEl } = this; + contentEl.empty(); + } +} + +const SettingType = { + HEADING: 'heading', + INFO_TEXT: 'info-text', + CLASS_TOGGLE: 'class-toggle', + CLASS_SELECT: 'class-select', + VARIABLE_TEXT: 'variable-text', + VARIABLE_NUMBER: 'variable-number', + VARIABLE_NUMBER_SLIDER: 'variable-number-slider', + VARIABLE_SELECT: 'variable-select', + VARIABLE_COLOR: 'variable-color', + VARIABLE_THEMED_COLOR: 'variable-themed-color', + COLOR_GRADIENT: 'color-gradient', +}; + var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function getDefaultExportFromCjs (x) { @@ -3277,157 +3428,6 @@ var chroma = createCommonjsModule(function (module, exports) { }))); }); -class ImportModal extends obsidian.Modal { - constructor(app, plugin) { - super(app); - this.plugin = plugin; - } - onOpen() { - const { contentEl, modalEl } = this; - modalEl.addClass('modal-style-settings'); - new obsidian.Setting(contentEl) - .setName('Import style setting') - .setDesc('Import an entire or partial configuration. Warning: this may override existing settings'); - new obsidian.Setting(contentEl).then((setting) => { - // Build an error message container - const errorSpan = createSpan({ - cls: 'style-settings-import-error', - text: 'Error importing config', - }); - setting.nameEl.appendChild(errorSpan); - // Attempt to parse the imported data and close if successful - const importAndClose = (str) => __awaiter(this, void 0, void 0, function* () { - if (str) { - try { - const importedSettings = JSON.parse(str); - yield this.plugin.settingsManager.setSettings(importedSettings); - this.plugin.settingsTab.display(); - this.close(); - } - catch (e) { - errorSpan.addClass('active'); - errorSpan.setText(`Error importing style settings: ${e}`); - } - } - else { - errorSpan.addClass('active'); - errorSpan.setText(`Error importing style settings: config is empty`); - } - }); - // Build a file input - setting.controlEl.createEl('input', { - cls: 'style-settings-import-input', - attr: { - id: 'style-settings-import-input', - name: 'style-settings-import-input', - type: 'file', - accept: '.json', - }, - }, (importInput) => { - // Set up a FileReader so we can parse the file contents - importInput.addEventListener('change', (e) => { - const reader = new FileReader(); - reader.onload = (e) => __awaiter(this, void 0, void 0, function* () { - yield importAndClose(e.target.result.toString().trim()); - }); - reader.readAsText(e.target.files[0]); - }); - }); - // Build a label we will style as a link - setting.controlEl.createEl('label', { - cls: 'style-settings-import-label', - text: 'Import from file', - attr: { - for: 'style-settings-import-input', - }, - }); - new obsidian.TextAreaComponent(contentEl) - .setPlaceholder('Paste config here...') - .then((ta) => { - new obsidian.ButtonComponent(contentEl) - .setButtonText('Save') - .onClick(() => __awaiter(this, void 0, void 0, function* () { - yield importAndClose(ta.getValue().trim()); - })); - }); - }); - } - onClose() { - const { contentEl } = this; - contentEl.empty(); - } -} - -class ExportModal extends obsidian.Modal { - constructor(app, plugin, section, config) { - super(app); - this.plugin = plugin; - this.config = config; - this.section = section; - } - onOpen() { - const { contentEl, modalEl } = this; - modalEl.addClass('modal-style-settings'); - new obsidian.Setting(contentEl) - .setName(`Export settings for: ${this.section}`) - .then((setting) => { - const output = JSON.stringify(this.config, null, 2); - // Build a copy to clipboard link - setting.controlEl.createEl('a', { - cls: 'style-settings-copy', - text: 'Copy to clipboard', - href: '#', - }, (copyButton) => { - new obsidian.TextAreaComponent(contentEl) - .setValue(output) - .then((textarea) => { - copyButton.addEventListener('click', (e) => { - e.preventDefault(); - // Select the textarea contents and copy them to the clipboard - textarea.inputEl.select(); - textarea.inputEl.setSelectionRange(0, 99999); - document.execCommand('copy'); - copyButton.addClass('success'); - setTimeout(() => { - // If the button is still in the dom, remove the success class - if (copyButton.parentNode) { - copyButton.removeClass('success'); - } - }, 2000); - }); - }); - }); - // Build a download link - setting.controlEl.createEl('a', { - cls: 'style-settings-download', - text: 'Download', - attr: { - download: 'style-settings.json', - href: `data:application/json;charset=utf-8,${encodeURIComponent(output)}`, - }, - }); - }); - } - onClose() { - const { contentEl } = this; - contentEl.empty(); - } -} - -const SettingType = { - HEADING: 'heading', - INFO_TEXT: 'info-text', - CLASS_TOGGLE: 'class-toggle', - CLASS_SELECT: 'class-select', - VARIABLE_TEXT: 'variable-text', - VARIABLE_NUMBER: 'variable-number', - VARIABLE_NUMBER_SLIDER: 'variable-number-slider', - VARIABLE_SELECT: 'variable-select', - VARIABLE_COLOR: 'variable-color', - VARIABLE_THEMED_COLOR: 'variable-themed-color', - COLOR_GRADIENT: 'color-gradient', -}; - function generateColorVariables(key, format, colorStr, opacity, altFormats = []) { const parsedColor = chroma(colorStr); const alts = altFormats.reduce((a, alt) => { @@ -3776,7 +3776,9 @@ class CSSSettingsManager { ` .trim() .replace(/[\r\n\s]+/g, ' '); - this.plugin.app.workspace.trigger('css-change', { source: 'style-settings' }); + this.plugin.app.workspace.trigger('css-change', { + source: 'style-settings', + }); } setConfig(settings) { this.config = {}; @@ -3865,6 +3867,1912 @@ class CSSSettingsManager { } } +const ar = {}; + +const cz = {}; + +const da = {}; + +const de = { + 'Default:': 'Standard:', + 'Error:': 'Fehler:', + 'missing default light value, or value is not in a valid color format': 'Fehlender heller standard Wert oder Wert ist in keinem validen Farb-Format', + 'missing default dark value, or value is not in a valid color format': 'Fehlender dunkler standard Wert oder Wert ist in keinem validen Farb-Format', + 'missing default value, or value is not in a valid color format': 'Fehlender standard Wert oder Wert ist in keinem validen Farb-Format', + 'missing default value': 'Fehlender standard Wert', +}; + +const en = { + 'Default:': 'Default:', + 'Error:': 'Error:', + 'missing default light value, or value is not in a valid color format': 'missing default light value, or value is not in a valid color format', + 'missing default dark value, or value is not in a valid color format': 'missing default dark value, or value is not in a valid color format', + 'missing default value, or value is not in a valid color format': 'missing default value, or value is not in a valid color format', + 'missing default value': 'missing default value', +}; + +const es = {}; + +const fr = {}; + +const hi = {}; + +const id = {}; + +const it = {}; + +const ja = {}; + +const ko = {}; + +const nl = { + 'Default:': 'Standaard:', + 'Error:': 'Error:', + 'missing default light value, or value is not in a valid color format': 'Geen standaard waarde voor het lichte thema, of de waarde is niet in het goede formaat', + 'missing default dark value, or value is not in a valid color format': 'Geen standaard waarde voor het donkere thema, of de waarde is niet in het goede formaat', + 'missing default value, or value is not in a valid color format': 'Geen standaard waarde, of de waarde is niet in het goede formaat', + 'missing default value': 'Geen standaard waarde', +}; + +const no = {}; + +const pl = {}; + +const pt = {}; + +const ptBr = {}; + +const ro = {}; + +const ru = {}; + +const sq = {}; + +const tr = {}; + +const uk = {}; + +const zh = { + 'Default:': '默认:', + 'Error:': '错误:', + 'missing default light value, or value is not in a valid color format': '缺少默认的浅色模式色值,或该色值没有采用一个有效的颜色格式', + 'missing default dark value, or value is not in a valid color format': '缺少默认的深色模式色值,或该色值没有采用一个有效的颜色格式', + 'missing default value, or value is not in a valid color format': '缺少默认色值,或该色值没有采用一个有效的颜色格式', + 'missing default value': '缺少默认色值', +}; + +const zhTw = {}; + +const lang = window.localStorage.getItem('language'); +const localeMap = { + ar, + cz, + da, + de, + en, + es, + fr, + hi, + id, + it, + ja, + ko, + nl, + no, + pl, + 'pt-BR': ptBr, + pt, + ro, + ru, + sq, + tr, + uk, + 'zh-TW': zhTw, + zh, +}; +const locale = localeMap[lang || 'en']; +function t(str) { + if (!locale) { + console.error('Error: Style Settings locale not found', lang); + } + return (locale && locale[str]) || en[str]; +} + +const settingRegExp = /\/\*!?\s*@settings[\r\n]+?([\s\S]+?)\*\//g; +const nameRegExp = /^name:\s*(.+)$/m; +function getTitle(config) { + if (lang) { + return config[`title.${lang}`] || config.title; + } + return config.title; +} +function getDescription(config) { + if (lang) { + return (config[`description.${lang}`] || + config.description); + } + return config.description; +} +function isValidDefaultColor(color) { + return /^(#|rgb|hsl)/.test(color); +} +function getPickrSettings(opts) { + const { el, isView, containerEl, swatches, opacity, defaultColor } = opts; + return { + el, + container: isView ? document.body : containerEl, + theme: 'nano', + swatches, + lockOpacity: !opacity, + default: defaultColor, + position: 'left-middle', + components: { + preview: true, + hue: true, + opacity: !!opacity, + interaction: { + hex: true, + rgba: true, + hsla: true, + input: true, + cancel: true, + save: true, + }, + }, + }; +} +function onPickrCancel(instance) { + instance.hide(); +} +function sanitizeText(str) { + if (str === '') { + return `""`; + } + return str.replace(/[;<>]/g, ''); +} +function createDescription(description, def, defLabel) { + const fragment = createFragment(); + if (description) { + fragment.appendChild(document.createTextNode(description)); + } + if (def) { + const small = createEl('small'); + small.appendChild(createEl('strong', { text: `${t('Default:')} ` })); + small.appendChild(document.createTextNode(defLabel || def)); + const div = createEl('div'); + div.appendChild(small); + fragment.appendChild(div); + } + return fragment; +} + +var fuzzysort = createCommonjsModule(function (module) { +((root, UMD) => { + if(module.exports) module.exports = UMD(); + else root['fuzzysort'] = UMD(); +})(commonjsGlobal, _ => { + + var single = (search, target) => { if(search=='farzher')return {target:"farzher was here (^-^*)/",score:0,_indexes:[0]} + if(!search || !target) return NULL + + var preparedSearch = getPreparedSearch(search); + if(!isObj(target)) target = getPrepared(target); + + var searchBitflags = preparedSearch.bitflags; + if((searchBitflags & target._bitflags) !== searchBitflags) return NULL + + return algorithm(preparedSearch, target) + }; + + + var go = (search, targets, options) => { if(search=='farzher')return [{target:"farzher was here (^-^*)/",score:0,_indexes:[0],obj:targets?targets[0]:NULL}] + if(!search) return options&&options.all ? all(search, targets, options) : noResults + + var preparedSearch = getPreparedSearch(search); + var searchBitflags = preparedSearch.bitflags; + preparedSearch.containsSpace; + + var threshold = options&&options.threshold || INT_MIN; + var limit = options&&options['limit'] || INT_MAX; // for some reason only limit breaks when minified + + var resultsLen = 0; var limitedCount = 0; + var targetsLen = targets.length; + + // This code is copy/pasted 3 times for performance reasons [options.keys, options.key, no keys] + + // options.key + if(options && options.key) { + var key = options.key; + for(var i = 0; i < targetsLen; ++i) { var obj = targets[i]; + var target = getValue(obj, key); + if(!target) continue + if(!isObj(target)) target = getPrepared(target); + + if((searchBitflags & target._bitflags) !== searchBitflags) continue + var result = algorithm(preparedSearch, target); + if(result === NULL) continue + if(result.score < threshold) continue + + // have to clone result so duplicate targets from different obj can each reference the correct obj + result = {target:result.target, _targetLower:'', _targetLowerCodes:NULL, _nextBeginningIndexes:NULL, _bitflags:0, score:result.score, _indexes:result._indexes, obj:obj}; // hidden + + if(resultsLen < limit) { q.add(result); ++resultsLen; } + else { + ++limitedCount; + if(result.score > q.peek().score) q.replaceTop(result); + } + } + + // options.keys + } else if(options && options.keys) { + var scoreFn = options['scoreFn'] || defaultScoreFn; + var keys = options.keys; + var keysLen = keys.length; + for(var i = 0; i < targetsLen; ++i) { var obj = targets[i]; + var objResults = new Array(keysLen); + for (var keyI = 0; keyI < keysLen; ++keyI) { + var key = keys[keyI]; + var target = getValue(obj, key); + if(!target) { objResults[keyI] = NULL; continue } + if(!isObj(target)) target = getPrepared(target); + + if((searchBitflags & target._bitflags) !== searchBitflags) objResults[keyI] = NULL; + else objResults[keyI] = algorithm(preparedSearch, target); + } + objResults.obj = obj; // before scoreFn so scoreFn can use it + var score = scoreFn(objResults); + if(score === NULL) continue + if(score < threshold) continue + objResults.score = score; + if(resultsLen < limit) { q.add(objResults); ++resultsLen; } + else { + ++limitedCount; + if(score > q.peek().score) q.replaceTop(objResults); + } + } + + // no keys + } else { + for(var i = 0; i < targetsLen; ++i) { var target = targets[i]; + if(!target) continue + if(!isObj(target)) target = getPrepared(target); + + if((searchBitflags & target._bitflags) !== searchBitflags) continue + var result = algorithm(preparedSearch, target); + if(result === NULL) continue + if(result.score < threshold) continue + if(resultsLen < limit) { q.add(result); ++resultsLen; } + else { + ++limitedCount; + if(result.score > q.peek().score) q.replaceTop(result); + } + } + } + + if(resultsLen === 0) return noResults + var results = new Array(resultsLen); + for(var i = resultsLen - 1; i >= 0; --i) results[i] = q.poll(); + results.total = resultsLen + limitedCount; + return results + }; + + + var highlight = (result, hOpen, hClose) => { + if(typeof hOpen === 'function') return highlightCallback(result, hOpen) + if(result === NULL) return NULL + if(hOpen === undefined) hOpen = ''; + if(hClose === undefined) hClose = ''; + var highlighted = ''; + var matchesIndex = 0; + var opened = false; + var target = result.target; + var targetLen = target.length; + var indexes = result._indexes; + indexes = indexes.slice(0, indexes.len).sort((a,b)=>a-b); + for(var i = 0; i < targetLen; ++i) { var char = target[i]; + if(indexes[matchesIndex] === i) { + ++matchesIndex; + if(!opened) { opened = true; + highlighted += hOpen; + } + + if(matchesIndex === indexes.length) { + highlighted += char + hClose + target.substr(i+1); + break + } + } else { + if(opened) { opened = false; + highlighted += hClose; + } + } + highlighted += char; + } + + return highlighted + }; + var highlightCallback = (result, cb) => { + if(result === NULL) return NULL + var target = result.target; + var targetLen = target.length; + var indexes = result._indexes; + indexes = indexes.slice(0, indexes.len).sort((a,b)=>a-b); + var highlighted = ''; + var matchI = 0; + var indexesI = 0; + var opened = false; + var result = []; + for(var i = 0; i < targetLen; ++i) { var char = target[i]; + if(indexes[indexesI] === i) { + ++indexesI; + if(!opened) { opened = true; + result.push(highlighted); highlighted = ''; + } + + if(indexesI === indexes.length) { + highlighted += char; + result.push(cb(highlighted, matchI++)); highlighted = ''; + result.push(target.substr(i+1)); + break + } + } else { + if(opened) { opened = false; + result.push(cb(highlighted, matchI++)); highlighted = ''; + } + } + highlighted += char; + } + return result + }; + + + var indexes = result => result._indexes.slice(0, result._indexes.len).sort((a,b)=>a-b); + + + var prepare = (target) => { + if(typeof target !== 'string') target = ''; + var info = prepareLowerInfo(target); + return {'target':target, _targetLower:info._lower, _targetLowerCodes:info.lowerCodes, _nextBeginningIndexes:NULL, _bitflags:info.bitflags, 'score':NULL, _indexes:[0], 'obj':NULL} // hidden + }; + + + // Below this point is only internal code + // Below this point is only internal code + // Below this point is only internal code + // Below this point is only internal code + + + var prepareSearch = (search) => { + if(typeof search !== 'string') search = ''; + search = search.trim(); + var info = prepareLowerInfo(search); + + var spaceSearches = []; + if(info.containsSpace) { + var searches = search.split(/\s+/); + searches = [...new Set(searches)]; // distinct + for(var i=0; i { + if(target.length > 999) return prepare(target) // don't cache huge targets + var targetPrepared = preparedCache.get(target); + if(targetPrepared !== undefined) return targetPrepared + targetPrepared = prepare(target); + preparedCache.set(target, targetPrepared); + return targetPrepared + }; + var getPreparedSearch = (search) => { + if(search.length > 999) return prepareSearch(search) // don't cache huge searches + var searchPrepared = preparedSearchCache.get(search); + if(searchPrepared !== undefined) return searchPrepared + searchPrepared = prepareSearch(search); + preparedSearchCache.set(search, searchPrepared); + return searchPrepared + }; + + + var all = (search, targets, options) => { + var results = []; results.total = targets.length; + + var limit = options && options.limit || INT_MAX; + + if(options && options.key) { + for(var i=0;i