Update memo layout and library import examples
All checks were successful
Deploy Sokko G / deploy (push) Successful in 16s

This commit is contained in:
Shinuwa 2026-08-25 19:17:19 +02:00
parent 6125336338
commit 91d99d6ca4
6 changed files with 86 additions and 28 deletions

View file

@ -2,7 +2,7 @@
import { CompactDropdown } from "../../../components/CompactDropdown.jsx";
import { Icon } from "../../../components/Icon.jsx";
import { moveItem, useGroupedReorder } from "../../../hooks/useGroupedReorder.js";
import { useEffect, useMemo, useState } from "react";
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { TextExchangeActions } from "./TextExchangeActions.jsx";
import { TEXT_COLORS } from "./notepadUtils.js";
@ -11,6 +11,7 @@ export function MemosModule({ toolboxId, moduleId, context, editing, textExchang
const data = useMemo(() => context.normalizeMemosData(storedData), [context, storedData]);
const textContent = context.moduleText?.memos || {};
const tickerItems = data.tickerEnabled ? data.items : [];
const textareaRefs = useRef(new Map());
const [drafts, setDrafts] = useState({});
const {
itemReorder,
@ -32,6 +33,16 @@ export function MemosModule({ toolboxId, moduleId, context, editing, textExchang
setDrafts(Object.fromEntries(data.items.map((item) => [item.id, item.text])));
}, [data.items]);
useLayoutEffect(() => {
data.items.forEach((item) => resizeMemoTextarea(textareaRefs.current.get(item.id)));
}, [data.items, drafts]);
function resizeMemoTextarea(element) {
if (!element) return;
element.style.height = "auto";
element.style.height = `${element.scrollHeight}px`;
}
function save(nextData) {
context.setModuleData(toolboxId, moduleId, nextData, "memos");
}
@ -133,10 +144,21 @@ export function MemosModule({ toolboxId, moduleId, context, editing, textExchang
<Icon name="drag" />
</button>
<textarea
ref={(element) => {
if (element) {
textareaRefs.current.set(memo.id, element);
resizeMemoTextarea(element);
} else {
textareaRefs.current.delete(memo.id);
}
}}
value={drafts[memo.id] ?? memo.text}
rows={3}
placeholder={textContent.placeholder || "Mémo court..."}
onChange={(event) => setDrafts((current) => ({ ...current, [memo.id]: event.target.value }))}
onChange={(event) => {
resizeMemoTextarea(event.currentTarget);
setDrafts((current) => ({ ...current, [memo.id]: event.target.value }));
}}
onBlur={() => commitMemoText(memo.id)}
aria-label={textContent.editLabel || "Modifier le mémo"}
/>

View file

@ -1,5 +1,6 @@
// Rôle : gère l'import/export texte des outils simples et tabulaires.
import { cellAddress, columnIndexToName } from "../tableFormulaEngine.js";
import { evaluateCalculatorEntries } from "../calculatorUtils.js";
import { cloneDrawingData, lineError, parseBoolean, parseColonImportLines, parseInteger, parseMetaLine, parseNumber, splitLines, textToNotepadExchangeHtml } from "./shared.js";
export function exportNotepadText(data) {
@ -216,9 +217,10 @@ export function importCountersText(text, context) {
export function exportCalculatorText(data) {
const lines = [];
const entries = evaluateCalculatorEntries(data.entries || []);
if (data.scrollResults) lines.push("@scrollResults: true");
function visit(parentId = "", depth = 0) {
(data.entries || []).filter((entry) => (entry.parentId || "") === parentId).forEach((entry) => {
entries.filter((entry) => (entry.parentId || "") === parentId).forEach((entry) => {
const formula = String(entry.formula || "").trim();
lines.push(`${" ".repeat(depth)}${entry.label || ""}: ${entry.value}${formula ? ` | formula=${formula}` : ""}`);
visit(entry.id, depth + 1);

View file

@ -3,7 +3,7 @@ import { formatMeta, lineError, parseBoolean, parseInteger, parseMetaLine, parse
export function exportTaskPlannerText(data) {
const lines = [];
if (data.weeklyResetDay !== 1) lines.push(`@weeklyResetDay: ${data.weeklyResetDay}`);
if (Number.isFinite(data.weeklyResetDay) && data.weeklyResetDay !== 1) lines.push(`@weeklyResetDay: ${data.weeklyResetDay}`);
if (data.resetTime && data.resetTime !== "00:00") lines.push(`@resetTime: ${data.resetTime}`);
if (data.hideCompleted) lines.push("@hideCompleted: true");
if (data.collapsedCategories?.length) lines.push(`@collapsed: ${data.collapsedCategories.join(", ")}`);
@ -169,4 +169,3 @@ export function parseGoalTreeItemsMeta(value) {
return [];
}
}