-
Notifications
You must be signed in to change notification settings - Fork 349
fix(vue-renderless/fluent-editor): Fix lineheight formatting to use '… #4212
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
Open
cfljue
wants to merge
1
commit into
opentiny:dev
Choose a base branch
from
cfljue:cfl/fix-rich-editor-line-height
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: opentiny/tiny-vue
Length of output: 6246
🌐 Web query:
Quill.js line-height format registration and usage💡 Result:
Quill.js does not include a built-in line-height format, so you must implement it using Parchment, Quill's document model [1][2]. To add this functionality, you need to create a custom Attributor and register it with Quill [3][2]. Implementation Steps 1. Define the Attributor: Use Parchment's StyleAttributor to map a format name (e.g., 'line-height') to the CSS 'line-height' property [3][2]. const Parchment = Quill.import('parchment'); const LineHeightStyle = new Parchment.Attributor.Style('line-height', 'line-height', { scope: Parchment.Scope.INLINE, whitelist: ['1.0', '1.2', '1.5', '1.6', '1.8', '2.0'] // Define allowed values }); 2. Register the Format: Register the new attributor with Quill so it can be recognized in the editor [1][2]. Quill.register(LineHeightStyle, true); 3. Configure the Toolbar: To allow users to select line-height, add it to your toolbar configuration [3][4]. const quill = new Quill('
#editor', { modules: { toolbar: [ [{ 'line-height': ['1.0', '1.2', '1.5', '1.6', '1.8', '2.0'] }] ] } }); Usage Notes - Scope: Line-height is typically applied as an inline format [3][2]. Ensure your CSS handles the resulting span elements correctly, as applying line-height to inline elements may require setting display: inline-block or adjusting parent block styles to avoid layout issues [5][4]. - Customization: You can extend the whitelist to include any valid CSS line-height values [3][2]. If you need to handle specific DOM-to-Delta conversions (e.g., converting style strings to numbers), you can extend the Attributor class and override the value method [3]. - Toolbar Integration: If using a custom toolbar, ensure you have a handler that triggers the format command using the Quill API, such as quill.format('line-height', value) [4][6].Citations:
🌐 Web query:
tiny-vue fluent-editor Quill format registration line-height or lineheight custom Parchment💡 Result:
To implement custom line-height support in a Quill-based editor like Fluent Editor, you must define a custom Parchment Attributor and register it with the Quill instance [1][2]. 1. Define the Attributor: Create a custom class extending Parchment.StyleAttributor to manage the line-height style [1]. This allows the editor to apply the CSS line-height property to inline elements [1]. import { Parchment } from 'fluent-editor'; // or 'quill' const LineHeightStyle = new Parchment.Attributor.Style('line-height', 'line-height', { scope: Parchment.Scope.INLINE, whitelist: ['1', '1.5', '2', '2.5'] // Define your allowed values }); 2. Register the Format: Register this attributor with your Quill/Fluent Editor instance so the editor recognizes the new format [1][2]. import { Quill } from 'fluent-editor'; Quill.register(LineHeightStyle, true); 3. Integration: Once registered, you can add a custom dropdown or button to your toolbar that triggers the format command [3]. When the user selects a value, use the editor API to apply it: quill.format('line-height', '1.5'); Note: Fluent Editor (part of OpenTiny) has already implemented a LineHeightStyle attributor in its codebase [1]. If you are using Fluent Editor, check if you can leverage the existing implementation in packages/fluent-editor/src/attributors/line-height.ts rather than creating a new one [1]. If you are using standard Quill, the steps above are the standard approach for extending the document model [2]. Ensure your CSS handles the applied styles correctly, as Quill often wraps content in spans that may require display: inline-block for line-height to take effect on specific elements [4][3].
Citations:
🏁 Script executed:
Repository: opentiny/tiny-vue
Length of output: 965
🏁 Script executed:
Repository: opentiny/tiny-vue
Length of output: 1777
🏁 Script executed:
Repository: opentiny/tiny-vue
Length of output: 5009
🏁 Script executed:
Repository: opentiny/tiny-vue
Length of output: 3687
🏁 Script executed:
Repository: opentiny/tiny-vue
Length of output: 1900
🏁 Script executed:
Repository: opentiny/tiny-vue
Length of output: 485
Fix the format key mismatch between toolbar configuration and format call.
The toolbar configuration (line 69) defines the format as
lineheight(no hyphen):{ lineheight: lineHeightConfig }, but the handler at line 294 applies'line-height'(with hyphen):state.quill.format('line-height', ...). In Quill, these keys must match exactly. Either:'lineheight'to match the toolbar config, or{ 'line-height': lineHeightConfig }to match the format callAdditionally, verify that the format name aligns with how the line-height Parchment Attributor is registered in the FluentEditor instance.
🤖 Prompt for AI Agents
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.
@cfljue 机器人有个检视意见,可以看下哈
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.
@zzcr好的,我这边补充下关注点:当前主要是确认这次改成line-height后,是否和编辑器里实际注册的格式名一致。具体看这 3 处是否统一即可:
lineheightHandler里调用的 format keylineheight)FluentEditor/ Parchment 注册的 line-height 格式名如果底层注册名就是
line-height,那这次修改方向是对的,但最好确认 toolbar 配置链路也能正确命中;如果注册名仍是lineheight,那这里就需要保持一致。作者更新后我也可以再帮忙复看。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.
这个富文本框的封装链路是Quill、@opentiny/fluent-editor、opentiny,可以看到上两层的格式名是
line-height,只有openTiny使用lineheight且导致问题出现(opentiny官网可以看到)。这里只修改执行层格式,不修改调用或者说定义层,是为了把修改无感更新,避免已有的使用者出错