Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Merge remote-tracking branch 'origin/develop' into feature/touchbar
Elian Doran4161bc17e1d5
diff --cc src/public/app/layouts/desktop_layout.tsindex f5b3dc2eb9,38fb75b433..ce91063770--- a/src/public/app/layouts/desktop_layout.ts+++ b/src/public/app/layouts/desktop_layout.ts@@@ -88,10 -87,18 +87,19 @@@ import utils from "../services/utils.jsimport GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js";import ContextualHelpButton from "../widgets/floating_buttons/help_button.js";import CloseZenButton from "../widgets/close_zen_button.js";+import TouchBarWidget from "../widgets/touch_bar.js";+ import type { AppContext } from "./../components/app_context.js";+ import type { WidgetsByParent } from "../services/bundle.js";+ import SwitchSplitOrientationButton from "../widgets/floating_buttons/switch_layout_button.js";+ import ToggleReadOnlyButton from "../widgets/floating_buttons/toggle_read_only_button.js";+ import PngExportButton from "../widgets/floating_buttons/png_export_button.js";+ import RefreshButton from "../widgets/floating_buttons/refresh_button.js";export default class DesktopLayout {- constructor(customWidgets) {++ private customWidgets: WidgetsByParent;++ constructor(customWidgets: WidgetsByParent) {this.customWidgets = customWidgets;}diff --cc src/public/app/types.d.tsindex beea7477f7,1ce3645270..504ae89077--- a/src/public/app/types.d.ts+++ b/src/public/app/types.d.ts@@@ -210,8 -284,61 +284,66 @@@ declare globalinterface TextPosition {textNode: TextNode;offset: number;+ compareWith(pos: TextPosition): string;+ }++ interface TextRange {++ }++ interface Marker {+ name: string;+ }++ interface CKNode {+ _children: CKNode[];+ name: string;+ childCount: number;+ isEmpty: boolean;+ toJSON(): object;+ is(type: string, name?: string);+ getAttribute(name: string): string;+ getChild(index: number): CKNode;+ data: string;+ startOffset: number;+ root: {+ document: {+ model: {+ createRangeIn(el: CKNode): TextRange;+ markers: {+ getMarkersIntersectingRange(range: TextRange): Marker[];+ }+ }+ }+ };+ }++ interface CKEvent {+ stop(): void;+ }++ interface PluginEventData {+ title: string;+ message: {+ message: string;+ };}+interface TextEditor {+ create(el: HTMLElement, config: {+ removePlugins?: string[];+ toolbar: {+ items: any[];+ },+ placeholder: string;+ mention: MentionConfig+ });+ enableReadOnlyMode(reason: string);++ commands: {++ get(name: string): {++ value: unknown;++ };++ }model: {document: {on(event: string, cb: () => void);diff --cc src/public/app/widgets/type_widgets/editable_code.tsindex ca922cfc2d,e27bfa0795..7b0891f3db--- a/src/public/app/widgets/type_widgets/editable_code.ts+++ b/src/public/app/widgets/type_widgets/editable_code.ts@@@ -5,10 -4,8 +5,10 @@@ import { t } from "../../services/i18n.import keyboardActionService from "../../services/keyboard_actions.js";import options from "../../services/options.js";import AbstractCodeTypeWidget from "./abstract_code_type_widget.js";+import appContext from "../../components/app_context.js";+import type { TouchBarItem } from "../touch_bar.js";- const TPL = `+ const TPL = /*html*/`<div class="note-detail-code note-detail-printable"><style>.note-detail-code {diff --cc src/public/app/widgets/type_widgets/editable_text.tsindex dfcf63e5bb,b503dfbaf4..2e2ba64c5d--- a/src/public/app/widgets/type_widgets/editable_text.ts+++ b/src/public/app/widgets/type_widgets/editable_text.ts@@@ -8,15 -8,15 +8,16 @@@ import froca from "../../services/frocaimport noteCreateService from "../../services/note_create.js";import AbstractTextTypeWidget from "./abstract_text_type_widget.js";import link from "../../services/link.js";- import appContext from "../../components/app_context.js";-import appContext, { type EventData } from "../../components/app_context.js";++import appContext, { type CommandListenerData, type EventData } from "../../components/app_context.js";import dialogService from "../../services/dialog.js";import { initSyntaxHighlighting } from "./ckeditor/syntax_highlight.js";import options from "../../services/options.js";import toast from "../../services/toast.js";- import { getMermaidConfig } from "../mermaid.js";import { normalizeMimeTypeForCKEditor } from "../../services/mime_type_definitions.js";- import { buildConfig, buildToolbarConfig } from "./ckeditor/toolbars.js";+import { buildSelectedBackgroundColor } from "../touch_bar.js";+ import { buildConfig, buildToolbarConfig } from "./ckeditor/config.js";+ import type FNote from "../../entities/fnote.js";+ import { getMermaidConfig } from "../../services/mermaid.js";const ENABLE_INSPECTOR = false;@@@ -513,60 -544,4 +550,60 @@@ export default class EditableTextTypeWiawait this.reinitialize(data);}- buildTouchBarCommand(data) {++ buildTouchBarCommand(data: CommandListenerData<"buildTouchBar">) {+ const { TouchBar, buildIcon } = data;+ const { TouchBarSegmentedControl, TouchBarGroup, TouchBarButton } = TouchBar;+ const { editor } = this.watchdog;+- const commandButton = (icon, command) => new TouchBarButton({++ const commandButton = (icon: string, command: string) => new TouchBarButton({+ icon: buildIcon(icon),+ click: () => editor.execute(command),- backgroundColor: buildSelectedBackgroundColor(editor.commands.get(command).value)++ backgroundColor: buildSelectedBackgroundColor(editor.commands.get(command).value as boolean)+ });++ let headingSelectedIndex = undefined;+ const headingCommand = editor.commands.get("heading");+ const paragraphCommand = editor.commands.get("paragraph");+ if (paragraphCommand.value) {+ headingSelectedIndex = 0;+ } else if (headingCommand.value === "heading2") {+ headingSelectedIndex = 1;+ } else if (headingCommand.value === "heading3") {+ headingSelectedIndex = 2;+ }++ return [+ new TouchBarSegmentedControl({+ segments: [+ { label: "P" },+ { label: "H2" },+ { label: "H3" }+ ],+ change(selectedIndex, isSelected) {+ switch (selectedIndex) {+ case 0:+ editor.execute("paragraph")+ break;+ case 1:+ editor.execute("heading", { value: "heading2" });+ break;+ case 2:+ editor.execute("heading", { value: "heading3" });+ break;+ }+ },+ selectedIndex: headingSelectedIndex+ }),+ new TouchBarGroup({+ items: new TouchBar({+ items: [+ commandButton("NSTouchBarTextBoldTemplate", "bold"),+ commandButton("NSTouchBarTextItalicTemplate", "italic"),+ commandButton("NSTouchBarTextUnderlineTemplate", "underline")+ ]+ })+ })+ ];+ }+}diff --cc src/public/app/widgets/type_widgets/geo_map.tsindex 6b478f1306,e858694dcc..82a01fc418--- a/src/public/app/widgets/type_widgets/geo_map.ts+++ b/src/public/app/widgets/type_widgets/geo_map.ts@@@ -5,10 -5,9 +5,9 @@@ import TypeWidget from "./type_widget.jimport server from "../../services/server.js";import toastService from "../../services/toast.js";import dialogService from "../../services/dialog.js";-import type { EventData } from "../../components/app_context.js";+import type { CommandListenerData, EventData } from "../../components/app_context.js";import { t } from "../../services/i18n.js";import attributes from "../../services/attributes.js";- import asset_path from "../../../../services/asset_path.js";import openContextMenu from "./geo_map_context_menu.js";import link from "../../services/link.js";import note_tooltip from "../../services/note_tooltip.js";diff --cc src/public/app/widgets/type_widgets/read_only_text.tsindex 2ac4d671b7,1524255f11..25c20718fa--- a/src/public/app/widgets/type_widgets/read_only_text.ts+++ b/src/public/app/widgets/type_widgets/read_only_text.ts@@@ -1,14 -1,13 +1,14 @@@import AbstractTextTypeWidget from "./abstract_text_type_widget.js";import libraryLoader from "../../services/library_loader.js";import { applySyntaxHighlight } from "../../services/syntax_highlight.js";- import { getMermaidConfig } from "../mermaid.js";import type FNote from "../../entities/fnote.js";-import type { EventData } from "../../components/app_context.js";+import type { CommandListenerData, EventData } from "../../components/app_context.js";import { getLocaleById } from "../../services/i18n.js";+import appContext from "../../components/app_context.js";+ import { getMermaidConfig } from "../../services/mermaid.js";- const TPL = `+ const TPL = /*html*/`-<div class="note-detail-readonly-text note-detail-printable">+<div class="note-detail-readonly-text note-detail-printable" tabindex="100"><style>/* h1 should not be used at all since semantically that's a note title */.note-detail-readonly-text h1 { font-size: 1.8em; }