Skip to content

Commit

Permalink
Merge branch '752-wikilinks-in-simplest-form-works-but-wikilinks-with…
Browse files Browse the repository at this point in the history
…-custom-text-dont'
  • Loading branch information
RafaelGB committed Jan 16, 2023
2 parents 73662e4 + 26e5b9b commit 2ef9bee
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/cdm/FolderModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export interface DatabaseHeaderProps {
export type RelationshipProps = {
value: Literal,
backgroundColor: string
view: DatabaseView,
}

export type RowTemplateOption = {
Expand Down
25 changes: 19 additions & 6 deletions src/components/RelationShip.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import React from "react";
import React, { useEffect, useRef } from "react";
import { RelationshipProps } from "cdm/FolderModel";
import { c } from "helpers/StylesHelper";
import { MarkdownService } from "services/MarkdownRenderService";

export default function Relationship(relationShipProps: RelationshipProps) {
const { value, backgroundColor } = relationShipProps;
const { value, backgroundColor, view } = relationShipProps;
const ref = useRef<HTMLDivElement>(null);

useEffect(() => {
if (ref.current !== null) {
MarkdownService.renderStringAsMarkdown(
view,
value?.toString(),
ref.current,
3
);
}
}, [value]);

return (
<span
<div
className={c("relationship")}
ref={ref}
style={{
backgroundColor: backgroundColor,
}}
>
{value && value.toString()}
</span>
/>
);
}
8 changes: 6 additions & 2 deletions src/components/cellTypes/SelectCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { InputType } from "helpers/Constants";
const SelectCell = (popperProps: CellComponentProps) => {
const { defaultCell } = popperProps;
const { row, column, table } = defaultCell;
const { tableState } = table.options.meta;
const { tableState, view } = table.options.meta;
const tableColumn = column.columnDef as TableColumn;
const dataActions = tableState.data((state) => state.actions);

Expand Down Expand Up @@ -153,7 +153,11 @@ const SelectCell = (popperProps: CellComponentProps) => {
tabIndex={0}
>
{cellValue ? (
<Relationship value={cellValue} backgroundColor={getColor()} />
<Relationship
value={cellValue}
backgroundColor={getColor()}
view={view}
/>
) : null}
</div>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/components/cellTypes/TagsCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { satinizedColumnOption } from "helpers/FileManagement";
const TagsCell = (tagsProps: CellComponentProps) => {
const { defaultCell } = tagsProps;
const { row, column, table } = defaultCell;
const { tableState } = table.options.meta;
const { tableState, view } = table.options.meta;
const tableColumn = column.columnDef as TableColumn;
const columnsInfo = tableState.columns((state) => state.info);
const configInfo = tableState.configState((state) => state.info);
Expand Down Expand Up @@ -166,6 +166,7 @@ const TagsCell = (tagsProps: CellComponentProps) => {
key={`tags-${row.index}-${tableColumn.key}-${tag}`}
value={tag.toString()}
backgroundColor={getColor(tag)}
view={view}
/>
</div>
))
Expand Down
1 change: 1 addition & 0 deletions src/components/contextMenu/CellContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export default function CellContextMenu(
<Relationship
value={index}
backgroundColor={StyleVariables.BACKGROUND_PRIMARY}
view={view}
/>
)}
</div>
Expand Down

0 comments on commit 2ef9bee

Please sign in to comment.