@wakastellar/ui 3.3.3 → 3.5.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 (140) hide show
  1. package/dist/badge-BbwO7QeZ.js +1 -0
  2. package/dist/badge-BfiocODp.mjs +23 -0
  3. package/dist/charts.cjs.js +1 -1
  4. package/dist/charts.es.js +1 -1
  5. package/dist/chunk-14q5BKub.js +1 -0
  6. package/dist/{chunk-BH6uBOac.mjs → chunk-Cr9pTUWm.mjs} +5 -5
  7. package/dist/cn-DEtaFQsA.js +1 -0
  8. package/dist/cn-DUn6aSIQ.mjs +24 -0
  9. package/dist/doc.cjs.js +2 -2
  10. package/dist/doc.es.js +19 -19
  11. package/dist/editor.cjs.js +48 -0
  12. package/dist/editor.d.ts +1 -0
  13. package/dist/editor.es.js +6551 -0
  14. package/dist/{exceljs.min-DG9M8IZ1.mjs → exceljs.min-DL1XYDll.mjs} +1 -1
  15. package/dist/{exceljs.min-BuefmDRS.js → exceljs.min-qeIfSCbF.js} +1 -1
  16. package/dist/export.cjs.js +1 -1
  17. package/dist/export.es.js +1 -1
  18. package/dist/index.cjs.js +150 -150
  19. package/dist/index.es.js +26782 -27591
  20. package/dist/input-BfaSAGVw.js +1 -0
  21. package/dist/input-DVr_Qkl8.mjs +14 -0
  22. package/dist/rich-text.cjs.js +1 -1
  23. package/dist/rich-text.es.js +1 -1
  24. package/dist/security-CyBpuklN.mjs +122 -0
  25. package/dist/security-bFWwDrlg.js +1 -0
  26. package/dist/separator-NrkltulH.js +1 -0
  27. package/dist/separator-ibN2mycs.mjs +51 -0
  28. package/dist/src/components/editor/blocks/index.d.ts +51 -0
  29. package/dist/src/components/editor/blocks/waka-acceptance-criteria-block.d.ts +60 -0
  30. package/dist/src/components/editor/blocks/waka-ai-assist-block.d.ts +58 -0
  31. package/dist/src/components/editor/blocks/waka-api-endpoint-block.d.ts +63 -0
  32. package/dist/src/components/editor/blocks/waka-code-playground-block.d.ts +61 -0
  33. package/dist/src/components/editor/blocks/waka-comment-thread-block.d.ts +85 -0
  34. package/dist/src/components/editor/blocks/waka-diagram-block.d.ts +52 -0
  35. package/dist/src/components/editor/blocks/waka-embed-block.d.ts +58 -0
  36. package/dist/src/components/editor/blocks/waka-slash-menu-block.d.ts +67 -0
  37. package/dist/src/components/editor/blocks/waka-user-story-block.d.ts +79 -0
  38. package/dist/src/components/editor/blocks/waka-version-diff-block.d.ts +73 -0
  39. package/dist/src/components/editor/index.d.ts +66 -0
  40. package/dist/src/components/editor/waka-ai-writer.d.ts +80 -0
  41. package/dist/src/components/editor/waka-collaborative-editor.d.ts +93 -0
  42. package/dist/src/components/editor/waka-diff-viewer.d.ts +71 -0
  43. package/dist/src/components/editor/waka-dnd-editor.d.ts +64 -0
  44. package/dist/src/components/editor/waka-document-editor.d.ts +92 -0
  45. package/dist/src/components/editor/waka-editor-elements.d.ts +79 -0
  46. package/dist/src/components/editor/waka-editor-leaves.d.ts +39 -0
  47. package/dist/src/components/editor/waka-editor-plugins.d.ts +41 -0
  48. package/dist/src/components/editor/waka-editor-toolbar.d.ts +20 -0
  49. package/dist/src/components/editor/waka-editor.d.ts +59 -0
  50. package/dist/src/components/editor/waka-floating-toolbar.d.ts +47 -0
  51. package/dist/src/components/editor/waka-markdown-editor.d.ts +60 -0
  52. package/dist/src/components/editor/waka-mention-editor.d.ts +125 -0
  53. package/dist/src/components/editor/waka-slash-menu.d.ts +70 -0
  54. package/dist/src/components/editor/waka-spec-editor.d.ts +88 -0
  55. package/dist/src/components/index.d.ts +1 -15
  56. package/dist/src/editor.d.ts +26 -0
  57. package/dist/textarea-CdQWggYG.js +1 -0
  58. package/dist/textarea-DJDXJ3nd.mjs +23 -0
  59. package/dist/types-C2St0wOW.js +1 -0
  60. package/dist/{types-B6GVaSIP.mjs → types-JnqoLyuv.mjs} +214 -211
  61. package/dist/{useDataTableImport-BPvfo--2.mjs → useDataTableImport-BWUFesPi.mjs} +3 -3
  62. package/dist/{useDataTableImport-Cm_pCKnO.js → useDataTableImport-T7ddpN5k.js} +3 -3
  63. package/dist/waka-doc-renderer-CTxC7Trf.js +3 -0
  64. package/dist/{waka-doc-renderer-BkIvas3z.mjs → waka-doc-renderer-Cw-Xnyen.mjs} +264 -281
  65. package/dist/waka-editor-plugins-DR6tpsUC.mjs +135 -0
  66. package/dist/waka-editor-plugins-sGSh9hn2.js +1 -0
  67. package/dist/waka-rich-text-editor-BlIdtknG.js +1 -0
  68. package/dist/waka-rich-text-editor-D1uA3zbB.js +1 -0
  69. package/dist/waka-rich-text-editor-DgSWiXMW.mjs +342 -0
  70. package/dist/waka-rich-text-editor-DndVJuDw.mjs +2 -0
  71. package/package.json +87 -2
  72. package/src/blocks/footer/index.tsx +1 -6
  73. package/src/blocks/login/index.tsx +1 -7
  74. package/src/blocks/profile/index.tsx +3 -5
  75. package/src/components/editor/blocks/index.ts +182 -0
  76. package/src/components/editor/blocks/waka-acceptance-criteria-block.tsx +326 -0
  77. package/src/components/editor/blocks/waka-ai-assist-block.tsx +284 -0
  78. package/src/components/editor/blocks/waka-api-endpoint-block.tsx +382 -0
  79. package/src/components/editor/blocks/waka-code-playground-block.tsx +331 -0
  80. package/src/components/editor/blocks/waka-comment-thread-block.tsx +448 -0
  81. package/src/components/editor/blocks/waka-diagram-block.tsx +293 -0
  82. package/src/components/editor/blocks/waka-embed-block.tsx +416 -0
  83. package/src/components/editor/blocks/waka-slash-menu-block.tsx +432 -0
  84. package/src/components/editor/blocks/waka-user-story-block.tsx +295 -0
  85. package/src/components/editor/blocks/waka-version-diff-block.tsx +426 -0
  86. package/src/components/editor/index.ts +279 -0
  87. package/src/components/editor/waka-ai-writer.tsx +434 -0
  88. package/src/components/editor/waka-collaborative-editor.tsx +426 -0
  89. package/src/components/editor/waka-diff-viewer.tsx +352 -0
  90. package/src/components/editor/waka-dnd-editor.tsx +284 -0
  91. package/src/components/editor/waka-document-editor.tsx +502 -0
  92. package/src/components/editor/waka-editor-elements.tsx +312 -0
  93. package/src/components/editor/waka-editor-leaves.tsx +101 -0
  94. package/src/components/editor/waka-editor-plugins.ts +207 -0
  95. package/src/components/editor/waka-editor-toolbar.tsx +358 -0
  96. package/src/components/editor/waka-editor.tsx +431 -0
  97. package/src/components/editor/waka-floating-toolbar.tsx +268 -0
  98. package/src/components/editor/waka-markdown-editor.tsx +395 -0
  99. package/src/components/editor/waka-mention-editor.tsx +459 -0
  100. package/src/components/editor/waka-slash-menu.tsx +392 -0
  101. package/src/components/editor/waka-spec-editor.tsx +657 -0
  102. package/src/components/index.ts +1 -18
  103. package/dist/chunk-BDDJmn7V.js +0 -1
  104. package/dist/cn-DnPbmOCy.js +0 -1
  105. package/dist/cn-DpLcAzrf.mjs +0 -22
  106. package/dist/separator-BDReXBvI.mjs +0 -59
  107. package/dist/separator-BKjNl9sI.js +0 -1
  108. package/dist/src/components/waka-actor-badge/index.d.ts +0 -8
  109. package/dist/src/components/waka-actors-list/index.d.ts +0 -18
  110. package/dist/src/components/waka-ai-assistant-button/index.d.ts +0 -8
  111. package/dist/src/components/waka-document-flyover/index.d.ts +0 -10
  112. package/dist/src/components/waka-document-preview-popup/index.d.ts +0 -26
  113. package/dist/src/components/waka-hour-balance-badge/index.d.ts +0 -8
  114. package/dist/src/components/waka-hour-consumption-table/index.d.ts +0 -15
  115. package/dist/src/components/waka-hour-pack-dialog/index.d.ts +0 -8
  116. package/dist/src/components/waka-project-stats-header/index.d.ts +0 -15
  117. package/dist/src/components/waka-step-comment-bubble/index.d.ts +0 -13
  118. package/dist/src/components/waka-step-comment-panel/index.d.ts +0 -20
  119. package/dist/src/components/waka-step-permission-matrix/index.d.ts +0 -12
  120. package/dist/src/components/waka-time-entry-dialog/index.d.ts +0 -16
  121. package/dist/src/components/waka-time-tracking-flyover/index.d.ts +0 -11
  122. package/dist/types-BH9cQRqZ.js +0 -1
  123. package/dist/waka-doc-renderer-BZ2-SqyT.js +0 -3
  124. package/dist/waka-rich-text-editor-BJGlQgpq.js +0 -1
  125. package/dist/waka-rich-text-editor-BJzzxeP1.mjs +0 -361
  126. package/dist/waka-rich-text-editor-wnXLwvUo.js +0 -1
  127. package/src/components/waka-actor-badge/index.tsx +0 -34
  128. package/src/components/waka-actors-list/index.tsx +0 -125
  129. package/src/components/waka-ai-assistant-button/index.tsx +0 -31
  130. package/src/components/waka-document-flyover/index.tsx +0 -36
  131. package/src/components/waka-document-preview-popup/index.tsx +0 -103
  132. package/src/components/waka-hour-balance-badge/index.tsx +0 -43
  133. package/src/components/waka-hour-consumption-table/index.tsx +0 -72
  134. package/src/components/waka-hour-pack-dialog/index.tsx +0 -72
  135. package/src/components/waka-project-stats-header/index.tsx +0 -69
  136. package/src/components/waka-step-comment-bubble/index.tsx +0 -71
  137. package/src/components/waka-step-comment-panel/index.tsx +0 -106
  138. package/src/components/waka-step-permission-matrix/index.tsx +0 -65
  139. package/src/components/waka-time-entry-dialog/index.tsx +0 -131
  140. package/src/components/waka-time-tracking-flyover/index.tsx +0 -41
