mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-03 14:19:58 +08:00
chore(touchbar): disable widget on non-mac
This commit is contained in:
parent
83e7e82252
commit
14516d53c3
@ -83,7 +83,7 @@ import CopyImageReferenceButton from "../widgets/floating_buttons/copy_image_ref
|
|||||||
import ScrollPaddingWidget from "../widgets/scroll_padding.js";
|
import ScrollPaddingWidget from "../widgets/scroll_padding.js";
|
||||||
import ClassicEditorToolbar from "../widgets/ribbon_widgets/classic_editor_toolbar.js";
|
import ClassicEditorToolbar from "../widgets/ribbon_widgets/classic_editor_toolbar.js";
|
||||||
import options from "../services/options.js";
|
import options from "../services/options.js";
|
||||||
import utils from "../services/utils.js";
|
import utils, { hasTouchBar } from "../services/utils.js";
|
||||||
import GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js";
|
import GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js";
|
||||||
import ContextualHelpButton from "../widgets/floating_buttons/help_button.js";
|
import ContextualHelpButton from "../widgets/floating_buttons/help_button.js";
|
||||||
import CloseZenButton from "../widgets/close_zen_button.js";
|
import CloseZenButton from "../widgets/close_zen_button.js";
|
||||||
@ -162,7 +162,7 @@ export default class DesktopLayout {
|
|||||||
.filling()
|
.filling()
|
||||||
.collapsible()
|
.collapsible()
|
||||||
.id("center-pane")
|
.id("center-pane")
|
||||||
.child(new TouchBarWidget())
|
.optChild(hasTouchBar, new TouchBarWidget())
|
||||||
.child(
|
.child(
|
||||||
new SplitNoteContainer(() =>
|
new SplitNoteContainer(() =>
|
||||||
new NoteWrapperWidget()
|
new NoteWrapperWidget()
|
||||||
|
@ -147,6 +147,8 @@ function isMac() {
|
|||||||
return navigator.platform.indexOf("Mac") > -1;
|
return navigator.platform.indexOf("Mac") > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const hasTouchBar = isMac();
|
||||||
|
|
||||||
function isCtrlKey(evt: KeyboardEvent | MouseEvent | JQuery.ClickEvent | JQuery.ContextMenuEvent | JQuery.TriggeredEvent | React.PointerEvent<HTMLCanvasElement>) {
|
function isCtrlKey(evt: KeyboardEvent | MouseEvent | JQuery.ClickEvent | JQuery.ContextMenuEvent | JQuery.TriggeredEvent | React.PointerEvent<HTMLCanvasElement>) {
|
||||||
return (!isMac() && evt.ctrlKey) || (isMac() && evt.metaKey);
|
return (!isMac() && evt.ctrlKey) || (isMac() && evt.metaKey);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import options from "../../services/options.js";
|
|||||||
import AbstractCodeTypeWidget from "./abstract_code_type_widget.js";
|
import AbstractCodeTypeWidget from "./abstract_code_type_widget.js";
|
||||||
import appContext from "../../components/app_context.js";
|
import appContext from "../../components/app_context.js";
|
||||||
import type { TouchBarItem } from "../touch_bar.js";
|
import type { TouchBarItem } from "../touch_bar.js";
|
||||||
|
import { hasTouchBar } from "../../services/utils.js";
|
||||||
|
|
||||||
const TPL = /*html*/`
|
const TPL = /*html*/`
|
||||||
<div class="note-detail-code note-detail-printable">
|
<div class="note-detail-code note-detail-printable">
|
||||||
@ -64,7 +65,7 @@ export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget {
|
|||||||
|
|
||||||
this.show();
|
this.show();
|
||||||
|
|
||||||
if (this.parent) {
|
if (this.parent && hasTouchBar) {
|
||||||
this.triggerCommand("refreshTouchBar");
|
this.triggerCommand("refreshTouchBar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { t } from "../../services/i18n.js";
|
|||||||
import libraryLoader from "../../services/library_loader.js";
|
import libraryLoader from "../../services/library_loader.js";
|
||||||
import noteAutocompleteService from "../../services/note_autocomplete.js";
|
import noteAutocompleteService from "../../services/note_autocomplete.js";
|
||||||
import mimeTypesService from "../../services/mime_types.js";
|
import mimeTypesService from "../../services/mime_types.js";
|
||||||
import utils from "../../services/utils.js";
|
import utils, { hasTouchBar } from "../../services/utils.js";
|
||||||
import keyboardActionService from "../../services/keyboard_actions.js";
|
import keyboardActionService from "../../services/keyboard_actions.js";
|
||||||
import froca from "../../services/froca.js";
|
import froca from "../../services/froca.js";
|
||||||
import noteCreateService from "../../services/note_create.js";
|
import noteCreateService from "../../services/note_create.js";
|
||||||
@ -282,8 +282,10 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Touch bar integration
|
// Touch bar integration
|
||||||
for (const event of [ "bold", "italic", "underline", "paragraph", "heading" ]) {
|
if (hasTouchBar) {
|
||||||
editor.commands.get(event).on("change", () => this.triggerCommand("refreshTouchBar"));
|
for (const event of [ "bold", "italic", "underline", "paragraph", "heading" ]) {
|
||||||
|
editor.commands.get(event).on("change", () => this.triggerCommand("refreshTouchBar"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
|
@ -15,6 +15,7 @@ import appContext from "../../components/app_context.js";
|
|||||||
|
|
||||||
import markerIcon from "leaflet/dist/images/marker-icon.png";
|
import markerIcon from "leaflet/dist/images/marker-icon.png";
|
||||||
import markerIconShadow from "leaflet/dist/images/marker-shadow.png";
|
import markerIconShadow from "leaflet/dist/images/marker-shadow.png";
|
||||||
|
import { hasTouchBar } from "../../services/utils.js";
|
||||||
|
|
||||||
const TPL = /*html*/`\
|
const TPL = /*html*/`\
|
||||||
<div class="note-detail-geo-map note-detail-printable">
|
<div class="note-detail-geo-map note-detail-printable">
|
||||||
@ -152,13 +153,16 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
|||||||
map.on("moveend", updateFn);
|
map.on("moveend", updateFn);
|
||||||
map.on("zoomend", updateFn);
|
map.on("zoomend", updateFn);
|
||||||
map.on("click", (e) => this.#onMapClicked(e));
|
map.on("click", (e) => this.#onMapClicked(e));
|
||||||
map.on("zoom", () => {
|
|
||||||
if (!this.ignoreNextZoomEvent) {
|
|
||||||
this.triggerCommand("refreshTouchBar");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ignoreNextZoomEvent = false;
|
if (hasTouchBar) {
|
||||||
});
|
map.on("zoom", () => {
|
||||||
|
if (!this.ignoreNextZoomEvent) {
|
||||||
|
this.triggerCommand("refreshTouchBar");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ignoreNextZoomEvent = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async #restoreViewportAndZoom() {
|
async #restoreViewportAndZoom() {
|
||||||
@ -287,7 +291,9 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
|||||||
#changeState(newState: State) {
|
#changeState(newState: State) {
|
||||||
this._state = newState;
|
this._state = newState;
|
||||||
this.geoMapWidget.$container.toggleClass("placing-note", newState === State.NewNote);
|
this.geoMapWidget.$container.toggleClass("placing-note", newState === State.NewNote);
|
||||||
this.triggerCommand("refreshTouchBar");
|
if (hasTouchBar) {
|
||||||
|
this.triggerCommand("refreshTouchBar");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async #onMapClicked(e: LeafletMouseEvent) {
|
async #onMapClicked(e: LeafletMouseEvent) {
|
||||||
|
@ -8,7 +8,7 @@ import options from "../../services/options.js";
|
|||||||
import dialogService from "../../services/dialog.js";
|
import dialogService from "../../services/dialog.js";
|
||||||
import attributes from "../../services/attributes.js";
|
import attributes from "../../services/attributes.js";
|
||||||
import type { CommandListenerData, EventData } from "../../components/app_context.js";
|
import type { CommandListenerData, EventData } from "../../components/app_context.js";
|
||||||
import utils from "../../services/utils.js";
|
import utils, { hasTouchBar } from "../../services/utils.js";
|
||||||
import date_notes from "../../services/date_notes.js";
|
import date_notes from "../../services/date_notes.js";
|
||||||
import appContext from "../../components/app_context.js";
|
import appContext from "../../components/app_context.js";
|
||||||
import type { EventImpl } from "@fullcalendar/core/internal";
|
import type { EventImpl } from "@fullcalendar/core/internal";
|
||||||
@ -269,7 +269,9 @@ export default class CalendarView extends ViewMode {
|
|||||||
this.debouncedSaveView();
|
this.debouncedSaveView();
|
||||||
this.lastView = currentView;
|
this.lastView = currentView;
|
||||||
|
|
||||||
appContext.triggerCommand("refreshTouchBar");
|
if (hasTouchBar) {
|
||||||
|
appContext.triggerCommand("refreshTouchBar");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async #onCalendarSelection(e: DateSelectArg) {
|
async #onCalendarSelection(e: DateSelectArg) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user