@social-mail/social-mail-client 1.8.331 → 1.8.333
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/dist/site-editor/editor/HtmlPageEditor.d.ts +1 -1
- package/dist/site-editor/editor/HtmlPageEditor.d.ts.map +1 -1
- package/dist/site-editor/editor/HtmlPageEditor.js +2 -0
- package/dist/site-editor/editor/HtmlPageEditor.js.map +1 -1
- package/dist/site-editor/editor/ui/SelectionUI.d.ts.map +1 -1
- package/dist/site-editor/editor/ui/SelectionUI.js +57 -22
- package/dist/site-editor/editor/ui/SelectionUI.js.map +1 -1
- package/dist/site-editor-app/SiteEditorApp.pack.js +59 -22
- package/dist/site-editor-app/SiteEditorApp.pack.js.map +1 -1
- package/dist/site-editor-app/SiteEditorApp.pack.min.js +1 -1
- package/dist/site-editor-app/SiteEditorApp.pack.min.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/site-editor/editor/HtmlPageEditor.tsx +4 -1
- package/src/site-editor/editor/ui/SelectionUI.tsx +82 -33
package/package.json
CHANGED
|
@@ -95,6 +95,8 @@ export default class HtmlPageEditor extends AtomControl {
|
|
|
95
95
|
|
|
96
96
|
public maxWidth = desktopWidth;
|
|
97
97
|
|
|
98
|
+
public contentEditor: HTMLIFrameElement;
|
|
99
|
+
|
|
98
100
|
|
|
99
101
|
public get modifiedDocument() {
|
|
100
102
|
if (!this.undoRedo.changed) {
|
|
@@ -231,7 +233,6 @@ export default class HtmlPageEditor extends AtomControl {
|
|
|
231
233
|
private lastInit: Promise<void>;
|
|
232
234
|
private initCT: CancelToken;
|
|
233
235
|
|
|
234
|
-
private contentEditor: HTMLIFrameElement;
|
|
235
236
|
|
|
236
237
|
|
|
237
238
|
private readonly dropTarget: SelectedElement = new SelectedElement(this);
|
|
@@ -580,6 +581,7 @@ export default class HtmlPageEditor extends AtomControl {
|
|
|
580
581
|
@Action({ onEvent: "undo"})
|
|
581
582
|
undo() {
|
|
582
583
|
this.undoRedo?.undo();
|
|
584
|
+
this.selection.updateRect();
|
|
583
585
|
// if (!this.undoList.length) {
|
|
584
586
|
// return;
|
|
585
587
|
// }
|
|
@@ -594,6 +596,7 @@ export default class HtmlPageEditor extends AtomControl {
|
|
|
594
596
|
@Action({ onEvent: "redo"})
|
|
595
597
|
redo() {
|
|
596
598
|
this.undoRedo?.redo();
|
|
599
|
+
this.selection.updateRect();
|
|
597
600
|
// if (!this.redoList.length) {
|
|
598
601
|
// return;
|
|
599
602
|
// }
|
|
@@ -43,6 +43,9 @@ const setCapture = (editor: HtmlPageEditor, element: HTMLElement, e: PointerEven
|
|
|
43
43
|
const selectedElement = selection.element;
|
|
44
44
|
const selectedParent = selectedElement.parentElement;
|
|
45
45
|
|
|
46
|
+
const frameDocument = selectedElement.ownerDocument;
|
|
47
|
+
const frame = editor.contentEditor;
|
|
48
|
+
|
|
46
49
|
|
|
47
50
|
const insetAttribute = `${prefix}-inset`;
|
|
48
51
|
const widthAttribute = `${prefix}-width`;
|
|
@@ -52,15 +55,10 @@ const setCapture = (editor: HtmlPageEditor, element: HTMLElement, e: PointerEven
|
|
|
52
55
|
const oldHeight = selectedElement.getAttribute(heightAttribute);
|
|
53
56
|
const oldInset = selectedElement.getAttribute(insetAttribute);
|
|
54
57
|
|
|
55
|
-
let newInset;
|
|
56
|
-
let newHeight;
|
|
57
|
-
let newWidth;
|
|
58
|
-
|
|
59
58
|
const records = [] as MutationRecord[];
|
|
60
59
|
|
|
61
60
|
|
|
62
61
|
const style = selectedElement.ownerDocument.defaultView.getComputedStyle(selectedElement);
|
|
63
|
-
const { left = "0", top = "0", right = "0", bottom = "0" } = style;
|
|
64
62
|
const width = selectedParent.offsetWidth;
|
|
65
63
|
const height = selectedParent.offsetHeight;
|
|
66
64
|
|
|
@@ -70,39 +68,51 @@ const setCapture = (editor: HtmlPageEditor, element: HTMLElement, e: PointerEven
|
|
|
70
68
|
|
|
71
69
|
const d = undoRedo.beginPause();
|
|
72
70
|
|
|
71
|
+
const left = parseFloat(style.left || "0");
|
|
72
|
+
const top = parseFloat(style.top || "0");
|
|
73
|
+
const bottom = parseFloat(style.bottom || "0");
|
|
74
|
+
const right = parseFloat(style.right || "0");
|
|
75
|
+
|
|
76
|
+
let moved = false;
|
|
77
|
+
|
|
78
|
+
let changed = false;
|
|
79
|
+
|
|
73
80
|
const captureMove = (evt: PointerEvent) => {
|
|
74
81
|
const dx = evt.clientX - sx;
|
|
75
82
|
const dy = evt.clientY - sy;
|
|
83
|
+
if (dx === 0 && dy === 0) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
76
86
|
const ri = {
|
|
77
|
-
left
|
|
78
|
-
top
|
|
79
|
-
right
|
|
80
|
-
bottom
|
|
87
|
+
left,
|
|
88
|
+
top,
|
|
89
|
+
right,
|
|
90
|
+
bottom,
|
|
81
91
|
sx,
|
|
82
92
|
sy,
|
|
83
93
|
dx,
|
|
84
94
|
dy
|
|
85
95
|
};
|
|
96
|
+
changed = true;
|
|
86
97
|
const r = fx(ri);
|
|
87
|
-
|
|
88
|
-
selectedElement.setAttribute(insetAttribute,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
newWidth = ps(width + widthDiff, width) + "%";
|
|
101
|
-
selectedElement.setAttribute(widthAttribute, newWidth);
|
|
102
|
-
newHeight = ps(height + heightDiff, height) + "%";
|
|
103
|
-
selectedElement.setAttribute(heightAttribute, newHeight);
|
|
98
|
+
const inset = `${ps(r.top, height)}% ${ps(r.right, width)}% ${ps(r.bottom, height)}% ${ps(r.left, width)}%`;
|
|
99
|
+
selectedElement.setAttribute(insetAttribute, inset);
|
|
100
|
+
|
|
101
|
+
if (!r.move) {
|
|
102
|
+
moved = true;
|
|
103
|
+
let widthDiff = -r.left;
|
|
104
|
+
let heightDiff = -r.top;
|
|
105
|
+
if (ri.bottom === r.bottom) {
|
|
106
|
+
heightDiff -= r.bottom;
|
|
107
|
+
}
|
|
108
|
+
if (ri.right === r.right) {
|
|
109
|
+
widthDiff -= r.right;
|
|
104
110
|
}
|
|
105
|
-
|
|
111
|
+
const newWidth = ps(width + widthDiff, width) + "%";
|
|
112
|
+
selectedElement.setAttribute(widthAttribute, newWidth);
|
|
113
|
+
const newHeight = ps(height + heightDiff, height) + "%";
|
|
114
|
+
selectedElement.setAttribute(heightAttribute, newHeight);
|
|
115
|
+
}
|
|
106
116
|
|
|
107
117
|
setTimeout(() => {
|
|
108
118
|
selection.updateRect();
|
|
@@ -112,14 +122,47 @@ const setCapture = (editor: HtmlPageEditor, element: HTMLElement, e: PointerEven
|
|
|
112
122
|
|
|
113
123
|
element.addEventListener("pointermove", captureMove);
|
|
114
124
|
element.setPointerCapture(e.pointerId);
|
|
115
|
-
const release = (e1) => {
|
|
125
|
+
const release = (e1: PointerEvent) => {
|
|
116
126
|
element.releasePointerCapture(e.pointerId);
|
|
117
127
|
element.removeEventListener("pointermove", captureMove);
|
|
118
128
|
element.removeEventListener("pointerup", release);
|
|
119
129
|
captureMove(e1);
|
|
120
|
-
editor.commit();
|
|
121
130
|
d.resume();
|
|
122
131
|
|
|
132
|
+
if (!changed) {
|
|
133
|
+
|
|
134
|
+
// try to select an element...
|
|
135
|
+
const frameRect = frame.getBoundingClientRect();
|
|
136
|
+
let { clientX, clientY } = e1;
|
|
137
|
+
clientX -= frameRect.left;
|
|
138
|
+
clientY -= frameRect.top;
|
|
139
|
+
|
|
140
|
+
const elementAtPoint = frameDocument.elementFromPoint(clientX, clientY);
|
|
141
|
+
if (!elementAtPoint) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (elementAtPoint === selectedElement) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const body = frameDocument.body;
|
|
150
|
+
|
|
151
|
+
let start = elementAtPoint;
|
|
152
|
+
while(start) {
|
|
153
|
+
if (start === selectedParent) {
|
|
154
|
+
// we need to select different child
|
|
155
|
+
editor.selection.update(elementAtPoint as any);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
start = start.parentElement;
|
|
159
|
+
if (start === body) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
123
166
|
// push records...
|
|
124
167
|
records.push({
|
|
125
168
|
type: "attributes",
|
|
@@ -129,7 +172,7 @@ const setCapture = (editor: HtmlPageEditor, element: HTMLElement, e: PointerEven
|
|
|
129
172
|
attributeNamespace: "",
|
|
130
173
|
} as MutationRecord);
|
|
131
174
|
|
|
132
|
-
if (
|
|
175
|
+
if (moved) {
|
|
133
176
|
records.push({
|
|
134
177
|
type: "attributes",
|
|
135
178
|
oldValue: oldWidth,
|
|
@@ -137,8 +180,6 @@ const setCapture = (editor: HtmlPageEditor, element: HTMLElement, e: PointerEven
|
|
|
137
180
|
attributeName: widthAttribute,
|
|
138
181
|
attributeNamespace: "",
|
|
139
182
|
} as MutationRecord);
|
|
140
|
-
}
|
|
141
|
-
if (newHeight) {
|
|
142
183
|
records.push({
|
|
143
184
|
type: "attributes",
|
|
144
185
|
oldValue: oldHeight,
|
|
@@ -149,6 +190,13 @@ const setCapture = (editor: HtmlPageEditor, element: HTMLElement, e: PointerEven
|
|
|
149
190
|
}
|
|
150
191
|
|
|
151
192
|
undoRedo.observe(records);
|
|
193
|
+
editor.commit();
|
|
194
|
+
|
|
195
|
+
setTimeout(() => {
|
|
196
|
+
selection.updateRect();
|
|
197
|
+
hover.updateRect();
|
|
198
|
+
}, 1);
|
|
199
|
+
|
|
152
200
|
};
|
|
153
201
|
element.addEventListener("pointerup", release);
|
|
154
202
|
};
|
|
@@ -216,7 +264,8 @@ const eventPointerDown = (editor: HtmlPageEditor, e: PointerEvent) => {
|
|
|
216
264
|
|
|
217
265
|
export function SelectionUI() {
|
|
218
266
|
return <selected-element data-element="selection"
|
|
219
|
-
data-edit={BindEditor.oneWay((e) => /
|
|
267
|
+
data-edit={BindEditor.oneWay((e) => /relative/i.test(e.selection.parentStyle.position)
|
|
268
|
+
&& /absolute|fixed/i.test(e.selection.currentStyle.position) ? "1" : null)}
|
|
220
269
|
event-pointerdown={BindEditor.event(eventPointerDown as any)}
|
|
221
270
|
style-left={BindEditor.oneWay((e) => e.selection.left)}
|
|
222
271
|
style-top={BindEditor.oneWay((e) => e.selection.top)}
|