Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.
23 changes: 21 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
"katex": "0.16.21",
"leaflet": "1.9.4",
"leaflet-gpx": "2.1.2",
"mark.js": "8.11.1",
"marked": "15.0.7",
"mermaid": "11.6.0",
"mime-types": "3.0.1",
Expand All @@ -147,7 +146,6 @@
"tmp": "0.2.3",
"turndown": "7.2.0",
"unescape": "1.0.1",
"vanilla-js-wheel-zoom": "9.0.4",
"ws": "8.18.1",
"xml2js": "0.6.2",
"yauzl": "3.2.0"
Expand Down Expand Up @@ -229,6 +227,7 @@
"jsdoc": "4.0.4",
"knockout": "3.5.1",
"lorem-ipsum": "2.0.8",
"mark.js": "8.11.1",
"mind-elixir": "4.4.3",
"mini-css-extract-plugin": "2.9.2",
"nodemon": "3.1.9",
Expand All @@ -239,6 +238,7 @@
"rimraf": "6.0.1",
"sass": "1.86.0",
"sass-loader": "16.0.5",
"script-loader": "0.7.2",
"split.js": "1.6.5",
"supertest": "7.1.0",
"svg-pan-zoom": "3.6.2",
Expand All @@ -249,6 +249,7 @@
"typedoc": "0.28.1",
"typescript": "5.8.2",
"typescript-eslint": "8.28.0",
"vanilla-js-wheel-zoom": "9.0.4",
"vitest": "3.0.9",
"webpack": "5.98.0",
"webpack-cli": "6.0.1",
Expand Down
22 changes: 14 additions & 8 deletions src/public/app/services/content_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { loadElkIfNeeded, postprocessMermaidSvg } from "./mermaid.js";
import { normalizeMimeTypeForCKEditor } from "./mime_type_definitions.js";
import renderDoc from "./doc_renderer.js";
import { t } from "i18next";
import type { Mermaid } from "mermaid";
import WheelZoom from 'vanilla-js-wheel-zoom';

let idCounter = 1;

Expand Down Expand Up @@ -150,13 +150,19 @@ function renderImage(entity: FNote | FAttachment, $renderedContent: JQuery<HTMLE
$renderedContent.append($img);

if (options.imageHasZoom) {
libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM).then(() => {
WZoom.create(`#${$img.attr("id")}`, {
maxScale: 50,
speed: 1.3,
zoomOnClick: false
});
});
const initZoom = async () => {
const element = document.querySelector(`#${$img.attr("id")}`);
if (element) {
WheelZoom.create(`#${$img.attr("id")}`, {
maxScale: 50,
speed: 1.3,
zoomOnClick: false
});
} else {
requestAnimationFrame(initZoom);
}
};
initZoom();
}

imageContextMenuService.setupContextMenu($img);
Expand Down
22 changes: 1 addition & 21 deletions src/public/app/services/library_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,11 @@ const CODE_MIRROR: Library = {
css: ["node_modules/codemirror/lib/codemirror.css", "node_modules/codemirror/addon/lint/lint.css"]
};

const CALENDAR_WIDGET: Library = {
css: ["stylesheets/calendar.css"]
};

const KATEX: Library = {
js: ["node_modules/katex/dist/katex.min.js", "node_modules/katex/dist/contrib/mhchem.min.js", "node_modules/katex/dist/contrib/auto-render.min.js"],
css: ["node_modules/katex/dist/katex.min.css"]
};

const WHEEL_ZOOM: Library = {
js: ["node_modules/vanilla-js-wheel-zoom/dist/wheel-zoom.min.js"]
};

const MARKJS: Library = {
js: ["node_modules/mark.js/dist/jquery.mark.es6.min.js"]
};