@@ -0,0 +1,293 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cn } from "../../../utils/cn"
5
+ import type { PlateElementProps } from "../waka-editor-elements"
6
+
7
+ // ============================================================================
8
+ // Types
9
+ // ============================================================================
10
+
11
+ export const DIAGRAM_BLOCK_TYPE = "diagram" as const
12
+
13
+ /** Supported diagram syntax types */
14
+ export type DiagramSyntax = "mermaid" | "plantuml" | "excalidraw"
15
+
16
+ /** Slate node for diagram blocks */
17
+ export interface DiagramElement {
18
+ type: typeof DIAGRAM_BLOCK_TYPE
19
+ /** Diagram syntax type */
20
+ syntax: DiagramSyntax
21
+ /** Raw source code of the diagram */
22
+ source: string
23
+ /** Optional title/caption */
24
+ caption?: string
25
+ children: Array<{ text: string }>
26
+ }
27
+
28
+ export interface WakaDiagramBlockProps extends PlateElementProps {
29
+ element?: DiagramElement & Record<string, unknown>
30
+ /**
31
+ * External render function: takes diagram source and syntax,
32
+ * returns sanitized SVG string or HTML.
33
+ *
34
+ * IMPORTANT: The consuming application is responsible for sanitizing
35
+ * the returned HTML (e.g. using DOMPurify) before it is rendered.
36
+ */
37
+ onRender?: (source: string, syntax: DiagramSyntax) => Promise<string>
38
+ }
39
+
40
+ // ============================================================================
41
+ // Syntax Label
42
+ // ============================================================================
43
+
44
+ const SYNTAX_CONFIG: Record<DiagramSyntax, { label: string; color: string; icon: string }> = {
45
+ mermaid: {
46
+ label: "Mermaid",
47
+ color: "text-pink-600 dark:text-pink-400 bg-pink-50 dark:bg-pink-500/10",
48
+ icon: "M12 3l8 4.5v9L12 21l-8-4.5v-9L12 3z",
49
+ },
50
+ plantuml: {
51
+ label: "PlantUML",
52
+ color: "text-teal-600 dark:text-teal-400 bg-teal-50 dark:bg-teal-500/10",
53
+ icon: "M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6z",
54
+ },
55
+ excalidraw: {
56
+ label: "Excalidraw",
57
+ color: "text-indigo-600 dark:text-indigo-400 bg-indigo-50 dark:bg-indigo-500/10",
58
+ icon: "M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z",
59
+ },
60
+ }
61
+
62
+ // ============================================================================
63
+ // Element Component
64
+ // ============================================================================
65
+
66
+ /**
67
+ * WakaDiagramBlock - A Plate.js block that embeds a diagram editor (Mermaid/PlantUML/Excalidraw)
68
+ * inline in the document. The user writes diagram source code and sees the rendered
69
+ * output below.
70
+ *
71
+ * The rendering is delegated to an external `onRender` callback, allowing the consuming
72
+ * app to use mermaid.js, kroki.io, or any other renderer. The consuming app MUST sanitize
73
+ * the rendered output (e.g. using DOMPurify) before returning it.
74
+ *
75
+ * If no `onRender` is provided, only the source code is displayed.
76
+ *
77
+ * Register in Plate editor:
78
+ * ```ts
79
+ * components: {
80
+ * [DIAGRAM_BLOCK_TYPE]: (props) => <WakaDiagramBlock {...props} onRender={myRenderer} />,
81
+ * }
82
+ * ```
83
+ */
84
+ export function WakaDiagramBlock({
85
+ attributes,
86
+ children,
87
+ element,
88
+ className,
89
+ onRender,
90
+ }: WakaDiagramBlockProps) {
91
+ const el = element as DiagramElement | undefined
92
+ const syntax = el?.syntax || "mermaid"
93
+ const source = el?.source || ""
94
+ const config = SYNTAX_CONFIG[syntax]
95
+
96
+ const [isRendering, setIsRendering] = React.useState(false)
97
+ const [renderError, setRenderError] = React.useState<string | null>(null)
98
+ const [showSource, setShowSource] = React.useState(!onRender)
99
+ const previewRef = React.useRef<HTMLDivElement>(null)
100
+
101
+ // Trigger render when source changes, inject result safely via DOM ref
102
+ React.useEffect(() => {
103
+ if (!source || !onRender || showSource) return
104
+ let cancelled = false
105
+
106
+ const render = async () => {
107
+ setIsRendering(true)
108
+ setRenderError(null)
109
+ try {
110
+ const result = await onRender(source, syntax)
111
+ if (!cancelled && previewRef.current) {
112
+ // Clear previous content
113
+ previewRef.current.textContent = ""
114
+ // Parse the sanitized HTML and append as DOM nodes
115
+ const parser = new DOMParser()
116
+ const doc = parser.parseFromString(result, "text/html")
117
+ const fragment = document.createDocumentFragment()
118
+ Array.from(doc.body.childNodes).forEach((node) => {
119
+ fragment.appendChild(document.importNode(node, true))
120
+ })
121
+ previewRef.current.appendChild(fragment)
122
+ }
123
+ } catch (err) {
124
+ if (!cancelled) {
125
+ setRenderError(err instanceof Error ? err.message : "Render failed")
126
+ }
127
+ } finally {
128
+ if (!cancelled) setIsRendering(false)
129
+ }
130
+ }
131
+
132
+ // Debounce rendering
133
+ const timeout = setTimeout(render, 500)
134
+ return () => {
135
+ cancelled = true
136
+ clearTimeout(timeout)
137
+ }
138
+ }, [source, syntax, onRender, showSource])
139
+
140
+ return (
141
+ <div
142
+ {...attributes}
143
+ contentEditable={false}
144
+ className={cn(
145
+ "my-4 rounded-lg overflow-hidden border border-border shadow-sm",
146
+ className
147
+ )}
148
+ >
149
+ {/* Header */}
150
+ <div className="flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border">
151
+ <div className="flex items-center gap-2">
152
+ <svg
153
+ className={cn("h-4 w-4", config.color.split(" ")[0])}
154
+ viewBox="0 0 24 24"
155
+ fill="none"
156
+ stroke="currentColor"
157
+ strokeWidth={2}
158
+ aria-hidden="true"
159
+ >
160
+ <path strokeLinecap="round" strokeLinejoin="round" d={config.icon} />
161
+ </svg>
162
+ <span className={cn("text-[10px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded", config.color)}>
163
+ {config.label}
164
+ </span>
165
+ {el?.caption && (
166
+ <span className="text-xs text-muted-foreground ml-2">{el.caption}</span>
167
+ )}
168
+ </div>
169
+
170
+ <div className="flex items-center gap-1">
171
+ {/* Toggle source/preview */}
172
+ <button
173
+ type="button"
174
+ onClick={() => setShowSource(true)}
175
+ className={cn(
176
+ "px-2 py-1 rounded text-[10px] font-medium transition-colors",
177
+ showSource
178
+ ? "bg-muted text-foreground"
179
+ : "text-muted-foreground hover:text-foreground"
180
+ )}
181
+ >
182
+ Source
183
+ </button>
184
+ <button
185
+ type="button"
186
+ onClick={() => setShowSource(false)}
187
+ className={cn(
188
+ "px-2 py-1 rounded text-[10px] font-medium transition-colors",
189
+ !showSource
190
+ ? "bg-muted text-foreground"
191
+ : "text-muted-foreground hover:text-foreground"
192
+ )}
193
+ >
194
+ Preview
195
+ </button>
196
+ </div>
197
+ </div>
198
+
199
+ {/* Source code */}
200
+ {showSource && (
201
+ <div className="border-b border-border">
202
+ <pre className={cn(
203
+ "text-[12px] font-mono leading-relaxed p-4 overflow-x-auto",
204
+ "bg-gray-950 dark:bg-gray-900 text-gray-100",
205
+ "max-h-[300px] overflow-y-auto"
206
+ )}>
207
+ <code>{source || `graph TD\n A[Start] --> B[Process]\n B --> C{Decision}\n C -->|Yes| D[Result A]\n C -->|No| E[Result B]`}</code>
208
+ </pre>
209
+ </div>
210
+ )}
211
+
212
+ {/* Rendered preview */}
213
+ {!showSource && (
214
+ <div className="p-4 bg-white dark:bg-gray-950 min-h-[120px] flex items-center justify-center">
215
+ {isRendering ? (
216
+ <div className="flex flex-col items-center gap-2 text-muted-foreground">
217
+ <svg className="h-6 w-6 animate-spin" viewBox="0 0 24 24" fill="none">
218
+ <circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
219
+ <path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
220
+ </svg>
221
+ <span className="text-xs">Rendering diagram...</span>
222
+ </div>
223
+ ) : renderError ? (
224
+ <div className="flex flex-col items-center gap-2 text-destructive">
225
+ <svg className="h-6 w-6" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
226
+ <path strokeLinecap="round" strokeLinejoin="round" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z" />
227
+ </svg>
228
+ <span className="text-xs">{renderError}</span>
229
+ </div>
230
+ ) : !onRender ? (
231
+ <div className="flex flex-col items-center gap-2 text-muted-foreground">
232
+ <svg className="h-8 w-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={1.5}>
233
+ <path strokeLinecap="round" strokeLinejoin="round" d={config.icon} />
234
+ </svg>
235
+ <span className="text-xs">Provide an onRender callback to see the diagram preview</span>
236
+ <button
237
+ type="button"
238
+ onClick={() => setShowSource(true)}
239
+ className="text-xs text-primary hover:underline"
240
+ >
241
+ View source instead
242
+ </button>
243
+ </div>
244
+ ) : (
245
+ <div
246
+ ref={previewRef}
247
+ className="diagram-rendered w-full [&_svg]:max-w-full [&_svg]:h-auto"
248
+ />
249
+ )}
250
+ </div>
251
+ )}
252
+
253
+ {/* Hidden Slate children */}
254
+ <div className="hidden">{children}</div>
255
+ </div>
256
+ )
257
+ }
258
+
259
+ WakaDiagramBlock.displayName = "WakaDiagramBlock"
260
+
261
+ // ============================================================================
262
+ // Node Factory
263
+ // ============================================================================
264
+
265
+ export function createDiagramNodes(options?: Partial<Omit<DiagramElement, "type" | "children">>): DiagramElement[] {
266
+ return [
267
+ {
268
+ type: DIAGRAM_BLOCK_TYPE,
269
+ syntax: options?.syntax || "mermaid",
270
+ source: options?.source || "graph TD\n A[Start] --> B[Process]\n B --> C{Decision}\n C -->|Yes| D[Result A]\n C -->|No| E[Result B]",
271
+ caption: options?.caption,
272
+ children: [{ text: "" }],
273
+ },
274
+ ]
275
+ }
276
+
277
+ export async function createDiagramPlugin(onRender?: (source: string, syntax: DiagramSyntax) => Promise<string>) {
278
+ try {
279
+ const { createPlatePlugin } = await import("platejs/react")
280
+ return createPlatePlugin({
281
+ key: DIAGRAM_BLOCK_TYPE,
282
+ node: {
283
+ isElement: true,
284
+ isVoid: true,
285
+ type: DIAGRAM_BLOCK_TYPE,
286
+ component: (props: WakaDiagramBlockProps) => <WakaDiagramBlock {...props} onRender={onRender} />,
287
+ },
288
+ })
289
+ } catch {
290
+ console.warn("[WakaDiagramBlock] platejs not installed")
291
+ return null
292
+ }
293
+ }