@devalok/shilp-sutra 0.49.4 → 0.50.0

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 (243) hide show
  1. package/AGENTS.md +12 -4
  2. package/MIGRATION.md +6 -0
  3. package/dist/_chunks/badge-group.js +12 -11
  4. package/dist/_chunks/badge-group.js.map +1 -1
  5. package/dist/_chunks/block-shell.js +1 -1
  6. package/dist/_chunks/block-shell.js.map +1 -1
  7. package/dist/_chunks/chat.js +18 -18
  8. package/dist/_chunks/chat.js.map +1 -1
  9. package/dist/_chunks/document-preview.js +1 -1
  10. package/dist/_chunks/document-preview.js.map +1 -1
  11. package/dist/_chunks/emoji-suggestion.js +1 -1
  12. package/dist/_chunks/emoji-suggestion.js.map +1 -1
  13. package/dist/_chunks/grid-lines.js +2 -2
  14. package/dist/_chunks/grid-lines.js.map +1 -1
  15. package/dist/_chunks/image-preview.js +1 -1
  16. package/dist/_chunks/image-preview.js.map +1 -1
  17. package/dist/_chunks/mention-suggestion.js +2 -2
  18. package/dist/_chunks/mention-suggestion.js.map +1 -1
  19. package/dist/_chunks/oauth-button.js +8 -8
  20. package/dist/_chunks/oauth-button.js.map +1 -1
  21. package/dist/_chunks/shared.js +2 -2
  22. package/dist/_chunks/shared.js.map +1 -1
  23. package/dist/_chunks/success.js +5 -5
  24. package/dist/_chunks/success.js.map +1 -1
  25. package/dist/_chunks/tiptap.js +3956 -1796
  26. package/dist/_chunks/tiptap.js.map +1 -1
  27. package/dist/_chunks/tooltip.js +2 -2
  28. package/dist/_chunks/tooltip.js.map +1 -1
  29. package/dist/_chunks/tree-view.js +2 -2
  30. package/dist/_chunks/tree-view.js.map +1 -1
  31. package/dist/_chunks/use-calendar.js +3 -3
  32. package/dist/_chunks/use-calendar.js.map +1 -1
  33. package/dist/ai/block-renderer.js +1 -1
  34. package/dist/ai/block-renderer.js.map +1 -1
  35. package/dist/ai/blocks/error.js +1 -1
  36. package/dist/ai/blocks/error.js.map +1 -1
  37. package/dist/ai/command-bar.js +15 -15
  38. package/dist/ai/command-bar.js.map +1 -1
  39. package/dist/ai/conversation.js +6 -6
  40. package/dist/ai/conversation.js.map +1 -1
  41. package/dist/composed/activity-feed.js +4 -4
  42. package/dist/composed/activity-feed.js.map +1 -1
  43. package/dist/composed/avatar-group.js +6 -6
  44. package/dist/composed/avatar-group.js.map +1 -1
  45. package/dist/composed/bulk-action-bar.js +1 -1
  46. package/dist/composed/bulk-action-bar.js.map +1 -1
  47. package/dist/composed/command-palette.js +12 -12
  48. package/dist/composed/command-palette.js.map +1 -1
  49. package/dist/composed/content-card.js +1 -1
  50. package/dist/composed/content-card.js.map +1 -1
  51. package/dist/composed/date-picker/index.js +17 -17
  52. package/dist/composed/date-picker/index.js.map +1 -1
  53. package/dist/composed/deadline-indicator.js +2 -2
  54. package/dist/composed/deadline-indicator.js.map +1 -1
  55. package/dist/composed/diff.d.ts +108 -0
  56. package/dist/composed/diff.d.ts.map +1 -0
  57. package/dist/composed/diff.js +1004 -0
  58. package/dist/composed/diff.js.map +1 -0
  59. package/dist/composed/emoji-picker.js +6 -6
  60. package/dist/composed/emoji-picker.js.map +1 -1
  61. package/dist/composed/empty-state.js +2 -2
  62. package/dist/composed/empty-state.js.map +1 -1
  63. package/dist/composed/error-boundary.js +6 -6
  64. package/dist/composed/error-boundary.js.map +1 -1
  65. package/dist/composed/file-preview.js +5 -5
  66. package/dist/composed/file-preview.js.map +1 -1
  67. package/dist/composed/filter-bar.js +3 -3
  68. package/dist/composed/filter-bar.js.map +1 -1
  69. package/dist/composed/form-section.js +2 -2
  70. package/dist/composed/form-section.js.map +1 -1
  71. package/dist/composed/inline-edit.d.ts +1 -1
  72. package/dist/composed/inline-edit.d.ts.map +1 -1
  73. package/dist/composed/inline-edit.js.map +1 -1
  74. package/dist/composed/loading-skeleton.js +3 -3
  75. package/dist/composed/loading-skeleton.js.map +1 -1
  76. package/dist/composed/markdown-viewer.js +11 -11
  77. package/dist/composed/markdown-viewer.js.map +1 -1
  78. package/dist/composed/master-detail.js +1 -1
  79. package/dist/composed/master-detail.js.map +1 -1
  80. package/dist/composed/member-picker.js +2 -2
  81. package/dist/composed/member-picker.js.map +1 -1
  82. package/dist/composed/multi-select-popover.js +5 -5
  83. package/dist/composed/multi-select-popover.js.map +1 -1
  84. package/dist/composed/page-header.js +3 -3
  85. package/dist/composed/page-header.js.map +1 -1
  86. package/dist/composed/page-skeletons.js +4 -4
  87. package/dist/composed/page-skeletons.js.map +1 -1
  88. package/dist/composed/priority-indicator.js +1 -1
  89. package/dist/composed/priority-indicator.js.map +1 -1
  90. package/dist/composed/responsive-modal.js +2 -2
  91. package/dist/composed/responsive-modal.js.map +1 -1
  92. package/dist/composed/rich-chat-input.js +27 -27
  93. package/dist/composed/rich-chat-input.js.map +1 -1
  94. package/dist/composed/rich-text-editor.d.ts +81 -6
  95. package/dist/composed/rich-text-editor.d.ts.map +1 -1
  96. package/dist/composed/rich-text-editor.js +365 -210
  97. package/dist/composed/rich-text-editor.js.map +1 -1
  98. package/dist/composed/schedule-view.js +4 -4
  99. package/dist/composed/schedule-view.js.map +1 -1
  100. package/dist/shell/bottom-navbar.js +4 -4
  101. package/dist/shell/bottom-navbar.js.map +1 -1
  102. package/dist/shell/notification-center.js +13 -13
  103. package/dist/shell/notification-center.js.map +1 -1
  104. package/dist/shell/notification-preferences.js +10 -10
  105. package/dist/shell/notification-preferences.js.map +1 -1
  106. package/dist/shell/sidebar.js +9 -9
  107. package/dist/shell/sidebar.js.map +1 -1
  108. package/dist/shell/top-bar.js +8 -8
  109. package/dist/shell/top-bar.js.map +1 -1
  110. package/dist/tokens/semantic.css +6 -1
  111. package/dist/tokens/typography-semantic.css +6 -6
  112. package/dist/tokens/utilities.css +8 -0
  113. package/dist/ui/accordion.js +2 -2
  114. package/dist/ui/accordion.js.map +1 -1
  115. package/dist/ui/alert-dialog.js +4 -4
  116. package/dist/ui/alert-dialog.js.map +1 -1
  117. package/dist/ui/alert.js +1 -1
  118. package/dist/ui/alert.js.map +1 -1
  119. package/dist/ui/autocomplete.d.ts.map +1 -1
  120. package/dist/ui/autocomplete.js +11 -3
  121. package/dist/ui/autocomplete.js.map +1 -1
  122. package/dist/ui/avatar.js +5 -5
  123. package/dist/ui/avatar.js.map +1 -1
  124. package/dist/ui/badge-group.d.ts +2 -6
  125. package/dist/ui/badge-group.d.ts.map +1 -1
  126. package/dist/ui/badge-indicator.d.ts +2 -6
  127. package/dist/ui/badge-indicator.d.ts.map +1 -1
  128. package/dist/ui/badge-indicator.js +19 -18
  129. package/dist/ui/badge-indicator.js.map +1 -1
  130. package/dist/ui/badge.d.ts +2 -4
  131. package/dist/ui/badge.d.ts.map +1 -1
  132. package/dist/ui/banner.js +1 -1
  133. package/dist/ui/banner.js.map +1 -1
  134. package/dist/ui/breadcrumb.js +1 -1
  135. package/dist/ui/breadcrumb.js.map +1 -1
  136. package/dist/ui/button.js +7 -7
  137. package/dist/ui/button.js.map +1 -1
  138. package/dist/ui/card.d.ts +1 -1
  139. package/dist/ui/card.js +1 -1
  140. package/dist/ui/card.js.map +1 -1
  141. package/dist/ui/charts/gauge-chart.js +2 -2
  142. package/dist/ui/charts/gauge-chart.js.map +1 -1
  143. package/dist/ui/charts/pie-chart.js +1 -1
  144. package/dist/ui/charts/pie-chart.js.map +1 -1
  145. package/dist/ui/charts/radar-chart.d.ts +19 -1
  146. package/dist/ui/charts/radar-chart.d.ts.map +1 -1
  147. package/dist/ui/charts/radar-chart.js +80 -42
  148. package/dist/ui/charts/radar-chart.js.map +1 -1
  149. package/dist/ui/code.js +2 -2
  150. package/dist/ui/code.js.map +1 -1
  151. package/dist/ui/color-input.d.ts.map +1 -1
  152. package/dist/ui/color-input.js +164 -157
  153. package/dist/ui/color-input.js.map +1 -1
  154. package/dist/ui/combobox.d.ts.map +1 -1
  155. package/dist/ui/combobox.js +143 -142
  156. package/dist/ui/combobox.js.map +1 -1
  157. package/dist/ui/context-menu.js +6 -6
  158. package/dist/ui/context-menu.js.map +1 -1
  159. package/dist/ui/data-table-body.js +1 -1
  160. package/dist/ui/data-table-body.js.map +1 -1
  161. package/dist/ui/data-table-bulk-actions.js +1 -1
  162. package/dist/ui/data-table-bulk-actions.js.map +1 -1
  163. package/dist/ui/data-table-card.js +1 -1
  164. package/dist/ui/data-table-card.js.map +1 -1
  165. package/dist/ui/data-table-header.js +1 -1
  166. package/dist/ui/data-table-header.js.map +1 -1
  167. package/dist/ui/data-table-pagination.js +3 -3
  168. package/dist/ui/data-table-pagination.js.map +1 -1
  169. package/dist/ui/data-table-toolbar.js +1 -1
  170. package/dist/ui/data-table-toolbar.js.map +1 -1
  171. package/dist/ui/data-table.js +1 -1
  172. package/dist/ui/data-table.js.map +1 -1
  173. package/dist/ui/dialog.js +2 -2
  174. package/dist/ui/dialog.js.map +1 -1
  175. package/dist/ui/dot.js +4 -4
  176. package/dist/ui/dot.js.map +1 -1
  177. package/dist/ui/dropdown-menu.js +6 -6
  178. package/dist/ui/dropdown-menu.js.map +1 -1
  179. package/dist/ui/file-upload.js +5 -5
  180. package/dist/ui/file-upload.js.map +1 -1
  181. package/dist/ui/form.js +1 -1
  182. package/dist/ui/form.js.map +1 -1
  183. package/dist/ui/input-otp.d.ts.map +1 -1
  184. package/dist/ui/input-otp.js +3 -3
  185. package/dist/ui/input-otp.js.map +1 -1
  186. package/dist/ui/input.js +8 -8
  187. package/dist/ui/input.js.map +1 -1
  188. package/dist/ui/label.js +1 -1
  189. package/dist/ui/label.js.map +1 -1
  190. package/dist/ui/lib/utils.d.ts.map +1 -1
  191. package/dist/ui/lib/utils.js +42 -13
  192. package/dist/ui/lib/utils.js.map +1 -1
  193. package/dist/ui/menubar.js +7 -7
  194. package/dist/ui/menubar.js.map +1 -1
  195. package/dist/ui/navigation-menu.js +1 -1
  196. package/dist/ui/navigation-menu.js.map +1 -1
  197. package/dist/ui/number-input.d.ts.map +1 -1
  198. package/dist/ui/number-input.js +6 -5
  199. package/dist/ui/number-input.js.map +1 -1
  200. package/dist/ui/pagination.js +1 -1
  201. package/dist/ui/pagination.js.map +1 -1
  202. package/dist/ui/progress-ring.js +3 -3
  203. package/dist/ui/progress-ring.js.map +1 -1
  204. package/dist/ui/progress.js +2 -2
  205. package/dist/ui/progress.js.map +1 -1
  206. package/dist/ui/segmented-control.js +3 -3
  207. package/dist/ui/segmented-control.js.map +1 -1
  208. package/dist/ui/select.d.ts.map +1 -1
  209. package/dist/ui/select.js +7 -6
  210. package/dist/ui/select.js.map +1 -1
  211. package/dist/ui/sheet.js +2 -2
  212. package/dist/ui/sheet.js.map +1 -1
  213. package/dist/ui/sidebar.js +7 -7
  214. package/dist/ui/sidebar.js.map +1 -1
  215. package/dist/ui/split-button.js +6 -6
  216. package/dist/ui/split-button.js.map +1 -1
  217. package/dist/ui/stat-card.d.ts +1 -1
  218. package/dist/ui/stat-card.js +7 -7
  219. package/dist/ui/stat-card.js.map +1 -1
  220. package/dist/ui/stepper.js +3 -3
  221. package/dist/ui/stepper.js.map +1 -1
  222. package/dist/ui/table.js +3 -3
  223. package/dist/ui/table.js.map +1 -1
  224. package/dist/ui/tabs.js +3 -3
  225. package/dist/ui/tabs.js.map +1 -1
  226. package/dist/ui/text.d.ts.map +1 -1
  227. package/dist/ui/text.js.map +1 -1
  228. package/dist/ui/textarea.d.ts.map +1 -1
  229. package/dist/ui/textarea.js +7 -6
  230. package/dist/ui/textarea.js.map +1 -1
  231. package/dist/ui/toast.js +11 -11
  232. package/dist/ui/toast.js.map +1 -1
  233. package/dist/ui/toggle.js +3 -3
  234. package/dist/ui/toggle.js.map +1 -1
  235. package/dist/ui/tooltip.js +1 -1
  236. package/dist/ui/tooltip.js.map +1 -1
  237. package/docs/components/composed/diff.md +50 -0
  238. package/docs/components/ui/data-table.md +2 -2
  239. package/llms.txt +2 -1
  240. package/mcp-manifest.json +147 -3
  241. package/package.json +8 -1
  242. package/skill/SKILL.md +1 -1
  243. package/skill/references/components.md +2 -1
