@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.js CHANGED
@@ -4352,13 +4352,17 @@ var useTextMenuState = (editor) => {
4352
4352
  const states = (0, import_react36.useEditorState)({
4353
4353
  editor,
4354
4354
  selector: (ctx) => {
4355
- var _a, _b, _c, _d, _e, _f;
4355
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4356
4356
  return {
4357
4357
  currentTextColor: ctx.editor.getAttributes("textStyle").color || DEFAULT_TEXT_COLOR,
4358
4358
  linkUrl: (_a = ctx.editor) == null ? void 0 : _a.getAttributes("link").href,
4359
4359
  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",
4360
4360
  isListActive: ctx.editor.isActive("bulletList") || ctx.editor.isActive("orderedList"),
4361
- isUrlVariable: (_f = ctx.editor.getAttributes("link").isUrlVariable) != null ? _f : false
4361
+ isUrlVariable: (_f = ctx.editor.getAttributes("link").isUrlVariable) != null ? _f : false,
4362
+ isHeadingActive: ctx.editor.isActive("heading"),
4363
+ headingShowIfKey: ((_g = ctx.editor.getAttributes("heading")) == null ? void 0 : _g.showIfKey) || "",
4364
+ isParagraphActive: ctx.editor.isActive("paragraph"),
4365
+ paragraphShowIfKey: ((_h = ctx.editor.getAttributes("paragraph")) == null ? void 0 : _h.showIfKey) || ""
4362
4366
  };
4363
4367
  },
4364
4368
  equalityFn: import_fast_deep_equal6.default
@@ -6077,6 +6081,7 @@ function TextBubbleMenu(props) {
6077
6081
  const turnIntoBlockOptions = useTurnIntoBlockOptions(editor);
6078
6082
  const colors = editor == null ? void 0 : editor.storage.color.colors;
6079
6083
  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 : [];
6084
+ const showIfKey = (state == null ? void 0 : state.isHeadingActive) ? state == null ? void 0 : state.headingShowIfKey : state == null ? void 0 : state.paragraphShowIfKey;
6080
6085
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
6081
6086
  import_react51.BubbleMenu,
6082
6087
  __spreadProps(__spreadValues({}, bubbleMenuProps), {
@@ -6167,6 +6172,22 @@ function TextBubbleMenu(props) {
6167
6172
  }
6168
6173
  )
6169
6174
  }
6175
+ ),
6176
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Divider, { className: "mly-mx-0" }),
6177
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
6178
+ ShowPopover,
6179
+ {
6180
+ showIfKey,
6181
+ onShowIfKeyValueChange: (value) => {
6182
+ editor == null ? void 0 : editor.chain().updateAttributes(
6183
+ state.isHeadingActive ? "heading" : "paragraph",
6184
+ {
6185
+ showIfKey: value
6186
+ }
6187
+ ).run();
6188
+ },
6189
+ editor
6190
+ }
6170
6191
  )
6171
6192
  ] })
6172
6193
  })
@@ -6287,11 +6308,11 @@ function getVariableSuggestions(variables = DEFAULT_VARIABLES, char = DEFAULT_VA
6287
6308
  var import_core15 = require("@tiptap/core");
6288
6309
  var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
6289
6310
  var import_extension_list_item = __toESM(require("@tiptap/extension-list-item"));
6290
- var import_extension_paragraph = __toESM(require("@tiptap/extension-paragraph"));
6311
+ var import_extension_paragraph2 = __toESM(require("@tiptap/extension-paragraph"));
6291
6312
  var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"));
6292
6313
  var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"));
6293
6314
  var import_extension_text_style = __toESM(require("@tiptap/extension-text-style"));
6294
- var import_extension_heading = __toESM(require("@tiptap/extension-heading"));
6315
+ var import_extension_heading2 = __toESM(require("@tiptap/extension-heading"));
6295
6316
  var import_extension_underline = __toESM(require("@tiptap/extension-underline"));
6296
6317
  var import_extension_document = __toESM(require("@tiptap/extension-document"));
6297
6318
  var import_extension_focus = __toESM(require("@tiptap/extension-focus"));
@@ -6368,6 +6389,54 @@ var LinkExtension = import_extension_link.default.extend({
6368
6389
  }
6369
6390
  });
6370
6391
 
