@maily-to/core 0.2.1 → 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.
@@ -11,6 +11,7 @@ import * as _tiptap_react from '@tiptap/react';
11
11
  import * as _tiptap_extension_image from '@tiptap/extension-image';
12
12
  import { Node as Node$1 } from '@tiptap/pm/model';
13
13
  import * as react from 'react';
14
+ import * as _tiptap_extension_code_block_lowlight from '@tiptap/extension-code-block-lowlight';
14
15
 
15
16
  type ColorStorage = {
16
17
  /**
@@ -391,4 +392,34 @@ declare const VariableList: react.ForwardRefExoticComponent<{
391
392
  } & SuggestionOptions<any, any> & react.RefAttributes<unknown>>;
392
393
  declare function getVariableSuggestions(char?: string): Omit<SuggestionOptions, 'editor'>;
393
394
 
394
- export { type AllowedButtonBorderRadius, type AllowedButtonVariant, type AllowedColumnVerticalAlign, type AllowedLogoAlignment, type AllowedLogoSize, type ButtonAttributes, ButtonExtension, Color, ColumnExtension, ColumnsExtension, DEFAULT_BUTTON_ALIGNMENT, DEFAULT_BUTTON_BACKGROUND_COLOR, DEFAULT_BUTTON_BORDER_RADIUS, DEFAULT_BUTTON_PADDING_BOTTOM, DEFAULT_BUTTON_PADDING_LEFT, DEFAULT_BUTTON_PADDING_RIGHT, DEFAULT_BUTTON_PADDING_TOP, DEFAULT_BUTTON_TEXT_COLOR, DEFAULT_BUTTON_VARIANT, DEFAULT_COLUMNS_GAP, DEFAULT_COLUMN_VERTICAL_ALIGN, DEFAULT_COLUMN_WIDTH, DEFAULT_LOGO_SIZE, DEFAULT_RENDER_VARIABLE_FUNCTION, DEFAULT_SECTION_ALIGN, DEFAULT_SECTION_BACKGROUND_COLOR, DEFAULT_SECTION_BORDER_COLOR, DEFAULT_SECTION_BORDER_RADIUS, DEFAULT_SECTION_BORDER_WIDTH, DEFAULT_SECTION_MARGIN_BOTTOM, DEFAULT_SECTION_MARGIN_LEFT, DEFAULT_SECTION_MARGIN_RIGHT, DEFAULT_SECTION_MARGIN_TOP, DEFAULT_SECTION_PADDING_BOTTOM, DEFAULT_SECTION_PADDING_LEFT, DEFAULT_SECTION_PADDING_RIGHT, DEFAULT_SECTION_PADDING_TOP, DEFAULT_SECTION_SHOW_IF_KEY, DEFAULT_SPACER_HEIGHT, DEFAULT_VARIABLES, DEFAULT_VARIABLE_SUGGESTION_POPOVER, DEFAULT_VARIABLE_TRIGGER_CHAR, Footer, type FooterOptions, HorizontalRule, ImageExtension, ImageUploadExtension, type ImageUploadOptions, ImageUploadPlugin, type ImageUploadPluginOptions, type ImageUploadStorage, LinkExtension, type LogoAttributes, LogoExtension, MailyKit, type MailyKitOptions, PlaceholderExtension, type RenderVariableFunction, type RenderVariableOptions, RepeatExtension, SectionExtension, SlashCommandExtension, type SlashCommandOptions, Spacer, type SpacerOptions, type Variable, VariableExtension, type VariableFunctionOptions, VariableList, type VariableListProps, type VariableOptions, VariablePluginKey, type VariableStorage, type Variables, type VariablesFunction, allowedButtonBorderRadius, allowedButtonVariant, allowedLogoAlignment, allowedLogoSize, getSlashCommandSuggestions, getVariableSuggestions, logoSizes, useImageUploadOptions };
395
+ type HtmlCodeBlockAttributes = {
396
+ activeTab: string;
397
+ showIfKey: string;
398
+ language: string;
399
+ };
400
+ declare module '@tiptap/core' {
401
+ interface Commands<ReturnType> {
402
+ htmlCodeBlock: {
403
+ /**
404
+ * Set a code block
405
+ * @param attributes Code block attributes
406
+ * @example editor.commands.setCodeBlock({ language: 'javascript' })
407
+ */
408
+ setHtmlCodeBlock: (attributes?: {
409
+ language: string;
410
+ }) => ReturnType;
411
+ /**
412
+ * Toggle a code block
413
+ * @param attributes Code block attributes
414
+ * @example editor.commands.toggleCodeBlock({ language: 'javascript' })
415
+ */
416
+ toggleHtmlCodeBlock: (attributes?: {
417
+ language: string;
418
+ }) => ReturnType;
419
+ updateHtmlCodeBlock: (attrs: Partial<HtmlCodeBlockAttributes>) => ReturnType;
420
+ };
421
+ }
422
+ }
423
+ declare const HTMLCodeBlockExtension: _tiptap_react.Node<_tiptap_extension_code_block_lowlight.CodeBlockLowlightOptions, any>;
424
+
425
+ export { type AllowedButtonBorderRadius, type AllowedButtonVariant, type AllowedColumnVerticalAlign, type AllowedLogoAlignment, type AllowedLogoSize, type ButtonAttributes, ButtonExtension, Color, ColumnExtension, ColumnsExtension, DEFAULT_BUTTON_ALIGNMENT, DEFAULT_BUTTON_BACKGROUND_COLOR, DEFAULT_BUTTON_BORDER_RADIUS, DEFAULT_BUTTON_PADDING_BOTTOM, DEFAULT_BUTTON_PADDING_LEFT, DEFAULT_BUTTON_PADDING_RIGHT, DEFAULT_BUTTON_PADDING_TOP, DEFAULT_BUTTON_TEXT_COLOR, DEFAULT_BUTTON_VARIANT, DEFAULT_COLUMNS_GAP, DEFAULT_COLUMN_VERTICAL_ALIGN, DEFAULT_COLUMN_WIDTH, DEFAULT_LOGO_SIZE, DEFAULT_RENDER_VARIABLE_FUNCTION, DEFAULT_SECTION_ALIGN, DEFAULT_SECTION_BACKGROUND_COLOR, DEFAULT_SECTION_BORDER_COLOR, DEFAULT_SECTION_BORDER_RADIUS, DEFAULT_SECTION_BORDER_WIDTH, DEFAULT_SECTION_MARGIN_BOTTOM, DEFAULT_SECTION_MARGIN_LEFT, DEFAULT_SECTION_MARGIN_RIGHT, DEFAULT_SECTION_MARGIN_TOP, DEFAULT_SECTION_PADDING_BOTTOM, DEFAULT_SECTION_PADDING_LEFT, DEFAULT_SECTION_PADDING_RIGHT, DEFAULT_SECTION_PADDING_TOP, DEFAULT_SECTION_SHOW_IF_KEY, DEFAULT_SPACER_HEIGHT, DEFAULT_VARIABLES, DEFAULT_VARIABLE_SUGGESTION_POPOVER, DEFAULT_VARIABLE_TRIGGER_CHAR, Footer, type FooterOptions, HTMLCodeBlockExtension, HorizontalRule, type HtmlCodeBlockAttributes, ImageExtension, ImageUploadExtension, type ImageUploadOptions, ImageUploadPlugin, type ImageUploadPluginOptions, type ImageUploadStorage, LinkExtension, type LogoAttributes, LogoExtension, MailyKit, type MailyKitOptions, PlaceholderExtension, type RenderVariableFunction, type RenderVariableOptions, RepeatExtension, SectionExtension, SlashCommandExtension, type SlashCommandOptions, Spacer, type SpacerOptions, type Variable, VariableExtension, type VariableFunctionOptions, VariableList, type VariableListProps, type VariableOptions, VariablePluginKey, type VariableStorage, type Variables, type VariablesFunction, allowedButtonBorderRadius, allowedButtonVariant, allowedLogoAlignment, allowedLogoSize, getSlashCommandSuggestions, getVariableSuggestions, logoSizes, useImageUploadOptions };
@@ -11,6 +11,7 @@ import * as _tiptap_react from '@tiptap/react';
11
11
  import * as _tiptap_extension_image from '@tiptap/extension-image';
