Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
Languages dialog: search and scroll the available list
nyblnet74c48509ac74
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.tsindex 22647a52..890c644a 100644--- a/slides/src/editor/editor.ts+++ b/slides/src/editor/editor.ts@@ -34,6 +34,9 @@ const i18nT = t* notice has been acknowledged. It is a property of the browser. */const SAVE_NOTICE_KEY = 'bento-save-notice'+/** Show the language search once the available list outgrows a glance. */+const SEARCH_FROM = 8+const SHAPE_MENU: Array<{ kind: ShapeKind; label: string; icon: string; draw?: 'line' | 'path' | 'connector' | 'free' | 'poly'; tip: string }> = [{ kind: 'rect', label: 'Rectangle', icon: ICONS.rect, tip: 'A rectangle — rounded corners, fills, gradients and shadows in the panel' },{ kind: 'ellipse', label: 'Ellipse', icon: ICONS.ellipse, tip: 'An ellipse or circle' },@@ -1020,7 +1023,7 @@ export class Editor {b.textContent = blurblistHost.appendChild(b)}- const row = (label: string, sub: string, action?: HTMLElement) => {+ const row = (label: string, sub: string, action?: HTMLElement, host: HTMLElement = listHost) => {const r = div('ed-lang-row')const txt = div('ed-lang-txt')const n = document.createElement('b')@@ -1030,7 +1033,7 @@ export class Editor {txt.append(n, s)r.appendChild(txt)if (action) r.appendChild(action)- listHost.appendChild(r)+ host.appendChild(r)}section(t('In this file'), t('Travels with the deck — anyone you send it to gets these too.'))@@ -1060,14 +1063,44 @@ export class Editor {row(p.label || p.lang, p.version ? t('Language pack · built for v{v}', { v: p.version }) : t('Language pack'), rm)}- const avail = await availablePacks()+ const all = await availablePacks()section(t('Available to add'), t('Adding one puts it on this computer. New languages arrive with each release.'))- if (!avail.length) {+ if (!all.length) {const none = div('ed-hint')none.textContent = t('Nothing new right now.')listHost.appendChild(none)}- for (const p of avail) {+ // Search + a scrolling list: this section is the one that grows without+ // bound as more languages ship, while the two above stay short. Matching+ // on the endonym AND the code means someone who knows "nl" but not+ // "Nederlands" (or the reverse) finds it either way.+ if (all.length > SEARCH_FROM) {+ const search = document.createElement('input')+ search.type = 'search'+ search.className = 'ed-lang-search'+ search.placeholder = t('Search languages')+ search.addEventListener('input', () => renderAvail(search.value))+ listHost.appendChild(search)+ }+ const scroller = div(all.length > SEARCH_FROM ? 'ed-lang-scroll' : '')+ listHost.appendChild(scroller)++ const renderAvail = (q = '') => {+ scroller.textContent = ''+ const needle = q.trim().toLowerCase()+ const hits = needle+ ? all.filter((p) => p.label.toLowerCase().includes(needle) || p.lang.toLowerCase().includes(needle))+ : all+ if (!hits.length) {+ const none = div('ed-hint')+ none.textContent = t('No language matches “{q}”.', { q: q.trim() })+ scroller.appendChild(none)+ return+ }+ for (const p of hits) addRow(p, scroller)+ }++ const addRow = (p: import('../packs').PackListing, host: HTMLElement) => {const add = document.createElement('button')add.className = 'ed-btn'add.textContent = t('Add')@@ -1087,8 +1120,10 @@ export class Editor {this.rebuildSidebar()void paint()})- row(p.label, p.lang, add)+ row(p.label, p.lang, add, host)}++ renderAvail()}await paint()diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.tsindex 250a9998..1af3c47c 100644--- a/slides/src/i18n/de.ts+++ b/slides/src/i18n/de.ts@@ -692,4 +692,6 @@ export const de: Catalog = {"{lang} is ready to use": "{lang} steht jetzt bereit","Couldn’t download that language — check your connection and try again.": "Diese Sprache konnte nicht geladen werden — prüfe deine Verbindung und versuche es erneut.","It works now, but there’s no room to save it here — it will be gone after a reload.": "Es funktioniert jetzt, aber hier ist kein Platz zum Speichern — nach dem Neuladen ist es weg.",+ "Search languages": "Sprachen suchen",+ "No language matches “{q}”.": "Keine Sprache passt zu „{q}“.",}diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.tsindex 3fa520db..270d502d 100644--- a/slides/src/i18n/es.ts+++ b/slides/src/i18n/es.ts@@ -692,4 +692,6 @@ export const es: Catalog = {"{lang} is ready to use": "{lang} ya está disponible","Couldn’t download that language — check your connection and try again.": "No se pudo descargar ese idioma: comprueba tu conexión e inténtalo de nuevo.","It works now, but there’s no room to save it here — it will be gone after a reload.": "Funciona ahora, pero no hay espacio para guardarlo aquí: desaparecerá al recargar.",+ "Search languages": "Buscar idiomas",+ "No language matches “{q}”.": "Ningún idioma coincide con «{q}».",}diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.tsindex a0be08c2..6b1ebb98 100644--- a/slides/src/i18n/fr.ts+++ b/slides/src/i18n/fr.ts@@ -692,4 +692,6 @@ export const fr: Catalog = {"{lang} is ready to use": "{lang} est prêt à l’emploi","Couldn’t download that language — check your connection and try again.": "Impossible de télécharger cette langue — vérifiez votre connexion et réessayez.","It works now, but there’s no room to save it here — it will be gone after a reload.": "Cela fonctionne pour l’instant, mais il n’y a pas de place pour l’enregistrer ici — ce sera perdu au rechargement.",+ "Search languages": "Rechercher des langues",+ "No language matches “{q}”.": "Aucune langue ne correspond à « {q} ».",}diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.tsindex ced9c711..241a7d90 100644--- a/slides/src/i18n/it.ts+++ b/slides/src/i18n/it.ts@@ -692,4 +692,6 @@ export const it: Catalog = {"{lang} is ready to use": "{lang} è pronta all’uso","Couldn’t download that language — check your connection and try again.": "Non è stato possibile scaricare quella lingua — controlla la connessione e riprova.","It works now, but there’s no room to save it here — it will be gone after a reload.": "Funziona adesso, ma non c’è spazio per salvarla qui — sparirà al ricaricamento.",+ "Search languages": "Cerca lingue",+ "No language matches “{q}”.": "Nessuna lingua corrisponde a «{q}».",}diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.tsindex c0cdac25..991f03a7 100644--- a/slides/src/i18n/ja.ts+++ b/slides/src/i18n/ja.ts@@ -692,4 +692,6 @@ export const ja: Catalog = {"{lang} is ready to use": "{lang} を使えるようになりました","Couldn’t download that language — check your connection and try again.": "その言語をダウンロードできませんでした — 接続を確認してもう一度お試しください。","It works now, but there’s no room to save it here — it will be gone after a reload.": "今は使えますが、ここに保存する空き容量がありません — 再読み込みすると消えます。",+ "Search languages": "言語を検索",+ "No language matches “{q}”.": "「{q}」に一致する言語はありません。",}diff --git a/slides/src/i18n/packed.ts b/slides/src/i18n/packed.tsindex 46f7e399..f3351988 100644--- a/slides/src/i18n/packed.ts+++ b/slides/src/i18n/packed.ts@@ -698,4 +698,6 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {"{lang} is ready to use": ["{lang} を使えるようになりました","{lang} 已可使用","{lang} 已可使用","{lang} ya está disponible","{lang} est prêt à l’emploi","{lang} steht jetzt bereit","{lang} è pronta all’uso","{lang} está pronto para uso"],"Couldn’t download that language — check your connection and try again.": ["その言語をダウンロードできませんでした — 接続を確認してもう一度お試しください。","无法下载该语言 — 请检查网络后重试。","無法下載該語言 — 請檢查網路後再試一次。","No se pudo descargar ese idioma: comprueba tu conexión e inténtalo de nuevo.","Impossible de télécharger cette langue — vérifiez votre connexion et réessayez.","Diese Sprache konnte nicht geladen werden — prüfe deine Verbindung und versuche es erneut.","Non è stato possibile scaricare quella lingua — controlla la connessione e riprova.","Não foi possível baixar esse idioma — verifique sua conexão e tente de novo."],"It works now, but there’s no room to save it here — it will be gone after a reload.": ["今は使えますが、ここに保存する空き容量がありません — 再読み込みすると消えます。","现在可以使用,但这里没有空间保存 — 重新加载后将会消失。","現在可以使用,但這裡沒有空間保存 — 重新載入後將會消失。","Funciona ahora, pero no hay espacio para guardarlo aquí: desaparecerá al recargar.","Cela fonctionne pour l’instant, mais il n’y a pas de place pour l’enregistrer ici — ce sera perdu au rechargement.","Es funktioniert jetzt, aber hier ist kein Platz zum Speichern — nach dem Neuladen ist es weg.","Funziona adesso, ma non c’è spazio per salvarla qui — sparirà al ricaricamento.","Funciona agora, mas não há espaço para salvar aqui — sumirá após recarregar."],+ "Search languages": ["言語を検索","搜索语言","搜尋語言","Buscar idiomas","Rechercher des langues","Sprachen suchen","Cerca lingue","Pesquisar idiomas"],+ "No language matches “{q}”.": ["「{q}」に一致する言語はありません。","没有与“{q}”匹配的语言。","沒有與「{q}」相符的語言。","Ningún idioma coincide con «{q}».","Aucune langue ne correspond à « {q} ».","Keine Sprache passt zu „{q}“.","Nessuna lingua corrisponde a «{q}».","Nenhum idioma corresponde a “{q}”."],}diff --git a/slides/src/i18n/pt.ts b/slides/src/i18n/pt.tsindex 272e49cf..cbdb4d96 100644--- a/slides/src/i18n/pt.ts+++ b/slides/src/i18n/pt.ts@@ -690,4 +690,6 @@ export const pt: Catalog = {"{lang} is ready to use": "{lang} está pronto para uso","Couldn’t download that language — check your connection and try again.": "Não foi possível baixar esse idioma — verifique sua conexão e tente de novo.","It works now, but there’s no room to save it here — it will be gone after a reload.": "Funciona agora, mas não há espaço para salvar aqui — sumirá após recarregar.",+ "Search languages": "Pesquisar idiomas",+ "No language matches “{q}”.": "Nenhum idioma corresponde a “{q}”.",}diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.tsindex b146d475..359b01c6 100644--- a/slides/src/i18n/zh-Hans.ts+++ b/slides/src/i18n/zh-Hans.ts@@ -692,4 +692,6 @@ export const zhHans: Catalog = {"{lang} is ready to use": "{lang} 已可使用","Couldn’t download that language — check your connection and try again.": "无法下载该语言 — 请检查网络后重试。","It works now, but there’s no room to save it here — it will be gone after a reload.": "现在可以使用,但这里没有空间保存 — 重新加载后将会消失。",+ "Search languages": "搜索语言",+ "No language matches “{q}”.": "没有与“{q}”匹配的语言。",}diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.tsindex 2409fcd4..6aa2bb61 100644--- a/slides/src/i18n/zh-Hant.ts+++ b/slides/src/i18n/zh-Hant.ts@@ -692,4 +692,6 @@ export const zhHant: Catalog = {"{lang} is ready to use": "{lang} 已可使用","Couldn’t download that language — check your connection and try again.": "無法下載該語言 — 請檢查網路後再試一次。","It works now, but there’s no room to save it here — it will be gone after a reload.": "現在可以使用,但這裡沒有空間保存 — 重新載入後將會消失。",+ "Search languages": "搜尋語言",+ "No language matches “{q}”.": "沒有與「{q}」相符的語言。",}diff --git a/slides/src/styles.css b/slides/src/styles.cssindex f5aea687..a94e3744 100644--- a/slides/src/styles.css+++ b/slides/src/styles.css@@ -1965,3 +1965,8 @@ input.ed-toggle { width: 16px; height: 16px; accent-color: #5E7699; cursor: poin.ed-lang-txt b { font-size: 13px; font-weight: 600; }.ed-lang-txt span { font-size: 11.5px; color: var(--muted); }.ed-lang-blurb { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: -2px 0 6px; }+.ed-lang-search {+ width: 100%; margin: 4px 0 6px; padding: 7px 10px; font-size: 13px;+ border: 1px solid var(--line); border-radius: 8px; background: var(--bg);+}+.ed-lang-scroll { max-height: 240px; overflow-y: auto; scrollbar-gutter: stable; }