diff --git a/apps/client/src/widgets/collections/calendar/index.tsx b/apps/client/src/widgets/collections/calendar/index.tsx index 317382593..d7112ca39 100644 --- a/apps/client/src/widgets/collections/calendar/index.tsx +++ b/apps/client/src/widgets/collections/calendar/index.tsx @@ -3,7 +3,7 @@ import { ViewModeProps } from "../interface"; import Calendar from "./calendar"; import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks"; import "./index.css"; -import { useNoteLabel, useNoteLabelBoolean, useResizeObserver, useSpacedUpdate, useTouchBar, useTriliumEvent, useTriliumOption, useTriliumOptionInt } from "../../react/hooks"; +import { useNoteLabel, useNoteLabelBoolean, useResizeObserver, useSpacedUpdate, useTriliumEvent, useTriliumOption, useTriliumOptionInt } from "../../react/hooks"; import { LOCALE_IDS } from "@triliumnext/commons"; import { Calendar as FullCalendar } from "@fullcalendar/core"; import { parseStartEndDateFromEvent, parseStartEndTimeFromEvent } from "./utils"; diff --git a/apps/client/src/widgets/collections/geomap/index.tsx b/apps/client/src/widgets/collections/geomap/index.tsx index ccc1330d1..07e942d19 100644 --- a/apps/client/src/widgets/collections/geomap/index.tsx +++ b/apps/client/src/widgets/collections/geomap/index.tsx @@ -1,7 +1,7 @@ import Map from "./map"; import "./index.css"; import { ViewModeProps } from "../interface"; -import { useNoteBlob, useNoteLabel, useNoteLabelBoolean, useNoteProperty, useNoteTreeDrag, useSpacedUpdate, useTouchBar, useTriliumEvent } from "../../react/hooks"; +import { useNoteBlob, useNoteLabel, useNoteLabelBoolean, useNoteProperty, useNoteTreeDrag, useSpacedUpdate, useTriliumEvent } from "../../react/hooks"; import { DEFAULT_MAP_LAYER_NAME } from "./map_layer"; import { divIcon, GPXOptions, LatLng, LeafletMouseEvent } from "leaflet"; import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "preact/hooks"; diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx index 1667ac82f..0b92b7459 100644 --- a/apps/client/src/widgets/react/hooks.tsx +++ b/apps/client/src/widgets/react/hooks.tsx @@ -700,26 +700,6 @@ export function useNoteTreeDrag(containerRef: MutableRef & { parentComponent: Component | null }) => void, - inputs: Inputs -) { - const parentComponent = useContext(ParentComponent); - - useLegacyImperativeHandlers({ - buildTouchBarCommand(context: CommandListenerData<"buildTouchBar">) { - return factory({ - ...context, - parentComponent - }); - } - }); - - useEffect(() => { - parentComponent?.triggerCommand("refreshTouchBar"); - }, inputs); -} - export function useResizeObserver(ref: RefObject, callback: () => void) { const resizeObserver = useRef(null); useEffect(() => { diff --git a/apps/client/src/widgets/type_widgets/code/Code.tsx b/apps/client/src/widgets/type_widgets/code/Code.tsx index cdc0391cb..377f99d03 100644 --- a/apps/client/src/widgets/type_widgets/code/Code.tsx +++ b/apps/client/src/widgets/type_widgets/code/Code.tsx @@ -6,6 +6,8 @@ import CodeMirror from "./CodeMirror"; import utils from "../../../services/utils"; import { useEditorSpacedUpdate, useNoteBlob, useTriliumOptionBool } from "../../react/hooks"; import { t } from "../../../services/i18n"; +import appContext from "../../../components/app_context"; +import TouchBar, { TouchBarButton } from "../../react/TouchBar"; export function ReadOnlyCode({ note, viewScope, ntxId }: TypeWidgetProps) { const [ content, setContent ] = useState(""); @@ -64,6 +66,12 @@ export function EditableCode({ note, ntxId, debounceUpdate }: TypeWidgetProps & spacedUpdate.scheduleUpdate(); }} /> + + + {(note?.mime.startsWith("application/javascript") || note?.mime === "text/x-sqlite;schema=trilium") && ( + appContext.triggerCommand("runActiveNote")} /> + )} + ) } diff --git a/apps/client/src/widgets/type_widgets_old/editable_code.ts b/apps/client/src/widgets/type_widgets_old/editable_code.ts index deb5acbf2..9d5164616 100644 --- a/apps/client/src/widgets/type_widgets_old/editable_code.ts +++ b/apps/client/src/widgets/type_widgets_old/editable_code.ts @@ -29,26 +29,4 @@ export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget { super.doRender(); } - async doRefresh(note: FNote) { - const blob = await this.note?.getBlob(); - - if (this.parent && hasTouchBar) { - this.triggerCommand("refreshTouchBar"); - } - } - - buildTouchBarCommand({ TouchBar, buildIcon }: CommandListenerData<"buildTouchBar">) { - const items: TouchBarItem[] = []; - const note = this.note; - - if (note?.mime.startsWith("application/javascript") || note?.mime === "text/x-sqlite;schema=trilium") { - items.push(new TouchBar.TouchBarButton({ - icon: buildIcon("NSImageNameTouchBarPlayTemplate"), - click: () => appContext.triggerCommand("runActiveNote") - })); - } - - return items; - } - }