@social-mail/social-mail-client 1.8.342 → 1.8.343
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/ui/SelectionUI.d.ts.map +1 -1
- package/dist/site-editor/editor/ui/SelectionUI.js +59 -94
- package/dist/site-editor/editor/ui/SelectionUI.js.map +1 -1
- package/dist/site-editor-app/SiteEditorApp.pack.js +59 -94
- 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/ui/SelectionUI.tsx +70 -123
package/package.json
CHANGED
|
@@ -7,8 +7,6 @@ import { BindEditor } from "../../properties/controls/PropertyEditor";
|
|
|
7
7
|
import "./SelectionUI.global.css";
|
|
8
8
|
import type HtmlPageEditor from "../HtmlPageEditor";
|
|
9
9
|
import { mobileScreenWidth, tabletScreenWidth } from "../sizes";
|
|
10
|
-
import type { SelectedElement } from "../SelectedElement";
|
|
11
|
-
import UndoRedo from "../UndoRedo";
|
|
12
10
|
declare global {
|
|
13
11
|
namespace JSX {
|
|
14
12
|
interface IntrinsicElements {
|
|
@@ -31,108 +29,49 @@ interface IRect {
|
|
|
31
29
|
|
|
32
30
|
const ps = (v, max) => (v* 100 / (max || 1)).toFixed(2);
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
: "styler-desktop");
|
|
68
|
-
|
|
69
|
-
const { selection, hover } = editor;
|
|
70
|
-
const selectedElement = selection.element;
|
|
71
|
-
const selectedParent = selectedElement.parentElement;
|
|
72
|
-
|
|
73
|
-
this.selectedElement = selectedElement;
|
|
74
|
-
this.selectedParent = selectedParent;
|
|
75
|
-
this.selection = selection;
|
|
76
|
-
this.hover = hover;
|
|
77
|
-
// const frameDocument = selectedElement.ownerDocument;
|
|
78
|
-
// const frame = editor.contentEditor;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const insetAttribute = `${prefix}-inset`;
|
|
82
|
-
const widthAttribute = `${prefix}-width`;
|
|
83
|
-
const heightAttribute = `${prefix}-height`;
|
|
84
|
-
|
|
85
|
-
this.insetAttribute = insetAttribute;
|
|
86
|
-
this.widthAttribute = widthAttribute;
|
|
87
|
-
this.heightAttribute = heightAttribute;
|
|
88
|
-
|
|
89
|
-
const oldWidth = selectedElement.getAttribute(widthAttribute);
|
|
90
|
-
const oldHeight = selectedElement.getAttribute(heightAttribute);
|
|
91
|
-
const oldInset = selectedElement.getAttribute(insetAttribute);
|
|
92
|
-
|
|
93
|
-
const style = selectedElement.ownerDocument.defaultView.getComputedStyle(selectedElement);
|
|
94
|
-
const width = selectedParent.offsetWidth;
|
|
95
|
-
const height = selectedParent.offsetHeight;
|
|
96
|
-
|
|
97
|
-
const left = parseFloat(style.left || "0");
|
|
98
|
-
const top = parseFloat(style.top || "0");
|
|
99
|
-
const bottom = parseFloat(style.bottom || "0");
|
|
100
|
-
const right = parseFloat(style.right || "0");
|
|
101
|
-
|
|
102
|
-
this.left = left;
|
|
103
|
-
this.top = top;
|
|
104
|
-
this.bottom = bottom;
|
|
105
|
-
this.right = right;
|
|
106
|
-
this.width = width;
|
|
107
|
-
this.height = height;
|
|
108
|
-
this.oldWidth = oldWidth;
|
|
109
|
-
this.oldHeight = oldHeight;
|
|
110
|
-
this.oldInset = oldInset;
|
|
111
|
-
|
|
112
|
-
const { undoRedo } = editor;
|
|
113
|
-
this.undoRedo = undoRedo;
|
|
114
|
-
|
|
115
|
-
const d = undoRedo.beginPause();
|
|
116
|
-
|
|
117
|
-
this.d = d;
|
|
118
|
-
this.resized = false;
|
|
119
|
-
}
|
|
32
|
+
const beginDrag = (editor: HtmlPageEditor, element: HTMLElement) => {
|
|
33
|
+
|
|
34
|
+
const prefix = editor.maxWidth === tabletScreenWidth
|
|
35
|
+
? "styler-tablet"
|
|
36
|
+
: (editor.maxWidth === mobileScreenWidth
|
|
37
|
+
? "styler-mobile"
|
|
38
|
+
: "styler-desktop");
|
|
39
|
+
|
|
40
|
+
const { selection, hover } = editor;
|
|
41
|
+
const selectedElement = selection.element;
|
|
42
|
+
const selectedParent = selectedElement.parentElement;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
const insetAttribute = `${prefix}-inset`;
|
|
47
|
+
const widthAttribute = `${prefix}-width`;
|
|
48
|
+
const heightAttribute = `${prefix}-height`;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
const oldWidth = selectedElement.getAttribute(widthAttribute);
|
|
52
|
+
const oldHeight = selectedElement.getAttribute(heightAttribute);
|
|
53
|
+
const oldInset = selectedElement.getAttribute(insetAttribute);
|
|
54
|
+
|
|
55
|
+
const style = selectedElement.ownerDocument.defaultView.getComputedStyle(selectedElement);
|
|
56
|
+
const width = selectedParent.offsetWidth;
|
|
57
|
+
const height = selectedParent.offsetHeight;
|
|
58
|
+
|
|
59
|
+
const left = parseFloat(style.left || "0");
|
|
60
|
+
const top = parseFloat(style.top || "0");
|
|
61
|
+
const bottom = parseFloat(style.bottom || "0");
|
|
62
|
+
const right = parseFloat(style.right || "0");
|
|
63
|
+
|
|
64
|
+
const { undoRedo } = editor;
|
|
120
65
|
|
|
121
|
-
|
|
66
|
+
const d = undoRedo.beginPause();
|
|
122
67
|
|
|
123
|
-
|
|
68
|
+
let resized = false;
|
|
69
|
+
let changed = false;
|
|
70
|
+
let timer = void 0;
|
|
124
71
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
selectedElement,
|
|
129
|
-
oldInset,
|
|
130
|
-
insetAttribute,
|
|
131
|
-
widthAttribute,
|
|
132
|
-
heightAttribute,
|
|
133
|
-
selection,
|
|
134
|
-
hover
|
|
135
|
-
} = this;
|
|
72
|
+
const move = ({ dx, dy, fx}: { dx: number, dy: number, fx: (r: IRect, ) => IRect}) => {
|
|
73
|
+
|
|
74
|
+
changed = true;
|
|
136
75
|
|
|
137
76
|
const ri = {
|
|
138
77
|
left,
|
|
@@ -147,7 +86,7 @@ class SelectedCapture {
|
|
|
147
86
|
selectedElement.setAttribute(insetAttribute, inset);
|
|
148
87
|
|
|
149
88
|
if (!r.move) {
|
|
150
|
-
|
|
89
|
+
resized = true;
|
|
151
90
|
let widthDiff = -r.left;
|
|
152
91
|
let heightDiff = -r.top;
|
|
153
92
|
if (ri.bottom === r.bottom) {
|
|
@@ -162,25 +101,19 @@ class SelectedCapture {
|
|
|
162
101
|
selectedElement.setAttribute(heightAttribute, newHeight);
|
|
163
102
|
}
|
|
164
103
|
|
|
165
|
-
clearTimeout(this.timer);
|
|
166
|
-
|
|
104
|
+
// clearTimeout(this.timer);
|
|
105
|
+
setTimeout(() => {
|
|
167
106
|
selection.updateRect();
|
|
168
107
|
hover.updateRect();
|
|
169
108
|
}, 1);
|
|
170
|
-
}
|
|
109
|
+
};
|
|
171
110
|
|
|
172
|
-
commit() {
|
|
111
|
+
const commit = () => {
|
|
173
112
|
|
|
174
|
-
|
|
113
|
+
d.resume();
|
|
175
114
|
|
|
176
115
|
const records = [] as MutationRecord[];
|
|
177
116
|
|
|
178
|
-
const { oldInset, oldHeight, oldWidth, selectedElement,
|
|
179
|
-
insetAttribute, widthAttribute, heightAttribute,
|
|
180
|
-
undoRedo, editor,
|
|
181
|
-
selection, hover
|
|
182
|
-
} = this;
|
|
183
|
-
|
|
184
117
|
// push records...
|
|
185
118
|
records.push({
|
|
186
119
|
type: "attributes",
|
|
@@ -190,7 +123,7 @@ class SelectedCapture {
|
|
|
190
123
|
attributeNamespace: "",
|
|
191
124
|
} as MutationRecord);
|
|
192
125
|
|
|
193
|
-
if (
|
|
126
|
+
if (resized) {
|
|
194
127
|
records.push({
|
|
195
128
|
type: "attributes",
|
|
196
129
|
oldValue: oldWidth,
|
|
@@ -210,18 +143,28 @@ class SelectedCapture {
|
|
|
210
143
|
undoRedo.observe(records);
|
|
211
144
|
editor.commit();
|
|
212
145
|
|
|
213
|
-
clearTimeout(
|
|
214
|
-
|
|
146
|
+
clearTimeout(timer);
|
|
147
|
+
timer = setTimeout(() => {
|
|
215
148
|
selection.updateRect();
|
|
216
149
|
hover.updateRect();
|
|
217
150
|
}, 1);
|
|
218
|
-
}
|
|
219
|
-
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
move,
|
|
155
|
+
commit,
|
|
156
|
+
selectedElement,
|
|
157
|
+
selectedParent,
|
|
158
|
+
get changed() {
|
|
159
|
+
return changed;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
};
|
|
220
163
|
|
|
221
164
|
const setCapture = (editor: HtmlPageEditor, element: HTMLElement, e: PointerEvent, fx: (r: IRect, ) => IRect) => {
|
|
222
165
|
|
|
223
166
|
|
|
224
|
-
const sc =
|
|
167
|
+
const sc = beginDrag(editor, element);
|
|
225
168
|
|
|
226
169
|
const sx = e.clientX;
|
|
227
170
|
const sy = e.clientY;
|
|
@@ -290,11 +233,13 @@ const eventPointerDown = (editor: HtmlPageEditor, e: PointerEvent) => {
|
|
|
290
233
|
const element = e.target as HTMLElement;
|
|
291
234
|
const currentElement = e.currentTarget as HTMLElement;
|
|
292
235
|
if (!currentElement.hasAttribute("data-edit")) {
|
|
236
|
+
setTimeout(() => currentElement.hasAttribute("data-edit")
|
|
237
|
+
? currentElement.focus({ preventScroll: true })
|
|
238
|
+
: void 0, 250);
|
|
293
239
|
return;
|
|
294
240
|
}
|
|
295
241
|
|
|
296
|
-
currentElement.
|
|
297
|
-
currentElement.focus();
|
|
242
|
+
currentElement.focus({ preventScroll: true });
|
|
298
243
|
|
|
299
244
|
const resize = element.getAttribute("data-resize");
|
|
300
245
|
if (resize) {
|
|
@@ -358,6 +303,7 @@ const eventKeyDown = (editor: HtmlPageEditor, e: KeyboardEvent) => {
|
|
|
358
303
|
if (!currentElement.hasAttribute("data-edit")) {
|
|
359
304
|
return;
|
|
360
305
|
}
|
|
306
|
+
// e.preventDefault();
|
|
361
307
|
|
|
362
308
|
let dx = 0;
|
|
363
309
|
let dy = 0;
|
|
@@ -383,7 +329,7 @@ const eventKeyDown = (editor: HtmlPageEditor, e: KeyboardEvent) => {
|
|
|
383
329
|
return;
|
|
384
330
|
}
|
|
385
331
|
|
|
386
|
-
let sc:
|
|
332
|
+
let sc: ReturnType<typeof beginDrag> = currentElement[keyboardEditingSymbol];
|
|
387
333
|
|
|
388
334
|
if(!sc) {
|
|
389
335
|
|
|
@@ -396,7 +342,7 @@ const eventKeyDown = (editor: HtmlPageEditor, e: KeyboardEvent) => {
|
|
|
396
342
|
return r;
|
|
397
343
|
};
|
|
398
344
|
|
|
399
|
-
sc =
|
|
345
|
+
sc = beginDrag(editor, element);
|
|
400
346
|
currentElement[keyboardEditingSymbol] = sc;
|
|
401
347
|
|
|
402
348
|
sc.move({ dx, dy, fx });
|
|
@@ -419,6 +365,7 @@ const eventKeyDown = (editor: HtmlPageEditor, e: KeyboardEvent) => {
|
|
|
419
365
|
|
|
420
366
|
export function SelectionUI() {
|
|
421
367
|
return <selected-element data-element="selection"
|
|
368
|
+
tabIndex="-1"
|
|
422
369
|
data-edit={BindEditor.oneWay((e) => /relative/i.test(e.selection.parentStyle.position)
|
|
423
370
|
&& /absolute|fixed/i.test(e.selection.currentStyle.position) ? "1" : null)}
|
|
424
371
|
event-pointerdown={BindEditor.event(eventPointerDown as any)}
|