@lit-pigeon/editor 0.3.4 → 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,5 +1,6 @@
1
- import { css as u, LitElement as b, html as s } from "lit";
2
- import { property as v, customElement as f } from "lit/decorators.js";
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";
3
4
  const d = {
4
5
  // toolbar
5
6
  "toolbar.undo": "Undo",
@@ -111,6 +112,7 @@ const d = {
111
112
  "panel.common.linkUrl": "Link URL",
112
113
  "panel.common.urlPlaceholder": "https://example.com",
113
114
  "panel.common.contentHtml": "Content (HTML)",
115
+ "panel.common.displayCondition": "Display condition",
114
116
  "panel.common.insertMergeTag": "Insert merge tag",
115
117
  "panel.common.tagBtn": "{ } Tag",
116
118
  "panel.common.uploadImage": "Upload Image",
@@ -121,9 +123,17 @@ const d = {
121
123
  "panel.body.contentWidth": "Content Width",
122
124
  "panel.body.fontFamily": "Font Family",
123
125
  "panel.body.contentAlignment": "Content Alignment",
126
+ "panel.body.linkColor": "Link Color",
127
+ "panel.body.linkUnderline": "Underline Links",
124
128
  "panel.body.emailName": "Email Name",
125
129
  "panel.body.previewText": "Preview Text",
126
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",
127
137
  // property panels — text
128
138
  "panel.text.title": "Text Properties",
129
139
  "panel.text.textAlign": "Text Align",
@@ -137,6 +147,13 @@ const d = {
137
147
  "panel.button.fontWeight.medium": "Medium (500)",
138
148
  "panel.button.fontWeight.semibold": "Semibold (600)",
139
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",
140
157
  "panel.button.fullWidth": "Full Width",
141
158
  // property panels — image
142
159
  "panel.image.title": "Image Properties",
@@ -208,8 +225,15 @@ const d = {
208
225
  "panel.row.layout3col": "3 Equal",
209
226
  "panel.row.layout4col": "4 Equal",
210
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",
211
233
  "panel.row.fullWidth": "Full Width",
234
+ "panel.row.noStackOnMobile": "Do not stack on mobile",
212
235
  "panel.row.displayCondition": "Display condition",
236
+ "panel.row.repeat": "Repeat for each",
213
237
  // controls — color picker
214
238
  "control.color.label": "Color",
215
239
  // controls — font picker
@@ -245,32 +269,73 @@ const d = {
245
269
  "richtext.apply": "Apply",
246
270
  "richtext.removeLink": "Remove link",
247
271
  "richtext.urlPlaceholder": "https://…"
248
- }, y = /* @__PURE__ */ new Set(["ar", "he", "fa", "ur", "ps", "sd", "dv", "yi"]);
249
- let m = "en", h = { en: d };
250
- function P(t, e) {
251
- m = t || "en", h = { en: d, ...e ?? {} };
272
+ };
273
+ let h = "en", b = { en: d };
274
+ function U(t, e) {
275
+ h = t || "en", b = { en: d, ...e ?? {} };
252
276
  }
253
277
  function r(t) {
254
278
  var e;
255
- return ((e = h[m]) == null ? void 0 : e[t]) ?? d[t] ?? t;
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;
256
296
  }
257
- function C(t, e) {
258
- if (e) return e;
259
- const a = (t || "en").toLowerCase().split(/[-_]/)[0];
260
- return y.has(a) ? "rtl" : "ltr";
297
+ function N(t, e) {
298
+ return w(t, e);
261
299
  }
262
300
  let c = null;
263
- function S() {
301
+ function I() {
264
302
  return c || (c = import("./rich-text.js").then((t) => t.default)), c;
265
303
  }
266
- class k {
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;
330
+ }
331
+ class S {
267
332
  constructor() {
268
333
  this._active = null, this._listeners = /* @__PURE__ */ new Set(), this._held = !1;
269
334
  }
270
335
  setActive(e) {
271
336
  if (this._active !== e) {
272
337
  this._active = e;
273
- for (const a of this._listeners) a(e);
338
+ for (const l of this._listeners) l(e);
274
339
  }
275
340
  }
276
341
  /** Clear only if `editor` is the currently-active one (avoids races on rapid focus changes). */
@@ -301,13 +366,13 @@ class k {
301
366
  return this._listeners.add(e), () => this._listeners.delete(e);
302
367
  }
303
368
  }
304
- const A = new k();
305
- var w = Object.defineProperty, x = Object.getOwnPropertyDescriptor, g = (t, e, a, o) => {
306
- for (var l = o > 1 ? void 0 : o ? x(e, a) : e, n = t.length - 1, p; n >= 0; n--)
307
- (p = t[n]) && (l = (o ? p(e, a, l) : p(l)) || l);
308
- return o && l && w(e, a, l), 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;
309
374
  };
310
- let i = class extends b {
375
+ let i = class extends v {
311
376
  constructor() {
312
377
  super(...arguments), this.linkTypes = [];
313
378
  }
@@ -320,24 +385,24 @@ let i = class extends b {
320
385
  `;
321
386
  }
322
387
  _onChange(t) {
323
- const e = t.target, a = e.value;
324
- if (e.value = "", !a) return;
325
- const o = this.linkTypes.find((n) => n.id === a);
326
- if (!o) return;
327
- let l;
328
- if (o.prompt) {
329
- const n = window.prompt(o.prompt === "email" ? r("control.linkType.emailPrompt") : r("control.linkType.telPrompt"));
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"));
330
395
  if (!n || !n.trim()) return;
331
- l = (o.prompt === "email" ? "mailto:" : "tel:") + n.trim();
332
- } else o.href && (l = o.href);
333
- l && this.dispatchEvent(new CustomEvent("link-type-select", {
334
- detail: { href: l },
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 },
335
400
  bubbles: !0,
336
401
  composed: !0
337
402
  }));
338
403
  }
339
404
  };
340
- i.styles = u`
405
+ i.styles = f`
341
406
  :host { display: inline-block; }
342
407
  select {
343
408
  height: 32px;
@@ -352,16 +417,19 @@ i.styles = u`
352
417
  max-width: 160px;
353
418
  }
354
419
  `;
355
- g([
356
- v({ attribute: !1 })
420
+ u([
421
+ y({ attribute: !1 })
357
422
  ], i.prototype, "linkTypes", 2);
358
- i = g([
359
- f("pigeon-link-type-picker")
423
+ i = u([
424
+ k("pigeon-link-type-picker")
360
425
  ], i);
361
426
  export {
362
- C as a,
363
- P as c,
364
- S as l,
365
- A 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,
366
434
  r as t
367
435
  };