mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-11-15 07:11:36 +08:00
feat(mermaid): custom zoom buttons
This commit is contained in:
parent
77fbeb4351
commit
fd46cd7529
@ -7,6 +7,7 @@ import { DEFAULT_GUTTER_SIZE } from "../../services/resizer.js";
|
|||||||
import options from "../../services/options.js";
|
import options from "../../services/options.js";
|
||||||
import type SwitchSplitOrientationButton from "../floating_buttons/switch_layout_button.js";
|
import type SwitchSplitOrientationButton from "../floating_buttons/switch_layout_button.js";
|
||||||
import type { EventData } from "../../components/app_context.js";
|
import type { EventData } from "../../components/app_context.js";
|
||||||
|
import type OnClickButtonWidget from "../buttons/onclick_button.js";
|
||||||
|
|
||||||
const TPL = `\
|
const TPL = `\
|
||||||
<div class="note-detail-split note-detail-printable">
|
<div class="note-detail-split note-detail-printable">
|
||||||
@ -16,6 +17,7 @@ const TPL = `\
|
|||||||
</div>
|
</div>
|
||||||
<div class="note-detail-split-preview-col">
|
<div class="note-detail-split-preview-col">
|
||||||
<div class="note-detail-split-preview"></div>
|
<div class="note-detail-split-preview"></div>
|
||||||
|
<div class="btn-group btn-group-sm map-type-switcher content-floating-buttons preview-buttons bottom-right" role="group"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -28,6 +30,10 @@ const TPL = `\
|
|||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.note-detail-split-preview-col {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
.note-detail-split .note-detail-split-editor {
|
.note-detail-split .note-detail-split-editor {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
@ -53,7 +59,8 @@ const TPL = `\
|
|||||||
border-left: 1px solid var(--main-border-color);
|
border-left: 1px solid var(--main-border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.note-detail-split.split-horizontal > div {
|
.note-detail-split.split-horizontal > .note-detail-split-editor-col,
|
||||||
|
.note-detail-split.split-horizontal > .note-detail-split-preview-col {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
@ -72,7 +79,8 @@ const TPL = `\
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.note-detail-split.split-vertical > div {
|
.note-detail-split.split-vertical > .note-detail-split-editor-col,
|
||||||
|
.note-detail-split.split-vertical > .note-detail-split-preview-col {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 50%;
|
height: 50%;
|
||||||
}
|
}
|
||||||
@ -126,14 +134,30 @@ export default abstract class AbstractSplitTypeWidget extends TypeWidget {
|
|||||||
doRender(): void {
|
doRender(): void {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
|
|
||||||
this.$editorCol = this.$widget.find(".note-detail-split-editor-col");
|
// Preview pane
|
||||||
this.$previewCol = this.$widget.find(".note-detail-split-preview-col");
|
this.$previewCol = this.$widget.find(".note-detail-split-preview-col");
|
||||||
this.$preview = this.$widget.find(".note-detail-split-preview");
|
this.$preview = this.$widget.find(".note-detail-split-preview");
|
||||||
|
|
||||||
|
// Editor pane
|
||||||
|
this.$editorCol = this.$widget.find(".note-detail-split-editor-col");
|
||||||
this.$editor = this.$widget.find(".note-detail-split-editor");
|
this.$editor = this.$widget.find(".note-detail-split-editor");
|
||||||
this.$editor.append(this.editorTypeWidget.render());
|
this.$editor.append(this.editorTypeWidget.render());
|
||||||
this.$errorContainer = this.$widget.find(".note-detail-error-container");
|
this.$errorContainer = this.$widget.find(".note-detail-error-container");
|
||||||
this.#adjustLayoutOrientation();
|
this.#adjustLayoutOrientation();
|
||||||
|
|
||||||
|
// Preview pane buttons
|
||||||
|
const $previewButtons = this.$previewCol.find(".preview-buttons");
|
||||||
|
const previewButtons = this.buildPreviewButtons();
|
||||||
|
$previewButtons.toggle(previewButtons.length > 0);
|
||||||
|
for (const previewButton of previewButtons) {
|
||||||
|
const $button = previewButton.render();
|
||||||
|
$button.removeClass("button-widget")
|
||||||
|
.addClass("btn")
|
||||||
|
.addClass("tn-tool-button");
|
||||||
|
$previewButtons.append($button);
|
||||||
|
previewButton.refreshIcon();
|
||||||
|
}
|
||||||
|
|
||||||
super.doRender();
|
super.doRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +239,10 @@ export default abstract class AbstractSplitTypeWidget extends TypeWidget {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildPreviewButtons(): OnClickButtonWidget[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
setError(message: string | null | undefined) {
|
setError(message: string | null | undefined) {
|
||||||
this.$errorContainer.toggleClass("hidden-ext", !message);
|
this.$errorContainer.toggleClass("hidden-ext", !message);
|
||||||
this.$preview.toggleClass("on-error", !!message);
|
this.$preview.toggleClass("on-error", !!message);
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
import type { EventData } from "../../components/app_context.js";
|
import type { EventData } from "../../components/app_context.js";
|
||||||
import type FNote from "../../entities/fnote.js";
|
import type FNote from "../../entities/fnote.js";
|
||||||
|
import { t } from "../../services/i18n.js";
|
||||||
import server from "../../services/server.js";
|
import server from "../../services/server.js";
|
||||||
import utils from "../../services/utils.js";
|
import utils from "../../services/utils.js";
|
||||||
|
import OnClickButtonWidget from "../buttons/onclick_button.js";
|
||||||
import AbstractSplitTypeWidget from "./abstract_split_type_widget.js";
|
import AbstractSplitTypeWidget from "./abstract_split_type_widget.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +152,7 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy
|
|||||||
const svgPanZoom = (await import("svg-pan-zoom")).default;
|
const svgPanZoom = (await import("svg-pan-zoom")).default;
|
||||||
const zoomInstance = svgPanZoom($svgEl[0], {
|
const zoomInstance = svgPanZoom($svgEl[0], {
|
||||||
zoomEnabled: true,
|
zoomEnabled: true,
|
||||||
controlIconsEnabled: true
|
controlIconsEnabled: false
|
||||||
});
|
});
|
||||||
|
|
||||||
if (preservePanZoom && pan && zoom) {
|
if (preservePanZoom && pan && zoom) {
|
||||||
@ -172,6 +174,26 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildPreviewButtons(): OnClickButtonWidget[] {
|
||||||
|
return [
|
||||||
|
new OnClickButtonWidget()
|
||||||
|
.icon("bx-zoom-in")
|
||||||
|
.title(t("relation_map_buttons.zoom_in_title"))
|
||||||
|
.titlePlacement("top")
|
||||||
|
.onClick(() => this.zoomInstance?.zoomIn())
|
||||||
|
, new OnClickButtonWidget()
|
||||||
|
.icon("bx-zoom-out")
|
||||||
|
.title(t("relation_map_buttons.zoom_out_title"))
|
||||||
|
.titlePlacement("top")
|
||||||
|
.onClick(() => this.zoomInstance?.zoomOut())
|
||||||
|
, new OnClickButtonWidget()
|
||||||
|
.icon("bx-crop")
|
||||||
|
.title(t("relation_map_buttons.reset_pan_zoom_title"))
|
||||||
|
.titlePlacement("top")
|
||||||
|
.onClick(() => this.zoomHandler())
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
#cleanUpZoom() {
|
#cleanUpZoom() {
|
||||||
if (this.zoomInstance) {
|
if (this.zoomInstance) {
|
||||||
this.zoomInstance.destroy();
|
this.zoomInstance.destroy();
|
||||||
|
|||||||
@ -1778,6 +1778,11 @@ footer.file-footer button {
|
|||||||
left: 10px;
|
left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.content-floating-buttons.bottom-right {
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.content-floating-buttons button.bx {
|
.content-floating-buttons button.bx {
|
||||||
font-size: 130%;
|
font-size: 130%;
|
||||||
padding: 1px 10px 1px 10px;
|
padding: 1px 10px 1px 10px;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user