const HIGHLIGHT_JS: Library = {
js: () => {
const mimeTypes = mimeTypesService.getMimeTypes();
Expand All @@ -85,10 +73,6 @@ const HIGHLIGHT_JS: Library = {
}
};

const LEAFLET: Library = {
css: ["node_modules/leaflet/dist/leaflet.css"]
};

async function requireLibrary(library: Library) {
if (library.css) {
library.css.map((cssUrl) => requireCss(cssUrl));
Expand Down Expand Up @@ -174,10 +158,6 @@ export default {
loadHighlightingTheme,
CKEDITOR,
CODE_MIRROR,
CALENDAR_WIDGET,
KATEX,
WHEEL_ZOOM,
MARKJS,
HIGHLIGHT_JS,
LEAFLET
HIGHLIGHT_JS
};
7 changes: 0 additions & 7 deletions src/public/app/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@ declare global {
var renderMathInElement: (element: HTMLElement, options: {
trust: boolean;
}) => void;
var WZoom = {
create(selector: string, opts: {
maxScale: number;
speed: number;
zoomOnClick: boolean
})
};
interface CKCodeBlockLanguage {
language: string;
label: string;
Expand Down
3 changes: 1 addition & 2 deletions src/public/app/widgets/buttons/calendar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { t } from "../../services/i18n.js";
import libraryLoader from "../../services/library_loader.js";
import utils from "../../services/utils.js";
import dateNoteService from "../../services/date_notes.js";
import server from "../../services/server.js";
Expand All @@ -9,6 +8,7 @@ import toastService from "../../services/toast.js";
import options from "../../services/options.js";
import { Dropdown } from "bootstrap";
import type { EventData } from "../../components/app_context.js";
import "../../../stylesheets/calendar.css";

const MONTHS = [
t("calendar.january"),
Expand Down Expand Up @@ -188,7 +188,6 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
}

async dropdownShown() {
await libraryLoader.requireLibrary(libraryLoader.CALENDAR_WIDGET);
this.init(appContext.tabManager.getActiveContextNote()?.getOwnedLabelValue("dateNote") ?? null);
}

Expand Down
3 changes: 1 addition & 2 deletions src/public/app/widgets/find_in_html.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// ck-find-result and ck-find-result_selected are the styles ck-editor
// uses for highlighting matches, use the same one on CodeMirror
// for consistency
import libraryLoader from "../services/library_loader.js";
import utils from "../services/utils.js";
import appContext from "../components/app_context.js";
import type FindWidget from "./find.js";
Expand All @@ -23,7 +22,7 @@ export default class FindInHtml {
}

async performFind(searchTerm: string, matchCase: boolean, wholeWord: boolean) {
await libraryLoader.requireLibrary(libraryLoader.MARKJS);
await import("script-loader!mark.js/dist/jquery.mark.min.js");

const $content = await this.parent?.noteContext?.getContentElement();

Expand Down
32 changes: 14 additions & 18 deletions src/public/app/widgets/geo_map.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Map } from "leaflet";
import library_loader from "../services/library_loader.js";
import L from "leaflet";
import "leaflet/dist/leaflet.css";
import NoteContextAwareWidget from "./note_context_aware_widget.js";

const TPL = `\
Expand All @@ -21,7 +22,7 @@ const TPL = `\
<div class="geo-map-container"></div>
</div>`;

export type Leaflet = typeof import("leaflet");
export type Leaflet = typeof L;
export type InitCallback = (L: Leaflet) => void;

export default class GeoMapWidget extends NoteContextAwareWidget {
Expand All @@ -40,23 +41,18 @@ export default class GeoMapWidget extends NoteContextAwareWidget {

this.$container = this.$widget.find(".geo-map-container");

library_loader.requireLibrary(library_loader.LEAFLET).then(async () => {
const L = (await import("leaflet")).default;

const map = L.map(this.$container[0], {
worldCopyJump: true
});
const map = L.map(this.$container[0], {
worldCopyJump: true
});

this.map = map;
if (this.initCallback) {
this.initCallback(L);
}
this.map = map;
if (this.initCallback) {
this.initCallback(L);
}

L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
detectRetina: true
}).addTo(map);
});
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
detectRetina: true
}).addTo(map);
}

}
22 changes: 14 additions & 8 deletions src/public/app/widgets/type_widgets/image.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import utils from "../../services/utils.js";
import TypeWidget from "./type_widget.js";
import libraryLoader from "../../services/library_loader.js";
import imageContextMenuService from "../../menus/image_context_menu.js";
import imageService from "../../services/image.js";
import type FNote from "../../entities/fnote.js";
import type { EventData } from "../../components/app_context.js";
import WheelZoom from 'vanilla-js-wheel-zoom';

const TPL = `
<div class="note-detail-image note-detail-printable">
Expand Down Expand Up @@ -54,13 +54,19 @@ class ImageTypeWidget extends TypeWidget {
this.$imageWrapper = this.$widget.find(".note-detail-image-wrapper");
this.$imageView = this.$widget.find(".note-detail-image-view").attr("id", `image-view-${utils.randomString(10)}`);

libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM).then(() => {
WZoom.create(`#${this.$imageView.attr("id")}`, {
maxScale: 50,
speed: 1.3,
zoomOnClick: false
});
});
const initZoom = async () => {
const element = document.querySelector(`#${this.$imageView.attr("id")}`);
if (element) {
WheelZoom.create(`#${this.$imageView.attr("id")}`, {
maxScale: 50,
speed: 1.3,
zoomOnClick: false
});
} else {
requestAnimationFrame(initZoom);
}
};
initZoom();

imageContextMenuService.setupContextMenu(this.$imageView);

Expand Down
15 changes: 7 additions & 8 deletions src/public/app/widgets/view_widgets/list_or_grid_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import linkService from "../../services/link.js";
import contentRenderer from "../../services/content_renderer.js";
import froca from "../../services/froca.js";
import attributeRenderer from "../../services/attribute_renderer.js";
import libraryLoader from "../../services/library_loader.js";
import treeService from "../../services/tree.js";
import utils from "../../services/utils.js";
import type FNote from "../../entities/fnote.js";
Expand Down Expand Up @@ -216,7 +215,7 @@ class ListOrGridView extends ViewMode {

const highlightedTokens = this.parentNote.highlightedTokens || [];
if (highlightedTokens.length > 0) {
await libraryLoader.requireLibrary(libraryLoader.MARKJS);
await import("script-loader!mark.js/dist/jquery.mark.min.js");

const regex = highlightedTokens.map((token) => utils.escapeRegExp(token)).join("|");

Expand Down Expand Up @@ -269,12 +268,12 @@ class ListOrGridView extends ViewMode {
i === this.page
? $("<span>").text(i).css("text-decoration", "underline").css("font-weight", "bold")
: $('<a href="javascript:">')
.text(i)
.attr("title", `Page of ${startIndex} - ${endIndex}`)
.on("click", () => {
this.page = i;
this.renderList();
}),
.text(i)
.attr("title", `Page of ${startIndex} - ${endIndex}`)
.on("click", () => {
this.page = i;
this.renderList();
}),
" &nbsp; "
);
} else if (lastPrinted) {
Expand Down
Loading