-
Notifications
You must be signed in to change notification settings - Fork 38
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
fix: fix line-height invalid close #154 #155
Conversation
WalkthroughThe pull request introduces line height configuration to the Fluent Editor's toolbar. By adding a new line height option to the Changes
Sequence DiagramsequenceDiagram
participant User
participant Toolbar
participant FluentEditor
participant Quill
User->>Toolbar: Select line height
Toolbar->>FluentEditor: Trigger lineheight handler
FluentEditor->>Quill: format('line-height', value)
Quill-->>User: Update text line spacing
Possibly related PRs
Suggested labels
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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: 1
🧹 Nitpick comments (1)
packages/docs/fluent-editor/demos/custom-toolbar.vue (1)
23-28
: Consider UX implications of extreme line-height valuesWhile the line-height configuration is well-structured, the higher values (3, 4, 5) might lead to poor readability. Consider:
- Limiting the maximum value to 3
- Adding a default value indicator
- Adding tooltips to preview the spacing
- { lineheight: ['1', '1.2', '1.5', '1.75', '2', '3', '4', '5'] }, + { lineheight: [ + { value: '1', default: true }, + '1.2', + '1.5', + '1.75', + '2', + '3' + ] },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/docs/fluent-editor/demos/custom-toolbar.vue
(1 hunks)packages/fluent-editor/src/fluent-editor.ts
(1 hunks)
🔇 Additional comments (1)
packages/fluent-editor/src/fluent-editor.ts (1)
146-148
: Verify LineHeightStyle implementation and CSS conflicts
Please ensure:
- The LineHeightStyle implementation properly handles the line-height attribute
- There are no CSS conflicts with existing styles
✅ Verification successful
Let me gather more information about the line-height implementation.
Line-height implementation is properly integrated
The verification shows:
- LineHeightStyle is correctly implemented as a Parchment StyleAttributor with inline scope
- The format is properly registered in the editor
- CSS usage of line-height in the codebase is limited to component-specific styling and doesn't conflict with the format implementation
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check LineHeightStyle implementation
rg -A 10 "class LineHeightStyle"
# Check for potential CSS conflicts with line-height
rg "line-height" --type css
Length of output: 1358
Script:
#!/bin/bash
# Search for line-height format/style registration and implementation
rg -A 5 "line-height|lineHeight" --type ts
# Look for Quill format definitions
ast-grep --pattern 'format($$$)'
Length of output: 1380
'lineheight': function (value) { | ||
this.quill.format('line-height', value) | ||
}, |
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.
🛠️ Refactor suggestion
Add validation and error handling to line-height handler
The current implementation lacks value validation and error handling. Consider:
- Validating numeric values
- Adding error handling for invalid inputs
- Supporting value cleanup (reset to default)
'lineheight': function (value) {
+ // Reset to default if value is false or empty
+ if (!value) {
+ this.quill.format('line-height', false);
+ return;
+ }
+
+ // Validate numeric value
+ const numValue = parseFloat(value);
+ if (isNaN(numValue) || numValue < 1 || numValue > 5) {
+ console.warn(`Invalid line-height value: ${value}`);
+ return;
+ }
+
this.quill.format('line-height', value)
},
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
'lineheight': function (value) { | |
this.quill.format('line-height', value) | |
}, | |
'lineheight': function (value) { | |
// Reset to default if value is false or empty | |
if (!value) { | |
this.quill.format('line-height', false); | |
return; | |
} | |
// Validate numeric value | |
const numValue = parseFloat(value); | |
if (isNaN(numValue) || numValue < 1 || numValue > 5) { | |
console.warn(`Invalid line-height value: ${value}`); | |
return; | |
} | |
this.quill.format('line-height', value) | |
}, |
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #154
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit