@daisychainapp/maily-to-core 0.4.0 → 0.4.1

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.
@@ -8617,83 +8617,24 @@ import { createLowlight, common } from "lowlight";
8617
8617
 
8618
8618
  // src/editor/nodes/html/html-view.tsx
8619
8619
  import { NodeViewContent as NodeViewContent2, NodeViewWrapper as NodeViewWrapper7 } from "@tiptap/react";
8620
- import { useMemo as useMemo7 } from "react";
8621
- import { jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
8620
+ import { jsx as jsx37 } from "react/jsx-runtime";
8622
8621
  function HTMLCodeBlockView(props) {
8623
- const { node, updateAttributes: updateAttributes2 } = props;
8624
- let { language, activeTab = "code" } = node.attrs;
8625
- activeTab || (activeTab = "code");
8622
+ const { node } = props;
8623
+ const { language } = node.attrs;
8626
8624
  const languageClass = language ? `language-${language}` : "";
8627
- const html2 = useMemo7(() => {
8628
- const text2 = node.content.content.reduce((acc, cur) => {
8629
- if (cur.type.name === "text") {
8630
- return acc + cur.text;
8631
- } else if (cur.type.name === "variable") {
8632
- const { id: variable, fallback } = (cur == null ? void 0 : cur.attrs) || {};
8633
- const formattedVariable = fallback ? `{{${variable},fallback=${fallback}}}` : `{{${variable}}}`;
8634
- return acc + formattedVariable;
8635
- }
8636
- return acc;
8637
- }, "");
8638
- const htmlParser = new DOMParser();
8639
- const htmlDoc = htmlParser.parseFromString(text2, "text/html");
8640
- const style = htmlDoc.querySelectorAll("style");
8641
- const body = htmlDoc.body;
8642
- const combinedStyle = Array.from(style).map((s) => s.innerHTML).join("\n");
8643
- return `<style>${combinedStyle}</style>${body.innerHTML}`;
8644
- }, [activeTab]);
8645
- const isEmpty = html2 === "";
8646
- return /* @__PURE__ */ jsxs20(
8625
+ return /* @__PURE__ */ jsx37(
8647
8626
  NodeViewWrapper7,
8648
8627
  {
8649
8628
  draggable: false,
8650
8629
  "data-drag-handle": false,
8651
8630
  "data-type": "htmlCodeBlock",
8652
- children: [
8653
- activeTab === "code" && /* @__PURE__ */ jsx37("pre", { className: "mly:my-0 mly:rounded-lg mly:border mly:border-gray-200 mly:bg-white mly:p-2 mly:text-black", children: /* @__PURE__ */ jsx37(
8654
- NodeViewContent2,
8655
- {
8656
- as: "code",
8657
- className: cn("is-editable", languageClass)
8658
- }
8659
- ) }),
8660
- activeTab === "preview" && /* @__PURE__ */ jsx37(
8661
- "div",
8662
- {
8663
- className: cn(
8664
- "mly:not-prose mly:rounded-lg mly:border mly:border-gray-200 mly:p-2",
8665
- isEmpty && "mly:min-h-[42px]"
8666
- ),
8667
- ref: (node2) => {
8668
- if (!node2 || (node2 == null ? void 0 : node2.shadowRoot)) {
8669
- return;
8670
- }
8671
- const shadow = node2.attachShadow({ mode: "open" });
8672
- const sheet = new CSSStyleSheet();
8673
- sheet.replaceSync(`
8674
- * { font-family: 'Inter', sans-serif; }
8675
- blockquote, h1, h2, h3, img, li, ol, p, ul {
8676
- margin-top: 0;
8677
- margin-bottom: 0;
8678
- }
8679
- `);
8680
- shadow.adoptedStyleSheets = [sheet];
8681
- const container = document.createElement("div");
8682
- container.innerHTML = html2;
8683
- shadow.appendChild(container);
8684
- },
8685
- contentEditable: false,
8686
- onClick: () => {
8687
- if (!isEmpty) {
8688
- return;
8689
- }
8690
- updateAttributes2({
8691
- activeTab: "code"
8692
- });
8693
- }
8694
- }
8695
- )
8696
- ]
8631
+ children: /* @__PURE__ */ jsx37("pre", { className: "mly-html-code-pre", children: /* @__PURE__ */ jsx37(
8632
+ NodeViewContent2,
8633
+ {
8634
+ as: "code",
8635
+ className: cn("is-editable", languageClass)
8636
+ }
8637
+ ) })
8697
8638
  }
8698
8639
  );
8699
8640
  }