@maily-to/core 0.2.0 → 0.2.2
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/extensions/index.d.mts +32 -1
- package/dist/extensions/index.d.ts +32 -1
- package/dist/extensions/index.js +158 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/index.mjs +159 -1
- package/dist/extensions/index.mjs.map +1 -1
- package/dist/index.css +2381 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +1 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/readme.md +2 -0
|
@@ -1825,7 +1825,7 @@ function ColorPicker(props) {
|
|
|
1825
1825
|
alpha: true,
|
|
1826
1826
|
color,
|
|
1827
1827
|
onChange: handleColorChange,
|
|
1828
|
-
className: "mly-mt-4 mly-w-full mly-min-w-0 mly-rounded-lg mly-border mly-border-gray-200 mly-px-2 mly-py-1.5 mly-text-sm mly-uppercase focus-visible:mly-border-gray-400 focus-visible:mly-outline-none",
|
|
1828
|
+
className: "mly-mt-4 mly-w-full mly-min-w-0 mly-rounded-lg mly-border mly-border-gray-200 mly-bg-white mly-px-2 mly-py-1.5 mly-text-sm mly-uppercase focus-visible:mly-border-gray-400 focus-visible:mly-outline-none",
|
|
1829
1829
|
prefixed: true
|
|
1830
1830
|
}
|
|
1831
1831
|
),
|
|
@@ -5585,6 +5585,163 @@ function getVariableSuggestions(char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
|
|
|
5585
5585
|
}
|
|
5586
5586
|
};
|
|
5587
5587
|
}
|
|
5588
|
+
|
|
5589
|
+
// src/editor/nodes/html/html.tsx
|
|
5590
|
+
import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight";
|
|
5591
|
+
import { TextSelection as TextSelection3 } from "@tiptap/pm/state";
|
|
5592
|
+
import {
|
|
5593
|
+
ReactNodeViewRenderer as ReactNodeViewRenderer7
|
|
5594
|
+
} from "@tiptap/react";
|
|
5595
|
+
import html from "highlight.js/lib/languages/xml";
|
|
5596
|
+
import { createLowlight, common } from "lowlight";
|
|
5597
|
+
|
|
5598
|
+
// src/editor/nodes/html/html-view.tsx
|
|
5599
|
+
import { NodeViewContent as NodeViewContent2, NodeViewWrapper as NodeViewWrapper7 } from "@tiptap/react";
|
|
5600
|
+
import { useMemo as useMemo8 } from "react";
|
|
5601
|
+
import { jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
5602
|
+
function HTMLCodeBlockView(props) {
|
|
5603
|
+
const { node, updateAttributes: updateAttributes2 } = props;
|
|
5604
|
+
let { language, activeTab = "code" } = node.attrs;
|
|
5605
|
+
activeTab || (activeTab = "code");
|
|
5606
|
+
const languageClass = language ? `language-${language}` : "";
|
|
5607
|
+
const html2 = useMemo8(() => {
|
|
5608
|
+
const text2 = node.content.content.reduce((acc, cur) => {
|
|
5609
|
+
if (cur.type.name === "text") {
|
|
5610
|
+
return acc + cur.text;
|
|
5611
|
+
} else if (cur.type.name === "variable") {
|
|
5612
|
+
const { id: variable, fallback } = (cur == null ? void 0 : cur.attrs) || {};
|
|
5613
|
+
const formattedVariable = fallback ? `{{${variable},fallback=${fallback}}}` : `{{${variable}}}`;
|
|
5614
|
+
return acc + formattedVariable;
|
|
5615
|
+
}
|
|
5616
|
+
return acc;
|
|
5617
|
+
}, "");
|
|
5618
|
+
const htmlParser = new DOMParser();
|
|
5619
|
+
const htmlDoc = htmlParser.parseFromString(text2, "text/html");
|
|
5620
|
+
const body = htmlDoc.body;
|
|
5621
|
+
return body.innerHTML;
|
|
5622
|
+
}, [activeTab]);
|
|
5623
|
+
const isEmpty = html2 === "";
|
|
5624
|
+
return /* @__PURE__ */ jsxs20(
|
|
5625
|
+
NodeViewWrapper7,
|
|
5626
|
+
{
|
|
5627
|
+
draggable: false,
|
|
5628
|
+
"data-drag-handle": false,
|
|
5629
|
+
"data-type": "htmlCodeBlock",
|
|
5630
|
+
children: [
|
|
5631
|
+
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(
|
|
5632
|
+
NodeViewContent2,
|
|
5633
|
+
{
|
|
5634
|
+
as: "code",
|
|
5635
|
+
className: cn("is-editable", languageClass)
|
|
5636
|
+
}
|
|
5637
|
+
) }),
|
|
5638
|
+
activeTab === "preview" && /* @__PURE__ */ jsx37(
|
|
5639
|
+
"div",
|
|
5640
|
+
{
|
|
5641
|
+
className: cn(
|
|
5642
|
+
"mly-not-prose mly-rounded-lg mly-border mly-border-gray-200 mly-p-2",
|
|
5643
|
+
isEmpty && "mly-min-h-[42px]"
|
|
5644
|
+
),
|
|
5645
|
+
dangerouslySetInnerHTML: { __html: html2 },
|
|
5646
|
+
contentEditable: false,
|
|
5647
|
+
onClick: () => {
|
|
5648
|
+
if (!isEmpty) {
|
|
5649
|
+
return;
|
|
5650
|
+
}
|
|
5651
|
+
updateAttributes2({
|
|
5652
|
+
activeTab: "code"
|
|
5653
|
+
});
|
|
5654
|
+
}
|
|
5655
|
+
}
|
|
5656
|
+
)
|
|
5657
|
+
]
|
|
5658
|
+
}
|
|
5659
|
+
);
|
|
5660
|
+
}
|
|
5661
|
+
|
|
5662
|
+
// src/editor/nodes/html/html.tsx
|
|
5663
|
+
var lowlight = createLowlight(common);
|
|
5664
|
+
lowlight.register("html", html);
|
|
5665
|
+
var HTMLCodeBlockExtension = CodeBlockLowlight.extend({
|
|
5666
|
+
name: "htmlCodeBlock",
|
|
5667
|
+
content: "(text|variable)*",
|
|
5668
|
+
addAttributes() {
|
|
5669
|
+
var _a;
|
|
5670
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
5671
|
+
activeTab: "code",
|
|
5672
|
+
showIfKey: {
|
|
5673
|
+
default: DEFAULT_SECTION_SHOW_IF_KEY,
|
|
5674
|
+
parseHTML: (element) => {
|
|
5675
|
+
return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
|
|
5676
|
+
},
|
|
5677
|
+
renderHTML(attributes) {
|
|
5678
|
+
if (!attributes.showIfKey) {
|
|
5679
|
+
return {};
|
|
5680
|
+
}
|
|
5681
|
+
return {
|
|
5682
|
+
"data-show-if-key": attributes.showIfKey
|
|
5683
|
+
};
|
|
5684
|
+
}
|
|
5685
|
+
}
|
|
5686
|
+
});
|
|
5687
|
+
},
|
|
5688
|
+
addNodeView() {
|
|
5689
|
+
return ReactNodeViewRenderer7(HTMLCodeBlockView, {
|
|
5690
|
+
className: "mly-relative",
|
|
5691
|
+
attrs: ({ node }) => {
|
|
5692
|
+
var _a;
|
|
5693
|
+
return {
|
|
5694
|
+
"data-active-tab": ((_a = node == null ? void 0 : node.attrs) == null ? void 0 : _a.activeTab) || "code"
|
|
5695
|
+
};
|
|
5696
|
+
}
|
|
5697
|
+
});
|
|
5698
|
+
},
|
|
5699
|
+
addCommands() {
|
|
5700
|
+
return {
|
|
5701
|
+
setHtmlCodeBlock: (attributes) => ({ commands }) => {
|
|
5702
|
+
return commands.setNode(this.name, attributes);
|
|
5703
|
+
},
|
|
5704
|
+
toggleHtmlCodeBlock: (attributes) => ({ commands }) => {
|
|
5705
|
+
return commands.toggleNode(this.name, "paragraph", attributes);
|
|
5706
|
+
},
|
|
5707
|
+
updateHtmlCodeBlock: (attrs) => updateAttributes(this.name, attrs)
|
|
5708
|
+
};
|
|
5709
|
+
},
|
|
5710
|
+
addKeyboardShortcuts() {
|
|
5711
|
+
var _a;
|
|
5712
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
5713
|
+
"Mod-a": ({ editor }) => {
|
|
5714
|
+
const { selection } = editor.state;
|
|
5715
|
+
const $pos = selection.$anchor;
|
|
5716
|
+
const node = $pos.node($pos.depth);
|
|
5717
|
+
if (node.type.name !== this.name) {
|
|
5718
|
+
return false;
|
|
5719
|
+
}
|
|
5720
|
+
let depth = $pos.depth;
|
|
5721
|
+
for (let d = depth; d > 0; d--) {
|
|
5722
|
+
if ($pos.node(d).type.name === this.name) {
|
|
5723
|
+
depth = d;
|
|
5724
|
+
break;
|
|
5725
|
+
}
|
|
5726
|
+
}
|
|
5727
|
+
const start = $pos.before(depth) + 1;
|
|
5728
|
+
const end = $pos.after(depth) - 1;
|
|
5729
|
+
const from = editor.state.doc.resolve(start);
|
|
5730
|
+
const to = editor.state.doc.resolve(end);
|
|
5731
|
+
if (from && to) {
|
|
5732
|
+
const transaction = editor.state.tr.setSelection(
|
|
5733
|
+
TextSelection3.between(from, to)
|
|
5734
|
+
);
|
|
5735
|
+
editor.view.dispatch(transaction);
|
|
5736
|
+
return true;
|
|
5737
|
+
}
|
|
5738
|
+
return false;
|
|
5739
|
+
}
|
|
5740
|
+
});
|
|
5741
|
+
}
|
|
5742
|
+
}).configure({
|
|
5743
|
+
lowlight
|
|
5744
|
+
});
|
|
5588
5745
|
export {
|
|
5589
5746
|
ButtonExtension,
|
|
5590
5747
|
Color,
|
|
@@ -5623,6 +5780,7 @@ export {
|
|
|
5623
5780
|
DEFAULT_VARIABLE_SUGGESTION_POPOVER,
|
|
5624
5781
|
DEFAULT_VARIABLE_TRIGGER_CHAR,
|
|
5625
5782
|
Footer,
|
|
5783
|
+
HTMLCodeBlockExtension,
|
|
5626
5784
|
HorizontalRule,
|
|
5627
5785
|
ImageExtension,
|
|
5628
5786
|
ImageUploadExtension,
|