fix(help): webview source not updating

This commit is contained in:
Elian Doran 2025-11-02 21:40:21 +02:00
parent 1d259aab9d
commit 4526455486
No known key found for this signature in database
4 changed files with 26 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -98,6 +98,21 @@ describe("Hidden Subtree", () => {
expect(updatedBoardTemplate?.title).not.toBe("My renamed board");
});
it("enforces webviewSrc of templates", () => {
const apiRefNote = becca.getNote("_help_9qPsTWBorUhQ");
expect(apiRefNote).toBeDefined();
cls.init(() => {
apiRefNote!.setAttribute("label", "webViewSrc", "foo");
apiRefNote!.save();
hiddenSubtreeService.checkHiddenSubtree(true);
});
const updatedApiRefNote = becca.getNote("_help_9qPsTWBorUhQ");
expect(updatedApiRefNote).toBeDefined();
expect(updatedApiRefNote?.getLabelValue("webViewSrc")).not.toBe("foo");
});
it("maintains launchers hidden, if they were shown by default but moved by the user", () => {
const launcher = becca.getNote("_lbLlmChat");
const branch = launcher?.getParentBranches()[0];

View File

@ -451,8 +451,16 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
// Enforce attribute structure if needed.
if (item.enforceAttributes) {
for (const attribute of note.getAttributes()) {
if (!attrs.some(a => a.name === attribute.name)) {
// Remove unwanted attributes.
const attrDef = attrs.find(a => a.name === attribute.name);
if (!attrDef) {
attribute.markAsDeleted();
continue;
}
// Ensure value is consistent.
if (attribute.value !== attrDef.value) {
note.setAttributeValueById(attribute.attributeId, attrDef.value);
}
}
}

View File

@ -78,6 +78,7 @@ export function parseNoteMeta(noteMeta: NoteMeta, docNameRoot: string): HiddenSu
// Handle web views
if (noteMeta.type === "webView") {
item.type = "webView";
item.enforceAttributes = true;
}
// Handle children