@clevertask/scribe 0.1.11 → 0.1.12

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.
Files changed (38) hide show
  1. package/dist/components/Menu/CalloutBubbleMenu.d.ts +7 -0
  2. package/dist/components/Menu/CalloutBubbleMenu.d.ts.map +1 -0
  3. package/dist/components/Menu/CalloutBubbleMenu.js +156 -0
  4. package/dist/components/Menu/TableBubbleMenu.d.ts.map +1 -1
  5. package/dist/components/Menu/TableBubbleMenu.js +97 -96
  6. package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts +10 -0
  7. package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts.map +1 -0
  8. package/dist/components/Menu/calloutBubbleMenuPlugin.js +22 -0
  9. package/dist/components/Menu/contextualMenuOwner.d.ts +4 -0
  10. package/dist/components/Menu/contextualMenuOwner.d.ts.map +1 -0
  11. package/dist/components/Menu/contextualMenuOwner.js +9 -0
  12. package/dist/components/Scribe/extension/callout.d.ts +32 -0
  13. package/dist/components/Scribe/extension/callout.d.ts.map +1 -0
  14. package/dist/components/Scribe/extension/callout.js +118 -0
  15. package/dist/components/Scribe/extension/extension-markdown-paste.js +1 -1
  16. package/dist/components/Scribe/extension/index.d.ts +1 -1
  17. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  18. package/dist/components/Scribe/extension/index.js +1 -1
  19. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
  20. package/dist/components/Scribe/extension/slashCommand/items.js +48 -28
  21. package/dist/components/Scribe/index.d.ts.map +1 -1
  22. package/dist/components/Scribe/index.js +126 -124
  23. package/dist/{extension-Dy6hHSvD.js → extension-_8uh0Ik9.js} +1234 -1232
  24. package/dist/{html-to-markdown-B6Uhn7ok.js → html-to-markdown-C920nQtn.js} +101 -60
  25. package/dist/icons/CalloutIcon.d.ts +9 -0
  26. package/dist/icons/CalloutIcon.d.ts.map +1 -0
  27. package/dist/icons/CalloutIcon.js +72 -0
  28. package/dist/main.css +119 -1
  29. package/dist/main.d.ts +1 -0
  30. package/dist/main.d.ts.map +1 -1
  31. package/dist/main.js +9 -8
  32. package/dist/{markdown-to-html-WmeDaJXP.js → markdown-to-html-CW0Nb9Ye.js} +32 -2
  33. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  34. package/dist/utils/html-to-markdown.js +1 -1
  35. package/dist/utils/index.js +3 -3
  36. package/dist/utils/markdown-to-html.d.ts.map +1 -1
  37. package/dist/utils/markdown-to-html.js +1 -1
  38. package/package.json +42 -19
