-
Notifications
You must be signed in to change notification settings - Fork 91
gw-rich-text-html-fields.php
: Added support to switch between visual and text mode.
#1058
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
gw-rich-text-html-fields.php
: Added support to switch between visual and text mode.
#1058
Conversation
…l and text mode.
WalkthroughThe pull request updates the JavaScript functionality related to the TinyMCE editor within the Gravity Forms plugin. The changes refactor the condition for fetching the editor ID by storing it in a variable and add event listeners for toggling between visual and text modes. Additionally, the comment section has been updated to remove a todo item and instead highlight support for inserting images. The modifications primarily streamline the mode-switching logic and enhance the editor's interactivity. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant B as Mode Switch Button
participant L as JS Listener
participant S as switchEditors.go
participant E as TinyMCE Editor
U->>B: Click mode switch button
B->>L: Dispatch click event
L->>L: Determine current mode and get editorId
L->>S: Invoke switchEditors.go(editorId, mode)
S->>E: Execute mode switch
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
gravity-forms/gw-rich-text-html-fields.php (1)
73-79
: Looks good: Mode switching implementationThe implementation successfully adds the ability to switch between visual and text modes in the editor. The event listeners are properly attached to the mode switch buttons, and the code correctly determines which mode to activate.
Consider adding a simple error check to ensure
window.switchEditors
exists before calling it:// Switch to visual/text mode. jQuery(`#wp-${editorId}-wrap .switch-tmce, #wp-${editorId}-wrap .switch-html`).on('click', function() { var mode = jQuery(this).hasClass('switch-tmce') ? 'tmce' : 'html'; + if (typeof window.switchEditors !== 'undefined') { window.switchEditors.go(editorId, mode); + } else { + console.error('switchEditors not available'); + } });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
gravity-forms/gw-rich-text-html-fields.php
(2 hunks)
🔇 Additional comments (2)
gravity-forms/gw-rich-text-html-fields.php (2)
12-12
: Comment updated to reflect implemented featureThe TODO comment has been updated to remove the item about switching to text mode (which is now implemented) and focuses on image insertion support instead. Good documentation maintenance!
70-71
: Good refactoring of editor IDStoring the editor ID in a variable improves code readability and maintainability. This makes the code cleaner while maintaining the same functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/2882543004/79740
Summary
This PR will allow switching to text & visual mode in editor.