@social-mail/social-mail-client 1.2.283 → 1.2.285

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-client",
3
- "version": "1.2.283",
3
+ "version": "1.2.285",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -227,31 +227,32 @@ export default class WebSiteStudioPage extends ContentPage {
227
227
  }
228
228
 
229
229
  async downloadHtml(file: IAppFile, cancelToken) {
230
- let text = await FetchBuilder.get(file.downloadUrl)
230
+ const text = await FetchBuilder.get(file.downloadUrl)
231
231
  .cancelToken(cancelToken)
232
232
  .responseAsText(true);
233
- const parser = new DOMParser();
234
- const doc = parser.parseFromString(text, "text/html");
235
- const injects = Array.from(doc.documentElement.querySelectorAll("inject")) as HTMLElement[];
236
- for (const e of injects) {
237
- let src = e.getAttribute("src");
238
- if(src.startsWith("/")) {
239
- src = src.substring(1);
240
- } else {
241
- // will do it later
242
- }
243
- const injectedFile = await this.cloudFileService.children(this.root.appFileID, src)
244
- .firstOrDefault();
245
- text = await FetchBuilder.get(injectedFile.downloadUrl).responseAsText();
246
- const dom = parser.parseFromString(text, "text/html");
247
- const children = Array.from(dom.body.children);
248
- e.innerHTML = "";
249
- for (const iterator of children) {
250
- iterator.setAttribute("contentEditable", "false");
251
- e.appendChild(iterator);
252
- }
253
- }
254
- return doc.documentElement.outerHTML;
233
+ return text;
234
+ // const parser = new DOMParser();
235
+ // const doc = parser.parseFromString(text, "text/html");
236
+ // const injects = Array.from(doc.documentElement.querySelectorAll("inject")) as HTMLElement[];
237
+ // for (const e of injects) {
238
+ // let src = e.getAttribute("src");
239
+ // if(src.startsWith("/")) {
240
+ // src = src.substring(1);
241
+ // } else {
242
+ // // will do it later
243
+ // }
244
+ // const injectedFile = await this.cloudFileService.children(this.root.appFileID, src)
245
+ // .firstOrDefault();
246
+ // text = await FetchBuilder.get(injectedFile.downloadUrl).responseAsText();
247
+ // const dom = parser.parseFromString(text, "text/html");
248
+ // const children = Array.from(dom.body.children);
249
+ // e.innerHTML = "";
250
+ // for (const iterator of children) {
251
+ // iterator.setAttribute("contentEditable", "false");
252
+ // e.appendChild(iterator);
253
+ // }
254
+ // }
255
+ // return doc.documentElement.outerHTML;
255
256
  }
256
257
 
257
258
  async createIndexHtml() {
@@ -120,6 +120,30 @@ export default class WebSitePageEditor extends HtmlPageEditor {
120
120
  this.htmlDocument.head.appendChild(script);
121
121
  }
122
122
  script.setAttribute("src", "//cdn.jsdelivr.net/npm/@social-mail/web-components@1.0.54/dist/components.webpack.js");
123
+
124
+ // inject injected component....
125
+ for(const e of Array.from(this.htmlDocument.querySelectorAll("inject"))) {
126
+ let src = e.getAttribute("src");
127
+ if(src.startsWith("/")) {
128
+ src = src.substring(1);
129
+ } else {
130
+ // will do it later
131
+ }
132
+ const file = await this.cloudFileService.children(this.folder.appFileID, src)
133
+ .firstOrDefault();
134
+ const text = await FetchBuilder.get(file.downloadUrl).responseAsText();
135
+ const parser = new DOMParser();
136
+ const dom = parser.parseFromString(text, "text/html");
137
+ const children = Array.from(dom.body.children);
138
+ for (const iterator of Array.from(e.children)) {
139
+ iterator.remove();
140
+ }
141
+ for (const iterator of children) {
142
+ iterator.setAttribute("contentEditable", "false");
143
+ iterator.remove();
144
+ e.appendChild(iterator);
145
+ }
146
+ }
123
147
  }
124
148
 
125
149