-
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 'Cannot convert undefined or null to object' error when pasting content with header formatting #134
Conversation
…ing content with header formatting
WalkthroughThe pull request introduces several updates to the Changes
Possibly related PRs
Poem
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: 0
🧹 Outside diff range and nitpick comments (3)
packages/fluent-editor/src/table/utils/node-matchers.ts (3)
Line range hint
14-16
: Fix logical error inindexOf
condition when checking for'pt'
innode.style.height
The condition
if (node.style.height.indexOf('pt'))
fails to detect'pt'
when it is at the beginning of the string becauseindexOf
returns0
, which is falsy. To correctly check if'pt'
is present in the string, useif (node.style.height.indexOf('pt') !== -1)
orif (node.style.height.includes('pt'))
.Apply this fix to correct the condition:
- if (node.style.height.indexOf('pt')) { + if (node.style.height.includes('pt')) {
288-290
: Ensureop.attributes
is always an object before usingObject.assign
In the
matchHeader
function, when usingObject.assign({}, op.attributes, { size: fontSize })
, ifop.attributes
isundefined
ornull
, it may cause unexpected behavior. To prevent this, initializeop.attributes
to an empty object if it is not defined.Here's how you can modify the code:
delta.forEach((op) => { + const attributes = op.attributes || {}; newDelta.insert( op.insert, - Object.assign({}, op.attributes, { + Object.assign({}, attributes, { size: fontSize, }), ) })
Line range hint
329-340
: Add error handling for the asynchronoussearch
operation inmatchMentionLink
In the
matchMentionLink
function, the promise returned bymention.options.search(name)
lacks error handling. If the promise is rejected, it may lead to unhandled promise rejections. Consider adding a.catch()
method to handle any errors and improve the robustness of your code.Apply this change to include error handling:
mention.options.search(name).then((res) => { const [item] = res if (item) { mention.options.select(item) } + }).catch((error) => { + console.error('Error during mention search:', error) })
…y#108) refactor(table): optimize menuInitial method for better readability(opentiny#108) fix(table): ensure menu is fully visible when menuHeight + top > winHeight(opentiny#108) fix(table): Resolve merge conflicts(opentiny#108) fix: fix 'Cannot convert undefined or null to object' error when pasting content with header formatting (opentiny#134)
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: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
Bug Fixes
Refactor