chore(react/ribbon): display attribute errors

This commit is contained in:
Elian Doran
2025-08-23 18:28:42 +03:00
parent f049b8b915
commit e8ae5486c8
2 changed files with 8 additions and 14 deletions

View File

@@ -165,12 +165,13 @@ export default function AttributeEditor({ note, componentId }: { note: FNote, co
onChange={(currentValue) => {
currentValueRef.current = currentValue ?? "";
setNeedsSaving(lastSavedContent.current !== currentValue);
setError(undefined);
}}
onClick={(e, pos) => {
if (pos && pos.textNode && pos.textNode.data) {
const clickIndex = getClickIndex(pos);
let parsedAttrs;
let parsedAttrs: Attribute[];
try {
parsedAttrs = attribute_parser.lexAndParse(getPreprocessedData(currentValueRef.current), true);
@@ -215,6 +216,12 @@ export default function AttributeEditor({ note, componentId }: { note: FNote, co
text={escapeQuotes(t("attribute_editor.save_attributes"))}
onClick={save}
/> }
{ error && (
<div className="attribute-errors">
{typeof error === "object" && "message" in error && typeof error.message === "string" && error.message}
</div>
)}
</div>
{attributeDetailWidgetEl}