Skip to content

Commit

Permalink
Show text on table cell
Browse files Browse the repository at this point in the history
  • Loading branch information
juan871003 committed Feb 19, 2025
1 parent fc9e6bd commit f86a9c5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { EntityField } from '../../../utils';
import { MenuBar } from './menu-bar';
import styles from './styles.module.css';

const extensions = [
export const extensions = [
StarterKit.configure({
bulletList: {
keepMarks: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export const HeaderOptions = (props: SectionProps) => {
{show.h1 ? (
<button
onClick={handleHeadingClick(1)}
className={
editor.isActive('paragraph') || editor.isActive('heading') ? styles.isActive : ''
}
className={editor.isActive('heading') ? styles.isActive : ''}
>
<EditorHIcon />
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const ListOptions = (props: SectionProps) => {
return [undefined, []] as const;
}

const optionButtons = Object.values(buttons).filter((button) => button && button != mainButton);
const optionButtons = Object.values(buttons).filter((button) => button);

return [mainButton, optionButtons] as const;
}, [options, editor]);
Expand Down
16 changes: 14 additions & 2 deletions src/packages/admin-ui-components/src/entity-list/columns.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { CellContext, createColumnHelper } from '@tanstack/react-table';
import { customFields } from 'virtual:graphweaver-user-supplied-custom-fields';
import { Link } from 'react-router-dom';

import { Entity, EntityField, routeFor } from '../utils';
import { generateText, generateJSON } from '@tiptap/react';
import { DetailPanelInputComponentOption, Entity, EntityField, routeFor } from '../utils';
import { cells } from '../table/cells';
import { Checkbox } from '../checkbox';
import { extensions } from '../detail-panel/fields';

const columnHelper = createColumnHelper<any>();

Expand Down Expand Up @@ -45,6 +46,17 @@ const cellForType = (field: EntityField, value: any, entityByType: (type: string
return value.join(', ');
}

if (field.detailPanelInputComponent?.name === DetailPanelInputComponentOption.MARKDOWN) {
if (!value) return null;
try {
const json = generateJSON(value, extensions);
return <div>{generateText(json, extensions)}</div>;
} catch (e) {
console.error(e);
return <div>{value}</div>;
}
}

// Ok, all we're left with is a simple value
return value;
};
Expand Down

0 comments on commit f86a9c5

Please sign in to comment.