@bygga.dev/editor 1.8.4 → 1.9.4

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,70 @@ 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[];
63
+ localColors?: string[];
64
+ colorsLabel?: string;
65
+ localColorsLabel?: string;
66
+ anyColor?: boolean;
10
67
  fonts?: BrandFont[];
11
68
  customFonts?: BrandCustomFont[];
69
+ styles?: BrandStyles;
70
+ custom?: Record<string, unknown>;
71
+ hiddenBlocks?: string[];
12
72
  };
13
73
 
14
74
  declare const brand$1: unique symbol;
@@ -18,18 +78,57 @@ type Document = {
18
78
  declare function parseDocument(json: unknown): Document;
19
79
  declare function createEmptyDocument(kind?: 'email' | 'page'): Document;
20
80
 
81
+ type BlockPluginBrand = {
82
+ readonly colors: readonly string[];
83
+ readonly localColors: readonly string[];
84
+ readonly colorsLabel?: string;
85
+ readonly localColorsLabel?: string;
86
+ readonly anyColor: boolean;
87
+ readonly fonts: readonly BrandFont[];
88
+ readonly customFonts: readonly BrandCustomFont[];
89
+ readonly styles: BrandStyles;
90
+ readonly custom: Readonly<Record<string, unknown>>;
91
+ readonly css: {
92
+ readonly header?: BlockPluginStyleCss;
93
+ readonly text?: BlockPluginStyleCss;
94
+ readonly button?: BlockPluginStyleCss;
95
+ };
96
+ };
97
+ type BlockPluginStyleCss = {
98
+ readonly fontFamily?: string;
99
+ readonly fontSize?: string;
100
+ readonly fontWeight?: string;
101
+ readonly fontStyle?: string;
102
+ readonly textDecoration?: string;
103
+ readonly color?: string;
104
+ readonly textAlign?: string;
105
+ readonly backgroundColor?: string;
106
+ readonly padding?: string;
107
+ readonly margin?: string;
108
+ readonly borderRadius?: string;
109
+ readonly borderWidth?: string;
110
+ readonly borderStyle?: string;
111
+ readonly borderColor?: string;
112
+ readonly cssText: string;
113
+ };
114
+ type BlockPluginCreateContext = {
115
+ readonly brand: BlockPluginBrand;
116
+ readonly locale: string;
117
+ };
21
118
  type BlockPluginSettingsContext<Data = unknown, Globals = unknown> = {
22
119
  readonly data: Data;
23
120
  update(data: Data): void;
24
121
  readonly globals: Globals;
25
122
  uploadImage(image: Blob): Promise<string>;
26
123
  readonly locale: string;
124
+ readonly brand: BlockPluginBrand;
27
125
  };
28
126
  type BlockPluginGlobalsContext<Globals = unknown> = {
29
127
  readonly globals: Globals;
30
128
  update(globals: Globals): void;
31
129
  uploadImage(image: Blob): Promise<string>;
32
130
  readonly locale: string;
131
+ readonly brand: BlockPluginBrand;
33
132
  };
34
133
  type BlockPluginGlobalSettings<Globals = unknown> = {
35
134
  create(): Globals;
@@ -40,7 +139,7 @@ type BlockPlugin<Data = unknown, Globals = unknown> = {
40
139
  name: string;
41
140
  label: string;
42
141
  icon?: string;
43
- create(): Data;
142
+ create(context: BlockPluginCreateContext): Data;
44
143
  parse(data: unknown): Data;
45
144
  email(data: Data, globals: Globals): string;
46
145
  preview?(node: HTMLElement, data: Data, globals: Globals): void;
@@ -119,10 +218,19 @@ type MergeTagEntry = MergeTagLabels & {
119
218
  };
120
219
  type MergeTags = Record<string, MergeTagEntry>;
121
220
 
221
+ type Permission = 'admin' | 'creator';
222
+
223
+ declare function documentDigest(document: Document): Promise<string>;
224
+
122
225
  declare const EDITOR_TAG = "bygga-editor";
123
226
  declare const ByggaEditor: CustomElementConstructor;
124
227
 
228
+ type AutosaveDetail = {
229
+ document: Document;
230
+ digest: string;
231
+ };
125
232
  type ByggaEditorEventMap = {
233
+ autosave: CustomEvent<[AutosaveDetail]>;
126
234
  change: CustomEvent<[Document]>;
127
235
  dirtychange: CustomEvent<[boolean]>;
128
236
  licenseerror: CustomEvent<[LicenseError]>;
@@ -139,6 +247,7 @@ interface ByggaEditorElement extends HTMLElement {
139
247
  locale?: Locale;
140
248
  markSaved(): void;
141
249
  mergeTags?: MergeTags;
250
+ permission?: Permission;
142
251
  removeEventListener<K extends keyof ByggaEditorEventMap>(type: K, listener: (this: ByggaEditorElement, event: ByggaEditorEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
143
252
  removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
144
253
  save(): Promise<void>;
@@ -150,5 +259,5 @@ declare global {
150
259
  }
151
260
  }
152
261
 
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 };
262
+ export { ByggaEditor, DEFAULT_LOCALE, EDITOR_TAG, SUPPORTED_LOCALES, createEmptyDocument, documentDigest, parseDocument, parseSavedBlock };
263
+ 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.4",
3
+ "version": "1.9.4",
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 };