@appsoftwareltd/etherpk-extension-api 0.18.5 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -340,7 +340,10 @@ context.commands.register('hello.taskWords', (target) => {
340
340
 
341
341
  `context.commandBar.register({ id, title, icon, command, pinned })` adds a button to the row of
342
342
  buttons across the bottom of a phone's screen: after the editing buttons that scroll, or with
343
- `pinned`, at the bar's right end, where it never scrolls away.
343
+ `pinned`, at the bar's right end, where it never scrolls away. With `files`, it is greyed while a tab
344
+ that shows any other type of file is in front, and with `pinned` as well it floats at the bottom right
345
+ of that file's tab in the desktop layout, which has no bar. `context.layout.activeFile()` says which
346
+ file is in front and what text is selected in it.
344
347
 
345
348
  ### Key chords
346
349
 
@@ -411,7 +414,7 @@ thumbnail.addEventListener('click', () => void context.assets.viewImages({ refs:
411
414
  ### Icons
412
415
 
413
416
  `context.icons.svg(name)` draws one of the extension's own icons or one of the Client's, as markup the
414
- Client trusts. The Client's icons, which every `icon` field may name too, are `alias`, `archive`, `backlinks`, `bold`, `bookmark`, `bullet`, `calendar`, `check`, `clock`, `close`, `code`, `copy`, `download`, `fit`, `flag`, `fold`, `frontmatter`, `globe`, `graph`, `grip`, `headless-client`, `highlight`, `image`, `import`, `indent`, `italic`, `list`, `lock`, `lock-open`, `more`, `move`, `move-down`, `move-up`, `new-page`, `open-external`, `outdent`, `page`, `pageless`, `pane-below`, `pane-right`, `pin`, `redo`, `rename`, `reset`, `search`, `slash`, `spell-check`, `table`, `table-add-column`, `table-add-row`, `table-format`, `table-remove-column`, `table-remove-row`, `task`, `task-reference`, `template`, `text-lines`, `today`, `todays-journal`, `tomorrow`, `trash`, `undo`, `view-larger`, `wikilink-close`, `wikilink-open`, `yesterday`, `zoom-in`, `zoom-out`. An
417
+ Client trusts. The Client's icons, which every `icon` field may name too, are `alias`, `archive`, `backlinks`, `bold`, `bookmark`, `bullet`, `calendar`, `check`, `clock`, `close`, `code`, `copy`, `download`, `fit`, `flag`, `fold`, `frontmatter`, `globe`, `graph`, `grip`, `headless-client`, `highlight`, `image`, `import`, `indent`, `italic`, `list`, `lock`, `lock-open`, `more`, `move`, `move-down`, `move-up`, `new-page`, `open-external`, `outdent`, `page`, `pdf`, `pdf-eraser`, `pdf-highlighter`, `pdf-note`, `pdf-page-next`, `pdf-page-previous`, `pdf-full-screen-exit`, `pdf-save`, `pdf-select`, `pdf-pen`, `pdf-print`, `pdf-signature`, `pageless`, `pane-below`, `pane-right`, `pin`, `redo`, `rename`, `reset`, `search`, `slash`, `spell-check`, `table`, `table-add-column`, `table-add-row`, `table-format`, `table-remove-column`, `table-remove-row`, `task`, `task-reference`, `template`, `text-lines`, `today`, `todays-journal`, `tomorrow`, `trash`, `undo`, `view-larger`, `wikilink-close`, `wikilink-open`, `yesterday`, `zoom-in`, `zoom-out`. An
415
418
  icon may be added in a later release, never taken away. An unknown name draws a small dot.
416
419
 
417
420
  ### Settings sections
package/dist/context.d.ts CHANGED
@@ -194,6 +194,8 @@ export interface ExtensionLayout {
194
194
  * journal entry's day, `YYYY-MM-DD`), or null when no document's tab is in front.
195
195
  */
196
196
  activeDocument(): string | null;
197
+ /** The file whose tab is in front, such as a PDF, or null when a document's tab or none is. */
198
+ activeFile(): ActiveFile | null;
197
199
  /** True while the desktop presenter is showing, 1024 pixels wide and more. */
198
200
  isDesktop(): boolean;
199
201
  /**
@@ -204,6 +206,10 @@ export interface ExtensionLayout {
204
206
  openWindow(options: {
205
207
  /** The heading the Client draws beside the close button. */
206
208
  title: string;
209
+ /** `whole` (the default) fills the window. `dialog` is a smaller box in its middle, the app dimmed behind it. */
210
+ size?: 'whole' | 'dialog';
211
+ /** For a `dialog`: asked on a click outside it, and it closes when this says yes. Left out, such a click does nothing. */
212
+ closesOnOutsideClick?(): boolean;
207
213
  /** Draw into `host`, which fills the window under the heading. */
208
214
  mount(host: HTMLElement, window: {
209
215
  close(): void;
@@ -215,6 +221,19 @@ export interface ExtensionLayout {
215
221
  close(): void;
216
222
  };
217
223
  }
224
+ /**
225
+ * The file a tab in front shows, as {@link ExtensionLayout.activeFile} reads it at that moment.
226
+ *
227
+ * @public
228
+ */
229
+ export interface ActiveFile {
230
+ /** Its type, by extension, in lower case: `pdf`, `png`. */
231
+ type: string;
232
+ /** The text selected in it now, on one line, or `''`. Only a PDF has any. */
233
+ selectedText: string;
234
+ /** Put the selection back as it was when this was read, as a dialog that took the keyboard closes. */
235
+ restoreSelection(): void;
236
+ }
218
237
  /**
219
238
  * The rules for naming a concept, which every index answer follows.
220
239
  *
package/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * @packageDocumentation
17
17
  */
18
- export type { CommandHandler, ExtensionCommandBar, ExtensionCommandMenu, ExtensionCommands, ExtensionConcepts, ExtensionContext, ExtensionContextMenu, ExtensionContributions, ExtensionGraphSidebar, ExtensionIcons, ExtensionKeybindings, ExtensionLayout, ExtensionModule, ExtensionPersonStorage, ExtensionSettings, ExtensionStorage, ExtensionTheme, ExtensionViews, IconMarkup, Keybinding, NoticeAction, NoticeOptions, } from './context';
18
+ export type { CommandHandler, ExtensionCommandBar, ExtensionCommandMenu, ExtensionCommands, ExtensionConcepts, ExtensionContext, ExtensionContextMenu, ExtensionContributions, ExtensionGraphSidebar, ExtensionIcons, ExtensionKeybindings, ActiveFile, ExtensionLayout, ExtensionModule, ExtensionPersonStorage, ExtensionSettings, ExtensionStorage, ExtensionTheme, ExtensionViews, IconMarkup, Keybinding, NoticeAction, NoticeOptions, } from './context';
19
19
  export type { AssetDescription, ExtensionAssets, ViewImagesOptions } from './assets';
20
20
  export type { AuthorizeOptions, ExtensionAuth } from './auth';
21
21
  export type { ChooseChoice, ChooseOptions, ExtensionDialogs, PickDateOptions, PromptOptions } from './dialogs';
package/dist/menus.d.ts CHANGED
@@ -187,6 +187,14 @@ export interface CommandBarButton {
187
187
  * editing buttons that scroll. For an action a person reaches for often.
188
188
  */
189
189
  pinned?: boolean;
190
+ /**
191
+ * The types of file the button works on, by extension (`['pdf']`, or `[]` for none): it is greyed
192
+ * while a tab that shows any other file is in front. Left out, the button takes no notice of what
193
+ * is in front, except that a PDF's tab puts its own tools on the bar, and a button that does not name
194
+ * `pdf` is not shown beside them. A `pinned` button that names a file type also floats at the bottom right of that
195
+ * file's tab in the desktop layout, which has no Command Bar. Only `pdf` files draw it there so far.
196
+ */
197
+ files?: readonly string[];
190
198
  /** The Command the button runs. */
191
199
  command: string;
192
200
  /** What the Command is given. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsoftwareltd/etherpk-extension-api",
3
- "version": "0.18.5",
3
+ "version": "0.19.1",
4
4
  "license": "MIT",
5
5
  "description": "The API an EtherPK extension is written against: the context it is started with, its manifest, and the contract its Views follow.",
6
6
  "type": "module",