@bygga.dev/editor 0.3.1 → 1.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 CHANGED
@@ -4,17 +4,61 @@ type Brand = {
4
4
  fonts?: BrandFont[];
5
5
  };
6
6
 
7
- declare const brand: unique symbol;
7
+ declare const brand$1: unique symbol;
8
8
  type Document = {
9
- readonly [brand]: 'Document';
9
+ readonly [brand$1]: 'Document';
10
10
  };
11
11
  declare function parseDocument(json: unknown): Document;
12
12
  declare function createEmptyDocument(): Document;
13
13
 
14
+ type BlockPluginSettingsContext<Data = unknown, Globals = unknown> = {
15
+ readonly data: Data;
16
+ update(data: Data): void;
17
+ readonly globals: Globals;
18
+ uploadImage(image: Blob): Promise<string>;
19
+ readonly locale: string;
20
+ };
21
+ type BlockPluginGlobalsContext<Globals = unknown> = {
22
+ readonly globals: Globals;
23
+ update(globals: Globals): void;
24
+ uploadImage(image: Blob): Promise<string>;
25
+ readonly locale: string;
26
+ };
27
+ type BlockPluginGlobalSettings<Globals = unknown> = {
28
+ create(): Globals;
29
+ parse(globals: unknown): Globals;
30
+ mount(node: HTMLElement, context: BlockPluginGlobalsContext<Globals>): (() => void) | undefined;
31
+ };
32
+ type BlockPlugin<Data = unknown, Globals = unknown> = {
33
+ name: string;
34
+ label: string;
35
+ icon?: string;
36
+ create(): Data;
37
+ parse(data: unknown): Data;
38
+ email(data: Data, globals: Globals): string;
39
+ preview?(node: HTMLElement, data: Data, globals: Globals): void;
40
+ settings(node: HTMLElement, context: BlockPluginSettingsContext<Data, Globals>): (() => void) | undefined;
41
+ globalSettings?: BlockPluginGlobalSettings<Globals>;
42
+ };
43
+
44
+ declare const brand: unique symbol;
45
+ type SavedBlockContent = {
46
+ readonly [brand]: 'SavedBlockContent';
47
+ };
48
+ type SavedBlock = {
49
+ id: string;
50
+ name: string;
51
+ content: SavedBlockContent;
52
+ };
53
+ declare function parseSavedBlock(json: unknown): SavedBlock;
54
+
14
55
  type EditorConfig = {
15
56
  uploadImage(image: Blob): Promise<string>;
16
57
  saveDocument?(document: Document, compiled: string | null): Promise<void>;
17
58
  onImageError?(error: unknown): void;
59
+ saveBlock?(saved: SavedBlock): Promise<void>;
60
+ deleteSavedBlock?(id: string): Promise<void>;
61
+ plugins?: readonly BlockPlugin[];
18
62
  };
19
63
 
20
64
  declare const SUPPORTED_LOCALES: readonly ["en", "sv"];
@@ -52,6 +96,7 @@ interface ByggaEditorElement extends HTMLElement {
52
96
  removeEventListener<K extends keyof ByggaEditorEventMap>(type: K, listener: (this: ByggaEditorElement, event: ByggaEditorEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
53
97
  removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
54
98
  save(): Promise<void>;
99
+ savedBlocks?: SavedBlock[];
55
100
  }
56
101
  declare global {
57
102
  interface HTMLElementTagNameMap {
@@ -59,5 +104,5 @@ declare global {
59
104
  }
60
105
  }
61
106
 
62
- export { ByggaEditor, DEFAULT_LOCALE, EDITOR_TAG, SUPPORTED_LOCALES, createEmptyDocument, parseDocument };
63
- export type { Brand, BrandFont, ByggaEditorElement, ByggaEditorEventMap, Document, EditorConfig, LicenseError, LicenseErrorReason, Locale, MergeTagLabels, MergeTags };
107
+ export { ByggaEditor, DEFAULT_LOCALE, EDITOR_TAG, SUPPORTED_LOCALES, createEmptyDocument, parseDocument, parseSavedBlock };
108
+ export type { BlockPlugin, BlockPluginGlobalSettings, BlockPluginGlobalsContext, BlockPluginSettingsContext, Brand, BrandFont, ByggaEditorElement, ByggaEditorEventMap, Document, EditorConfig, LicenseError, LicenseErrorReason, Locale, MergeTagLabels, MergeTags, SavedBlock, SavedBlockContent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bygga.dev/editor",
3
- "version": "0.3.1",
3
+ "version": "1.1.0",
4
4
  "description": "Visual content builder shipped as the <bygga-editor> custom element",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",