6392
+ // src/editor/nodes/heading/heading.ts
6393
+ var import_extension_heading = __toESM(require("@tiptap/extension-heading"));
6394
+ var HeadingExtension = import_extension_heading.default.extend({
6395
+ addAttributes() {
6396
+ var _a;
6397
+ return __spreadProps(__spreadValues({}, ((_a = this == null ? void 0 : this.parent) == null ? void 0 : _a.call(this)) || {}), {
6398
+ showIfKey: {
6399
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
6400
+ parseHTML: (element) => {
6401
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
6402
+ },
6403
+ renderHTML(attributes) {
6404
+ if (!attributes.showIfKey) {
6405
+ return {};
6406
+ }
6407
+ return {
6408
+ "data-show-if-key": attributes.showIfKey
6409
+ };
6410
+ }
6411
+ }
6412
+ });
6413
+ }
6414
+ });
6415
+
6416
+ // src/editor/nodes/paragraph/paragraph.ts
6417
+ var import_extension_paragraph = __toESM(require("@tiptap/extension-paragraph"));
6418
+ var ParagraphExtension = import_extension_paragraph.default.extend({
6419
+ addAttributes() {
6420
+ var _a;
6421
+ return __spreadProps(__spreadValues({}, ((_a = this == null ? void 0 : this.parent) == null ? void 0 : _a.call(this)) || {}), {
6422
+ showIfKey: {
6423
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
6424
+ parseHTML: (element) => {
6425
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
6426
+ },
6427
+ renderHTML(attributes) {
6428
+ if (!attributes.showIfKey) {
6429
+ return {};
6430
+ }
6431
+ return {
6432
+ "data-show-if-key": attributes.showIfKey
6433
+ };
6434
+ }
6435
+ }
6436
+ });
6437
+ }
6438
+ });
6439
+
6371
6440
  // src/editor/extensions/maily-kit.tsx
6372
6441
  var MailyKit = import_core15.Extension.create({
6373
6442
  name: "maily-kit",
@@ -6389,12 +6458,6 @@ var MailyKit = import_core15.Extension.create({
6389
6458
  content: "(block|columns)+"
6390
6459
  }),
6391
6460
  import_starter_kit.default.configure({
6392
- heading: {
6393
- levels: [1, 2, 3],
6394
- HTMLAttributes: {
6395
- class: "mly-relative"
6396
- }
6397
- },
6398
6461
  code: {
6399
6462
  HTMLAttributes: {
6400
6463
  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"
@@ -6405,11 +6468,6 @@ var MailyKit = import_core15.Extension.create({
6405
6468
  class: "mly-not-prose mly-border-l-4 mly-border-gray-300 mly-pl-4 mly-mt-4 mly-mb-4 mly-relative"
6406
6469
  }
6407
6470
  },
6408
- paragraph: {
6409
- HTMLAttributes: {
6410
- class: "mly-relative"
6411
- }
6412
- },
6413
6471
  bulletList: {
6414
6472
  HTMLAttributes: {
6415
6473
  class: "mly-relative"
@@ -6420,6 +6478,8 @@ var MailyKit = import_core15.Extension.create({
6420
6478
  class: "mly-relative"
6421
6479
  }
6422
6480
  },
6481
+ heading: false,
6482
+ paragraph: false,
6423
6483
  horizontalRule: false,
6424
6484
  dropcursor: false,
6425
6485
  document: false
@@ -6428,7 +6488,7 @@ var MailyKit = import_core15.Extension.create({
6428
6488
  Color.configure({ types: [import_extension_text_style.default.name, import_extension_list_item.default.name] }),
6429
6489
  import_extension_text_style.default.configure(),
6430
6490
  import_extension_text_align.default.configure({
6431
- types: [import_extension_paragraph.default.name, import_extension_heading.default.name, Footer.name]
6491
+ types: [import_extension_paragraph2.default.name, import_extension_heading2.default.name, Footer.name]
6432
6492
  }),
6433
6493
  HorizontalRule,
6434
6494
  import_extension_placeholder.default.configure({
@@ -6455,6 +6515,17 @@ var MailyKit = import_core15.Extension.create({
6455
6515
  color: "#555",
6456
6516
  width: 3,
6457
6517
  class: "ProseMirror-dropcursor"
6518
+ }),
6519
+ HeadingExtension.configure({
6520
+ levels: [1, 2, 3],
6521
+ HTMLAttributes: {
6522
+ class: "mly-relative"
6523
+ }
6524
+ }),
6525
+ ParagraphExtension.configure({
6526
+ HTMLAttributes: {
6527
+ class: "mly-relative"
6528
+ }
6458
6529
  })
6459
6530
  ];
6460
6531
  if (this.options.linkCard !== false) {