@@ -3,23 +3,24 @@ import { cn as e } from "../ui/lib/utils.js";
3
3
  import { Icon as t } from "../ui/icon.js";
4
4
  import { Button as n } from "../ui/button.js";
5
5
  import { MENTION_TOKEN_CLASS as r } from "../_chunks/mention.js";
6
- import { EditorContent as i, ListKit as a, Placeholder as o, index_default as s, index_default$1 as c, index_default$2 as l, index_default$4 as u, index_default$5 as d, useEditor as f, useEditorState as p } from "../_chunks/tiptap.js";
7
- import { EmojiNode as m } from "./extensions/emoji-node.js";
8
- import { createEmojiSuggestion as h } from "../_chunks/emoji-suggestion.js";
9
- import { FileAttachment as g, createSuggestionRenderer as _ } from "../_chunks/mention-suggestion.js";
6
+ import { EditorContent as i, ListKit as a, Markdown as o, Placeholder as s, index_default as c, index_default$1 as l, index_default$2 as u, index_default$4 as d, index_default$5 as f, useEditor as p, useEditorState as m } from "../_chunks/tiptap.js";
7
+ import { EmojiNode as h } from "./extensions/emoji-node.js";
8
+ import { createEmojiSuggestion as g } from "../_chunks/emoji-suggestion.js";
9
+ import { FileAttachment as _, createSuggestionRenderer as ee } from "../_chunks/mention-suggestion.js";
10
10
  import * as v from "react";
