@emabuild/core 0.0.1 → 0.0.2

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.
@@ -8,6 +8,10 @@ export declare class RowRenderer extends RowRenderer_base {
8
8
  row: DesignRow;
9
9
  store: EditorStore;
10
10
  toolRegistry: ToolRegistry;
11
+ private handleMoveUp;
12
+ private handleMoveDown;
13
+ private handleDuplicate;
14
+ private handleDelete;
11
15
  render(): import('lit').TemplateResult<1>;
12
16
  }
13
17
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"row-renderer.d.ts","sourceRoot":"","sources":["../../src/canvas/row-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,sBAAsB,CAAC;;AAE9B,qBACa,WAAY,SAAQ,gBAA2B;IAC1D,MAAM,CAAC,MAAM,0BAoCX;IAE8B,GAAG,EAAG,SAAS,CAAC;IAChB,KAAK,EAAG,WAAW,CAAC;IACpB,YAAY,EAAG,YAAY,CAAC;IAE5D,MAAM;CA+BP"}
1
+ {"version":3,"file":"row-renderer.d.ts","sourceRoot":"","sources":["../../src/canvas/row-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,sBAAsB,CAAC;;AAE9B,qBACa,WAAY,SAAQ,gBAA2B;IAC1D,MAAM,CAAC,MAAM,0BAuDX;IAE8B,GAAG,EAAG,SAAS,CAAC;IAChB,KAAK,EAAG,WAAW,CAAC;IACpB,YAAY,EAAG,YAAY,CAAC;IAE5D,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,YAAY;IAKpB,MAAM;CA4CP"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { E, M, T } from "./mail-editor-DzI7SmSe.js";
1
+ import { E, M, T } from "./mail-editor-CoB2C5CT.js";
2
2
  export {
3
3
  E as EditorStore,
4
4
  M as MailEditorElement,
@@ -246,6 +246,34 @@ class EditorStore {
246
246
  this.notify();
247
247
  this.emitUpdate("row_reordered");
248
248
  }
249
+ duplicateRow(rowId) {
250
+ const row = this.findRow(rowId);
251
+ if (!row) return;
252
+ this.pushHistory();
253
+ const cloned = deepClone(row);
254
+ const rowNum = this.counterManager.next("u_row");
255
+ cloned.id = `u_row_${rowNum}`;
256
+ cloned.values._meta = { htmlID: cloned.id, htmlClassNames: "u_row" };
257
+ for (const col of cloned.columns) {
258
+ const colNum = this.counterManager.next("u_column");
259
+ col.id = `u_column_${colNum}`;
260
+ col.values._meta = { htmlID: col.id, htmlClassNames: "u_column" };
261
+ for (const content of col.contents) {
262
+ const cNum = this.counterManager.next(`u_content_${content.type}`);
263
+ content.id = `u_content_${content.type}_${cNum}`;
264
+ content.values._meta = { htmlID: content.id, htmlClassNames: `u_content_${content.type}` };
265
+ }
266
+ }
267
+ const rows = this.design.body.rows;
268
+ const idx = rows.findIndex((r) => r.id === rowId);
269
+ rows.splice(idx + 1, 0, cloned);
270
+ this.syncCounters();
271
+ this.notify();
272
+ this.emitUpdate("row_added", cloned);
273
+ }
274
+ getRowIndex(rowId) {
275
+ return this.design.body.rows.findIndex((r) => r.id === rowId);
276
+ }
249
277
  updateRowValues(rowId, patch) {
250
278
  const row = this.findRow(rowId);
251
279
  if (!row) return;
@@ -813,7 +841,7 @@ const textTool = {
813
841
  title: "Text",
814
842
  options: {
815
843
  text: {
816
- label: "Text",
844
+ label: "Text Content",
817
845
  defaultValue: '<p style="font-size: 14px;">This is a new text block. Change the text.</p>',
818
846
  widget: "rich_text"
819
847
  }
@@ -824,8 +852,24 @@ const textTool = {
824
852
  options: {
825
853
  color: { label: "Text Color", defaultValue: "#000000", widget: "color_picker" },
826
854
  backgroundColor: { label: "Background Color", defaultValue: "", widget: "color_picker" },
827
- lineHeight: { label: "Line Height", defaultValue: "140%", widget: "text" },
828
- linkStyle: { label: "Link Style", defaultValue: void 0, widget: "link_style" }
855
+ textAlign: {
856
+ label: "Text Align",
857
+ defaultValue: "left",
858
+ widget: "alignment"
859
+ },
860
+ lineHeight: {
861
+ label: "Line Height",
862
+ defaultValue: "140%",
863
+ widget: "dropdown",
864
+ widgetParams: { options: [
865
+ { label: "100%", value: "100%" },
866
+ { label: "120%", value: "120%" },
867
+ { label: "140%", value: "140%" },
868
+ { label: "160%", value: "160%" },
869
+ { label: "180%", value: "180%" },
870
+ { label: "200%", value: "200%" }
871
+ ] }
872
+ }
829
873
  }
830
874
  },
831
875
  spacing: {
@@ -919,18 +963,57 @@ const headingTool = {
919
963
  style: {
920
964
  title: "Style",
921
965
  options: {
922
- fontSize: { label: "Font Size", defaultValue: "22px", widget: "text" },
966
+ fontSize: {
967
+ label: "Font Size",
968
+ defaultValue: "22px",
969
+ widget: "dropdown",
970
+ widgetParams: { options: [
971
+ { label: "14px", value: "14px" },
972
+ { label: "16px", value: "16px" },
973
+ { label: "18px", value: "18px" },
974
+ { label: "20px", value: "20px" },
975
+ { label: "22px", value: "22px" },
976
+ { label: "26px", value: "26px" },
977
+ { label: "30px", value: "30px" },
978
+ { label: "36px", value: "36px" },
979
+ { label: "48px", value: "48px" },
980
+ { label: "60px", value: "60px" }
981
+ ] }
982
+ },
923
983
  color: { label: "Text Color", defaultValue: "#000000", widget: "color_picker" },
924
- textAlign: { label: "Text Align", defaultValue: "left", widget: "text" },
925
- fontWeight: { label: "Font Weight", defaultValue: "700", widget: "text" },
926
- lineHeight: { label: "Line Height", defaultValue: "140%", widget: "text" },
984
+ textAlign: { label: "Text Align", defaultValue: "left", widget: "alignment" },
985
+ fontWeight: {
986
+ label: "Font Weight",
987
+ defaultValue: "700",
988
+ widget: "dropdown",
989
+ widgetParams: { options: [
990
+ { label: "Normal", value: "400" },
991
+ { label: "Medium", value: "500" },
992
+ { label: "Semi Bold", value: "600" },
993
+ { label: "Bold", value: "700" },
994
+ { label: "Extra Bold", value: "800" }
995
+ ] }
996
+ },
997
+ lineHeight: {
998
+ label: "Line Height",
999
+ defaultValue: "140%",
1000
+ widget: "dropdown",
1001
+ widgetParams: { options: [
1002
+ { label: "100%", value: "100%" },
1003
+ { label: "120%", value: "120%" },
1004
+ { label: "140%", value: "140%" },
1005
+ { label: "160%", value: "160%" },
1006
+ { label: "180%", value: "180%" },
1007
+ { label: "200%", value: "200%" }
1008
+ ] }
1009
+ },
927
1010
  letterSpacing: { label: "Letter Spacing", defaultValue: "normal", widget: "text" }
928
1011
  }
929
1012
  },
930
1013
  spacing: {
931
1014
  title: "Spacing",
932
1015
  options: {
933
- containerPadding: { label: "Padding", defaultValue: "10px", widget: "text" }
1016
+ containerPadding: { label: "Padding", defaultValue: "10px", widget: "padding" }
934
1017
  }
935
1018
  },
936
1019
  general: {
@@ -1009,13 +1092,13 @@ const paragraphTool = {
1009
1092
  color: { label: "Text Color", defaultValue: "#374151", widget: "color_picker" },
1010
1093
  lineHeight: { label: "Line Height", defaultValue: "160%", widget: "text" },
1011
1094
  letterSpacing: { label: "Letter Spacing", defaultValue: "normal", widget: "text" },
1012
- textAlign: { label: "Text Align", defaultValue: "left", widget: "text" }
1095
+ textAlign: { label: "Text Align", defaultValue: "left", widget: "alignment" }
1013
1096
  }
1014
1097
  },
1015
1098
  spacing: {
1016
1099
  title: "Spacing",
1017
1100
  options: {
1018
- containerPadding: { label: "Padding", defaultValue: "10px", widget: "text" }
1101
+ containerPadding: { label: "Padding", defaultValue: "10px", widget: "padding" }
1019
1102
  }
1020
1103
  }
1021
1104
  },
@@ -1069,16 +1152,26 @@ const imageTool = {
1069
1152
  style: {
1070
1153
  title: "Style",
1071
1154
  options: {
1072
- width: { label: "Width", defaultValue: "100%", widget: "text" },
1073
- maxWidth: { label: "Max Width", defaultValue: "100%", widget: "text" },
1074
- align: { label: "Align", defaultValue: "center", widget: "text" },
1155
+ width: {
1156
+ label: "Width",
1157
+ defaultValue: "100%",
1158
+ widget: "dropdown",
1159
+ widgetParams: { options: [
1160
+ { label: "Auto", value: "auto" },
1161
+ { label: "25%", value: "25%" },
1162
+ { label: "50%", value: "50%" },
1163
+ { label: "75%", value: "75%" },
1164
+ { label: "100%", value: "100%" }
1165
+ ] }
1166
+ },
1167
+ align: { label: "Align", defaultValue: "center", widget: "alignment" },
1075
1168
  borderRadius: { label: "Border Radius", defaultValue: "0px", widget: "text" }
1076
1169
  }
1077
1170
  },
1078
1171
  spacing: {
1079
1172
  title: "Spacing",
1080
1173
  options: {
1081
- containerPadding: { label: "Padding", defaultValue: "10px", widget: "text" }
1174
+ containerPadding: { label: "Padding", defaultValue: "10px", widget: "padding" }
1082
1175
  }
1083
1176
  },
1084
1177
  general: {
@@ -1165,12 +1258,41 @@ const buttonTool = {
1165
1258
  options: {
1166
1259
  backgroundColor: { label: "Button Color", defaultValue: "#3b82f6", widget: "color_picker" },
1167
1260
  textColor: { label: "Text Color", defaultValue: "#ffffff", widget: "color_picker" },
1168
- fontSize: { label: "Font Size", defaultValue: "14px", widget: "text" },
1169
- fontWeight: { label: "Font Weight", defaultValue: "700", widget: "text" },
1261
+ fontSize: {
1262
+ label: "Font Size",
1263
+ defaultValue: "14px",
1264
+ widget: "dropdown",
1265
+ widgetParams: { options: [
1266
+ { label: "12px", value: "12px" },
1267
+ { label: "13px", value: "13px" },
1268
+ { label: "14px", value: "14px" },
1269
+ { label: "16px", value: "16px" },
1270
+ { label: "18px", value: "18px" },
1271
+ { label: "20px", value: "20px" }
1272
+ ] }
1273
+ },
1274
+ fontWeight: {
1275
+ label: "Font Weight",
1276
+ defaultValue: "700",
1277
+ widget: "dropdown",
1278
+ widgetParams: { options: [
1279
+ { label: "Normal", value: "400" },
1280
+ { label: "Bold", value: "700" }
1281
+ ] }
1282
+ },
1170
1283
  borderRadius: { label: "Border Radius", defaultValue: "4px", widget: "text" },
1171
- buttonWidth: { label: "Width", defaultValue: "auto", widget: "text" },
1172
- textAlign: { label: "Align", defaultValue: "center", widget: "text" },
1173
- buttonPadding: { label: "Button Padding", defaultValue: "10px 20px", widget: "text" },
1284
+ buttonWidth: {
1285
+ label: "Width",
1286
+ defaultValue: "auto",
1287
+ widget: "dropdown",
1288
+ widgetParams: { options: [
1289
+ { label: "Auto", value: "auto" },
1290
+ { label: "100%", value: "100%" },
1291
+ { label: "50%", value: "50%" }
1292
+ ] }
1293
+ },
1294
+ textAlign: { label: "Align", defaultValue: "center", widget: "alignment" },
1295
+ buttonPadding: { label: "Button Padding", defaultValue: "10px 20px", widget: "padding" },
1174
1296
  borderColor: { label: "Border Color", defaultValue: "", widget: "color_picker" },
1175
1297
  borderWidth: { label: "Border Width", defaultValue: "0px", widget: "text" }
1176
1298
  }
@@ -1178,7 +1300,7 @@ const buttonTool = {
1178
1300
  spacing: {
1179
1301
  title: "Spacing",
1180
1302
  options: {
1181
- containerPadding: { label: "Padding", defaultValue: "10px", widget: "text" }
1303
+ containerPadding: { label: "Padding", defaultValue: "10px", widget: "padding" }
1182
1304
  }
1183
1305
  },
1184
1306
  general: {
@@ -1279,7 +1401,17 @@ const dividerTool = {
1279
1401
  title: "Style",
1280
1402
  options: {
1281
1403
  borderTopWidth: { label: "Width", defaultValue: "1px", widget: "text" },
1282
- borderTopStyle: { label: "Style", defaultValue: "solid", widget: "text" },
1404
+ borderTopStyle: {
1405
+ label: "Style",
1406
+ defaultValue: "solid",
1407
+ widget: "dropdown",
1408
+ widgetParams: { options: [
1409
+ { label: "Solid", value: "solid" },
1410
+ { label: "Dashed", value: "dashed" },
1411
+ { label: "Dotted", value: "dotted" },
1412
+ { label: "Double", value: "double" }
1413
+ ] }
1414
+ },
1283
1415
  borderTopColor: { label: "Color", defaultValue: "#cccccc", widget: "color_picker" },
1284
1416
  width: { label: "Line Width", defaultValue: "100%", widget: "text" }
1285
1417
  }
@@ -1287,7 +1419,7 @@ const dividerTool = {
1287
1419
  spacing: {
1288
1420
  title: "Spacing",
1289
1421
  options: {
1290
- containerPadding: { label: "Padding", defaultValue: "10px", widget: "text" }
1422
+ containerPadding: { label: "Padding", defaultValue: "10px", widget: "padding" }
1291
1423
  }
1292
1424
  },
1293
1425
  general: {
@@ -2151,11 +2283,30 @@ let MailEditorElement = class extends LitElement {
2151
2283
  this.dragManager = null;
2152
2284
  this.callbacks = /* @__PURE__ */ new Map();
2153
2285
  this.unsubscribe = null;
2286
+ this._handleKeydown = (e) => {
2287
+ const mod = e.metaKey || e.ctrlKey;
2288
+ const tag = e.target?.tagName;
2289
+ if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return;
2290
+ if (mod && e.key === "z" && !e.shiftKey) {
2291
+ e.preventDefault();
2292
+ this.store.undo();
2293
+ } else if (mod && (e.key === "y" || e.key === "z" && e.shiftKey)) {
2294
+ e.preventDefault();
2295
+ this.store.redo();
2296
+ } else if ((e.key === "Delete" || e.key === "Backspace") && this.store.selectedId) {
2297
+ e.preventDefault();
2298
+ this.store.removeContent(this.store.selectedId);
2299
+ } else if (e.key === "Escape") {
2300
+ this.store.select(null);
2301
+ }
2302
+ };
2154
2303
  }
2155
2304
  connectedCallback() {
2156
2305
  super.connectedCallback();
2157
2306
  this.registerBuiltInTools();
2158
2307
  this.applyOptions();
2308
+ this.setAttribute("tabindex", "0");
2309
+ this.addEventListener("keydown", this._handleKeydown);
2159
2310
  }
2160
2311
  firstUpdated() {
2161
2312
  this.dragManager = new DragManager(this.store, this.toolRegistry, this.shadowRoot);
@@ -2174,6 +2325,7 @@ let MailEditorElement = class extends LitElement {
2174
2325
  this.dragManager?.detach();
2175
2326
  this.unsubscribe?.();
2176
2327
  this.store.events.removeAllListeners();
2328
+ this.removeEventListener("keydown", this._handleKeydown);
2177
2329
  }
2178
2330
  // ----------------------------------------------------------
2179
2331
  // Public API — mirrors Unlayer
@@ -2283,4 +2435,4 @@ export {
2283
2435
  MailEditorElement as M,
2284
2436
  ToolRegistry as T
2285
2437
  };
2286
- //# sourceMappingURL=mail-editor-DzI7SmSe.js.map
2438
+ //# sourceMappingURL=mail-editor-CoB2C5CT.js.map