@lvl99dotcom/edaha-editor 0.2.0 → 0.4.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/README.md +8 -1
- package/dist/client/assets/index--k7n6Qb8.css +1 -0
- package/dist/client/assets/{index-n5aM_lw1.js → index-owkKXGfS.js} +149 -130
- package/dist/client/index.html +2 -2
- package/dist/client-lib/index.js +4037 -0
- package/dist/client-lib/style.css +1569 -0
- package/dist/editor/index.d.ts +24 -1
- package/dist/editor/index.js +15 -1
- package/dist/server/app/index.js +2 -1
- package/dist/server/store/index.d.ts +2 -1
- package/dist/server/store/index.js +5 -3
- package/dist/server/types/index.d.ts +2 -0
- package/dist/types/client/components/define/index.d.ts +7 -0
- package/dist/types/client/components/edaha-article/index.d.ts +380 -0
- package/dist/types/client/components/edaha-article-browser/index.d.ts +162 -0
- package/dist/types/client/components/edaha-article-data-field/index.d.ts +121 -0
- package/dist/types/client/components/edaha-article-data-group/index.d.ts +40 -0
- package/dist/types/client/components/edaha-editor/index.d.ts +289 -0
- package/dist/types/client/components/edaha-embed-dialog/index.d.ts +84 -0
- package/dist/types/client/components/edaha-file-browser/index.d.ts +203 -0
- package/dist/types/client/components/edaha-markdown/index.d.ts +70 -0
- package/dist/types/client/components/edaha-metadata-field/index.d.ts +100 -0
- package/dist/types/client/components/edaha-richtext/index.d.ts +88 -0
- package/dist/types/client/components/edaha-toasts/index.d.ts +47 -0
- package/dist/types/client/dates/index.d.ts +14 -0
- package/dist/types/client/editorApi/index.d.ts +129 -0
- package/dist/types/client/embeds/index.d.ts +74 -0
- package/dist/types/client/icons/index.d.ts +60 -0
- package/dist/types/client/index.d.ts +2 -0
- package/dist/types/client/markdown/index.d.ts +163 -0
- package/dist/types/client/metadataForm/index.d.ts +77 -0
- package/dist/types/client/narrow/index.d.ts +21 -0
- package/dist/types/client/richtext/editor/index.d.ts +34 -0
- package/dist/types/client/richtext/extensions/index.d.ts +90 -0
- package/dist/types/client/sortTable/index.d.ts +24 -0
- package/dist/types/client/theme/index.d.ts +48 -0
- package/dist/types/server/types/index.d.ts +251 -0
- package/package.json +15 -10
- package/dist/client/assets/index-KKuFTVH2.css +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import type { EmbedInfo } from "../../../server/types/index.ts";
|
|
3
|
+
import { type EmbedValidator, type EmbedValue } from "../../embeds/index.ts";
|
|
4
|
+
import "../edaha-metadata-field/index.ts";
|
|
5
|
+
/** What the content's hint says when the embed doesn't say what its content is */
|
|
6
|
+
export declare const DEFAULT_EMBED_INFO = "Provide the embed's content, e.g. a URL or code";
|
|
7
|
+
/**
|
|
8
|
+
* The embed dialog: asks for the content of an embed of one kind (e.g. a YouTube video's URL, or a diagram's code),
|
|
9
|
+
* showing what the kind embeds, with its options' fields (if it has options) above the content. Its kind can't be
|
|
10
|
+
* changed here: each kind has its own toolbar button. Option fields show their defaults and show or hide by their
|
|
11
|
+
* conditions; the embed is saved with every shown option's value. With a validator, the content and options are
|
|
12
|
+
* checked before they are saved, and any problems are shown under them. Rendered in the light DOM.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* html`<edaha-embed-dialog></edaha-embed-dialog>`
|
|
16
|
+
* const value = await dialog.edit(youtube, { key: "youtube", content: "", options: {} }, true);
|
|
17
|
+
*/
|
|
18
|
+
export declare class EdahaEmbedDialog extends LitElement {
|
|
19
|
+
static properties: {
|
|
20
|
+
embed: {
|
|
21
|
+
state: boolean;
|
|
22
|
+
};
|
|
23
|
+
content: {
|
|
24
|
+
state: boolean;
|
|
25
|
+
};
|
|
26
|
+
options: {
|
|
27
|
+
state: boolean;
|
|
28
|
+
};
|
|
29
|
+
changing: {
|
|
30
|
+
state: boolean;
|
|
31
|
+
};
|
|
32
|
+
errors: {
|
|
33
|
+
state: boolean;
|
|
34
|
+
};
|
|
35
|
+
checking: {
|
|
36
|
+
state: boolean;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/** The kind of embed whose content is asked for */
|
|
40
|
+
embed: EmbedInfo | undefined;
|
|
41
|
+
/** The embed's content */
|
|
42
|
+
content: string;
|
|
43
|
+
/** The embed's options as set (hidden options' values are kept until it is saved, and defaults aren't filled in) */
|
|
44
|
+
options: Record<string, unknown>;
|
|
45
|
+
/** Whether an existing embed is being changed (rather than a new one added) */
|
|
46
|
+
changing: boolean;
|
|
47
|
+
/** Why the content isn't valid, from the last check */
|
|
48
|
+
errors: string[];
|
|
49
|
+
/** Whether the content is being checked */
|
|
50
|
+
checking: boolean;
|
|
51
|
+
/** Resolves the open `edit` call */
|
|
52
|
+
private editing;
|
|
53
|
+
/** Checks the content of the open `edit` call */
|
|
54
|
+
private validator;
|
|
55
|
+
constructor();
|
|
56
|
+
protected createRenderRoot(): this;
|
|
57
|
+
/** The dialog, once rendered */
|
|
58
|
+
private get dialog();
|
|
59
|
+
/** The content's text box, once rendered */
|
|
60
|
+
private get textarea();
|
|
61
|
+
/**
|
|
62
|
+
* Open the dialog to add an embed of a kind (`adding`), or change an embed block's content and options. Resolves with
|
|
63
|
+
* the embed, or undefined if the dialog is closed without saving.
|
|
64
|
+
*
|
|
65
|
+
* @param validate - gives why an embed's content or options aren't valid (none when they are), checked before it is
|
|
66
|
+
* saved
|
|
67
|
+
* @example
|
|
68
|
+
* const value = await dialog.edit(youtube, block, false, ({ key, content, options }) => api.validateEmbed(key, content, options));
|
|
69
|
+
*/
|
|
70
|
+
edit(embed: EmbedInfo, { content, options }: EmbedValue, adding: boolean, validate?: EmbedValidator): Promise<EmbedValue | undefined>;
|
|
71
|
+
/** Give the result to the open `edit` call, if there is one */
|
|
72
|
+
private finish;
|
|
73
|
+
/** The options' values with their defaults and without hidden ones, and which are hidden (see resolveFields) */
|
|
74
|
+
private resolvedOptions;
|
|
75
|
+
/** Close the dialog without saving */
|
|
76
|
+
close(): void;
|
|
77
|
+
/** Save the content and options, if there is content (or it is optional) and they are valid; otherwise show why not */
|
|
78
|
+
private save;
|
|
79
|
+
/** Change an option (or a value inside one), from its field */
|
|
80
|
+
private onOptionChange;
|
|
81
|
+
/** Render the embed's options' fields as a group, or nothing when it has none */
|
|
82
|
+
private renderOptionFields;
|
|
83
|
+
render(): import("lit").TemplateResult<1>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import type { ArticleOrder, ArticleTypeLabels, FileChange, FileFilters, FileKind, FilePage, FileSort, FileSummary } from "../../../server/types/index.ts";
|
|
3
|
+
import type { EditorApi } from "../../editorApi/index.ts";
|
|
4
|
+
/** The kinds of files, as the file browser names them */
|
|
5
|
+
export declare const FILE_KINDS: readonly {
|
|
6
|
+
value: FileKind;
|
|
7
|
+
label: string;
|
|
8
|
+
}[];
|
|
9
|
+
/** The results' sortable columns (Operations isn't sortable) */
|
|
10
|
+
export declare const FILE_COLUMNS: readonly {
|
|
11
|
+
sort: FileSort;
|
|
12
|
+
label: string;
|
|
13
|
+
}[];
|
|
14
|
+
/** The event fired after a file is replaced or deleted (detail: the file and what changed) */
|
|
15
|
+
export declare const FILES_CHANGED_EVENT = "files-changed";
|
|
16
|
+
/** Detail of the `files-changed` event */
|
|
17
|
+
export interface FilesChanged extends FileChange {
|
|
18
|
+
/** The file that was replaced or deleted */
|
|
19
|
+
file: FileSummary;
|
|
20
|
+
}
|
|
21
|
+
/** A file chosen for an article: how the article refers to it, its name, and its kind */
|
|
22
|
+
export interface ChosenFile {
|
|
23
|
+
/** How the article refers to it (or, in the rich text editor, the URL showing it) */
|
|
24
|
+
url: string;
|
|
25
|
+
name: string;
|
|
26
|
+
kind: FileKind;
|
|
27
|
+
}
|
|
28
|
+
/** Lets the user choose an existing file (first showing files of a kind, if given); undefined if none was chosen */
|
|
29
|
+
export type FileChooser = (kind?: FileKind) => Promise<ChosenFile | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* The kind of files a file input's `accept` takes, when it only takes images.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* acceptedKind("image/png, image/jpeg"); // "image"
|
|
35
|
+
* acceptedKind("image/png, application/pdf"); // undefined
|
|
36
|
+
*/
|
|
37
|
+
export declare const acceptedKind: (accept?: string) => FileKind | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* A file size for people: bytes, kilobytes, megabytes or gigabytes (1 KB = 1024 bytes), with one decimal below 10.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* formatFileSize(512); // "512 B"
|
|
43
|
+
* formatFileSize(1536); // "1.5 KB"
|
|
44
|
+
* formatFileSize(5 * 1024 ** 3); // "5 GB"
|
|
45
|
+
*/
|
|
46
|
+
export declare const formatFileSize: (bytes: number) => string;
|
|
47
|
+
/**
|
|
48
|
+
* The file browser: a dialog listing the files in the articles' folders, 50 at a time, found by name and filtered by
|
|
49
|
+
* kind and article type, in a table whose column headings sort it. Each file can be opened, its website path copied,
|
|
50
|
+
* replaced with another file, or deleted; replacing and deleting update references to it in every article, and fire
|
|
51
|
+
* `files-changed` (detail: {@link FilesChanged}). Rendered in the light DOM.
|
|
52
|
+
*
|
|
53
|
+
* Opened with `pick`, it also lets the user choose a file (e.g. to insert into an article), and gives the chosen file.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* html`<edaha-file-browser .api=${api} .types=${types}></edaha-file-browser>`
|
|
57
|
+
* browser.show();
|
|
58
|
+
* const file = await browser.pick("image");
|
|
59
|
+
*/
|
|
60
|
+
export declare class EdahaFileBrowser extends LitElement {
|
|
61
|
+
static properties: {
|
|
62
|
+
api: {
|
|
63
|
+
attribute: boolean;
|
|
64
|
+
};
|
|
65
|
+
types: {
|
|
66
|
+
attribute: boolean;
|
|
67
|
+
};
|
|
68
|
+
search: {
|
|
69
|
+
state: boolean;
|
|
70
|
+
};
|
|
71
|
+
kind: {
|
|
72
|
+
state: boolean;
|
|
73
|
+
};
|
|
74
|
+
type: {
|
|
75
|
+
state: boolean;
|
|
76
|
+
};
|
|
77
|
+
sort: {
|
|
78
|
+
state: boolean;
|
|
79
|
+
};
|
|
80
|
+
order: {
|
|
81
|
+
state: boolean;
|
|
82
|
+
};
|
|
83
|
+
page: {
|
|
84
|
+
state: boolean;
|
|
85
|
+
};
|
|
86
|
+
result: {
|
|
87
|
+
state: boolean;
|
|
88
|
+
};
|
|
89
|
+
filters: {
|
|
90
|
+
state: boolean;
|
|
91
|
+
};
|
|
92
|
+
loading: {
|
|
93
|
+
state: boolean;
|
|
94
|
+
};
|
|
95
|
+
message: {
|
|
96
|
+
state: boolean;
|
|
97
|
+
};
|
|
98
|
+
error: {
|
|
99
|
+
state: boolean;
|
|
100
|
+
};
|
|
101
|
+
picking: {
|
|
102
|
+
state: boolean;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
api: EditorApi;
|
|
106
|
+
/** The configured article types' labels */
|
|
107
|
+
types: Record<string, ArticleTypeLabels>;
|
|
108
|
+
search: string;
|
|
109
|
+
kind: string;
|
|
110
|
+
type: string;
|
|
111
|
+
/** The column the results are sorted by (undefined: by location, then name) */
|
|
112
|
+
sort?: FileSort | undefined;
|
|
113
|
+
order?: ArticleOrder | undefined;
|
|
114
|
+
page: number;
|
|
115
|
+
/** The files found, once loaded */
|
|
116
|
+
result?: FilePage | undefined;
|
|
117
|
+
filters: FileFilters;
|
|
118
|
+
loading: boolean;
|
|
119
|
+
/** What the last operation did, e.g. "Copied /news/hello/photo.png" */
|
|
120
|
+
message: string;
|
|
121
|
+
error: string;
|
|
122
|
+
/** While choosing a file with `pick`: gives the chosen file (or undefined) */
|
|
123
|
+
picking?: ((file?: FileSummary) => void) | undefined;
|
|
124
|
+
/** How long to wait after typing in the search before searching, in ms (replaceable for tests) */
|
|
125
|
+
searchDelay: number;
|
|
126
|
+
/** Asks to confirm replacing or deleting (replaceable for tests) */
|
|
127
|
+
confirm: (message: string) => boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Copy text to the clipboard: with the Clipboard API, or where it isn't allowed, by selecting the text in a hidden
|
|
130
|
+
* text box inside the dialog (the page behind it can't be focused). Rejects if neither works.
|
|
131
|
+
*/
|
|
132
|
+
copy: (text: string) => Promise<void>;
|
|
133
|
+
/** The waiting search, if any */
|
|
134
|
+
private searchTimer?;
|
|
135
|
+
/** Counts searches, so only the latest one's result is shown */
|
|
136
|
+
private searches;
|
|
137
|
+
/** The file being replaced, while its replacement is chosen */
|
|
138
|
+
private replacing?;
|
|
139
|
+
constructor();
|
|
140
|
+
protected createRenderRoot(): this;
|
|
141
|
+
/** The dialog, once rendered */
|
|
142
|
+
private get dialog();
|
|
143
|
+
/** Whether the browser is open */
|
|
144
|
+
get open(): boolean;
|
|
145
|
+
/** Open the browser with its filters cleared, on the first page, with focus in the search field */
|
|
146
|
+
show(): Promise<void>;
|
|
147
|
+
/** Open the browser with its filters cleared but for the kind, on the first page, with focus in the search field */
|
|
148
|
+
private openWith;
|
|
149
|
+
/**
|
|
150
|
+
* Open the browser to choose a file (first showing files of a kind, if given). Resolves with the chosen file, or
|
|
151
|
+
* undefined if the browser is closed without choosing one.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* const image = await browser.pick("image");
|
|
155
|
+
*/
|
|
156
|
+
pick(kind?: FileKind | ""): Promise<FileSummary | undefined>;
|
|
157
|
+
/** Stop choosing a file, giving the chosen one (or undefined) */
|
|
158
|
+
private finishPicking;
|
|
159
|
+
/** Choose a file while picking, closing the browser */
|
|
160
|
+
private chooseFile;
|
|
161
|
+
/** Close the browser */
|
|
162
|
+
close(): void;
|
|
163
|
+
/** Load the filters' choices (keeping the last ones if it fails) */
|
|
164
|
+
private loadFilters;
|
|
165
|
+
/** Find the files for the current search, filters, sort and page */
|
|
166
|
+
load(): Promise<void>;
|
|
167
|
+
/** Change a filter, going back to the first page */
|
|
168
|
+
private choose;
|
|
169
|
+
/** Search once typing pauses, from the first page */
|
|
170
|
+
private onSearch;
|
|
171
|
+
/** Sort by a column (see `nextSort`), going back to the first page */
|
|
172
|
+
private sortBy;
|
|
173
|
+
/** Show another page, from its top */
|
|
174
|
+
private goTo;
|
|
175
|
+
/** Show what an operation did, or its error */
|
|
176
|
+
private report;
|
|
177
|
+
/** Copy a file's path on the website */
|
|
178
|
+
copyUrl(file: FileSummary): Promise<void>;
|
|
179
|
+
/** Choose a file to replace another with (it is replaced once chosen) */
|
|
180
|
+
private chooseReplacement;
|
|
181
|
+
/** Tell the editor a file was replaced or deleted, and show the files again */
|
|
182
|
+
private changed;
|
|
183
|
+
/**
|
|
184
|
+
* Replace a file with another, after confirming (saying how many articles refer to it, which then refer to the new
|
|
185
|
+
* file if its name differs).
|
|
186
|
+
*/
|
|
187
|
+
replace(file: FileSummary, replacement: File): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Delete a file after confirming (saying how many articles refer to it, which then don't).
|
|
190
|
+
*/
|
|
191
|
+
delete(file: FileSummary): Promise<void>;
|
|
192
|
+
/** Render a select filter with an "any" choice first */
|
|
193
|
+
private renderSelect;
|
|
194
|
+
/** Render an operation's icon button, named for screen readers and as a tooltip */
|
|
195
|
+
private renderOperation;
|
|
196
|
+
/** Render the found files as a table */
|
|
197
|
+
private renderResults;
|
|
198
|
+
/** Render the page buttons, when there is more than one page */
|
|
199
|
+
private renderPages;
|
|
200
|
+
/** What the status line says: an error, what an operation did, loading, or how many files were found */
|
|
201
|
+
private statusText;
|
|
202
|
+
render(): import("lit").TemplateResult<1>;
|
|
203
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import type { ImageUploader } from "../edaha-richtext/index.ts";
|
|
3
|
+
import type { FileChooser } from "../edaha-file-browser/index.ts";
|
|
4
|
+
import { type EmbedTools } from "../../embeds/index.ts";
|
|
5
|
+
import { type TextEdit } from "../../markdown/index.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Markdown editor for an article body: a text box with a toolbar that has the same buttons as the rich text editor's.
|
|
8
|
+
* The buttons write Markdown, or HTML where Markdown has nothing for it (small and big text, details blocks). Rendered
|
|
9
|
+
* in the light DOM, so its text box can be labelled by the field's label (give it `textareaId`). Fires
|
|
10
|
+
* `markdown-change` when the text changes; read it from `value`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* html`<edaha-markdown .value=${markdown} .textareaId=${"field-body"} @markdown-change=${onChange}></edaha-markdown>`
|
|
14
|
+
*/
|
|
15
|
+
export declare class EdahaMarkdown extends LitElement {
|
|
16
|
+
static properties: {
|
|
17
|
+
value: {
|
|
18
|
+
attribute: boolean;
|
|
19
|
+
};
|
|
20
|
+
textareaId: {
|
|
21
|
+
attribute: boolean;
|
|
22
|
+
};
|
|
23
|
+
uploadImage: {
|
|
24
|
+
attribute: boolean;
|
|
25
|
+
};
|
|
26
|
+
chooseFile: {
|
|
27
|
+
attribute: boolean;
|
|
28
|
+
};
|
|
29
|
+
embedTools: {
|
|
30
|
+
attribute: boolean;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** The Markdown */
|
|
34
|
+
value: string;
|
|
35
|
+
/** The text box's id, for its label */
|
|
36
|
+
textareaId: string;
|
|
37
|
+
/** Uploads an image file and returns how to refer to it in Markdown; without it, the upload button is disabled */
|
|
38
|
+
uploadImage?: ImageUploader | undefined;
|
|
39
|
+
/** Lets the user choose an existing file, giving how to refer to it; without it, its button is disabled */
|
|
40
|
+
chooseFile?: FileChooser | undefined;
|
|
41
|
+
/** The site's embeds and the embed dialog; without them, the embed button is disabled */
|
|
42
|
+
embedTools?: EmbedTools | undefined;
|
|
43
|
+
/** Asks for a URL (replaceable for tests) */
|
|
44
|
+
prompt: (message: string, value?: string) => string | null;
|
|
45
|
+
constructor();
|
|
46
|
+
protected createRenderRoot(): this;
|
|
47
|
+
/** The toolbar's buttons, in the same order as the rich text editor's */
|
|
48
|
+
private readonly actions;
|
|
49
|
+
/** The text box, once rendered */
|
|
50
|
+
private get textarea();
|
|
51
|
+
/** The text and its selection now */
|
|
52
|
+
private get selection();
|
|
53
|
+
/** Take the text box's text as the value, announcing it if it changed */
|
|
54
|
+
private sync;
|
|
55
|
+
/**
|
|
56
|
+
* Make an edit in the text box: replace only the part that changed, then select what the edit selects. The change is
|
|
57
|
+
* typed in where the browser supports it, so it can be undone like typing.
|
|
58
|
+
*/
|
|
59
|
+
apply(edit: TextEdit | undefined): void;
|
|
60
|
+
/** Upload the chosen image and insert it at the cursor */
|
|
61
|
+
private onImageFile;
|
|
62
|
+
/**
|
|
63
|
+
* Ask for an embed's content in the embed dialog (where the selection was when asked): a new embed of a kind,
|
|
64
|
+
* inserted after the selection, or the selected embed block when it is of that kind.
|
|
65
|
+
*/
|
|
66
|
+
private editEmbed;
|
|
67
|
+
/** Let the user choose an existing file, and insert it where the selection was when asked */
|
|
68
|
+
private onChooseFile;
|
|
69
|
+
render(): import("lit").TemplateResult<1>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import type { MetadataProblem, MetadataSchema } from "@lvl99dotcom/edaha.md/generator/metadata";
|
|
3
|
+
import { type FileChooser } from "../edaha-file-browser/index.ts";
|
|
4
|
+
/** Detail of the `metadata-change` event: the changed value's path (e.g. "credit/name") and its new value */
|
|
5
|
+
export interface MetadataChange {
|
|
6
|
+
path: string;
|
|
7
|
+
value: unknown;
|
|
8
|
+
}
|
|
9
|
+
/** Uploads a file into the article's folder and returns its name */
|
|
10
|
+
export type FileUploader = (file: File) => Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* One custom metadata value's field, built from its schema: an input, textarea, select, checkboxes, radio buttons or
|
|
13
|
+
* a file chooser, a group of fields for a map, or a list of fields with Add and Delete buttons. Its label and
|
|
14
|
+
* description come from `$edahaField` (or the schema), and its problems show above it. Rendered in the light DOM.
|
|
15
|
+
*
|
|
16
|
+
* Fires `metadata-change` (detail: {@link MetadataChange}) when the value changes, and `metadata-blur` (detail: the
|
|
17
|
+
* path) when focus leaves the field.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* html`<edaha-metadata-field path="featured" .schema=${schema} .value=${value}></edaha-metadata-field>`
|
|
21
|
+
*/
|
|
22
|
+
export declare class EdahaMetadataField extends LitElement {
|
|
23
|
+
static properties: {
|
|
24
|
+
path: {};
|
|
25
|
+
label: {};
|
|
26
|
+
schema: {
|
|
27
|
+
attribute: boolean;
|
|
28
|
+
};
|
|
29
|
+
value: {
|
|
30
|
+
attribute: boolean;
|
|
31
|
+
};
|
|
32
|
+
problems: {
|
|
33
|
+
attribute: boolean;
|
|
34
|
+
};
|
|
35
|
+
hiddenFields: {
|
|
36
|
+
attribute: boolean;
|
|
37
|
+
};
|
|
38
|
+
required: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
};
|
|
41
|
+
uploadFile: {
|
|
42
|
+
attribute: boolean;
|
|
43
|
+
};
|
|
44
|
+
chooseFile: {
|
|
45
|
+
attribute: boolean;
|
|
46
|
+
};
|
|
47
|
+
fileUrl: {
|
|
48
|
+
attribute: boolean;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/** The value's path from the article's settings, e.g. "featured", "credit/name" or "images/2" */
|
|
52
|
+
path: string;
|
|
53
|
+
/** The label, when it isn't the schema's (e.g. "Images 2" for a list's item) */
|
|
54
|
+
label?: string | undefined;
|
|
55
|
+
schema: MetadataSchema;
|
|
56
|
+
value: unknown;
|
|
57
|
+
/** Problems with the article's metadata (those for this value, and inside it, show) */
|
|
58
|
+
problems: MetadataProblem[];
|
|
59
|
+
/** The paths (in dot notation, e.g. "credit.name") of fields hidden by their conditions, which aren't shown */
|
|
60
|
+
hiddenFields: ReadonlySet<string>;
|
|
61
|
+
required: boolean;
|
|
62
|
+
/** Uploads files for file fields; without it they can't be chosen */
|
|
63
|
+
uploadFile?: FileUploader | undefined;
|
|
64
|
+
/** Lets the user choose an existing file for file fields */
|
|
65
|
+
chooseFile?: FileChooser | undefined;
|
|
66
|
+
/** The URL a file name is shown at, for file fields */
|
|
67
|
+
fileUrl?: ((name: string) => string | undefined) | undefined;
|
|
68
|
+
constructor();
|
|
69
|
+
protected createRenderRoot(): this;
|
|
70
|
+
/** Change the value at a path inside this one (or this one), telling the article */
|
|
71
|
+
private change;
|
|
72
|
+
/** The key at the end of the path, e.g. "name" for "credit/name" */
|
|
73
|
+
private get key();
|
|
74
|
+
/** The label shown */
|
|
75
|
+
private get fieldTitle();
|
|
76
|
+
/** Render the description, extra information and problems shown above the input, linked to it by id */
|
|
77
|
+
private renderNotes;
|
|
78
|
+
/** The ids of the notes an input is described by */
|
|
79
|
+
private describedBy;
|
|
80
|
+
/** Render a child field for a map's property or a list's item */
|
|
81
|
+
private renderChild;
|
|
82
|
+
/** Render a map of fields as a group */
|
|
83
|
+
private renderObject;
|
|
84
|
+
/** Render a list of fields, with Delete buttons and an Add button */
|
|
85
|
+
private renderList;
|
|
86
|
+
/** Render a select: a dropdown, a list (`list: true`), and choosing several for a whole list (`multiple: true`) */
|
|
87
|
+
private renderSelect;
|
|
88
|
+
/** Render radio buttons, each with its own description */
|
|
89
|
+
private renderRadio;
|
|
90
|
+
/** Let the user choose an existing file (of the kind the field accepts), and set the value to it */
|
|
91
|
+
private chooseExisting;
|
|
92
|
+
/**
|
|
93
|
+
* Render a file field: the file's name (linked), a chooser that uploads it, a button choosing an existing file, and
|
|
94
|
+
* a button that clears it.
|
|
95
|
+
*/
|
|
96
|
+
private renderFile;
|
|
97
|
+
/** Render the input for a single value's field kind (the other kinds are an `<input>` of the same type) */
|
|
98
|
+
private renderInput;
|
|
99
|
+
render(): import("lit").TemplateResult<1>;
|
|
100
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/core";
|
|
2
|
+
import { LitElement, type PropertyValues } from "lit";
|
|
3
|
+
import { type EmbedTools } from "../../embeds/index.ts";
|
|
4
|
+
import { type FileAddress } from "../../richtext/editor/index.ts";
|
|
5
|
+
import type { ChosenFile, FileChooser } from "../edaha-file-browser/index.ts";
|
|
6
|
+
/** Uploads an image and returns the URL to show it at */
|
|
7
|
+
export type ImageUploader = (file: File) => Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Rich text editor for an article body (Tiptap) with a toolbar. Rendered in the light DOM, as ProseMirror needs
|
|
10
|
+
* document selection APIs. Fires `richtext-change` when the content changes (not `input`, which typing in the
|
|
11
|
+
* editable area fires too); read the HTML from `value`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* html`<edaha-richtext .value=${body} .uploadImage=${upload} @richtext-change=${onChange}></edaha-richtext>`
|
|
15
|
+
*/
|
|
16
|
+
export declare class EdahaRichtext extends LitElement {
|
|
17
|
+
static properties: {
|
|
18
|
+
value: {
|
|
19
|
+
attribute: boolean;
|
|
20
|
+
};
|
|
21
|
+
uploadImage: {
|
|
22
|
+
attribute: boolean;
|
|
23
|
+
};
|
|
24
|
+
chooseFile: {
|
|
25
|
+
attribute: boolean;
|
|
26
|
+
};
|
|
27
|
+
embedTools: {
|
|
28
|
+
attribute: boolean;
|
|
29
|
+
};
|
|
30
|
+
fileAddress: {
|
|
31
|
+
attribute: boolean;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/** The content as HTML */
|
|
35
|
+
value: string;
|
|
36
|
+
/** Uploads an image file; without it, the upload button is disabled */
|
|
37
|
+
uploadImage?: ImageUploader | undefined;
|
|
38
|
+
/** Lets the user choose an existing file, giving the URL to show it at; without it, its button is disabled */
|
|
39
|
+
chooseFile?: FileChooser | undefined;
|
|
40
|
+
/** The site's embeds, the embed dialog, and embed blocks' frames */
|
|
41
|
+
embedTools?: EmbedTools | undefined;
|
|
42
|
+
/** The address images in the body are shown from, for their `src` (e.g. on another page's editor server) */
|
|
43
|
+
fileAddress?: FileAddress | undefined;
|
|
44
|
+
/** The Tiptap editor, once rendered */
|
|
45
|
+
editor?: Editor;
|
|
46
|
+
/**
|
|
47
|
+
* The toolbar that floats above selected text, with its format buttons. The editor shows it and moves it into the
|
|
48
|
+
* editable area's box while text is selected, so it is rendered here rather than in the component's template.
|
|
49
|
+
*/
|
|
50
|
+
readonly formatMenu: HTMLElement;
|
|
51
|
+
/** Asks for a URL (replaceable for tests) */
|
|
52
|
+
prompt: (message: string, value?: string) => string | null;
|
|
53
|
+
constructor();
|
|
54
|
+
protected createRenderRoot(): this;
|
|
55
|
+
/** The floating toolbar's buttons, for formatting selected text */
|
|
56
|
+
private readonly formatActions;
|
|
57
|
+
/** The toolbar's buttons */
|
|
58
|
+
private readonly actions;
|
|
59
|
+
/**
|
|
60
|
+
* Add, change or remove (empty URL) the link on the selection.
|
|
61
|
+
*/
|
|
62
|
+
private editLink;
|
|
63
|
+
/**
|
|
64
|
+
* Insert an image by URL.
|
|
65
|
+
*/
|
|
66
|
+
private insertImageUrl;
|
|
67
|
+
/**
|
|
68
|
+
* Ask for an embed's content in the embed dialog: a new embed of a kind (from its toolbar button), inserted after the
|
|
69
|
+
* selected block, or the selected embed block (from its "Edit" button, or its kind's toolbar button).
|
|
70
|
+
*
|
|
71
|
+
* @param key - the kind of embed to add, from its toolbar button
|
|
72
|
+
*/
|
|
73
|
+
private editEmbed;
|
|
74
|
+
/**
|
|
75
|
+
* Upload the chosen image and insert it.
|
|
76
|
+
*/
|
|
77
|
+
private onImageFile;
|
|
78
|
+
/**
|
|
79
|
+
* Insert a file: an image as an image, anything else as a link (on the selection, or named after the file).
|
|
80
|
+
*/
|
|
81
|
+
insertFile({ url, name, kind }: ChosenFile): void;
|
|
82
|
+
/** Let the user choose an existing file, and insert it */
|
|
83
|
+
private onChooseFile;
|
|
84
|
+
protected firstUpdated(): void;
|
|
85
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
86
|
+
disconnectedCallback(): void;
|
|
87
|
+
render(): import("lit").TemplateResult<1>;
|
|
88
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
/** A message shown as a toast */
|
|
3
|
+
export interface ToastMessage {
|
|
4
|
+
kind: "success" | "error";
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
/** The event other components fire (bubbling) to show a toast; its detail is a {@link ToastMessage} */
|
|
8
|
+
export declare const TOAST_EVENT = "edaha-toast";
|
|
9
|
+
/** A toast on screen */
|
|
10
|
+
interface Toast extends ToastMessage {
|
|
11
|
+
id: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Show a toast from a component, by firing {@link TOAST_EVENT} for the editor to show.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* showToast(this, { kind: "success", message: "Saved" });
|
|
18
|
+
*/
|
|
19
|
+
export declare const showToast: (from: EventTarget, toast: ToastMessage) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Toasts in a corner of the editor: successes go away after a few seconds, errors stay until dismissed. Rendered in the
|
|
22
|
+
* light DOM.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* html`<edaha-toasts></edaha-toasts>`; // then toasts.show({ kind: "error", message: "Not found" })
|
|
26
|
+
*/
|
|
27
|
+
export declare class EdahaToasts extends LitElement {
|
|
28
|
+
static properties: {
|
|
29
|
+
toasts: {
|
|
30
|
+
state: boolean;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
toasts: Toast[];
|
|
34
|
+
/** How long a success toast is shown, in ms (replaceable for tests) */
|
|
35
|
+
duration: number;
|
|
36
|
+
private nextId;
|
|
37
|
+
constructor();
|
|
38
|
+
protected createRenderRoot(): this;
|
|
39
|
+
/**
|
|
40
|
+
* Show a toast. Success toasts are dismissed after `duration`.
|
|
41
|
+
*/
|
|
42
|
+
show(toast: ToastMessage): void;
|
|
43
|
+
/** Remove a toast */
|
|
44
|
+
dismiss(id: number): void;
|
|
45
|
+
render(): import("lit").TemplateResult<1>;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an ISO 8601 date to a `datetime-local` input value in local time.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* toLocalInput("2026-10-19T09:54:00.000Z"); // "2026-10-19T11:54" in Paris (UTC+2)
|
|
6
|
+
*/
|
|
7
|
+
export declare const toLocalInput: (iso: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Convert a `datetime-local` input value (local time) to an ISO 8601 date. Returns "" for an empty or invalid value.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* fromLocalInput("2026-10-19T11:54"); // "2026-10-19T09:54:00.000Z" in Paris (UTC+2)
|
|
13
|
+
*/
|
|
14
|
+
export declare const fromLocalInput: (value: string) => string;
|