Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/gui/src/IPC.js
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,11 @@ const ipc_listener = async (event, handled) => {
// set options
event.data.options = event.data.options ?? {};

// Map defaultValue to default for compatibility
if (event.data.options.defaultValue && !event.data.options.default) {
event.data.options.default = event.data.options.defaultValue;
}

// clear window_options for security reasons
event.data.options.window_options = {};

Expand Down Expand Up @@ -1382,6 +1387,11 @@ const ipc_listener = async (event, handled) => {
}
event.data.options = event.data.options ?? {};

// Map defaultValue to default for compatibility
if (event.data.options.defaultValue && !event.data.options.default) {
event.data.options.default = event.data.options.defaultValue;
}

// Clear window_options for security reasons
event.data.options.window_options = {};

Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/UI/UIWindowFontPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function UIWindowFontPicker (options) {
h += '<div style="padding: 20px; border-bottom: 1px solid #ced7e1; width: 100%; box-sizing: border-box;">';
h += '<div class="font-list" style="margin-bottom: 10px; height: 200px; overflow-y: scroll; background-color: white; padding: 0 10px;">';
fontAvailable.forEach(element => {
h += `<p class="font-selector disable-user-select ${options.default === element ? 'font-selector-active' : ''}" style="font-family: '${html_encode(element)}';" data-font-family="${html_encode(element)}">${html_encode(element)}</p>`; // 👉️ one, two, three, four
h += `<p class="font-selector disable-user-select ${(options.default === element || options.defaultValue === element) ? 'font-selector-active' : ''}" style="font-family: '${html_encode(element)}';" data-font-family="${html_encode(element)}">${html_encode(element)}</p>`; // 👉️ one, two, three, four
});
h += '</div>';

Expand Down
2 changes: 1 addition & 1 deletion src/puter-js/src/modules/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ class UI extends EventListener {
return new Promise((resolve) => {
const opts = typeof options === 'string' ? { defaultFont: options } : (options ?? {});
const el = document.createElement('puter-font-picker');
const defaultFont = opts.defaultFont || opts.default || 'System UI';
const defaultFont = opts.defaultValue || opts.defaultFont || opts.default || 'System UI';
el.setAttribute('default-font', defaultFont);
el.addEventListener('response', (e) => resolve(e.detail));
document.body.appendChild(el);
Expand Down
3 changes: 3 additions & 0 deletions src/puter-js/types/modules/ui.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ export interface ColorPickerOptions {
export interface FontPickerOptions {
/** The font initially selected when the picker opens. */
defaultFont?: string;

/** The font initially selected when the picker opens (alias for defaultFont). */
defaultValue?: string;
}

/** Options that configure `showDirectoryPicker()`. */
Expand Down
Loading