mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	chore(touchbar): disable widget on non-mac
This commit is contained in:
		| @@ -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,9 +282,11 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             // Touch bar integration |             // Touch bar integration | ||||||
|  |             if (hasTouchBar) { | ||||||
|                 for (const event of [ "bold", "italic", "underline", "paragraph", "heading" ]) { |                 for (const event of [ "bold", "italic", "underline", "paragraph", "heading" ]) { | ||||||
|                     editor.commands.get(event).on("change", () => this.triggerCommand("refreshTouchBar")); |                     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,6 +153,8 @@ 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)); | ||||||
|  |  | ||||||
|  |         if (hasTouchBar) { | ||||||
|             map.on("zoom", () => { |             map.on("zoom", () => { | ||||||
|                 if (!this.ignoreNextZoomEvent) { |                 if (!this.ignoreNextZoomEvent) { | ||||||
|                     this.triggerCommand("refreshTouchBar"); |                     this.triggerCommand("refreshTouchBar"); | ||||||
| @@ -160,6 +163,7 @@ export default class GeoMapTypeWidget extends TypeWidget { | |||||||
|                 this.ignoreNextZoomEvent = false; |                 this.ignoreNextZoomEvent = false; | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     async #restoreViewportAndZoom() { |     async #restoreViewportAndZoom() { | ||||||
|         const map = this.geoMapWidget.map; |         const map = this.geoMapWidget.map; | ||||||
| @@ -287,8 +291,10 @@ 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); | ||||||
|  |         if (hasTouchBar) { | ||||||
|             this.triggerCommand("refreshTouchBar"); |             this.triggerCommand("refreshTouchBar"); | ||||||
|         } |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     async #onMapClicked(e: LeafletMouseEvent) { |     async #onMapClicked(e: LeafletMouseEvent) { | ||||||
|         if (this._state !== State.NewNote) { |         if (this._state !== State.NewNote) { | ||||||
|   | |||||||
| @@ -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,8 +269,10 @@ export default class CalendarView extends ViewMode { | |||||||
|         this.debouncedSaveView(); |         this.debouncedSaveView(); | ||||||
|         this.lastView = currentView; |         this.lastView = currentView; | ||||||
|  |  | ||||||
|  |         if (hasTouchBar) { | ||||||
|             appContext.triggerCommand("refreshTouchBar"); |             appContext.triggerCommand("refreshTouchBar"); | ||||||
|         } |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     async #onCalendarSelection(e: DateSelectArg) { |     async #onCalendarSelection(e: DateSelectArg) { | ||||||
|         // Handle start and end date |         // Handle start and end date | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user