Skip to content

Build your personal knowledge base with Trilium Notes

feat(code): adjust word wrap through note actions

Elian Doran9116cbcba47c
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index f18749449f..e6c88a6c19 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -695,6 +695,11 @@
"move_right": "Move right"
},
"note_actions": {
+ "word_wrap": "Word wrap",
+ "word_wrap_auto": "Auto",
+ "word_wrap_auto_description": "Follow the global setting",
+ "word_wrap_on": "On",
+ "word_wrap_off": "Off",
"convert_into_attachment": "Convert into attachment",
"re_render_note": "Re-render note",
"search_in_note": "Search in note",
@@ -2328,6 +2333,10 @@
"print": "Print",
"export_pdf": "Export as PDF",
"system_print": "Print using system dialog",
+ "destination": "Destination",
+ "destination_pdf": "Save as PDF",
+ "destination_printers": "Printers",
+ "destination_default": "Default",
"orientation": "Orientation",
"portrait": "Portrait",
"landscape": "Landscape",
diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsx
index 1bbd42c049..679b624c10 100644
--- a/apps/client/src/widgets/ribbon/NoteActions.tsx
+++ b/apps/client/src/widgets/ribbon/NoteActions.tsx
@@ -22,7 +22,7 @@ import MovePaneButton from "../buttons/move_pane_button";
import ActionButton from "../react/ActionButton";
import Dropdown from "../react/Dropdown";
import { FormDropdownDivider, FormDropdownSubmenu, FormListHeader, FormListItem, FormListToggleableItem } from "../react/FormList";
-import { useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteProperty, useSyncedRef, useTriliumEvent, useTriliumOption } from "../react/hooks";
+import { useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteLabelOptionalBool, useNoteProperty, useSyncedRef, useTriliumEvent, useTriliumOption } from "../react/hooks";
import { ParentComponent } from "../react/react_utils";
import { NoteTypeDropdownContent, useNoteBookmarkState, useShareState } from "./BasicPropertiesTab";
import NoteActionsCustom from "./NoteActionsCustom";
@@ -115,6 +115,8 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNote
>
{itemsAtStart}
+ {note.type === "code" && <CodeProperties note={note} />}
+
{isReadOnly && <>
<CommandItem icon="bx bx-pencil" text={t("read-only-info.edit-note")}
command={() => enableEditing()} />
@@ -179,6 +181,27 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNote
);
}
+function CodeProperties({ note }: { note: FNote }) {
+ const [ wrapLines, setWrapLines ] = useNoteLabelOptionalBool(note, "wrapLines");
+
+ return (
+ <>
+ <FormDropdownSubmenu title={t("note_actions.word_wrap")} icon="bx bx-align-justify" dropStart>
+ <FormListItem checked={wrapLines == null} onClick={() => setWrapLines(null)} description={t("note_actions.word_wrap_auto_description")}>
+ {t("note_actions.word_wrap_auto")}
+ </FormListItem>
+ <FormListItem checked={wrapLines === true} onClick={() => setWrapLines(true)}>
+ {t("note_actions.word_wrap_on")}
+ </FormListItem>
+ <FormListItem checked={wrapLines === false} onClick={() => setWrapLines(false)}>
+ {t("note_actions.word_wrap_off")}
+ </FormListItem>
+ </FormDropdownSubmenu>
+ <FormDropdownDivider />
+ </>
+ );
+}
+
function NoteBasicProperties({ note, focus }: {
note: FNote;
focus: RefObject<ItemToFocus>;