New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
document
filed not support rich text using text
type in database?
#8768
Comments
Current I create a custom field like this(read the code and keystone 5 's doc) to solve it, But it has a bug rich text body is empty when creating it only work when updating import React from 'react';
import { FieldProps } from '@keystone-6/core/types';
import { FieldContainer, FieldLabel } from '@keystone-ui/fields';
import { controller } from '@keystone-6/core/fields/types/json/views';
import { useState } from 'react';
import { Editor } from '@tinymce/tinymce-react';
import { TINYMCE_API_KEY } from './config';
export const Field = ({ field, value, onChange, autoFocus }: FieldProps<typeof controller>) => {
const onEditorChange = (html: string) => {
if (onChange) {
let keystonOnChangeValue = value;
keystonOnChangeValue.inner.value = html;
onChange(keystonOnChangeValue);
setHtmlValue(html);
}
};
const apiKey = TINYMCE_API_KEY;
const [htmlValue, setHtmlValue] = useState(value.inner.value);
return (
<FieldContainer>
<FieldLabel>{field.label}</FieldLabel>
<Editor
apiKey={apiKey}
plugins="wordcount image link"
value={htmlValue}
onEditorChange={(html) => {
onEditorChange(html);
}}
/>
</FieldContainer>
);
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am using text type store rich text in db,This is the exist
prisma.schema
in another project(Article.body is the column to store rich text)And this is generate by
prisma.ts
in keystoneand the schema.ts
The text was updated successfully, but these errors were encountered: