From b3dee2ab9e0a130c65606fa1fb0a1386154a9104 Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Mon, 1 Nov 2021 15:21:27 +0100 Subject: [PATCH] vault backup: 2021-11-01 15:21:27 --- notes/.obsidian/app.json | 5 +- notes/.obsidian/community-plugins.json | 4 +- notes/.obsidian/graph.json | 16 +- .../obsidian-codemirror-options/data.json | 31 + .../obsidian-codemirror-options/main.js | 10788 ++++++++++++++++ .../obsidian-codemirror-options/manifest.json | 9 + .../obsidian-codemirror-options/styles.css | 1339 ++ notes/ang/Testy.md | 1 - notes/ang/listening.md | 1 - notes/ang/slovesa.md | 1 - notes/cjl/jména.md | 24 +- notes/data/Pasted image 20211101144629.png | Bin 0 -> 61663 bytes notes/data/Pasted image 20211101144810.png | Bin 0 -> 25271 bytes notes/data/Pasted image 20211101144829.png | Bin 0 -> 88004 bytes notes/data/Pasted image 20211101144913.png | Bin 0 -> 1196746 bytes notes/data/Pasted image 20211101145000.png | Bin 0 -> 863833 bytes notes/data/Pasted image 20211101145017.png | Bin 0 -> 855182 bytes notes/data/Pasted image 20211101145031.png | Bin 0 -> 683848 bytes notes/data/Pasted image 20211101145057.png | Bin 0 -> 1152847 bytes notes/data/Pasted image 20211101145113.png | Bin 0 -> 988177 bytes notes/data/Pasted image 20211101145123.png | Bin 0 -> 834731 bytes notes/data/Pasted image 20211101145200.png | Bin 0 -> 137304 bytes notes/data/Pasted image 20211101145306.png | Bin 0 -> 1374930 bytes notes/data/Pasted image 20211101145318.png | Bin 0 -> 506791 bytes notes/data/Pasted image 20211101145332.png | Bin 0 -> 903937 bytes notes/data/Pasted image 20211101145341.png | Bin 0 -> 534948 bytes notes/data/Pasted image 20211101145351.png | Bin 0 -> 1471660 bytes notes/data/Pasted image 20211101145401.png | Bin 0 -> 280229 bytes notes/data/Pasted image 20211101145410.png | Bin 0 -> 327362 bytes notes/data/Pasted image 20211101145419.png | Bin 0 -> 799538 bytes notes/data/Pasted image 20211101145432.png | Bin 0 -> 523734 bytes notes/dej/Data.md | 5 + notes/dej/moderní/1. světová válka.md | 11 +- .../František Ferdinand d`Este.md | 10 + .../moderní/1. světová válka/Použití plynů.md | 3 +- .../1. světová válka/Sarajevský atentát.md | 11 +- .../1. světová válka/Východní fronta.md | 1 - notes/dej/moderní/1. světová válka/Zbraně.md | 5 +- .../1. světová válka/Západní fronta.md | 1 - .../1. světová válka/Český zahraniční odboj.md | 24 + .../Čeští vojáci na bojištích světové války.md | 25 + notes/dej/starší/úvod.md | 7 +- notes/dej/Úvod.md | 4 +- notes/ech/Mendělejev.md | 3 +- notes/ech/Názvosloví.md | 75 +- notes/ech/Vazby.md | 1 - notes/ech/hmota.md | 1 - notes/ech/obal atomu.md | 3 - notes/ech/prvky.md | 16 + notes/ech/radioaktivita.md | 3 - notes/ele/Náboj, proud, napětí a odpor.md | 3 - notes/ele/Polovodiče.md | 1 - notes/ele/Vodiče.md | 2 - notes/fyz/Exponencionální zápis.md | 1 - notes/fyz/Jednotky SI.md | 2 - notes/fyz/Pohyb.md | 8 +- notes/fyz/Příklad.md | 1 - notes/fyz/Rychlost.md | 2 +- notes/fyz/Veličiny.md | 12 - notes/har/CPU.md | 7 - notes/har/IQRF.md | 2 +- notes/har/historie počítačů.md | 1 - notes/mat/Druhá odmocnina.md | 1 - notes/mat/Matematika.md | 3 +- notes/mat/Množiny.md | 5 - notes/mat/Násobek a dělitel.md | 2 - ...lad složených čísel na součin prvočísel.md | 1 - notes/mat/Zakrouhlení.md | 1 - notes/mat/Zlomky.md | 1 - notes/mat/Číselné obory.md | 2 - notes/mat/Číselné soustavy.md | 1 - notes/pdv/30 let linuxu.md | 2 +- notes/pdv/Procesory AMD x Intel.md | 1 - notes/psi/Sítě.md | 1 + notes/psi/Základy komunikace.md | 8 - 75 files changed, 12395 insertions(+), 104 deletions(-) create mode 100644 notes/.obsidian/plugins/obsidian-codemirror-options/data.json create mode 100644 notes/.obsidian/plugins/obsidian-codemirror-options/main.js create mode 100644 notes/.obsidian/plugins/obsidian-codemirror-options/manifest.json create mode 100644 notes/.obsidian/plugins/obsidian-codemirror-options/styles.css create mode 100644 notes/data/Pasted image 20211101144629.png create mode 100644 notes/data/Pasted image 20211101144810.png create mode 100644 notes/data/Pasted image 20211101144829.png create mode 100644 notes/data/Pasted image 20211101144913.png create mode 100644 notes/data/Pasted image 20211101145000.png create mode 100644 notes/data/Pasted image 20211101145017.png create mode 100644 notes/data/Pasted image 20211101145031.png create mode 100644 notes/data/Pasted image 20211101145057.png create mode 100644 notes/data/Pasted image 20211101145113.png create mode 100644 notes/data/Pasted image 20211101145123.png create mode 100644 notes/data/Pasted image 20211101145200.png create mode 100644 notes/data/Pasted image 20211101145306.png create mode 100644 notes/data/Pasted image 20211101145318.png create mode 100644 notes/data/Pasted image 20211101145332.png create mode 100644 notes/data/Pasted image 20211101145341.png create mode 100644 notes/data/Pasted image 20211101145351.png create mode 100644 notes/data/Pasted image 20211101145401.png create mode 100644 notes/data/Pasted image 20211101145410.png create mode 100644 notes/data/Pasted image 20211101145419.png create mode 100644 notes/data/Pasted image 20211101145432.png create mode 100644 notes/dej/moderní/1. světová válka/František Ferdinand d`Este.md create mode 100644 notes/dej/moderní/1. světová válka/Český zahraniční odboj.md create mode 100644 notes/dej/moderní/1. světová válka/Čeští vojáci na bojištích světové války.md diff --git a/notes/.obsidian/app.json b/notes/.obsidian/app.json index 9e26dfe..43f7f97 100644 --- a/notes/.obsidian/app.json +++ b/notes/.obsidian/app.json @@ -1 +1,4 @@ -{} \ No newline at end of file +{ + "newFileLocation": "current", + "attachmentFolderPath": "data" +} \ No newline at end of file diff --git a/notes/.obsidian/community-plugins.json b/notes/.obsidian/community-plugins.json index fdf8f3d..d6634e1 100644 --- a/notes/.obsidian/community-plugins.json +++ b/notes/.obsidian/community-plugins.json @@ -3,7 +3,6 @@ "table-editor-obsidian", "obsidian-admonition", "obsidian-auto-link-title", - "obsidian-autocomplete-plugin", "code-block-copy", "cycle-through-panes", "dataview", @@ -23,6 +22,5 @@ "wikilinks-to-mdlinks-obsidian", "obsidian-outliner", "obsidian-chartsview-plugin", - "obsidian-activity-history", - "obsidian-excalidraw-plugin" + "obsidian-codemirror-options" ] \ No newline at end of file diff --git a/notes/.obsidian/graph.json b/notes/.obsidian/graph.json index b3487a6..d96c69e 100644 --- a/notes/.obsidian/graph.json +++ b/notes/.obsidian/graph.json @@ -1,7 +1,7 @@ { "collapse-filter": false, "search": "", - "showTags": true, + "showTags": false, "showAttachments": false, "hideUnresolved": false, "showOrphans": true, @@ -78,16 +78,16 @@ } } ], - "collapse-display": true, + "collapse-display": false, "showArrow": true, - "textFadeMultiplier": -1.5, + "textFadeMultiplier": -2.3, "nodeSizeMultiplier": 1, "lineSizeMultiplier": 1, "collapse-forces": false, - "centerStrength": 0.476470588235294, - "repelStrength": 10.7058823529412, - "linkStrength": 1, - "linkDistance": 85, - "scale": 0.3503656304628013, + "centerStrength": 0.4, + "repelStrength": 10.2352941176471, + "linkStrength": 0.458823529411765, + "linkDistance": 240, + "scale": 0.3414744101388251, "close": false } \ No newline at end of file diff --git a/notes/.obsidian/plugins/obsidian-codemirror-options/data.json b/notes/.obsidian/plugins/obsidian-codemirror-options/data.json new file mode 100644 index 0000000..7afe536 --- /dev/null +++ b/notes/.obsidian/plugins/obsidian-codemirror-options/data.json @@ -0,0 +1,31 @@ +{ + "dynamicCursor": false, + "markSelection": false, + "activeLineOnSelect": false, + "enableCMinPreview": false, + "enablePrismJSStyling": false, + "editModeHideTokens": false, + "editModeClickHandler": false, + "showLineNums": false, + "copyButton": false, + "copyButtonOnPRE": false, + "enableOpenMD": false, + "cursorBlinkRate": 530, + "foldLinks": false, + "foldImages": true, + "containerAttributes": false, + "syntaxHighlighting": false, + "autoAlignTables": false, + "renderCode": false, + "renderHTML": false, + "renderChart": true, + "renderAdmonition": true, + "renderQuery": true, + "renderDataview": true, + "renderMath": true, + "renderMathPreview": true, + "renderBanner": true, + "styleCheckBox": true, + "allowedYamlKeys": "document-font-size", + "tokenList": "em|strong|strikethrough|code|linkText|task|internalLink|highlight" +} \ No newline at end of file diff --git a/notes/.obsidian/plugins/obsidian-codemirror-options/main.js b/notes/.obsidian/plugins/obsidian-codemirror-options/main.js new file mode 100644 index 0000000..b094a87 --- /dev/null +++ b/notes/.obsidian/plugins/obsidian-codemirror-options/main.js @@ -0,0 +1,10788 @@ +/* +THIS IS A GENERATED/BUNDLED FILE BY ROLLUP +if you want to view the source visit the plugins github repository +*/ + +'use strict'; + +var obsidian = require('obsidian'); +var electron = require('electron'); + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +function unload_math_preview(cm) { + cm.setOption("hmdFoldMath", { + onPreview: null, + onPreviewEnd: null, + }); +} +function init_math_preview(cm) { + if (obsidian.loadMathJax) + obsidian.loadMathJax(); + if (!document.querySelector("#math-preview")) { + var mathPreviewEl = document.createElement("div"); + mathPreviewEl.className = "float-win float-win-hidden"; + mathPreviewEl.id = "math-preview"; + var mathTitleEl = document.createElement("div"); + mathTitleEl.addClass("float-win-title"); + mathPreviewEl.appendChild(mathTitleEl); + mathTitleEl.outerHTML = "
\n \n Math Preview\n
"; + var mathContentEl = document.createElement("div"); + mathContentEl.addClass("float-win-content"); + mathContentEl.id = "math-preview-content"; + mathPreviewEl.appendChild(mathContentEl); + document.body.appendChild(mathPreviewEl); + } + var mathRenderer = null; + var win = new FloatWin("math-preview"); + var supressed = false; + win.closeBtn.addEventListener("click", function () { + supressed = true; // for current TeX block + }, false); + function updatePreview(expr) { + if (supressed) + return; + if (!mathRenderer) { + // initialize renderer and preview window + mathRenderer = cm.hmd.FoldMath.createRenderer(document.getElementById("math-preview-content"), "display"); + mathRenderer.onChanged = function () { + // finished rendering. show the window + if (!win.visible) { + var cursorPos = cm.charCoords(cm.getCursor(), "window"); + win.moveTo(cursorPos.left, cursorPos.bottom); + } + win.show(); + }; + } + if (!mathRenderer.isReady()) + return; + mathRenderer.startRender(expr); + } + function hidePreview() { + win.hide(); + supressed = false; + } + cm.setOption("hmdFoldMath", { + onPreview: updatePreview, + onPreviewEnd: hidePreview, + }); +} +function FloatWin(id) { + var win = document.getElementById(id); + // eslint-disable-next-line @typescript-eslint/no-this-alias + var self = this; + /** @type {HTMLDivElement} */ + var titlebar = win.querySelector(".float-win-title"); + titlebar.addEventListener("selectstart", function () { + return false; + }, false); + /** @type {HTMLButtonElement} */ + var closeBtn = win.querySelector(".float-win-close"); + if (closeBtn) { + closeBtn.addEventListener("click", function () { + self.hide(); + }, false); + } + var boxX, boxY, mouseX, mouseY, offsetX, offsetY; + titlebar.addEventListener("mousedown", function (e) { + if (e.target === closeBtn) + return; + boxX = win.offsetLeft; + boxY = win.offsetTop; + mouseX = getMouseXY(e).x; + mouseY = getMouseXY(e).y; + offsetX = mouseX - boxX; + offsetY = mouseY - boxY; + document.addEventListener("mousemove", move, false); + document.addEventListener("mouseup", up, false); + }, false); + function move(e) { + var x = getMouseXY(e).x - offsetX; + var y = getMouseXY(e).y - offsetY; + var width = document.documentElement.clientWidth - titlebar.offsetWidth; + var height = document.documentElement.clientHeight - titlebar.offsetHeight; + x = Math.min(Math.max(0, x), width); + y = Math.min(Math.max(0, y), height); + win.style.left = x + "px"; + win.style.top = y + "px"; + } + function up(e) { + document.removeEventListener("mousemove", move, false); + document.removeEventListener("mouseup", up, false); + } + function getMouseXY(e) { + var x = 0, y = 0; + e = e || window.event; + if (e.pageX) { + x = e.pageX; + y = e.pageY; + } + else { + x = e.clientX + document.body.scrollLeft - document.body.clientLeft; + y = e.clientY + document.body.scrollTop - document.body.clientTop; + } + return { + x: x, + y: y, + }; + } + this.el = win; + this.closeBtn = closeBtn; + this.visible = !/float-win-hidden/.test(win.className); +} +FloatWin.prototype.show = function (moveToCenter) { + if (this.visible) + return; + var el = this.el, + // eslint-disable-next-line @typescript-eslint/no-this-alias + self = this; + this.visible = true; + el.className = this.el.className.replace(/\s*(float-win-hidden\s*)+/g, " "); + if (moveToCenter) { + setTimeout(function () { + self.moveTo((window.innerWidth - el.offsetWidth) / 2, (window.innerHeight - el.offsetHeight) / 2); + }, 0); + } +}; +FloatWin.prototype.hide = function () { + if (!this.visible) + return; + this.visible = false; + this.el.className += " float-win-hidden"; +}; +FloatWin.prototype.moveTo = function (x, y) { + var s = this.el.style; + s.left = x + "px"; + s.top = y + "px"; +}; + +var DEFAULT_SETTINGS = { + dynamicCursor: false, + markSelection: false, + activeLineOnSelect: false, + enableCMinPreview: false, + enablePrismJSStyling: false, + editModeHideTokens: false, + editModeClickHandler: false, + showLineNums: false, + copyButton: false, + copyButtonOnPRE: false, + enableOpenMD: false, + cursorBlinkRate: 530, + foldLinks: false, + foldImages: false, + containerAttributes: false, + syntaxHighlighting: false, + autoAlignTables: false, + renderCode: false, + renderHTML: false, + renderChart: false, + renderAdmonition: false, + renderQuery: false, + renderDataview: false, + renderMath: false, + renderMathPreview: false, + renderBanner: true, + styleCheckBox: true, + allowedYamlKeys: "document-font-size", + tokenList: "em|strong|strikethrough|code|linkText|task|internalLink|highlight", +}; +var ObsidianCodeMirrorOptionsSettingsTab = /** @class */ (function (_super) { + __extends(ObsidianCodeMirrorOptionsSettingsTab, _super); + function ObsidianCodeMirrorOptionsSettingsTab(app, plugin) { + var _this = _super.call(this, app, plugin) || this; + _this.plugin = plugin; + return _this; + } + ObsidianCodeMirrorOptionsSettingsTab.prototype.display = function () { + var _this = this; + var containerEl = this.containerEl; + containerEl.empty(); + containerEl.addClass("codemirror-options-settings"); + containerEl.createEl("h3", { + text: "Markdown Parsing", + }); + new obsidian.Setting(containerEl) + .setName("⚠️ Hide Markdown Tokens") + .setDesc("Emulate WYSIWYG while editing by hiding markdown tokens. Markdown tokens will automatically hide once the cursor leaves the element.\n This mode will apply the class .hmd-inactive-line to all inactive lines and the class .hmd-hidden-token to all hidden tokens.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.editModeHideTokens).onChange(function (value) { + _this.plugin.settings.editModeHideTokens = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("hmdHideToken", _this.plugin.settings.editModeHideTokens ? _this.plugin.settings.tokenList : false); + _this.plugin.applyBodyClasses(); + // hide the token list if the hide tokens setting is disabled + _this.plugin.settings.editModeHideTokens + ? tokenSettings.settingEl.removeClass("setting-disabled") + : tokenSettings.settingEl.addClass("setting-disabled"); + }); + }); + var tokenSettings = new obsidian.Setting(this.containerEl) + .setName("⚠️ Token List") + .setDesc("These markdown token types will be hidden. The default value will hide all currently supported tokens.\n Values must be pipe delimted with no spaces. Available options are: em|strong|strikethrough|code|linkText|task|internalLink|highlight") + .setClass("token-list-setting") + .addText(function (textfield) { + textfield.setPlaceholder(String("em|strong|strikethrough|code|linkText|task|internalLink|highlight")); + textfield.inputEl.type = "text"; + textfield.setValue(String(_this.plugin.settings.tokenList)); + textfield.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + this.plugin.settings.tokenList = value; + this.plugin.saveData(this.plugin.settings); + this.plugin.updateCodeMirrorOption("hmdHideToken", this.plugin.settings.editModeHideTokens ? this.plugin.settings.tokenList : false, true); + return [2 /*return*/]; + }); + }); }); + }); + new obsidian.Setting(containerEl) + .setName("⚠️ Enable OpenMD Mode") + .setDesc("Completely replace the HyperMD CodeMirror mode with a modified version of HyperMD that aims to\n replicate the default Obsidian edit mode parser while adding additional functionality such as\n improved internal link parsing.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.enableOpenMD).onChange(function (value) { + _this.plugin.settings.enableOpenMD = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("mode", _this.plugin.settings.enableOpenMD ? "openmd" : "hypermd"); + }); + }); + new obsidian.Setting(containerEl) + .setName("⚠️ Collapse External Links") + .setDesc("This will collapse external links in edit mode so that the URL is hidden and only the link text is shown. \n The full URL will display once you click into the link text.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.foldLinks).onChange(function (value) { + _this.plugin.settings.foldLinks = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.applyBodyClasses(); + _this.plugin.updateCodeMirrorOption("hmdFold", { + image: _this.plugin.settings.foldImages, + link: _this.plugin.settings.foldLinks, + html: _this.plugin.settings.renderHTML, + code: _this.plugin.settings.renderCode, + math: _this.plugin.settings.renderMath, + }); + }); + }); + new obsidian.Setting(containerEl) + .setName("⚠️ Render Images Inline") + .setDesc("This will render images in edit mode inline. Clicking on the image will collapse the image down to its source view.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.foldImages).onChange(function (value) { + _this.plugin.settings.foldImages = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.applyBodyClasses(); + _this.plugin.updateCodeMirrorOption("hmdFold", { + image: _this.plugin.settings.foldImages, + link: _this.plugin.settings.foldLinks, + html: _this.plugin.settings.renderHTML, + code: _this.plugin.settings.renderCode, + math: _this.plugin.settings.renderMath, + }); + }); + }); + new obsidian.Setting(containerEl) + .setName("Edit Mode Click Handler") + .setDesc("Allow mouse clicks to toggle checkboxes in edit mode.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.editModeClickHandler).onChange(function (value) { + _this.plugin.settings.editModeClickHandler = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("hmdClick", _this.plugin.settings.editModeClickHandler); + }); + }); + new obsidian.Setting(containerEl) + .setName("Style Checkboxes") + .setDesc("Disable this if you want to do your own styling of edit mode checkboxes. This setting does nothing if Hide Markdown Tokens is disabled") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.styleCheckBox).onChange(function (value) { + _this.plugin.settings.styleCheckBox = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.applyBodyClasses(); + }); + }); + containerEl.createEl("h3", { + text: "Edit Mode Code Rendering", + }); + new obsidian.Setting(containerEl) + .setName("Render HTML") + .setDesc("") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.renderHTML).onChange(function (value) { + _this.plugin.settings.renderHTML = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("hmdFold", { + image: _this.plugin.settings.foldImages, + link: _this.plugin.settings.foldLinks, + html: _this.plugin.settings.renderHTML, + code: _this.plugin.settings.renderCode, + math: _this.plugin.settings.renderMath, + }); + }); + }); + new obsidian.Setting(containerEl) + .setName("Render Math") + .setDesc("") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.renderMath).onChange(function (value) { + _this.plugin.settings.renderMath = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("hmdFold", { + image: _this.plugin.settings.foldImages, + link: _this.plugin.settings.foldLinks, + html: _this.plugin.settings.renderHTML, + code: _this.plugin.settings.renderCode, + math: _this.plugin.settings.renderMath, + }); + }); + }); + new obsidian.Setting(containerEl) + .setName("Render Math Preview") + .setDesc("") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.renderMathPreview).onChange(function (value) { + _this.plugin.settings.renderMathPreview = value; + _this.plugin.saveData(_this.plugin.settings); + if (_this.plugin.settings.renderMathPreview) { + _this.app.workspace.iterateCodeMirrors(function (cm) { + init_math_preview(cm); + }); + } + else { + var previewEl = document.querySelector("#math-preview"); + if (previewEl) { + document.querySelector("#math-preview").detach(); + } + _this.app.workspace.iterateCodeMirrors(function (cm) { + unload_math_preview(cm); + }); + } + }); + }); + new obsidian.Setting(containerEl) + .setName("Render Code Blocks") + .setDesc("If this is disabled, none of the options below will do anything") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.renderCode).onChange(function (value) { + _this.plugin.settings.renderCode = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("hmdFold", { + image: _this.plugin.settings.foldImages, + link: _this.plugin.settings.foldLinks, + html: _this.plugin.settings.renderHTML, + code: _this.plugin.settings.renderCode, + math: _this.plugin.settings.renderMath, + }); + }); + }); + new obsidian.Setting(containerEl) + .setName("Render Admonitions") + .setDesc("") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.renderAdmonition).onChange(function (value) { + _this.plugin.settings.renderAdmonition = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("hmdFoldCode", { + admonition: _this.plugin.settings.renderAdmonition, + chart: _this.plugin.settings.renderChart, + query: _this.plugin.settings.renderQuery, + dataview: _this.plugin.settings.renderDataview, + }); + }); + }); + new obsidian.Setting(containerEl) + .setName("Render Charts") + .setDesc("") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.renderChart).onChange(function (value) { + _this.plugin.settings.renderChart = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("hmdFoldCode", { + admonition: _this.plugin.settings.renderAdmonition, + chart: _this.plugin.settings.renderChart, + query: _this.plugin.settings.renderQuery, + dataview: _this.plugin.settings.renderDataview, + }); + }); + }); + new obsidian.Setting(containerEl) + .setName("Render Embedded Search") + .setDesc("") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.renderQuery).onChange(function (value) { + _this.plugin.settings.renderQuery = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("hmdFoldCode", { + admonition: _this.plugin.settings.renderAdmonition, + chart: _this.plugin.settings.renderChart, + query: _this.plugin.settings.renderQuery, + dataview: _this.plugin.settings.renderDataview, + }); + }); + }); + new obsidian.Setting(containerEl) + .setName("Render Dataview") + .setDesc("") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.renderDataview).onChange(function (value) { + _this.plugin.settings.renderDataview = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("hmdFoldCode", { + admonition: _this.plugin.settings.renderAdmonition, + chart: _this.plugin.settings.renderChart, + query: _this.plugin.settings.renderQuery, + dataview: _this.plugin.settings.renderDataview, + }); + }); + }); + new obsidian.Setting(containerEl) + .setName("Render Banners") + .setDesc("This settings requires that the \"Container Attributes\" setting is enabled") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.renderBanner).onChange(function (value) { + _this.plugin.settings.renderBanner = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.applyBodyClasses(); + _this.app.workspace.iterateCodeMirrors(function (cm) { + cm.refresh(); + }); + }); + }); + containerEl.createEl("h3", { + text: "Visual Styling", + }); + new obsidian.Setting(containerEl) + .setName("Container Attributes") + .setDesc("Apply data attributes to the CodeMirror line div elements that describe the contained child elements. Think of\n this like Contextual Typography for Edit Mode.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.containerAttributes).onChange(function (value) { + _this.plugin.settings.containerAttributes = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorHandlers("renderLine", _this.plugin.onRenderLineBound, value, true); + }); + }); + new obsidian.Setting(this.containerEl) + .setName("⚠️ Allowed Front Matter Keys") + .setDesc("A comma seperated list of front matter keys to turn into CSS variables and data attributes") + .setClass("frontmatter-key-list-setting") + .addText(function (textfield) { + textfield.setPlaceholder(String("")); + textfield.inputEl.type = "text"; + textfield.setValue(String(_this.plugin.settings.allowedYamlKeys)); + textfield.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + this.plugin.settings.allowedYamlKeys = value; + this.plugin.saveData(this.plugin.settings); + return [2 /*return*/]; + }); + }); }); + }); + new obsidian.Setting(containerEl) + .setName("Auto Align Tables") + .setDesc("Automatically align markdown tables as they are being built. Note: This setting currently requires that OpenMD Mode be enabled.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.autoAlignTables).onChange(function (value) { + _this.plugin.settings.autoAlignTables = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("hmdTableAlign", _this.plugin.settings.autoAlignTables); + }); + }); + new obsidian.Setting(containerEl) + .setName("Dynamic cursor size") + .setDesc("When enabled, the cursor height will be determined by the max height of the entire line. \n When disabled, the cursor's height is based on the height of the adjacent reference character.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.dynamicCursor).onChange(function (value) { + _this.plugin.settings.dynamicCursor = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("singleCursorHeightPerLine", !_this.plugin.settings.dynamicCursor); + }); + }); + new obsidian.Setting(containerEl) + .setName("Style active selection") + .setDesc("When enabled, selected text will be marked with the CSS class .CodeMirror-selectedtext. \n Useful to force the styling of selected text when ::selection is not sufficient.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.markSelection).onChange(function (value) { + _this.plugin.settings.markSelection = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("styleSelectedText", _this.plugin.settings.markSelection); + _this.plugin.applyBodyClasses(); + }); + }); + new obsidian.Setting(containerEl) + .setName("Retain active line on selection") + .setDesc("When enabled, text selection will not remove the .active-line class on the current line. \n When disabled text selection on the active line will remove the .active-line class.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.activeLineOnSelect).onChange(function (value) { + _this.plugin.settings.activeLineOnSelect = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.updateCodeMirrorOption("styleActiveLine", _this.plugin.settings.activeLineOnSelect ? { nonEmpty: true } : true); + }); + }); + new obsidian.Setting(containerEl) + .setName("Cursor Blink Rate") + .setDesc("Value is in milliseconds. Default is 530. Set to 0 to disable blinking.") + .addText(function (textfield) { + textfield.setPlaceholder(String(530)); + textfield.inputEl.type = "number"; + textfield.setValue(String(_this.plugin.settings.cursorBlinkRate)); + textfield.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + this.plugin.settings.cursorBlinkRate = Number(value); + this.plugin.saveData(this.plugin.settings); + this.plugin.updateCodeMirrorOption("cursorBlinkRate", this.plugin.settings.cursorBlinkRate); + return [2 /*return*/]; + }); + }); }); + }); + containerEl.createEl("h3", { + text: "Syntax Highlighting", + }); + var lineNums, copyButton, copyButtonPre; + if ( + //@ts-ignore + this.app.plugins.plugins["cm-editor-syntax-highlight-obsidian"]) { + new obsidian.Setting(containerEl) + .setName("Enable Edit Mode Syntax Highlighting Themes") + .setDesc("Apply syntax highlighting themes to code blocks in edit mode. The default theme is Material Pale Night\n but additional themes are available via the Style Settings plugin") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.syntaxHighlighting).onChange(function (value) { + _this.plugin.settings.syntaxHighlighting = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.applyBodyClasses(true); + }); + }); + new obsidian.Setting(containerEl) + .setName("Enable Preview Mode Syntax Highlighting Themes") + .setDesc("Apply syntax highlighting themes to code blocks in preview mode. The default theme is Material Pale Night\n but additional themes are available via the Style Settings plugin") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.enablePrismJSStyling).onChange(function (value) { + _this.plugin.settings.enablePrismJSStyling = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.applyBodyClasses(true); + }); + }); + new obsidian.Setting(containerEl) + .setName("Use CodeMirror for syntax highlighting in preview mode") + .setDesc("This setting creates consistent highlighting between edit and preview by using CodeMirror to highlight code in both modes.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.enableCMinPreview).onChange(function (value) { + _this.plugin.settings.enableCMinPreview = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.applyBodyClasses(true); + _this.plugin.settings.enableCMinPreview + ? (lineNums.settingEl.removeClass("setting-disabled"), + copyButton.settingEl.removeClass("setting-disabled"), + copyButtonPre.settingEl.removeClass("setting-disabled")) + : (lineNums.settingEl.addClass("setting-disabled"), + copyButton.settingEl.addClass("setting-disabled"), + copyButtonPre.settingEl.addClass("setting-disabled")); + }); + }); + lineNums = new obsidian.Setting(containerEl) + .setName("⚠️ Show line numbers for code blocks in preview mode") + .setDesc("This setting will add line numbers to code blocks in preview mode.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.showLineNums).onChange(function (value) { + _this.plugin.settings.showLineNums = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.applyBodyClasses(true); + }); + }); + copyButton = new obsidian.Setting(containerEl) + .setName("Enable copy button to code blocks in preview mode") + .setDesc("This setting will add a copy button to the bottom left corner of code blocks in preview mode. The button will show up on code block hover.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.copyButton).onChange(function (value) { + _this.plugin.settings.copyButton = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.applyBodyClasses(true); + }); + }); + copyButtonPre = new obsidian.Setting(containerEl) + .setName("⚠️ Enable copy button to all PRE blocks in preview mode") + .setDesc("This setting will add a copy button to any PRE element. This could negatively impact certain plugins that render PRE blocks.") + .addToggle(function (toggle) { + return toggle.setValue(_this.plugin.settings.copyButtonOnPRE).onChange(function (value) { + _this.plugin.settings.copyButtonOnPRE = value; + _this.plugin.saveData(_this.plugin.settings); + _this.plugin.applyBodyClasses(true); + }); + }); + } + else { + new obsidian.Setting(containerEl) + .setName("Use CodeMirror for syntax highlighting in preview mode") + .setDesc('⚠️ Install the plugin "Editor Syntax Highlight" in order to use this feature') + .setClass("info"); + } + containerEl.createEl("h3", { + text: "Syntax Highlighting Theme", + }); + new obsidian.Setting(containerEl) + .setName("Refer to the Style Settings plugin") + .setDesc("To customize the syntax highlighting theme, \n install the Style Settings plugin and expand the \"CodeMirror Options\" section") + .setClass("info"); + // update dynamic setting visibility + this.plugin.settings.editModeHideTokens + ? tokenSettings.settingEl.removeClass("setting-disabled") + : tokenSettings.settingEl.addClass("setting-disabled"); + this.plugin.settings.enableCMinPreview + ? (lineNums === null || lineNums === void 0 ? void 0 : lineNums.settingEl.removeClass("setting-disabled"), + copyButton === null || copyButton === void 0 ? void 0 : copyButton.settingEl.removeClass("setting-disabled"), + copyButtonPre === null || copyButtonPre === void 0 ? void 0 : copyButtonPre.settingEl.removeClass("setting-disabled")) + : (lineNums === null || lineNums === void 0 ? void 0 : lineNums.settingEl.addClass("setting-disabled"), + copyButton === null || copyButton === void 0 ? void 0 : copyButton.settingEl.addClass("setting-disabled"), + copyButtonPre === null || copyButtonPre === void 0 ? void 0 : copyButtonPre.settingEl.addClass("setting-disabled")); + }; + return ObsidianCodeMirrorOptionsSettingsTab; +}(obsidian.PluginSettingTab)); + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +function leftFillNum(num, targetLength) { + return num.toString().padStart(targetLength, 0); +} + +CodeMirror.runMode = function (string, modespec, callback, options) { + var mode = CodeMirror.getMode(CodeMirror.defaults, modespec); + var lineNumber = 1; + if (callback.nodeType == 1) { + var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize; + var lineNums = (options && options.lineNums) || false; + var node = callback, + col = 0; + node.innerHTML = ""; + callback = function (text, style) { + if (text == "\n") { + if (lineNums) { + lineNumber++; //increment line number + var lineNum = document.createElement("span"); + lineNum.addClass("cm-linenumber"); + var content = document.createTextNode(leftFillNum(lineNumber, 2) + " "); + lineNum.appendChild(content); + node.appendChild(document.createTextNode(text)); + node.appendChild(lineNum); + } else { + node.appendChild(document.createTextNode(text)); + } + col = 0; + return; + } + var content = ""; + // replace tabs + for (var pos = 0; ; ) { + var idx = text.indexOf("\t", pos); + if (idx == -1) { + content += text.slice(pos); + col += text.length - pos; + break; + } else { + col += idx - pos; + content += text.slice(pos, idx); + var size = tabSize - (col % tabSize); + col += size; + for (var i = 0; i < size; ++i) content += " "; + pos = idx + 1; + } + } + + if (style) { + var sp = node.appendChild(document.createElement("span")); + sp.className = "cm-" + style.replace(/ +/g, " cm-"); + sp.appendChild(document.createTextNode(content)); + } else { + node.appendChild(document.createTextNode(content)); + } + }; + } + + var lines = CodeMirror.splitLines(string), + state = (options && options.state) || CodeMirror.startState(mode); + var lineLength = lineNums && mode.name !== "yaml" ? lines.length - 1 : lines.length; + for (var i = 0, e = lineLength; i < e; ++i) { + if (i) callback("\n"); + var stream = new CodeMirror.StringStream(lines[i]); + while (!stream.eol()) { + var style = mode.token(stream, state); + callback(stream.current(), style, i, stream.start); + stream.start = stream.pos; + } + } + if (lineNums) { + var outputDiv = node; + var firstLine = document.createElement("span"); + firstLine.addClass("cm-linenumber"); + var content = document.createTextNode(leftFillNum(1, 2) + " "); + firstLine.appendChild(content); + outputDiv?.insertBefore(firstLine, outputDiv.firstChild); + } +}; + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +CodeMirror.colorize = (function () { + var isBlock = /^(p|li|div|h\\d|pre|blockquote|td)$/; + + function textContent(node, out) { + if (node.nodeType == 3) return out.push(node.nodeValue); + for (var ch = node.firstChild; ch; ch = ch.nextSibling) { + textContent(ch, out); + if (isBlock.test(node.nodeType)) out.push("\n"); + } + } + + return function (collection, defaultMode, showLineNums = false) { + if (!collection) collection = document.body.getElementsByTagName("pre"); + + for (var i = 0; i < collection.length; ++i) { + var node = collection[i]; + var mode = node.getAttribute("data-lang") || defaultMode; + if (!mode) continue; + + var text = []; + textContent(node, text); + node.innerHTML = ""; + CodeMirror.runMode(text.join(""), mode, node, { lineNums: showLineNums }); + node.parentElement.className += " cm-s-obsidian"; + } + }; +})(); + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Because sometimes you need to mark the selected *text*. +// +// Adds an option 'styleSelectedText' which, when enabled, gives +// selected text the CSS class given as option value, or +// "CodeMirror-selectedtext" when the value is not a string. + +(function(mod) { + mod(CodeMirror); +})(function(CodeMirror) { + + CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) { + var prev = old && old != CodeMirror.Init; + if (val && !prev) { + cm.state.markedSelection = []; + cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext"; + reset(cm); + cm.on("cursorActivity", onCursorActivity); + cm.on("change", onChange); + } else if (!val && prev) { + cm.off("cursorActivity", onCursorActivity); + cm.off("change", onChange); + clear(cm); + cm.state.markedSelection = cm.state.markedSelectionStyle = null; + } + }); + + function onCursorActivity(cm) { + if (cm.state.markedSelection) + cm.operation(function() { update(cm); }); + } + + function onChange(cm) { + if (cm.state.markedSelection && cm.state.markedSelection.length) + cm.operation(function() { clear(cm); }); + } + + var CHUNK_SIZE = 8; + var Pos = CodeMirror.Pos; + var cmp = CodeMirror.cmpPos; + + function coverRange(cm, from, to, addAt) { + if (cmp(from, to) == 0) return; + var array = cm.state.markedSelection; + var cls = cm.state.markedSelectionStyle; + for (var line = from.line;;) { + var start = line == from.line ? from : Pos(line, 0); + var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line; + var end = atEnd ? to : Pos(endLine, 0); + var mark = cm.markText(start, end, {className: cls}); + if (addAt == null) array.push(mark); + else array.splice(addAt++, 0, mark); + if (atEnd) break; + line = endLine; + } + } + + function clear(cm) { + var array = cm.state.markedSelection; + for (var i = 0; i < array.length; ++i) array[i].clear(); + array.length = 0; + } + + function reset(cm) { + clear(cm); + var ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) + coverRange(cm, ranges[i].from(), ranges[i].to()); + } + + function update(cm) { + if (!cm.somethingSelected()) return clear(cm); + if (cm.listSelections().length > 1) return reset(cm); + + var from = cm.getCursor("start"), to = cm.getCursor("end"); + + var array = cm.state.markedSelection; + if (!array.length) return coverRange(cm, from, to); + + var coverStart = array[0].find(), coverEnd = array[array.length - 1].find(); + if (!coverStart || !coverEnd || to.line - from.line <= CHUNK_SIZE || + cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0) + return reset(cm); + + while (cmp(from, coverStart.from) > 0) { + array.shift().clear(); + coverStart = array[0].find(); + } + if (cmp(from, coverStart.from) < 0) { + if (coverStart.to.line - from.line < CHUNK_SIZE) { + array.shift().clear(); + coverRange(cm, from, coverStart.to, 0); + } else { + coverRange(cm, from, coverStart.from, 0); + } + } + + while (cmp(to, coverEnd.to) < 0) { + array.pop().clear(); + coverEnd = array[array.length - 1].find(); + } + if (cmp(to, coverEnd.to) > 0) { + if (to.line - coverEnd.from.line < CHUNK_SIZE) { + array.pop().clear(); + coverRange(cm, coverEnd.from, to); + } else { + coverRange(cm, coverEnd.to, to); + } + } + } +}); + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function (mod) { + mod(CodeMirror); +})(function (CodeMirror) { + var WRAP_CLASS = "CodeMirror-activeline"; + var BACK_CLASS = "CodeMirror-activeline-background"; + var GUTT_CLASS = "CodeMirror-activeline-gutter"; + + CodeMirror.defineOption("styleActiveLine", false, function (cm, val, old) { + var prev = old == CodeMirror.Init ? false : old; + if (val == prev) return; + if (prev) { + cm.off("beforeSelectionChange", selectionChange); + clearActiveLines(cm); + delete cm.state.activeLines; + } + if (val) { + cm.state.activeLines = []; + updateActiveLines(cm, cm.listSelections()); + cm.on("beforeSelectionChange", selectionChange); + cm.refresh(); + } + }); + + function clearActiveLines(cm) { + for (var i = 0; i < cm.state.activeLines.length; i++) { + cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS); + cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS); + cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS); + } + } + + function sameArray(a, b) { + if (a.length != b.length) return false; + for (var i = 0; i < a.length; i++) if (a[i] != b[i]) return false; + return true; + } + + function updateActiveLines(cm, ranges) { + var active = []; + for (var i = 0; i < ranges.length; i++) { + var range = ranges[i]; + var option = cm.getOption("styleActiveLine"); + // if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty()) + // nothingislost: modified the nonEmpty option to support multiple selected lines + if (typeof option == "object" && option.nonEmpty ? false : !range.empty()) continue; + // nothingislost: support forwards and backwards multi line selections + if (range.head.line > range.anchor.line) { + var start = range.anchor.line, + end = range.head.line; + } else { + var start = range.head.line, + end = range.anchor.line; + } + // nothingislost: get the visual start for all lines in the selection + for (var j = start; j < end + 1; ++j) { + var line = cm.getLineHandleVisualStart(j); + if (active[active.length - 1] != line) active.push(line); + } + } + if (sameArray(cm.state.activeLines, active)) return; + cm.operation(function () { + clearActiveLines(cm); + for (var i = 0; i < active.length; i++) { + cm.addLineClass(active[i], "wrap", WRAP_CLASS); + cm.addLineClass(active[i], "background", BACK_CLASS); + cm.addLineClass(active[i], "gutter", GUTT_CLASS); + } + cm.state.activeLines = active; + }); + } + + function selectionChange(cm, sel) { + updateActiveLines(cm, sel.ranges); + } +}); + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function createCommonjsModule(fn, basedir, module) { + return module = { + path: basedir, + exports: {}, + require: function (path, base) { + return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); + } + }, fn(module, module.exports), module.exports; +} + +function commonjsRequire () { + throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); +} + +createCommonjsModule(function (module) { +/*! + * HyperMD, copyright (c) by laobubu + * Distributed under an MIT license: http://laobubu.net/HyperMD/LICENSE + * + * Break the Wall between writing and preview, in a Markdown Editor. + * + * HyperMD makes Markdown editor on web WYSIWYG, based on CodeMirror + * + * Homepage: http://laobubu.net/HyperMD/ + * Issues: https://github.com/laobubu/HyperMD/issues + */ +(function (global, factory) { + (global = typeof globalThis !== "undefined" ? globalThis : global || self), + factory((global.HyperMD = {}), global.CodeMirror); +})(commonjsGlobal, function (exports, CodeMirror) { + + /** + * Provides some common PolyFill + * + * @internal Part of HyperMD core. + * + * You shall NOT import this file; please import "core" instead + */ + if (typeof Object["assign"] != "function") { + // Must be writable: true, enumerable: false, configurable: true + Object.defineProperty(Object, "assign", { + value: function assign(target, varArgs) { + var arguments$1 = arguments; + + if (target == null) { + // TypeError if undefined or null + throw new TypeError("Cannot convert undefined or null to object"); + } + var to = Object(target); + for (var index = 1; index < arguments.length; index++) { + var nextSource = arguments$1[index]; + if (nextSource != null) { + // Skip over if undefined or null + for (var nextKey in nextSource) { + // Avoid bugs when hasOwnProperty is shadowed + if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { + to[nextKey] = nextSource[nextKey]; + } + } + } + } + return to; + }, + writable: true, + configurable: true, + }); + } + + /** + * Provides some universal utils + * + * @internal Part of HyperMD core. + * + * You shall NOT import this file; please import "core" instead + */ + /** Simple FlipFlop */ + var FlipFlop = /** @class */ (function () { + /** + * Simple FlipFlop + * + * @param {function} on_cb see FlipFlop.ON(callback) + * @param {function} off_cb see FlipFlop.OFF(callback) + * @param {T} [state] initial state. default: false (boolean) + * @param {string} [subkey] if get an object, use this key to retrive status. default: "enabled" + */ + function FlipFlop(on_cb, off_cb, state, subkey) { + if (state === void 0) { + state = false; + } + if (subkey === void 0) { + subkey = "enabled"; + } + this.on_cb = on_cb; + this.off_cb = off_cb; + this.state = state; + this.subkey = subkey; + } + /** set a callback when state is changed and is **NOT** `null`, `false` etc. */ + FlipFlop.prototype.ON = function (callback) { + this.on_cb = callback; + return this; + }; + /** set a callback when state is set to `null`, `false` etc. */ + FlipFlop.prototype.OFF = function (callback) { + this.off_cb = callback; + return this; + }; + /** + * Update FlipFlop status, and trig callback function if needed + * + * @param {T|object} state new status value. can be a object + * @param {boolean} [toBool] convert retrived value to boolean. default: false + */ + FlipFlop.prototype.set = function (state, toBool) { + var newVal = typeof state === "object" && state ? state[this.subkey] : state; + if (toBool) { + newVal = !!newVal; + } + if (newVal === this.state) { + return; + } + if ((this.state = newVal)) { + this.on_cb && this.on_cb(newVal); + } else { + this.off_cb && this.off_cb(newVal); + } + }; + FlipFlop.prototype.setBool = function (state) { + return this.set(state, true); + }; + /** + * Bind to a object's property with `Object.defineProperty` + * so that you may set state with `obj.enable = true` + */ + FlipFlop.prototype.bind = function (obj, key, toBool) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + var _this = this; + Object.defineProperty(obj, key, { + get: function () { + return _this.state; + }, + set: function (v) { + return _this.set(v, toBool); + }, + configurable: true, + enumerable: true, + }); + return this; + }; + return FlipFlop; + })(); + /** async run a function, and retry up to N times until it returns true */ + function tryToRun(fn, times, onFailed) { + times = ~~times || 5; + var delayTime = 250; + function nextCycle() { + if (!times--) { + if (onFailed) { + onFailed(); + } + return; + } + try { + if (fn()) { + return; + } + } catch (e) {} + setTimeout(nextCycle, delayTime); + delayTime *= 2; + } + setTimeout(nextCycle, 0); + } + /** + * make a debounced function + * + * @param {Function} fn + * @param {number} delay in ms + */ + function debounce(fn, delay) { + var deferTask = null; + var notClearBefore = 0; + var run = function () { + fn(); + deferTask = 0; + }; + var ans = function () { + var nowTime = +new Date(); + if (deferTask) { + if (nowTime < notClearBefore) { + return; + } else { + clearTimeout(deferTask); + } + } + deferTask = setTimeout(run, delay); + notClearBefore = nowTime + 100; // allow 100ms error + }; + ans.stop = function () { + if (!deferTask) { + return; + } + clearTimeout(deferTask); + deferTask = 0; + }; + return ans; + } + /** + * addClass / removeClass etc. + * + * using CodeMirror's (although they're legacy API) + */ + var addClass = CodeMirror.addClass; + var rmClass = CodeMirror.rmClass; + var contains = CodeMirror.contains; + /** + * a fallback for new Array(count).fill(data) + */ + function repeat(item, count) { + var ans = new Array(count); + if (ans["fill"]) { + ans["fill"](item); + } else { + for (var i = 0; i < count; i++) { + ans[i] = item; + } + } + return ans; + } + function repeatStr(item, count) { + var ans = ""; + while (count-- > 0) { + ans += item; + } + return ans; + } + /** + * Visit element nodes and their children + */ + function visitElements(seeds, handler) { + var queue = [seeds], + tmp; + while ((tmp = queue.shift())) { + for (var i = 0; i < tmp.length; i++) { + var el = tmp[i]; + if (!el || el.nodeType != Node.ELEMENT_NODE) { + continue; + } + handler(el); + if (el.children && el.children.length > 0) { + queue.push(el.children); + } + } + } + } + /** + * A lazy and simple Element size watcher. NOT WORK with animations + */ + function watchSize(el, onChange, needPoll) { + var _a = el.getBoundingClientRect(), + width = _a.width, + height = _a.height; + /** check size and trig onChange */ + var check = debounce(function () { + var rect = el.getBoundingClientRect(); + var newWidth = rect.width, + newHeight = rect.height; + if (width != newWidth || height != newHeight) { + onChange(newWidth, newHeight, width, height); + width = newWidth; + height = newHeight; + setTimeout(check, 200); // maybe changed again later? + } + }, 100); + var nextTimer = null; + function pollOnce() { + if (nextTimer) { + clearTimeout(nextTimer); + } + if (!stopped) { + nextTimer = setTimeout(pollOnce, 200); + } + check(); + } + var stopped = false; + function stop() { + stopped = true; + check.stop(); + if (nextTimer) { + clearTimeout(nextTimer); + nextTimer = null; + } + for (var i = 0; i < eventBinded.length; i++) { + eventBinded[i][0].removeEventListener(eventBinded[i][1], check, false); + } + } + var eventBinded = []; + function bindEvents(el) { + var tagName = el.tagName; + var computedStyle = getComputedStyle(el); + var getStyle = function (name) { + return computedStyle.getPropertyValue(name) || ""; + }; + if (getStyle("resize") != "none") { + needPoll = true; + } + // size changes if loaded + if (/^(?:img|video)$/i.test(tagName)) { + el.addEventListener("load", check, false); + el.addEventListener("error", check, false); + } else if (/^(?:details|summary)$/i.test(tagName)) { + el.addEventListener("click", check, false); + } + } + if (!needPoll) { + visitElements([el], bindEvents); + } + // bindEvents will update `needPoll` + if (needPoll) { + nextTimer = setTimeout(pollOnce, 200); + } + return { + check: check, + stop: stop, + }; + } + function makeSymbol(name) { + if (typeof Symbol === "function") { + return Symbol(name); + } + return "_\n" + name + "\n_" + Math.floor(Math.random() * 0xffff).toString(16); + } + + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + + var __assign = function () { + __assign = + Object.assign || + function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; + + /** + * Ready-to-use functions that powers up your Markdown editor + * + * @internal Part of HyperMD core. + * + * You shall NOT import this file; please import "core" instead + */ + // if (HyperMD_Mark in editor), the editor was a HyperMD mode at least once + var HyperMD_Mark = "__hypermd__"; + /** + * The default configuration that used by `HyperMD.fromTextArea` + * + * Addons may update this object freely! + */ + var suggestedEditorConfig = { + lineNumbers: true, + lineWrapping: true, + theme: "light", + mode: "text/x-hypermd", + tabSize: 4, + autoCloseBrackets: true, + foldGutter: true, + gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "HyperMD-goback"], + }; + /** + * Editor Options that disable HyperMD WYSIWYG visual effects. + * These option will be applied when user invoke `switchToNormal`. + * + * Addons about visual effects, shall update this object! + */ + var normalVisualConfig = { + theme: "default", + }; + /** + * Initialize an editor from a