Compare commits

...

3 Commits

2 changed files with 14 additions and 4 deletions

View File

@ -67,12 +67,12 @@ class UI {
*/ */
public static updateUI(element?: Element) { public static updateUI(element?: Element) {
element = element || document.body; element = element || document.body;
UI.unescapeMarkTags(element);
UI.addLineNumbers(element); UI.addLineNumbers(element);
UI.addHighlighting(element); UI.addHighlighting(element);
UI.addBootstrapTooltips(element); UI.addBootstrapTooltips(element);
UI.renderTeX(element); UI.renderTeX(element);
UI.renderTimestamps(element); UI.renderTimestamps(element);
UI.unescapeMarkTags(element);
} }
/** /**
@ -81,6 +81,10 @@ class UI {
*/ */
public static addBootstrapTooltips(element?: Element) { public static addBootstrapTooltips(element?: Element) {
element = element || document.body; element = element || document.body;
const list = element.querySelectorAll('[data-bs-toggle="tooltip"]');
list.forEach((el: Element) => new bootstrap.Tooltip(el));
element.querySelectorAll("[title]").forEach((el) => { element.querySelectorAll("[title]").forEach((el) => {
el.setAttribute("data-bs-toggle", "tooltip"); el.setAttribute("data-bs-toggle", "tooltip");
el.setAttribute("data-bs-placement", "bottom"); el.setAttribute("data-bs-placement", "bottom");
@ -195,9 +199,6 @@ class UI {
let content = block.innerHTML; let content = block.innerHTML;
// but ugly fucking hack. I hate this // but ugly fucking hack. I hate this
content = content.replaceAll('<span class="token operator">&lt;</span>mark<span class="token operator">&gt;</span>', "<mark>");
content = content.replaceAll('<span class="token operator">&lt;</span><span class="token operator">/</span>mark<span class="token operator">&gt;</span>', "</mark>");
content = content.replaceAll("&lt;mark&gt;", "<mark>"); content = content.replaceAll("&lt;mark&gt;", "<mark>");
content = content.replaceAll("&lt;/mark&gt;", "</mark>"); content = content.replaceAll("&lt;/mark&gt;", "</mark>");
block.innerHTML = content; block.innerHTML = content;

View File

@ -5,8 +5,17 @@ import Input from "./Input";
const pkg = require("../../package.json"); const pkg = require("../../package.json");
declare const Handlebars: any; declare const Handlebars: any;
declare const Prism: any;
(() => { (() => {
Prism.languages.extend('markup', {});
Prism.languages.insertBefore('custom', 'tag', {
'mark': {
pattern: /<\/?mark(?:\s+\w+(?:=(?:"[^"]*"|'[^']*'|[^\s'">=]+))?\s*|\s*)\/?>/,
greedy: true
}
});
let isCtrl = false; let isCtrl = false;
document.addEventListener('keyup', (e) => { document.addEventListener('keyup', (e) => {
if (e.ctrlKey) isCtrl = false; if (e.ctrlKey) isCtrl = false;