chore: 🤖 move mark.js to webpack

This commit is contained in:
Jin 2025-03-28 16:23:06 +01:00
parent 94bc550c67
commit 2476e0b504
5 changed files with 5 additions and 13 deletions

3
package-lock.json generated
View File

@ -66,7 +66,6 @@
"katex": "0.16.21", "katex": "0.16.21",
"leaflet": "1.9.4", "leaflet": "1.9.4",
"leaflet-gpx": "2.1.2", "leaflet-gpx": "2.1.2",
"mark.js": "8.11.1",
"marked": "15.0.7", "marked": "15.0.7",
"mermaid": "11.6.0", "mermaid": "11.6.0",
"mime-types": "2.1.35", "mime-types": "2.1.35",
@ -173,6 +172,7 @@
"jsdoc": "4.0.4", "jsdoc": "4.0.4",
"knockout": "3.5.1", "knockout": "3.5.1",
"lorem-ipsum": "2.0.8", "lorem-ipsum": "2.0.8",
"mark.js": "8.11.1",
"mind-elixir": "4.4.3", "mind-elixir": "4.4.3",
"mini-css-extract-plugin": "2.9.2", "mini-css-extract-plugin": "2.9.2",
"nodemon": "3.1.9", "nodemon": "3.1.9",
@ -15066,6 +15066,7 @@
"version": "8.11.1", "version": "8.11.1",
"resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz", "resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz",
"integrity": "sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==", "integrity": "sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/markdown-it": { "node_modules/markdown-it": {

View File

@ -125,7 +125,6 @@
"katex": "0.16.21", "katex": "0.16.21",
"leaflet": "1.9.4", "leaflet": "1.9.4",
"leaflet-gpx": "2.1.2", "leaflet-gpx": "2.1.2",
"mark.js": "8.11.1",
"marked": "15.0.7", "marked": "15.0.7",
"mermaid": "11.6.0", "mermaid": "11.6.0",
"mime-types": "2.1.35", "mime-types": "2.1.35",
@ -229,6 +228,7 @@
"jsdoc": "4.0.4", "jsdoc": "4.0.4",
"knockout": "3.5.1", "knockout": "3.5.1",
"lorem-ipsum": "2.0.8", "lorem-ipsum": "2.0.8",
"mark.js": "8.11.1",
"mind-elixir": "4.4.3", "mind-elixir": "4.4.3",
"mini-css-extract-plugin": "2.9.2", "mini-css-extract-plugin": "2.9.2",
"nodemon": "3.1.9", "nodemon": "3.1.9",

View File

@ -51,10 +51,6 @@ const KATEX: Library = {
css: ["node_modules/katex/dist/katex.min.css"] css: ["node_modules/katex/dist/katex.min.css"]
}; };
const MARKJS: Library = {
js: ["node_modules/mark.js/dist/jquery.mark.es6.min.js"]
};
const HIGHLIGHT_JS: Library = { const HIGHLIGHT_JS: Library = {
js: () => { js: () => {
const mimeTypes = mimeTypesService.getMimeTypes(); const mimeTypes = mimeTypesService.getMimeTypes();
@ -172,7 +168,6 @@ export default {
CODE_MIRROR, CODE_MIRROR,
CALENDAR_WIDGET, CALENDAR_WIDGET,
KATEX, KATEX,
MARKJS,
HIGHLIGHT_JS, HIGHLIGHT_JS,
LEAFLET LEAFLET
}; };

View File

@ -1,11 +1,11 @@
// ck-find-result and ck-find-result_selected are the styles ck-editor // ck-find-result and ck-find-result_selected are the styles ck-editor
// uses for highlighting matches, use the same one on CodeMirror // uses for highlighting matches, use the same one on CodeMirror
// for consistency // for consistency
import libraryLoader from "../services/library_loader.js";
import utils from "../services/utils.js"; import utils from "../services/utils.js";
import appContext from "../components/app_context.js"; import appContext from "../components/app_context.js";
import type FindWidget from "./find.js"; import type FindWidget from "./find.js";
import type { FindResult } from "./find.js"; import type { FindResult } from "./find.js";
import 'mark.js';
const FIND_RESULT_SELECTED_CSS_CLASSNAME = "ck-find-result_selected"; const FIND_RESULT_SELECTED_CSS_CLASSNAME = "ck-find-result_selected";
const FIND_RESULT_CSS_CLASSNAME = "ck-find-result"; const FIND_RESULT_CSS_CLASSNAME = "ck-find-result";
@ -23,8 +23,6 @@ export default class FindInHtml {
} }
async performFind(searchTerm: string, matchCase: boolean, wholeWord: boolean) { async performFind(searchTerm: string, matchCase: boolean, wholeWord: boolean) {
await libraryLoader.requireLibrary(libraryLoader.MARKJS);
const $content = await this.parent?.noteContext?.getContentElement(); const $content = await this.parent?.noteContext?.getContentElement();
const wholeWordChar = wholeWord ? "\\b" : ""; const wholeWordChar = wholeWord ? "\\b" : "";

View File

@ -2,11 +2,11 @@ import linkService from "../../services/link.js";
import contentRenderer from "../../services/content_renderer.js"; import contentRenderer from "../../services/content_renderer.js";
import froca from "../../services/froca.js"; import froca from "../../services/froca.js";
import attributeRenderer from "../../services/attribute_renderer.js"; import attributeRenderer from "../../services/attribute_renderer.js";
import libraryLoader from "../../services/library_loader.js";
import treeService from "../../services/tree.js"; import treeService from "../../services/tree.js";
import utils from "../../services/utils.js"; import utils from "../../services/utils.js";
import type FNote from "../../entities/fnote.js"; import type FNote from "../../entities/fnote.js";
import ViewMode, { type ViewModeArgs } from "./view_mode.js"; import ViewMode, { type ViewModeArgs } from "./view_mode.js";
import 'mark.js';
const TPL = ` const TPL = `
<div class="note-list"> <div class="note-list">
@ -216,8 +216,6 @@ class ListOrGridView extends ViewMode {
const highlightedTokens = this.parentNote.highlightedTokens || []; const highlightedTokens = this.parentNote.highlightedTokens || [];
if (highlightedTokens.length > 0) { if (highlightedTokens.length > 0) {
await libraryLoader.requireLibrary(libraryLoader.MARKJS);
const regex = highlightedTokens.map((token) => utils.escapeRegExp(token)).join("|"); const regex = highlightedTokens.map((token) => utils.escapeRegExp(token)).join("|");
this.highlightRegex = new RegExp(regex, "gi"); this.highlightRegex = new RegExp(regex, "gi");