@bygga.dev/editor 0.1.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/element.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ declare const brand: unique symbol;
2
+ type Document = {
3
+ readonly [brand]: 'Document';
4
+ };
5
+ declare function parseDocument(json: unknown): Document;
6
+ declare function createEmptyDocument(): Document;
7
+
8
+ type EditorConfig = {
9
+ uploadImage(image: Blob): Promise<string>;
10
+ saveDocument?(document: Document): Promise<void>;
11
+ onImageError?(error: unknown): void;
12
+ };
13
+
14
+ declare const SUPPORTED_LOCALES: readonly ["en", "sv"];
15
+ type Locale = (typeof SUPPORTED_LOCALES)[number];
16
+ declare const DEFAULT_LOCALE: Locale;
17
+
18
+ type LicenseErrorReason = 'key' | 'domain' | 'origin' | 'malformed' | 'unreachable' | 'invalid' | 'insecure-context';
19
+ type LicenseError = {
20
+ reason: LicenseErrorReason;
21
+ };
22
+
23
+ type MergeTagLabels = Partial<Record<Locale, string>>;
24
+ type MergeTags = Record<string, MergeTagLabels>;
25
+
26
+ declare const EDITOR_TAG = "bygga-editor";
27
+ declare const ByggaEditor: CustomElementConstructor;
28
+
29
+ type ByggaEditorEventMap = {
30
+ change: CustomEvent<[Document]>;
31
+ dirtychange: CustomEvent<[boolean]>;
32
+ licenseerror: CustomEvent<[LicenseError]>;
33
+ };
34
+ interface ByggaEditorElement extends HTMLElement {
35
+ addEventListener<K extends keyof ByggaEditorEventMap>(type: K, listener: (this: ByggaEditorElement, event: ByggaEditorEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
36
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
37
+ config: EditorConfig;
38
+ document?: Document | null;
39
+ getDocument(): Document;
40
+ isDirty(): boolean;
41
+ licenseKey?: string;
42
+ locale?: Locale;
43
+ markSaved(): void;
44
+ mergeTags?: MergeTags;
45
+ removeEventListener<K extends keyof ByggaEditorEventMap>(type: K, listener: (this: ByggaEditorElement, event: ByggaEditorEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
46
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
47
+ save(): Promise<void>;
48
+ }
49
+ declare global {
50
+ interface HTMLElementTagNameMap {
51
+ 'bygga-editor': ByggaEditorElement;
52
+ }
53
+ }
54
+
55
+ export { ByggaEditor, DEFAULT_LOCALE, EDITOR_TAG, SUPPORTED_LOCALES, createEmptyDocument, parseDocument };
56
+ export type { ByggaEditorElement, ByggaEditorEventMap, Document, EditorConfig, LicenseError, LicenseErrorReason, Locale, MergeTagLabels, MergeTags };
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@bygga.dev/editor",
3
+ "version": "0.1.0",
4
+ "description": "Visual content builder shipped as the <bygga-editor> custom element",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "sideEffects": true,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./element.d.ts",
11
+ "default": "./bygga-editor.js"
12
+ }
13
+ }
14
+ }