mirror of
https://github.com/zadam/trilium.git
synced 2026-05-06 17:17:37 +02:00
chore: address requested changes
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
--ck-content-color-image-caption-background: transparent !important;
|
||||
}
|
||||
|
||||
@page {
|
||||
margin: 2cm;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
|
||||
@@ -446,7 +446,7 @@ function TabWidthSwitcher({ note, noteContext }: StatusBarContext) {
|
||||
const [ globalUseTabs ] = useTriliumOptionBool("codeNoteIndentWithTabs");
|
||||
const [ noteTabWidth, setNoteTabWidth ] = useNoteLabelInt(note, "tabWidth");
|
||||
const [ noteUseTabs, setNoteUseTabs ] = useNoteLabelOptionalBool(note, "indentWithTabs");
|
||||
const effectiveTabWidth = noteTabWidth ?? globalTabWidth;
|
||||
const effectiveTabWidth = noteTabWidth ?? globalTabWidth ?? 4;
|
||||
const effectiveUseTabs = noteUseTabs ?? globalUseTabs;
|
||||
const hasWidthOverride = noteTabWidth != null;
|
||||
const hasStyleOverride = noteUseTabs != null;
|
||||
|
||||
@@ -29,7 +29,7 @@ function measureLeadingColumns(leading: string, tabWidth: number): number {
|
||||
*/
|
||||
export function convertIndentation(content: string, from: IndentStyle, to: IndentStyle): string {
|
||||
if (from.useTabs === to.useTabs && from.width === to.width) return content;
|
||||
if (from.width <= 0 || to.width <= 0) return content;
|
||||
if (!Number.isFinite(from.width) || !Number.isFinite(to.width) || from.width <= 0 || to.width <= 0) return content;
|
||||
const toUnit = to.useTabs ? "\t" : " ".repeat(to.width);
|
||||
|
||||
return content.replace(/^[ \t]+/gm, (leading) => {
|
||||
|
||||
@@ -19,6 +19,9 @@ export default function FormTextBox({ inputRef, className, type, currentValue, o
|
||||
if (type === "number") {
|
||||
const { min, max } = rest;
|
||||
const currentValueNum = parseInt(value, 10);
|
||||
if (!Number.isFinite(currentValueNum)) {
|
||||
return String(min ?? "");
|
||||
}
|
||||
if (min && currentValueNum < parseInt(String(min), 10)) {
|
||||
return String(min);
|
||||
} else if (max && currentValueNum > parseInt(String(max), 10)) {
|
||||
|
||||
@@ -682,8 +682,9 @@ export function useNoteLabelInt(note: FNote | undefined | null, labelName: Filte
|
||||
//@ts-expect-error `useNoteLabel` only accepts string properties but we need to be able to read number ones.
|
||||
const [ value, setValue ] = useNoteLabel(note, labelName);
|
||||
useDebugValue(labelName);
|
||||
const parsed = value ? parseInt(value, 10) : undefined;
|
||||
return [
|
||||
(value ? parseInt(value, 10) : undefined),
|
||||
(Number.isFinite(parsed) ? parsed : undefined),
|
||||
(newValue) => setValue(newValue === null ? null : String(newValue))
|
||||
];
|
||||
}
|
||||
|
||||
@@ -51,10 +51,8 @@ export default function CodeMirror({ className, content, mime, editorRef: extern
|
||||
|
||||
// React to indent size / style changes.
|
||||
useEffect(() => {
|
||||
if (extraOpts.indentSize != null) {
|
||||
codeEditorRef.current?.setIndent(extraOpts.indentSize, !!extraOpts.useTabs);
|
||||
} else if (extraOpts.useTabs != null) {
|
||||
codeEditorRef.current?.setUseTabs(extraOpts.useTabs);
|
||||
if (extraOpts.indentSize != null || extraOpts.useTabs != null) {
|
||||
codeEditorRef.current?.setIndent(extraOpts.indentSize ?? 4, !!extraOpts.useTabs);
|
||||
}
|
||||
}, [ extraOpts.indentSize, extraOpts.useTabs ]);
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ function CodeBlockPreview({ theme, wordWrap, tabWidth }: { theme: string, wordWr
|
||||
const codeStyle: CSSProperties = useMemo(() => {
|
||||
return {
|
||||
whiteSpace: wordWrap ? "pre-wrap" : "pre",
|
||||
tabSize: tabWidth ?? "4"
|
||||
tabSize: tabWidth || "4"
|
||||
};
|
||||
}, [ wordWrap, tabWidth ]);
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext
|
||||
const onWatchdogStateChange = useWatchdogCrashHandling();
|
||||
|
||||
useEffect(() => {
|
||||
document.body.style.setProperty("--code-block-tab-width", codeBlockTabWidth ?? "4");
|
||||
document.body.style.setProperty("--code-block-tab-width", codeBlockTabWidth || "4");
|
||||
}, [codeBlockTabWidth]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -28,7 +28,7 @@ export default function ReadOnlyText({ note, noteContext, ntxId }: TypeWidgetPro
|
||||
const { isRtl } = useNoteLanguage(note);
|
||||
|
||||
useEffect(() => {
|
||||
document.body.style.setProperty("--code-block-tab-width", codeBlockTabWidth ?? "4");
|
||||
document.body.style.setProperty("--code-block-tab-width", codeBlockTabWidth || "4");
|
||||
}, [codeBlockTabWidth]);
|
||||
|
||||
// Apply necessary transforms.
|
||||
|
||||
@@ -221,6 +221,7 @@ export function initPrintingHandlers() {
|
||||
scale,
|
||||
margins: parseMargins(margins),
|
||||
pageRanges: pageRanges || undefined,
|
||||
preferCSSPageSize: false,
|
||||
generateDocumentOutline: true,
|
||||
generateTaggedPDF: true,
|
||||
printBackground: true,
|
||||
@@ -272,6 +273,7 @@ export function initPrintingHandlers() {
|
||||
scale,
|
||||
margins: parseMargins(margins),
|
||||
pageRanges: pageRanges || undefined,
|
||||
preferCSSPageSize: false,
|
||||
generateDocumentOutline: true,
|
||||
generateTaggedPDF: true,
|
||||
printBackground: true,
|
||||
@@ -350,6 +352,8 @@ export function initPrintingHandlers() {
|
||||
|
||||
// print() accepts most of the same options as printToPDF, but typing differs
|
||||
// slightly (e.g. no "Ledger" pageSize). Cast to keep this concise.
|
||||
// "Ledger" and "Tabloid" are the same physical size (11×17 in); Electron's
|
||||
// print() API only recognises "Tabloid", so we map "Ledger" to "Tabloid".
|
||||
const printOpts: Electron.WebContentsPrintOptions = {
|
||||
silent,
|
||||
deviceName,
|
||||
|
||||
@@ -183,6 +183,8 @@ export default class CodeMirror extends EditorView {
|
||||
}
|
||||
|
||||
setIndent(size: number, useTabs: boolean) {
|
||||
if (!Number.isFinite(size) || size < 1) size = 4;
|
||||
if (size > 16) size = 16;
|
||||
this.config.indentSize = size;
|
||||
this.config.useTabs = useTabs;
|
||||
this.dispatch({
|
||||
|
||||
@@ -83,6 +83,10 @@ export default [
|
||||
{ type: "label", name: "iconPack", isDangerous: true },
|
||||
{ type: "label", name: "docName", isDangerous: true },
|
||||
|
||||
{ type: "label", name: "tabWidth" },
|
||||
{ type: "label", name: "indentWithTabs" },
|
||||
{ type: "label", name: "wrapLines" },
|
||||
|
||||
{ type: "label", name: "printLandscape" },
|
||||
{ type: "label", name: "printPageSize" },
|
||||
{ type: "label", name: "printScale" },
|
||||
|
||||
Reference in New Issue
Block a user