12
12
  import { Node as Node$1 } from '@tiptap/pm/model';
13
13
  import * as react from 'react';
14
+ import * as _tiptap_extension_code_block_lowlight from '@tiptap/extension-code-block-lowlight';
14
15
 
15
16
  type ColorStorage = {
16
17
  /**
@@ -391,4 +392,34 @@ declare const VariableList: react.ForwardRefExoticComponent<{
391
392
  } & SuggestionOptions<any, any> & react.RefAttributes<unknown>>;
392
393
  declare function getVariableSuggestions(char?: string): Omit<SuggestionOptions, 'editor'>;
393
394
 
394
- export { type AllowedButtonBorderRadius, type AllowedButtonVariant, type AllowedColumnVerticalAlign, type AllowedLogoAlignment, type AllowedLogoSize, type ButtonAttributes, ButtonExtension, Color, ColumnExtension, ColumnsExtension, DEFAULT_BUTTON_ALIGNMENT, DEFAULT_BUTTON_BACKGROUND_COLOR, DEFAULT_BUTTON_BORDER_RADIUS, DEFAULT_BUTTON_PADDING_BOTTOM, DEFAULT_BUTTON_PADDING_LEFT, DEFAULT_BUTTON_PADDING_RIGHT, DEFAULT_BUTTON_PADDING_TOP, DEFAULT_BUTTON_TEXT_COLOR, DEFAULT_BUTTON_VARIANT, DEFAULT_COLUMNS_GAP, DEFAULT_COLUMN_VERTICAL_ALIGN, DEFAULT_COLUMN_WIDTH, DEFAULT_LOGO_SIZE, DEFAULT_RENDER_VARIABLE_FUNCTION, DEFAULT_SECTION_ALIGN, DEFAULT_SECTION_BACKGROUND_COLOR, DEFAULT_SECTION_BORDER_COLOR, DEFAULT_SECTION_BORDER_RADIUS, DEFAULT_SECTION_BORDER_WIDTH, DEFAULT_SECTION_MARGIN_BOTTOM, DEFAULT_SECTION_MARGIN_LEFT, DEFAULT_SECTION_MARGIN_RIGHT, DEFAULT_SECTION_MARGIN_TOP, DEFAULT_SECTION_PADDING_BOTTOM, DEFAULT_SECTION_PADDING_LEFT, DEFAULT_SECTION_PADDING_RIGHT, DEFAULT_SECTION_PADDING_TOP, DEFAULT_SECTION_SHOW_IF_KEY, DEFAULT_SPACER_HEIGHT, DEFAULT_VARIABLES, DEFAULT_VARIABLE_SUGGESTION_POPOVER, DEFAULT_VARIABLE_TRIGGER_CHAR, Footer, type FooterOptions, HorizontalRule, ImageExtension, ImageUploadExtension, type ImageUploadOptions, ImageUploadPlugin, type ImageUploadPluginOptions, type ImageUploadStorage, LinkExtension, type LogoAttributes, LogoExtension, MailyKit, type MailyKitOptions, PlaceholderExtension, type RenderVariableFunction, type RenderVariableOptions, RepeatExtension, SectionExtension, SlashCommandExtension, type SlashCommandOptions, Spacer, type SpacerOptions, type Variable, VariableExtension, type VariableFunctionOptions, VariableList, type VariableListProps, type VariableOptions, VariablePluginKey, type VariableStorage, type Variables, type VariablesFunction, allowedButtonBorderRadius, allowedButtonVariant, allowedLogoAlignment, allowedLogoSize, getSlashCommandSuggestions, getVariableSuggestions, logoSizes, useImageUploadOptions };
395
+ type HtmlCodeBlockAttributes = {
396
+ activeTab: string;
397
+ showIfKey: string;
398
+ language: string;
399
+ };
400
+ declare module '@tiptap/core' {
401
+ interface Commands<ReturnType> {
402
+ htmlCodeBlock: {
403
+ /**
404
+ * Set a code block
405
+ * @param attributes Code block attributes
406
+ * @example editor.commands.setCodeBlock({ language: 'javascript' })
407
+ */
408
+ setHtmlCodeBlock: (attributes?: {
409
+ language: string;
410
+ }) => ReturnType;
411
+ /**
412
+ * Toggle a code block
413
+ * @param attributes Code block attributes
414
+ * @example editor.commands.toggleCodeBlock({ language: 'javascript' })
415
+ */
416
+ toggleHtmlCodeBlock: (attributes?: {
417
+ language: string;
418
+ }) => ReturnType;
419
+ updateHtmlCodeBlock: (attrs: Partial<HtmlCodeBlockAttributes>) => ReturnType;
420
+ };
421
+ }
422
+ }
423
+ declare const HTMLCodeBlockExtension: _tiptap_react.Node<_tiptap_extension_code_block_lowlight.CodeBlockLowlightOptions, any>;
424
+
425
+ export { type AllowedButtonBorderRadius, type AllowedButtonVariant, type AllowedColumnVerticalAlign, type AllowedLogoAlignment, type AllowedLogoSize, type ButtonAttributes, ButtonExtension, Color, ColumnExtension, ColumnsExtension, DEFAULT_BUTTON_ALIGNMENT, DEFAULT_BUTTON_BACKGROUND_COLOR, DEFAULT_BUTTON_BORDER_RADIUS, DEFAULT_BUTTON_PADDING_BOTTOM, DEFAULT_BUTTON_PADDING_LEFT, DEFAULT_BUTTON_PADDING_RIGHT, DEFAULT_BUTTON_PADDING_TOP, DEFAULT_BUTTON_TEXT_COLOR, DEFAULT_BUTTON_VARIANT, DEFAULT_COLUMNS_GAP, DEFAULT_COLUMN_VERTICAL_ALIGN, DEFAULT_COLUMN_WIDTH, DEFAULT_LOGO_SIZE, DEFAULT_RENDER_VARIABLE_FUNCTION, DEFAULT_SECTION_ALIGN, DEFAULT_SECTION_BACKGROUND_COLOR, DEFAULT_SECTION_BORDER_COLOR, DEFAULT_SECTION_BORDER_RADIUS, DEFAULT_SECTION_BORDER_WIDTH, DEFAULT_SECTION_MARGIN_BOTTOM, DEFAULT_SECTION_MARGIN_LEFT, DEFAULT_SECTION_MARGIN_RIGHT, DEFAULT_SECTION_MARGIN_TOP, DEFAULT_SECTION_PADDING_BOTTOM, DEFAULT_SECTION_PADDING_LEFT, DEFAULT_SECTION_PADDING_RIGHT, DEFAULT_SECTION_PADDING_TOP, DEFAULT_SECTION_SHOW_IF_KEY, DEFAULT_SPACER_HEIGHT, DEFAULT_VARIABLES, DEFAULT_VARIABLE_SUGGESTION_POPOVER, DEFAULT_VARIABLE_TRIGGER_CHAR, Footer, type FooterOptions, HTMLCodeBlockExtension, HorizontalRule, type HtmlCodeBlockAttributes, ImageExtension, ImageUploadExtension, type ImageUploadOptions, ImageUploadPlugin, type ImageUploadPluginOptions, type ImageUploadStorage, LinkExtension, type LogoAttributes, LogoExtension, MailyKit, type MailyKitOptions, PlaceholderExtension, type RenderVariableFunction, type RenderVariableOptions, RepeatExtension, SectionExtension, SlashCommandExtension, type SlashCommandOptions, Spacer, type SpacerOptions, type Variable, VariableExtension, type VariableFunctionOptions, VariableList, type VariableListProps, type VariableOptions, VariablePluginKey, type VariableStorage, type Variables, type VariablesFunction, allowedButtonBorderRadius, allowedButtonVariant, allowedLogoAlignment, allowedLogoSize, getSlashCommandSuggestions, getVariableSuggestions, logoSizes, useImageUploadOptions };
@@ -116,6 +116,7 @@ __export(extensions_exports, {
116
116
  DEFAULT_VARIABLE_SUGGESTION_POPOVER: () => DEFAULT_VARIABLE_SUGGESTION_POPOVER,
117
117
  DEFAULT_VARIABLE_TRIGGER_CHAR: () => DEFAULT_VARIABLE_TRIGGER_CHAR,
118
118
  Footer: () => Footer,
119
+ HTMLCodeBlockExtension: () => HTMLCodeBlockExtension,
119
120
  HorizontalRule: () => HorizontalRule,
120
121
  ImageExtension: () => ImageExtension,
121
122
  ImageUploadExtension: () => ImageUploadExtension,
@@ -5633,6 +5634,161 @@ function getVariableSuggestions(char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
5633
5634
  }
5634
5635
  };
5635
5636
  }
