@formicoidea/labre-core 0.46.2 → 0.47.0
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/dist/_pkgs/affine-block-data-view/columns/index.d.ts +1 -1
- package/dist/_pkgs/affine-block-database/data-source.d.ts +1 -1
- package/dist/_pkgs/affine-block-database/properties/converts.d.ts +4 -4
- package/dist/_pkgs/affine-block-database/properties/index.d.ts +1 -1
- package/dist/_pkgs/affine-block-frame/commands.js +41 -1
- package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +1 -1
- package/dist/_pkgs/affine-block-frame/view.js +7 -2
- package/dist/_pkgs/affine-block-note/components/edgeless-page-block-title.d.ts +7 -0
- package/dist/_pkgs/affine-block-note/components/edgeless-page-block-title.js +15 -1
- package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.js +20 -6
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/commands.d.ts +2 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/commands.js +79 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.d.ts +18 -1
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +53 -30
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/index.js +1 -0
- package/dist/_pkgs/affine-block-surface/view.js +11 -2
- package/dist/_pkgs/affine-fragment-doc-title/doc-title.d.ts +8 -0
- package/dist/_pkgs/affine-fragment-doc-title/doc-title.js +65 -4
- package/dist/_pkgs/affine-fragment-doc-title/effects.d.ts +2 -0
- package/dist/_pkgs/affine-fragment-doc-title/effects.js +2 -0
- package/dist/_pkgs/affine-fragment-doc-title/index.d.ts +2 -0
- package/dist/_pkgs/affine-fragment-doc-title/index.js +2 -0
- package/dist/_pkgs/affine-fragment-doc-title/title-band/format.d.ts +69 -0
- package/dist/_pkgs/affine-fragment-doc-title/title-band/format.js +182 -0
- package/dist/_pkgs/affine-fragment-doc-title/title-band/title-band.d.ts +62 -0
- package/dist/_pkgs/affine-fragment-doc-title/title-band/title-band.js +649 -0
- package/dist/_pkgs/affine-fragment-doc-title/translations.d.ts +21 -0
- package/dist/_pkgs/affine-fragment-doc-title/translations.js +58 -0
- package/dist/_pkgs/affine-shared/services/index.d.ts +2 -0
- package/dist/_pkgs/affine-shared/services/index.js +2 -0
- package/dist/_pkgs/affine-shared/services/properties-panel-service.d.ts +50 -0
- package/dist/_pkgs/affine-shared/services/properties-panel-service.js +17 -0
- package/dist/_pkgs/affine-shared/services/title-band-service.d.ts +124 -0
- package/dist/_pkgs/affine-shared/services/title-band-service.js +17 -0
- package/dist/_pkgs/data-view/property-presets/converts.d.ts +2 -2
- package/dist/_pkgs/data-view/property-presets/index.d.ts +1 -1
- package/dist/_pkgs/data-view/property-presets/number/cell-renderer.d.ts +1 -1
- package/dist/_pkgs/data-view/property-presets/number/define.d.ts +1 -1
- package/dist/_pkgs/data-view/property-presets/number/types.d.ts +2 -2
- package/dist/_pkgs/data-view/property-presets/pure-index.d.ts +2 -1
- package/dist/_pkgs/data-view/property-presets/pure-index.js +4 -0
- package/dist/_pkgs/std/extension/command-registry.d.ts +50 -1
- package/dist/_pkgs/std/extension/command-registry.js +26 -7
- package/dist/commands.js +2 -1
- package/dist/host-panels.d.ts +83 -2
- package/dist/host-panels.js +82 -1
- package/package.json +1 -1
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/file-exporter.d.ts +0 -26
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/file-exporter.js +0 -73
|
@@ -11,7 +11,65 @@ export const DOC_TITLE_PLACEHOLDER = [
|
|
|
11
11
|
'com.labre.doc-title.placeholder',
|
|
12
12
|
'Title',
|
|
13
13
|
];
|
|
14
|
+
/* ── The title band (ADR 0035 §11), `./title-band/title-band.ts` ───────── */
|
|
15
|
+
/** The band's accessible name: the group of property chips. */
|
|
16
|
+
export const TITLE_BAND_LABEL = [
|
|
17
|
+
'com.labre.title-band.label',
|
|
18
|
+
'Page properties',
|
|
19
|
+
];
|
|
20
|
+
/** What an empty chip says after the property's name (REQ-PR-1). */
|
|
21
|
+
export const TITLE_BAND_EMPTY = [
|
|
22
|
+
'com.labre.title-band.empty',
|
|
23
|
+
'Not set',
|
|
24
|
+
];
|
|
25
|
+
/** The "+" (REQ-PR-4); what it does is the host's. */
|
|
26
|
+
export const TITLE_BAND_ADD = [
|
|
27
|
+
'com.labre.title-band.add',
|
|
28
|
+
'Add a property',
|
|
29
|
+
];
|
|
30
|
+
/** The button beside the "+" that opens the host's properties panel. */
|
|
31
|
+
export const TITLE_BAND_OPEN_PANEL = [
|
|
32
|
+
'com.labre.title-band.open-panel',
|
|
33
|
+
'Open the properties panel',
|
|
34
|
+
];
|
|
35
|
+
/** Folds the chips away. */
|
|
36
|
+
export const TITLE_BAND_COLLAPSE = [
|
|
37
|
+
'com.labre.title-band.collapse',
|
|
38
|
+
'Hide properties',
|
|
39
|
+
];
|
|
40
|
+
/** The folded band's only button; `count` is the number of chips. */
|
|
41
|
+
export const TITLE_BAND_EXPAND = [
|
|
42
|
+
'com.labre.title-band.expand',
|
|
43
|
+
'Properties ({{count}})',
|
|
44
|
+
];
|
|
45
|
+
/** The accessible name of the skeleton drawn while the sheet loads. */
|
|
46
|
+
export const TITLE_BAND_LOADING = [
|
|
47
|
+
'com.labre.title-band.loading',
|
|
48
|
+
'Loading properties',
|
|
49
|
+
];
|
|
50
|
+
/** Clears a select or a date from its editor. */
|
|
51
|
+
export const TITLE_BAND_CLEAR = [
|
|
52
|
+
'com.labre.title-band.clear',
|
|
53
|
+
'Clear value',
|
|
54
|
+
];
|
|
55
|
+
/**
|
|
56
|
+
* The note header's row of child pages the document holds but does not
|
|
57
|
+
* display (ADR 0035 §9d, canvas view only).
|
|
58
|
+
*/
|
|
59
|
+
export const TITLE_BAND_NOT_SHOWN = [
|
|
60
|
+
'com.labre.title-band.not-shown',
|
|
61
|
+
'Not shown in this document',
|
|
62
|
+
];
|
|
14
63
|
/** Every wording this package declares, in the order it renders them. */
|
|
15
64
|
export const DOC_TITLE_WORDINGS = [
|
|
16
65
|
DOC_TITLE_PLACEHOLDER,
|
|
66
|
+
TITLE_BAND_ADD,
|
|
67
|
+
TITLE_BAND_CLEAR,
|
|
68
|
+
TITLE_BAND_COLLAPSE,
|
|
69
|
+
TITLE_BAND_EMPTY,
|
|
70
|
+
TITLE_BAND_EXPAND,
|
|
71
|
+
TITLE_BAND_LABEL,
|
|
72
|
+
TITLE_BAND_LOADING,
|
|
73
|
+
TITLE_BAND_NOT_SHOWN,
|
|
74
|
+
TITLE_BAND_OPEN_PANEL,
|
|
17
75
|
];
|
|
@@ -30,10 +30,12 @@ export * from './page-viewport-service.js';
|
|
|
30
30
|
export * from './parse-url-service.js';
|
|
31
31
|
export * from './pivot-materiality-publisher.js';
|
|
32
32
|
export * from './pivot-properties-service.js';
|
|
33
|
+
export * from './properties-panel-service.js';
|
|
33
34
|
export * from './quick-search-service.js';
|
|
34
35
|
export * from './selection-pane-service.js';
|
|
35
36
|
export * from './telemetry-service/index.js';
|
|
36
37
|
export * from './theme-service.js';
|
|
38
|
+
export * from './title-band-service.js';
|
|
37
39
|
export * from './toolbar-service/index.js';
|
|
38
40
|
export * from './translation-service/index.js';
|
|
39
41
|
export * from './universe-tag-defs-service.js';
|
|
@@ -30,10 +30,12 @@ export * from './page-viewport-service.js';
|
|
|
30
30
|
export * from './parse-url-service.js';
|
|
31
31
|
export * from './pivot-materiality-publisher.js';
|
|
32
32
|
export * from './pivot-properties-service.js';
|
|
33
|
+
export * from './properties-panel-service.js';
|
|
33
34
|
export * from './quick-search-service.js';
|
|
34
35
|
export * from './selection-pane-service.js';
|
|
35
36
|
export * from './telemetry-service/index.js';
|
|
36
37
|
export * from './theme-service.js';
|
|
38
|
+
export * from './title-band-service.js';
|
|
37
39
|
export * from './toolbar-service/index.js';
|
|
38
40
|
export * from './translation-service/index.js';
|
|
39
41
|
export * from './universe-tag-defs-service.js';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ExtensionType } from '../../store/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* What the properties panel is asked to show (ADR 0035 §9b): one panel with a
|
|
4
|
+
* typed request, like the artefact catalogue's `open(owner)`.
|
|
5
|
+
*
|
|
6
|
+
* - `page`: the property sheet of one document — the button beside the title
|
|
7
|
+
* band's "+" sends it, under the page title and in the note header alike.
|
|
8
|
+
* - `source`: the properties of one data source of a database, as a view
|
|
9
|
+
* shows them. Declared now so the host's `open` is written once against the
|
|
10
|
+
* whole union; the library sends it from the database view bar and the view
|
|
11
|
+
* settings when they ship (ADR 0035, issue B10), never before.
|
|
12
|
+
*
|
|
13
|
+
* The union only widens: a new scope is a new member, and an existing member
|
|
14
|
+
* never gains a required field.
|
|
15
|
+
*/
|
|
16
|
+
export type PropertiesPanelRequest = {
|
|
17
|
+
scope: 'page';
|
|
18
|
+
docId: string;
|
|
19
|
+
} | {
|
|
20
|
+
scope: 'source';
|
|
21
|
+
docId: string;
|
|
22
|
+
blockId: string;
|
|
23
|
+
sourceId: string;
|
|
24
|
+
viewId?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The properties panel (ADR 0035 §9b), shaped as every panel seam of
|
|
28
|
+
* ADR 0034 §1: two verbs, nothing else. The host draws the panel where it
|
|
29
|
+
* wants it (the Labre app, in its left sidebar); the library never mounts one
|
|
30
|
+
* and keeps no "is it open" state, so a second `open` with another request
|
|
31
|
+
* retargets the host's panel rather than toggling anything here.
|
|
32
|
+
*
|
|
33
|
+
* Absent or `null`, the title band draws no panel button: a button that opens
|
|
34
|
+
* nothing is a lie. A database's properties stay reachable through the
|
|
35
|
+
* data-view's own properties popover.
|
|
36
|
+
*/
|
|
37
|
+
export interface PropertiesPanelService {
|
|
38
|
+
/** Show the panel for `request`. */
|
|
39
|
+
open(request: PropertiesPanelRequest): void;
|
|
40
|
+
/** Put it away. Writes nothing. */
|
|
41
|
+
close(): void;
|
|
42
|
+
}
|
|
43
|
+
export declare const PropertiesPanelProvider: import("../../global/di/types.js").ServiceIdentifier<PropertiesPanelService> & (<U extends PropertiesPanelService = PropertiesPanelService>(variant: import("../../global/di/types.js").ServiceVariant) => import("../../global/di/types.js").ServiceIdentifier<U>);
|
|
44
|
+
/**
|
|
45
|
+
* Host seam: the host's properties panel, or `null` to say there is none.
|
|
46
|
+
*
|
|
47
|
+
* `di.override`, like `OutlinePanelExtension`, so a later registration always
|
|
48
|
+
* wins and registering twice never throws at boot.
|
|
49
|
+
*/
|
|
50
|
+
export declare function PropertiesPanelExtension(service: PropertiesPanelService | null): ExtensionType;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createIdentifier } from '../../global/di/index.js';
|
|
2
|
+
export const PropertiesPanelProvider = createIdentifier('LabrePropertiesPanel');
|
|
3
|
+
/**
|
|
4
|
+
* Host seam: the host's properties panel, or `null` to say there is none.
|
|
5
|
+
*
|
|
6
|
+
* `di.override`, like `OutlinePanelExtension`, so a later registration always
|
|
7
|
+
* wins and registering twice never throws at boot.
|
|
8
|
+
*/
|
|
9
|
+
export function PropertiesPanelExtension(service) {
|
|
10
|
+
return {
|
|
11
|
+
setup: di => {
|
|
12
|
+
// `null` rides through the factory on purpose: `getOptional` then
|
|
13
|
+
// reports the panel as absent, which is the whole "no button" story.
|
|
14
|
+
di.override(PropertiesPanelProvider, () => service);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { ExtensionType } from '../../store/index.js';
|
|
2
|
+
import type { ReadonlySignal } from '@preact/signals-core';
|
|
3
|
+
/**
|
|
4
|
+
* `TitleBandProvider` — the one seam that feeds the band of property chips
|
|
5
|
+
* under the page title and at the head of the page's note on the canvas
|
|
6
|
+
* (ADR 0035 §9d and §11, REQ-PR-1 and PR-7).
|
|
7
|
+
*
|
|
8
|
+
* **No value lives in the document.** A page's property values are the
|
|
9
|
+
* host's (the Labre app keeps them in SQL, labre ADR-0047); the library reads
|
|
10
|
+
* them here, draws them, and hands every edit back through `set`. It never
|
|
11
|
+
* learns where they live, never caches them and never applies a value itself:
|
|
12
|
+
* the host's store does, and owns the rollback.
|
|
13
|
+
*
|
|
14
|
+
* Not `PivotPropertiesProvider` (ADR 0006): that seam is keyed by an element's
|
|
15
|
+
* `pivotDocId`, read-only, with its own value union; this one is keyed by a
|
|
16
|
+
* document, written, and speaks the data-view property types, so a chip and a
|
|
17
|
+
* database cell read the same `type`, `data` and value.
|
|
18
|
+
*
|
|
19
|
+
* Absent, there is no band at all: no chips, no "+", no panel button, no "Not
|
|
20
|
+
* shown in this document" row, and nothing else changes.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* One visible property of a page's sheet, in the order the band draws it.
|
|
24
|
+
*
|
|
25
|
+
* `type` and `data` are a data-view property type and its config (`select`
|
|
26
|
+
* with `{ options }`, `number` with `{ format }`, …); `value` is the JSON a
|
|
27
|
+
* data-view cell of that type holds (`select`: an option id, `multi-select`:
|
|
28
|
+
* option ids, `date`: epoch milliseconds, `checkbox`: a boolean, text types: a
|
|
29
|
+
* string). `null` or `undefined` is an empty value, drawn as an empty chip
|
|
30
|
+
* that can still be clicked (REQ-PR-1).
|
|
31
|
+
*
|
|
32
|
+
* Visibility is resolved by the host: what is in the list is visible, in that
|
|
33
|
+
* order, including a visible property with no value.
|
|
34
|
+
*/
|
|
35
|
+
export interface TitleBandProperty {
|
|
36
|
+
/** Stable, host-defined id; what `set` receives back. */
|
|
37
|
+
id: string;
|
|
38
|
+
/** Whose definition this is: the workspace's, or the database's of a row. */
|
|
39
|
+
namespace: 'workspace' | 'database';
|
|
40
|
+
/** Display name, already localized by the host. */
|
|
41
|
+
name: string;
|
|
42
|
+
/** A data-view property type (`text`, `number`, `select`, …). */
|
|
43
|
+
type: string;
|
|
44
|
+
/** That type's config, as a data-view property holds it. */
|
|
45
|
+
data: Record<string, unknown>;
|
|
46
|
+
/** The JSON a data-view cell of that type holds; nullish is empty. */
|
|
47
|
+
value: unknown;
|
|
48
|
+
/** A read-only property draws its chip and opens no editor. */
|
|
49
|
+
readonly: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The state of one page's sheet. Same four states as ADR 0006: the signal may
|
|
53
|
+
* start at `loading` and settle later, and the library never awaits it.
|
|
54
|
+
*/
|
|
55
|
+
export type TitleBandSheetState = {
|
|
56
|
+
status: 'loading';
|
|
57
|
+
} | {
|
|
58
|
+
status: 'ready';
|
|
59
|
+
properties: readonly TitleBandProperty[];
|
|
60
|
+
}
|
|
61
|
+
/** The page has no sheet this viewer may read. The band draws nothing. */
|
|
62
|
+
| {
|
|
63
|
+
status: 'missing';
|
|
64
|
+
} | {
|
|
65
|
+
status: 'error';
|
|
66
|
+
reason?: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A child page this document holds but does not display (labre ADR-0045):
|
|
70
|
+
* the host decides what belongs here, the library never computes a parent or
|
|
71
|
+
* a child.
|
|
72
|
+
*/
|
|
73
|
+
export interface TitleBandNotShownPage {
|
|
74
|
+
docId: string;
|
|
75
|
+
/** The page's title; an empty one is drawn as "Untitled". */
|
|
76
|
+
title: string;
|
|
77
|
+
}
|
|
78
|
+
export interface TitleBandService {
|
|
79
|
+
/**
|
|
80
|
+
* The sheet of document `docId`. MUST return synchronously and MUST NOT
|
|
81
|
+
* throw; the same signal for the same document is the host's business (the
|
|
82
|
+
* band asks once per mounted document).
|
|
83
|
+
*/
|
|
84
|
+
sheet$(docId: string): ReadonlySignal<TitleBandSheetState>;
|
|
85
|
+
/**
|
|
86
|
+
* Write one value. The band shows the chip as pending until the promise
|
|
87
|
+
* settles and never applies the value itself: the new value arrives through
|
|
88
|
+
* `sheet$`. A rejection is the host's to report and roll back; the band only
|
|
89
|
+
* clears its pending state. `value` is `null` to clear.
|
|
90
|
+
*/
|
|
91
|
+
set(docId: string, propertyId: string, value: unknown): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* The band's "+" (REQ-PR-4): what it does is the host's (open the
|
|
94
|
+
* workspace's property settings, or create a database property directly
|
|
95
|
+
* on a row). Absent, there is no "+".
|
|
96
|
+
*/
|
|
97
|
+
add?(docId: string): void;
|
|
98
|
+
/**
|
|
99
|
+
* Whether the band is collapsed for this document. The host decides where
|
|
100
|
+
* that is remembered (the Labre app: per device, REQ-PR-6). Absent, the
|
|
101
|
+
* band opens expanded every time and a collapse lasts while it is mounted.
|
|
102
|
+
*/
|
|
103
|
+
collapsed$?(docId: string): ReadonlySignal<boolean>;
|
|
104
|
+
setCollapsed?(docId: string, collapsed: boolean): void;
|
|
105
|
+
/**
|
|
106
|
+
* The child pages this document holds but does not display. Read **in the
|
|
107
|
+
* canvas view only**, drawn in the note header as a "Not shown in this
|
|
108
|
+
* document" row of page links that open through the linked-document path
|
|
109
|
+
* (`RefNodeSlotsProvider.docLinkClicked`). In the page view the host draws
|
|
110
|
+
* that row under the title itself, so a document never shows two. Absent
|
|
111
|
+
* or empty, no row.
|
|
112
|
+
*/
|
|
113
|
+
notShown$?(docId: string): ReadonlySignal<readonly TitleBandNotShownPage[]>;
|
|
114
|
+
}
|
|
115
|
+
export declare const TitleBandProvider: import("../../global/di/types.js").ServiceIdentifier<TitleBandService> & (<U extends TitleBandService = TitleBandService>(variant: import("../../global/di/types.js").ServiceVariant) => import("../../global/di/types.js").ServiceIdentifier<U>);
|
|
116
|
+
/**
|
|
117
|
+
* Host seam: the service that feeds the title band. **No default is
|
|
118
|
+
* registered**: absence is a meaningful state (the playground without a mock,
|
|
119
|
+
* a host with no properties), and the band then draws nothing.
|
|
120
|
+
*
|
|
121
|
+
* `di.override`, so a later registration always wins and registering twice
|
|
122
|
+
* never throws at boot.
|
|
123
|
+
*/
|
|
124
|
+
export declare function TitleBandExtension(service: TitleBandService): ExtensionType;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createIdentifier } from '../../global/di/index.js';
|
|
2
|
+
export const TitleBandProvider = createIdentifier('LabreTitleBand');
|
|
3
|
+
/**
|
|
4
|
+
* Host seam: the service that feeds the title band. **No default is
|
|
5
|
+
* registered**: absence is a meaningful state (the playground without a mock,
|
|
6
|
+
* a host with no properties), and the band then draws nothing.
|
|
7
|
+
*
|
|
8
|
+
* `di.override`, so a later registration always wins and registering twice
|
|
9
|
+
* never throws at boot.
|
|
10
|
+
*/
|
|
11
|
+
export function TitleBandExtension(service) {
|
|
12
|
+
return {
|
|
13
|
+
setup: di => {
|
|
14
|
+
di.override(TitleBandProvider, () => service);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -18,14 +18,14 @@ export declare const presetPropertyConverts: ({
|
|
|
18
18
|
from: any;
|
|
19
19
|
to: any;
|
|
20
20
|
convert: import("../index.js").ConvertFunction<import("../index.js").PropertyModel<"number", {
|
|
21
|
-
format: "number" | "
|
|
21
|
+
format: "number" | "percent" | "numberWithCommas" | "currencyINR" | "currencyYen" | "currencyCNY" | "currencyUSD" | "currencyEUR" | "currencyGBP";
|
|
22
22
|
decimal?: number | undefined;
|
|
23
23
|
}, number | null, number | null>, import("../index.js").PropertyModel<"progress", {}, number, number>>;
|
|
24
24
|
} | {
|
|
25
25
|
from: any;
|
|
26
26
|
to: any;
|
|
27
27
|
convert: import("../index.js").ConvertFunction<import("../index.js").PropertyModel<"progress", {}, number, number>, import("../index.js").PropertyModel<"number", {
|
|
28
|
-
format: "number" | "
|
|
28
|
+
format: "number" | "percent" | "numberWithCommas" | "currencyINR" | "currencyYen" | "currencyCNY" | "currencyUSD" | "currencyEUR" | "currencyGBP";
|
|
29
29
|
decimal?: number | undefined;
|
|
30
30
|
}, number | null, number | null>>;
|
|
31
31
|
} | {
|
|
@@ -13,7 +13,7 @@ export declare const propertyPresets: {
|
|
|
13
13
|
}[];
|
|
14
14
|
}, string[], string[]>;
|
|
15
15
|
numberPropertyConfig: import("../index.js").PropertyMetaConfig<"number", {
|
|
16
|
-
format: "number" | "
|
|
16
|
+
format: "number" | "percent" | "numberWithCommas" | "currencyINR" | "currencyYen" | "currencyCNY" | "currencyUSD" | "currencyEUR" | "currencyGBP";
|
|
17
17
|
decimal?: number | undefined;
|
|
18
18
|
}, number | null, number | null>;
|
|
19
19
|
progressPropertyConfig: import("../index.js").PropertyMetaConfig<"progress", {}, number, number>;
|
|
@@ -13,6 +13,6 @@ export declare class NumberCell extends BaseCellRenderer<number, number, NumberP
|
|
|
13
13
|
render(): import("lit-html").TemplateResult<1>;
|
|
14
14
|
}
|
|
15
15
|
export declare const numberPropertyConfig: import("../../index.js").PropertyMetaConfig<"number", {
|
|
16
|
-
format: "number" | "
|
|
16
|
+
format: "number" | "percent" | "numberWithCommas" | "currencyINR" | "currencyYen" | "currencyCNY" | "currencyUSD" | "currencyEUR" | "currencyGBP";
|
|
17
17
|
decimal?: number | undefined;
|
|
18
18
|
}, number | null, number | null>;
|
|
@@ -3,6 +3,6 @@ export declare const numberPropertyType: {
|
|
|
3
3
|
modelConfig: <PropertyData extends Record<string, unknown> = Record<string, never>, RawValue = unknown, JsonValue = unknown>(ops: import("../../index.js").PropertyConfig<PropertyData, RawValue, JsonValue>) => import("../../index.js").PropertyModel<"number", PropertyData, RawValue, JsonValue>;
|
|
4
4
|
};
|
|
5
5
|
export declare const numberPropertyModelConfig: import("../../index.js").PropertyModel<"number", {
|
|
6
|
-
format: "number" | "
|
|
6
|
+
format: "number" | "percent" | "numberWithCommas" | "currencyINR" | "currencyYen" | "currencyCNY" | "currencyUSD" | "currencyEUR" | "currencyGBP";
|
|
7
7
|
decimal?: number | undefined;
|
|
8
8
|
}, number | null, number | null>;
|
|
@@ -3,10 +3,10 @@ export declare const NumberPropertySchema: zod.ZodObject<{
|
|
|
3
3
|
decimal: zod.ZodOptional<zod.ZodNumber>;
|
|
4
4
|
format: zod.ZodEnum<["number", "numberWithCommas", "percent", "currencyYen", "currencyINR", "currencyCNY", "currencyUSD", "currencyEUR", "currencyGBP"]>;
|
|
5
5
|
}, "strip", zod.ZodTypeAny, {
|
|
6
|
-
format: "number" | "
|
|
6
|
+
format: "number" | "percent" | "numberWithCommas" | "currencyINR" | "currencyYen" | "currencyCNY" | "currencyUSD" | "currencyEUR" | "currencyGBP";
|
|
7
7
|
decimal?: number | undefined;
|
|
8
8
|
}, {
|
|
9
|
-
format: "number" | "
|
|
9
|
+
format: "number" | "percent" | "numberWithCommas" | "currencyINR" | "currencyYen" | "currencyCNY" | "currencyUSD" | "currencyEUR" | "currencyGBP";
|
|
10
10
|
decimal?: number | undefined;
|
|
11
11
|
}>;
|
|
12
12
|
export type NumberPropertyDataType = zod.infer<typeof NumberPropertySchema>;
|
|
@@ -10,7 +10,7 @@ export declare const propertyModelPresets: {
|
|
|
10
10
|
}[];
|
|
11
11
|
}, string[], string[]>;
|
|
12
12
|
numberPropertyModelConfig: import("../index.js").PropertyModel<"number", {
|
|
13
|
-
format: "number" | "
|
|
13
|
+
format: "number" | "percent" | "numberWithCommas" | "currencyINR" | "currencyYen" | "currencyCNY" | "currencyUSD" | "currencyEUR" | "currencyGBP";
|
|
14
14
|
decimal?: number | undefined;
|
|
15
15
|
}, number | null, number | null>;
|
|
16
16
|
progressPropertyModelConfig: import("../index.js").PropertyModel<"progress", {}, number, number>;
|
|
@@ -23,3 +23,4 @@ export declare const propertyModelPresets: {
|
|
|
23
23
|
}, string | null, string | null>;
|
|
24
24
|
textPropertyModelConfig: import("../index.js").PropertyModel<"text", {}, string, string>;
|
|
25
25
|
};
|
|
26
|
+
export { formatNumber, type NumberFormat, NumberFormatSchema, } from './number/utils/formatter.js';
|
|
@@ -16,3 +16,7 @@ export const propertyModelPresets = {
|
|
|
16
16
|
selectPropertyModelConfig,
|
|
17
17
|
textPropertyModelConfig,
|
|
18
18
|
};
|
|
19
|
+
// The number preset's formats and formatter, so the title band's own copy of
|
|
20
|
+
// the table (`fragments/doc-title/src/title-band/format.ts`) can be held to
|
|
21
|
+
// it by a parity spec (`title-band-number-parity.unit.spec.ts`).
|
|
22
|
+
export { formatNumber, NumberFormatSchema, } from './number/utils/formatter.js';
|
|
@@ -57,8 +57,16 @@ export type Availability = 'always' | 'selection' | 'selection:framework' | 'edi
|
|
|
57
57
|
* command, so the behaviour, the availability rule and the single telemetry
|
|
58
58
|
* emission stay in one place, and `CommandInvocation.surface` reports where the
|
|
59
59
|
* user actually clicked instead of borrowing another surface's name.
|
|
60
|
+
*
|
|
61
|
+
* `'view-menu'` joined with the view actions (ADR 0034, amendment of
|
|
62
|
+
* 2026-10-13): what is proper to the view the editor shows — the canvas grid,
|
|
63
|
+
* its PNG and PDF export, the presentation — listed for a HOST menu (Labre's
|
|
64
|
+
* "This view" section of its header ⋯). The library draws no such menu; the
|
|
65
|
+
* host reads the projection `getViewActions` (`@labre/affine/host-panels`)
|
|
66
|
+
* and runs an entry through `runCommand`, so the behaviour and the one
|
|
67
|
+
* telemetry emission stay in the command.
|
|
60
68
|
*/
|
|
61
|
-
export type CommandSurface = 'senior-menu' | 'catalogue' | 'palette' | 'contextual-toolbar' | 'agent';
|
|
69
|
+
export type CommandSurface = 'senior-menu' | 'catalogue' | 'palette' | 'contextual-toolbar' | 'agent' | 'view-menu';
|
|
62
70
|
export type CommandKind = 'artefact' | 'tool' | 'toggle' | 'legend' | 'action';
|
|
63
71
|
/** Where the invocation came from — feeds `segment` / `module` / `control`. */
|
|
64
72
|
export interface CommandInvocation {
|
|
@@ -130,6 +138,15 @@ export interface CommandDescriptor<P = void> {
|
|
|
130
138
|
* only narrowing. Not projected into either manifest.
|
|
131
139
|
*/
|
|
132
140
|
when?: (std: BlockStdScope) => boolean;
|
|
141
|
+
/**
|
|
142
|
+
* A toggle's current state, for a surface that draws a check mark (the
|
|
143
|
+
* host's view menu reads it through `getViewActions`). Absent = not a
|
|
144
|
+
* toggle. It may read signals: a caller that reads it inside an `effect`
|
|
145
|
+
* or a `computed` follows the state, whoever changes it. Not projected into
|
|
146
|
+
* either manifest — a state is a fact of the open editor, not of the
|
|
147
|
+
* catalogue.
|
|
148
|
+
*/
|
|
149
|
+
checked?: (std: BlockStdScope) => boolean;
|
|
133
150
|
/** THE new capability: invocable without a keyboard event. */
|
|
134
151
|
run: (std: BlockStdScope, invocation: CommandInvocation, params?: P) => void | Promise<void>;
|
|
135
152
|
/** Agent-facing parameter contract. */
|
|
@@ -472,6 +489,26 @@ export declare const isEditingOnCanvas: (std: BlockStdScope) => boolean;
|
|
|
472
489
|
* in `when`. See ADR 0008 § Availability.
|
|
473
490
|
*/
|
|
474
491
|
export declare function isCommandAvailable(std: BlockStdScope, command: AnyCommandDescriptor): boolean;
|
|
492
|
+
/**
|
|
493
|
+
* A file a command hands back to its caller instead of downloading it — the
|
|
494
|
+
* PNG and PDF exports of the canvas. The library renders, the host decides
|
|
495
|
+
* where the bytes go (a download, a share sheet, an upload).
|
|
496
|
+
*/
|
|
497
|
+
export interface CommandFile {
|
|
498
|
+
blob: Blob;
|
|
499
|
+
/** Sanitised, extension included: `Order to cash.png`. */
|
|
500
|
+
filename: string;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* The params of a command that produces a {@link CommandFile}. Given
|
|
504
|
+
* `deliver`, the command hands the file to it and downloads nothing; without
|
|
505
|
+
* it (the palette, a bound chord) the command downloads the file itself. Not
|
|
506
|
+
* declared as a zod `params`: a callback crosses no serializable seam, and an
|
|
507
|
+
* agent gets the download.
|
|
508
|
+
*/
|
|
509
|
+
export interface CommandFileParams {
|
|
510
|
+
deliver?: (file: CommandFile) => void;
|
|
511
|
+
}
|
|
475
512
|
/**
|
|
476
513
|
* THE bottleneck: the one place a command runs, and therefore the one place
|
|
477
514
|
* its telemetry is emitted and its usage measured. Every surface (sub-menu,
|
|
@@ -479,6 +516,18 @@ export declare function isCommandAvailable(std: BlockStdScope, command: AnyComma
|
|
|
479
516
|
* the per-menu `track()` duplicates.
|
|
480
517
|
*/
|
|
481
518
|
export declare function runCommand(std: BlockStdScope, command: AnyCommandDescriptor, invocation: CommandInvocation, params?: unknown): void;
|
|
519
|
+
/**
|
|
520
|
+
* {@link runCommand} for a caller that waits: the same bottleneck (usage and
|
|
521
|
+
* telemetry recorded once, synchronously, as there), but the returned promise
|
|
522
|
+
* settles when the command's own work does and REJECTS when it fails, where
|
|
523
|
+
* `runCommand` only logs. For a gesture that shows progress — a menu entry
|
|
524
|
+
* that spins while the canvas export renders, then reports a failure.
|
|
525
|
+
*
|
|
526
|
+
* A separate function rather than a return value on `runCommand`: a promise
|
|
527
|
+
* returned there would read as a floating promise at every existing call site
|
|
528
|
+
* of every host.
|
|
529
|
+
*/
|
|
530
|
+
export declare function runCommandAsync(std: BlockStdScope, command: AnyCommandDescriptor, invocation: CommandInvocation, params?: unknown): Promise<void>;
|
|
482
531
|
/**
|
|
483
532
|
* One of the three permanent projections out of {@link CommandDescriptor} —
|
|
484
533
|
* NOT a migration shim. It is TOTAL: keyless commands yield a descriptor with
|
|
@@ -82,6 +82,17 @@ export function isCommandAvailable(std, command) {
|
|
|
82
82
|
return !std.store.readonly;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
/** Shared by the two entry points below: run, then measure, then report. */
|
|
86
|
+
function invokeCommand(std, command, invocation, params) {
|
|
87
|
+
const result = command.run(std, invocation, params);
|
|
88
|
+
// Before the telemetry gate on purpose: usage is measured for EVERY command,
|
|
89
|
+
// including the ones with no `telemetry` field and the self-emitting ones.
|
|
90
|
+
std.getOptional(CommandUsageIdentifier)?.record(command, invocation);
|
|
91
|
+
if (command.telemetry) {
|
|
92
|
+
std.getOptional(CommandTelemetryIdentifier)?.({ std, command, invocation });
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
85
96
|
/**
|
|
86
97
|
* THE bottleneck: the one place a command runs, and therefore the one place
|
|
87
98
|
* its telemetry is emitted and its usage measured. Every surface (sub-menu,
|
|
@@ -89,15 +100,23 @@ export function isCommandAvailable(std, command) {
|
|
|
89
100
|
* the per-menu `track()` duplicates.
|
|
90
101
|
*/
|
|
91
102
|
export function runCommand(std, command, invocation, params) {
|
|
92
|
-
const result =
|
|
103
|
+
const result = invokeCommand(std, command, invocation, params);
|
|
93
104
|
if (result instanceof Promise)
|
|
94
105
|
result.catch(console.error);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* {@link runCommand} for a caller that waits: the same bottleneck (usage and
|
|
109
|
+
* telemetry recorded once, synchronously, as there), but the returned promise
|
|
110
|
+
* settles when the command's own work does and REJECTS when it fails, where
|
|
111
|
+
* `runCommand` only logs. For a gesture that shows progress — a menu entry
|
|
112
|
+
* that spins while the canvas export renders, then reports a failure.
|
|
113
|
+
*
|
|
114
|
+
* A separate function rather than a return value on `runCommand`: a promise
|
|
115
|
+
* returned there would read as a floating promise at every existing call site
|
|
116
|
+
* of every host.
|
|
117
|
+
*/
|
|
118
|
+
export async function runCommandAsync(std, command, invocation, params) {
|
|
119
|
+
await invokeCommand(std, command, invocation, params);
|
|
101
120
|
}
|
|
102
121
|
/**
|
|
103
122
|
* One of the three permanent projections out of {@link CommandDescriptor} —
|
package/dist/commands.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { frameCommands } from './_pkgs/affine-block-frame/index.js';
|
|
2
2
|
import { copyLinkCommands, coreCommands, pivotCommands, readingCommands, tagCommands, } from './_pkgs/affine-block-root/index.js';
|
|
3
|
-
import { auditCommands, canvasGridCommands, exportSvgCommands, mapQualityCommands, selectionPaneCommands, userLayerCommands, } from './_pkgs/affine-block-surface/index.js';
|
|
3
|
+
import { auditCommands, canvasExportCommands, canvasGridCommands, exportSvgCommands, mapQualityCommands, selectionPaneCommands, userLayerCommands, } from './_pkgs/affine-block-surface/index.js';
|
|
4
4
|
import { edgeDirectionCommands } from './_pkgs/affine-gfx-connector/index.js';
|
|
5
5
|
import { shapeCommands } from './_pkgs/affine-gfx-shape/index.js';
|
|
6
6
|
import { toCommandManifestEntry, } from './_pkgs/std/index.js';
|
|
@@ -58,6 +58,7 @@ export function getCommands(flags) {
|
|
|
58
58
|
...selectionPaneCommands,
|
|
59
59
|
...frameCommands,
|
|
60
60
|
...canvasGridCommands,
|
|
61
|
+
...canvasExportCommands,
|
|
61
62
|
...userLayerCommands,
|
|
62
63
|
...edgeDirectionCommands,
|
|
63
64
|
...(isCapabilityEnabled(flags, 'ai-audit') ? auditCommands : []),
|
package/dist/host-panels.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FramePreview } from './_pkgs/affine-fragment-frame-panel/index.js';
|
|
2
2
|
import type { FrameBlockModel } from './_pkgs/affine-model/index.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type BlockStdScope, type CommandFile } from './_pkgs/std/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* `@labre/affine/host-panels` — the verbs a host's own panel calls (ADR 0034
|
|
6
6
|
* §4, docs/integrate/08-host-panels.md).
|
|
@@ -40,14 +40,23 @@ import type { BlockStdScope } from './_pkgs/std/index.js';
|
|
|
40
40
|
* cannot find here is a gap in this module, not a reason to import a widget
|
|
41
41
|
* package.
|
|
42
42
|
*
|
|
43
|
+
* **The view actions** (amendment of 2026-10-13) are the same idea for a
|
|
44
|
+
* host's MENU rather than its panel: `getViewActions` projects the commands
|
|
45
|
+
* on the `'view-menu'` surface — the grid, the PNG and PDF export, Present —
|
|
46
|
+
* into rows of data (label, icon key, check, disabled), and `runViewAction`
|
|
47
|
+
* runs one and hands back the file an export produced. The host draws the
|
|
48
|
+
* rows (Labre's header ⋯, section "This view"); nothing here renders.
|
|
49
|
+
*
|
|
43
50
|
* ponytail: `frameList` is a plain read, not a signal of the frame list; a
|
|
44
51
|
* host follows reorders through `std.store.slots.blockUpdated` (08 says how).
|
|
45
52
|
* A signal of the frame list is the upgrade path if two hosts ask.
|
|
46
53
|
*/
|
|
47
|
-
export { type AnyCommandDescriptor, type CommandInvocation, type CommandOwner, type CommandSurface, getCommandIcon, getCommandsForSurface, getRegisteredCommands, runCommand, } from './_pkgs/std/index.js';
|
|
54
|
+
export { type AnyCommandDescriptor, type CommandFile, type CommandInvocation, type CommandOwner, type CommandSurface, getCommandIcon, getCommandsForSurface, getRegisteredCommands, runCommand, runCommandAsync, } from './_pkgs/std/index.js';
|
|
48
55
|
export { armArtefact } from './_pkgs/affine-widget-edgeless-toolbar/index.js';
|
|
49
56
|
export { type SelectionPaneNode, selectionPaneTree, } from './_pkgs/affine-block-surface/index.js';
|
|
50
57
|
export { frameCommands, type ReorderFramesParams, reorderFramesParams, } from './_pkgs/affine-block-frame/index.js';
|
|
58
|
+
export { formatPropertyValue, isPropertyValueEmpty, } from './_pkgs/affine-fragment-doc-title/index.js';
|
|
59
|
+
export type { PropertiesPanelRequest, PropertiesPanelService, TitleBandNotShownPage, TitleBandProperty, TitleBandService, TitleBandSheetState, } from './_pkgs/affine-shared/services/index.js';
|
|
51
60
|
/**
|
|
52
61
|
* The document's frames in presentation order, first slide first — the order
|
|
53
62
|
* `canvas.frame.reorder` writes and the presentation walks. Works in page mode
|
|
@@ -88,3 +97,75 @@ export declare function createFramePreview(std: BlockStdScope, frame: FrameBlock
|
|
|
88
97
|
height?: number;
|
|
89
98
|
fillScreen?: boolean;
|
|
90
99
|
}): FramePreview;
|
|
100
|
+
/**
|
|
101
|
+
* One entry of the current view's own actions — what a host draws in the
|
|
102
|
+
* "This view" section of its menu (ADR 0034, amendment of 2026-10-13). Data
|
|
103
|
+
* only: the host owns the menu, the row, the spinner and the toast; the
|
|
104
|
+
* library owns what the entry does.
|
|
105
|
+
*/
|
|
106
|
+
export interface ViewAction {
|
|
107
|
+
/**
|
|
108
|
+
* The command id, stable across versions (`canvas.grid.toggle`): the key a
|
|
109
|
+
* host maps its own icon, test id or placement to, and what it passes back
|
|
110
|
+
* to {@link runViewAction}.
|
|
111
|
+
*/
|
|
112
|
+
id: string;
|
|
113
|
+
/**
|
|
114
|
+
* The group the entry belongs to, from the command's `category`:
|
|
115
|
+
* `'display'` (the grid), `'export'` (PNG, PDF), `'present'`. A host draws
|
|
116
|
+
* a separator between groups, or places a group elsewhere (Labre keeps
|
|
117
|
+
* "Present" in its header). Open: a later minor may add a group.
|
|
118
|
+
*/
|
|
119
|
+
section: string;
|
|
120
|
+
/** Resolved through the host's `TranslationExtension`, else English. */
|
|
121
|
+
label: string;
|
|
122
|
+
/** The `com.labre.*` key behind {@link label}, for a host that translates itself. */
|
|
123
|
+
labelKey: string;
|
|
124
|
+
/** Stable asset key; `getCommandIcon(std, iconKey)` is the library's icon. */
|
|
125
|
+
iconKey?: string;
|
|
126
|
+
/** Present only on a toggle: the state a check mark shows. */
|
|
127
|
+
checked?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Listed but refused now (a write on a read-only document): draw it
|
|
130
|
+
* disabled. An entry that does not apply at all is not listed.
|
|
131
|
+
*/
|
|
132
|
+
disabled: boolean;
|
|
133
|
+
}
|
|
134
|
+
/** What {@link runViewAction} hands back. */
|
|
135
|
+
export interface ViewActionResult {
|
|
136
|
+
/**
|
|
137
|
+
* The file an export produced — the host downloads it, shares it, uploads
|
|
138
|
+
* it. Absent for an action that makes none, and for an export that found
|
|
139
|
+
* nothing to draw.
|
|
140
|
+
*/
|
|
141
|
+
file?: CommandFile;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The actions proper to the view the editor shows now, in their declared
|
|
145
|
+
* order: the commands registered on the `'view-menu'` surface whose `scope`
|
|
146
|
+
* is this mode (or `'global'`) and whose `when` holds.
|
|
147
|
+
*
|
|
148
|
+
* `mode` is the view the host shows; omitted, it is read from
|
|
149
|
+
* `DocModeProvider`, and a provider that does not know (the library default
|
|
150
|
+
* answers `null`) leaves the choice to registration — the canvas commands are
|
|
151
|
+
* registered on the edgeless scope only. Flags apply by construction: a
|
|
152
|
+
* `frame: false` assembly registers no "Present", so it is not listed.
|
|
153
|
+
*
|
|
154
|
+
* Reactive when read inside an `effect` or a `computed`: `checked`, `when`
|
|
155
|
+
* and the read-only refusal read signals, so the list follows the grid, a
|
|
156
|
+
* toggle, a peer's save or a document turning read-only. Read it again after a
|
|
157
|
+
* mode switch: the `std` is rebuilt.
|
|
158
|
+
*/
|
|
159
|
+
export declare function getViewActions(std: BlockStdScope, mode?: 'page' | 'edgeless'): ViewAction[];
|
|
160
|
+
/**
|
|
161
|
+
* Run one entry of {@link getViewActions} by its id, through `runCommand`'s
|
|
162
|
+
* bottleneck (usage and telemetry recorded once), and wait for it.
|
|
163
|
+
*
|
|
164
|
+
* Resolves when the action is done — after the export has rendered — with the
|
|
165
|
+
* file it produced, if any: the library renders, the host decides where the
|
|
166
|
+
* bytes go, and nothing is downloaded behind its back. Rejects when the action
|
|
167
|
+
* fails, so the host can say so. An id that is not a view action here, an
|
|
168
|
+
* entry that no longer applies or a refused one runs nothing and resolves
|
|
169
|
+
* with no file.
|
|
170
|
+
*/
|
|
171
|
+
export declare function runViewAction(std: BlockStdScope, id: string): Promise<ViewActionResult>;
|