@bygga.dev/editor 1.8.3 → 1.9.3

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
@@ -5,10 +5,66 @@ type BrandCustomFont = {
5
5
  fontFamily?: string;
6
6
  type?: 'file' | 'stylesheet';
7
7
  };
8
+ type BrandBlockType = 'text' | 'header' | 'columns' | 'image' | 'button' | 'spacer' | 'divider' | 'html';
9
+ type BrandBox = number | {
10
+ top: number;
11
+ right: number;
12
+ bottom: number;
13
+ left: number;
14
+ };
15
+ type BrandCorners = number | {
16
+ topLeft: number;
17
+ topRight: number;
18
+ bottomRight: number;
19
+ bottomLeft: number;
20
+ };
21
+ type BrandBorder = {
22
+ width: BrandBox;
23
+ color?: string;
24
+ style?: 'solid' | 'dashed' | 'dotted';
25
+ };
26
+ type BrandTextStyle = {
27
+ font?: string;
28
+ fontSize?: number;
29
+ color?: string;
30
+ bold?: boolean;
31
+ italic?: boolean;
32
+ underline?: boolean;
33
+ align?: 'left' | 'center' | 'right' | 'justify';
34
+ background?: string;
35
+ padding?: BrandBox;
36
+ margin?: BrandBox;
37
+ borderRadius?: BrandCorners;
38
+ border?: BrandBorder;
39
+ paragraphSpacing?: number;
40
+ };
41
+ type BrandHeaderStyle = Omit<BrandTextStyle, 'paragraphSpacing'> & {
42
+ level?: 1 | 2 | 3;
43
+ };
44
+ type BrandButtonStyle = {
45
+ background?: string;
46
+ textColor?: string;
47
+ font?: string;
48
+ fontSize?: number;
49
+ bold?: boolean;
50
+ borderRadius?: BrandCorners;
51
+ padding?: BrandBox;
52
+ margin?: BrandBox;
53
+ border?: BrandBorder;
54
+ align?: 'left' | 'center' | 'right';
55
+ };
56
+ type BrandStyles = {
57
+ header?: BrandHeaderStyle;
58
+ text?: BrandTextStyle;
59
+ button?: BrandButtonStyle;
60
+ };
8
61
  type Brand = {
9
62
  colors?: string[];
10
63
  fonts?: BrandFont[];
11
64
  customFonts?: BrandCustomFont[];
65
+ styles?: BrandStyles;
66
+ custom?: Record<string, unknown>;
67
+ hiddenBlocks?: string[];
12
68
  };
13
69
 
14
70
  declare const brand$1: unique symbol;
