@lit-pigeon/editor 0.3.3 → 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.
@@ -1,15 +1,341 @@
1
- let t = null;
2
- function r() {
3
- return t || (t = import("./rich-text.js").then((s) => s.default)), t;
1
+ import { css as f, LitElement as v, html as s } from "lit";
2
+ import { property as y, customElement as k } from "lit/decorators.js";
3
+ import { resolveDirection as w } from "@lit-pigeon/core";
4
+ const d = {
5
+ // toolbar
6
+ "toolbar.undo": "Undo",
7
+ "toolbar.redo": "Redo",
8
+ "toolbar.preview-device": "Preview device",
9
+ "toolbar.desktop-view": "Desktop view",
10
+ "toolbar.tablet-view-title": "Tablet view (768px)",
11
+ "toolbar.tablet-view": "Tablet view",
12
+ "toolbar.mobile-view-title": "Mobile view (375px)",
13
+ "toolbar.mobile-view": "Mobile view",
14
+ "toolbar.fullscreen": "Fullscreen",
15
+ "toolbar.exit-fullscreen": "Exit fullscreen",
16
+ "toolbar.enter-fullscreen": "Enter fullscreen",
17
+ "toolbar.templates": "Templates",
18
+ "toolbar.preview": "Preview",
19
+ "toolbar.export": "Export",
20
+ "toolbar.export-format": "Export format",
21
+ "toolbar.export-html": "Export HTML",
22
+ "toolbar.export-mjml": "Export MJML",
23
+ "toolbar.export-json": "Export JSON",
24
+ // palette
25
+ "palette.label": "Palette",
26
+ "palette.tab.content": "Content",
27
+ "palette.tab.layers": "Layers",
28
+ "palette.tab.brand": "Brand",
29
+ "palette.tab.saved": "Saved",
30
+ // palette — layout section
31
+ "palette.layout.section-content": "Content",
32
+ "palette.layout.section-layout": "Layout",
33
+ "palette.layout.1-col": "1 Column",
34
+ "palette.layout.2-col": "2 Columns",
35
+ "palette.layout.3-col": "3 Columns",
36
+ "palette.layout.4-col": "4 Columns",
37
+ // palette — brand tab
38
+ "palette.brand.colors": "Colors",
39
+ "palette.brand.fonts": "Fonts",
40
+ "palette.brand.logos": "Logos",
41
+ "palette.brand.add": "+ Add",
42
+ "palette.brand.no-colors": "No colors yet",
43
+ "palette.brand.no-fonts": "No fonts yet",
44
+ "palette.brand.no-logos": "No logos yet",
45
+ "palette.brand.color-name-label": "Color name",
46
+ "palette.brand.color-value-label": "Color value",
47
+ "palette.brand.delete-title": "Delete",
48
+ "palette.brand.insert-logo-title": "Insert logo",
49
+ // palette — saved tab
50
+ "palette.saved.empty": "No saved rows yet. Use the bookmark action on a row to save it here.",
51
+ "palette.saved.delete-title": "Delete",
52
+ // preview
53
+ "preview.heading": "Preview",
54
+ "preview.tab-group-label": "Preview format",
55
+ "preview.tab.preview": "Preview",
56
+ "preview.tab.html": "HTML",
57
+ "preview.tab.mjml": "MJML",
58
+ "preview.tab.json": "JSON",
59
+ "preview.device.desktop": "Desktop preview",
60
+ "preview.device.mobile": "Mobile preview",
61
+ "preview.close": "Close preview",
62
+ "preview.loading": "Rendering...",
63
+ // template picker
64
+ "template.heading": "Templates",
65
+ "template.close": "Close",
66
+ "template.section.choose": "Choose a template",
67
+ "template.empty": "No templates available yet.",
68
+ "template.section.save": "Save current as template",
69
+ "template.field.name": "Name",
70
+ "template.field.name-placeholder": "My template",
71
+ "template.field.category": "Category",
72
+ "template.field.description": "Description (optional)",
73
+ "template.field.description-placeholder": "What is this template for?",
74
+ "template.cancel": "Cancel",
75
+ "template.save": "Save template",
76
+ "template.error.name-required": "Name is required",
77
+ // asset manager
78
+ "asset.title": "Select asset",
79
+ "asset.title-upload": "Select image",
80
+ "asset.close": "Close",
81
+ "asset.tab.library": "Library",
82
+ "asset.tab.upload": "Upload",
83
+ "asset.folder.all": "All folders",
84
+ "asset.search": "Search assets",
85
+ "asset.tag-filter-label": "Filter by tag",
86
+ "asset.loading": "Loading…",
87
+ "asset.empty.filtered": "No assets match your filters.",
88
+ "asset.empty.no-assets": "No saved assets yet. Upload one to get started.",
89
+ "asset.drop-zone.label": "Drag & drop an image here",
90
+ "asset.drop-zone.hint": "or click to browse",
91
+ "asset.url.separator": "or enter URL",
92
+ "asset.url.placeholder": "https://example.com/image.jpg",
93
+ "asset.url.use": "Use URL",
94
+ // asset manager — stock tab
95
+ "asset.tab.stock": "Stock",
96
+ "asset.stock.search": "Search free photos…",
97
+ "asset.stock.idle": "Search Unsplash and Pexels for free photos.",
98
+ "asset.stock.empty": "No photos found. Try another search.",
99
+ "asset.stock.load-more": "Load more",
100
+ "asset.stock.photo-by": "Photo by",
101
+ "asset.stock.on": "on",
102
+ "asset.stock.error": "Couldn’t load photos. Check the API key or try again.",
103
+ "asset.stock.rate-limited": "Rate limit reached. Try again shortly.",
104
+ // property panels — shared (common) labels
105
+ "panel.common.backgroundColor": "Background Color",
106
+ "panel.common.padding": "Padding",
107
+ "panel.common.outerPadding": "Outer Padding",
108
+ "panel.common.innerPadding": "Inner Padding",
109
+ "panel.common.alignment": "Alignment",
110
+ "panel.common.fontSize": "Font Size",
111
+ "panel.common.borderRadius": "Border Radius",
112
+ "panel.common.linkUrl": "Link URL",
113
+ "panel.common.urlPlaceholder": "https://example.com",
114
+ "panel.common.contentHtml": "Content (HTML)",
115
+ "panel.common.displayCondition": "Display condition",
116
+ "panel.common.insertMergeTag": "Insert merge tag",
117
+ "panel.common.tagBtn": "{ } Tag",
118
+ "panel.common.uploadImage": "Upload Image",
119
+ "panel.common.left": "Left",
120
+ "panel.common.center": "Center",
121
+ // property panels — body
122
+ "panel.body.title": "Email Body",
123
+ "panel.body.contentWidth": "Content Width",
124
+ "panel.body.fontFamily": "Font Family",
125
+ "panel.body.contentAlignment": "Content Alignment",
126
+ "panel.body.linkColor": "Link Color",
127
+ "panel.body.linkUnderline": "Underline Links",
128
+ "panel.body.emailName": "Email Name",
129
+ "panel.body.previewText": "Preview Text",
130
+ "panel.body.previewTextPlaceholder": "Email preview text...",
131
+ "panel.body.language": "Language",
132
+ "panel.body.languagePlaceholder": "e.g. en, pt-BR",
133
+ "panel.body.textDirection": "Text Direction",
134
+ "panel.body.directionAuto": "Auto",
135
+ "panel.body.directionLtr": "Left to right",
136
+ "panel.body.directionRtl": "Right to left",
137
+ // property panels — text
138
+ "panel.text.title": "Text Properties",
139
+ "panel.text.textAlign": "Text Align",
140
+ "panel.text.lineHeight": "Line Height",
141
+ // property panels — button
142
+ "panel.button.title": "Button Properties",
143
+ "panel.button.buttonText": "Button Text",
144
+ "panel.button.textColor": "Text Color",
145
+ "panel.button.fontWeight": "Font Weight",
146
+ "panel.button.fontWeight.normal": "Normal (400)",
147
+ "panel.button.fontWeight.medium": "Medium (500)",
148
+ "panel.button.fontWeight.semibold": "Semibold (600)",
149
+ "panel.button.fontWeight.bold": "Bold (700)",
150
+ "panel.button.border": "Border",
151
+ "panel.button.borderNone": "None",
152
+ "panel.button.borderSolid": "Solid",
153
+ "panel.button.borderDashed": "Dashed",
154
+ "panel.button.borderDotted": "Dotted",
155
+ "panel.button.borderWidth": "Border Width",
156
+ "panel.button.borderColor": "Border Color",
157
+ "panel.button.fullWidth": "Full Width",
158
+ // property panels — image
159
+ "panel.image.title": "Image Properties",
160
+ "panel.image.imageUrl": "Image URL",
161
+ "panel.image.urlPlaceholder": "https://example.com/image.jpg",
162
+ "panel.image.altText": "Alt Text",
163
+ "panel.image.altPlaceholder": "Image description",
164
+ "panel.image.width": "Width (0 = auto)",
165
+ // property panels — hero
166
+ "panel.hero.title": "Hero Properties",
167
+ "panel.hero.backgroundUrl": "Background URL",
168
+ "panel.hero.backgroundUrlPlaceholder": "https://example.com/hero.jpg",
169
+ "panel.hero.backgroundPosition": "Background Position",
170
+ "panel.hero.mode": "Mode",
171
+ "panel.hero.modeFluidHeight": "Fluid Height",
172
+ "panel.hero.modeFixedHeight": "Fixed Height",
173
+ "panel.hero.height": "Height",
174
+ "panel.hero.width": "Width",
175
+ "panel.hero.verticalAlign": "Vertical Align",
176
+ "panel.hero.verticalAlignTop": "Top",
177
+ "panel.hero.verticalAlignMiddle": "Middle",
178
+ "panel.hero.verticalAlignBottom": "Bottom",
179
+ // property panels — navbar
180
+ "panel.navbar.title": "Navbar Properties",
181
+ "panel.navbar.links": "Links",
182
+ "panel.navbar.linkLabel": "Link",
183
+ "panel.navbar.removeLink": "Remove",
184
+ "panel.navbar.linkText": "Text",
185
+ "panel.navbar.url": "URL",
186
+ "panel.navbar.addLink": "+ Add Link",
187
+ "panel.navbar.hamburger": "Hamburger (mobile)",
188
+ "panel.navbar.hamburgerShow": "Show",
189
+ "panel.navbar.hamburgerHide": "Hide",
190
+ "panel.navbar.linkColor": "Link Color",
191
+ "panel.navbar.linkFontSize": "Link Font Size",
192
+ "panel.navbar.linkPadding": "Link Padding",
193
+ // property panels — divider
194
+ "panel.divider.title": "Divider Properties",
195
+ "panel.divider.style": "Style",
196
+ "panel.divider.styleSolid": "Solid",
197
+ "panel.divider.styleDashed": "Dashed",
198
+ "panel.divider.styleDotted": "Dotted",
199
+ "panel.divider.color": "Color",
200
+ "panel.divider.width": "Width",
201
+ "panel.divider.lineWidth": "Line Width",
202
+ // property panels — spacer
203
+ "panel.spacer.title": "Spacer Properties",
204
+ "panel.spacer.height": "Height",
205
+ // property panels — social
206
+ "panel.social.title": "Social Properties",
207
+ "panel.social.icons": "Icons",
208
+ "panel.social.iconLabel": "Icon",
209
+ "panel.social.removeIcon": "Remove",
210
+ "panel.social.network": "Network",
211
+ "panel.social.url": "URL",
212
+ "panel.social.iconUrl": "Icon URL",
213
+ "panel.social.altText": "Label (alt text)",
214
+ "panel.social.addIcon": "+ Add Icon",
215
+ "panel.social.iconSize": "Icon Size",
216
+ "panel.social.spacing": "Spacing",
217
+ // property panels — html
218
+ "panel.html.title": "HTML Properties",
219
+ "panel.html.rawHtml": "Raw HTML",
220
+ // property panels — row
221
+ "panel.row.title": "Row Properties",
222
+ "panel.row.columnLayout": "Column Layout",
223
+ "panel.row.layout1col": "1 Column",
224
+ "panel.row.layout2col": "2 Equal",
225
+ "panel.row.layout3col": "3 Equal",
226
+ "panel.row.layout4col": "4 Equal",
227
+ "panel.row.backgroundImageUrl": "Background Image URL",
228
+ "panel.row.backgroundRepeat": "Background Repeat",
229
+ "panel.row.backgroundRepeatNone": "Do not repeat",
230
+ "panel.row.backgroundRepeatTile": "Tile",
231
+ "panel.row.backgroundSize": "Background Size",
232
+ "panel.row.backgroundPosition": "Background Position",
233
+ "panel.row.fullWidth": "Full Width",
234
+ "panel.row.noStackOnMobile": "Do not stack on mobile",
235
+ "panel.row.displayCondition": "Display condition",
236
+ "panel.row.repeat": "Repeat for each",
237
+ // controls — color picker
238
+ "control.color.label": "Color",
239
+ // controls — font picker
240
+ "control.fontPicker.label": "Font Family",
241
+ // controls — link type picker
242
+ "control.linkType.ariaLabel": "Insert a special link",
243
+ "control.linkType.placeholder": "+ Special link",
244
+ "control.linkType.emailPrompt": "Email address",
245
+ "control.linkType.telPrompt": "Phone number",
246
+ // controls — spacing input
247
+ "control.spacing.top": "Top",
248
+ "control.spacing.right": "Right",
249
+ "control.spacing.bottom": "Bottom",
250
+ "control.spacing.left": "Left",
251
+ "control.spacing.topTitle": "Top (px)",
252
+ "control.spacing.rightTitle": "Right (px)",
253
+ "control.spacing.bottomTitle": "Bottom (px)",
254
+ "control.spacing.leftTitle": "Left (px)",
255
+ // controls — alignment picker
256
+ "control.alignment.left": "Align left",
257
+ "control.alignment.center": "Align center",
258
+ "control.alignment.right": "Align right",
259
+ // controls — merge tag picker
260
+ "control.mergeTag.searchPlaceholder": "Search tags...",
261
+ "control.mergeTag.noMatches": "No matching tags",
262
+ // rich text bubble toolbar
263
+ "richtext.bold": "Bold (Cmd+B)",
264
+ "richtext.italic": "Italic (Cmd+I)",
265
+ "richtext.underline": "Underline (Cmd+U)",
266
+ "richtext.strike": "Strike",
267
+ "richtext.code": "Code",
268
+ "richtext.link": "Link",
269
+ "richtext.apply": "Apply",
270
+ "richtext.removeLink": "Remove link",
271
+ "richtext.urlPlaceholder": "https://…"
272
+ };
273
+ let h = "en", b = { en: d };
274
+ function U(t, e) {
275
+ h = t || "en", b = { en: d, ...e ?? {} };
276
+ }
277
+ function r(t) {
278
+ var e;
279
+ return ((e = b[h]) == null ? void 0 : e[t]) ?? d[t] ?? t;
280
+ }
281
+ const g = {
282
+ es: () => import("./es.js"),
283
+ fr: () => import("./fr.js"),
284
+ de: () => import("./de.js"),
285
+ "pt-BR": () => import("./pt-BR.js"),
286
+ it: () => import("./it.js"),
287
+ nl: () => import("./nl.js"),
288
+ ja: () => import("./ja.js"),
289
+ "zh-CN": () => import("./zh-CN.js"),
290
+ ar: () => import("./ar.js"),
291
+ hi: () => import("./hi.js")
292
+ }, m = Object.keys(g);
293
+ async function B(t) {
294
+ const e = t.toLowerCase().replace(/_/g, "-"), l = e.split("-")[0], a = m.find((o) => o.toLowerCase() === e) ?? m.find((o) => o.toLowerCase().split("-")[0] === l);
295
+ return a ? (await g[a]()).default : void 0;
296
+ }
297
+ function N(t, e) {
298
+ return w(t, e);
299
+ }
300
+ let c = null;
301
+ function I() {
302
+ return c || (c = import("./rich-text.js").then((t) => t.default)), c;
303
+ }
304
+ const x = new Set(
305
+ "a abbr address b bdi bdo big blockquote br caption center cite code col colgroup dd del dfn div dl dt em figcaption figure font h1 h2 h3 h4 h5 h6 hr i img ins kbd li mark ol p pre q s samp small span strike strong sub sup table tbody td tfoot th thead tr tt u ul var wbr".split(" ")
306
+ ), L = new Set(
307
+ "script style iframe frame frameset object embed applet form input button select textarea option meta base link svg math noscript template title head".split(" ")
308
+ ), T = new Set(
309
+ "style class id title dir lang role href target rel name src alt width height align valign bgcolor background border cellpadding cellspacing colspan rowspan color face size start type".split(" ")
310
+ ), P = /* @__PURE__ */ new Set(["href", "src", "background"]), C = /^(?:javascript|vbscript|data(?!:image\/(?:png|gif|jpe?g|webp)[;,])):/i;
311
+ function M(t) {
312
+ if (typeof DOMParser > "u" || !t.includes("<")) return t;
313
+ const e = new DOMParser().parseFromString(`<body>${t}`, "text/html").body;
314
+ for (const l of Array.from(e.getElementsByTagName("form"))) Element.prototype.remove.call(l);
315
+ for (const l of Array.from(e.querySelectorAll("*"))) {
316
+ const a = l.localName;
317
+ if (L.has(a)) {
318
+ l.remove();
319
+ continue;
320
+ }
321
+ if (!x.has(a)) {
322
+ l.replaceWith(...Array.from(l.childNodes));
323
+ continue;
324
+ }
325
+ for (const { name: o, value: n } of Array.from(l.attributes))
326
+ (!(T.has(o) || o.startsWith("data-") || o.startsWith("aria-")) || // eslint-disable-next-line no-control-regex
327
+ P.has(o) && C.test(n.replace(/[\x00-\x20]/g, ""))) && l.removeAttribute(o);
328
+ }
329
+ return e.innerHTML;
4
330
  }
5
- class l {
331
+ class S {
6
332
  constructor() {
7
333
  this._active = null, this._listeners = /* @__PURE__ */ new Set(), this._held = !1;
8
334
  }
9
335
  setActive(e) {
10
336
  if (this._active !== e) {
11
337
  this._active = e;
12
- for (const i of this._listeners) i(e);
338
+ for (const l of this._listeners) l(e);
13
339
  }
14
340
  }
15
341
  /** Clear only if `editor` is the currently-active one (avoids races on rapid focus changes). */
@@ -40,8 +366,70 @@ class l {
40
366
  return this._listeners.add(e), () => this._listeners.delete(e);
41
367
  }
42
368
  }
43
- const h = new l();
369
+ const W = new S();
370
+ var A = Object.defineProperty, R = Object.getOwnPropertyDescriptor, u = (t, e, l, a) => {
371
+ for (var o = a > 1 ? void 0 : a ? R(e, l) : e, n = t.length - 1, p; n >= 0; n--)
372
+ (p = t[n]) && (o = (a ? p(e, l, o) : p(o)) || o);
373
+ return a && o && A(e, l, o), o;
374
+ };
375
+ let i = class extends v {
376
+ constructor() {
377
+ super(...arguments), this.linkTypes = [];
378
+ }
379
+ render() {
380
+ return this.linkTypes.length === 0 ? s`` : s`
381
+ <select aria-label=${r("control.linkType.ariaLabel")} @change=${this._onChange}>
382
+ <option value="">${r("control.linkType.placeholder")}</option>
383
+ ${this.linkTypes.map((t) => s`<option value=${t.id}>${t.label}</option>`)}
384
+ </select>
385
+ `;
386
+ }
387
+ _onChange(t) {
388
+ const e = t.target, l = e.value;
389
+ if (e.value = "", !l) return;
390
+ const a = this.linkTypes.find((n) => n.id === l);
391
+ if (!a) return;
392
+ let o;
393
+ if (a.prompt) {
394
+ const n = window.prompt(a.prompt === "email" ? r("control.linkType.emailPrompt") : r("control.linkType.telPrompt"));
395
+ if (!n || !n.trim()) return;
396
+ o = (a.prompt === "email" ? "mailto:" : "tel:") + n.trim();
397
+ } else a.href && (o = a.href);
398
+ o && this.dispatchEvent(new CustomEvent("link-type-select", {
399
+ detail: { href: o },
400
+ bubbles: !0,
401
+ composed: !0
402
+ }));
403
+ }
404
+ };
405
+ i.styles = f`
406
+ :host { display: inline-block; }
407
+ select {
408
+ height: 32px;
409
+ border: 1px solid var(--pigeon-input, #cbd5e1);
410
+ border-radius: var(--pigeon-radius-sm, 4px);
411
+ padding: 0 6px;
412
+ font-family: var(--pigeon-font);
413
+ font-size: 12px;
414
+ color: var(--pigeon-text-secondary, #64748b);
415
+ background: var(--pigeon-bg, #ffffff);
416
+ cursor: pointer;
417
+ max-width: 160px;
418
+ }
419
+ `;
420
+ u([
421
+ y({ attribute: !1 })
422
+ ], i.prototype, "linkTypes", 2);
423
+ i = u([
424
+ k("pigeon-link-type-picker")
425
+ ], i);
44
426
  export {
45
- r as l,
46
- h as r
427
+ m as B,
428
+ N as a,
429
+ B as b,
430
+ U as c,
431
+ I as l,
432
+ W as r,
433
+ M as s,
434
+ r as t
47
435
  };