@maily-to/core 0.0.24 → 0.0.25

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/index.mjs CHANGED
@@ -4381,13 +4381,17 @@ var useTextMenuState = (editor) => {
4381
4381
  const states = useEditorState6({
4382
4382
  editor,
4383
4383
  selector: (ctx) => {
4384
- var _a, _b, _c, _d, _e, _f;
4384
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4385
4385
  return {
4386
4386
  currentTextColor: ctx.editor.getAttributes("textStyle").color || DEFAULT_TEXT_COLOR,
4387
4387
  linkUrl: (_a = ctx.editor) == null ? void 0 : _a.getAttributes("link").href,
4388
4388
  textAlign: ((_b = ctx.editor) == null ? void 0 : _b.isActive({ textAlign: "left" })) ? "left" : ((_c = ctx.editor) == null ? void 0 : _c.isActive({ textAlign: "center" })) ? "center" : ((_d = ctx.editor) == null ? void 0 : _d.isActive({ textAlign: "right" })) ? "right" : ((_e = ctx.editor) == null ? void 0 : _e.isActive({ textAlign: "justify" })) ? "justify" : "left",
4389
4389
  isListActive: ctx.editor.isActive("bulletList") || ctx.editor.isActive("orderedList"),
4390
- isUrlVariable: (_f = ctx.editor.getAttributes("link").isUrlVariable) != null ? _f : false
4390
+ isUrlVariable: (_f = ctx.editor.getAttributes("link").isUrlVariable) != null ? _f : false,
4391
+ isHeadingActive: ctx.editor.isActive("heading"),
4392
+ headingShowIfKey: ((_g = ctx.editor.getAttributes("heading")) == null ? void 0 : _g.showIfKey) || "",
4393
+ isParagraphActive: ctx.editor.isActive("paragraph"),
4394
+ paragraphShowIfKey: ((_h = ctx.editor.getAttributes("paragraph")) == null ? void 0 : _h.showIfKey) || ""
4391
4395
  };
4392
4396
  },
4393
4397
  equalityFn: deepEql6
@@ -6114,6 +6118,7 @@ function TextBubbleMenu(props) {
6114
6118
  const turnIntoBlockOptions = useTurnIntoBlockOptions(editor);
6115
6119
  const colors = editor == null ? void 0 : editor.storage.color.colors;
6116
6120
  const suggestedColors = (_c = (_b = (_a = Array == null ? void 0 : Array.from(colors)) == null ? void 0 : _a.reverse()) == null ? void 0 : _b.slice(0, 6)) != null ? _c : [];
6121
+ const showIfKey = (state == null ? void 0 : state.isHeadingActive) ? state == null ? void 0 : state.headingShowIfKey : state == null ? void 0 : state.paragraphShowIfKey;
6117
6122
  return /* @__PURE__ */ jsx44(
6118
6123
  BubbleMenu6,
6119
6124
  __spreadProps(__spreadValues({}, bubbleMenuProps), {
@@ -6204,6 +6209,22 @@ function TextBubbleMenu(props) {
6204
6209
  }
6205
6210
  )
6206
6211
  }
6212
+ ),
6213
+ /* @__PURE__ */ jsx44(Divider, { className: "mly-mx-0" }),
6214
+ /* @__PURE__ */ jsx44(
6215
+ ShowPopover,
6216
+ {
6217
+ showIfKey,
6218
+ onShowIfKeyValueChange: (value) => {
6219
+ editor == null ? void 0 : editor.chain().updateAttributes(
6220
+ state.isHeadingActive ? "heading" : "paragraph",
6221
+ {
6222
+ showIfKey: value
6223
+ }
6224
+ ).run();
6225
+ },
6226
+ editor
6227
+ }
6207
6228
  )
6208
6229
  ] })
6209
6230
  })
@@ -6405,6 +6426,54 @@ var LinkExtension = TiptapLink.extend({
6405
6426
  }
6406
6427
  });
6407
6428
 
6429
+ // src/editor/nodes/heading/heading.ts
6430
+ import TiptapHeading from "@tiptap/extension-heading";
6431
+ var HeadingExtension = TiptapHeading.extend({
6432
+ addAttributes() {
6433
+ var _a;
6434
+ return __spreadProps(__spreadValues({}, ((_a = this == null ? void 0 : this.parent) == null ? void 0 : _a.call(this)) || {}), {
6435
+ showIfKey: {
6436
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
6437
+ parseHTML: (element) => {
6438
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
6439
+ },
6440
+ renderHTML(attributes) {
6441
+ if (!attributes.showIfKey) {
6442
+ return {};
6443
+ }
6444
+ return {
6445
+ "data-show-if-key": attributes.showIfKey
6446
+ };
6447
+ }
6448
+ }
6449
+ });
6450
+ }
6451
+ });
6452
+
6453
+ // src/editor/nodes/paragraph/paragraph.ts
6454
+ import TiptapParagraph from "@tiptap/extension-paragraph";
6455
+ var ParagraphExtension = TiptapParagraph.extend({
6456
+ addAttributes() {
6457
+ var _a;
6458
+ return __spreadProps(__spreadValues({}, ((_a = this == null ? void 0 : this.parent) == null ? void 0 : _a.call(this)) || {}), {
6459
+ showIfKey: {
6460
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
6461
+ parseHTML: (element) => {
6462
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
6463
+ },
6464
+ renderHTML(attributes) {
6465
+ if (!attributes.showIfKey) {
6466
+ return {};
6467
+ }
6468
+ return {
6469
+ "data-show-if-key": attributes.showIfKey
6470
+ };
6471
+ }
6472
+ }
6473
+ });
6474
+ }
6475
+ });
6476
+
6408
6477
  // src/editor/extensions/maily-kit.tsx
6409
6478
  var MailyKit = Extension.create({
6410
6479
  name: "maily-kit",
@@ -6426,12 +6495,6 @@ var MailyKit = Extension.create({
6426
6495
  content: "(block|columns)+"
6427
6496
  }),
6428
6497
  StarterKit.configure({
6429
- heading: {
6430
- levels: [1, 2, 3],
6431
- HTMLAttributes: {
6432
- class: "mly-relative"
6433
- }
6434
- },
6435
6498
  code: {
6436
6499
  HTMLAttributes: {
6437
6500
  class: "mly-px-1 mly-relative mly-py-0.5 mly-bg-[#efefef] mly-text-sm mly-rounded-md mly-tracking-normal mly-font-normal"
@@ -6442,11 +6505,6 @@ var MailyKit = Extension.create({
6442
6505
  class: "mly-not-prose mly-border-l-4 mly-border-gray-300 mly-pl-4 mly-mt-4 mly-mb-4 mly-relative"
6443
6506
  }
6444
6507
  },
6445
- paragraph: {
6446
- HTMLAttributes: {
6447
- class: "mly-relative"
6448
- }
6449
- },
6450
6508
  bulletList: {
6451
6509
  HTMLAttributes: {
6452
6510
  class: "mly-relative"
@@ -6457,6 +6515,8 @@ var MailyKit = Extension.create({
6457
6515
  class: "mly-relative"
6458
6516
  }
6459
6517
  },
6518
+ heading: false,
6519
+ paragraph: false,
6460
6520
  horizontalRule: false,
6461
6521
  dropcursor: false,
6462
6522
  document: false
@@ -6492,6 +6552,17 @@ var MailyKit = Extension.create({
6492
6552
  color: "#555",
6493
6553
  width: 3,
6494
6554
  class: "ProseMirror-dropcursor"
6555
+ }),
6556
+ HeadingExtension.configure({
6557
+ levels: [1, 2, 3],
6558
+ HTMLAttributes: {
6559
+ class: "mly-relative"
6560
+ }
6561
+ }),
6562
+ ParagraphExtension.configure({
6563
+ HTMLAttributes: {
6564
+ class: "mly-relative"
6565
+ }
6495
6566
  })
6496
6567
  ];
6497
6568
  if (this.options.linkCard !== false) {