@@ -18,18 +74,53 @@ type Document = {
18
74
  declare function parseDocument(json: unknown): Document;
19
75
  declare function createEmptyDocument(kind?: 'email' | 'page'): Document;
20
76
 
77
+ type BlockPluginBrand = {
78
+ readonly colors: readonly string[];
79
+ readonly fonts: readonly BrandFont[];
80
+ readonly customFonts: readonly BrandCustomFont[];
81
+ readonly styles: BrandStyles;
82
+ readonly custom: Readonly<Record<string, unknown>>;
83
+ readonly css: {
84
+ readonly header?: BlockPluginStyleCss;
85
+ readonly text?: BlockPluginStyleCss;
86
+ readonly button?: BlockPluginStyleCss;
87
+ };
88
+ };
89
+ type BlockPluginStyleCss = {
90
+ readonly fontFamily?: string;
91
+ readonly fontSize?: string;
92
+ readonly fontWeight?: string;
93
+ readonly fontStyle?: string;
94
+ readonly textDecoration?: string;
95
+ readonly color?: string;
96
+ readonly textAlign?: string;
97
+ readonly backgroundColor?: string;
98
+ readonly padding?: string;
99
+ readonly margin?: string;
100
+ readonly borderRadius?: string;
101
+ readonly borderWidth?: string;
102
+ readonly borderStyle?: string;
103
+ readonly borderColor?: string;
104
+ readonly cssText: string;
105
+ };
106
+ type BlockPluginCreateContext = {
107
+ readonly brand: BlockPluginBrand;
108
+ readonly locale: string;
109
+ };
21
110
  type BlockPluginSettingsContext<Data = unknown, Globals = unknown> = {
22
111
  readonly data: Data;
23
112
  update(data: Data): void;
24
113
  readonly globals: Globals;
25
114
  uploadImage(image: Blob): Promise<string>;
26
115
  readonly locale: string;
116
+ readonly brand: BlockPluginBrand;
27
117
  };
28
118
  type BlockPluginGlobalsContext<Globals = unknown> = {
29
119
  readonly globals: Globals;
30
120
  update(globals: Globals): void;
31
121
  uploadImage(image: Blob): Promise<string>;
32
122
  readonly locale: string;
123
+ readonly brand: BlockPluginBrand;
33
124
  };
34
125
  type BlockPluginGlobalSettings<Globals = unknown> = {
35
126
  create(): Globals;
@@ -40,7 +131,7 @@ type BlockPlugin<Data = unknown, Globals = unknown> = {
40
131
  name: string;
41
132
  label: string;
42
133
  icon?: string;
43
- create(): Data;
134
+ create(context: BlockPluginCreateContext): Data;
44
135
  parse(data: unknown): Data;
45
136
  email(data: Data, globals: Globals): string;
46
137
  preview?(node: HTMLElement, data: Data, globals: Globals): void;
@@ -119,10 +210,19 @@ type MergeTagEntry = MergeTagLabels & {
119
210
  };
120
211
  type MergeTags = Record<string, MergeTagEntry>;
121
212
 
213
+ type Permission = 'admin' | 'creator';
214
+
215
+ declare function documentDigest(document: Document): Promise<string>;
216
+
122
217
  declare const EDITOR_TAG = "bygga-editor";
123
218
  declare const ByggaEditor: CustomElementConstructor;
124
219
 
220
+ type AutosaveDetail = {
221
+ document: Document;
222
+ digest: string;
223
+ };
125
224
  type ByggaEditorEventMap = {
225
+ autosave: CustomEvent<[AutosaveDetail]>;
126
226
  change: CustomEvent<[Document]>;
127
227
  dirtychange: CustomEvent<[boolean]>;
128
228
  licenseerror: CustomEvent<[LicenseError]>;
@@ -139,6 +239,7 @@ interface ByggaEditorElement extends HTMLElement {
139
239
  locale?: Locale;
140
240
  markSaved(): void;
141
241
  mergeTags?: MergeTags;
242
+ permission?: Permission;
142
243
  removeEventListener<K extends keyof ByggaEditorEventMap>(type: K, listener: (this: ByggaEditorElement, event: ByggaEditorEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
143
244
  removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
144
245
  save(): Promise<void>;
@@ -150,5 +251,5 @@ declare global {
150
251
  }
151
252
  }
152
253
 
153
- export { ByggaEditor, DEFAULT_LOCALE, EDITOR_TAG, SUPPORTED_LOCALES, createEmptyDocument, parseDocument, parseSavedBlock };
154
- export type { AiAction, AiAssistant, AiRequest, BlockPlugin, BlockPluginGlobalSettings, BlockPluginGlobalsContext, BlockPluginSettingsContext, Brand, BrandCustomFont, BrandFont, ByggaEditorElement, ByggaEditorEventMap, Document, EditorConfig, LicenseError, LicenseErrorReason, Locale, MergeTagEntry, MergeTagLabels, MergeTagOption, MergeTags, SavedBlock, SavedBlockContent };
254
+ export { ByggaEditor, DEFAULT_LOCALE, EDITOR_TAG, SUPPORTED_LOCALES, createEmptyDocument, documentDigest, parseDocument, parseSavedBlock };
255
+ export type { AiAction, AiAssistant, AiRequest, AutosaveDetail, BlockPlugin, BlockPluginBrand, BlockPluginCreateContext, BlockPluginGlobalSettings, BlockPluginGlobalsContext, BlockPluginSettingsContext, BlockPluginStyleCss, Brand, BrandBlockType, BrandBorder, BrandBox, BrandButtonStyle, BrandCorners, BrandCustomFont, BrandFont, BrandHeaderStyle, BrandStyles, BrandTextStyle, ByggaEditorElement, ByggaEditorEventMap, Document, EditorConfig, LicenseError, LicenseErrorReason, Locale, MergeTagEntry, MergeTagLabels, MergeTagOption, MergeTags, Permission, SavedBlock, SavedBlockContent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bygga.dev/editor",
3
- "version": "1.8.3",
3
+ "version": "1.9.3",
4
4
  "description": "Visual content builder shipped as the <bygga-editor> custom element",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -4772,6 +4772,6 @@ var su = !1, cu = () => {
4772
4772
  withMemo: () => qs,
4773
4773
  withModifiers: () => ql,
4774
4774
  withScopeId: () => cr
4775
- }), uu = () => {}, du = Symbol("editorData"), fu = Symbol("documentActions"), pu = Symbol("stackAcceptsDrop"), mu = Symbol("anchorIds"), hu = Symbol("documentFont"), gu = Symbol("documentKind"), _u = Symbol("pluginGlobals"), vu = Symbol("flyoutHost"), yu = Symbol("containingColumns"), bu = Symbol("underCondition"), xu = Symbol("columnsAcross");
4775
+ }), uu = () => {}, du = Symbol("editorData"), fu = Symbol("documentActions"), pu = Symbol("stackAcceptsDrop"), mu = Symbol("anchorIds"), hu = Symbol("documentFont"), gu = Symbol("documentKind"), _u = Symbol("pluginGlobals"), vu = Symbol("flyoutHost"), yu = Symbol("containingColumns"), bu = Symbol("underCondition"), xu = Symbol("underLock"), Su = Symbol("columnsAcross");
4776
4776
  //#endregion
4777
- export { ur as $, J as A, Hi as B, Zo as C, vs as D, os as E, pr as F, sa as G, es as H, Da as I, Ja as J, ta as K, xs as L, Zr as M, Q as N, as as O, Gs as P, lr as Q, Kn as R, Fr as S, fs as T, fr as U, Ki as V, aa as W, br as X, ei as Y, _r as Z, Nl as _, hu as a, Ne as at, ql as b, vu as c, rn as ct, bu as d, ln as dt, mn as et, lu as f, _e as ft, Ll as g, t as gt, Pl as h, Ee as ht, fu as i, en as it, Oi as j, gs as k, _u as l, an as lt, tu as m, j as mt, xu as n, Me as nt, gu as o, Kt as ot, fl as p, ve as pt, Qr as q, yu as r, L as rt, du as s, Jt as st, mu as t, je as tt, pu as u, un as ut, Mc as v, Ws as w, G as x, Yl as y, Gi as z };
4777
+ export { lr as $, gs as A, Gi as B, Fr as C, os as D, fs as E, Gs as F, aa as G, Ki as H, pr as I, Qr as J, sa as K, Da as L, Oi as M, Zr as N, vs as O, Q as P, _r as Q, xs as R, G as S, Ws as T, es as U, Hi as V, fr as W, ei as X, Ja as Y, br as Z, Ll as _, t as _t, hu as a, en as at, Yl as b, vu as c, Jt as ct, bu as d, un as dt, ur as et, xu as f, ln as ft, Pl as g, Ee as gt, tu as h, j as ht, fu as i, L as it, J as j, as as k, _u as l, rn as lt, fl as m, ve as mt, Su as n, je as nt, gu as o, Ne as ot, lu as p, _e as pt, ta as q, yu as r, Me as rt, du as s, Kt as st, mu as t, mn as tt, pu as u, an as ut, Nl as v, Zo as w, ql as x, Mc as y, Kn as z };