mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
chore: 🤖 move wheel zoom to webpack
This commit is contained in:
parent
1a312bf01c
commit
94bc550c67
3
package-lock.json
generated
3
package-lock.json
generated
@ -91,7 +91,6 @@
|
|||||||
"tmp": "0.2.3",
|
"tmp": "0.2.3",
|
||||||
"turndown": "7.2.0",
|
"turndown": "7.2.0",
|
||||||
"unescape": "1.0.1",
|
"unescape": "1.0.1",
|
||||||
"vanilla-js-wheel-zoom": "9.0.4",
|
|
||||||
"ws": "8.18.1",
|
"ws": "8.18.1",
|
||||||
"xml2js": "0.6.2",
|
"xml2js": "0.6.2",
|
||||||
"yauzl": "3.2.0"
|
"yauzl": "3.2.0"
|
||||||
@ -192,6 +191,7 @@
|
|||||||
"typedoc": "0.28.1",
|
"typedoc": "0.28.1",
|
||||||
"typescript": "5.8.2",
|
"typescript": "5.8.2",
|
||||||
"typescript-eslint": "8.28.0",
|
"typescript-eslint": "8.28.0",
|
||||||
|
"vanilla-js-wheel-zoom": "9.0.4",
|
||||||
"vitest": "3.0.9",
|
"vitest": "3.0.9",
|
||||||
"webpack": "5.98.0",
|
"webpack": "5.98.0",
|
||||||
"webpack-cli": "6.0.1",
|
"webpack-cli": "6.0.1",
|
||||||
@ -21207,6 +21207,7 @@
|
|||||||
"version": "9.0.4",
|
"version": "9.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/vanilla-js-wheel-zoom/-/vanilla-js-wheel-zoom-9.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/vanilla-js-wheel-zoom/-/vanilla-js-wheel-zoom-9.0.4.tgz",
|
||||||
"integrity": "sha512-OjmS9ihEKBCRw2OQ7IiIdQGXdC5gTEEmtcAWZcPeNAJaYiS61KCd02Z72YMtIoXLGN5TZP+wliBMylLAsr6wow==",
|
"integrity": "sha512-OjmS9ihEKBCRw2OQ7IiIdQGXdC5gTEEmtcAWZcPeNAJaYiS61KCd02Z72YMtIoXLGN5TZP+wliBMylLAsr6wow==",
|
||||||
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/vary": {
|
"node_modules/vary": {
|
||||||
|
@ -150,7 +150,6 @@
|
|||||||
"tmp": "0.2.3",
|
"tmp": "0.2.3",
|
||||||
"turndown": "7.2.0",
|
"turndown": "7.2.0",
|
||||||
"unescape": "1.0.1",
|
"unescape": "1.0.1",
|
||||||
"vanilla-js-wheel-zoom": "9.0.4",
|
|
||||||
"ws": "8.18.1",
|
"ws": "8.18.1",
|
||||||
"xml2js": "0.6.2",
|
"xml2js": "0.6.2",
|
||||||
"yauzl": "3.2.0"
|
"yauzl": "3.2.0"
|
||||||
@ -248,6 +247,7 @@
|
|||||||
"typedoc": "0.28.1",
|
"typedoc": "0.28.1",
|
||||||
"typescript": "5.8.2",
|
"typescript": "5.8.2",
|
||||||
"typescript-eslint": "8.28.0",
|
"typescript-eslint": "8.28.0",
|
||||||
|
"vanilla-js-wheel-zoom": "9.0.4",
|
||||||
"vitest": "3.0.9",
|
"vitest": "3.0.9",
|
||||||
"webpack": "5.98.0",
|
"webpack": "5.98.0",
|
||||||
"webpack-cli": "6.0.1",
|
"webpack-cli": "6.0.1",
|
||||||
|
@ -15,7 +15,7 @@ import { loadElkIfNeeded, postprocessMermaidSvg } from "./mermaid.js";
|
|||||||
import { normalizeMimeTypeForCKEditor } from "./mime_type_definitions.js";
|
import { normalizeMimeTypeForCKEditor } from "./mime_type_definitions.js";
|
||||||
import renderDoc from "./doc_renderer.js";
|
import renderDoc from "./doc_renderer.js";
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
import type { Mermaid } from "mermaid";
|
import WheelZoom from 'vanilla-js-wheel-zoom';
|
||||||
|
|
||||||
let idCounter = 1;
|
let idCounter = 1;
|
||||||
|
|
||||||
@ -150,13 +150,16 @@ function renderImage(entity: FNote | FAttachment, $renderedContent: JQuery<HTMLE
|
|||||||
$renderedContent.append($img);
|
$renderedContent.append($img);
|
||||||
|
|
||||||
if (options.imageHasZoom) {
|
if (options.imageHasZoom) {
|
||||||
libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM).then(() => {
|
setTimeout(() => {
|
||||||
WZoom.create(`#${$img.attr("id")}`, {
|
const element = document.querySelector(`#${$img.attr("id")}`);
|
||||||
maxScale: 50,
|
if (element) {
|
||||||
speed: 1.3,
|
WheelZoom.create(`#${$img.attr("id")}`, {
|
||||||
zoomOnClick: false
|
maxScale: 50,
|
||||||
});
|
speed: 1.3,
|
||||||
});
|
zoomOnClick: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
imageContextMenuService.setupContextMenu($img);
|
imageContextMenuService.setupContextMenu($img);
|
||||||
|
@ -51,10 +51,6 @@ const KATEX: Library = {
|
|||||||
css: ["node_modules/katex/dist/katex.min.css"]
|
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 = {
|
const MARKJS: Library = {
|
||||||
js: ["node_modules/mark.js/dist/jquery.mark.es6.min.js"]
|
js: ["node_modules/mark.js/dist/jquery.mark.es6.min.js"]
|
||||||
};
|
};
|
||||||
@ -176,7 +172,6 @@ export default {
|
|||||||
CODE_MIRROR,
|
CODE_MIRROR,
|
||||||
CALENDAR_WIDGET,
|
CALENDAR_WIDGET,
|
||||||
KATEX,
|
KATEX,
|
||||||
WHEEL_ZOOM,
|
|
||||||
MARKJS,
|
MARKJS,
|
||||||
HIGHLIGHT_JS,
|
HIGHLIGHT_JS,
|
||||||
LEAFLET
|
LEAFLET
|
||||||
|
7
src/public/app/types.d.ts
vendored
7
src/public/app/types.d.ts
vendored
@ -132,13 +132,6 @@ declare global {
|
|||||||
var renderMathInElement: (element: HTMLElement, options: {
|
var renderMathInElement: (element: HTMLElement, options: {
|
||||||
trust: boolean;
|
trust: boolean;
|
||||||
}) => void;
|
}) => void;
|
||||||
var WZoom = {
|
|
||||||
create(selector: string, opts: {
|
|
||||||
maxScale: number;
|
|
||||||
speed: number;
|
|
||||||
zoomOnClick: boolean
|
|
||||||
})
|
|
||||||
};
|
|
||||||
interface CKCodeBlockLanguage {
|
interface CKCodeBlockLanguage {
|
||||||
language: string;
|
language: string;
|
||||||
label: string;
|
label: string;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import utils from "../../services/utils.js";
|
import utils from "../../services/utils.js";
|
||||||
import TypeWidget from "./type_widget.js";
|
import TypeWidget from "./type_widget.js";
|
||||||
import libraryLoader from "../../services/library_loader.js";
|
|
||||||
import imageContextMenuService from "../../menus/image_context_menu.js";
|
import imageContextMenuService from "../../menus/image_context_menu.js";
|
||||||
import imageService from "../../services/image.js";
|
import imageService from "../../services/image.js";
|
||||||
import type FNote from "../../entities/fnote.js";
|
import type FNote from "../../entities/fnote.js";
|
||||||
import type { EventData } from "../../components/app_context.js";
|
import type { EventData } from "../../components/app_context.js";
|
||||||
|
import WheelZoom from 'vanilla-js-wheel-zoom';
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="note-detail-image note-detail-printable">
|
<div class="note-detail-image note-detail-printable">
|
||||||
@ -54,13 +54,16 @@ class ImageTypeWidget extends TypeWidget {
|
|||||||
this.$imageWrapper = this.$widget.find(".note-detail-image-wrapper");
|
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)}`);
|
this.$imageView = this.$widget.find(".note-detail-image-view").attr("id", `image-view-${utils.randomString(10)}`);
|
||||||
|
|
||||||
libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM).then(() => {
|
setTimeout(() => {
|
||||||
WZoom.create(`#${this.$imageView.attr("id")}`, {
|
const element = document.querySelector(`#${this.$imageView.attr("id")}`);
|
||||||
maxScale: 50,
|
if (element) {
|
||||||
speed: 1.3,
|
WheelZoom.create(`#${this.$imageView.attr("id")}`, {
|
||||||
zoomOnClick: false
|
maxScale: 50,
|
||||||
});
|
speed: 1.3,
|
||||||
});
|
zoomOnClick: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
|
||||||
imageContextMenuService.setupContextMenu(this.$imageView);
|
imageContextMenuService.setupContextMenu(this.$imageView);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user