Skip to content

Commit 393ba0e

Browse files
authored
refreshAttributeSelect API (#480)
* add refreshAttributeSelect api * mv inside of feature flag * 1.6.0
1 parent b946445 commit 393ba0e

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

docs/attribute-select.md

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ You can customize the appearance of the dropdowns by targeting the following CSS
4949
- Dropdown button: `roamjs-attribute-select-button`
5050
- Popover content: `roamjs-attribute-select-popover`
5151

52+
## Developer API
53+
54+
For developers of other extensions who want to interact with the Attribute Select feature, we expose the following API, available on the global `window.roamjs.extension.workbench` object:
55+
56+
- `refreshAttributeSelect` - `() => void` Refreshes the defined attributes and updates the attribute observer. This is useful when attributes or options have been programmatically updated and need to be reflected in the UI without a page reload.
57+
5258
<!-- # Demo -->
5359

5460
<!-- TODO -->

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@types/mozilla-readability": "^0.2.0",
2424
"@types/turndown": "^5.0.1"
2525
},
26-
"version": "1.5.5",
26+
"version": "1.6.0",
2727
"samepage": {
2828
"extends": "node_modules/roamjs-components/package.json"
2929
}

src/features/attributeSelect.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -766,12 +766,22 @@ export const toggleFeature = async (flag: boolean) => {
766766

767767
updateAttributeObserver();
768768

769+
window.roamjs.extension.workbench = {
770+
refreshAttributeSelect: () => {
771+
definedAttributes = getDefinedAttributes();
772+
updateAttributeObserver();
773+
},
774+
};
775+
769776
unloads.add(() => {
770777
observer.disconnect();
771778
attributeObserver.disconnect();
772779
});
773780
} else {
774781
unloads.forEach((u) => u());
775782
unloads.clear();
783+
if (window.roamjs?.extension?.workbench?.refreshAttributeSelect) {
784+
delete window.roamjs.extension.workbench.refreshAttributeSelect;
785+
}
776786
}
777787
};

0 commit comments

Comments
 (0)