Add Raw JSON Form Field Input (#9078)

- Implemented the `renderText` method for `VariableTag`. This method
returns the `variable` attribute of the node, i.e. `{{test}}`.
- Used the `editor.getText()` function to simply get the textual
representation of the field without relying on `editor.getJSON()` and
`parseEditorContent`.
- Implemented the RawJSON form field, which is heavily based on the
`TextVariableEditor` component.
- This component is inspired from the `RawJsonFieldInput` field,
especially the JSON validation.

Closes https://github.com/twentyhq/private-issues/issues/180
This commit is contained in:
Baptiste Devessier
2024-12-18 11:42:12 +01:00
committed by GitHub
parent 8623585106
commit deb37edd7c
5 changed files with 344 additions and 1 deletions

View File

@ -1,7 +1,7 @@
import { isNonEmptyString } from '@sniptt/guards';
import { Editor } from '@tiptap/react';
const CAPTURE_VARIABLE_TAG_REGEX = /({{[^{}]+}})/;
export const CAPTURE_VARIABLE_TAG_REGEX = /({{[^{}]+}})/;
export const initializeEditorContent = (editor: Editor, content: string) => {
const lines = content.split(/\n/);

View File

@ -41,6 +41,10 @@ export const VariableTag = Node.create({
];
},
renderText: ({ node }) => {
return node.attrs.variable;
},
addCommands: () => ({
insertVariableTag:
(variableName: string) =>