mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 01:06:00 +02:00
feat(code): adjust word wrap through note actions
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user