-
Notifications
You must be signed in to change notification settings - Fork 118
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
RichTextEditor value and onChange props #1236
Comments
Marking issue as stale since there was no activity for 30 days |
I've also been looking into this - I wanted to add a character counter below to allow my team to keep track of character count without being strictly limited by a max or min. It's not a big feature, but it's a small quality of life improvement that would allow them to avoid jumping from character-counting tool to contentful. |
@vitalbone, I found something which I hope is helpful - at least concerning the While I couldn't get the The
I hope this helps! :) |
Marking issue as stale since there was no activity for 30 days |
Hi, I also tried to dig into the internals and found that Anecdotally, when removed the wrapping I would appreciate some guidance on the issue. |
Update: |
Marking issue as stale since there was no activity for 30 days |
Would be nice to get this operational, any update here?
|
Marking issue as stale since there was no activity for 30 days |
is there any updates on this? |
Hey folks, sorry for the lack of engagement here. Field editors are designed to work exclusively with the App SDK, specifically the FieldSDK. Meaning, all field editors read their values and write changes back via the SDK. If you want to update a field value, you need do that via the appropriate SDK method. Otherwise onChange may not trigger or would have an undefined behavior. e.g. This is a tiny field app that renders a text area and the contentful rich text editor. It then syncs all writes to the text area to the Rich text editor as a paragraph. It's a dumb app but gets the idea across. You can use Demorich-text-editor-updates.mp4Codeimport { FieldAppSDK } from "@contentful/app-sdk";
import { Flex, Textarea, Heading } from "@contentful/f36-components";
import { useAutoResizer, useSDK } from "@contentful/react-apps-toolkit";
import { RichTextEditor } from "@contentful/field-editor-rich-text";
import { useEffect, useState } from "react";
const Field = () => {
useAutoResizer();
const sdk = useSDK<FieldAppSDK>();
const [textAreaValue, setTextAreaValue] = useState<string>("");
useEffect(() => {
sdk.field.setValue({
nodeType: "document",
data: {},
content: [
{
nodeType: "paragraph",
data: {},
content: [
{
nodeType: "text",
value: textAreaValue,
marks: [],
data: {},
},
],
},
],
});
}, [textAreaValue]);
return (
<Flex flexDirection="column">
<Heading> Custom Editor</Heading>
<Flex marginBottom="spacingS" marginTop="spacingS">
<Textarea
onChange={(e) => setTextAreaValue(e.target.value)}
placeholder="Type here to change the rich text editor"
>
{textAreaValue}
</Textarea>
</Flex>
<RichTextEditor sdk={sdk} isInitiallyDisabled={false} />
</Flex>
);
};
export default Field; I hope that helps. |
Looks like I misunderstood the issue, sorry. If the issue is that If you are stuck in an older version, using |
Hi, I've been trying to understand if it's possible to add an initial value and change the value of the
RichTextEditor
field.There doesn't seem to be any documentation so I'm not sure how it's supposed to function. Pardon my naiveté but I was hoping it would be as simple as the following however this doesn't work.
Could you please provide an example of the correct way to add an initial value in the text in the editor, as well as the mechanism to update the text in the editor. Thank you.
The text was updated successfully, but these errors were encountered: