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:
committed by
GitHub
parent
8623585106
commit
deb37edd7c
@ -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/);
|
||||
|
||||
@ -41,6 +41,10 @@ export const VariableTag = Node.create({
|
||||
];
|
||||
},
|
||||
|
||||
renderText: ({ node }) => {
|
||||
return node.attrs.variable;
|
||||
},
|
||||
|
||||
addCommands: () => ({
|
||||
insertVariableTag:
|
||||
(variableName: string) =>
|
||||
|
||||
Reference in New Issue
Block a user