style(journals): apply expanded 80-width formatting and snake_case

- Batch formatted all Journals module files using Prettier with printWidth: 80.
- Refactored preventDefault to prevent_default across all Svelte components.
- Standardized line breaks for imports and long attribute lists for better readability.
- Ensured consistent snake_case naming for internal identifiers.
This commit is contained in:
Scott Idem
2026-02-06 14:15:43 -05:00
parent 07dd6c18a1
commit 2f3125c64b
37 changed files with 3033 additions and 1133 deletions

View File

@@ -1,19 +1,28 @@
/**
* Wraps the current selection in CodeMirror with the given prefix and suffix.
*/
export function wrapSelection(view: any, prefix: string, suffix: string = prefix) {
export function wrapSelection(
view: any,
prefix: string,
suffix: string = prefix
) {
if (!view || view.updateInProgress) return;
const { state } = view;
view.dispatch(state.changeByRange((range: any) => {
return {
changes: [
{from: range.from, insert: prefix},
{from: range.to, insert: suffix}
],
range: range.constructor.range(range.from + prefix.length, range.to + prefix.length)
};
}));
view.dispatch(
state.changeByRange((range: any) => {
return {
changes: [
{ from: range.from, insert: prefix },
{ from: range.to, insert: suffix }
],
range: range.constructor.range(
range.from + prefix.length,
range.to + prefix.length
)
};
})
);
view.focus();
}
@@ -22,32 +31,49 @@ export function wrapSelection(view: any, prefix: string, suffix: string = prefix
*/
export function toggleLinePrefix(view: any, prefix: string) {
if (!view || view.updateInProgress) return;
const { state } = view;
view.dispatch(state.changeByRange((range: any) => {
const lines = [];
for (let pos = range.from; pos <= range.to; ) {
const line = state.doc.lineAt(pos);
lines.push(line);
pos = line.to + 1;
}
const isAlreadyPrefixed = lines.every(l => l.text.startsWith(prefix));
const lineChanges = lines.map(l => {
if (isAlreadyPrefixed) {
return { from: l.from, to: l.from + prefix.length, insert: '' };
} else {
return { from: l.from, insert: prefix };
view.dispatch(
state.changeByRange((range: any) => {
const lines = [];
for (let pos = range.from; pos <= range.to; ) {
const line = state.doc.lineAt(pos);
lines.push(line);
pos = line.to + 1;
}
});
const newFrom = range.from + (isAlreadyPrefixed ? -prefix.length : prefix.length);
const newTo = range.to + (isAlreadyPrefixed ? (-prefix.length * lines.length) : (prefix.length * lines.length));
const isAlreadyPrefixed = lines.every((l) =>
l.text.startsWith(prefix)
);
const lineChanges = lines.map((l) => {
if (isAlreadyPrefixed) {
return {
from: l.from,
to: l.from + prefix.length,
insert: ''
};
} else {
return { from: l.from, insert: prefix };
}
});
return {
changes: lineChanges,
range: range.constructor.range(newFrom, Math.max(newFrom, newTo))
};
}));
const newFrom =
range.from +
(isAlreadyPrefixed ? -prefix.length : prefix.length);
const newTo =
range.to +
(isAlreadyPrefixed
? -prefix.length * lines.length
: prefix.length * lines.length);
return {
changes: lineChanges,
range: range.constructor.range(
newFrom,
Math.max(newFrom, newTo)
)
};
})
);
view.focus();
}
}