|
|
@@ -8,6 +8,8 @@ import { useWorkspace } from '@/contexts/WorkspaceContext'
|
|
|
import { usePermissions } from '@/hooks/usePermissions'
|
|
|
import Button from '@/components/Button'
|
|
|
import ConfirmModal from '@/components/ConfirmModal'
|
|
|
+import MarkdownEditor from '@/components/MarkdownEditor'
|
|
|
+import MarkdownRenderer from '@/components/MarkdownRenderer'
|
|
|
import type { DocumentListConfig, Document } from '@/types'
|
|
|
|
|
|
interface ViewField {
|
|
|
@@ -17,6 +19,7 @@ interface ViewField {
|
|
|
required?: boolean
|
|
|
options?: Array<{ value: string; label: string }> | string[]
|
|
|
widget?: string // Widget type override (e.g., 'textarea' for text fields)
|
|
|
+ markdown?: boolean // Enable markdown editing/rendering for textarea fields
|
|
|
}
|
|
|
|
|
|
interface View {
|
|
|
@@ -400,6 +403,20 @@ export function DocumentListRenderer({
|
|
|
|
|
|
// Check for textarea - either by type or by widget override
|
|
|
if (field.type === 'textarea' || field.type === 'text-long' || field.widget === 'textarea') {
|
|
|
+ // Use markdown editor if markdown is enabled (not in compact/inline mode)
|
|
|
+ if (field.markdown && !compact) {
|
|
|
+ return (
|
|
|
+ <div key={field.name}>
|
|
|
+ <MarkdownEditor
|
|
|
+ label={field.label}
|
|
|
+ value={String(value)}
|
|
|
+ onChange={(val) => setFormData(prev => ({ ...prev, [field.name]: val }))}
|
|
|
+ required={field.required}
|
|
|
+ height={150}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
return (
|
|
|
<div key={field.name} className={compact ? "flex-1 min-w-[200px]" : ""}>
|
|
|
{!compact && (
|
|
|
@@ -608,11 +625,23 @@ export function DocumentListRenderer({
|
|
|
renderInlineEditRow(doc)
|
|
|
) : (
|
|
|
<tr key={doc.id} className="hover:bg-gray-50">
|
|
|
- {visibleColumns.map((colName) => (
|
|
|
- <td key={colName} className="whitespace-nowrap px-4 py-3 text-sm text-gray-900">
|
|
|
- {formatCellValue(getColumnValue(doc, colName), fields.find(f => f.name === colName)?.type)}
|
|
|
- </td>
|
|
|
- ))}
|
|
|
+ {visibleColumns.map((colName) => {
|
|
|
+ const field = fields.find(f => f.name === colName)
|
|
|
+ const value = getColumnValue(doc, colName)
|
|
|
+ // For markdown fields, render as compact markdown
|
|
|
+ if (field?.markdown && value) {
|
|
|
+ return (
|
|
|
+ <td key={colName} className="max-w-xs px-4 py-3 text-sm text-gray-900">
|
|
|
+ <MarkdownRenderer content={String(value)} compact />
|
|
|
+ </td>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ <td key={colName} className="whitespace-nowrap px-4 py-3 text-sm text-gray-900">
|
|
|
+ {formatCellValue(value, field?.type)}
|
|
|
+ </td>
|
|
|
+ )
|
|
|
+ })}
|
|
|
<td className="whitespace-nowrap px-4 py-3 text-right text-sm">
|
|
|
<div className="flex justify-end gap-2">
|
|
|
{showEditButton && (
|
|
|
@@ -724,6 +753,17 @@ export function DocumentListRenderer({
|
|
|
const bodyField = fields.find(f => f.name === colName)
|
|
|
const val = getColumnValue(doc, colName)
|
|
|
if (val === null || val === undefined) return null
|
|
|
+ // Render markdown fields with full rendering
|
|
|
+ if (bodyField?.markdown) {
|
|
|
+ return (
|
|
|
+ <div key={colName} className="text-sm">
|
|
|
+ <span className="text-gray-500">{bodyField?.label || colName}:</span>
|
|
|
+ <div className="mt-1">
|
|
|
+ <MarkdownRenderer content={String(val)} className="text-gray-900" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
return (
|
|
|
<div key={colName} className="flex items-center text-sm">
|
|
|
<span className="text-gray-500 mr-2">{bodyField?.label || colName}:</span>
|
|
|
@@ -838,6 +878,17 @@ export function DocumentListRenderer({
|
|
|
const bodyField = fields.find(f => f.name === colName)
|
|
|
const val = getColumnValue(doc, colName)
|
|
|
if (val === null || val === undefined) return null
|
|
|
+ // Render markdown fields with compact rendering in kanban
|
|
|
+ if (bodyField?.markdown) {
|
|
|
+ return (
|
|
|
+ <div key={colName} className="text-xs text-gray-500">
|
|
|
+ <span>{bodyField?.label || colName}: </span>
|
|
|
+ <span className="text-gray-700">
|
|
|
+ <MarkdownRenderer content={String(val)} compact />
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
return (
|
|
|
<div key={colName} className="text-xs text-gray-500">
|
|
|
<span>{bodyField?.label || colName}: </span>
|