Skip to content
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

chore: rich-text组件配置更新时,对应富文本编辑器也更新配置 #8608

Merged
merged 4 commits into from
Nov 16, 2023

Conversation

sqzhou
Copy link
Collaborator

@sqzhou sqzhou commented Nov 3, 2023

What

🤖 Generated by Copilot at 1da043e

This pull request enhances the functionality and performance of the RichText and Tinymce components in amis-ui and amis-core by improving their prop reactivity, editor initialization, and lifecycle management. It also adds some debugging and utility code.

🤖 Generated by Copilot at 1da043e

To make RichText more reactive
We use anyChanged detective
And recreate the editor
With new config and better
Lifecycle management directive

Why

How

🤖 Generated by Copilot at 1da043e

  • Import anyChanged function from amis-core to compare props in componentDidUpdate methods of FroalaEditorComponent and RichTextControl (link, link, link)
  • Refactor componentDidMount method of TinymceEditorComponent to extract editor initialization logic into initTiny method and use autobind decorator (link)
  • Add componentDidUpdate and componentWillUnmount methods to TinymceEditorComponent to handle dynamic changes in config prop and editor removal (link)
  • Remove unused FormBaseControl import from InputRichText.tsx (link)
  • Move editor config initialization from constructor to getConfig method of RichTextControl and store config in state (link, link, link)
  • Add componentDidUpdate method to RichTextControl to update state config when props change (link)
  • Pass state config to FroalaEditorComponent or TinymceEditorComponent instead of instance property (link)
  • Add detectProps option to FormItem decorator of RichTextControlRenderer to trigger re-render when props change (link)
  • Modify componentDidUpdate method of FroalaEditorComponent to destroy and recreate editor instance when config prop changes (link)
  • Add console log statement for debugging in FroalaEditorComponent (link)

@github-actions github-actions bot added the fix label Nov 3, 2023
Copy link

github-actions bot commented Nov 3, 2023

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

@lurunze1226 lurunze1226 changed the title fix: rich-text组件配置更新时,对应富文本编辑器也更新配置 chore: rich-text组件配置更新时,对应富文本编辑器也更新配置 Nov 16, 2023
@lurunze1226 lurunze1226 merged commit e576aa5 into baidu:master Nov 16, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants