Skip to content

Commit

Permalink
Adds category label to the variabe if the selected variable belongs t…
Browse files Browse the repository at this point in the history
…o a category. (#1249)

* Added yalc and yalc.lock to the gitignore.

* Added tooltip around the variable when the content is trimmed.

* Updated the variable label to include the category label when available.
  • Loading branch information
deepakjosp authored Oct 22, 2024
1 parent f97d063 commit 7d618a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
.env.test.local
.env.production.local

# Ignore yalc generated files
yalc.lock
/.yalc

npm-debug.log*
yarn-debug.log*
yarn-error.log*
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NodeViewWrapper } from "@tiptap/react";
import { Tooltip } from "neetoui";

import { MAX_VARIABLE_NAME_DISPLAY_LENGTH } from "./constants";

Expand All @@ -16,8 +17,10 @@ const VariableComponent = ({ node, extension }) => {
data-variable=""
>
{extension.options.charOpen}
{variableName?.substr(0, MAX_VARIABLE_NAME_DISPLAY_LENGTH)?.trim()}
{shouldTruncate && "..."}
<Tooltip content={variableName} disabled={!shouldTruncate} position="top">
{variableName?.substr(0, MAX_VARIABLE_NAME_DISPLAY_LENGTH)?.trim()}
{shouldTruncate && "..."}
</Tooltip>
{extension.options.charClose}
</NodeViewWrapper>
);
Expand Down
12 changes: 10 additions & 2 deletions src/components/Editor/Menu/Fixed/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,17 @@ const Fixed = ({
options.includes(EDITOR_OPTIONS.VIDEO_UPLOAD);

const handleVariableClick = item => {
const { category, key, label } = item;
const { category, categoryLabel, key, label } = item;
const variableName = category ? `${category}.${key}` : key;
editor.chain().focus().setVariable({ id: variableName, label }).run();
const variableLabel = category
? `${categoryLabel || category}:${label}`
: label;

editor
.chain()
.focus()
.setVariable({ id: variableName, label: variableLabel })
.run();
};

return (
Expand Down

0 comments on commit 7d618a1

Please sign in to comment.