@social-mail/social-mail-client 1.2.44 → 1.2.45

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/index.js CHANGED
@@ -22,7 +22,9 @@
22
22
 
23
23
  const view = script.getAttribute("data-view");
24
24
 
25
- const host = script.getAttribute("data-host");
25
+ let host = script.getAttribute("data-host");
26
+
27
+ const replace = script.getAttribute("data-replace");
26
28
 
27
29
  const packed = JSON.parse(script.getAttribute("data-packed") ?? "true");
28
30
  const min = JSON.parse(script.getAttribute("data-min") ?? "true");
@@ -61,11 +63,16 @@
61
63
  };
62
64
  UMD.setupRoot(package, packageRoot);
63
65
  UMD.lang = "en-US";
66
+ if (replace) {
67
+ host = document.createElement("section");
68
+ script.parentElement.replaceChild(section, script);
69
+ }
70
+
64
71
  if (host) {
65
72
  UMD.hostView(host, viewName, 0).then(done);
66
73
  } else {
67
74
  UMD.loadView(viewName, 0).then(done);
68
- }
75
+ }
69
76
  });
70
77
 
71
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-client",
3
- "version": "1.2.44",
3
+ "version": "1.2.45",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,10 @@
1
+ import XNode from "@web-atoms/core/dist/core/XNode";
2
+ import { Block } from "./Block";
3
+
4
+ export const BlogComponent = Block({
5
+ className: "fad fa-blog",
6
+ title: "Add Blog Component",
7
+ factory: () => <section data-web-atoms-view="blog-view" style="margin: 10px; padding: 10px; background: gray; border-radius: 10px; color: white;">
8
+ Blog View
9
+ </section>
10
+ });
@@ -24,6 +24,7 @@ import { ImageCard } from "../blocks/ImageCard";
24
24
  import { TextBox } from "../blocks/TextBox";
25
25
  import { Card } from "../blocks/Card";
26
26
  import { List } from "../blocks/List";
27
+ import { BlogComponent } from "../blocks/Components";
27
28
 
28
29
  styled.css `
29
30
  display: grid;
@@ -206,11 +207,18 @@ export default class HtmlPageEditor extends AtomControl {
206
207
  const target = e.target as Node;
207
208
  e.preventDefault();
208
209
  const element: HTMLElement = target.nodeType === Node.ELEMENT_NODE ? target as HTMLElement : target.parentElement;
209
- element.setAttribute("contentEditable", "true");
210
- this.setSelection(element as any);
211
210
  if (element.tagName === "IMG") {
212
211
  this.changeImage().catch(console.error);
212
+ return;
213
+ }
214
+ if (element.getAttribute("data-editable") === "false") {
215
+ return;
213
216
  }
217
+ if (element.hasAttribute("data-web-atoms-view")) {
218
+ return;
219
+ }
220
+ element.setAttribute("contentEditable", "true");
221
+ this.setSelection(element as any);
214
222
  });
215
223
 
216
224
  this.htmlDocument.addEventListener("scroll", (e) => {
@@ -313,6 +321,7 @@ export default class HtmlPageEditor extends AtomControl {
313
321
  <Columns2/>
314
322
  <Columns3/>
315
323
  <List/>
324
+ <BlogComponent/>
316
325
  </EditorToolbar>
317
326
  <div data-element="editor"
318
327
  style-max-width={Bind.oneWay(() => this.maxWidth > 768 ? "" : this.maxWidth + "px" )}>
@@ -513,6 +522,17 @@ export default class HtmlPageEditor extends AtomControl {
513
522
  const element = all[index];
514
523
  element.removeAttribute("draggable");
515
524
  }
525
+ // replace script tags...
526
+ const blogView = clone.querySelector(`section[data-web-atoms-view="blog-view"]`);
527
+ if (blogView) {
528
+ const blogScript = this.htmlDocument.createElement("script");
529
+ blogScript.src = "https://cdn.jsdelivr.net/npm/@social-mail/social-mail-client@1.2.45/component.js";
530
+ blogScript.setAttribute("data-package", "@social-mail/social-mail-client");
531
+ blogScript.setAttribute("data-package-root", "https://cdn.jsdelivr.net/npm/@social-mail/social-mail-client@1.2.45/");
532
+ blogScript.setAttribute("data-replace", "true");
533
+ blogScript.setAttribute("data-view", "dist/public/channel/ChannelView");
534
+ blogView.parentElement.replaceChild(blogScript, blogView);
535
+ }
516
536
  const currentHtml = clone.innerHTML;
517
537
  if (!lastHtml) {
518
538
  this.lastHtml = currentHtml;