@social-mail/social-mail-client 1.8.433 → 1.8.435

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.
Files changed (52) hide show
  1. package/dist/site-editor/editor/EditingSymbols.d.ts +2 -0
  2. package/dist/site-editor/editor/EditingSymbols.d.ts.map +1 -0
  3. package/dist/site-editor/editor/EditingSymbols.js +12 -0
  4. package/dist/site-editor/editor/EditingSymbols.js.map +1 -0
  5. package/dist/site-editor/editor/HtmlPageEditor.d.ts.map +1 -1
  6. package/dist/site-editor/editor/HtmlPageEditor.global.css +1 -1
  7. package/dist/site-editor/editor/HtmlPageEditor.global.css.map +1 -1
  8. package/dist/site-editor/editor/HtmlPageEditor.js +5 -11
  9. package/dist/site-editor/editor/HtmlPageEditor.js.map +1 -1
  10. package/dist/site-editor/editor/SelectedElement.js +2 -2
  11. package/dist/site-editor/editor/SelectedElement.js.map +1 -1
  12. package/dist/site-editor/editor/UndoRedo.d.ts.map +1 -1
  13. package/dist/site-editor/editor/UndoRedo.js +7 -2
  14. package/dist/site-editor/editor/UndoRedo.js.map +1 -1
  15. package/dist/site-editor/editor/guides/UIGuides.d.ts +12 -0
  16. package/dist/site-editor/editor/guides/UIGuides.d.ts.map +1 -0
  17. package/dist/site-editor/editor/guides/UIGuides.global.css +2 -0
  18. package/dist/site-editor/editor/guides/UIGuides.global.css.map +1 -0
  19. package/dist/site-editor/editor/guides/UIGuides.js +25 -0
  20. package/dist/site-editor/editor/guides/UIGuides.js.map +1 -0
  21. package/dist/site-editor/editor/ui/SelectionUI.d.ts.map +1 -1
  22. package/dist/site-editor/editor/ui/SelectionUI.global.css +1 -1
  23. package/dist/site-editor/editor/ui/SelectionUI.global.css.map +1 -1
  24. package/dist/site-editor/editor/ui/SelectionUI.js +68 -40
  25. package/dist/site-editor/editor/ui/SelectionUI.js.map +1 -1
  26. package/dist/site-editor/editor/ui/SnapGuides.d.ts +36 -0
  27. package/dist/site-editor/editor/ui/SnapGuides.d.ts.map +1 -0
  28. package/dist/site-editor/editor/ui/SnapGuides.js +180 -0
  29. package/dist/site-editor/editor/ui/SnapGuides.js.map +1 -0
  30. package/dist/site-editor-app/SiteEditorApp.pack.global.css +1 -1
  31. package/dist/site-editor-app/SiteEditorApp.pack.global.css.map +1 -1
  32. package/dist/site-editor-app/SiteEditorApp.pack.js +309 -56
  33. package/dist/site-editor-app/SiteEditorApp.pack.js.map +1 -1
  34. package/dist/site-editor-app/SiteEditorApp.pack.min.js +1 -1
  35. package/dist/site-editor-app/SiteEditorApp.pack.min.js.map +1 -1
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/dist/web/AppIndex.pack.local.css +1 -1
  38. package/dist/web/AppIndex.pack.local.css.map +1 -1
  39. package/dist/web/drawer/AppDrawer.local.css +1 -1
  40. package/dist/web/drawer/AppDrawer.local.css.map +1 -1
  41. package/package.json +1 -1
  42. package/src/site-editor/editor/EditingSymbols.ts +1 -0
  43. package/src/site-editor/editor/HtmlPageEditor.global.css +0 -18
  44. package/src/site-editor/editor/HtmlPageEditor.tsx +2 -7
  45. package/src/site-editor/editor/SelectedElement.tsx +2 -2
  46. package/src/site-editor/editor/UndoRedo.tsx +4 -0
  47. package/src/site-editor/editor/guides/UIGuides.global.css +42 -0
  48. package/src/site-editor/editor/guides/UIGuides.tsx +29 -0
  49. package/src/site-editor/editor/ui/SelectionUI.global.css +2 -1
  50. package/src/site-editor/editor/ui/SelectionUI.tsx +93 -41
  51. package/src/site-editor/editor/ui/SnapGuides.ts +222 -0
  52. package/src/web/drawer/AppDrawer.local.css +1 -0