5637
+
5638
+ // src/editor/nodes/html/html.tsx
5639
+ var import_extension_code_block_lowlight = __toESM(require("@tiptap/extension-code-block-lowlight"));
5640
+ var import_state5 = require("@tiptap/pm/state");
5641
+ var import_react37 = require("@tiptap/react");
5642
+ var import_xml = __toESM(require("highlight.js/lib/languages/xml"));
5643
+ var import_lowlight = require("lowlight");
5644
+
5645
+ // src/editor/nodes/html/html-view.tsx
5646
+ var import_react35 = require("@tiptap/react");
5647
+ var import_react36 = require("react");
5648
+ var import_jsx_runtime37 = require("react/jsx-runtime");
5649
+ function HTMLCodeBlockView(props) {
5650
+ const { node, updateAttributes: updateAttributes2 } = props;
5651
+ let { language, activeTab = "code" } = node.attrs;
5652
+ activeTab || (activeTab = "code");
5653
+ const languageClass = language ? `language-${language}` : "";
5654
+ const html2 = (0, import_react36.useMemo)(() => {
5655
+ const text2 = node.content.content.reduce((acc, cur) => {
5656
+ if (cur.type.name === "text") {
5657
+ return acc + cur.text;
5658
+ } else if (cur.type.name === "variable") {
5659
+ const { id: variable, fallback } = (cur == null ? void 0 : cur.attrs) || {};
5660
+ const formattedVariable = fallback ? `{{${variable},fallback=${fallback}}}` : `{{${variable}}}`;
5661
+ return acc + formattedVariable;
5662
+ }
5663
+ return acc;
5664
+ }, "");
5665
+ const htmlParser = new DOMParser();
5666
+ const htmlDoc = htmlParser.parseFromString(text2, "text/html");
5667
+ const body = htmlDoc.body;
5668
+ return body.innerHTML;
5669
+ }, [activeTab]);
5670
+ const isEmpty = html2 === "";
5671
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
5672
+ import_react35.NodeViewWrapper,
5673
+ {
5674
+ draggable: false,
5675
+ "data-drag-handle": false,
5676
+ "data-type": "htmlCodeBlock",
5677
+ children: [
5678
+ activeTab === "code" && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("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__ */ (0, import_jsx_runtime37.jsx)(
5679
+ import_react35.NodeViewContent,
5680
+ {
5681
+ as: "code",
5682
+ className: cn("is-editable", languageClass)
5683
+ }
5684
+ ) }),
5685
+ activeTab === "preview" && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
5686
+ "div",
5687
+ {
5688
+ className: cn(
5689
+ "mly-not-prose mly-rounded-lg mly-border mly-border-gray-200 mly-p-2",
5690
+ isEmpty && "mly-min-h-[42px]"
5691
+ ),
5692
+ dangerouslySetInnerHTML: { __html: html2 },
5693
+ contentEditable: false,
5694
+ onClick: () => {
5695
+ if (!isEmpty) {
5696
+ return;
5697
+ }
5698
+ updateAttributes2({
5699
+ activeTab: "code"
5700
+ });
5701
+ }
5702
+ }
5703
+ )
5704
+ ]
5705
+ }
5706
+ );
5707
+ }
5708
+
5709
+ // src/editor/nodes/html/html.tsx
5710
+ var lowlight = (0, import_lowlight.createLowlight)(import_lowlight.common);
5711
+ lowlight.register("html", import_xml.default);
5712
+ var HTMLCodeBlockExtension = import_extension_code_block_lowlight.default.extend({
5713
+ name: "htmlCodeBlock",
5714
+ content: "(text|variable)*",
5715
+ addAttributes() {
5716
+ var _a;
5717
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
5718
+ activeTab: "code",
5719
+ showIfKey: {
5720
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
5721
+ parseHTML: (element) => {
5722
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
5723
+ },
5724
+ renderHTML(attributes) {
5725
+ if (!attributes.showIfKey) {
5726
+ return {};
5727
+ }
5728
+ return {
5729
+ "data-show-if-key": attributes.showIfKey
5730
+ };
5731
+ }
5732
+ }
5733
+ });
5734
+ },
5735
+ addNodeView() {
5736
+ return (0, import_react37.ReactNodeViewRenderer)(HTMLCodeBlockView, {
5737
+ className: "mly-relative",
5738
+ attrs: ({ node }) => {
5739
+ var _a;
5740
+ return {
5741
+ "data-active-tab": ((_a = node == null ? void 0 : node.attrs) == null ? void 0 : _a.activeTab) || "code"
5742
+ };
5743
+ }
5744
+ });
5745
+ },
5746
+ addCommands() {
5747
+ return {
5748
+ setHtmlCodeBlock: (attributes) => ({ commands }) => {
5749
+ return commands.setNode(this.name, attributes);
5750
+ },
5751
+ toggleHtmlCodeBlock: (attributes) => ({ commands }) => {
5752
+ return commands.toggleNode(this.name, "paragraph", attributes);
5753
+ },
5754
+ updateHtmlCodeBlock: (attrs) => updateAttributes(this.name, attrs)
5755
+ };
5756
+ },
5757
+ addKeyboardShortcuts() {
5758
+ var _a;
5759
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
5760
+ "Mod-a": ({ editor }) => {
5761
+ const { selection } = editor.state;
5762
+ const $pos = selection.$anchor;
5763
+ const node = $pos.node($pos.depth);
5764
+ if (node.type.name !== this.name) {
5765
+ return false;
5766
+ }
5767
+ let depth = $pos.depth;
5768
+ for (let d = depth; d > 0; d--) {
5769
+ if ($pos.node(d).type.name === this.name) {
5770
+ depth = d;
5771
+ break;
5772
+ }
5773
+ }
5774
+ const start = $pos.before(depth) + 1;
5775
+ const end = $pos.after(depth) - 1;
5776
+ const from = editor.state.doc.resolve(start);
5777
+ const to = editor.state.doc.resolve(end);
5778
+ if (from && to) {
5779
+ const transaction = editor.state.tr.setSelection(
5780
+ import_state5.TextSelection.between(from, to)
5781
+ );
5782
+ editor.view.dispatch(transaction);
5783
+ return true;
5784
+ }
5785
+ return false;
5786
+ }
5787
+ });
5788
+ }
5789
+ }).configure({
5790
+ lowlight
5791
+ });
5636
5792
  // Annotate the CommonJS export names for ESM import in node:
5637
5793
  0 && (module.exports = {
5638
5794
  ButtonExtension,
@@ -5672,6 +5828,7 @@ function getVariableSuggestions(char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
5672
5828
  DEFAULT_VARIABLE_SUGGESTION_POPOVER,
5673
5829
  DEFAULT_VARIABLE_TRIGGER_CHAR,
5674
5830
  Footer,
5831
+ HTMLCodeBlockExtension,
5675
5832
  HorizontalRule,
5676
5833
  ImageExtension,
5677
5834
  ImageUploadExtension,