11
- import { jsx as y, jsxs as b } from "react/jsx-runtime";
12
- import { IconAlignCenter as x, IconAlignLeft as S, IconAlignRight as C, IconArrowBackUp as w, IconArrowForwardUp as T, IconBlockquote as E, IconBold as D, IconCode as O, IconH2 as k, IconH3 as A, IconHighlight as j, IconItalic as M, IconLineDashed as N, IconLink as P, IconList as F, IconListCheck as I, IconListNumbers as L, IconMoodSmile as R, IconPaperclip as z, IconPhoto as B, IconStrikethrough as V, IconUnderline as H } from "@tabler/icons-react";
11
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
12
+ import { IconAlignCenter as S, IconAlignLeft as C, IconAlignRight as w, IconArrowBackUp as T, IconArrowForwardUp as E, IconBlockquote as D, IconBold as O, IconCode as k, IconEye as A, IconH2 as te, IconH3 as ne, IconHighlight as re, IconItalic as j, IconLineDashed as M, IconLink as N, IconList as P, IconListCheck as F, IconListNumbers as I, IconMoodSmile as L, IconPaperclip as ie, IconPhoto as ae, IconStrikethrough as R, IconUnderline as z } from "@tabler/icons-react";
13
+ import { AnimatePresence as oe, motion as B, useReducedMotion as V } from "framer-motion";
13
14
  //#region src/composed/rich-text-editor.tsx