@@ -0,0 +1,222 @@
1
+ import HtmlPageEditor from "../HtmlPageEditor";
2
+
3
+ const uiGuides = Symbol("ui-guides");
4
+
5
+ interface IRect {
6
+ left;
7
+ top;
8
+ right;
9
+ bottom;
10
+ dx;
11
+ dy;
12
+ mx;
13
+ my;
14
+ width,
15
+ height,
16
+ // sx;
17
+ // sy;
18
+ move?: boolean;
19
+ }
20
+ export default class SnapGuides {
21
+
22
+ hGuide: HTMLDivElement;
23
+ vGuide: HTMLDivElement;
24
+ uiGuides: HTMLElement;
25
+
26
+ all = [] as { left, top, right, bottom, midX, midY, src }[];
27
+
28
+ constructor(
29
+ private direction: string,
30
+ private editor: HtmlPageEditor,
31
+ private e: HTMLElement
32
+ ) {
33
+ if(!/selected/i.test(e.tagName)) {
34
+ e = e.parentElement;
35
+ }
36
+
37
+ const pe = e.parentElement;
38
+
39
+ const guides = (e[uiGuides] ??= editor.element.querySelector("ui-guides")) as HTMLElement;
40
+
41
+ this.hGuide = e["hGuide"] ??= guides.querySelector("h-guide");
42
+ this.vGuide = e["vGuide"] ??= guides.querySelector("v-guide");
43
+
44
+
45
+ const { all } = this;
46
+ const current = this.editor.selection.element;
47
+
48
+ const parent = current.parentElement;
49
+
50
+ let start = current.parentElement;
51
+ all.push({
52
+ src: start,
53
+ left: 0,
54
+ top: 0,
55
+ right: start.offsetWidth,
56
+ bottom: start.offsetHeight,
57
+ midX: start.offsetWidth /2,
58
+ midY: start.offsetHeight / 2
59
+ });
60
+ start = start.firstElementChild as HTMLElement;
61
+ if(start) {
62
+ if (start.offsetParent === parent && start !== current) {
63
+ all.push({
64
+ src: start,
65
+ left: start.offsetLeft,
66
+ top: start.offsetTop,
67
+ right: start.offsetLeft + start.offsetWidth,
68
+ bottom: start.offsetTop + start.offsetHeight,
69
+ midX: start.offsetLeft + (start.offsetWidth /2),
70
+ midY: start.offsetTop + (start.offsetHeight / 2)
71
+ });
72
+ }
73
+ do {
74
+ if (start !== current) {
75
+ all.push({
76
+ src: start,
77
+ left: start.offsetLeft,
78
+ top: start.offsetTop,
79
+ right: start.offsetLeft + start.offsetWidth,
80
+ bottom: start.offsetTop + start.offsetHeight,
81
+ midX: start.offsetLeft + (start.offsetWidth /2),
82
+ midY: start.offsetTop + (start.offsetHeight / 2)
83
+ });
84
+ }
85
+ start = start.nextElementSibling as HTMLElement;
86
+ } while(start);
87
+ }
88
+ console.log(all);
89
+ }
90
+
91
+ snap(rect: IRect) {
92
+
93
+ let moving = false;
94
+ let setLeft = false;
95
+ let setTop = false;
96
+
97
+ switch(this.direction) {
98
+ case "none":
99
+ return rect;
100
+ case "move":
101
+ moving = true;
102
+ setLeft = true;
103
+ setTop = true;
104
+ break;
105
+ case "lt":
106
+ setLeft = true;
107
+ setTop = true;
108
+ break;
109
+ case "rt":
110
+ setTop = true;
111
+ break;
112
+ case "lb":
113
+ setLeft = true;
114
+ break;
115
+ case "rb":
116
+ break;
117
+ }
118
+
119
+
120
+ const mpX = rect.mx;
121
+ const mpY = rect.my;
122
+
123
+ const x = rect.left;
124
+ const y = rect.top;
125
+
126
+ const rx = x + rect.width;
127
+ const ry = y + rect.height;
128
+
129
+ let vl = void 0 as number;
130
+ let hl = void 0 as number;
131
+
132
+ let dx;
133
+ let dy;
134
+ let fdx;
135
+ let fdy;
136
+
137
+ const range = 2;
138
+
139
+ for (const { left, top, right, midX, bottom, midY} of this.all) {
140
+ if (!vl) {
141
+ dx = mpX - midX;
142
+ if (dx >= -range && dx <= range) {
143
+ vl = midX;
144
+ fdx = dx;
145
+ } else {
146
+ dx = x - left;
147
+ if (dx >= -range && dx <= range) {
148
+ vl = left;
149
+ fdx = dx;
150
+ } else {
151
+ dx = rx - (right);
152
+ if(dx >= -range && dx <= range) {
153
+ vl = right;
154
+ fdx = dx;
155
+ }
156
+ }
157
+ }
158
+ }
159
+ if (!hl) {
160
+ dy = mpY - midY;
161
+ if (dy >= -range && dy <= range) {
162
+ hl = midY;
163
+ fdy = dy;
164
+ } else {
165
+ dy = y - top;
166
+ if (dy >= -range && dy <= range) {
167
+ hl = top;
168
+ fdy = dy;
169
+ } else {
170
+ dy = ry - (bottom);
171
+ if(dx >= -range && dx <= range) {
172
+ hl = bottom;
173
+ fdy = dy;
174
+ }
175
+ }
176
+ }
177
+ }
178
+ }
179
+
180
+ const v = this.vGuide;
181
+ if (vl) {
182
+ // if (moving) {
183
+ // rect.left += fdx;
184
+ // rect.right -= fdx;
185
+ // } else {
186
+ // if (setLeft) {
187
+ // rect.left += fdx;
188
+ // } else {
189
+ // rect.right -= fdx;
190
+ // }
191
+ // }
192
+ v.style.left = vl + "px";
193
+ } else {
194
+ v.removeAttribute("style");
195
+ }
196
+
197
+ const h = this.hGuide;
198
+ if (hl) {
199
+ // if (moving) {
200
+ // rect.top += fdy;
201
+ // rect.bottom -= fdy;
202
+ // } else {
203
+ // if (setTop) {
204
+ // rect.top += fdy;
205
+ // } else {
206
+ // rect.bottom -= fdy;
207
+ // }
208
+ // }
209
+ h.style.top = hl + "px";
210
+ } else {
211
+ h.removeAttribute("style");
212
+ }
213
+
214
+ return rect;
215
+ }
216
+
217
+ dispose() {
218
+ const { hGuide, vGuide } = this;
219
+ hGuide.removeAttribute("style");
220
+ vGuide.removeAttribute("style");
221
+ }
222
+ }
@@ -15,6 +15,7 @@ drawer-menu {
15
15
  & input {
16
16
  width: 100%;
17
17
  margin-left: 16px;
18
+ padding-right: 16px;
18
19
  border-radius: 0;
19
20
  border-bottom: solid 1px transparent;
20
21
  &:focus {