Changeset 0.18.1 (#80)
This commit is contained in:
@@ -196,12 +196,59 @@ const Extensions = {
|
||||
},
|
||||
},
|
||||
|
||||
// UI injection points (v0.17.0 — stub for now)
|
||||
// UI primitives — safe wrappers around primary UI components.
|
||||
// Extensions use these instead of reaching into globals directly.
|
||||
ui: {
|
||||
inject: (region, el) => {
|
||||
/** Show a toast notification. type: 'success' | 'error' | 'warning' | 'info' */
|
||||
toast(msg, type = 'success') {
|
||||
if (typeof UI !== 'undefined' && UI.toast) UI.toast(msg, type);
|
||||
},
|
||||
|
||||
/** Open the side-panel preview with arbitrary HTML content. */
|
||||
openPreview(html) {
|
||||
const frame = document.getElementById('previewFrame');
|
||||
const empty = document.getElementById('previewEmpty');
|
||||
if (frame) {
|
||||
frame.srcdoc = html;
|
||||
frame.style.display = '';
|
||||
}
|
||||
if (empty) empty.style.display = 'none';
|
||||
if (typeof PanelRegistry !== 'undefined') {
|
||||
PanelRegistry.open('preview');
|
||||
PanelRegistry.refreshActions();
|
||||
}
|
||||
},
|
||||
|
||||
/** Is the current theme dark? */
|
||||
isDark() {
|
||||
return document.body.classList.contains('dark-theme') ||
|
||||
window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
},
|
||||
|
||||
/** Is the viewport at mobile width (≤ 768px)? */
|
||||
isMobile() {
|
||||
return window.innerWidth <= 768;
|
||||
},
|
||||
|
||||
/** Is the side panel container currently open? */
|
||||
isPanelOpen() {
|
||||
if (typeof PanelRegistry !== 'undefined') return PanelRegistry.isContainerOpen();
|
||||
return false;
|
||||
},
|
||||
|
||||
/** Show a confirm dialog. Returns Promise<boolean>. */
|
||||
confirm(msg, opts) {
|
||||
if (typeof showConfirm === 'function') return showConfirm(msg, opts);
|
||||
return Promise.resolve(window.confirm(msg));
|
||||
},
|
||||
|
||||
/** Inject an element into a named UI region (stub for future use). */
|
||||
inject(region, el) {
|
||||
console.warn(`[Extensions] ui.inject() not yet implemented (${extId}:${region})`);
|
||||
},
|
||||
createMenu: (anchor, opts) => {
|
||||
|
||||
/** Create a popup menu anchored to an element. */
|
||||
createMenu(anchor, opts) {
|
||||
if (typeof createPopupMenu === 'function') return createPopupMenu(anchor, opts);
|
||||
return null;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user