expose dialog functions to plugins

Massimo Melina committed Apr 2, 2023 at 20:00 UTC 991366bd08dd364b7d26e04389c30af67e8cc4ca
5 files changed +12 -4
frontend/src/BrowseFiles.ts
+4 -1
@@ -227,13 +227,16 @@ const Entry = memo((entry: DirEntry & { midnight: Date, separator?: string }) =>
227 menu.push(...res.flat())
228 const close = newDialog({
229 title: t`File menu`,
230 + className: 'file-dialog',
231 icon: () => ico,
232 position: isMobile() ? undefined
233 : [ev.pageX, ev.pageY - window.scrollY] as [number, number],
234 Content() {
235 const {t} = useI18N()
236 return h(Fragment, {},
236 - t("Name: {name}", { name }),
237 + h('dl', { className: 'file-dialog-properties' },
238 + h('dt', {}, t`Name:`), h('dd', {}, name),
239 + ),
240 h('div', { className: 'file-menu' },
241 menu.map((e: any, i) => !e?.label ? null :
242 h('a', {
frontend/src/index.scss
+4
@@ -383,6 +383,10 @@ button label {
383 }
384 }
385
386 +.file-dialog-properties {
387 + word-break: break-word;
388 + & dd { margin-left: 1.5em; }
389 +}
390 .file-menu {
391 padding-top: .5em;
392 border-top: 1px solid var(--faint-contrast);
frontend/src/misc.ts
+2 -1
@@ -7,6 +7,7 @@ import { Icon } from './icons'
7 import { Dict } from '@hfs/shared'
8 import { state } from './state'
9 import { t } from './i18n'
10 +import * as dialogLib from './dialog'
11 import _ from 'lodash'
12 export * from '@hfs/shared'
13
@@ -60,7 +61,7 @@ export function hfsEvent(name: string, params?:Dict) {
61
62 Object.assign((window as any).HFS ||= {}, {
63 onEvent(name: string, cb: (params:any, tools: any, output:any) => any) {
63 - const tools = { h, React, state, t, _ }
64 + const tools = { h, React, state, t, _, dialogLib }
65 const key = 'hfs.' + name
66 document.addEventListener(key, wrapper)
67 return () => document.removeEventListener(key, wrapper)
langs/hfs-lang-en.json
+1 -1
@@ -105,7 +105,7 @@
105 "download counter": "download counter",
106
107 "File menu": "File menu",
108 - "Name: {name}": "Name: {name}",
108 + "Name:": "Name:",
109 "file_open": "Open",
110 "Download": "Download"
111 }
langs/hfs-lang-it.json
+1 -1
@@ -99,7 +99,7 @@
99 "download counter": "download conteggiati",
100
101 "File menu": "Menu file",
102 - "Name: {name}": "Nome: {name}",
102 + "Name:": "Nome:",
103 "file_open": "Apri",
104 "Download": "Download"
105 }