dishui 0.0.75 → 0.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/pro/RichTextEditor/BubbleToolbar.js +2 -26
- package/dist/components/pro/RichTextEditor/BubbleToolbar.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.d.ts +2 -1
- package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js +57 -22
- package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/Toolbar.js +2 -22
- package/dist/components/pro/RichTextEditor/Toolbar/Toolbar.js.map +1 -1
- package/dist/components/pro/RichTextEditor/extensions/CodeBlockView.js +31 -31
- package/dist/components/pro/RichTextEditor/extensions/CodeBlockView.js.map +1 -1
- package/dist/components/pro/RichTextEditor/extensions/FloatingDialog.js +44 -69
- package/dist/components/pro/RichTextEditor/extensions/FloatingDialog.js.map +1 -1
- package/dist/components/pro/RichTextEditor/extensions/MarkdownBlock.js +71 -70
- package/dist/components/pro/RichTextEditor/extensions/MarkdownBlock.js.map +1 -1
- package/dist/components/pro/RichTextEditor/extensions/legacyMermaid.d.ts +2 -0
- package/dist/components/pro/RichTextEditor/extensions/legacyMermaid.js +96 -0
- package/dist/components/pro/RichTextEditor/extensions/legacyMermaid.js.map +1 -0
- package/dist/dishui.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingDialog.js","names":[],"sources":["../../../../../src/components/pro/RichTextEditor/extensions/FloatingDialog.tsx"],"sourcesContent":["import React, { useState, useRef, useCallback, useEffect } from 'react';\nimport { cn } from '../../../../utils/cn';\nimport { Node, mergeAttributes } from '@tiptap/react';\nimport { NodeViewWrapper, NodeViewContent, ReactNodeViewRenderer } from '@tiptap/react';\nimport type { NodeViewProps } from '@tiptap/react';\nimport { useNodeEditable } from './MarkdownBlock';\n\ntype DialogLayout = 'block' | 'wrap-left' | 'wrap-right' | 'float';\n\ninterface DialogAttrs {\n x: number;\n y: number;\n width: number;\n height: number;\n borderColor: string;\n bgColor: string;\n title: string;\n layout: DialogLayout;\n zIndex: number;\n}\n\nconst DIALOG_COLORS = [\n { label: 'Blue', border: '#3b82f6', bg: '#eff6ff' },\n { label: 'Green', border: '#22c55e', bg: '#f0fdf4' },\n { label: 'Orange', border: '#f97316', bg: '#fff7ed' },\n { label: 'Red', border: '#ef4444', bg: '#fef2f2' },\n { label: 'Purple', border: '#8b5cf6', bg: '#faf5ff' },\n { label: 'Gray', border: '#6b7280', bg: '#f9fafb' },\n];\n\nconst LAYOUT_OPTIONS: { key: DialogLayout; label: string; icon: React.ReactNode }[] = [\n {\n key: 'block', label: 'Block',\n icon: <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\" /><line x1=\"3\" y1=\"3\" x2=\"21\" y2=\"3\" /><line x1=\"3\" y1=\"21\" x2=\"21\" y2=\"21\" /></svg>,\n },\n {\n key: 'wrap-left', label: 'Wrap Left',\n icon: <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><rect x=\"2\" y=\"4\" width=\"10\" height=\"8\" rx=\"1\" /><line x1=\"15\" y1=\"5\" x2=\"22\" y2=\"5\" /><line x1=\"15\" y1=\"8\" x2=\"22\" y2=\"8\" /><line x1=\"15\" y1=\"11\" x2=\"22\" y2=\"11\" /><line x1=\"2\" y1=\"15\" x2=\"22\" y2=\"15\" /><line x1=\"2\" y1=\"18\" x2=\"22\" y2=\"18\" /></svg>,\n },\n {\n key: 'wrap-right', label: 'Wrap Right',\n icon: <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><rect x=\"12\" y=\"4\" width=\"10\" height=\"8\" rx=\"1\" /><line x1=\"2\" y1=\"5\" x2=\"9\" y2=\"5\" /><line x1=\"2\" y1=\"8\" x2=\"9\" y2=\"8\" /><line x1=\"2\" y1=\"11\" x2=\"9\" y2=\"11\" /><line x1=\"2\" y1=\"15\" x2=\"22\" y2=\"15\" /><line x1=\"2\" y1=\"18\" x2=\"22\" y2=\"18\" /></svg>,\n },\n {\n key: 'float', label: 'Float',\n icon: <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><rect x=\"6\" y=\"6\" width=\"12\" height=\"12\" rx=\"2\" /><path d=\"M2 2h4M18 2h4M2 22h4M18 22h4\" strokeDasharray=\"2 2\" /><line x1=\"2\" y1=\"12\" x2=\"6\" y2=\"12\" strokeDasharray=\"2 2\" /><line x1=\"18\" y1=\"12\" x2=\"22\" y2=\"12\" strokeDasharray=\"2 2\" /></svg>,\n },\n];\n\n/** Scan the document and return all zIndex values of float-layout floatingDialog nodes */\nfunction collectFloatZIndices(editor: NodeViewProps['editor']): number[] {\n const indices: number[] = [];\n editor.state.doc.descendants((node) => {\n if (node.type.name === 'floatingDialog' && node.attrs.layout === 'float') {\n indices.push(node.attrs.zIndex ?? 10);\n }\n });\n return indices;\n}\n\nconst FloatingDialogView: React.FC<NodeViewProps> = ({\n node,\n editor,\n updateAttributes: writeAttributes,\n deleteNode,\n selected,\n}) => {\n const editable = useNodeEditable(editor);\n const updateAttributes = useCallback((attributes: Record<string, unknown>) => {\n if (!editor.isDestroyed && editor.isEditable) writeAttributes(attributes);\n }, [editor, writeAttributes]);\n const gestureCleanup = useRef<(() => void) | null>(null);\n const attrs = node.attrs as DialogAttrs;\n const layout = attrs.layout || 'block';\n const isFloat = layout === 'float';\n const zIndex = attrs.zIndex ?? 10;\n\n const [editingTitle, setEditingTitle] = useState(false);\n const [localTitle, setLocalTitle] = useState(attrs.title);\n const [showColorPicker, setShowColorPicker] = useState(false);\n const [showLayoutPicker, setShowLayoutPicker] = useState(false);\n const dragStart = useRef({ mx: 0, my: 0, x: 0, y: 0 });\n const resizeStart = useRef({ mx: 0, my: 0, w: 0, h: 0 });\n const colorRef = useRef<HTMLDivElement>(null);\n const layoutRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n setLocalTitle(attrs.title);\n }, [attrs.title]);\n\n useEffect(() => {\n if (!editable) {\n gestureCleanup.current?.();\n setEditingTitle(false);\n setLocalTitle(attrs.title);\n setShowColorPicker(false);\n setShowLayoutPicker(false);\n }\n }, [editable, attrs.title]);\n\n useEffect(() => {\n const cleanup = () => gestureCleanup.current?.();\n editor.on('destroy', cleanup);\n window.addEventListener('blur', cleanup);\n return () => {\n cleanup();\n editor.off('destroy', cleanup);\n window.removeEventListener('blur', cleanup);\n };\n }, [editor]);\n\n useEffect(() => {\n const handler = (e: MouseEvent) => {\n if (colorRef.current && !colorRef.current.contains(e.target as globalThis.Node)) {\n setShowColorPicker(false);\n }\n if (layoutRef.current && !layoutRef.current.contains(e.target as globalThis.Node)) {\n setShowLayoutPicker(false);\n }\n };\n document.addEventListener('mousedown', handler);\n return () => document.removeEventListener('mousedown', handler);\n }, []);\n\n const onDragStart = useCallback((e: React.MouseEvent) => {\n if (!isFloat || editor.isDestroyed || !editor.isEditable || e.button !== 0) return;\n gestureCleanup.current?.();\n e.preventDefault();\n e.stopPropagation();\n dragStart.current = { mx: e.clientX, my: e.clientY, x: attrs.x, y: attrs.y };\n\n const onMove = (ev: MouseEvent) => {\n const dx = ev.clientX - dragStart.current.mx;\n const dy = ev.clientY - dragStart.current.my;\n updateAttributes({\n x: dragStart.current.x + dx,\n y: dragStart.current.y + dy,\n });\n };\n const onUp = () => {\n document.removeEventListener('mousemove', onMove);\n document.removeEventListener('mouseup', onUp);\n };\n document.addEventListener('mousemove', onMove);\n document.addEventListener('mouseup', onUp);\n gestureCleanup.current = onUp;\n }, [editor, isFloat, attrs.x, attrs.y, updateAttributes]);\n\n const onResizeStart = useCallback((e: React.MouseEvent) => {\n if (editor.isDestroyed || !editor.isEditable || e.button !== 0) return;\n gestureCleanup.current?.();\n e.preventDefault();\n e.stopPropagation();\n resizeStart.current = { mx: e.clientX, my: e.clientY, w: attrs.width, h: attrs.height };\n\n const onMove = (ev: MouseEvent) => {\n const dw = ev.clientX - resizeStart.current.mx;\n const dh = ev.clientY - resizeStart.current.my;\n updateAttributes({\n width: Math.max(160, resizeStart.current.w + dw),\n height: Math.max(80, resizeStart.current.h + dh),\n });\n };\n const onUp = () => {\n document.removeEventListener('mousemove', onMove);\n document.removeEventListener('mouseup', onUp);\n };\n document.addEventListener('mousemove', onMove);\n document.addEventListener('mouseup', onUp);\n gestureCleanup.current = onUp;\n }, [editor, attrs.width, attrs.height, updateAttributes]);\n\n const saveTitle = useCallback(() => {\n updateAttributes({ title: localTitle });\n setEditingTitle(false);\n }, [localTitle, updateAttributes]);\n\n const bringForward = useCallback(() => {\n const all = collectFloatZIndices(editor);\n const maxZ = Math.max(...all);\n if (zIndex < maxZ) {\n updateAttributes({ zIndex: maxZ + 1 });\n }\n }, [editor, zIndex, updateAttributes]);\n\n const sendBackward = useCallback(() => {\n const all = collectFloatZIndices(editor);\n const minZ = Math.min(...all);\n if (zIndex > minZ) {\n updateAttributes({ zIndex: minZ - 1 });\n } else if (zIndex > 1) {\n updateAttributes({ zIndex: zIndex - 1 });\n }\n }, [editor, zIndex, updateAttributes]);\n\n const wrapperClass = cn(\n 'rte-float-dialog',\n `rte-float-dialog--${layout}`,\n selected && 'rte-float-dialog--selected',\n );\n\n const wrapperStyle: React.CSSProperties = isFloat\n ? { position: 'absolute', left: attrs.x, top: attrs.y, zIndex }\n : {};\n\n const boxStyle: React.CSSProperties = {\n width: layout === 'block' ? '100%' : attrs.width,\n minHeight: attrs.height,\n borderColor: attrs.borderColor,\n backgroundColor: attrs.bgColor,\n };\n\n const layoutIcon = LAYOUT_OPTIONS.find((l) => l.key === layout)?.icon;\n\n return (\n <NodeViewWrapper className={wrapperClass} style={wrapperStyle}>\n <div className=\"rte-float-dialog__box\" style={boxStyle}>\n {/* Title bar */}\n <div\n className=\"rte-float-dialog__titlebar\"\n style={{ borderBottomColor: attrs.borderColor }}\n onMouseDown={onDragStart}\n contentEditable={false}\n >\n {isFloat && (\n <span className=\"rte-float-dialog__drag-icon\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\">\n <circle cx=\"9\" cy=\"5\" r=\"1.5\" /><circle cx=\"15\" cy=\"5\" r=\"1.5\" />\n <circle cx=\"9\" cy=\"12\" r=\"1.5\" /><circle cx=\"15\" cy=\"12\" r=\"1.5\" />\n <circle cx=\"9\" cy=\"19\" r=\"1.5\" /><circle cx=\"15\" cy=\"19\" r=\"1.5\" />\n </svg>\n </span>\n )}\n\n {editingTitle && editable ? (\n <input\n className=\"rte-float-dialog__title-input\"\n value={localTitle}\n onChange={(e) => setLocalTitle(e.target.value)}\n placeholder=\"Title...\"\n onMouseDown={(e) => e.stopPropagation()}\n onBlur={saveTitle}\n onKeyDown={(e) => { if (e.key === 'Enter' || e.key === 'Escape') saveTitle(); }}\n autoFocus\n />\n ) : (\n <span className=\"rte-float-dialog__title\" onDoubleClick={() => { if (!editor.isDestroyed && editor.isEditable) setEditingTitle(true); }}>\n {attrs.title || 'Dialog'}\n </span>\n )}\n\n {editable && <div className=\"rte-float-dialog__actions\">\n {/* Z-order controls — only for float layout */}\n {isFloat && (\n <div className=\"rte-float-dialog__zorder\">\n <button\n type=\"button\"\n className=\"rte-float-dialog__action-btn\"\n onClick={(e) => { e.stopPropagation(); bringForward(); }}\n title=\"Bring to Front\"\n onMouseDown={(e) => e.stopPropagation()}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\">\n <rect x=\"8\" y=\"2\" width=\"13\" height=\"13\" rx=\"2\" />\n <rect x=\"3\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" opacity=\"0.4\" />\n </svg>\n </button>\n <button\n type=\"button\"\n className=\"rte-float-dialog__action-btn\"\n onClick={(e) => { e.stopPropagation(); sendBackward(); }}\n title=\"Send to Back\"\n onMouseDown={(e) => e.stopPropagation()}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\">\n <rect x=\"3\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" />\n <rect x=\"8\" y=\"2\" width=\"13\" height=\"13\" rx=\"2\" opacity=\"0.4\" />\n </svg>\n </button>\n </div>\n )}\n\n {/* Layout picker */}\n <div ref={layoutRef} style={{ position: 'relative' }}>\n <button\n type=\"button\"\n className=\"rte-float-dialog__action-btn\"\n onClick={(e) => { e.stopPropagation(); setShowLayoutPicker(!showLayoutPicker); }}\n title={`Layout: ${layout}`}\n onMouseDown={(e) => e.stopPropagation()}\n >\n {layoutIcon}\n </button>\n {showLayoutPicker && (\n <div className=\"rte-float-dialog__layout-dropdown\" onMouseDown={(e) => e.stopPropagation()}>\n {LAYOUT_OPTIONS.map((opt) => (\n <button\n key={opt.key}\n type=\"button\"\n className={`rte-float-dialog__layout-option ${layout === opt.key ? 'rte-float-dialog__layout-option--active' : ''}`}\n onClick={() => { updateAttributes({ layout: opt.key }); setShowLayoutPicker(false); }}\n title={opt.label}\n >\n {opt.icon}\n <span>{opt.label}</span>\n </button>\n ))}\n </div>\n )}\n </div>\n\n {/* Color picker */}\n <div ref={colorRef} style={{ position: 'relative' }}>\n <button\n type=\"button\"\n className=\"rte-float-dialog__action-btn\"\n onClick={(e) => { e.stopPropagation(); setShowColorPicker(!showColorPicker); }}\n title=\"Color\"\n onMouseDown={(e) => e.stopPropagation()}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill={attrs.borderColor} stroke={attrs.borderColor} strokeWidth=\"2\">\n <circle cx=\"12\" cy=\"12\" r=\"8\" />\n </svg>\n </button>\n {showColorPicker && (\n <div className=\"rte-float-dialog__color-dropdown\" onMouseDown={(e) => e.stopPropagation()}>\n {DIALOG_COLORS.map((c) => (\n <button\n key={c.label}\n type=\"button\"\n className=\"rte-float-dialog__color-swatch\"\n style={{ backgroundColor: c.border }}\n onClick={() => { updateAttributes({ borderColor: c.border, bgColor: c.bg }); setShowColorPicker(false); }}\n title={c.label}\n />\n ))}\n </div>\n )}\n </div>\n\n {/* Delete */}\n <button\n type=\"button\"\n className=\"rte-float-dialog__action-btn rte-float-dialog__action-btn--danger\"\n onClick={(e) => { e.stopPropagation(); if (!editor.isDestroyed && editor.isEditable) deleteNode(); }}\n title=\"Delete\"\n onMouseDown={(e) => e.stopPropagation()}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" /><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </button>\n </div>}\n </div>\n\n {/* Rich text body — Tiptap editable content */}\n <NodeViewContent className=\"rte-float-dialog__body\" />\n\n {/* Resize handle */}\n {editable && <div className=\"rte-float-dialog__resize-handle\" onMouseDown={onResizeStart} contentEditable={false}>\n <svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\">\n <circle cx=\"8\" cy=\"8\" r=\"1.2\" /><circle cx=\"4\" cy=\"8\" r=\"1.2\" /><circle cx=\"8\" cy=\"4\" r=\"1.2\" />\n </svg>\n </div>}\n </div>\n </NodeViewWrapper>\n );\n};\n\n/** Scan document for the highest zIndex among existing float dialogs */\nexport function getNextFloatZIndex(editor: { state: { doc: { descendants: (cb: (node: { type: { name: string }; attrs: Record<string, unknown> }) => void) => void } } }): number {\n let maxZ = 9;\n editor.state.doc.descendants((node) => {\n if (node.type.name === 'floatingDialog' && node.attrs.layout === 'float') {\n const z = (node.attrs.zIndex as number) ?? 10;\n if (z > maxZ) maxZ = z;\n }\n });\n return maxZ + 1;\n}\n\nexport const FloatingDialogExtension = Node.create({\n name: 'floatingDialog',\n group: 'block',\n content: 'block+',\n draggable: true,\n isolating: true,\n defining: true,\n\n addAttributes() {\n return {\n title: { default: 'Note' },\n x: { default: 20 },\n y: { default: 0 },\n width: { default: 280 },\n height: { default: 120 },\n borderColor: { default: '#3b82f6' },\n bgColor: { default: '#eff6ff' },\n layout: { default: 'block' },\n zIndex: { default: 10 },\n };\n },\n\n parseHTML() {\n return [{ tag: 'div[data-type=\"floating-dialog\"]' }];\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', mergeAttributes(HTMLAttributes, { 'data-type': 'floating-dialog' }), 0];\n },\n\n addNodeView() {\n return ReactNodeViewRenderer(FloatingDialogView);\n },\n});\n\nexport default FloatingDialogExtension;\n"],"mappings":";;;;;;AAqBA,IAAM,IAAgB;CACpB;EAAE,OAAO;EAAQ,QAAQ;EAAW,IAAI;CAAU;CAClD;EAAE,OAAO;EAAS,QAAQ;EAAW,IAAI;CAAU;CACnD;EAAE,OAAO;EAAU,QAAQ;EAAW,IAAI;CAAU;CACpD;EAAE,OAAO;EAAO,QAAQ;EAAW,IAAI;CAAU;CACjD;EAAE,OAAO;EAAU,QAAQ;EAAW,IAAI;CAAU;CACpD;EAAE,OAAO;EAAQ,QAAQ;EAAW,IAAI;CAAU;AACpD,GAEM,IAAgF;CACpF;EACE,KAAK;EAAS,OAAO;EACrB,MAAM,kBAAC,OAAD;GAAK,OAAM;GAAK,QAAO;GAAK,SAAQ;GAAY,MAAK;GAAO,QAAO;GAAe,aAAY;GAA9F,UAAA;IAAkG,kBAAC,QAAD;KAAM,GAAE;KAAI,GAAE;KAAI,OAAM;KAAK,QAAO;KAAK,IAAG;IAAK,CAAA;IAAC,kBAAC,QAAD;KAAM,IAAG;KAAI,IAAG;KAAI,IAAG;KAAK,IAAG;IAAK,CAAA;IAAC,kBAAC,QAAD;KAAM,IAAG;KAAI,IAAG;KAAK,IAAG;KAAK,IAAG;IAAM,CAAA;GAAM;;CAC7O;CACA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Q,EAAE,SAAS,GAAG;EACxB;CACF;CAEA,YAAY;EACV,OAAO,CAAC,EAAE,KAAK,qCAAmC,CAAC;CACrD;CAEA,WAAW,EAAE,qBAAkB;EAC7B,OAAO;GAAC;GAAO,EAAgB,GAAgB,EAAE,aAAa,kBAAkB,CAAC;GAAG;EAAC;CACvF;CAEA,cAAc;EACZ,OAAO,EAAsB,CAAkB;CACjD;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"FloatingDialog.js","names":[],"sources":["../../../../../src/components/pro/RichTextEditor/extensions/FloatingDialog.tsx"],"sourcesContent":["import React, { useState, useRef, useCallback, useEffect } from 'react';\nimport { cn } from '../../../../utils/cn';\nimport { Node, mergeAttributes } from '@tiptap/react';\nimport { NodeViewWrapper, NodeViewContent, ReactNodeViewRenderer } from '@tiptap/react';\nimport type { NodeViewProps } from '@tiptap/react';\nimport { useNodeEditable } from './MarkdownBlock';\n\ntype DialogLayout = 'block' | 'wrap-left' | 'wrap-right' | 'float';\n\ninterface DialogAttrs {\n x: number;\n y: number;\n width: number;\n height: number;\n borderColor: string;\n bgColor: string;\n title: string;\n layout: DialogLayout;\n zIndex: number;\n}\n\nconst DIALOG_COLORS = [\n { label: 'Blue', border: '#3b82f6', bg: '#eff6ff' },\n { label: 'Green', border: '#22c55e', bg: '#f0fdf4' },\n { label: 'Orange', border: '#f97316', bg: '#fff7ed' },\n { label: 'Red', border: '#ef4444', bg: '#fef2f2' },\n { label: 'Purple', border: '#8b5cf6', bg: '#faf5ff' },\n { label: 'Gray', border: '#6b7280', bg: '#f9fafb' },\n];\n\nconst LAYOUT_OPTIONS: { key: DialogLayout; label: string; icon: React.ReactNode }[] = [\n {\n key: 'block', label: 'Block',\n icon: <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\" /><line x1=\"3\" y1=\"3\" x2=\"21\" y2=\"3\" /><line x1=\"3\" y1=\"21\" x2=\"21\" y2=\"21\" /></svg>,\n },\n {\n key: 'wrap-left', label: 'Wrap Left',\n icon: <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><rect x=\"2\" y=\"4\" width=\"10\" height=\"8\" rx=\"1\" /><line x1=\"15\" y1=\"5\" x2=\"22\" y2=\"5\" /><line x1=\"15\" y1=\"8\" x2=\"22\" y2=\"8\" /><line x1=\"15\" y1=\"11\" x2=\"22\" y2=\"11\" /><line x1=\"2\" y1=\"15\" x2=\"22\" y2=\"15\" /><line x1=\"2\" y1=\"18\" x2=\"22\" y2=\"18\" /></svg>,\n },\n {\n key: 'wrap-right', label: 'Wrap Right',\n icon: <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><rect x=\"12\" y=\"4\" width=\"10\" height=\"8\" rx=\"1\" /><line x1=\"2\" y1=\"5\" x2=\"9\" y2=\"5\" /><line x1=\"2\" y1=\"8\" x2=\"9\" y2=\"8\" /><line x1=\"2\" y1=\"11\" x2=\"9\" y2=\"11\" /><line x1=\"2\" y1=\"15\" x2=\"22\" y2=\"15\" /><line x1=\"2\" y1=\"18\" x2=\"22\" y2=\"18\" /></svg>,\n },\n {\n key: 'float', label: 'Float',\n icon: <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><rect x=\"6\" y=\"6\" width=\"12\" height=\"12\" rx=\"2\" /><path d=\"M2 2h4M18 2h4M2 22h4M18 22h4\" strokeDasharray=\"2 2\" /><line x1=\"2\" y1=\"12\" x2=\"6\" y2=\"12\" strokeDasharray=\"2 2\" /><line x1=\"18\" y1=\"12\" x2=\"22\" y2=\"12\" strokeDasharray=\"2 2\" /></svg>,\n },\n];\n\n/** Scan the document and return all zIndex values of float-layout floatingDialog nodes */\nfunction collectFloatZIndices(editor: NodeViewProps['editor']): number[] {\n const indices: number[] = [];\n editor.state.doc.descendants((node) => {\n if (node.type.name === 'floatingDialog' && node.attrs.layout === 'float') {\n indices.push(node.attrs.zIndex ?? 10);\n }\n });\n return indices;\n}\n\nconst FloatingDialogView: React.FC<NodeViewProps> = ({\n node,\n editor,\n updateAttributes: writeAttributes,\n deleteNode,\n selected,\n}) => {\n const editable = useNodeEditable(editor);\n const updateAttributes = useCallback((attributes: Record<string, unknown>) => {\n if (!editor.isDestroyed && editor.isEditable) writeAttributes(attributes);\n }, [editor, writeAttributes]);\n const gestureCleanup = useRef<(() => void) | null>(null);\n const attrs = node.attrs as DialogAttrs;\n const layout = attrs.layout || 'block';\n const isFloat = layout === 'float';\n const zIndex = attrs.zIndex ?? 10;\n\n const [editingTitle, setEditingTitle] = useState(false);\n const [localTitle, setLocalTitle] = useState(attrs.title);\n const [showColorPicker, setShowColorPicker] = useState(false);\n const [showLayoutPicker, setShowLayoutPicker] = useState(false);\n\n const colorRef = useRef<HTMLDivElement>(null);\n const layoutRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n setLocalTitle(attrs.title);\n }, [attrs.title]);\n\n useEffect(() => {\n if (!editable) {\n gestureCleanup.current?.();\n setEditingTitle(false);\n setLocalTitle(attrs.title);\n setShowColorPicker(false);\n setShowLayoutPicker(false);\n }\n }, [editable, attrs.title]);\n\n useEffect(() => {\n const cleanup = () => gestureCleanup.current?.();\n editor.on('destroy', cleanup);\n window.addEventListener('blur', cleanup);\n return () => {\n cleanup();\n editor.off('destroy', cleanup);\n window.removeEventListener('blur', cleanup);\n };\n }, [editor]);\n\n useEffect(() => {\n const handler = (e: MouseEvent) => {\n if (colorRef.current && !colorRef.current.contains(e.target as globalThis.Node)) {\n setShowColorPicker(false);\n }\n if (layoutRef.current && !layoutRef.current.contains(e.target as globalThis.Node)) {\n setShowLayoutPicker(false);\n }\n };\n document.addEventListener('mousedown', handler);\n return () => document.removeEventListener('mousedown', handler);\n }, []);\n\n const startGesture = useCallback((e: React.PointerEvent<HTMLDivElement>, resize: boolean) => {\n if (editor.isDestroyed || !editor.isEditable || !e.isPrimary || e.button !== 0) return;\n if (!resize && (!isFloat || (e.target as HTMLElement).closest('button, input'))) return;\n gestureCleanup.current?.();\n e.preventDefault();\n e.stopPropagation();\n\n const target = e.currentTarget;\n const doc = target.ownerDocument;\n const pointerId = e.pointerId;\n const { clientX, clientY } = e;\n let lastX = resize ? attrs.width : attrs.x;\n let lastY = resize ? attrs.height : attrs.y;\n const startX = lastX;\n const startY = lastY;\n\n const onMove = (ev: PointerEvent) => {\n if (ev.pointerId !== pointerId) return;\n const x = resize ? Math.max(160, startX + ev.clientX - clientX) : startX + ev.clientX - clientX;\n const y = resize ? Math.max(80, startY + ev.clientY - clientY) : startY + ev.clientY - clientY;\n if (x === lastX && y === lastY) return;\n lastX = x;\n lastY = y;\n updateAttributes(resize ? { width: x, height: y } : { x, y });\n };\n const cleanup = () => {\n doc.removeEventListener('pointermove', onMove);\n doc.removeEventListener('pointerup', onEnd);\n doc.removeEventListener('pointercancel', onEnd);\n target.removeEventListener('lostpointercapture', onEnd);\n gestureCleanup.current = null;\n if (target.hasPointerCapture(pointerId)) target.releasePointerCapture(pointerId);\n };\n const onEnd = (ev: PointerEvent) => {\n if (ev.pointerId === pointerId) cleanup();\n };\n // Capture keeps the gesture paired even when a finger leaves the handle.\n target.setPointerCapture(pointerId);\n doc.addEventListener('pointermove', onMove);\n doc.addEventListener('pointerup', onEnd);\n doc.addEventListener('pointercancel', onEnd);\n target.addEventListener('lostpointercapture', onEnd);\n gestureCleanup.current = cleanup;\n }, [editor, isFloat, attrs.x, attrs.y, attrs.width, attrs.height, updateAttributes]);\n\n const saveTitle = useCallback(() => {\n updateAttributes({ title: localTitle });\n setEditingTitle(false);\n }, [localTitle, updateAttributes]);\n\n const bringForward = useCallback(() => {\n const all = collectFloatZIndices(editor);\n const maxZ = Math.max(...all);\n if (zIndex < maxZ) {\n updateAttributes({ zIndex: maxZ + 1 });\n }\n }, [editor, zIndex, updateAttributes]);\n\n const sendBackward = useCallback(() => {\n const all = collectFloatZIndices(editor);\n const minZ = Math.min(...all);\n if (zIndex > minZ) {\n updateAttributes({ zIndex: minZ - 1 });\n } else if (zIndex > 1) {\n updateAttributes({ zIndex: zIndex - 1 });\n }\n }, [editor, zIndex, updateAttributes]);\n\n const wrapperClass = cn(\n 'rte-float-dialog',\n `rte-float-dialog--${layout}`,\n selected && 'rte-float-dialog--selected',\n );\n\n const wrapperStyle: React.CSSProperties = isFloat\n ? { position: 'absolute', left: attrs.x, top: attrs.y, zIndex }\n : {};\n\n const boxStyle: React.CSSProperties = {\n width: layout === 'block' ? '100%' : attrs.width,\n minHeight: attrs.height,\n borderColor: attrs.borderColor,\n backgroundColor: attrs.bgColor,\n };\n\n const layoutIcon = LAYOUT_OPTIONS.find((l) => l.key === layout)?.icon;\n\n return (\n <NodeViewWrapper className={wrapperClass} style={wrapperStyle}>\n <div className=\"rte-float-dialog__box\" style={boxStyle}>\n {/* Title bar */}\n <div\n className=\"rte-float-dialog__titlebar\"\n style={{ borderBottomColor: attrs.borderColor, touchAction: isFloat && editable ? 'none' : undefined }}\n onPointerDown={(e) => startGesture(e, false)}\n contentEditable={false}\n >\n {isFloat && (\n <span className=\"rte-float-dialog__drag-icon\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\">\n <circle cx=\"9\" cy=\"5\" r=\"1.5\" /><circle cx=\"15\" cy=\"5\" r=\"1.5\" />\n <circle cx=\"9\" cy=\"12\" r=\"1.5\" /><circle cx=\"15\" cy=\"12\" r=\"1.5\" />\n <circle cx=\"9\" cy=\"19\" r=\"1.5\" /><circle cx=\"15\" cy=\"19\" r=\"1.5\" />\n </svg>\n </span>\n )}\n\n {editingTitle && editable ? (\n <input\n className=\"rte-float-dialog__title-input\"\n value={localTitle}\n onChange={(e) => setLocalTitle(e.target.value)}\n placeholder=\"Title...\"\n onMouseDown={(e) => e.stopPropagation()}\n onPointerDown={(e) => e.stopPropagation()}\n onBlur={saveTitle}\n onKeyDown={(e) => { if (e.key === 'Enter' || e.key === 'Escape') saveTitle(); }}\n autoFocus\n />\n ) : (\n <span className=\"rte-float-dialog__title\" onDoubleClick={() => { if (!editor.isDestroyed && editor.isEditable) setEditingTitle(true); }}>\n {attrs.title || 'Dialog'}\n </span>\n )}\n\n {editable && <div className=\"rte-float-dialog__actions\" onPointerDown={(e) => e.stopPropagation()}>\n {/* Z-order controls — only for float layout */}\n {isFloat && (\n <div className=\"rte-float-dialog__zorder\">\n <button\n type=\"button\"\n className=\"rte-float-dialog__action-btn\"\n onClick={(e) => { e.stopPropagation(); bringForward(); }}\n title=\"Bring to Front\"\n onMouseDown={(e) => e.stopPropagation()}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\">\n <rect x=\"8\" y=\"2\" width=\"13\" height=\"13\" rx=\"2\" />\n <rect x=\"3\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" opacity=\"0.4\" />\n </svg>\n </button>\n <button\n type=\"button\"\n className=\"rte-float-dialog__action-btn\"\n onClick={(e) => { e.stopPropagation(); sendBackward(); }}\n title=\"Send to Back\"\n onMouseDown={(e) => e.stopPropagation()}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\">\n <rect x=\"3\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" />\n <rect x=\"8\" y=\"2\" width=\"13\" height=\"13\" rx=\"2\" opacity=\"0.4\" />\n </svg>\n </button>\n </div>\n )}\n\n {/* Layout picker */}\n <div ref={layoutRef} style={{ position: 'relative' }}>\n <button\n type=\"button\"\n className=\"rte-float-dialog__action-btn\"\n onClick={(e) => { e.stopPropagation(); setShowLayoutPicker(!showLayoutPicker); }}\n title={`Layout: ${layout}`}\n onMouseDown={(e) => e.stopPropagation()}\n >\n {layoutIcon}\n </button>\n {showLayoutPicker && (\n <div className=\"rte-float-dialog__layout-dropdown\" onMouseDown={(e) => e.stopPropagation()}>\n {LAYOUT_OPTIONS.map((opt) => (\n <button\n key={opt.key}\n type=\"button\"\n className={`rte-float-dialog__layout-option ${layout === opt.key ? 'rte-float-dialog__layout-option--active' : ''}`}\n onClick={() => { updateAttributes({ layout: opt.key }); setShowLayoutPicker(false); }}\n title={opt.label}\n >\n {opt.icon}\n <span>{opt.label}</span>\n </button>\n ))}\n </div>\n )}\n </div>\n\n {/* Color picker */}\n <div ref={colorRef} style={{ position: 'relative' }}>\n <button\n type=\"button\"\n className=\"rte-float-dialog__action-btn\"\n onClick={(e) => { e.stopPropagation(); setShowColorPicker(!showColorPicker); }}\n title=\"Color\"\n onMouseDown={(e) => e.stopPropagation()}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill={attrs.borderColor} stroke={attrs.borderColor} strokeWidth=\"2\">\n <circle cx=\"12\" cy=\"12\" r=\"8\" />\n </svg>\n </button>\n {showColorPicker && (\n <div className=\"rte-float-dialog__color-dropdown\" onMouseDown={(e) => e.stopPropagation()}>\n {DIALOG_COLORS.map((c) => (\n <button\n key={c.label}\n type=\"button\"\n className=\"rte-float-dialog__color-swatch\"\n style={{ backgroundColor: c.border }}\n onClick={() => { updateAttributes({ borderColor: c.border, bgColor: c.bg }); setShowColorPicker(false); }}\n title={c.label}\n />\n ))}\n </div>\n )}\n </div>\n\n {/* Delete */}\n <button\n type=\"button\"\n className=\"rte-float-dialog__action-btn rte-float-dialog__action-btn--danger\"\n onClick={(e) => { e.stopPropagation(); if (!editor.isDestroyed && editor.isEditable) deleteNode(); }}\n title=\"Delete\"\n onMouseDown={(e) => e.stopPropagation()}\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" /><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </button>\n </div>}\n </div>\n\n {/* Rich text body — Tiptap editable content */}\n <NodeViewContent className=\"rte-float-dialog__body\" />\n\n {/* Resize handle */}\n {editable && <div className=\"rte-float-dialog__resize-handle\" onPointerDown={(e) => startGesture(e, true)} contentEditable={false}>\n <svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\">\n <circle cx=\"8\" cy=\"8\" r=\"1.2\" /><circle cx=\"4\" cy=\"8\" r=\"1.2\" /><circle cx=\"8\" cy=\"4\" r=\"1.2\" />\n </svg>\n </div>}\n </div>\n </NodeViewWrapper>\n );\n};\n\n/** Scan document for the highest zIndex among existing float dialogs */\nexport function getNextFloatZIndex(editor: { state: { doc: { descendants: (cb: (node: { type: { name: string }; attrs: Record<string, unknown> }) => void) => void } } }): number {\n let maxZ = 9;\n editor.state.doc.descendants((node) => {\n if (node.type.name === 'floatingDialog' && node.attrs.layout === 'float') {\n const z = (node.attrs.zIndex as number) ?? 10;\n if (z > maxZ) maxZ = z;\n }\n });\n return maxZ + 1;\n}\n\nexport const FloatingDialogExtension = Node.create({\n name: 'floatingDialog',\n group: 'block',\n content: 'block+',\n draggable: true,\n isolating: true,\n defining: true,\n\n addAttributes() {\n return {\n title: { default: 'Note' },\n x: { default: 20 },\n y: { default: 0 },\n width: { default: 280 },\n height: { default: 120 },\n borderColor: { default: '#3b82f6' },\n bgColor: { default: '#eff6ff' },\n layout: { default: 'block' },\n zIndex: { default: 10 },\n };\n },\n\n parseHTML() {\n return [{ tag: 'div[data-type=\"floating-dialog\"]' }];\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', mergeAttributes(HTMLAttributes, { 'data-type': 'floating-dialog' }), 0];\n },\n\n addNodeView() {\n return ReactNodeViewRenderer(FloatingDialogView);\n },\n});\n\nexport default FloatingDialogExtension;\n"],"mappings":";;;;;;AAqBA,IAAM,IAAgB;CACpB;EAAE,OAAO;EAAQ,QAAQ;EAAW,IAAI;CAAU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CAOX,OANA,EAAO,MAAM,IAAI,aAAa,MAAS;EACrC,IAAI,EAAK,KAAK,SAAS,oBAAoB,EAAK,MAAM,WAAW,SAAS;GACxE,IAAM,IAAK,EAAK,MAAM,UAAqB;GAC3C,AAAI,IAAI,MAAM,IAAO;EACvB;CACF,CAAC,GACM,IAAO;AAChB;AAEA,IAAa,IAA0B,EAAK,OAAO;CACjD,MAAM;CACN,OAAO;CACP,SAAS;CACT,WAAW;CACX,WAAW;CACX,UAAU;CAEV,gBAAgB;EACd,OAAO;GACL,OAAO,EAAE,SAAS,OAAO;GACzB,GAAG,EAAE,SAAS,GAAG;GACjB,GAAG,EAAE,SAAS,EAAE;GAChB,OAAO,EAAE,SAAS,IAAI;GACtB,QAAQ,EAAE,SAAS,IAAI;GACvB,aAAa,EAAE,SAAS,UAAU;GAClC,SAAS,EAAE,SAAS,UAAU;GAC9B,QAAQ,EAAE,SAAS,QAAQ;GAC3B,QAAQ,EAAE,SAAS,GAAG;EACxB;CACF;CAEA,YAAY;EACV,OAAO,CAAC,EAAE,KAAK,qCAAmC,CAAC;CACrD;CAEA,WAAW,EAAE,qBAAkB;EAC7B,OAAO;GAAC;GAAO,EAAgB,GAAgB,EAAE,aAAa,kBAAkB,CAAC;GAAG;EAAC;CACvF;CAEA,cAAc;EACZ,OAAO,EAAsB,CAAkB;CACjD;AACF,CAAC"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import l from "react-
|
|
6
|
-
import u from "
|
|
7
|
-
import d from "
|
|
8
|
-
import f from "
|
|
9
|
-
import p from "
|
|
1
|
+
import { normalizeLegacyMermaid as e } from "./legacyMermaid.js";
|
|
2
|
+
import { useCallback as t, useEffect as n, useRef as r, useState as i, useSyncExternalStore as a } from "react";
|
|
3
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
4
|
+
import { Prism as c } from "react-syntax-highlighter";
|
|
5
|
+
import { oneLight as l } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
6
|
+
import u from "react-markdown";
|
|
7
|
+
import d from "remark-gfm";
|
|
8
|
+
import f from "rehype-katex";
|
|
9
|
+
import p from "remark-math";
|
|
10
|
+
import m from "mermaid";
|
|
10
11
|
import "katex/dist/katex.min.css";
|
|
11
|
-
import { Node as
|
|
12
|
+
import { Node as h, NodeViewWrapper as g, ReactNodeViewRenderer as _, mergeAttributes as v } from "@tiptap/react";
|
|
12
13
|
//#region src/components/pro/RichTextEditor/extensions/MarkdownBlock.tsx
|
|
13
|
-
function
|
|
14
|
-
let n =
|
|
15
|
-
|
|
16
|
-
}), [
|
|
17
|
-
return
|
|
14
|
+
function y(e) {
|
|
15
|
+
let n = t((t) => (e.on("update", t), e.on("transaction", t), e.on("destroy", t), () => {
|
|
16
|
+
e.off("update", t), e.off("transaction", t), e.off("destroy", t);
|
|
17
|
+
}), [e]);
|
|
18
|
+
return a(n, () => !e.isDestroyed && e.isEditable, () => !1);
|
|
18
19
|
}
|
|
19
|
-
var
|
|
20
|
-
function
|
|
21
|
-
let n =
|
|
20
|
+
var b = Promise.resolve();
|
|
21
|
+
function x(e, t) {
|
|
22
|
+
let n = b.then(() => (m.initialize({
|
|
22
23
|
startOnLoad: !1,
|
|
23
24
|
theme: "default",
|
|
24
25
|
securityLevel: "strict",
|
|
@@ -28,35 +29,35 @@ function b(e, t) {
|
|
|
28
29
|
useMaxWidth: !0,
|
|
29
30
|
htmlLabels: !1
|
|
30
31
|
}
|
|
31
|
-
}),
|
|
32
|
-
return
|
|
32
|
+
}), m.mermaidAPI.render(e, t)));
|
|
33
|
+
return b = n.catch(() => void 0), n;
|
|
33
34
|
}
|
|
34
|
-
var
|
|
35
|
-
let
|
|
36
|
-
return
|
|
37
|
-
if (!
|
|
38
|
-
let
|
|
35
|
+
var S = ({ code: t }) => {
|
|
36
|
+
let i = r(null);
|
|
37
|
+
return n(() => {
|
|
38
|
+
if (!i.current || (i.current.replaceChildren(), !t.trim())) return;
|
|
39
|
+
let n = !1;
|
|
39
40
|
return (async () => {
|
|
40
41
|
try {
|
|
41
|
-
let { svg:
|
|
42
|
-
!
|
|
42
|
+
let { svg: r } = await x(`mermaid-md-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`, e(t));
|
|
43
|
+
!n && i.current && (i.current.innerHTML = r);
|
|
43
44
|
} catch (e) {
|
|
44
|
-
!
|
|
45
|
+
!n && i.current && (i.current.textContent = String(e));
|
|
45
46
|
}
|
|
46
47
|
})(), () => {
|
|
47
|
-
|
|
48
|
+
n = !0;
|
|
48
49
|
};
|
|
49
|
-
}, [
|
|
50
|
-
ref:
|
|
50
|
+
}, [t]), /* @__PURE__ */ o("div", {
|
|
51
|
+
ref: i,
|
|
51
52
|
className: "rte-mermaid-container"
|
|
52
53
|
});
|
|
53
|
-
},
|
|
54
|
-
remarkPlugins: [
|
|
55
|
-
rehypePlugins: [
|
|
54
|
+
}, C = ({ content: e }) => /* @__PURE__ */ o(u, {
|
|
55
|
+
remarkPlugins: [d, p],
|
|
56
|
+
rehypePlugins: [f],
|
|
56
57
|
components: { code({ className: e, children: t, ...n }) {
|
|
57
58
|
let r = /language-(\w+)/.exec(e || "")?.[1], i = String(t).replace(/\n$/, "");
|
|
58
|
-
return r === "mermaid" ? /* @__PURE__ */
|
|
59
|
-
style:
|
|
59
|
+
return r === "mermaid" ? /* @__PURE__ */ o(S, { code: i }) : r ? /* @__PURE__ */ o(c, {
|
|
60
|
+
style: l,
|
|
60
61
|
language: r,
|
|
61
62
|
PreTag: "div",
|
|
62
63
|
customStyle: {
|
|
@@ -66,51 +67,51 @@ var x = ({ code: e }) => {
|
|
|
66
67
|
margin: "0.5em 0"
|
|
67
68
|
},
|
|
68
69
|
children: i
|
|
69
|
-
}) : /* @__PURE__ */
|
|
70
|
+
}) : /* @__PURE__ */ o("code", {
|
|
70
71
|
className: e,
|
|
71
72
|
...n,
|
|
72
73
|
children: t
|
|
73
74
|
});
|
|
74
75
|
} },
|
|
75
76
|
children: e
|
|
76
|
-
}),
|
|
77
|
-
let u =
|
|
78
|
-
|
|
79
|
-
m(
|
|
80
|
-
}, [
|
|
81
|
-
d &&
|
|
77
|
+
}), w = ({ node: e, editor: a, updateAttributes: c, selected: l }) => {
|
|
78
|
+
let u = y(a), [d, f] = i(!1), [p, m] = i(e.attrs.content || ""), h = r(null);
|
|
79
|
+
n(() => {
|
|
80
|
+
m(e.attrs.content || ""), f(!1);
|
|
81
|
+
}, [e.attrs.content, u]), n(() => {
|
|
82
|
+
d && h.current && (h.current.focus(), _(h.current));
|
|
82
83
|
}, [d]);
|
|
83
84
|
let _ = (e) => {
|
|
84
85
|
e.style.height = "auto", e.style.height = e.scrollHeight + "px";
|
|
85
|
-
},
|
|
86
|
+
}, v = t((e) => {
|
|
86
87
|
m(e.target.value), _(e.target);
|
|
87
|
-
}, []), b =
|
|
88
|
-
!
|
|
88
|
+
}, []), b = t(() => {
|
|
89
|
+
!a.isDestroyed && a.isEditable && c({ content: p }), f(!1);
|
|
89
90
|
}, [
|
|
90
|
-
|
|
91
|
+
a,
|
|
91
92
|
p,
|
|
92
93
|
c
|
|
93
|
-
]), x =
|
|
94
|
+
]), x = t((e) => {
|
|
94
95
|
e.key === "Escape" && b();
|
|
95
|
-
}, [b]),
|
|
96
|
-
return /* @__PURE__ */
|
|
96
|
+
}, [b]), S = p || "# Markdown Block\n\nWrite your **markdown** here.\n\n```mermaid\ngraph LR\n A[Start] --> B[End]\n```\n";
|
|
97
|
+
return /* @__PURE__ */ s(g, {
|
|
97
98
|
contentEditable: !1,
|
|
98
99
|
className: `rte-markdown-block ${l ? "rte-markdown-block--selected" : ""}`,
|
|
99
|
-
children: [/* @__PURE__ */
|
|
100
|
+
children: [/* @__PURE__ */ s("div", {
|
|
100
101
|
className: "rte-markdown-block__header",
|
|
101
|
-
children: [/* @__PURE__ */
|
|
102
|
+
children: [/* @__PURE__ */ o("span", {
|
|
102
103
|
className: "rte-markdown-block__label",
|
|
103
104
|
children: "Markdown"
|
|
104
|
-
}), /* @__PURE__ */
|
|
105
|
+
}), /* @__PURE__ */ s("button", {
|
|
105
106
|
type: "button",
|
|
106
107
|
className: `rte-markdown-block__toggle ${d ? "rte-markdown-block__toggle--active" : ""}`,
|
|
107
108
|
disabled: !u,
|
|
108
109
|
onMouseDown: (e) => e.preventDefault(),
|
|
109
110
|
onClick: () => {
|
|
110
|
-
!
|
|
111
|
+
!a.isDestroyed && a.isEditable && (d && c({ content: p }), f(!d));
|
|
111
112
|
},
|
|
112
113
|
title: d ? "Preview" : "Edit",
|
|
113
|
-
children: [d ? /* @__PURE__ */
|
|
114
|
+
children: [d ? /* @__PURE__ */ s("svg", {
|
|
114
115
|
width: "14",
|
|
115
116
|
height: "14",
|
|
116
117
|
viewBox: "0 0 24 24",
|
|
@@ -119,12 +120,12 @@ var x = ({ code: e }) => {
|
|
|
119
120
|
strokeWidth: "2",
|
|
120
121
|
strokeLinecap: "round",
|
|
121
122
|
strokeLinejoin: "round",
|
|
122
|
-
children: [/* @__PURE__ */
|
|
123
|
+
children: [/* @__PURE__ */ o("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }), /* @__PURE__ */ o("circle", {
|
|
123
124
|
cx: "12",
|
|
124
125
|
cy: "12",
|
|
125
126
|
r: "3"
|
|
126
127
|
})]
|
|
127
|
-
}) : /* @__PURE__ */
|
|
128
|
+
}) : /* @__PURE__ */ s("svg", {
|
|
128
129
|
width: "14",
|
|
129
130
|
height: "14",
|
|
130
131
|
viewBox: "0 0 24 24",
|
|
@@ -133,33 +134,33 @@ var x = ({ code: e }) => {
|
|
|
133
134
|
strokeWidth: "2",
|
|
134
135
|
strokeLinecap: "round",
|
|
135
136
|
strokeLinejoin: "round",
|
|
136
|
-
children: [/* @__PURE__ */
|
|
137
|
-
}), /* @__PURE__ */
|
|
137
|
+
children: [/* @__PURE__ */ o("path", { d: "M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7" }), /* @__PURE__ */ o("path", { d: "M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" })]
|
|
138
|
+
}), /* @__PURE__ */ o("span", { children: d ? "Preview" : "Edit" })]
|
|
138
139
|
})]
|
|
139
|
-
}), /* @__PURE__ */
|
|
140
|
+
}), /* @__PURE__ */ o("div", {
|
|
140
141
|
className: "rte-markdown-block__body",
|
|
141
|
-
children: d && u ? /* @__PURE__ */
|
|
142
|
-
ref:
|
|
142
|
+
children: d && u ? /* @__PURE__ */ o("textarea", {
|
|
143
|
+
ref: h,
|
|
143
144
|
className: "rte-markdown-block__editor",
|
|
144
145
|
value: p,
|
|
145
|
-
onChange:
|
|
146
|
+
onChange: v,
|
|
146
147
|
onBlur: b,
|
|
147
148
|
onKeyDown: x,
|
|
148
149
|
placeholder: "Enter Markdown content...",
|
|
149
150
|
rows: 5
|
|
150
|
-
}) : /* @__PURE__ */
|
|
151
|
+
}) : /* @__PURE__ */ o("div", {
|
|
151
152
|
className: "rte-markdown-block__preview prose",
|
|
152
153
|
onDoubleClick: () => {
|
|
153
|
-
!
|
|
154
|
+
!a.isDestroyed && a.isEditable && f(!0);
|
|
154
155
|
},
|
|
155
|
-
children:
|
|
156
|
+
children: S.trim() ? /* @__PURE__ */ o(C, { content: S }) : /* @__PURE__ */ o("p", {
|
|
156
157
|
className: "rte-markdown-block__placeholder",
|
|
157
158
|
children: "Double-click to edit Markdown content..."
|
|
158
159
|
})
|
|
159
160
|
})
|
|
160
161
|
})]
|
|
161
162
|
});
|
|
162
|
-
},
|
|
163
|
+
}, T = h.create({
|
|
163
164
|
name: "markdownBlock",
|
|
164
165
|
group: "block",
|
|
165
166
|
atom: !0,
|
|
@@ -171,13 +172,13 @@ var x = ({ code: e }) => {
|
|
|
171
172
|
return [{ tag: "div[data-type=\"markdown-block\"]" }];
|
|
172
173
|
},
|
|
173
174
|
renderHTML({ HTMLAttributes: e }) {
|
|
174
|
-
return ["div",
|
|
175
|
+
return ["div", v(e, { "data-type": "markdown-block" })];
|
|
175
176
|
},
|
|
176
177
|
addNodeView() {
|
|
177
|
-
return
|
|
178
|
+
return _(w);
|
|
178
179
|
}
|
|
179
180
|
});
|
|
180
181
|
//#endregion
|
|
181
|
-
export {
|
|
182
|
+
export { T as MarkdownBlockExtension, T as default, S as MermaidRenderer, y as useNodeEditable };
|
|
182
183
|
|
|
183
184
|
//# sourceMappingURL=MarkdownBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownBlock.js","names":[],"sources":["../../../../../src/components/pro/RichTextEditor/extensions/MarkdownBlock.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef, useCallback, useSyncExternalStore } from 'react';\nimport { Node, mergeAttributes } from '@tiptap/react';\nimport { NodeViewWrapper, ReactNodeViewRenderer } from '@tiptap/react';\nimport type { NodeViewProps } from '@tiptap/react';\nimport ReactMarkdown from 'react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport rehypeKatex from 'rehype-katex';\n\nimport { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';\nimport { oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism';\nimport mermaid from 'mermaid';\nimport 'katex/dist/katex.min.css';\n\nexport function useNodeEditable(editor: NodeViewProps['editor']) {\n const subscribe = useCallback((notify: () => void) => {\n // setEditable emits update, not transaction, in Tiptap 3.\n editor.on('update', notify);\n editor.on('transaction', notify);\n editor.on('destroy', notify);\n return () => {\n editor.off('update', notify);\n editor.off('transaction', notify);\n editor.off('destroy', notify);\n };\n }, [editor]);\n return useSyncExternalStore(subscribe, () => !editor.isDestroyed && editor.isEditable, () => false);\n}\n\nlet renderQueue: Promise<unknown> = Promise.resolve();\n\nfunction renderMermaid(id: string, code: string) {\n const result = renderQueue.then(() => {\n // Capture strict config when rendering starts, not before Mermaid's global queue runs.\n mermaid.initialize({\n startOnLoad: false,\n theme: 'default',\n securityLevel: 'strict',\n suppressErrorRendering: true,\n fontFamily: 'inherit',\n flowchart: { useMaxWidth: true, htmlLabels: false },\n });\n return mermaid.mermaidAPI.render(id, code);\n });\n renderQueue = result.catch(() => undefined);\n return result;\n}\n\nexport const MermaidRenderer: React.FC<{ code: string }> = ({ code }) => {\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!containerRef.current) return;\n containerRef.current.replaceChildren();\n if (!code.trim()) return;\n\n let cancelled = false;\n const render = async () => {\n try {\n const id = `mermaid-md-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;\n const { svg } = await renderMermaid(id, code);\n if (!cancelled && containerRef.current) {\n containerRef.current.innerHTML = svg;\n }\n } catch (err) {\n if (!cancelled && containerRef.current) {\n containerRef.current.textContent = String(err);\n }\n }\n };\n render();\n return () => { cancelled = true; };\n }, [code]);\n\n return <div ref={containerRef} className=\"rte-mermaid-container\" />;\n};\n\nconst MarkdownPreview: React.FC<{ content: string }> = ({ content }) => {\n return (\n <ReactMarkdown\n remarkPlugins={[remarkGfm, remarkMath]}\n rehypePlugins={[rehypeKatex]}\n components={{\n code({ className, children, ...props }) {\n const match = /language-(\\w+)/.exec(className || '');\n const lang = match?.[1];\n const text = String(children).replace(/\\n$/, '');\n\n if (lang === 'mermaid') {\n return <MermaidRenderer code={text} />;\n }\n\n if (lang) {\n return (\n <SyntaxHighlighter\n style={oneLight as Record<string, React.CSSProperties>}\n language={lang}\n PreTag=\"div\"\n customStyle={{\n borderRadius: '0.5rem',\n fontSize: '0.875em',\n padding: '1em',\n margin: '0.5em 0',\n }}\n >\n {text}\n </SyntaxHighlighter>\n );\n }\n return <code className={className} {...props}>{children}</code>;\n },\n }}\n >\n {content}\n </ReactMarkdown>\n );\n};\n\nconst MarkdownBlockView: React.FC<NodeViewProps> = ({\n node,\n editor,\n updateAttributes,\n selected,\n}) => {\n const editable = useNodeEditable(editor);\n const [isEditing, setIsEditing] = useState(false);\n const [localContent, setLocalContent] = useState(node.attrs.content || '');\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n setLocalContent(node.attrs.content || '');\n setIsEditing(false);\n }, [node.attrs.content, editable]);\n\n useEffect(() => {\n if (isEditing && textareaRef.current) {\n textareaRef.current.focus();\n adjustTextareaHeight(textareaRef.current);\n }\n }, [isEditing]);\n\n const adjustTextareaHeight = (el: HTMLTextAreaElement) => {\n el.style.height = 'auto';\n el.style.height = el.scrollHeight + 'px';\n };\n\n const handleChange = useCallback((e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setLocalContent(e.target.value);\n adjustTextareaHeight(e.target);\n }, []);\n\n const handleBlur = useCallback(() => {\n if (!editor.isDestroyed && editor.isEditable) updateAttributes({ content: localContent });\n setIsEditing(false);\n }, [editor, localContent, updateAttributes]);\n\n const handleKeyDown = useCallback((e: React.KeyboardEvent) => {\n if (e.key === 'Escape') {\n handleBlur();\n }\n }, [handleBlur]);\n\n const defaultContent = `# Markdown Block\n\nWrite your **markdown** here.\n\n\\`\\`\\`mermaid\ngraph LR\n A[Start] --> B[End]\n\\`\\`\\`\n`;\n\n const displayContent = localContent || defaultContent;\n\n return (\n <NodeViewWrapper contentEditable={false} className={`rte-markdown-block ${selected ? 'rte-markdown-block--selected' : ''}`}>\n <div className=\"rte-markdown-block__header\">\n <span className=\"rte-markdown-block__label\">Markdown</span>\n <button\n type=\"button\"\n className={`rte-markdown-block__toggle ${isEditing ? 'rte-markdown-block__toggle--active' : ''}`}\n disabled={!editable}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n if (editor.isDestroyed || !editor.isEditable) return;\n if (isEditing) {\n updateAttributes({ content: localContent });\n }\n setIsEditing(!isEditing);\n }}\n title={isEditing ? 'Preview' : 'Edit'}\n >\n {isEditing ? (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n ) : (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7\" />\n <path d=\"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z\" />\n </svg>\n )}\n <span>{isEditing ? 'Preview' : 'Edit'}</span>\n </button>\n </div>\n\n <div className=\"rte-markdown-block__body\">\n {isEditing && editable ? (\n <textarea\n ref={textareaRef}\n className=\"rte-markdown-block__editor\"\n value={localContent}\n onChange={handleChange}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n placeholder=\"Enter Markdown content...\"\n rows={5}\n />\n ) : (\n <div\n className=\"rte-markdown-block__preview prose\"\n onDoubleClick={() => { if (!editor.isDestroyed && editor.isEditable) setIsEditing(true); }}\n >\n {displayContent.trim() ? (\n <MarkdownPreview content={displayContent} />\n ) : (\n <p className=\"rte-markdown-block__placeholder\">\n Double-click to edit Markdown content...\n </p>\n )}\n </div>\n )}\n </div>\n </NodeViewWrapper>\n );\n};\n\nexport const MarkdownBlockExtension = Node.create({\n name: 'markdownBlock',\n group: 'block',\n atom: true,\n draggable: true,\n\n addAttributes() {\n return {\n content: {\n default: '',\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'div[data-type=\"markdown-block\"]',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', mergeAttributes(HTMLAttributes, { 'data-type': 'markdown-block' })];\n },\n\n addNodeView() {\n return ReactNodeViewRenderer(MarkdownBlockView);\n },\n});\n\nexport default MarkdownBlockExtension;\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,EAAgB,GAAiC;CAC/D,IAAM,IAAY,GAAa,OAE7B,EAAO,GAAG,UAAU,CAAM,GAC1B,EA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,YAAY,OAAa,CAAA,CACtC;GACL,CAAA,CAAA;EAEL,CAAA,GAAA,kBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,KAAa,IACZ,kBAAC,YAAD;IACE,KAAK;IACL,WAAU;IACV,OAAO;IACP,UAAU;IACV,QAAQ;IACR,WAAW;IACX,aAAY;IACZ,MAAM;GACP,CAAA,IAED,kBAAC,OAAD;IACE,WAAU;IACV,qBAAqB;KAAE,AAAI,CAAC,EAAO,eAAe,EAAO,cAAY,EAAa,EAAI;IAAG;IAExF,UAAA,EAAe,KAAK,IACnB,kBAAC,GAAD,EAAiB,SAAS,EAAiB,CAAA,IAE3C,kBAAC,KAAD;KAAG,WAAU;KAAkC,UAAA;IAE5C,CAAA;GAEF,CAAA;EAEJ,CAAA,CACU;;AAErB,GAEa,IAAyB,EAAK,OAAO;CAChD,MAAM;CACN,OAAO;CACP,MAAM;CACN,WAAW;CAEX,gBAAgB;EACd,OAAO,EACL,SAAS,EACP,SAAS,GACX,EACF;CACF;CAEA,YAAY;EACV,OAAO,CACL,EACE,KAAK,oCACP,CACF;CACF;CAEA,WAAW,EAAE,qBAAkB;EAC7B,OAAO,CAAC,OAAO,EAAgB,GAAgB,EAAE,aAAa,iBAAiB,CAAC,CAAC;CACnF;CAEA,cAAc;EACZ,OAAO,EAAsB,CAAiB;CAChD;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"MarkdownBlock.js","names":[],"sources":["../../../../../src/components/pro/RichTextEditor/extensions/MarkdownBlock.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef, useCallback, useSyncExternalStore } from 'react';\nimport { Node, mergeAttributes } from '@tiptap/react';\nimport { NodeViewWrapper, ReactNodeViewRenderer } from '@tiptap/react';\nimport type { NodeViewProps } from '@tiptap/react';\nimport ReactMarkdown from 'react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport rehypeKatex from 'rehype-katex';\n\nimport { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';\nimport { oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism';\nimport mermaid from 'mermaid';\nimport { normalizeLegacyMermaid } from './legacyMermaid';\nimport 'katex/dist/katex.min.css';\n\nexport function useNodeEditable(editor: NodeViewProps['editor']) {\n const subscribe = useCallback((notify: () => void) => {\n // setEditable emits update, not transaction, in Tiptap 3.\n editor.on('update', notify);\n editor.on('transaction', notify);\n editor.on('destroy', notify);\n return () => {\n editor.off('update', notify);\n editor.off('transaction', notify);\n editor.off('destroy', notify);\n };\n }, [editor]);\n return useSyncExternalStore(subscribe, () => !editor.isDestroyed && editor.isEditable, () => false);\n}\n\nlet renderQueue: Promise<unknown> = Promise.resolve();\n\nfunction renderMermaid(id: string, code: string) {\n const result = renderQueue.then(() => {\n // Capture strict config when rendering starts, not before Mermaid's global queue runs.\n mermaid.initialize({\n startOnLoad: false,\n theme: 'default',\n securityLevel: 'strict',\n suppressErrorRendering: true,\n fontFamily: 'inherit',\n flowchart: { useMaxWidth: true, htmlLabels: false },\n });\n return mermaid.mermaidAPI.render(id, code);\n });\n renderQueue = result.catch(() => undefined);\n return result;\n}\n\nexport const MermaidRenderer: React.FC<{ code: string }> = ({ code }) => {\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!containerRef.current) return;\n containerRef.current.replaceChildren();\n if (!code.trim()) return;\n\n let cancelled = false;\n const render = async () => {\n try {\n const id = `mermaid-md-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;\n const { svg } = await renderMermaid(id, normalizeLegacyMermaid(code));\n if (!cancelled && containerRef.current) {\n containerRef.current.innerHTML = svg;\n }\n } catch (err) {\n if (!cancelled && containerRef.current) {\n containerRef.current.textContent = String(err);\n }\n }\n };\n render();\n return () => { cancelled = true; };\n }, [code]);\n\n return <div ref={containerRef} className=\"rte-mermaid-container\" />;\n};\n\nconst MarkdownPreview: React.FC<{ content: string }> = ({ content }) => {\n return (\n <ReactMarkdown\n remarkPlugins={[remarkGfm, remarkMath]}\n rehypePlugins={[rehypeKatex]}\n components={{\n code({ className, children, ...props }) {\n const match = /language-(\\w+)/.exec(className || '');\n const lang = match?.[1];\n const text = String(children).replace(/\\n$/, '');\n\n if (lang === 'mermaid') {\n return <MermaidRenderer code={text} />;\n }\n\n if (lang) {\n return (\n <SyntaxHighlighter\n style={oneLight as Record<string, React.CSSProperties>}\n language={lang}\n PreTag=\"div\"\n customStyle={{\n borderRadius: '0.5rem',\n fontSize: '0.875em',\n padding: '1em',\n margin: '0.5em 0',\n }}\n >\n {text}\n </SyntaxHighlighter>\n );\n }\n return <code className={className} {...props}>{children}</code>;\n },\n }}\n >\n {content}\n </ReactMarkdown>\n );\n};\n\nconst MarkdownBlockView: React.FC<NodeViewProps> = ({\n node,\n editor,\n updateAttributes,\n selected,\n}) => {\n const editable = useNodeEditable(editor);\n const [isEditing, setIsEditing] = useState(false);\n const [localContent, setLocalContent] = useState(node.attrs.content || '');\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n setLocalContent(node.attrs.content || '');\n setIsEditing(false);\n }, [node.attrs.content, editable]);\n\n useEffect(() => {\n if (isEditing && textareaRef.current) {\n textareaRef.current.focus();\n adjustTextareaHeight(textareaRef.current);\n }\n }, [isEditing]);\n\n const adjustTextareaHeight = (el: HTMLTextAreaElement) => {\n el.style.height = 'auto';\n el.style.height = el.scrollHeight + 'px';\n };\n\n const handleChange = useCallback((e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setLocalContent(e.target.value);\n adjustTextareaHeight(e.target);\n }, []);\n\n const handleBlur = useCallback(() => {\n if (!editor.isDestroyed && editor.isEditable) updateAttributes({ content: localContent });\n setIsEditing(false);\n }, [editor, localContent, updateAttributes]);\n\n const handleKeyDown = useCallback((e: React.KeyboardEvent) => {\n if (e.key === 'Escape') {\n handleBlur();\n }\n }, [handleBlur]);\n\n const defaultContent = `# Markdown Block\n\nWrite your **markdown** here.\n\n\\`\\`\\`mermaid\ngraph LR\n A[Start] --> B[End]\n\\`\\`\\`\n`;\n\n const displayContent = localContent || defaultContent;\n\n return (\n <NodeViewWrapper contentEditable={false} className={`rte-markdown-block ${selected ? 'rte-markdown-block--selected' : ''}`}>\n <div className=\"rte-markdown-block__header\">\n <span className=\"rte-markdown-block__label\">Markdown</span>\n <button\n type=\"button\"\n className={`rte-markdown-block__toggle ${isEditing ? 'rte-markdown-block__toggle--active' : ''}`}\n disabled={!editable}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n if (editor.isDestroyed || !editor.isEditable) return;\n if (isEditing) {\n updateAttributes({ content: localContent });\n }\n setIsEditing(!isEditing);\n }}\n title={isEditing ? 'Preview' : 'Edit'}\n >\n {isEditing ? (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n ) : (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7\" />\n <path d=\"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z\" />\n </svg>\n )}\n <span>{isEditing ? 'Preview' : 'Edit'}</span>\n </button>\n </div>\n\n <div className=\"rte-markdown-block__body\">\n {isEditing && editable ? (\n <textarea\n ref={textareaRef}\n className=\"rte-markdown-block__editor\"\n value={localContent}\n onChange={handleChange}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n placeholder=\"Enter Markdown content...\"\n rows={5}\n />\n ) : (\n <div\n className=\"rte-markdown-block__preview prose\"\n onDoubleClick={() => { if (!editor.isDestroyed && editor.isEditable) setIsEditing(true); }}\n >\n {displayContent.trim() ? (\n <MarkdownPreview content={displayContent} />\n ) : (\n <p className=\"rte-markdown-block__placeholder\">\n Double-click to edit Markdown content...\n </p>\n )}\n </div>\n )}\n </div>\n </NodeViewWrapper>\n );\n};\n\nexport const MarkdownBlockExtension = Node.create({\n name: 'markdownBlock',\n group: 'block',\n atom: true,\n draggable: true,\n\n addAttributes() {\n return {\n content: {\n default: '',\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'div[data-type=\"markdown-block\"]',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', mergeAttributes(HTMLAttributes, { 'data-type': 'markdown-block' })];\n },\n\n addNodeView() {\n return ReactNodeViewRenderer(MarkdownBlockView);\n },\n});\n\nexport default MarkdownBlockExtension;\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAgB,EAAgB,GAAiC;CAC/D,IAAM,IAAY,GAAa,OAE7B,EAAO,GAAG,UAAU,CAAM,GAC1B,EAAO,GAAG,eAAe,CAAM,GAC/B,EAAO,GAAG,WAAW,CAAM,SACd;EAGX,AAFA,EAAO,IAAI,UAAU,CAAM,GAC3B,EAAO,IAAI,eAAe,CAAM,GAChC,EAAO,IAAI,WAAW,CAAM;CAC9B,IACC,CAAC,CAAM,CAAC;CACX,OAAO,EAAqB,SAAiB,CAAC,EAAO,eAAe,EAAO,kBAAkB,EAAK;AACpG;AAEA,IAAI,IAAgC,QAAQ,QAAQ;AAEpD,SAAS,EAAc,GAAY,GAAc;CAC/C,IAAM,IAAS,EAAY,YAEzB,EAAQ,WAAW;EACjB,aAAa;EACb,OAAO;EACP,eAAe;EACf,wBAAwB;EACxB,YAAY;EACZ,WAAW;GAAE,aAAa;GAAM,YAAY;EAAM;CACpD,CAAC,GACM,EAAQ,WAAW,OAAO,GAAI,CAAI,EAC1C;CAED,OADA,IAAc,EAAO,YAAY,KAAA,CAAS,GACnC;AACT;AAEA,IAAa,KAA+C,EAAE,cAAW;CACvE,IAAM,IAAe,EAAuB,IAAI;CAyBhD,OAvB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V,OAAO,CACL,EACE,KAAK,oCACP,CACF;CACF;CAEA,WAAW,EAAE,qBAAkB;EAC7B,OAAO,CAAC,OAAO,EAAgB,GAAgB,EAAE,aAAa,iBAAiB,CAAC,CAAC;CACnF;CAEA,cAAc;EACZ,OAAO,EAAsB,CAAiB;CAChD;AACF,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//#region src/components/pro/RichTextEditor/extensions/legacyMermaid.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return Array.from(e, (e) => /[\p{L}\p{N} ,.!?_-]/u.test(e) ? e : `#${e.codePointAt(0)};`).join("");
|
|
4
|
+
}
|
|
5
|
+
function t(t) {
|
|
6
|
+
let n = t.split(/\r?\n/), r = n[0].trim();
|
|
7
|
+
if (r !== "flow" && r !== "seq") return t;
|
|
8
|
+
let i = (e, t) => {
|
|
9
|
+
throw Error(`Legacy ${r}, line ${e + 1}: ${t}`);
|
|
10
|
+
}, a = n.map((e, t) => ({
|
|
11
|
+
value: e.trim(),
|
|
12
|
+
line: t
|
|
13
|
+
})).slice(1).filter(({ value: e }) => e && !e.startsWith("#"));
|
|
14
|
+
if (a.length || i(0, "Empty diagram"), r === "seq") {
|
|
15
|
+
let t = /* @__PURE__ */ new Map(), n = (e, n) => (e = e.trim(), (!e || /[\r\n:<>]/.test(e)) && i(n, "Invalid participant name"), t.has(e) || t.set(e, `p${t.size}`), t.get(e)), r = [], o = {
|
|
16
|
+
"->": "->>",
|
|
17
|
+
"-->": "-->>",
|
|
18
|
+
"->>": "->",
|
|
19
|
+
"-->>": "-->"
|
|
20
|
+
};
|
|
21
|
+
for (let { value: t, line: s } of a) {
|
|
22
|
+
let a = /^Note\s+(right of|left of|over)\s+([^:]+):\s*(.*)$/i.exec(t);
|
|
23
|
+
if (a) {
|
|
24
|
+
let t = a[1].toLowerCase(), o = a[2].split(",");
|
|
25
|
+
o.length > (t === "over" ? 2 : 1) && i(s, "Unsupported note participants"), r.push(`Note ${t} ${o.map((e) => n(e, s)).join(",")}: ${e(a[3])}`);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
let c = /^([^:<>]+?)(-->>|->>|-->|->)([^:<>]+):\s*(.*)$/.exec(t);
|
|
29
|
+
(!c || /[-]$/.test(c[1].trim())) && i(s, "Unsupported sequence statement or arrow"), r.push(`${n(c[1], s)}${o[c[2]]}${n(c[3], s)}: ${e(c[4])}`);
|
|
30
|
+
}
|
|
31
|
+
return [
|
|
32
|
+
"sequenceDiagram",
|
|
33
|
+
...Array.from(t, ([t, n]) => `participant ${n} as ${e(t)}`),
|
|
34
|
+
...r
|
|
35
|
+
].join("\n");
|
|
36
|
+
}
|
|
37
|
+
let o = /* @__PURE__ */ new Map(), s = [], c = [], l = {
|
|
38
|
+
start: ["([", "])"],
|
|
39
|
+
end: ["([", "])"],
|
|
40
|
+
operation: ["[", "]"],
|
|
41
|
+
condition: ["{", "}"],
|
|
42
|
+
inputoutput: ["[/", "/]"],
|
|
43
|
+
subroutine: ["[[", "]]"]
|
|
44
|
+
};
|
|
45
|
+
for (let { value: t, line: n } of a) {
|
|
46
|
+
if (!t.includes("=>")) continue;
|
|
47
|
+
let r = /^([A-Za-z_][\w]*)=>([a-z]+)(?::\s*(.*))?$/.exec(t);
|
|
48
|
+
(!r || !Object.hasOwn(l, r[2])) && i(n, "Unsupported node declaration/type");
|
|
49
|
+
let [, a, c, u] = r;
|
|
50
|
+
o.has(a) && i(n, `Duplicate node: ${a}`), u && /\||:>/.test(u) && i(n, "Node styles and links are unsupported");
|
|
51
|
+
let d = `n${o.size}`;
|
|
52
|
+
o.set(a, {
|
|
53
|
+
id: d,
|
|
54
|
+
type: c
|
|
55
|
+
});
|
|
56
|
+
let [f, p] = l[c];
|
|
57
|
+
s.push(`${d}${f}"${e(u ?? c)}"${p}`);
|
|
58
|
+
}
|
|
59
|
+
let u, d = {
|
|
60
|
+
right: "LR",
|
|
61
|
+
left: "RL",
|
|
62
|
+
top: "BT",
|
|
63
|
+
bottom: "TD"
|
|
64
|
+
};
|
|
65
|
+
for (let { value: e, line: t } of a) {
|
|
66
|
+
if (e.includes("=>")) continue;
|
|
67
|
+
let n = e.split("->");
|
|
68
|
+
n.length < 2 && i(t, "Unsupported flow statement");
|
|
69
|
+
let r = n.map((e) => {
|
|
70
|
+
let n = /^\s*([A-Za-z_][\w]*)(?:\(([^()]+)\))?\s*$/.exec(e);
|
|
71
|
+
return (!n || !o.has(n[1])) && i(t, "Invalid or undefined node reference"), {
|
|
72
|
+
node: o.get(n[1]),
|
|
73
|
+
options: n[2]?.split(",").map((e) => e.trim()) ?? []
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
for (let e = 0; e < r.length; e++) {
|
|
77
|
+
let { node: n, options: a } = r[e];
|
|
78
|
+
if (e === r.length - 1) {
|
|
79
|
+
a.length && i(t, "Options on a terminal reference are unsupported");
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
let o, s;
|
|
83
|
+
for (let e of a) (e === "yes" || e === "no") && n.type === "condition" && !o ? o = e : Object.hasOwn(d, e) && !s ? s = d[e] : i(t, `Unsupported branch/direction: ${e}`);
|
|
84
|
+
s && (u && u !== s && i(t, "Mixed edge directions cannot be represented reliably"), u = s), c.push(`${n.id} -->${o ? `|${o}|` : ""} ${r[e + 1].node.id}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return o.size || i(0, "No node declarations"), [
|
|
88
|
+
`flowchart ${u ?? "TD"}`,
|
|
89
|
+
...s,
|
|
90
|
+
...c
|
|
91
|
+
].join("\n");
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { t as normalizeLegacyMermaid };
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=legacyMermaid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacyMermaid.js","names":[],"sources":["../../../../../src/components/pro/RichTextEditor/extensions/legacyMermaid.ts"],"sourcesContent":["// Encode user text before embedding it in Mermaid syntax (including entity-like input).\nfunction text(value: string): string {\n return Array.from(value, char => /[\\p{L}\\p{N} ,.!?_-]/u.test(char)\n ? char : `#${char.codePointAt(0)};`).join('');\n}\n\n/** Convert only explicit legacy headers. Unsupported syntax fails rather than changing meaning. */\nexport function normalizeLegacyMermaid(source: string): string {\n const lines = source.split(/\\r?\\n/);\n const kind = lines[0].trim();\n if (kind !== 'flow' && kind !== 'seq') return source;\n const fail = (line: number, reason: string): never => {\n throw new Error(`Legacy ${kind}, line ${line + 1}: ${reason}`);\n };\n const body = lines.map((value, line) => ({ value: value.trim(), line }))\n .slice(1).filter(({ value }) => value && !value.startsWith('#'));\n if (!body.length) fail(0, 'Empty diagram');\n\n if (kind === 'seq') {\n const actors = new Map<string, string>();\n const actor = (name: string, line: number) => {\n name = name.trim();\n if (!name || /[\\r\\n:<>]/.test(name)) fail(line, 'Invalid participant name');\n if (!actors.has(name)) actors.set(name, `p${actors.size}`);\n return actors.get(name)!;\n };\n const output: string[] = [];\n const arrows: Record<string, string> = { '->': '->>', '-->': '-->>', '->>': '->', '-->>': '-->' };\n for (const { value, line } of body) {\n const note = /^Note\\s+(right of|left of|over)\\s+([^:]+):\\s*(.*)$/i.exec(value);\n if (note) {\n const placement = note[1].toLowerCase();\n const names = note[2].split(',');\n if (names.length > (placement === 'over' ? 2 : 1)) fail(line, 'Unsupported note participants');\n output.push(`Note ${placement} ${names.map(name => actor(name, line)).join(',')}: ${text(note[3])}`);\n continue;\n }\n const message = /^([^:<>]+?)(-->>|->>|-->|->)([^:<>]+):\\s*(.*)$/.exec(value);\n if (!message || /[-]$/.test(message[1].trim())) fail(line, 'Unsupported sequence statement or arrow');\n output.push(`${actor(message![1], line)}${arrows[message![2]]}${actor(message![3], line)}: ${text(message![4])}`);\n }\n return ['sequenceDiagram', ...Array.from(actors, ([name, id]) => `participant ${id} as ${text(name)}`), ...output].join('\\n');\n }\n\n const nodes = new Map<string, { id: string; type: string }>();\n const declarations: string[] = [];\n const edges: string[] = [];\n const shapes: Record<string, [string, string]> = {\n start: ['([', '])'], end: ['([', '])'], operation: ['[', ']'],\n condition: ['{', '}'], inputoutput: ['[/', '/]'], subroutine: ['[[', ']]'],\n };\n for (const { value, line } of body) {\n if (!value.includes('=>')) continue;\n const match = /^([A-Za-z_][\\w]*)=>([a-z]+)(?::\\s*(.*))?$/.exec(value);\n if (!match || !Object.hasOwn(shapes, match[2])) fail(line, 'Unsupported node declaration/type');\n const [, name, type, label] = match!;\n if (nodes.has(name)) fail(line, `Duplicate node: ${name}`);\n // flowchart.js uses these as state/link metadata, not literal label text.\n if (label && /\\||:>/.test(label)) fail(line, 'Node styles and links are unsupported');\n const id = `n${nodes.size}`;\n nodes.set(name, { id, type });\n const [open, close] = shapes[type];\n declarations.push(`${id}${open}\"${text(label ?? type)}\"${close}`);\n }\n let direction: string | undefined;\n const directions: Record<string, string> = { right: 'LR', left: 'RL', top: 'BT', bottom: 'TD' };\n for (const { value, line } of body) {\n if (value.includes('=>')) continue;\n const parts = value.split('->');\n if (parts.length < 2) fail(line, 'Unsupported flow statement');\n const refs = parts.map(part => {\n const match = /^\\s*([A-Za-z_][\\w]*)(?:\\(([^()]+)\\))?\\s*$/.exec(part);\n if (!match || !nodes.has(match[1])) fail(line, 'Invalid or undefined node reference');\n return { node: nodes.get(match![1])!, options: match![2]?.split(',').map(option => option.trim()) ?? [] };\n });\n for (let i = 0; i < refs.length; i++) {\n const { node, options } = refs[i];\n if (i === refs.length - 1) {\n if (options.length) fail(line, 'Options on a terminal reference are unsupported');\n break;\n }\n let branch: string | undefined;\n let hint: string | undefined;\n for (const option of options) {\n if ((option === 'yes' || option === 'no') && node.type === 'condition' && !branch) branch = option;\n else if (Object.hasOwn(directions, option) && !hint) hint = directions[option];\n else fail(line, `Unsupported branch/direction: ${option}`);\n }\n if (hint) {\n if (direction && direction !== hint) fail(line, 'Mixed edge directions cannot be represented reliably');\n direction = hint;\n }\n edges.push(`${node.id} -->${branch ? `|${branch}|` : ''} ${refs[i + 1].node.id}`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