14
- var U = [
15
+ var H = [
15
16
  "prose prose-sm max-w-none",
16
- "font-body text-ds-md leading-relaxed text-surface-fg",
17
- "[&_h2]:text-ds-xl [&_h2]:mb-ds-03 [&_h2]:mt-ds-05 [&_h2]:text-surface-fg",
18
- "[&_h3]:text-ds-base [&_h3]:font-semibold [&_h3]:mb-ds-02b [&_h3]:mt-ds-04 [&_h3]:text-surface-fg",
17
+ "font-body text-body-md leading-relaxed text-surface-fg",
18
+ "[&_h2]:text-heading-sm [&_h2]:mb-ds-03 [&_h2]:mt-ds-05 [&_h2]:text-surface-fg",
19
+ "[&_h3]:text-body-lg [&_h3]:font-semibold [&_h3]:mb-ds-02b [&_h3]:mt-ds-04 [&_h3]:text-surface-fg",
19
20
  "[&_p]:mb-ds-02b [&_p]:text-surface-fg-muted",
20
21
  "[&_ul]:ml-ds-05 [&_ul]:list-disc [&_ol]:ml-ds-05 [&_ol]:list-decimal",
21
22
  "[&_li]:text-surface-fg-muted",
22
- "[&_code]:rounded [&_code]:bg-surface-raised [&_code]:px-ds-02b [&_code]:py-ds-01 [&_code]:text-ds-md [&_code]:text-accent-11",
23
+ "[&_code]:rounded [&_code]:bg-surface-raised [&_code]:px-ds-02b [&_code]:py-ds-01 [&_code]:text-body-md [&_code]:text-accent-11",
23
24
  "[&_pre]:rounded-surface [&_pre]:bg-surface-raised [&_pre]:p-ds-04",
24
25
  "[&_strong]:font-semibold [&_strong]:text-surface-fg",
25
26
  "[&_blockquote]:border-l-[3px] [&_blockquote]:border-accent-6 [&_blockquote]:pl-ds-04 [&_blockquote]:italic [&_blockquote]:text-surface-fg-subtle",
@@ -30,8 +31,8 @@ var U = [
30
31
  "[&_img]:max-w-full [&_img]:rounded-control [&_img]:my-ds-03",
31
32
  r
32
33
  ];
33
- function W({ onClick: t, isActive: n = !1, disabled: r = !1, title: i, children: a }) {
34
- return /* @__PURE__ */ y("button", {
34
+ function U({ onClick: t, isActive: n = !1, disabled: r = !1, title: i, children: a }) {
35
+ return /* @__PURE__ */ b("button", {
35
36
  type: "button",
36
37
  onClick: t,
37
38
  disabled: r,
@@ -42,14 +43,14 @@ function W({ onClick: t, isActive: n = !1, disabled: r = !1, title: i, children:
42
43
  children: a
43
44
  });
44
45
  }
45
- function G({ editor: e }) {
46
- let [r, i] = v.useState(!1), [a, o] = v.useState(""), s = v.useRef(null), { isLink: c } = p({
46
+ function W({ editor: e }) {
47
+ let [r, i] = v.useState(!1), [a, o] = v.useState(""), s = v.useRef(null), { isLink: c } = m({
47
48
  editor: e,
48
49
  selector: ({ editor: e }) => ({ isLink: e.isActive("link") })
49
50
  });
50
- return /* @__PURE__ */ b("div", {
51
+ return /* @__PURE__ */ x("div", {
51
52
  className: "relative",
52
- children: [/* @__PURE__ */ y(W, {
53
+ children: [/* @__PURE__ */ b(U, {
53
54
  onClick: () => {
54
55
  if (c) {
55
56
  e.chain().focus().unsetLink().run();
@@ -60,17 +61,17 @@ function G({ editor: e }) {
60
61
  },
61
62
  isActive: c,
62
63
  title: "Link",
63
- children: /* @__PURE__ */ y(t, {
64
- icon: P,
64
+ children: /* @__PURE__ */ b(t, {
65
+ icon: N,
65
66
  size: "sm"
66
67
  })
67
- }), r && /* @__PURE__ */ b("form", {
68
+ }), r && /* @__PURE__ */ x("form", {
68
69
  onSubmit: (t) => {
69
70
  t.preventDefault(), a.trim() && e.chain().focus().setLink({ href: a.trim() }).run(), i(!1), o("");
70
71
  },
71
72
  "aria-label": "Edit link URL",
72
73
  className: "absolute left-0 top-full z-popover mt-ds-01 flex items-center gap-ds-02 rounded-control bg-surface-overlay p-ds-02 shadow-raised-hover",
73
- children: [/* @__PURE__ */ y("input", {
74
+ children: [/* @__PURE__ */ b("input", {
74
75
  ref: s,
75
76
  type: "url",
76
77
  value: a,
@@ -79,8 +80,8 @@ function G({ editor: e }) {
79
80
  t.key === "Escape" && (i(!1), o(""), e.commands.focus());
80
81
  },
81
82
  placeholder: "https://...",
82
- className: "h-ds-sm w-[240px] rounded-control-inner border border-surface-border-strong bg-surface-overlay px-ds-03 text-ds-sm text-surface-fg focus:border-accent-7 focus:outline-hidden"
83
- }), /* @__PURE__ */ y(n, {
83
+ className: "h-ds-sm w-[240px] rounded-control-inner border border-surface-border-strong bg-surface-overlay px-ds-03 text-body-sm text-surface-fg focus:border-accent-7 focus:outline-hidden"
84
+ }), /* @__PURE__ */ b(n, {
84
85
  type: "submit",
85
86
  variant: "solid",
86
87
  size: "sm",
@@ -89,11 +90,11 @@ function G({ editor: e }) {
89
90
  })]
90
91
  });
91
92
  }
92
- function K() {
93
- return /* @__PURE__ */ y("div", { className: "mx-ds-02 h-ds-05 w-px bg-surface-border" });
93
+ function G() {
94
+ return /* @__PURE__ */ b("div", { className: "mx-ds-02 h-ds-05 w-px bg-surface-border" });
94
95
  }
95
- function q({ editor: e, toolbar: n, onImageClick: r, onFileClick: i, onEmojiClick: a }) {
96
- let o = p({
96
+ function K({ editor: e, toolbar: n, onImageClick: r, onFileClick: i, onEmojiClick: a, trailing: o, showControls: s = !0 }) {
97
+ let c = m({
97
98
  editor: e,
98
99
  selector: ({ editor: e }) => ({
99
100
  isBold: e.isActive("bold"),
@@ -115,235 +116,246 @@ function q({ editor: e, toolbar: n, onImageClick: r, onFileClick: i, onEmojiClic
115
116
  canUndo: e.can().undo(),
116
117
  canRedo: e.can().redo()
117
118
  })
118
- }), s = (e) => !n || n.includes(e), c = s("bold") || s("italic") || s("underline") || s("strike") || s("highlight"), l = s("h2") || s("h3") || s("blockquote"), u = s("bulletList") || s("orderedList") || s("taskList") || s("codeBlock"), d = s("link") || !!r && s("image") || !!i && s("file") || s("hr"), f = s("alignLeft") || s("alignCenter") || s("alignRight"), m = !!a && s("emoji"), h = s("undo") || s("redo");
119
- return /* @__PURE__ */ b("div", {
119
+ }), l = (e) => !n || n.includes(e), u = l("bold") || l("italic") || l("underline") || l("strike") || l("highlight"), d = l("h2") || l("h3") || l("blockquote"), f = l("bulletList") || l("orderedList") || l("taskList") || l("codeBlock"), p = l("link") || !!r && l("image") || !!i && l("file") || l("hr"), h = l("alignLeft") || l("alignCenter") || l("alignRight"), g = !!a && l("emoji"), _ = l("undo") || l("redo");
120
+ return /* @__PURE__ */ x("div", {
120
121
  role: "toolbar",
121
122
  "aria-label": "Text formatting",
122
- className: "flex flex-wrap items-center gap-ds-01 border-b border-surface-border-strong px-ds-04 py-ds-02b",
123
- children: [
124
- s("bold") && /* @__PURE__ */ y(W, {
123
+ className: "flex min-h-[2.75rem] flex-wrap items-center gap-ds-01 border-b border-surface-border-strong px-ds-04 py-ds-02b",
124
+ children: [s && /* @__PURE__ */ x(y, { children: [
125
+ l("bold") && /* @__PURE__ */ b(U, {
125
126
  onClick: () => e.chain().focus().toggleBold().run(),
126
- isActive: o.isBold,
127
+ isActive: c.isBold,
127
128
  title: "Bold",
128
- children: /* @__PURE__ */ y(t, {
129
- icon: D,
129
+ children: /* @__PURE__ */ b(t, {
130
+ icon: O,
130
131
  size: "sm",
131
132
  stroke: "bold"
132
133
  })
133
134
  }),
134
- s("italic") && /* @__PURE__ */ y(W, {
135
+ l("italic") && /* @__PURE__ */ b(U, {
135
136
  onClick: () => e.chain().focus().toggleItalic().run(),
136
- isActive: o.isItalic,
137
+ isActive: c.isItalic,
137
138
  title: "Italic",
138
- children: /* @__PURE__ */ y(t, {
139
- icon: M,
139
+ children: /* @__PURE__ */ b(t, {
140
+ icon: j,
140
141
  size: "sm",
141
142
  stroke: "bold"
142
143
  })
143
144
  }),
144
- s("underline") && /* @__PURE__ */ y(W, {
145
+ l("underline") && /* @__PURE__ */ b(U, {
145
146
  onClick: () => e.chain().focus().toggleUnderline().run(),
146
- isActive: o.isUnderline,
147
+ isActive: c.isUnderline,
147
148
  title: "Underline",
148
- children: /* @__PURE__ */ y(t, {
149
- icon: H,
149
+ children: /* @__PURE__ */ b(t, {
150
+ icon: z,
150
151
  size: "sm",
151
152
  stroke: "bold"
152
153
  })
153
154
  }),
154
- s("strike") && /* @__PURE__ */ y(W, {
155
+ l("strike") && /* @__PURE__ */ b(U, {
155
156
  onClick: () => e.chain().focus().toggleStrike().run(),
156
- isActive: o.isStrike,
157
+ isActive: c.isStrike,
157
158
  title: "Strikethrough",
158
- children: /* @__PURE__ */ y(t, {
159
- icon: V,
159
+ children: /* @__PURE__ */ b(t, {
160
+ icon: R,
160
161
  size: "sm",
161
162
  stroke: "bold"
162
163
  })
163
164
  }),
164
- s("highlight") && /* @__PURE__ */ y(W, {
165
+ l("highlight") && /* @__PURE__ */ b(U, {
165
166
  onClick: () => e.chain().focus().toggleHighlight().run(),
166
- isActive: o.isHighlight,
167
+ isActive: c.isHighlight,
167
168
  title: "Highlight",
168
- children: /* @__PURE__ */ y(t, {
169
- icon: j,
169
+ children: /* @__PURE__ */ b(t, {
170
+ icon: re,
170
171
  size: "sm",
171
172
  stroke: "bold"
172
173
  })
173
174
  }),
174
- c && l && /* @__PURE__ */ y(K, {}),
175
- s("h2") && /* @__PURE__ */ y(W, {
175
+ u && d && /* @__PURE__ */ b(G, {}),
176
+ l("h2") && /* @__PURE__ */ b(U, {
176
177
  onClick: () => e.chain().focus().toggleHeading({ level: 2 }).run(),
177
- isActive: o.isH2,
178
+ isActive: c.isH2,
178
179
  title: "Heading 2",
179
- children: /* @__PURE__ */ y(t, {
180
- icon: k,
180
+ children: /* @__PURE__ */ b(t, {
181
+ icon: te,
181
182
  size: "sm",
182
183
  stroke: "bold"
183
184
  })
184
185
  }),
185
- s("h3") && /* @__PURE__ */ y(W, {
186
+ l("h3") && /* @__PURE__ */ b(U, {
186
187
  onClick: () => e.chain().focus().toggleHeading({ level: 3 }).run(),
187
- isActive: o.isH3,
188
+ isActive: c.isH3,
188
189
  title: "Heading 3",
189
- children: /* @__PURE__ */ y(t, {
190
- icon: A,
190
+ children: /* @__PURE__ */ b(t, {
191
+ icon: ne,
191
192
  size: "sm",
192
193
  stroke: "bold"
193
194
  })
194
195
  }),
195
- s("blockquote") && /* @__PURE__ */ y(W, {
196
+ l("blockquote") && /* @__PURE__ */ b(U, {
196
197
  onClick: () => e.chain().focus().toggleBlockquote().run(),
197
- isActive: o.isBlockquote,
198
+ isActive: c.isBlockquote,
198
199
  title: "Blockquote",
199
- children: /* @__PURE__ */ y(t, {
200
- icon: E,
200
+ children: /* @__PURE__ */ b(t, {
201
+ icon: D,
201
202
  size: "sm",
202
203
  stroke: "bold"
203
204
  })
204
205
  }),
205
- l && u && /* @__PURE__ */ y(K, {}),
206
- s("bulletList") && /* @__PURE__ */ y(W, {
206
+ d && f && /* @__PURE__ */ b(G, {}),
207
+ l("bulletList") && /* @__PURE__ */ b(U, {
207
208
  onClick: () => e.chain().focus().toggleBulletList().run(),
208
- isActive: o.isBulletList,
209
+ isActive: c.isBulletList,
209
210
  title: "Bullet list",
210
- children: /* @__PURE__ */ y(t, {
211
- icon: F,
211
+ children: /* @__PURE__ */ b(t, {
212
+ icon: P,
212
213
  size: "sm",
213
214
  stroke: "bold"
214
215
  })
215
216
  }),
216
- s("orderedList") && /* @__PURE__ */ y(W, {
217
+ l("orderedList") && /* @__PURE__ */ b(U, {
217
218
  onClick: () => e.chain().focus().toggleOrderedList().run(),
218
- isActive: o.isOrderedList,
219
+ isActive: c.isOrderedList,
219
220
  title: "Ordered list",
220
- children: /* @__PURE__ */ y(t, {
221
- icon: L,
221
+ children: /* @__PURE__ */ b(t, {
222
+ icon: I,
222
223
  size: "sm",
223
224
  stroke: "bold"
224
225
  })
225
226
  }),
226
- s("taskList") && /* @__PURE__ */ y(W, {
227
+ l("taskList") && /* @__PURE__ */ b(U, {
227
228
  onClick: () => e.chain().focus().toggleTaskList().run(),
228
- isActive: o.isTaskList,
229
+ isActive: c.isTaskList,
229
230
  title: "Task list",
230
- children: /* @__PURE__ */ y(t, {
231
- icon: I,
231
+ children: /* @__PURE__ */ b(t, {
232
+ icon: F,
232
233
  size: "sm",
233
234
  stroke: "bold"
234
235
  })
235
236
  }),
236
- s("codeBlock") && /* @__PURE__ */ y(W, {
237
+ l("codeBlock") && /* @__PURE__ */ b(U, {
237
238
  onClick: () => e.chain().focus().toggleCodeBlock().run(),
238
- isActive: o.isCodeBlock,
239
+ isActive: c.isCodeBlock,
239
240
  title: "Code block",
240
- children: /* @__PURE__ */ y(t, {
241
- icon: O,
241
+ children: /* @__PURE__ */ b(t, {
242
+ icon: k,
242
243
  size: "sm",
243
244
  stroke: "bold"
244
245
  })
245
246
  }),
246
- u && d && /* @__PURE__ */ y(K, {}),
247
- s("link") && /* @__PURE__ */ y(G, { editor: e }),
248
- r && s("image") && /* @__PURE__ */ y(W, {
247
+ f && p && /* @__PURE__ */ b(G, {}),
248
+ l("link") && /* @__PURE__ */ b(W, { editor: e }),
249
+ r && l("image") && /* @__PURE__ */ b(U, {
249
250
  onClick: r,
250
251
  title: "Insert image",
251
- children: /* @__PURE__ */ y(t, {
252
- icon: B,
252
+ children: /* @__PURE__ */ b(t, {
253
+ icon: ae,
253
254
  size: "sm"
254
255
  })
255
256
  }),
256
- i && s("file") && /* @__PURE__ */ y(W, {
257
+ i && l("file") && /* @__PURE__ */ b(U, {
257
258
  onClick: i,
258
259
  title: "Attach file",
259
- children: /* @__PURE__ */ y(t, {
260
- icon: z,
260
+ children: /* @__PURE__ */ b(t, {
261
+ icon: ie,
261
262
  size: "sm"
262
263
  })
263
264
  }),
264
- s("hr") && /* @__PURE__ */ y(W, {
265
+ l("hr") && /* @__PURE__ */ b(U, {
265
266
  onClick: () => e.chain().focus().setHorizontalRule().run(),
266
267
  title: "Horizontal rule",
267
- children: /* @__PURE__ */ y(t, {
268
- icon: N,
268
+ children: /* @__PURE__ */ b(t, {
269
+ icon: M,
269
270
  size: "sm"
270
271
  })
271
272
  }),
272
- d && f && /* @__PURE__ */ y(K, {}),
273
- s("alignLeft") && /* @__PURE__ */ y(W, {
273
+ p && h && /* @__PURE__ */ b(G, {}),
274
+ l("alignLeft") && /* @__PURE__ */ b(U, {
274
275
  onClick: () => e.chain().focus().setTextAlign("left").run(),
275
- isActive: o.isAlignLeft,
276
+ isActive: c.isAlignLeft,
276
277
  title: "Align left",
277
- children: /* @__PURE__ */ y(t, {
278
- icon: S,
278
+ children: /* @__PURE__ */ b(t, {
279
+ icon: C,
279
280
  size: "sm"
280
281
  })
281
282
  }),
282
- s("alignCenter") && /* @__PURE__ */ y(W, {
283
+ l("alignCenter") && /* @__PURE__ */ b(U, {
283
284
  onClick: () => e.chain().focus().setTextAlign("center").run(),
284
- isActive: o.isAlignCenter,
285
+ isActive: c.isAlignCenter,
285
286
  title: "Align center",
286
- children: /* @__PURE__ */ y(t, {
287
- icon: x,
287
+ children: /* @__PURE__ */ b(t, {
288
+ icon: S,
288
289
  size: "sm"
289
290
  })
290
291
  }),
291
- s("alignRight") && /* @__PURE__ */ y(W, {
292
+ l("alignRight") && /* @__PURE__ */ b(U, {
292
293
  onClick: () => e.chain().focus().setTextAlign("right").run(),
293
- isActive: o.isAlignRight,
294
+ isActive: c.isAlignRight,
294
295
  title: "Align right",
295
- children: /* @__PURE__ */ y(t, {
296
- icon: C,
296
+ children: /* @__PURE__ */ b(t, {
297
+ icon: w,
297
298
  size: "sm"
298
299
  })
299
300
  }),
300
- f && (m || h) && /* @__PURE__ */ y(K, {}),
301
- a && s("emoji") && /* @__PURE__ */ y(W, {
301
+ h && (g || _) && /* @__PURE__ */ b(G, {}),
302
+ a && l("emoji") && /* @__PURE__ */ b(U, {
302
303
  onClick: a,
303
304
  title: "Emoji",
304
- children: /* @__PURE__ */ y(t, {
305
- icon: R,
305
+ children: /* @__PURE__ */ b(t, {
306
+ icon: L,
306
307
  size: "sm"
307
308
  })
308
309
  }),
309
- s("undo") && /* @__PURE__ */ y(W, {
310
+ l("undo") && /* @__PURE__ */ b(U, {
310
311
  onClick: () => e.chain().focus().undo().run(),
311
- disabled: !o.canUndo,
312
+ disabled: !c.canUndo,
312
313
  title: "Undo",
313
- children: /* @__PURE__ */ y(t, {
314
- icon: w,
314
+ children: /* @__PURE__ */ b(t, {
315
+ icon: T,
315
316
  size: "sm"
316
317
  })
317
318
  }),
318
- s("redo") && /* @__PURE__ */ y(W, {
319
+ l("redo") && /* @__PURE__ */ b(U, {
319
320
  onClick: () => e.chain().focus().redo().run(),
320
- disabled: !o.canRedo,
321
+ disabled: !c.canRedo,
321
322
  title: "Redo",
322
- children: /* @__PURE__ */ y(t, {
323
- icon: T,
323
+ children: /* @__PURE__ */ b(t, {
324
+ icon: E,
324
325
  size: "sm"
325
326
  })
326
327
  })
327
- ]
328
+ ] }), o && /* @__PURE__ */ b("div", {
329
+ className: "ml-auto flex items-center pl-ds-02",
330
+ children: o
331
+ })]
328
332
  });
329
333
  }
330
- var J = v.lazy(() => import("./emoji-picker.js").then((e) => ({ default: e.EmojiPicker })));
331
- function Y({ onSelect: e }) {
332
- let t = /* @__PURE__ */ y("div", {
334
+ var q = v.lazy(() => import("./emoji-picker.js").then((e) => ({ default: e.EmojiPicker })));
335
+ function se({ onSelect: e }) {
336
+ let t = /* @__PURE__ */ b("div", {
333
337
  className: "flex h-[435px] w-[352px] items-center justify-center rounded-surface bg-surface-overlay shadow-raised-hover",
334
- children: /* @__PURE__ */ y("span", {
335
- className: "text-ds-sm text-surface-fg-subtle",
338
+ children: /* @__PURE__ */ b("span", {
339
+ className: "text-body-sm text-surface-fg-subtle",
336
340
  children: "Loading…"
337
341
  })
338
342
  });
339
- return /* @__PURE__ */ y(v.Suspense, {
343
+ return /* @__PURE__ */ b(v.Suspense, {
340
344
  fallback: t,
341
- children: /* @__PURE__ */ y(J, { onSelect: e })
345
+ children: /* @__PURE__ */ b(q, { onSelect: e })
342
346
  });
343
347
  }
344
- var X = v.forwardRef(function({ content: t = "", placeholder: n = "Start writing...", onChange: r, className: p, editable: x = !0, toolbar: S, onImageUpload: C, onFileUpload: w, mentions: T, onMentionSearch: E, onMentionSelect: D, emojiSet: O = "native", ...k }, A) {
345
- let j = v.useRef(null), M = v.useRef(!1), [N, P] = v.useState(!1), F = v.useRef(null), I = v.useRef(null), L = v.useRef(null), R = async (e) => {
346
- let t = j.current;
348
+ var J = v.createContext(null);
349
+ function Y() {
350
+ let e = v.useContext(J);
351
+ if (!e) throw Error("RichTextEditor.Toolbar / .Content must be used within <RichTextEditor.Provider>");
352
+ return e;
353
+ }
354
+ var X = v.forwardRef(function({ format: t = "html", content: n = "", placeholder: r = "Start writing...", onChange: i, className: m, editable: y = !0, toolbar: S, onImageUpload: C, onFileUpload: w, mentions: T, onMentionSearch: E, onMentionSelect: D, sourceMode: O, defaultSourceMode: k = !1, onSourceModeChange: A, emojiSet: te = "native", sourceToggle: ne, children: re, ...j }, M) {
355
+ let N = v.useRef(null), P = v.useRef(!1), F = V(), [I, L] = v.useState(!1), [ie, ae] = v.useState(k), R = O ?? ie, z = v.useCallback((e) => {
356
+ O === void 0 && ae(e), A?.(e);
357
+ }, [O, A]), [U, W] = v.useState(""), G = v.useRef(null), K = v.useRef(null), q = v.useRef(null), Y = async (e) => {
358
+ let t = N.current;
347
359
  if (t) if (C) {
348
360
  let n = await C(e);
349
361
  n && /^https?:\/\//i.test(n) && t.chain().focus().setImage({ src: n }).run();
@@ -353,8 +365,8 @@ var X = v.forwardRef(function({ content: t = "", placeholder: n = "Start writing
353
365
  t.chain().focus().setImage({ src: n.result }).run();
354
366
  }, n.readAsDataURL(e);
355
367
  }
356
- }, z = async (e) => {
357
- let t = j.current;
368
+ }, X = async (e) => {
369
+ let t = N.current;
358
370
  if (!t || !w) return;
359
371
  let n = await w(e);
360
372
  t.chain().focus().insertContent({
@@ -365,10 +377,10 @@ var X = v.forwardRef(function({ content: t = "", placeholder: n = "Start writing
365
377
  size: n.size
366
378
  }
367
379
  }).run();
368
- }, B = f({
380
+ }, Z = p({
369
381
  immediatelyRender: !1,
370
382
  extensions: [
371
- c.configure({
383
+ l.configure({
372
384
  heading: { levels: [2, 3] },
373
385
  link: {
374
386
  openOnClick: !1,
@@ -384,11 +396,11 @@ var X = v.forwardRef(function({ content: t = "", placeholder: n = "Start writing
384
396
  }
385
397
  }
386
398
  }),
387
- o.configure({
388
- placeholder: n,
399
+ s.configure({
400
+ placeholder: r,
389
401
  emptyEditorClass: "before:content-[attr(data-placeholder)] before:text-surface-fg-subtle before:float-left before:h-0 before:pointer-events-none"
390
402
  }),
391
- d.configure({ multicolor: !1 }),
403
+ f.configure({ multicolor: !1 }),
392
404
  a.configure({
393
405
  bulletList: !1,
394
406
  orderedList: !1,
@@ -397,113 +409,254 @@ var X = v.forwardRef(function({ content: t = "", placeholder: n = "Start writing
397
409
  taskList: {},
398
410
  taskItem: { nested: !0 }
399
411
  }),
400
- s.configure({ types: ["heading", "paragraph"] }),
401
- u.configure({
412
+ c.configure({ types: ["heading", "paragraph"] }),
413
+ d.configure({
402
414
  allowBase64: !0,
403
415
  HTMLAttributes: { class: "max-w-full rounded-control" }
404
416
  }),
405
- g,
406
- ...T || E ? [l.configure({
417
+ _,
418
+ ...T || E ? [u.configure({
407
419
  HTMLAttributes: { class: "mention" },
408
420
  suggestion: {
409
421
  items: async ({ query: e }) => E ? await E(e) : T ? T.filter((t) => t.label.toLowerCase().includes(e.toLowerCase())).slice(0, 8) : [],
410
- render: _(D)
422
+ render: ee(D)
411
423
  }
412
424
  })] : [],
413
- m,
414
- h()
425
+ h,
426
+ g(),
427
+ o
415
428
  ],
416
- content: t,
417
- editable: x,
429
+ content: n,
430
+ contentType: t === "markdown" ? "markdown" : void 0,
431
+ editable: y,
418
432
  editorProps: {
419
433
  handleDrop: (e, t, n, r) => {
420
434
  if (r || !t.dataTransfer?.files.length) return !1;
421
435
  let i = t.dataTransfer.files[0];
422
- return i ? i.type.startsWith("image/") ? (R(i), !0) : w ? (z(i), !0) : !1 : !1;
436
+ return i ? i.type.startsWith("image/") ? (Y(i), !0) : w ? (X(i), !0) : !1 : !1;
423
437
  },
424
438
  handlePaste: (e, t) => {
425
439
  let n = t.clipboardData?.files[0];
426
- return n ? n.type.startsWith("image/") ? (R(n), !0) : w ? (z(n), !0) : !1 : !1;
440
+ return n ? n.type.startsWith("image/") ? (Y(n), !0) : w ? (X(n), !0) : !1 : !1;
427
441
  },
428
- attributes: { class: e(...U, "focus:outline-hidden", "min-h-[120px] px-ds-04 py-ds-04") }
442
+ attributes: { class: e(...H, "focus:outline-hidden", "min-h-[120px] px-ds-04 py-ds-04") }
429
443
  },
430
444
  onUpdate: ({ editor: e }) => {
431
- M.current = !0, r?.(e.getHTML()), queueMicrotask(() => {
432
- M.current = !1;
445
+ P.current = !0, i?.(t === "markdown" ? e.getMarkdown() : e.getHTML()), queueMicrotask(() => {
446
+ P.current = !1;
433
447
  });
434
448
  }
435
449
  });
436
- return v.useEffect(() => {
437
- j.current = B;
438
- }, [B]), v.useEffect(() => {
439
- if (!N) return;
450
+ if (v.useEffect(() => {
451
+ N.current = Z;
452
+ }, [Z]), v.useEffect(() => {
453
+ if (!I) return;
440
454
  let e = (e) => {
441
- F.current && !F.current.contains(e.target) && P(!1);
455
+ G.current && !G.current.contains(e.target) && L(!1);
442
456
  };
443
457
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
444
- }, [N]), v.useEffect(() => {
445
- M.current || B && t !== B.getHTML() && B.commands.setContent(t, { emitUpdate: !1 });
446
- }, [B, t]), B ? /* @__PURE__ */ b("div", {
447
- ref: A,
448
- ...k,
449
- className: e("relative", p),
450
- children: [N && /* @__PURE__ */ y("div", {
451
- ref: F,
452
- className: "absolute bottom-full right-0 z-popover mb-ds-02",
453
- onKeyDown: (e) => {
454
- e.key === "Escape" && (e.stopPropagation(), P(!1));
455
- },
456
- children: /* @__PURE__ */ y(Y, { onSelect: ({ id: e, native: t }) => {
457
- B.chain().focus().insertContent({
458
- type: "emojiNode",
459
- attrs: {
460
- id: e,
461
- native: t
462
- }
463
- }).run(), P(!1);
464
- } })
465
- }), /* @__PURE__ */ b("div", {
466
- className: e("overflow-hidden rounded-surface border border-surface-border-strong bg-surface-raised", "transition-colors ease-productive-standard focus-within:border-surface-border-strong"),
458
+ }, [I]), v.useEffect(() => {
459
+ P.current || Z && n !== (t === "markdown" ? Z.getMarkdown() : Z.getHTML()) && Z.commands.setContent(n, {
460
+ emitUpdate: !1,
461
+ contentType: t === "markdown" ? "markdown" : void 0
462
+ });
463
+ }, [
464
+ Z,
465
+ n,
466
+ t
467
+ ]), v.useEffect(() => {
468
+ R && Z && W(Z.getMarkdown());
469
+ }, [R]), !Z) return null;
470
+ let Q = {
471
+ editor: Z,
472
+ toolbar: S,
473
+ editable: y,
474
+ onImageClick: () => K.current?.click(),
475
+ onFileClick: w ? () => q.current?.click() : void 0,
476
+ onEmojiClick: () => L((e) => !e),
477
+ sourceMode: R,
478
+ setSourceMode: z,
479
+ toggleSource: () => z(!R),
480
+ sourceText: U,
481
+ onSourceChange: (e) => {
482
+ W(e), Z.commands.setContent(e, { contentType: "markdown" });
483
+ }
484
+ };
485
+ return /* @__PURE__ */ b(J.Provider, {
486
+ value: Q,
487
+ children: /* @__PURE__ */ x("div", {
488
+ ref: M,
489
+ ...j,
490
+ className: e("relative", m),
467
491
  children: [
468
- /* @__PURE__ */ y("input", {
469
- ref: I,
492
+ /* @__PURE__ */ b(oe, { children: I && /* @__PURE__ */ b(B.div, {
493
+ ref: G,
494
+ initial: !F && {
495
+ opacity: 0,
496
+ scale: .96,
497
+ y: 4
498
+ },
499
+ animate: {
500
+ opacity: 1,
501
+ scale: 1,
502
+ y: 0
503
+ },
504
+ exit: F ? { opacity: 0 } : {
505
+ opacity: 0,
506
+ scale: .96,
507
+ y: 4
508
+ },
509
+ transition: {
510
+ duration: .14,
511
+ ease: "easeOut"
512
+ },
513
+ className: "absolute bottom-full right-0 z-popover mb-ds-02 origin-bottom-right",
514
+ onKeyDown: (e) => {
515
+ e.key === "Escape" && (e.stopPropagation(), L(!1));
516
+ },
517
+ children: /* @__PURE__ */ b(se, { onSelect: ({ id: e, native: t }) => {
518
+ Z.chain().focus().insertContent({
519
+ type: "emojiNode",
520
+ attrs: {
521
+ id: e,
522
+ native: t
523
+ }
524
+ }).run(), L(!1);
525
+ } })
526
+ }, "emoji-picker") }),
527
+ /* @__PURE__ */ b("input", {
528
+ ref: K,
470
529
  type: "file",
471
530
  accept: "image/*",
472
531
  "aria-label": "Upload image",
473
532
  className: "hidden",
474
533
  onChange: (e) => {
475
534
  let t = e.target.files?.[0];
476
- t && R(t), e.target.value = "";
535
+ t && Y(t), e.target.value = "";
477
536
  }
478
537
  }),
479
- w && /* @__PURE__ */ y("input", {
480
- ref: L,
538
+ w && /* @__PURE__ */ b("input", {
539
+ ref: q,
481
540
  type: "file",
482
541
  "aria-label": "Upload file",
483
542
  className: "hidden",
484
543
  onChange: (e) => {
485
544
  let t = e.target.files?.[0];
486
- t && z(t), e.target.value = "";
545
+ t && X(t), e.target.value = "";
487
546
  }
488
547
  }),
489
- x && /* @__PURE__ */ y(q, {
490
- editor: B,
491
- toolbar: S,
492
- onImageClick: () => I.current?.click(),
493
- onFileClick: w ? () => L.current?.click() : void 0,
494
- onEmojiClick: () => P((e) => !e)
495
- }),
496
- /* @__PURE__ */ y(i, { editor: B })
548
+ re
497
549
  ]
498
- })]
499
- }) : null;
550
+ })
551
+ });
552
+ });
553
+ X.displayName = "RichTextEditor.Provider";
554
+ function Z({ trailing: e }) {
555
+ let { editor: t, toolbar: n, editable: r, sourceMode: i, onImageClick: a, onFileClick: o, onEmojiClick: s } = Y();
556
+ if (!r) return null;
557
+ let c = !i;
558
+ return !c && !e ? null : /* @__PURE__ */ b(K, {
559
+ editor: t,
560
+ toolbar: n,
561
+ showControls: c,
562
+ trailing: e,
563
+ onImageClick: a,
564
+ onFileClick: o,
565
+ onEmojiClick: s
566
+ });
567
+ }
568
+ Z.displayName = "RichTextEditor.Toolbar";
569
+ function Q() {
570
+ let { editor: e, sourceMode: t, sourceText: n, onSourceChange: r } = Y(), a = V() ? { opacity: 0 } : {
571
+ opacity: 0,
572
+ y: 4
573
+ };
574
+ return /* @__PURE__ */ b(oe, {
575
+ mode: "wait",
576
+ initial: !1,
577
+ children: t ? /* @__PURE__ */ b(B.div, {
578
+ initial: a,
579
+ animate: {
580
+ opacity: 1,
581
+ y: 0
582
+ },
583
+ exit: a,
584
+ transition: {
585
+ duration: .14,
586
+ ease: "easeOut"
587
+ },
588
+ children: /* @__PURE__ */ b("textarea", {
589
+ value: n,
590
+ onChange: (e) => r(e.target.value),
591
+ spellCheck: !1,
592
+ "aria-label": "Markdown source",
593
+ className: "block min-h-[120px] w-full resize-y bg-surface-raised px-ds-04 py-ds-04 font-mono text-body-sm leading-ds-relaxed text-surface-fg focus:outline-hidden"
594
+ })
595
+ }, "source") : /* @__PURE__ */ b(B.div, {
596
+ initial: a,
597
+ animate: {
598
+ opacity: 1,
599
+ y: 0
600
+ },
601
+ exit: a,
602
+ transition: {
603
+ duration: .14,
604
+ ease: "easeOut"
605
+ },
606
+ children: /* @__PURE__ */ b(i, { editor: e })
607
+ }, "visual")
608
+ });
609
+ }
610
+ Q.displayName = "RichTextEditor.Content";
611
+ function $({ className: e, iconOnly: r = !1 }) {
612
+ let { sourceMode: i, toggleSource: a } = Y(), o = i ? "Switch to visual editor" : "Switch to Markdown source", s = i ? A : k;
613
+ return r ? /* @__PURE__ */ b(n, {
614
+ type: "button",
615
+ variant: "ghost",
616
+ size: "icon-sm",
617
+ "aria-pressed": i,
618
+ "aria-label": o,
619
+ title: o,
620
+ className: e,
621
+ onClick: a,
622
+ children: /* @__PURE__ */ b(t, {
623
+ icon: s,
624
+ size: "sm"
625
+ })
626
+ }) : /* @__PURE__ */ b(n, {
627
+ type: "button",
628
+ variant: "ghost",
629
+ size: "sm",
630
+ "aria-pressed": i,
631
+ "aria-label": o,
632
+ startIcon: s,
633
+ className: e,
634
+ onClick: a,
635
+ children: i ? "Editor" : "Markdown"
636
+ });
637
+ }
638
+ $.displayName = "RichTextEditor.SourceToggle";
639
+ var ce = v.forwardRef(function(t, n) {
640
+ return /* @__PURE__ */ b(X, {
641
+ ref: n,
642
+ ...t,
643
+ children: /* @__PURE__ */ x("div", {
644
+ className: e("overflow-hidden rounded-surface border border-surface-border-strong bg-surface-raised", "transition-colors ease-productive-standard focus-within:border-surface-border-strong"),
645
+ children: [/* @__PURE__ */ b(Z, { trailing: t.sourceToggle ? /* @__PURE__ */ b($, {}) : void 0 }), /* @__PURE__ */ b(Q, {})]
646
+ })
647
+ });
500
648
  });
501
- X.displayName = "RichTextEditor";
502
- var Z = v.forwardRef(function({ content: t, className: n, ...r }, o) {
503
- let p = f({
649
+ ce.displayName = "RichTextEditor";
650
+ var le = Object.assign(ce, {
651
+ Provider: X,
652
+ Toolbar: Z,
653
+ Content: Q,
654
+ SourceToggle: $
655
+ }), ue = v.forwardRef(function({ content: t, format: n = "html", className: r, ...s }, m) {
656
+ let h = p({
504
657
  immediatelyRender: !1,
505
658
  extensions: [
506
- c.configure({
659
+ l.configure({
507
660
  heading: { levels: [2, 3] },
508
661
  link: {
509
662
  openOnClick: !0,
@@ -519,7 +672,7 @@ var Z = v.forwardRef(function({ content: t, className: n, ...r }, o) {
519
672
  }
520
673
  }
521
674
  }),
522
- d.configure({ multicolor: !1 }),
675
+ f.configure({ multicolor: !1 }),
523
676
  a.configure({
524
677
  bulletList: !1,
525
678
  orderedList: !1,
@@ -528,25 +681,27 @@ var Z = v.forwardRef(function({ content: t, className: n, ...r }, o) {
528
681
  taskList: {},
529
682
  taskItem: { nested: !0 }
530
683
  }),
531
- s.configure({ types: ["heading", "paragraph"] }),
532
- u.configure({
684
+ c.configure({ types: ["heading", "paragraph"] }),
685
+ d.configure({
533
686
  allowBase64: !0,
534
687
  HTMLAttributes: { class: "max-w-full rounded-control" }
535
688
  }),
536
- g,
537
- l.configure({ HTMLAttributes: { class: "mention" } })
689
+ _,
690
+ u.configure({ HTMLAttributes: { class: "mention" } }),
691
+ o
538
692
  ],
539
693
  content: t,
694
+ contentType: n === "markdown" ? "markdown" : void 0,
540
695
  editable: !1,
541
- editorProps: { attributes: { class: e(...U) } }
696
+ editorProps: { attributes: { class: e(...H) } }
542
697
  });
543
- return p ? /* @__PURE__ */ y("div", {
544
- ref: o,
545
- ...r,
546
- className: n,
547
- children: /* @__PURE__ */ y(i, { editor: p })
698
+ return h ? /* @__PURE__ */ b("div", {
699
+ ref: m,
700
+ ...s,
701
+ className: r,
702
+ children: /* @__PURE__ */ b(i, { editor: h })
548
703
  }) : null;
549
704
  });
550
- Z.displayName = "RichTextViewer";
705
+ ue.displayName = "RichTextViewer";
551
706
  //#endregion
552
- export { X as RichTextEditor, Z as RichTextViewer };
707
+ export { le as RichTextEditor, Q as RichTextEditorContent, X as RichTextEditorProvider, $ as RichTextEditorSourceToggle, Z as RichTextEditorToolbar, ue as RichTextViewer, Y as useRichTextEditor };