@@ -271,10 +271,10 @@ S.prototype = {
271
271
  function C(e, t, n) {
272
272
  for (var r = 0; r < e.length; r++) {
273
273
  var i = e[r];
274
- if (w(i, t, n)) return i;
274
+ if (ee(i, t, n)) return i;
275
275
  }
276
276
  }
277
- function w(e, t, n) {
277
+ function ee(e, t, n) {
278
278
  var r = e.filter;
279
279
  if (typeof r == "string") {
280
280
  if (r === t.nodeName.toLowerCase()) return !0;
@@ -284,7 +284,7 @@ function w(e, t, n) {
284
284
  if (r.call(e, t, n)) return !0;
285
285
  } else throw TypeError("`filter` needs to be a string, array, or function");
286
286
  }
287
- function ee(e) {
287
+ function w(e) {
288
288
  var t = e.element, n = e.isBlock, r = e.isVoid, i = e.isPre || function(e) {
289
289
  return e.nodeName === "PRE";
290
290
  };
@@ -342,41 +342,41 @@ function A() {
342
342
  }
343
343
  return e;
344
344
  }
345
- var j = O() ? D.DOMParser : k();
346
- function M(e, t) {
347
- var n = typeof e == "string" ? te().parseFromString("<x-turndown id=\"turndown-root\">" + e + "</x-turndown>", "text/html").getElementById("turndown-root") : e.cloneNode(!0);
348
- return ee({
345
+ var te = O() ? D.DOMParser : k();
346
+ function ne(e, t) {
347
+ var n = typeof e == "string" ? re().parseFromString("<x-turndown id=\"turndown-root\">" + e + "</x-turndown>", "text/html").getElementById("turndown-root") : e.cloneNode(!0);
348
+ return w({
349
349
  element: n,
350
350
  isBlock: s,
351
351
  isVoid: l,
352
- isPre: t.preformattedCode ? ne : null
352
+ isPre: t.preformattedCode ? ie : null
353
353
  }), n;
354
354
  }
355
- var N;
356
- function te() {
357
- return N ||= new j(), N;
355
+ var j;
356
+ function re() {
357
+ return j ||= new te(), j;
358
358
  }
359
- function ne(e) {
359
+ function ie(e) {
360
360
  return e.nodeName === "PRE" || e.nodeName === "CODE";
361
361
  }
362
- function P(e, t) {
363
- return e.isBlock = s(e), e.isCode = e.nodeName === "CODE" || e.parentNode.isCode, e.isBlank = F(e), e.flankingWhitespace = I(e, t), e;
362
+ function M(e, t) {
363
+ return e.isBlock = s(e), e.isCode = e.nodeName === "CODE" || e.parentNode.isCode, e.isBlank = N(e), e.flankingWhitespace = P(e, t), e;
364
364
  }
365
- function F(e) {
365
+ function N(e) {
366
366
  return !l(e) && !f(e) && /^\s*$/i.test(e.textContent) && !u(e) && !p(e);
367
367
  }
368
- function I(e, t) {
368
+ function P(e, t) {
369
369
  if (e.isBlock || t.preformattedCode && e.isCode) return {
370
370
  leading: "",
371
371
  trailing: ""
372
372
  };
373
- var n = L(e.textContent);
374
- return n.leadingAscii && R("left", e, t) && (n.leading = n.leadingNonAscii), n.trailingAscii && R("right", e, t) && (n.trailing = n.trailingNonAscii), {
373
+ var n = F(e.textContent);
374
+ return n.leadingAscii && I("left", e, t) && (n.leading = n.leadingNonAscii), n.trailingAscii && I("right", e, t) && (n.trailing = n.trailingNonAscii), {
375
375
  leading: n.leading,
376
376
  trailing: n.trailing
377
377
  };
378
378
  }
379
- function L(e) {
379
+ function F(e) {
380
380
  var t = e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
381
381
  return {
382
382
  leading: t[1],
@@ -387,13 +387,13 @@ function L(e) {
387
387
  trailingAscii: t[6]
388
388
  };
389
389
  }
390
- function R(e, t, n) {
390
+ function I(e, t, n) {
391
391
  var r, i, a;
392
392
  return e === "left" ? (r = t.previousSibling, i = / $/) : (r = t.nextSibling, i = /^ /), r && (r.nodeType === 3 ? a = i.test(r.nodeValue) : n.preformattedCode && r.nodeName === "CODE" ? a = !1 : r.nodeType === 1 && !s(r) && (a = i.test(r.textContent))), a;
393
393
  }
394
- var z = Array.prototype.reduce;
395
- function B(e) {
396
- if (!(this instanceof B)) return new B(e);
394
+ var L = Array.prototype.reduce;
395
+ function R(e) {
396
+ if (!(this instanceof R)) return new R(e);
397
397
  var n = {
398
398
  rules: v,
399
399
  headingStyle: "setext",
@@ -419,12 +419,12 @@ function B(e) {
419
419
  };
420
420
  this.options = t({}, n, e), this.rules = new S(this.options);
421
421
  }
422
- B.prototype = {
422
+ R.prototype = {
423
423
  turndown: function(e) {
424
- if (!G(e)) throw TypeError(e + " is not a string, or an element/document/fragment node.");
424
+ if (!U(e)) throw TypeError(e + " is not a string, or an element/document/fragment node.");
425
425
  if (e === "") return "";
426
- var t = V.call(this, new M(e, this.options));
427
- return H.call(this, t);
426
+ var t = z.call(this, new ne(e, this.options));
427
+ return B.call(this, t);
428
428
  },
429
429
  use: function(e) {
430
430
  if (Array.isArray(e)) for (var t = 0; t < e.length; t++) this.use(e[t]);
@@ -445,34 +445,44 @@ B.prototype = {
445
445
  return _(e);
446
446
  }
447
447
  };
448
- function V(e) {
448
+ function z(e) {
449
449
  var t = this;
450
- return z.call(e.childNodes, function(e, n) {
451
- n = new P(n, t.options);
450
+ return L.call(e.childNodes, function(e, n) {
451
+ n = new M(n, t.options);
452
452
  var r = "";
453
- return n.nodeType === 3 ? r = n.isCode ? n.nodeValue : t.escape(n.nodeValue) : n.nodeType === 1 && (r = U.call(t, n)), W(e, r);
453
+ return n.nodeType === 3 ? r = n.isCode ? n.nodeValue : t.escape(n.nodeValue) : n.nodeType === 1 && (r = V.call(t, n)), H(e, r);
454
454
  }, "");
455
455
  }
456
- function H(e) {
456
+ function B(e) {
457
457
  var t = this;
458
458
  return this.rules.forEach(function(n) {
459
- typeof n.append == "function" && (e = W(e, n.append(t.options)));
459
+ typeof n.append == "function" && (e = H(e, n.append(t.options)));
460
460
  }), e.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
461
461
  }
462
- function U(e) {
463
- var t = this.rules.forNode(e), n = V.call(this, e), r = e.flankingWhitespace;
462
+ function V(e) {
463
+ var t = this.rules.forNode(e), n = z.call(this, e), r = e.flankingWhitespace;
464
464
  return (r.leading || r.trailing) && (n = n.trim()), r.leading + t.replacement(n, e, this.options) + r.trailing;
465
465
  }
466
- function W(e, t) {
466
+ function H(e, t) {
467
467
  var n = i(e), a = r(t), o = Math.max(e.length - n.length, t.length - a.length);
468
468
  return n + "\n\n".substring(0, o) + a;
469
469
  }
470
- function G(e) {
470
+ function U(e) {
471
471
  return e != null && (typeof e == "string" || e.nodeType && (e.nodeType === 1 || e.nodeType === 9 || e.nodeType === 11));
472
472
  }
473
473
  //#endregion
474
474
  //#region lib/utils/html-to-markdown.ts
475
- var K = "scribe-table-break", q = (/* @__PURE__ */ "address.article.aside.blockquote.details.dialog.dd.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.menu.nav.ol.p.pre.section.summary.table.ul".split(".")).join(","), J = /* @__PURE__ */ new Set([
475
+ var W = "scribe-table-break", G = /* @__PURE__ */ new Set([
476
+ "info",
477
+ "tip",
478
+ "warning",
479
+ "caution"
480
+ ]), K = [
481
+ "width",
482
+ "min-width",
483
+ "max-width",
484
+ "text-align"
485
+ ], q = (/* @__PURE__ */ "address.article.aside.blockquote.details.dialog.dd.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.menu.nav.ol.p.pre.section.summary.table.ul".split(".")).join(","), ae = /* @__PURE__ */ new Set([
476
486
  "A",
477
487
  "B",
478
488
  "BR",
@@ -483,55 +493,86 @@ var K = "scribe-table-break", q = (/* @__PURE__ */ "address.article.aside.
483
493
  "IMG",
484
494
  "S",
485
495
  "STRONG"
486
- ]), Y = (e) => J.has(e.tagName) || e.tagName === "SPAN" && e.getAttribute("data-type") === "latex", X = (e) => Y(e) && Array.from(e.querySelectorAll("*")).every(Y), Z = (e) => e.nodeType !== Node.TEXT_NODE || !!e.textContent?.trim(), re = (e) => {
487
- let t = Array.from(e.childNodes).filter(Z);
488
- return t.length === 0 ? !0 : t.length === 1 && t[0] instanceof HTMLParagraphElement ? !t[0].querySelector(q) && Array.from(t[0].children).every(X) : t.every((e) => !(e instanceof Element) && e.nodeType === Node.TEXT_NODE || e instanceof Element && !e.matches(q) && !e.querySelector(q) && X(e));
489
- }, ie = (e) => e.hasAttribute("width") || /(?:^|;)\s*width\s*:/i.test(e.getAttribute("style") ?? "") ? !0 : Array.from(e.querySelectorAll("th, td, col")).some((e) => !!(e.hasAttribute("colwidth") || e.hasAttribute("width") || /(?:^|;)\s*width\s*:/i.test(e.getAttribute("style") ?? ""))), Q = (e) => {
496
+ ]), J = (e) => ae.has(e.tagName) || e.tagName === "SPAN" && e.getAttribute("data-type") === "latex", Y = (e) => J(e) && Array.from(e.querySelectorAll("*")).every(J), X = (e) => e.nodeType !== Node.TEXT_NODE || !!e.textContent?.trim(), oe = (e) => {
497
+ let t = Array.from(e.childNodes).filter(X);
498
+ return t.length === 0 ? !0 : t.length === 1 && t[0] instanceof HTMLParagraphElement ? !t[0].querySelector(q) && Array.from(t[0].children).every(Y) : t.every((e) => !(e instanceof Element) && e.nodeType === Node.TEXT_NODE || e instanceof Element && !e.matches(q) && !e.querySelector(q) && Y(e));
499
+ }, se = (e) => e.hasAttribute("width") || /(?:^|;)\s*width\s*:/i.test(e.getAttribute("style") ?? "") ? !0 : Array.from(e.querySelectorAll("th, td, col")).some((e) => !!(e.hasAttribute("colwidth") || e.hasAttribute("width") || /(?:^|;)\s*width\s*:/i.test(e.getAttribute("style") ?? ""))), ce = (e) => {
490
500
  let t = e.style.textAlign.trim().toLowerCase(), n = (e.getAttribute("align") ?? "").trim().toLowerCase();
491
501
  if (t && n && t !== n) return;
492
502
  let r = t || n;
493
503
  if (!r) return null;
494
504
  if (r === "left" || r === "center" || r === "right") return r;
495
- }, ae = (e) => {
496
- if (e.caption || e.tFoot || ie(e)) return null;
505
+ }, le = (e) => {
506
+ if (e.caption || e.tFoot || se(e)) return null;
497
507
  let t = Array.from(e.rows), n = t[0]?.cells.length ?? 0;
498
508
  if (t.length === 0 || n === 0) return null;
499
509
  let r = t.map((e) => Array.from(e.cells));
500
- if (r.some((t, r) => t.length !== n || t.some((t) => t.closest("table") !== e || t.colSpan !== 1 || t.rowSpan !== 1 || !re(t) || (r === 0 ? t.tagName !== "TH" : t.tagName !== "TD")))) return null;
510
+ if (r.some((t, r) => t.length !== n || t.some((t) => t.closest("table") !== e || t.colSpan !== 1 || t.rowSpan !== 1 || !oe(t) || (r === 0 ? t.tagName !== "TH" : t.tagName !== "TD")))) return null;
501
511
  let i = r[0].map((e, t) => {
502
- let n = r.map((e) => Q(e[t])), i = n[0];
512
+ let n = r.map((e) => ce(e[t])), i = n[0];
503
513
  if (!(i === void 0 || n.some((e) => e !== i))) return i;
504
514
  });
505
515
  return i.some((e) => e === void 0) ? null : {
506
516
  rows: r,
507
517
  alignments: i
508
518
  };
509
- }, oe = (e, t) => {
510
- let n = Array.from(t.childNodes).filter(Z), r = (n.length === 1 && n[0] instanceof HTMLParagraphElement ? n[0] : t).cloneNode(!0);
519
+ }, ue = (e, t) => {
520
+ let n = Array.from(t.childNodes).filter(X), r = (n.length === 1 && n[0] instanceof HTMLParagraphElement ? n[0] : t).cloneNode(!0);
511
521
  r.querySelectorAll("br").forEach((e) => {
512
- e.replaceWith(e.ownerDocument.createTextNode(K));
522
+ e.replaceWith(e.ownerDocument.createTextNode(W));
513
523
  });
514
- let i = e.turndown(r.innerHTML).split(K).join("<br>").split("|").join("\\|").trim();
524
+ let i = e.turndown(r.innerHTML).split(W).join("<br>").split("|").join("\\|").trim();
515
525
  return /[\r\n]/.test(i) ? null : i;
526
+ }, Z = (e) => {
527
+ let t = e.cloneNode(!0);
528
+ return t.querySelectorAll("span[data-type=\"latex\"]").forEach((e) => {
529
+ e.textContent === "•" && (e.textContent = "");
530
+ }), $(t), t.outerHTML;
531
+ }, Q = (e) => {
532
+ let t = e?.trim().toLowerCase();
533
+ return t && G.has(t) ? t : "info";
534
+ }, de = (e) => {
535
+ let t = Q(e.getAttribute("data-variant"));
536
+ Array.from(e.attributes).forEach((t) => {
537
+ t.name !== "data-type" && t.name !== "data-variant" && t.name !== "role" && e.removeAttribute(t.name);
538
+ }), e.setAttribute("data-type", "callout"), e.setAttribute("data-variant", t), e.setAttribute("role", "note");
539
+ }, fe = (e) => {
540
+ let t = e.matches("table, col, th, td") ? K.map((t) => [t, e.style.getPropertyValue(t)]).filter(([, e]) => !!e) : [];
541
+ e.removeAttribute("style"), t.forEach(([t, n]) => {
542
+ e.style.setProperty(t, n);
543
+ });
516
544
  }, $ = (e) => {
545
+ [...e.matches("aside[data-type=\"callout\"]") ? [e] : [], ...Array.from(e.querySelectorAll("aside[data-type=\"callout\"]"))].forEach((e) => {
546
+ [e, ...Array.from(e.querySelectorAll("*"))].forEach((e) => {
547
+ fe(e), Array.from(e.attributes).forEach((t) => {
548
+ t.name.toLowerCase().startsWith("on") && e.removeAttribute(t.name);
549
+ });
550
+ }), de(e);
551
+ });
552
+ }, pe = (e) => {
517
553
  let t = e.cloneNode(!0);
518
554
  return t.querySelectorAll("span[data-type=\"latex\"]").forEach((e) => {
519
555
  e.textContent === "•" && (e.textContent = "");
520
- }), t.outerHTML;
521
- }, se = (e) => {
556
+ }), $(t), t.outerHTML;
557
+ }, me = (e) => {
558
+ e.addRule("scribeCallout", {
559
+ filter: (e) => e.nodeName === "ASIDE" && e.getAttribute("data-type") === "callout",
560
+ replacement: (e, t) => `\n\n${pe(t)}\n\n`
561
+ });
562
+ }, he = (e) => {
522
563
  e.addRule("scribeTable", {
523
564
  filter: "table",
524
565
  replacement: (t, n) => {
525
- let r = n, i = ae(r);
526
- if (!i) return `\n\n${$(r)}\n\n`;
527
- let { rows: a, alignments: o } = i, s = a.map((t) => t.map((t) => oe(e, t)));
528
- if (s.some((e) => e.some((e) => e === null))) return `\n\n${$(r)}\n\n`;
566
+ let r = n, i = le(r);
567
+ if (!i) return `\n\n${Z(r)}\n\n`;
568
+ let { rows: a, alignments: o } = i, s = a.map((t) => t.map((t) => ue(e, t)));
569
+ if (s.some((e) => e.some((e) => e === null))) return `\n\n${Z(r)}\n\n`;
529
570
  let c = s.map((e) => `| ${e.join(" | ")} |`), l = `| ${o.map((e) => e === "left" ? ":---" : e === "center" ? ":---:" : e === "right" ? "---:" : "---").join(" | ")} |`;
530
571
  return c.splice(1, 0, l), `\n\n${c.join("\n")}\n\n`;
531
572
  }
532
573
  });
533
- }, ce = (t) => {
534
- let n = new B({
574
+ }, ge = (t) => {
575
+ let n = new R({
535
576
  headingStyle: "atx",
536
577
  hr: "---",
537
578
  bulletListMarker: "-",
@@ -550,7 +591,7 @@ var K = "scribe-table-break", q = (/* @__PURE__ */ "address.article.aside.
550
591
  replacement: function(e) {
551
592
  return "~~" + e + "~~";
552
593
  }
553
- }), se(n), n.turndown(e.sanitize(((e) => e.replace(/<span([^>]+data-type="latex"[^>]*)><\/span>/g, "<span$1>•</span>"))(t), { ADD_ATTR: ["colwidth"] }));
594
+ }), me(n), he(n), n.turndown(e.sanitize(((e) => e.replace(/<span([^>]+data-type="latex"[^>]*)><\/span>/g, "<span$1>•</span>"))(t), { ADD_ATTR: ["colwidth"] }));
554
595
  };
555
596
  //#endregion
556
- export { ce as t };
597
+ export { ge as t };
@@ -0,0 +1,9 @@
1
+ import type { FC } from "react";
2
+ import type { CalloutVariant } from "../components/Scribe/extension/callout";
3
+ export interface CalloutIconProps {
4
+ className?: string;
5
+ variant: CalloutVariant;
6
+ }
7
+ export declare const CalloutIcon: FC<CalloutIconProps>;
8
+ export declare const RemoveCalloutIcon: FC;
9
+ //# sourceMappingURL=CalloutIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CalloutIcon.d.ts","sourceRoot":"","sources":["../../lib/icons/CalloutIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAE7E,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,cAAc,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA0D5C,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,EAiB/B,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ //#region lib/icons/CalloutIcon.tsx
3
+ var n = ({ className: n = "scribe-callout-icon", variant: r }) => {
4
+ let i = {
5
+ "aria-hidden": !0,
6
+ className: n,
7
+ fill: "none",
8
+ height: 18,
9
+ viewBox: "0 0 20 20",
10
+ width: 18
11
+ }, a = {
12
+ stroke: "currentColor",
13
+ strokeLinecap: "round",
14
+ strokeLinejoin: "round",
15
+ strokeWidth: 1.5
16
+ };
17
+ return r === "tip" ? /* @__PURE__ */ t("svg", {
18
+ ...i,
19
+ children: [/* @__PURE__ */ e("path", {
20
+ d: "M6.5 12.1a5 5 0 1 1 7 0c-.8.75-1.2 1.4-1.2 2.15H7.7c0-.75-.4-1.4-1.2-2.15Z",
21
+ ...a
22
+ }), /* @__PURE__ */ e("path", {
23
+ d: "M7.9 16.6h4.2M8.8 14.25v2.35M11.2 14.25v2.35",
24
+ ...a
25
+ })]
26
+ }) : r === "warning" ? /* @__PURE__ */ t("svg", {
27
+ ...i,
28
+ children: [/* @__PURE__ */ e("path", {
29
+ d: "M9.1 3.6 2.3 15.4a1.05 1.05 0 0 0 .9 1.55h13.6a1.05 1.05 0 0 0 .9-1.55L10.9 3.6a1.04 1.04 0 0 0-1.8 0Z",
30
+ ...a
31
+ }), /* @__PURE__ */ e("path", {
32
+ d: "M10 7.6v4.45M10 14.65v.05",
33
+ ...a
34
+ })]
35
+ }) : r === "caution" ? /* @__PURE__ */ t("svg", {
36
+ ...i,
37
+ children: [/* @__PURE__ */ e("path", {
38
+ d: "m6.45 2.75-3.7 3.7v7.1l3.7 3.7h7.1l3.7-3.7v-7.1l-3.7-3.7h-7.1Z",
39
+ ...a
40
+ }), /* @__PURE__ */ e("path", {
41
+ d: "M10 6.2v5.65M10 14.45v.05",
42
+ ...a
43
+ })]
44
+ }) : /* @__PURE__ */ t("svg", {
45
+ ...i,
46
+ children: [/* @__PURE__ */ e("circle", {
47
+ cx: "10",
48
+ cy: "10",
49
+ r: "7.25",
50
+ ...a
51
+ }), /* @__PURE__ */ e("path", {
52
+ d: "M10 8.5v5M10 5.65v.05",
53
+ ...a
54
+ })]
55
+ });
56
+ }, r = () => /* @__PURE__ */ e("svg", {
57
+ "aria-hidden": "true",
58
+ className: "scribe-callout-icon",
59
+ fill: "none",
60
+ height: "18",
61
+ viewBox: "0 0 20 20",
62
+ width: "18",
63
+ children: /* @__PURE__ */ e("path", {
64
+ d: "M7.25 4.5h7.25M7.25 8.5h7.25M7.25 12.5h4.5M5.25 15.5l-2.5-2.5 2.5-2.5M2.75 13h4",
65
+ stroke: "currentColor",
66
+ strokeLinecap: "round",
67
+ strokeLinejoin: "round",
68
+ strokeWidth: "1.5"
69
+ })
70
+ });
71
+ //#endregion
72
+ export { n as CalloutIcon, r as RemoveCalloutIcon };
package/dist/main.css CHANGED
@@ -120,6 +120,103 @@
120
120
  padding-left: 1rem;
121
121
  }
122
122
 
123
+ .scribe-content .tiptap [data-type="callout"] {
124
+ --scribe-callout-background: var(--blue-2);
125
+ --scribe-callout-border: var(--blue-6);
126
+ --scribe-callout-icon: var(--blue-11);
127
+ --scribe-callout-label: var(--blue-12);
128
+
129
+ background: var(--scribe-callout-background);
130
+ border: 1px solid var(--scribe-callout-border);
131
+ border-radius: 10px;
132
+ box-sizing: border-box;
133
+ color: var(--gray-12);
134
+ margin: 0 0 1rem;
135
+ padding: 12px 14px;
136
+ }
137
+
138
+ .scribe-content .tiptap [data-type="callout"][data-variant="tip"] {
139
+ --scribe-callout-background: var(--green-2);
140
+ --scribe-callout-border: var(--green-6);
141
+ --scribe-callout-icon: var(--green-11);
142
+ --scribe-callout-label: var(--green-12);
143
+ }
144
+
145
+ .scribe-content .tiptap [data-type="callout"][data-variant="warning"] {
146
+ --scribe-callout-background: var(--amber-2);
147
+ --scribe-callout-border: var(--amber-6);
148
+ --scribe-callout-icon: var(--amber-11);
149
+ --scribe-callout-label: var(--amber-12);
150
+ }
151
+
152
+ .scribe-content .tiptap [data-type="callout"][data-variant="caution"] {
153
+ --scribe-callout-background: var(--red-2);
154
+ --scribe-callout-border: var(--red-6);
155
+ --scribe-callout-icon: var(--red-11);
156
+ --scribe-callout-label: var(--red-12);
157
+ }
158
+
159
+ .scribe-content .tiptap [data-callout-header] {
160
+ align-items: center;
161
+ color: var(--scribe-callout-label);
162
+ display: flex;
163
+ font-size: 0.875rem;
164
+ font-weight: 600;
165
+ gap: 8px;
166
+ line-height: 1.25rem;
167
+ margin-bottom: 6px;
168
+ user-select: none;
169
+ }
170
+
171
+ .scribe-content .tiptap [data-callout-icon] {
172
+ -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10' cy='10' r='7.25'/%3E%3Cpath d='M10 8.5v5M10 5.65v.05'/%3E%3C/svg%3E");
173
+ -webkit-mask-position: center;
174
+ -webkit-mask-repeat: no-repeat;
175
+ -webkit-mask-size: contain;
176
+ background: var(--scribe-callout-icon);
177
+ display: inline-block;
178
+ flex: 0 0 18px;
179
+ height: 18px;
180
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10' cy='10' r='7.25'/%3E%3Cpath d='M10 8.5v5M10 5.65v.05'/%3E%3C/svg%3E");
181
+ mask-position: center;
182
+ mask-repeat: no-repeat;
183
+ mask-size: contain;
184
+ width: 18px;
185
+ }
186
+
187
+ .scribe-content .tiptap [data-type="callout"][data-variant="tip"] [data-callout-icon] {
188
+ -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.5 12.1a5 5 0 1 1 7 0c-.8.75-1.2 1.4-1.2 2.15H7.7c0-.75-.4-1.4-1.2-2.15Z'/%3E%3Cpath d='M7.9 16.6h4.2M8.8 14.25v2.35M11.2 14.25v2.35'/%3E%3C/svg%3E");
189
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.5 12.1a5 5 0 1 1 7 0c-.8.75-1.2 1.4-1.2 2.15H7.7c0-.75-.4-1.4-1.2-2.15Z'/%3E%3Cpath d='M7.9 16.6h4.2M8.8 14.25v2.35M11.2 14.25v2.35'/%3E%3C/svg%3E");
190
+ }
191
+
192
+ .scribe-content .tiptap [data-type="callout"][data-variant="warning"] [data-callout-icon] {
193
+ -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.1 3.6 2.3 15.4a1.05 1.05 0 0 0 .9 1.55h13.6a1.05 1.05 0 0 0 .9-1.55L10.9 3.6a1.04 1.04 0 0 0-1.8 0Z'/%3E%3Cpath d='M10 7.6v4.45M10 14.65v.05'/%3E%3C/svg%3E");
194
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.1 3.6 2.3 15.4a1.05 1.05 0 0 0 .9 1.55h13.6a1.05 1.05 0 0 0 .9-1.55L10.9 3.6a1.04 1.04 0 0 0-1.8 0Z'/%3E%3Cpath d='M10 7.6v4.45M10 14.65v.05'/%3E%3C/svg%3E");
195
+ }
196
+
197
+ .scribe-content .tiptap [data-type="callout"][data-variant="caution"] [data-callout-icon] {
198
+ -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6.45 2.75-3.7 3.7v7.1l3.7 3.7h7.1l3.7-3.7v-7.1l-3.7-3.7h-7.1Z'/%3E%3Cpath d='M10 6.2v5.65M10 14.45v.05'/%3E%3C/svg%3E");
199
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6.45 2.75-3.7 3.7v7.1l3.7 3.7h7.1l3.7-3.7v-7.1l-3.7-3.7h-7.1Z'/%3E%3Cpath d='M10 6.2v5.65M10 14.45v.05'/%3E%3C/svg%3E");
200
+ }
201
+
202
+ .scribe-content .tiptap [data-callout-content] {
203
+ color: var(--gray-12);
204
+ min-width: 0;
205
+ }
206
+
207
+ .scribe-content .tiptap [data-callout-content] > *:first-child {
208
+ margin-top: 0;
209
+ }
210
+
211
+ .scribe-content .tiptap [data-callout-content] > *:last-child {
212
+ margin-bottom: 0;
213
+ }
214
+
215
+ .scribe-content .tiptap [data-type="callout"].ProseMirror-selectednode {
216
+ outline: 2px solid var(--accent-8);
217
+ outline-offset: 2px;
218
+ }
219
+
123
220
  .scribe-content .tiptap code {
124
221
  background: var(--gray-a3);
125
222
  border-radius: 6px;
@@ -224,7 +321,8 @@
224
321
  }
225
322
 
226
323
  .scribe-bubble-menu,
227
- .scribe-table-bubble-menu {
324
+ .scribe-table-bubble-menu,
325
+ .scribe-callout-bubble-menu {
228
326
  background: var(--color-panel-solid);
229
327
  border: 1px solid var(--gray-6);
230
328
  border-radius: 12px;
@@ -239,6 +337,26 @@
239
337
  overflow-x: auto;
240
338
  }
241
339
 
340
+ .scribe-callout-bubble-menu {
341
+ max-width: calc(100vw - 16px);
342
+ width: max-content;
343
+ }
344
+
345
+ .scribe-callout-type-button {
346
+ flex-shrink: 0;
347
+ white-space: nowrap;
348
+ }
349
+
350
+ .scribe-callout-menu-separator {
351
+ height: 20px;
352
+ margin: 0 2px;
353
+ }
354
+
355
+ .scribe-callout-icon {
356
+ display: block;
357
+ flex: 0 0 auto;
358
+ }
359
+
242
360
  .scribe-table-bubble-menu > * {
243
361
  flex-shrink: 0;
244
362
  }
package/dist/main.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./components/Scribe";
2
+ export * from "./components/Scribe/extension/callout";
2
3
  export * from "./utils";
3
4
  export type { Content } from "@tiptap/react";
4
5
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../lib/main.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../lib/main.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uCAAuC,CAAC;AACtD,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
package/dist/main.js CHANGED
@@ -1,8 +1,9 @@
1
- import { t as e } from "./html-to-markdown-B6Uhn7ok.js";
2
- import { t } from "./markdown-to-html-WmeDaJXP.js";
3
- import { isInViewport as n } from "./utils/is-in-viewport.js";
4
- import { convertLegacyMathDelimiters as r } from "./utils/convert-legacy-math-delimiters.js";
5
- import { SuggestionItemType as i } from "./components/Scribe/extension/slashCommand/items.js";
6
- import { createScribeEditor as a } from "./utils/index.js";
7
- import { Scribe as o } from "./components/Scribe/index.js";
8
- export { o as Scribe, i as SuggestionItemType, r as convertLegacyMathDelimiters, a as createScribeEditor, e as html2md, n as isInViewport, t as md2html };
1
+ import { CALLOUT_VARIANTS as e, CALLOUT_VARIANT_LABELS as t, Callout as n, DEFAULT_CALLOUT_VARIANT as r, isCalloutVariant as i } from "./components/Scribe/extension/callout.js";
2
+ import { t as a } from "./html-to-markdown-C920nQtn.js";
3
+ import { t as o } from "./markdown-to-html-CW0Nb9Ye.js";
4
+ import { isInViewport as s } from "./utils/is-in-viewport.js";
5
+ import { convertLegacyMathDelimiters as c } from "./utils/convert-legacy-math-delimiters.js";
6
+ import { SuggestionItemType as l } from "./components/Scribe/extension/slashCommand/items.js";
7
+ import { createScribeEditor as u } from "./utils/index.js";
8
+ import { Scribe as d } from "./components/Scribe/index.js";
9
+ export { e as CALLOUT_VARIANTS, t as CALLOUT_VARIANT_LABELS, n as Callout, r as DEFAULT_CALLOUT_VARIANT, d as Scribe, l as SuggestionItemType, c as convertLegacyMathDelimiters, u as createScribeEditor, a as html2md, i as isCalloutVariant, s as isInViewport, o as md2html };
@@ -1468,6 +1468,36 @@ $.use = ze, $.walkTokens = function(e, t) {
1468
1468
  }, $.parseInline = Q.parseInline, $.Parser = X, $.parser = X.parse, $.Renderer = J, $.TextRenderer = Y, $.Lexer = q, $.lexer = q.lex, $.Tokenizer = K, $.Hooks = Z, $.parse = $, $.options, $.setOptions, $.walkTokens, $.parseInline, X.parse, q.lex;
1469
1469
  //#endregion
1470
1470
  //#region lib/utils/markdown-to-html.ts
1471
- var Be = (t) => e.sanitize($.parse(t, { async: !1 }), { ADD_ATTR: ["colwidth"] });
1471
+ var Be = /* @__PURE__ */ new Set([
1472
+ "info",
1473
+ "tip",
1474
+ "warning",
1475
+ "caution"
1476
+ ]), Ve = [
1477
+ "width",
1478
+ "min-width",
1479
+ "max-width",
1480
+ "text-align"
1481
+ ], He = (e) => {
1482
+ let t = e?.trim().toLowerCase();
1483
+ return t && Be.has(t) ? t : "info";
1484
+ }, Ue = (e) => {
1485
+ let t = e.matches("table, col, th, td") ? Ve.map((t) => [t, e.style.getPropertyValue(t)]).filter(([, e]) => !!e) : [];
1486
+ e.removeAttribute("style"), t.forEach(([t, n]) => {
1487
+ e.style.setProperty(t, n);
1488
+ });
1489
+ }, We = (e) => {
1490
+ let t = document.createElement("div");
1491
+ return t.innerHTML = e, t.querySelectorAll("aside[data-type=\"callout\"]").forEach((e) => {
1492
+ let t = He(e.getAttribute("data-variant"));
1493
+ Array.from(e.attributes).forEach((t) => {
1494
+ t.name !== "data-type" && t.name !== "data-variant" && t.name !== "role" && e.removeAttribute(t.name);
1495
+ }), e.setAttribute("data-type", "callout"), e.setAttribute("data-variant", t), e.setAttribute("role", "note"), [e, ...Array.from(e.querySelectorAll("*"))].forEach((e) => {
1496
+ Ue(e), Array.from(e.attributes).forEach((t) => {
1497
+ t.name.toLowerCase().startsWith("on") && e.removeAttribute(t.name);
1498
+ });
1499
+ });
1500
+ }), t.innerHTML;
1501
+ }, Ge = (t) => We(e.sanitize($.parse(t, { async: !1 }), { ADD_ATTR: ["colwidth"] }));
1472
1502
  //#endregion
1473
- export { $ as n, Be as t };
1503
+ export { $ as n, Ge as t };
@@ -1 +1 @@
1
- {"version":3,"file":"html-to-markdown.d.ts","sourceRoot":"","sources":["../../lib/utils/html-to-markdown.ts"],"names":[],"mappings":"AAuQA,eAAO,MAAM,OAAO,SAAU,MAAM,WAuCnC,CAAC"}
1
+ {"version":3,"file":"html-to-markdown.d.ts","sourceRoot":"","sources":["../../lib/utils/html-to-markdown.ts"],"names":[],"mappings":"AA4VA,eAAO,MAAM,OAAO,SAAU,MAAM,WAwCnC,CAAC"}
@@ -1,2 +1,2 @@
1
- import { t as e } from "../html-to-markdown-B6Uhn7ok.js";
1
+ import { t as e } from "../html-to-markdown-C920nQtn.js";
2
2
  export { e as html2md };
@@ -1,9 +1,9 @@
1
1
  import { t as e } from "../dist-DFua_Xbu.js";
2
- import { t } from "../html-to-markdown-B6Uhn7ok.js";
3
- import { t as n } from "../markdown-to-html-WmeDaJXP.js";
2
+ import { t } from "../html-to-markdown-C920nQtn.js";
3
+ import { t as n } from "../markdown-to-html-CW0Nb9Ye.js";
4
4
  import { isInViewport as r } from "./is-in-viewport.js";
5
5
  import { convertLegacyMathDelimiters as i } from "./convert-legacy-math-delimiters.js";
6
- import { t as a } from "../extension-Dy6hHSvD.js";
6
+ import { t as a } from "../extension-_8uh0Ik9.js";
7
7
  //#region lib/utils/create-scribe-editor.ts
8
8
  function o({ content: n = "", editable: r = !1, onContentChange: i }) {
9
9
  return new e({
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-to-html.d.ts","sourceRoot":"","sources":["../../lib/utils/markdown-to-html.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,OAAQ,MAAM,WAG9B,CAAC"}
1
+ {"version":3,"file":"markdown-to-html.d.ts","sourceRoot":"","sources":["../../lib/utils/markdown-to-html.ts"],"names":[],"mappings":"AA8DA,eAAO,MAAM,OAAO,OAAQ,MAAM,WAMjC,CAAC"}
@@ -1,2 +1,2 @@
1
- import { t as e } from "../markdown-to-html-WmeDaJXP.js";
1
+ import { t as e } from "../markdown-to-html-CW0Nb9Ye.js";
2
2
  export { e as md2html };