@social-mail/social-mail-client 1.9.68 → 1.9.70
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/admin/AdminAppIndex.pack.global.css +1 -1
- package/dist/admin/AdminAppIndex.pack.global.css.map +1 -1
- package/dist/public/channel/ChannelApp.pack.global.css +1 -1
- package/dist/public/channel/ChannelApp.pack.global.css.map +1 -1
- package/dist/public/store/StoreApp.pack.global.css +1 -1
- package/dist/public/store/StoreApp.pack.global.css.map +1 -1
- package/dist/site-editor/editor/HtmlPageEditor.d.ts +1 -0
- package/dist/site-editor/editor/HtmlPageEditor.d.ts.map +1 -1
- package/dist/site-editor/editor/HtmlPageEditor.js +94 -90
- package/dist/site-editor/editor/HtmlPageEditor.js.map +1 -1
- package/dist/site-editor/editor/UndoRedo.d.ts.map +1 -1
- package/dist/site-editor/editor/UndoRedo.js +9 -7
- package/dist/site-editor/editor/UndoRedo.js.map +1 -1
- package/dist/site-editor/editor/ui/SelectionUI.d.ts.map +1 -1
- package/dist/site-editor/editor/ui/SelectionUI.js +35 -8
- package/dist/site-editor/editor/ui/SelectionUI.js.map +1 -1
- package/dist/site-editor-app/SiteEditorApp.pack.global.css +1 -1
- package/dist/site-editor-app/SiteEditorApp.pack.global.css.map +1 -1
- package/dist/site-editor-app/SiteEditorApp.pack.js +140 -107
- 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/dist/web/AppIndex.pack.global.css +1 -1
- package/dist/web/AppIndex.pack.global.css.map +1 -1
- package/node_modules/@web-atoms/web-controls/dist/mobile-app/MobileApp.global.css +1 -1
- package/node_modules/@web-atoms/web-controls/dist/mobile-app/MobileApp.global.css.map +1 -1
- package/node_modules/@web-atoms/web-controls/package.json +1 -1
- package/node_modules/@web-atoms/web-controls/src/mobile-app/MobileApp.global.css +4 -0
- package/package.json +2 -2
- package/src/site-editor/editor/HtmlPageEditor.tsx +110 -103
- package/src/site-editor/editor/UndoRedo.tsx +9 -7
- package/src/site-editor/editor/ui/SelectionUI.tsx +43 -7
|
@@ -97,6 +97,7 @@ export default class HtmlPageEditor extends AtomControl {
|
|
|
97
97
|
public maxWidth = desktopWidth;
|
|
98
98
|
|
|
99
99
|
public contentEditor: HTMLIFrameElement;
|
|
100
|
+
public dndStyle: CSSStyleSheet;
|
|
100
101
|
|
|
101
102
|
|
|
102
103
|
public get modifiedDocument() {
|
|
@@ -481,6 +482,9 @@ export default class HtmlPageEditor extends AtomControl {
|
|
|
481
482
|
}
|
|
482
483
|
|
|
483
484
|
setSelection(element, commit = true) {
|
|
485
|
+
if (element.tagName === "HTML") {
|
|
486
|
+
element = element.querySelector("body > *:nth-child(1)");
|
|
487
|
+
}
|
|
484
488
|
const old = this.selection?.element;
|
|
485
489
|
if (old?.draggable) {
|
|
486
490
|
old.removeAttribute("draggable");
|
|
@@ -817,9 +821,11 @@ export default class HtmlPageEditor extends AtomControl {
|
|
|
817
821
|
caret.insertRule(`* {
|
|
818
822
|
caret-color: currentColor !important;
|
|
819
823
|
}`);
|
|
824
|
+
const dndStyle = new this.htmlDocument.defaultView.CSSStyleSheet();
|
|
825
|
+
this.dndStyle = dndStyle;
|
|
820
826
|
this.htmlDocument.adoptedStyleSheets = this.htmlDocument.adoptedStyleSheets?.length
|
|
821
|
-
? [ ... this.htmlDocument.adoptedStyleSheets, caret]
|
|
822
|
-
: [caret];
|
|
827
|
+
? [ ... this.htmlDocument.adoptedStyleSheets, caret, dndStyle]
|
|
828
|
+
: [caret, dndStyle];
|
|
823
829
|
|
|
824
830
|
const clone = this.htmlDocument;
|
|
825
831
|
let stylerCss = clone.querySelector(`link[rel="stylesheet"][styler-css="styler.css"]`);
|
|
@@ -832,131 +838,132 @@ export default class HtmlPageEditor extends AtomControl {
|
|
|
832
838
|
|
|
833
839
|
this.undoRedo = new UndoRedo(this.htmlDocument, this);
|
|
834
840
|
|
|
841
|
+
await sleep(10);
|
|
842
|
+
|
|
835
843
|
// install styler...
|
|
836
|
-
setTimeout(() => {
|
|
837
844
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
845
|
+
if (clone.querySelector(`[styler-layout="component"]`)) {
|
|
846
|
+
let componentScript = clone.querySelector("[styler-component-script]") as HTMLScriptElement;
|
|
847
|
+
if(!componentScript) {
|
|
848
|
+
componentScript = this.htmlDocument.createElement("script");
|
|
849
|
+
componentScript.setAttribute("styler-component-script", "component-script");
|
|
850
|
+
const head = clone.querySelector("head");
|
|
851
|
+
head.appendChild(componentScript);
|
|
852
|
+
|
|
853
|
+
// remove existing script with src..
|
|
854
|
+
const scripts = clone.querySelectorAll("script[src]");
|
|
855
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
856
|
+
for (let index = 0; index < scripts.length; index++) {
|
|
857
|
+
const script = scripts[index];
|
|
858
|
+
const srcScript = script.getAttribute("src");
|
|
859
|
+
if (srcScript.includes("@social-mail/social-mail-client/") || srcScript.includes("/component.js")) {
|
|
860
|
+
script.remove();
|
|
861
|
+
break;
|
|
856
862
|
}
|
|
857
863
|
}
|
|
858
|
-
const src = socialMailComponentPath;
|
|
859
|
-
if (componentScript.getAttribute("src") !== src) {
|
|
860
|
-
componentScript.setAttribute("src", src);
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
let wc = clone.querySelector("script[web-components]");
|
|
865
|
-
if (!wc) {
|
|
866
|
-
wc = this.htmlDocument.createElement("script");
|
|
867
|
-
wc.setAttribute("web-components", "social");
|
|
868
|
-
wc.setAttribute("async", "true");
|
|
869
|
-
wc.setAttribute("defer", "true");
|
|
870
|
-
clone.head.appendChild(doc.createTextNode("\n"));
|
|
871
|
-
clone.head.appendChild(wc);
|
|
872
|
-
clone.head.appendChild(doc.createTextNode("\n"));
|
|
873
864
|
}
|
|
874
|
-
const
|
|
875
|
-
if (
|
|
876
|
-
|
|
865
|
+
const src = socialMailComponentPath;
|
|
866
|
+
if (componentScript.getAttribute("src") !== src) {
|
|
867
|
+
componentScript.setAttribute("src", src);
|
|
877
868
|
}
|
|
869
|
+
}
|
|
878
870
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
871
|
+
let wc = clone.querySelector("script[web-components]");
|
|
872
|
+
if (!wc) {
|
|
873
|
+
wc = this.htmlDocument.createElement("script");
|
|
874
|
+
wc.setAttribute("web-components", "social");
|
|
875
|
+
wc.setAttribute("async", "true");
|
|
876
|
+
wc.setAttribute("defer", "true");
|
|
877
|
+
clone.head.appendChild(doc.createTextNode("\n"));
|
|
878
|
+
clone.head.appendChild(wc);
|
|
879
|
+
clone.head.appendChild(doc.createTextNode("\n"));
|
|
880
|
+
}
|
|
881
|
+
const wcs = `${WebComponents.path}/dist/main.js`;
|
|
882
|
+
if (wc.getAttribute("src") !== wcs) {
|
|
883
|
+
wc.setAttribute("src", wcs);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
const sc = "//cdn.jsdelivr.net/npm/@social-mail/social-mail-client@latest/styler-lite/styler.css";
|
|
887
|
+
const oldStylerCss = stylerCss.getAttribute("href");
|
|
888
|
+
if (oldStylerCss !== sc) {
|
|
889
|
+
stylerCss.setAttribute("href", sc);
|
|
890
|
+
}
|
|
884
891
|
|
|
885
|
-
|
|
886
|
-
|
|
892
|
+
// let us clean up...
|
|
893
|
+
for(const node of descendentElementIterator(clone.documentElement)) {
|
|
887
894
|
|
|
888
|
-
|
|
889
|
-
|
|
895
|
+
const style = (node as HTMLElement).style;
|
|
896
|
+
if (style) {
|
|
890
897
|
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
+
// this is fix for changes in names...
|
|
899
|
+
for(const attributeName of node.getAttributeNames()) {
|
|
900
|
+
let av = node.getAttribute(attributeName);
|
|
901
|
+
if (av === "null") {
|
|
902
|
+
node.removeAttribute(attributeName);
|
|
903
|
+
continue;
|
|
904
|
+
}
|
|
898
905
|
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
906
|
+
if (attributeName.includes("-desktop-")) {
|
|
907
|
+
const a = attributeName.replace("-desktop-", "-");
|
|
908
|
+
node.removeAttribute(attributeName);
|
|
909
|
+
node.setAttribute(a, av);
|
|
910
|
+
continue;
|
|
911
|
+
}
|
|
905
912
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
if(attributeName.startsWith("styler-all-child")) {
|
|
915
|
-
node.removeAttribute(attributeName);
|
|
916
|
-
node.setAttribute(attributeName.replace("styler-all-", "styler-"), av);
|
|
913
|
+
const s = editorSuggestions[attributeName] as { label: string, value: string }[];
|
|
914
|
+
if (s) {
|
|
915
|
+
const cv = s.find((x) => x.label === av);
|
|
916
|
+
if (cv && cv.value !== av) {
|
|
917
|
+
av = cv.value;
|
|
918
|
+
node.setAttribute(attributeName, av);
|
|
917
919
|
}
|
|
918
920
|
}
|
|
921
|
+
if(attributeName.startsWith("styler-all-child")) {
|
|
922
|
+
node.removeAttribute(attributeName);
|
|
923
|
+
node.setAttribute(attributeName.replace("styler-all-", "styler-"), av);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
919
926
|
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
}
|
|
927
|
+
const remove = [];
|
|
928
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
929
|
+
for (let index = 0; index < style.length; index++) {
|
|
930
|
+
const styleName = style[index];
|
|
931
|
+
if (styleName.startsWith("--styler-")) {
|
|
932
|
+
const stylerName = styleName.substring(2);
|
|
933
|
+
if (node.getAttribute(stylerName) !== "custom") {
|
|
934
|
+
// remove this one..
|
|
935
|
+
remove.push(styleName);
|
|
930
936
|
}
|
|
931
937
|
}
|
|
938
|
+
}
|
|
932
939
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
}
|
|
940
|
+
for (const n of remove) {
|
|
941
|
+
style.removeProperty(n);
|
|
936
942
|
}
|
|
937
943
|
}
|
|
944
|
+
}
|
|
938
945
|
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
946
|
+
// add meta utf-8
|
|
947
|
+
if(!clone.querySelector(`meta[charset]`)) {
|
|
948
|
+
clone.head.appendChild(doc.createTextNode("\n\t"));
|
|
949
|
+
clone.head.appendChild(
|
|
950
|
+
ElementBuilder.create("meta", clone)
|
|
951
|
+
.attr("charset", "utf-8")
|
|
952
|
+
.element);
|
|
953
|
+
clone.head.appendChild(doc.createTextNode("\n"));
|
|
954
|
+
}
|
|
948
955
|
|
|
949
|
-
|
|
950
|
-
this.undoRedo.pause();
|
|
951
|
-
stylerCss.setAttribute("original-href", sc);
|
|
952
|
-
stylerCss.setAttribute("href", UMD.resolvePath("@social-mail/social-mail-client/styler-lite/styler.css"));
|
|
956
|
+
await sleep(5);
|
|
953
957
|
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
+
this.undoRedo.pause();
|
|
959
|
+
stylerCss.setAttribute("original-href", sc);
|
|
960
|
+
stylerCss.setAttribute("href", UMD.resolvePath("@social-mail/social-mail-client/styler-lite/styler.css"));
|
|
961
|
+
|
|
962
|
+
if(!clone.body.hasAttribute("styler-expansion-enabled")) {
|
|
963
|
+
clone.body.setAttribute("styler-expansion-enabled", "true");
|
|
964
|
+
}
|
|
958
965
|
|
|
959
|
-
|
|
966
|
+
this.setSelection(this.htmlDocument.querySelector("body > *:nth-child(1)"));
|
|
960
967
|
}
|
|
961
968
|
|
|
962
969
|
protected async updateEditable(doc: Document) {
|
|
@@ -55,13 +55,15 @@ export default class UndoRedo {
|
|
|
55
55
|
|
|
56
56
|
observe(records: MutationRecord[]) {
|
|
57
57
|
const { documentObserver } = this;
|
|
58
|
-
if (this.silent
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
d
|
|
58
|
+
if (this.silent) {
|
|
59
|
+
if (documentObserver?.length) {
|
|
60
|
+
for (const x of records) {
|
|
61
|
+
if (x.target[isDragged]) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
for (const d of documentObserver) {
|
|
65
|
+
d(x);
|
|
66
|
+
}
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
return;
|
|
@@ -26,6 +26,33 @@ interface IRect {
|
|
|
26
26
|
|
|
27
27
|
const ps = (v, max) => (v* 100 / (max || 1)).toFixed(2);
|
|
28
28
|
|
|
29
|
+
const cssPath = (el) => {
|
|
30
|
+
// if (!(el instanceof Element)) {
|
|
31
|
+
// return;
|
|
32
|
+
// }
|
|
33
|
+
const path = [];
|
|
34
|
+
while (el.nodeType === Node.ELEMENT_NODE) {
|
|
35
|
+
let selector = el.nodeName.toLowerCase();
|
|
36
|
+
if (el.id) {
|
|
37
|
+
selector += '#' + el.id;
|
|
38
|
+
} else {
|
|
39
|
+
let nth = 1;
|
|
40
|
+
let f = (el as HTMLElement).parentElement.firstElementChild;
|
|
41
|
+
while(f !== el) {
|
|
42
|
+
nth++;
|
|
43
|
+
f = f.nextElementSibling;
|
|
44
|
+
}
|
|
45
|
+
selector += ":nth-child("+nth+")";
|
|
46
|
+
}
|
|
47
|
+
path.unshift(selector);
|
|
48
|
+
if (el.tagName === "BODY") {
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
el = el.parentNode;
|
|
52
|
+
}
|
|
53
|
+
return path.join(" > ");
|
|
54
|
+
};
|
|
55
|
+
|
|
29
56
|
const beginDrag = (direction: string, editor: HtmlPageEditor, element: HTMLElement) => {
|
|
30
57
|
|
|
31
58
|
const snaps = new SnapGuides(direction, editor, element);
|
|
@@ -79,6 +106,10 @@ const beginDrag = (direction: string, editor: HtmlPageEditor, element: HTMLEleme
|
|
|
79
106
|
|
|
80
107
|
let updateTimer = void 0;
|
|
81
108
|
|
|
109
|
+
const dndStyle = editor.dndStyle;
|
|
110
|
+
|
|
111
|
+
const elementSelector = cssPath(selectedElement);
|
|
112
|
+
|
|
82
113
|
const move = ({ dx, dy, fx}: { dx: number, dy: number, fx: (r: IRect, ) => IRect}) => {
|
|
83
114
|
|
|
84
115
|
changed = true;
|
|
@@ -108,18 +139,25 @@ const beginDrag = (direction: string, editor: HtmlPageEditor, element: HTMLEleme
|
|
|
108
139
|
r = snaps.snap(r);
|
|
109
140
|
|
|
110
141
|
inset = `${ps(r.top, height)}% ${ps(r.right, width)}% ${ps(r.bottom, height)}% ${ps(r.left, width)}%`;
|
|
111
|
-
|
|
142
|
+
let rules = `${elementSelector} {
|
|
143
|
+
inset: ${inset};
|
|
144
|
+
`;
|
|
112
145
|
|
|
113
146
|
if (!r.move) {
|
|
114
147
|
resized = true;
|
|
115
148
|
newWidth = ps(elementWidth + dx, width) + "%";
|
|
116
|
-
|
|
149
|
+
rules += ` width: ${newWidth}; `;
|
|
150
|
+
// selectedElement.style.width = newWidth;
|
|
117
151
|
// // selectedElement.setAttribute(widthAttribute, newWidth);
|
|
118
152
|
newHeight = ps(elementHeight + dy, height) + "%";
|
|
119
|
-
|
|
153
|
+
rules += ` height: ${newHeight}; `;
|
|
154
|
+
// selectedElement.style.height = newHeight;
|
|
120
155
|
// selectedElement.setAttribute(heightAttribute, newHeight);
|
|
121
156
|
}
|
|
122
157
|
|
|
158
|
+
rules += "}";
|
|
159
|
+
|
|
160
|
+
dndStyle.replaceSync(rules);
|
|
123
161
|
|
|
124
162
|
if(!updateTimer) {
|
|
125
163
|
updateTimer = setTimeout(() => {
|
|
@@ -138,9 +176,7 @@ const beginDrag = (direction: string, editor: HtmlPageEditor, element: HTMLEleme
|
|
|
138
176
|
const commit = () => {
|
|
139
177
|
|
|
140
178
|
|
|
141
|
-
|
|
142
|
-
selectedElement.style.removeProperty("width");
|
|
143
|
-
selectedElement.style.removeProperty("height");
|
|
179
|
+
dndStyle.replaceSync("");
|
|
144
180
|
|
|
145
181
|
selectedElement.setAttribute(insetAttribute, inset);
|
|
146
182
|
if (resized) {
|
|
@@ -231,10 +267,10 @@ const setCapture = (direction: string, editor: HtmlPageEditor, element: HTMLElem
|
|
|
231
267
|
element.removeEventListener("pointermove", captureMove);
|
|
232
268
|
element.removeEventListener("pointerup", release);
|
|
233
269
|
|
|
234
|
-
sc.resume();
|
|
235
270
|
|
|
236
271
|
if (!sc.changed) {
|
|
237
272
|
|
|
273
|
+
sc.resume();
|
|
238
274
|
const { selectedElement, selectedParent } = sc;
|
|
239
275
|
const frameDocument = selectedElement.ownerDocument;
|
|
240
276
|
const frame = editor.contentEditor;
|