Update memo layout and library import examples
All checks were successful
Deploy Sokko G / deploy (push) Successful in 16s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 16s
This commit is contained in:
parent
6125336338
commit
91d99d6ca4
6 changed files with 86 additions and 28 deletions
|
|
@ -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"}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@
|
|||
display: grid;
|
||||
gap: var(--space-2);
|
||||
min-height: 132px;
|
||||
padding: var(--space-3) var(--space-3) var(--space-3) 52px;
|
||||
padding: var(--space-3);
|
||||
border: 1px solid color-mix(in srgb, var(--memo-color) 42%, transparent);
|
||||
border-radius: var(--radius-md);
|
||||
background:
|
||||
|
|
@ -94,7 +94,8 @@
|
|||
.memo-card textarea {
|
||||
width: 100%;
|
||||
min-height: 76px;
|
||||
resize: vertical;
|
||||
overflow: hidden;
|
||||
resize: none;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--color-text-primary);
|
||||
|
|
@ -109,8 +110,8 @@
|
|||
|
||||
.memo-drag-handle {
|
||||
position: absolute;
|
||||
top: var(--space-3);
|
||||
left: var(--space-3);
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
display: inline-grid;
|
||||
width: 34px;
|
||||
min-width: 34px;
|
||||
|
|
@ -119,8 +120,15 @@
|
|||
padding: 0;
|
||||
color: var(--color-text-muted);
|
||||
cursor: grab;
|
||||
opacity: 0.72;
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.memo-card:hover .memo-drag-handle,
|
||||
.memo-card:focus-within .memo-drag-handle {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.memo-drag-handle:active {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue